@hamster-note/components 0.2.1-beta.2 → 0.2.1-beta.3

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 CHANGED
@@ -106,27 +106,30 @@ const [anchor, setAnchor] = useState<HTMLElement | null>(null);
106
106
 
107
107
  <Button
108
108
  aria-expanded={open}
109
- aria-haspopup="menu"
109
+ aria-haspopup="dialog"
110
110
  onClick={(event) => {
111
111
  setAnchor(event.currentTarget);
112
112
  setOpen((value) => !value);
113
113
  }}
114
114
  >
115
- 编辑
115
+ 文字
116
116
  </Button>;
117
117
  {
118
118
  open ? (
119
- <Popover anchor={anchor} placement="bottom-start">
120
- <Menu>
121
- <MenuItem shortcut="⌘X">剪切</MenuItem>
122
- <MenuItem shortcut="⌘C">复制</MenuItem>
123
- </Menu>
119
+ <Popover anchor={anchor} aria-label="文字操作" placement="bottom-start" role="toolbar">
120
+ <Button size="small" variant="ghost">
121
+ 加粗
122
+ </Button>
123
+ <PopoverSeparator />
124
+ <Button size="small" variant="ghost">
125
+ 斜体
126
+ </Button>
124
127
  </Popover>
125
128
  ) : null;
126
129
  }
127
130
  ```
128
131
 
129
- `Menu` 提供语义菜单列表,可独立渲染,也可嵌入 `Popover` 当作下拉菜单使用。`MenuItem`
132
+ `Menu` 提供语义菜单列表,可独立渲染,也可传入 `anchor` 直接作为下拉菜单使用。`MenuItem`
130
133
  支持 `shortcut` 显示快捷键、`tone="danger"` 标记破坏性操作;`MenuLabel` 用于分组小标题,
131
134
  `MenuSeparator` 用于分组分隔线:
132
135
 
@@ -143,10 +146,13 @@ import { Menu, MenuItem, MenuLabel, MenuSeparator } from '@hamster-note/componen
143
146
  </Menu>;
144
147
  ```
145
148
 
146
- 嵌入 `Popover` 当作下拉菜单:`Menu` 复用全局颜色 token,自动继承 `Popover` 的 dark/light
147
- 主题,无需任何主题 prop。触发按钮需要设置 `aria-haspopup="menu"` 并用 `aria-controls` /
148
- `aria-expanded` 连接浮层(显示状态由使用方控制,与 `Popover` 哲学一致)。下拉菜单推荐
149
- 配合 `anchor` 使用(见上文锚点定位),让菜单渲染到 body 下并自动躲避视口边缘:
149
+ 传入 `anchor` 当作下拉菜单:`Menu` 进入锚定模式——经 Portal 渲染到 `document.body`
150
+ 下,`.hn-menu` 直接作为浮层表面(自动叠加 `.hn-menu--floating`:边框、阴影与 dark token
151
+ 覆盖;传 `data-theme="light"` 切换浅色),无需再外套 `Popover`。`placement` /
152
+ `anchorOffset` / `anchorCrossOffset` / `viewportMargin` 与 `Popover` 锚定模式语义一致,
153
+ 同样自动翻转并 clamp 到视口安全距离内。触发按钮需要设置 `aria-haspopup="menu"` 并用
154
+ `aria-controls` / `aria-expanded` 连接菜单(显示状态、外部点击关闭与焦点返回仍由使用方
155
+ 控制,与 `Popover` 哲学一致):
150
156
 
151
157
  ```tsx
152
158
  <Button aria-controls="file-menu" aria-expanded={open} aria-haspopup="menu" onClick={toggle}>
@@ -154,21 +160,19 @@ import { Menu, MenuItem, MenuLabel, MenuSeparator } from '@hamster-note/componen
154
160
  </Button>;
155
161
  {
156
162
  open ? (
157
- <Popover anchor={anchorEl} aria-label="编辑操作" id="file-menu">
158
- <Menu>
159
- <MenuItem shortcut="⌘X">剪切</MenuItem>
160
- <MenuItem shortcut="⌘C">复制</MenuItem>
161
- <MenuSeparator />
162
- <MenuItem tone="danger">清空选中</MenuItem>
163
- </Menu>
164
- </Popover>
163
+ <Menu anchor={anchorEl} aria-label="编辑操作" id="file-menu" ref={menuRef}>
164
+ <MenuItem shortcut="⌘X">剪切</MenuItem>
165
+ <MenuItem shortcut="⌘C">复制</MenuItem>
166
+ <MenuSeparator />
167
+ <MenuItem tone="danger">清空选中</MenuItem>
168
+ </Menu>
165
169
  ) : null;
166
170
  }
167
171
  ```
168
172
 
169
173
  `MenuSubmenu` 提供嵌套子菜单能力:trigger 复用 `MenuItem` 的视觉,右侧带 ▸ chevron;panel
170
- 复用 `Popover` 作为表面(自动继承 dark/light 主题,与 `Menu` 同样的复用哲学),内部再嵌一层
171
- `Menu` 承载子项。panel 经 Portal 渲染到 `document.body` 下,默认向 trigger 右侧展开,
174
+ 即一层锚定模式的 `Menu`(`.hn-menu` 直接作为浮层表面,自带边框 / 阴影与 dark token 覆盖,
175
+ 不再外套 `Popover`)。panel 经 Portal 渲染到 `document.body` 下,默认向 trigger 右侧展开,
172
176
  右侧空间不足时自动向左翻转,垂直方向 clamp 在视口安全距离内。鼠标悬停展开(带 150ms 开 /
173
177
  200ms 关延迟,避免移动缝隙误关),点击 trigger 切换(触屏 fallback);键盘上
174
178
  `ArrowRight`/`Enter`/`Space` 进入子菜单并把焦点送到第一个
@@ -402,8 +406,9 @@ import { Button, ThemeProvider } from '@hamster-note/components';
402
406
  `PopoverSeparator` 分组内容;`anchor` 模式下经 Portal 渲染到 body 并自动躲避视口边缘。
403
407
  - `Menu`:`role="menu"` 语义菜单列表,含 `MenuItem`(支持 `shortcut` 与 `danger` tone)、
404
408
  `MenuLabel`、`MenuSeparator` 与 `MenuSubmenu`(嵌套子菜单,panel 渲染到 body 下、
405
- 右侧不足自动左翻,复用 `Popover` 作为表面自动继承主题),可独立使用或嵌入 `Popover`
406
- 自动继承主题。
409
+ 右侧不足自动左翻,panel 即浮动 `Menu` 自身)。传入 `anchor` 后 `.hn-menu` 直接作为
410
+ 下拉浮层表面(自带边框 / 阴影与 dark token,可 `data-theme="light"`),无需外套
411
+ `Popover`;也可嵌入 `Popover` 自动继承主题。
407
412
  - `Kbd`:纯展示型快捷键键帽组件。`keys` 渲染组合键序列(键帽间用小号 `+` 连接符拼接),
408
413
  `children` 渲染单个键帽;颜色一律引用全局 token,嵌入 `Popover` 自动继承主题。
409
414
  - `Dialog`:受控模态对话框。Portal 渲染到 `document.body`,内置焦点循环、滚动锁、Esc /
@@ -9,7 +9,7 @@
9
9
  * 设计:单一数据源。IconName 类型从 ICON_NAMES 数组派生,避免数组与联合
10
10
  * 类型之间出现漂移。新增图标只需在数组里追加一个字面量。
11
11
  */
12
- /** 52 个图标名称字面量数组(运行时枚举与 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", "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
- /** 52 个图标的名称联合类型(从 ICON_NAMES 派生,单一数据源) */
12
+ /** 55 个图标名称字面量数组(运行时枚举与 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", "keyboard", "type", "handle", "card", "minimap", "font-size", "drag", "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
+ /** 55 个图标的名称联合类型(从 ICON_NAMES 派生,单一数据源) */
15
15
  export type IconName = (typeof ICON_NAMES)[number];
@@ -1,7 +1,15 @@
1
- import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
1
+ import { ButtonHTMLAttributes, HTMLAttributes, ReactNode, Ref } from 'react';
2
+ import { FloatingPlacement } from '../popover/use-anchor-position';
2
3
  export type MenuItemTone = 'default' | 'danger';
4
+ export type MenuPlacement = FloatingPlacement;
3
5
  export interface MenuProps extends HTMLAttributes<HTMLDivElement> {
4
6
  readonly children: ReactNode;
7
+ readonly anchor?: HTMLElement | null;
8
+ readonly placement?: MenuPlacement;
9
+ readonly anchorOffset?: number;
10
+ readonly anchorCrossOffset?: number;
11
+ readonly viewportMargin?: number;
12
+ readonly ref?: Ref<HTMLDivElement>;
5
13
  }
6
14
  export interface MenuItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
7
15
  readonly children: ReactNode;
@@ -18,7 +26,7 @@ export interface MenuSubmenuProps extends Omit<HTMLAttributes<HTMLDivElement>, '
18
26
  readonly 'aria-label'?: string;
19
27
  readonly disabled?: boolean;
20
28
  }
21
- export declare function Menu({ children, className, ...props }: MenuProps): import("react").JSX.Element;
29
+ export declare function Menu({ children, className, anchor, placement, anchorOffset, anchorCrossOffset, viewportMargin, ref, style, ...props }: MenuProps): import("react").JSX.Element;
22
30
  export declare function MenuItem({ children, className, shortcut, tone, type, ...props }: MenuItemProps): import("react").JSX.Element;
23
31
  export declare function MenuSeparator({ className, ...props }: MenuSeparatorProps): import("react").JSX.Element;
24
32
  export declare function MenuLabel({ children, className, ...props }: MenuLabelProps): 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';
@@ -1,2 +1,2 @@
1
- @layer hamster-note.tokens{:root{--hn-color-surface:#111114;--hn-color-surface-hover:#17171b;--hn-color-text:#f4f4f5;--hn-color-text-muted:#92929d;--hn-color-border:#ffffff1a;--hn-color-border-strong:#ffffff2b;--hn-color-accent:#7c83ff;--hn-color-accent-hover:#9197ff;--hn-color-danger:#fb7185;--hn-color-success:#4ade80;--hn-color-warning:#fbbf24;--hn-font-sans:"IBM Plex Sans", "Noto Sans SC", sans-serif;--hn-font-mono:"IBM Plex Mono", monospace;--hn-radius-sm:6px;--hn-radius-md:8px;--hn-radius-lg:12px;--hn-focus-ring:0 0 0 3px #9197ff6b;--hn-transition:.14s cubic-bezier(.2, .8, .2, 1)}}@layer hamster-note.components{.hn-badge{border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-sm);min-height:22px;font-family:var(--hn-font-mono);color:var(--hn-color-text-muted);background:#ffffff0a;align-items:center;gap:6px;padding:2px 8px;font-size:11px;font-weight:550;line-height:1.2;display:inline-flex}.hn-badge:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.hn-badge--accent{color:#aeb2ff;background:#7c83ff1a;border-color:#7c83ff3d}.hn-badge--success{color:var(--hn-color-success);background:#4ade8017;border-color:#4ade8038}.hn-badge--warning{color:var(--hn-color-warning);background:#fbbf2417;border-color:#fbbf2438}.hn-badge--danger{color:var(--hn-color-danger);background:#fb718517;border-color:#fb718538}.hn-button{border-radius:var(--hn-radius-md);min-height:36px;font-family:var(--hn-font-sans);color:var(--hn-color-text);cursor:pointer;transition:background-color var(--hn-transition), border-color var(--hn-transition), color var(--hn-transition), opacity var(--hn-transition);border:1px solid #0000;justify-content:center;align-items:center;gap:8px;padding:0 14px;font-size:13px;font-weight:600;line-height:1;display:inline-flex}.hn-button:focus-visible{box-shadow:var(--hn-focus-ring);outline:none}.hn-button:disabled{cursor:not-allowed;opacity:.42}.hn-button--primary{background:var(--hn-color-accent);color:#09090b}.hn-button--primary:hover:not(:disabled){background:var(--hn-color-accent-hover)}.hn-button--secondary{border-color:var(--hn-color-border);background:var(--hn-color-surface)}.hn-button--secondary:hover:not(:disabled){border-color:var(--hn-color-border-strong);background:var(--hn-color-surface-hover)}.hn-button--ghost{color:var(--hn-color-text-muted);background:0 0}.hn-button--ghost:hover:not(:disabled){background:var(--hn-color-surface-hover);color:var(--hn-color-text)}.hn-button--small{min-height:30px;padding:0 11px;font-size:12px}.hn-button--large{min-height:42px;padding:0 18px;font-size:14px}@media (prefers-reduced-motion:reduce){.hn-button{transition-duration:.01ms}}.hn-dialog__backdrop{z-index:1100;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:#00000073;transition:opacity .14s cubic-bezier(.2,.8,.2,1);position:fixed;inset:0}.hn-dialog__backdrop[data-state=enter]{opacity:1}.hn-dialog__backdrop[data-state=exit]{opacity:0}.hn-dialog__panel{z-index:1100;border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-lg);background:var(--hn-color-surface);width:auto;min-width:320px;max-width:calc(100vw - 32px);max-height:calc(100vh - 64px);color:var(--hn-color-text);font-family:var(--hn-font-sans);flex-direction:column;padding:20px 24px;transition:opacity .14s cubic-bezier(.2,.8,.2,1),transform .18s cubic-bezier(.2,.8,.2,1);display:flex;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:0 16px 48px #00000052}.hn-dialog__panel[data-state=enter]{opacity:1;transform:translate(-50%,-50%)}.hn-dialog__panel[data-state=exit],.hn-dialog__panel{opacity:0;transform:translate(-50%,calc(8px - 50%))}.hn-dialog__panel:focus-visible{box-shadow:var(--hn-focus-ring), 0 16px 48px #00000052;outline:none}.hn-dialog__title{letter-spacing:-.01em;color:var(--hn-color-text);margin:0 0 4px;font-size:18px;font-weight:550;line-height:1.45}.hn-dialog__description{color:var(--hn-color-text-muted);margin:0;font-size:13px;line-height:1.65}.hn-dialog__content{margin-top:16px}.hn-dialog__panel:not(:has(.hn-dialog__title)) .hn-dialog__content{margin-top:0}@media (prefers-reduced-motion:reduce){.hn-dialog__backdrop,.hn-dialog__panel{transition-duration:.01ms}}.hn-confirm__footer{justify-content:flex-end;gap:8px;margin-top:20px;display:flex}.hn-confirm__footer[data-tone=danger] .hn-button--primary{background:var(--hn-color-danger);color:#09090b}.hn-confirm__footer[data-tone=danger] .hn-button--primary:hover:not(:disabled){background:color-mix(in srgb, var(--hn-color-danger) 88%, white)}.hn-drawer__backdrop{z-index:1200;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:#00000073;transition:opacity .14s cubic-bezier(.2,.8,.2,1);position:fixed;inset:0}.hn-drawer__backdrop[data-state=enter]{opacity:1}.hn-drawer__backdrop[data-state=exit]{opacity:0}.hn-drawer__panel{z-index:1200;border:1px solid var(--hn-color-border);background:var(--hn-color-surface);max-width:100vw;max-height:100vh;color:var(--hn-color-text);font-family:var(--hn-font-sans);opacity:0;flex-direction:column;padding:20px 24px;transition:opacity .14s cubic-bezier(.2,.8,.2,1),transform .18s cubic-bezier(.2,.8,.2,1);display:flex;position:fixed;box-shadow:0 16px 48px #00000052}.hn-drawer__panel:focus-visible{box-shadow:var(--hn-focus-ring), 0 16px 48px #00000052;outline:none}.hn-drawer__panel--left,.hn-drawer__panel--right{width:var(--hn-drawer-size,360px);max-width:100vw;height:100vh;top:0;bottom:0}.hn-drawer__panel--left{border-radius:0 var(--hn-radius-lg) var(--hn-radius-lg) 0;left:0;transform:translate(-100%)}.hn-drawer__panel--right{border-radius:var(--hn-radius-lg) 0 0 var(--hn-radius-lg);right:0;transform:translate(100%)}.hn-drawer__panel--left[data-state=enter],.hn-drawer__panel--right[data-state=enter]{opacity:1;transform:translate(0)}.hn-drawer__panel--left[data-state=exit]{opacity:0;transform:translate(-100%)}.hn-drawer__panel--right[data-state=exit]{opacity:0;transform:translate(100%)}.hn-drawer__panel--top,.hn-drawer__panel--bottom{width:100vw;height:var(--hn-drawer-size,280px);max-height:100vh;left:0;right:0}.hn-drawer__panel--top{border-radius:0 0 var(--hn-radius-lg) var(--hn-radius-lg);top:0;transform:translateY(-100%)}.hn-drawer__panel--bottom{border-radius:var(--hn-radius-lg) var(--hn-radius-lg) 0 0;bottom:0;transform:translateY(100%)}.hn-drawer__panel--top[data-state=enter],.hn-drawer__panel--bottom[data-state=enter]{opacity:1;transform:translateY(0)}.hn-drawer__panel--top[data-state=exit]{opacity:0;transform:translateY(-100%)}.hn-drawer__panel--bottom[data-state=exit]{opacity:0;transform:translateY(100%)}.hn-drawer__title{letter-spacing:-.01em;color:var(--hn-color-text);margin:0 0 4px;font-size:18px;font-weight:550;line-height:1.45}.hn-drawer__description{color:var(--hn-color-text-muted);margin:0;font-size:13px;line-height:1.65}.hn-drawer__content{flex:auto;margin-top:16px;overflow:auto}.hn-drawer__panel:not(:has(.hn-drawer__title)) .hn-drawer__content{margin-top:0}@media (prefers-reduced-motion:reduce){.hn-drawer__backdrop,.hn-drawer__panel{transition-duration:.01ms}}.hn-icon{vertical-align:-.125em;pointer-events:none;flex-shrink:0;justify-content:center;align-items:center;line-height:0;display:inline-flex}.hn-kbd{font-family:var(--hn-font-mono);color:var(--hn-color-text);white-space:nowrap;vertical-align:baseline;align-items:center;gap:4px;font-size:11px;line-height:1;display:inline-flex}.hn-kbd__key{border:1px solid color-mix(in srgb, var(--hn-color-text) 22%, transparent);border-radius:var(--hn-radius-sm);background:var(--hn-color-surface-hover);min-width:18px;color:var(--hn-color-text);vertical-align:baseline;white-space:nowrap;-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;padding:2px 6px;font-family:inherit;font-size:11px;font-weight:500;line-height:1;display:inline-flex;box-shadow:inset 0 -1px #0000001f}.hn-kbd__plus{color:var(--hn-color-text-muted);-webkit-user-select:none;user-select:none;font-family:inherit;font-size:11px;font-weight:400;line-height:1}.hn-loading{color:var(--hn-color-accent);font-family:var(--hn-font-sans);justify-content:center;align-items:center;gap:8px;line-height:0;display:inline-flex}.hn-loading__spinner{animation:hn-loading-spin var(--hn-loading-duration,.9s) linear infinite;transform-origin:50%;flex-shrink:0;display:block}.hn-loading__text{color:var(--hn-color-text-muted);white-space:nowrap;font-size:13px;line-height:1.5}.hn-loading--small .hn-loading__text{font-size:12px}.hn-loading--large .hn-loading__text{font-size:14px}.hn-loading--cover{background:color-mix(in srgb, var(--hn-color-surface) 72%, transparent);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);border-radius:inherit;color:var(--hn-color-accent);flex-direction:column;gap:12px;position:absolute;inset:0}.hn-loading--cover .hn-loading__text{color:var(--hn-color-text)}.hn-loading-overlay{z-index:1200;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);color:var(--hn-color-accent);font-family:var(--hn-font-sans);background:#00000073;flex-direction:column;justify-content:center;align-items:center;gap:14px;animation:.14s cubic-bezier(.2,.8,.2,1) hn-loading-overlay-fade;display:flex;position:fixed;inset:0}.hn-loading-overlay .hn-loading__text{color:var(--hn-color-text);font-size:14px}@keyframes hn-loading-spin{to{transform:rotate(360deg)}}@keyframes hn-loading-overlay-fade{0%{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.hn-loading__spinner{animation-duration:2.4s;animation-timing-function:steps(12,end)}.hn-loading-overlay{animation-duration:.01ms}}.hn-popover{--hn-popover-background:#1e293bcc;--hn-popover-border:#ffffff1a;--hn-popover-separator:#ffffff2e;--hn-color-surface:#111114;--hn-color-surface-hover:#ffffff1a;--hn-color-text:#f8fafc;--hn-color-text-muted:#cbd5e1;--hn-color-border:#ffffff1a;--hn-color-border-strong:#ffffff2b;--hn-popover-padding:5px;max-width:100%;padding:var(--hn-popover-padding);border:1px solid var(--hn-popover-border);border-radius:calc(var(--hn-radius-md) + var(--hn-popover-padding));background:var(--hn-popover-background);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);color:var(--hn-color-text);font-family:var(--hn-font-sans);align-items:center;gap:3px;display:inline-flex;box-shadow:0 8px 24px #0f172a47}.hn-popover[data-theme=light]{--hn-popover-background:#fffc;--hn-popover-border:#0f172a1f;--hn-popover-separator:#0f172a29;--hn-color-surface:#fff;--hn-color-surface-hover:#f1f5f9;--hn-color-text:#1e293b;--hn-color-text-muted:#64748b;--hn-color-border:#0000001a;--hn-color-border-strong:#0000002e;box-shadow:0 8px 24px #0f172a29}.hn-popover--floating{z-index:1000}.hn-popover[data-orientation=vertical]{flex-direction:column}.hn-popover__separator{background:var(--hn-popover-separator);border:0;flex:0 0 1px;width:1px;height:20px;margin:0 4px;padding:0}.hn-popover[data-orientation=vertical] .hn-popover__separator{flex:0 0 1px;width:20px;height:1px;margin:4px 0}.hn-menu{min-width:180px;font-family:var(--hn-font-sans);color:var(--hn-color-text);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border-radius:var(--hn-radius-md);background:#1e293bcc;flex-direction:column;gap:2px;padding:4px;display:flex}.hn-menu__item{border-radius:var(--hn-radius-md);width:100%;min-height:32px;color:var(--hn-color-text);cursor:pointer;text-align:left;transition:background-color var(--hn-transition), color var(--hn-transition);background:0 0;border:0;justify-content:space-between;align-items:center;gap:12px;padding:0 10px;font-size:13px;line-height:1;display:flex}.hn-menu__item:hover:not(:disabled){background:var(--hn-color-surface-hover)}.hn-menu__item:focus-visible{box-shadow:var(--hn-focus-ring);outline:none}.hn-menu__item:disabled{cursor:not-allowed;opacity:.42}.hn-menu__item--danger{color:var(--hn-color-danger)}.hn-menu__item-label{flex:auto;min-width:0}.hn-menu__shortcut{font:400 11px/1 var(--hn-font-mono);color:var(--hn-color-text-muted);flex-shrink:0;align-items:center;display:inline-flex}.hn-menu__separator{background:var(--hn-popover-separator,var(--hn-color-border));border:0;height:1px;margin:4px 2px}.hn-menu__label{color:var(--hn-color-text-muted);-webkit-user-select:none;user-select:none;padding:4px 10px 2px;font-size:11px;line-height:1}.hn-menu__submenu{display:block}.hn-menu__submenu--open>.hn-menu__submenu-trigger{background:var(--hn-color-surface-hover)}.hn-menu__submenu-chevron{font:400 11px/1 var(--hn-font-sans);color:var(--hn-color-text-muted);transition:transform var(--hn-transition);flex-shrink:0;align-items:center;display:inline-flex}.hn-menu__submenu--open>.hn-menu__submenu-trigger .hn-menu__submenu-chevron{transform:rotate(90deg)}.hn-menu__submenu-panel{z-index:1000}.hn-menu__submenu-panel .hn-menu{min-width:160px}@media (prefers-reduced-motion:reduce){.hn-menu__item,.hn-menu__submenu-chevron{transition-duration:.01ms}}.hn-note-card{box-sizing:border-box;border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-lg);background:var(--hn-color-surface);width:100%;font-family:var(--hn-font-sans);color:var(--hn-color-text);text-align:left;transition:background-color var(--hn-transition), border-color var(--hn-transition), transform .18s cubic-bezier(.2, .8, .2, 1);gap:14px;padding:18px;display:grid;position:relative}.hn-note-card__action{z-index:1;border-radius:inherit;cursor:pointer;background:0 0;border:0;position:absolute;inset:0}.hn-note-card--interactive:has(.hn-note-card__action:hover){border-color:var(--hn-color-border-strong);background:var(--hn-color-surface-hover);transform:translateY(-1px)}.hn-note-card--interactive:has(.hn-note-card__action:focus-visible){box-shadow:var(--hn-focus-ring);outline:none}.hn-note-card__action:focus-visible{outline:none}.hn-note-card--selected{background:#7c83ff14;border-color:#7c83ff73}.hn-note-card__heading{gap:5px;display:grid}.hn-note-card__title,.hn-note-card__excerpt,.hn-note-card__meta{margin:0}.hn-note-card__title{letter-spacing:-.01em;font-size:15px;font-weight:600;line-height:1.35}.hn-note-card__excerpt{color:var(--hn-color-text-muted);text-wrap:pretty;font-size:13px;line-height:1.6}.hn-note-card__meta{font-family:var(--hn-font-mono);color:#70707b;font-size:11px;line-height:1.4}@media (prefers-reduced-motion:reduce){.hn-note-card{transition-duration:.01ms}}.hn-text-field{width:100%;font-family:var(--hn-font-sans);gap:7px;display:grid}.hn-text-field__label{color:var(--hn-color-text);font-size:12px;font-weight:600;line-height:1.3}.hn-text-field__control{box-sizing:border-box;border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-md);background:var(--hn-color-surface);width:100%;min-height:38px;font:400 14px/1.4 var(--hn-font-sans);color:var(--hn-color-text);transition:border-color var(--hn-transition), background-color var(--hn-transition), box-shadow var(--hn-transition);outline:none;padding:8px 11px}.hn-text-field__control::placeholder{color:#666670}.hn-text-field__control:hover:not(:disabled){border-color:var(--hn-color-border-strong)}.hn-text-field__control:focus-visible{border-color:var(--hn-color-accent);background:var(--hn-color-surface-hover);box-shadow:var(--hn-focus-ring);outline:none}.hn-text-field__control:disabled{cursor:not-allowed;opacity:.48}.hn-text-field--invalid .hn-text-field__control{border-color:#fb718599}.hn-text-field__message{color:var(--hn-color-text-muted);margin:0;font-size:12px;line-height:1.4}.hn-text-field--invalid .hn-text-field__message{color:var(--hn-color-danger)}@media (prefers-reduced-motion:reduce){.hn-text-field__control{transition-duration:.01ms}}.hn-theme{display:contents}.hn-theme[data-accent=custom]{--hn-color-accent-hover:color-mix(in srgb, var(--hn-color-accent), #fff 16%);--hn-focus-ring:0 0 0 3px color-mix(in srgb, var(--hn-color-accent) 42%, transparent)}}.hn-theme[data-mode=light]{--hn-color-surface:#fff;--hn-color-surface-hover:#f4f4f6;--hn-color-text:#18181b;--hn-color-text-muted:#63636d;--hn-color-border:#0000001a;--hn-color-border-strong:#0000002e;--hn-color-danger:#e11d48;--hn-color-success:#16a34a;--hn-color-warning:#d97706}.hn-theme[data-mode=dark]{--hn-color-surface:#111114;--hn-color-surface-hover:#17171b;--hn-color-text:#f4f4f5;--hn-color-text-muted:#92929d;--hn-color-border:#ffffff1a;--hn-color-border-strong:#ffffff2b;--hn-color-danger:#fb7185;--hn-color-success:#4ade80;--hn-color-warning:#fbbf24}
1
+ @layer hamster-note.tokens{:root{--hn-color-surface:#111114;--hn-color-surface-hover:#17171b;--hn-color-text:#f4f4f5;--hn-color-text-muted:#92929d;--hn-color-border:#ffffff1a;--hn-color-border-strong:#ffffff2b;--hn-color-accent:#7c83ff;--hn-color-accent-hover:#9197ff;--hn-color-danger:#fb7185;--hn-color-success:#4ade80;--hn-color-warning:#fbbf24;--hn-font-sans:"IBM Plex Sans", "Noto Sans SC", sans-serif;--hn-font-mono:"IBM Plex Mono", monospace;--hn-radius-sm:6px;--hn-radius-md:8px;--hn-radius-lg:12px;--hn-focus-ring:0 0 0 3px #9197ff6b;--hn-transition:.14s cubic-bezier(.2, .8, .2, 1)}}@layer hamster-note.components{.hn-badge{border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-sm);min-height:22px;font-family:var(--hn-font-mono);color:var(--hn-color-text-muted);background:#ffffff0a;align-items:center;gap:6px;padding:2px 8px;font-size:11px;font-weight:550;line-height:1.2;display:inline-flex}.hn-badge:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.hn-badge--accent{color:#aeb2ff;background:#7c83ff1a;border-color:#7c83ff3d}.hn-badge--success{color:var(--hn-color-success);background:#4ade8017;border-color:#4ade8038}.hn-badge--warning{color:var(--hn-color-warning);background:#fbbf2417;border-color:#fbbf2438}.hn-badge--danger{color:var(--hn-color-danger);background:#fb718517;border-color:#fb718538}.hn-button{border-radius:var(--hn-radius-md);min-height:36px;font-family:var(--hn-font-sans);color:var(--hn-color-text);cursor:pointer;transition:background-color var(--hn-transition), border-color var(--hn-transition), color var(--hn-transition), opacity var(--hn-transition);border:1px solid #0000;justify-content:center;align-items:center;gap:8px;padding:0 14px;font-size:13px;font-weight:600;line-height:1;display:inline-flex}.hn-button:focus-visible{box-shadow:var(--hn-focus-ring);outline:none}.hn-button:disabled{cursor:not-allowed;opacity:.42}.hn-button--primary{background:var(--hn-color-accent);color:#09090b}.hn-button--primary:hover:not(:disabled){background:var(--hn-color-accent-hover)}.hn-button--secondary{border-color:var(--hn-color-border);background:var(--hn-color-surface)}.hn-button--secondary:hover:not(:disabled){border-color:var(--hn-color-border-strong);background:var(--hn-color-surface-hover)}.hn-button--ghost{color:var(--hn-color-text-muted);background:0 0}.hn-button--ghost:hover:not(:disabled){background:var(--hn-color-surface-hover);color:var(--hn-color-text)}.hn-button--small{min-height:30px;padding:0 11px;font-size:12px}.hn-button--large{min-height:42px;padding:0 18px;font-size:14px}@media (prefers-reduced-motion:reduce){.hn-button{transition-duration:.01ms}}.hn-dialog__backdrop{z-index:1100;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:#00000073;transition:opacity .14s cubic-bezier(.2,.8,.2,1);position:fixed;inset:0}.hn-dialog__backdrop[data-state=enter]{opacity:1}.hn-dialog__backdrop[data-state=exit]{opacity:0}.hn-dialog__panel{z-index:1100;border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-lg);background:var(--hn-color-surface);width:auto;min-width:320px;max-width:calc(100vw - 32px);max-height:calc(100vh - 64px);color:var(--hn-color-text);font-family:var(--hn-font-sans);flex-direction:column;padding:20px 24px;transition:opacity .14s cubic-bezier(.2,.8,.2,1),transform .18s cubic-bezier(.2,.8,.2,1);display:flex;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:0 16px 48px #00000052}.hn-dialog__panel[data-state=enter]{opacity:1;transform:translate(-50%,-50%)}.hn-dialog__panel[data-state=exit],.hn-dialog__panel{opacity:0;transform:translate(-50%,calc(8px - 50%))}.hn-dialog__panel:focus-visible{box-shadow:var(--hn-focus-ring), 0 16px 48px #00000052;outline:none}.hn-dialog__title{letter-spacing:-.01em;color:var(--hn-color-text);margin:0 0 4px;font-size:18px;font-weight:550;line-height:1.45}.hn-dialog__description{color:var(--hn-color-text-muted);margin:0;font-size:13px;line-height:1.65}.hn-dialog__content{margin-top:16px}.hn-dialog__panel:not(:has(.hn-dialog__title)) .hn-dialog__content{margin-top:0}@media (prefers-reduced-motion:reduce){.hn-dialog__backdrop,.hn-dialog__panel{transition-duration:.01ms}}.hn-confirm__footer{justify-content:flex-end;gap:8px;margin-top:20px;display:flex}.hn-confirm__footer[data-tone=danger] .hn-button--primary{background:var(--hn-color-danger);color:#09090b}.hn-confirm__footer[data-tone=danger] .hn-button--primary:hover:not(:disabled){background:color-mix(in srgb, var(--hn-color-danger) 88%, white)}.hn-drawer__backdrop{z-index:1200;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:#00000073;transition:opacity .14s cubic-bezier(.2,.8,.2,1);position:fixed;inset:0}.hn-drawer__backdrop[data-state=enter]{opacity:1}.hn-drawer__backdrop[data-state=exit]{opacity:0}.hn-drawer__panel{z-index:1200;border:1px solid var(--hn-color-border);background:var(--hn-color-surface);max-width:100vw;max-height:100vh;color:var(--hn-color-text);font-family:var(--hn-font-sans);opacity:0;flex-direction:column;padding:20px 24px;transition:opacity .14s cubic-bezier(.2,.8,.2,1),transform .18s cubic-bezier(.2,.8,.2,1);display:flex;position:fixed;box-shadow:0 16px 48px #00000052}.hn-drawer__panel:focus-visible{box-shadow:var(--hn-focus-ring), 0 16px 48px #00000052;outline:none}.hn-drawer__panel--left,.hn-drawer__panel--right{width:var(--hn-drawer-size,360px);max-width:100vw;height:100vh;top:0;bottom:0}.hn-drawer__panel--left{border-radius:0 var(--hn-radius-lg) var(--hn-radius-lg) 0;left:0;transform:translate(-100%)}.hn-drawer__panel--right{border-radius:var(--hn-radius-lg) 0 0 var(--hn-radius-lg);right:0;transform:translate(100%)}.hn-drawer__panel--left[data-state=enter],.hn-drawer__panel--right[data-state=enter]{opacity:1;transform:translate(0)}.hn-drawer__panel--left[data-state=exit]{opacity:0;transform:translate(-100%)}.hn-drawer__panel--right[data-state=exit]{opacity:0;transform:translate(100%)}.hn-drawer__panel--top,.hn-drawer__panel--bottom{width:100vw;height:var(--hn-drawer-size,280px);max-height:100vh;left:0;right:0}.hn-drawer__panel--top{border-radius:0 0 var(--hn-radius-lg) var(--hn-radius-lg);top:0;transform:translateY(-100%)}.hn-drawer__panel--bottom{border-radius:var(--hn-radius-lg) var(--hn-radius-lg) 0 0;bottom:0;transform:translateY(100%)}.hn-drawer__panel--top[data-state=enter],.hn-drawer__panel--bottom[data-state=enter]{opacity:1;transform:translateY(0)}.hn-drawer__panel--top[data-state=exit]{opacity:0;transform:translateY(-100%)}.hn-drawer__panel--bottom[data-state=exit]{opacity:0;transform:translateY(100%)}.hn-drawer__title{letter-spacing:-.01em;color:var(--hn-color-text);margin:0 0 4px;font-size:18px;font-weight:550;line-height:1.45}.hn-drawer__description{color:var(--hn-color-text-muted);margin:0;font-size:13px;line-height:1.65}.hn-drawer__content{flex:auto;margin-top:16px;overflow:auto}.hn-drawer__panel:not(:has(.hn-drawer__title)) .hn-drawer__content{margin-top:0}@media (prefers-reduced-motion:reduce){.hn-drawer__backdrop,.hn-drawer__panel{transition-duration:.01ms}}.hn-icon{vertical-align:-.125em;pointer-events:none;flex-shrink:0;justify-content:center;align-items:center;line-height:0;display:inline-flex}.hn-kbd{font-family:var(--hn-font-mono);color:var(--hn-color-text);white-space:nowrap;vertical-align:baseline;align-items:center;gap:4px;font-size:11px;line-height:1;display:inline-flex}.hn-kbd__key{border:1px solid color-mix(in srgb, var(--hn-color-text) 22%, transparent);border-radius:var(--hn-radius-sm);background:var(--hn-color-surface-hover);min-width:18px;color:var(--hn-color-text);vertical-align:baseline;white-space:nowrap;-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;padding:2px 6px;font-family:inherit;font-size:11px;font-weight:500;line-height:1;display:inline-flex;box-shadow:inset 0 -1px #0000001f}.hn-kbd__plus{color:var(--hn-color-text-muted);-webkit-user-select:none;user-select:none;font-family:inherit;font-size:11px;font-weight:400;line-height:1}.hn-loading{color:var(--hn-color-accent);font-family:var(--hn-font-sans);justify-content:center;align-items:center;gap:8px;line-height:0;display:inline-flex}.hn-loading__spinner{animation:hn-loading-spin var(--hn-loading-duration,.9s) linear infinite;transform-origin:50%;flex-shrink:0;display:block}.hn-loading__text{color:var(--hn-color-text-muted);white-space:nowrap;font-size:13px;line-height:1.5}.hn-loading--small .hn-loading__text{font-size:12px}.hn-loading--large .hn-loading__text{font-size:14px}.hn-loading--cover{background:color-mix(in srgb, var(--hn-color-surface) 72%, transparent);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);border-radius:inherit;color:var(--hn-color-accent);flex-direction:column;gap:12px;position:absolute;inset:0}.hn-loading--cover .hn-loading__text{color:var(--hn-color-text)}.hn-loading-overlay{z-index:1200;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);color:var(--hn-color-accent);font-family:var(--hn-font-sans);background:#00000073;flex-direction:column;justify-content:center;align-items:center;gap:14px;animation:.14s cubic-bezier(.2,.8,.2,1) hn-loading-overlay-fade;display:flex;position:fixed;inset:0}.hn-loading-overlay .hn-loading__text{color:var(--hn-color-text);font-size:14px}@keyframes hn-loading-spin{to{transform:rotate(360deg)}}@keyframes hn-loading-overlay-fade{0%{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.hn-loading__spinner{animation-duration:2.4s;animation-timing-function:steps(12,end)}.hn-loading-overlay{animation-duration:.01ms}}.hn-menu{--hn-menu-background:#1e293bcc;min-width:180px;font-family:var(--hn-font-sans);color:var(--hn-color-text);background:var(--hn-menu-background);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border-radius:var(--hn-radius-md);flex-direction:column;gap:2px;padding:4px;display:flex}.hn-menu--floating{--hn-menu-border:#ffffff1a;--hn-popover-separator:#ffffff2e;--hn-color-surface-hover:#ffffff1a;--hn-color-text:#f8fafc;--hn-color-text-muted:#cbd5e1;z-index:1000;border:1px solid var(--hn-menu-border);border-radius:calc(var(--hn-radius-md) + 5px);padding:5px;box-shadow:0 8px 24px #0f172a47}.hn-menu--floating[data-theme=light]{--hn-menu-background:#fffc;--hn-menu-border:#0f172a1f;--hn-popover-separator:#0f172a29;--hn-color-surface-hover:#f1f5f9;--hn-color-text:#1e293b;--hn-color-text-muted:#64748b;box-shadow:0 8px 24px #0f172a29}.hn-menu__item{border-radius:var(--hn-radius-md);width:100%;min-height:32px;color:var(--hn-color-text);cursor:pointer;text-align:left;transition:background-color var(--hn-transition), color var(--hn-transition);background:0 0;border:0;justify-content:space-between;align-items:center;gap:12px;padding:0 10px;font-size:13px;line-height:1;display:flex}.hn-menu__item:hover:not(:disabled){background:var(--hn-color-surface-hover)}.hn-menu__item:focus-visible{box-shadow:var(--hn-focus-ring);outline:none}.hn-menu__item:disabled{cursor:not-allowed;opacity:.42}.hn-menu__item--danger{color:var(--hn-color-danger)}.hn-menu__item-label{flex:auto;min-width:0}.hn-menu__shortcut{font:400 11px/1 var(--hn-font-mono);color:var(--hn-color-text-muted);flex-shrink:0;align-items:center;display:inline-flex}.hn-menu__separator{background:var(--hn-popover-separator,var(--hn-color-border));border:0;height:1px;margin:4px 2px}.hn-menu__label{color:var(--hn-color-text-muted);-webkit-user-select:none;user-select:none;padding:4px 10px 2px;font-size:11px;line-height:1}.hn-menu__submenu{display:block}.hn-menu__submenu--open>.hn-menu__submenu-trigger{background:var(--hn-color-surface-hover)}.hn-menu__submenu-chevron{font:400 11px/1 var(--hn-font-sans);color:var(--hn-color-text-muted);transition:transform var(--hn-transition);flex-shrink:0;align-items:center;display:inline-flex}.hn-menu__submenu--open>.hn-menu__submenu-trigger .hn-menu__submenu-chevron{transform:rotate(90deg)}.hn-menu__submenu-panel{min-width:160px}@media (prefers-reduced-motion:reduce){.hn-menu__item,.hn-menu__submenu-chevron{transition-duration:.01ms}}.hn-note-card{box-sizing:border-box;border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-lg);background:var(--hn-color-surface);width:100%;font-family:var(--hn-font-sans);color:var(--hn-color-text);text-align:left;transition:background-color var(--hn-transition), border-color var(--hn-transition), transform .18s cubic-bezier(.2, .8, .2, 1);gap:14px;padding:18px;display:grid;position:relative}.hn-note-card__action{z-index:1;border-radius:inherit;cursor:pointer;background:0 0;border:0;position:absolute;inset:0}.hn-note-card--interactive:has(.hn-note-card__action:hover){border-color:var(--hn-color-border-strong);background:var(--hn-color-surface-hover);transform:translateY(-1px)}.hn-note-card--interactive:has(.hn-note-card__action:focus-visible){box-shadow:var(--hn-focus-ring);outline:none}.hn-note-card__action:focus-visible{outline:none}.hn-note-card--selected{background:#7c83ff14;border-color:#7c83ff73}.hn-note-card__heading{gap:5px;display:grid}.hn-note-card__title,.hn-note-card__excerpt,.hn-note-card__meta{margin:0}.hn-note-card__title{letter-spacing:-.01em;font-size:15px;font-weight:600;line-height:1.35}.hn-note-card__excerpt{color:var(--hn-color-text-muted);text-wrap:pretty;font-size:13px;line-height:1.6}.hn-note-card__meta{font-family:var(--hn-font-mono);color:#70707b;font-size:11px;line-height:1.4}@media (prefers-reduced-motion:reduce){.hn-note-card{transition-duration:.01ms}}.hn-popover{--hn-popover-background:#1e293bcc;--hn-popover-border:#ffffff1a;--hn-popover-separator:#ffffff2e;--hn-color-surface:#111114;--hn-color-surface-hover:#ffffff1a;--hn-color-text:#f8fafc;--hn-color-text-muted:#cbd5e1;--hn-color-border:#ffffff1a;--hn-color-border-strong:#ffffff2b;--hn-popover-padding:5px;max-width:100%;padding:var(--hn-popover-padding);border:1px solid var(--hn-popover-border);border-radius:calc(var(--hn-radius-md) + var(--hn-popover-padding));background:var(--hn-popover-background);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);color:var(--hn-color-text);font-family:var(--hn-font-sans);align-items:center;gap:3px;display:inline-flex;box-shadow:0 8px 24px #0f172a47}.hn-popover[data-theme=light]{--hn-popover-background:#fffc;--hn-popover-border:#0f172a1f;--hn-popover-separator:#0f172a29;--hn-color-surface:#fff;--hn-color-surface-hover:#f1f5f9;--hn-color-text:#1e293b;--hn-color-text-muted:#64748b;--hn-color-border:#0000001a;--hn-color-border-strong:#0000002e;box-shadow:0 8px 24px #0f172a29}.hn-popover--floating{z-index:1000}.hn-popover[data-orientation=vertical]{flex-direction:column}.hn-popover__separator{background:var(--hn-popover-separator);border:0;flex:0 0 1px;width:1px;height:20px;margin:0 4px;padding:0}.hn-popover[data-orientation=vertical] .hn-popover__separator{flex:0 0 1px;width:20px;height:1px;margin:4px 0}.hn-text-field{width:100%;font-family:var(--hn-font-sans);gap:7px;display:grid}.hn-text-field__label{color:var(--hn-color-text);font-size:12px;font-weight:600;line-height:1.3}.hn-text-field__control{box-sizing:border-box;border:1px solid var(--hn-color-border);border-radius:var(--hn-radius-md);background:var(--hn-color-surface);width:100%;min-height:38px;font:400 14px/1.4 var(--hn-font-sans);color:var(--hn-color-text);transition:border-color var(--hn-transition), background-color var(--hn-transition), box-shadow var(--hn-transition);outline:none;padding:8px 11px}.hn-text-field__control::placeholder{color:#666670}.hn-text-field__control:hover:not(:disabled){border-color:var(--hn-color-border-strong)}.hn-text-field__control:focus-visible{border-color:var(--hn-color-accent);background:var(--hn-color-surface-hover);box-shadow:var(--hn-focus-ring);outline:none}.hn-text-field__control:disabled{cursor:not-allowed;opacity:.48}.hn-text-field--invalid .hn-text-field__control{border-color:#fb718599}.hn-text-field__message{color:var(--hn-color-text-muted);margin:0;font-size:12px;line-height:1.4}.hn-text-field--invalid .hn-text-field__message{color:var(--hn-color-danger)}@media (prefers-reduced-motion:reduce){.hn-text-field__control{transition-duration:.01ms}}.hn-theme{display:contents}.hn-theme[data-accent=custom]{--hn-color-accent-hover:color-mix(in srgb, var(--hn-color-accent), #fff 16%);--hn-focus-ring:0 0 0 3px color-mix(in srgb, var(--hn-color-accent) 42%, transparent)}}.hn-theme[data-mode=light]{--hn-color-surface:#fff;--hn-color-surface-hover:#f4f4f6;--hn-color-text:#18181b;--hn-color-text-muted:#63636d;--hn-color-border:#0000001a;--hn-color-border-strong:#0000002e;--hn-color-danger:#e11d48;--hn-color-success:#16a34a;--hn-color-warning:#d97706}.hn-theme[data-mode=dark]{--hn-color-surface:#111114;--hn-color-surface-hover:#17171b;--hn-color-text:#f4f4f5;--hn-color-text-muted:#92929d;--hn-color-border:#ffffff1a;--hn-color-border-strong:#ffffff2b;--hn-color-danger:#fb7185;--hn-color-success:#4ade80;--hn-color-warning:#fbbf24}
2
2
  /*$vite$:1*/
@@ -281,6 +281,35 @@ var r = {
281
281
  /* @__PURE__ */ t("path", { d: "M7 14h6" }),
282
282
  /* @__PURE__ */ t("path", { d: "M7 17h4" })
283
283
  ] }),
284
+ minimap: /* @__PURE__ */ n(e, { children: [
285
+ /* @__PURE__ */ t("rect", {
286
+ height: "18",
287
+ rx: "2",
288
+ width: "18",
289
+ x: "3",
290
+ y: "3"
291
+ }),
292
+ /* @__PURE__ */ t("rect", {
293
+ height: "7",
294
+ rx: "1",
295
+ width: "9",
296
+ x: "7",
297
+ y: "7"
298
+ }),
299
+ /* @__PURE__ */ t("path", { d: "M7 17h6" })
300
+ ] }),
301
+ "font-size": /* @__PURE__ */ n(e, { children: [
302
+ /* @__PURE__ */ t("path", { d: "M5 16L9 7l4 9" }),
303
+ /* @__PURE__ */ t("path", { d: "M6.5 13h5" }),
304
+ /* @__PURE__ */ t("path", { d: "M15 18l2.5-5 2.5 5" }),
305
+ /* @__PURE__ */ t("path", { d: "M16 16.5h3" })
306
+ ] }),
307
+ drag: /* @__PURE__ */ n(e, { children: [
308
+ /* @__PURE__ */ t("path", { d: "M18 11V6a2 2 0 0 0-4 0v5" }),
309
+ /* @__PURE__ */ t("path", { d: "M14 10V4a2 2 0 0 0-4 0v6" }),
310
+ /* @__PURE__ */ t("path", { d: "M10 10.5V6a2 2 0 0 0-4 0v8" }),
311
+ /* @__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" })
312
+ ] }),
284
313
  search: /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("circle", {
285
314
  cx: "11",
286
315
  cy: "11",
@@ -483,6 +512,6 @@ function i({ label: e, name: n, className: i, ...a }) {
483
512
  }
484
513
  //#endregion
485
514
  //#region src/components/icon/icon-names.ts
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(".");
515
+ 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.minimap.font-size.drag.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
516
  //#endregion
488
517
  export { i as n, a as t };
package/dist/icon.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./icon-DUpDkTEa.js";
1
+ import { n as e, t } from "./icon-DNZLJUqH.js";
2
2
  export { t as ICON_NAMES, e as Icon };
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export type { KbdProps } from './components/kbd';
14
14
  export { Kbd } from './components/kbd';
15
15
  export type { LoadingOptions, LoadingProps, LoadingSize } from './components/loading';
16
16
  export { Loading, hideLoading, showLoading } from './components/loading';
17
- export type { MenuItemProps, MenuItemTone, MenuLabelProps, MenuProps, MenuSeparatorProps, MenuSubmenuProps, } from './components/menu';
17
+ export type { MenuItemProps, MenuItemTone, MenuLabelProps, MenuPlacement, MenuProps, MenuSeparatorProps, MenuSubmenuProps, } from './components/menu';
18
18
  export { Menu, MenuItem, MenuLabel, MenuSeparator, MenuSubmenu } from './components/menu';
19
19
  export type { NoteCardProps } from './components/note-card';
20
20
  export { NoteCard } from './components/note-card';
package/dist/index.js CHANGED
@@ -3,12 +3,12 @@ import { t } from "./button-DRz0VTkf.js";
3
3
  import { i as n, n as r, r as i, t as a } from "./confirm-3eBmopl8.js";
4
4
  import { t as o } from "./dialog-B4xS5zlK.js";
5
5
  import { t as s } from "./drawer-DoeuGAHD.js";
6
- import { n as c, t as l } from "./icon-DUpDkTEa.js";
6
+ import { n as c, t as l } from "./icon-DNZLJUqH.js";
7
7
  import { t as u } from "./kbd-D9XXd3qf.js";
8
8
  import { n as d, r as f, t as p } from "./loading-BpykjzMR.js";
9
- import { a as m, i as h, n as g, r as _, t as v } from "./menu-DKWGPsiS.js";
10
- import { n as y, t as b } from "./popover-Bx4b_3E9.js";
11
- import { t as x } from "./note-card-Dm-WbNTO.js";
9
+ import { a as m, i as h, n as g, r as _, t as v } from "./menu-Dj-Dje_l.js";
10
+ import { t as y } from "./note-card-Dm-WbNTO.js";
11
+ import { n as b, t as x } from "./popover-baLHE3lf.js";
12
12
  import { t as S } from "./text-field-B8Scu04G.js";
13
13
  import { n as C, r as w, t as T } from "./theme-C0p_hpKk.js";
14
- export { e as Badge, t as Button, r as Confirm, i as ConfirmProvider, o as Dialog, s as Drawer, l as ICON_NAMES, c as Icon, u as Kbd, f as Loading, v as Menu, g as MenuItem, _ as MenuLabel, h as MenuSeparator, m as MenuSubmenu, x as NoteCard, b as Popover, y as PopoverSeparator, C as THEME_ACCENTS, S as TextField, T as ThemeProvider, a as confirm, a as confirmDialog, p as hideLoading, w as isThemeAccentPreset, d as showLoading, n as useConfirm };
14
+ export { e as Badge, t as Button, r as Confirm, i as ConfirmProvider, o as Dialog, s as Drawer, l as ICON_NAMES, c as Icon, u as Kbd, f as Loading, v as Menu, g as MenuItem, _ as MenuLabel, h as MenuSeparator, m as MenuSubmenu, y as NoteCard, x as Popover, b as PopoverSeparator, C as THEME_ACCENTS, S as TextField, T as ThemeProvider, a as confirm, a as confirmDialog, p as hideLoading, w as isThemeAccentPreset, d as showLoading, n as useConfirm };
@@ -0,0 +1,153 @@
1
+ /* empty css */
2
+ import { t as e } from "./use-anchor-position-DWle8yoL.js";
3
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
4
+ import { useEffect as r, useRef as i, useState as a } from "react";
5
+ import { createPortal as o } from "react-dom";
6
+ //#region src/components/menu/Menu.tsx
7
+ function s({ children: n, className: r, anchor: i = null, placement: a = "bottom-start", anchorOffset: s = 6, anchorCrossOffset: c = 0, viewportMargin: l = 8, ref: u, style: d, ...f }) {
8
+ let p = i !== null, { floatingRef: m, style: h } = e({
9
+ anchor: i,
10
+ placement: a,
11
+ offset: s,
12
+ crossOffset: c,
13
+ viewportMargin: l
14
+ }), g = [
15
+ "hn-menu",
16
+ p ? "hn-menu--floating" : void 0,
17
+ r
18
+ ].filter(Boolean).join(" "), _ = p ? {
19
+ ...h,
20
+ ...d
21
+ } : d, v = (e) => {
22
+ m.current = e, typeof u == "function" ? u(e) : u != null && (u.current = e);
23
+ }, y = /* @__PURE__ */ t("div", {
24
+ ...f,
25
+ className: g,
26
+ ref: v,
27
+ role: "menu",
28
+ style: _,
29
+ children: n
30
+ });
31
+ return p && typeof document < "u" ? o(y, document.body) : y;
32
+ }
33
+ function c({ children: e, className: r, shortcut: i, tone: a = "default", type: o = "button", ...s }) {
34
+ let c = [
35
+ "hn-menu__item",
36
+ `hn-menu__item--${a}`,
37
+ r
38
+ ].filter(Boolean).join(" ");
39
+ return /* @__PURE__ */ n("button", {
40
+ ...s,
41
+ className: c,
42
+ role: "menuitem",
43
+ type: o,
44
+ children: [/* @__PURE__ */ t("span", {
45
+ className: "hn-menu__item-label",
46
+ children: e
47
+ }), i != null && i !== "" ? /* @__PURE__ */ t("span", {
48
+ className: "hn-menu__shortcut",
49
+ children: i
50
+ }) : null]
51
+ });
52
+ }
53
+ function l({ className: e, ...n }) {
54
+ let r = ["hn-menu__separator", e].filter(Boolean).join(" ");
55
+ return /* @__PURE__ */ t("hr", {
56
+ ...n,
57
+ className: r
58
+ });
59
+ }
60
+ function u({ children: e, className: n, ...r }) {
61
+ let i = ["hn-menu__label", n].filter(Boolean).join(" ");
62
+ return /* @__PURE__ */ t("div", {
63
+ ...r,
64
+ className: i,
65
+ children: e
66
+ });
67
+ }
68
+ var d = 150, f = 200;
69
+ function p({ label: e, children: o, className: c, disabled: l = !1, "aria-label": u, ...p }) {
70
+ let [m, h] = a(!1), g = i(null), _ = i(null), [v, y] = a(null), b = i(null), x = () => {
71
+ g.current !== null && (clearTimeout(g.current), g.current = null);
72
+ }, S = (e, t) => {
73
+ x(), g.current = setTimeout(() => {
74
+ h(e), g.current = null;
75
+ }, t);
76
+ };
77
+ r(() => () => {
78
+ g.current !== null && (clearTimeout(g.current), g.current = null);
79
+ }, []);
80
+ let C = () => {
81
+ l || S(!0, d);
82
+ }, w = () => {
83
+ S(!1, f);
84
+ }, T = () => {
85
+ l || (x(), h((e) => !e));
86
+ }, E = () => {
87
+ let e = b.current;
88
+ if (e === null) return;
89
+ let t = e.querySelector("[role=\"menuitem\"]");
90
+ t === null ? e.focus() : t.focus();
91
+ }, D = (e) => {
92
+ if (!l) switch (e.key) {
93
+ case "ArrowRight":
94
+ case "Enter":
95
+ case " ":
96
+ e.preventDefault(), x(), h(!0), requestAnimationFrame(() => {
97
+ E();
98
+ });
99
+ break;
100
+ }
101
+ }, O = (e) => {
102
+ switch (e.key) {
103
+ case "ArrowLeft":
104
+ case "Escape":
105
+ e.preventDefault(), x(), h(!1), _.current?.focus();
106
+ break;
107
+ }
108
+ }, k = u ?? (typeof e == "string" ? e : void 0), A = [
109
+ "hn-menu__submenu",
110
+ m ? "hn-menu__submenu--open" : void 0,
111
+ c
112
+ ].filter(Boolean).join(" "), j = (e) => {
113
+ _.current = e, y(e);
114
+ };
115
+ return /* @__PURE__ */ n("div", {
116
+ ...p,
117
+ className: A,
118
+ onPointerEnter: l ? void 0 : C,
119
+ onPointerLeave: l ? void 0 : w,
120
+ children: [/* @__PURE__ */ n("button", {
121
+ "aria-expanded": m,
122
+ "aria-haspopup": "menu",
123
+ className: "hn-menu__item hn-menu__submenu-trigger",
124
+ disabled: l,
125
+ onClick: T,
126
+ onKeyDown: D,
127
+ ref: j,
128
+ role: "menuitem",
129
+ type: "button",
130
+ children: [/* @__PURE__ */ t("span", {
131
+ className: "hn-menu__item-label",
132
+ children: e
133
+ }), /* @__PURE__ */ t("span", {
134
+ "aria-hidden": "true",
135
+ className: "hn-menu__submenu-chevron",
136
+ children: "▸"
137
+ })]
138
+ }), m ? /* @__PURE__ */ t(s, {
139
+ anchor: v,
140
+ anchorCrossOffset: -6,
141
+ anchorOffset: 2,
142
+ "aria-label": k,
143
+ className: "hn-menu__submenu-panel",
144
+ onKeyDown: O,
145
+ placement: "right-start",
146
+ ref: b,
147
+ tabIndex: -1,
148
+ children: o
149
+ }) : null]
150
+ });
151
+ }
152
+ //#endregion
153
+ export { p as a, l as i, c as n, u as r, s as t };
package/dist/menu.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, r, t as i } from "./menu-DKWGPsiS.js";
1
+ import { a as e, i as t, n, r, t as i } from "./menu-Dj-Dje_l.js";
2
2
  export { i as Menu, n as MenuItem, r as MenuLabel, t as MenuSeparator, e as MenuSubmenu };
@@ -0,0 +1,82 @@
1
+ /* empty css */
2
+ import { t as e } from "./use-anchor-position-DWle8yoL.js";
3
+ import { jsx as t } from "react/jsx-runtime";
4
+ import { createContext as n, useContext as r } from "react";
5
+ import { createPortal as i } from "react-dom";
6
+ //#region src/components/popover/Popover.tsx
7
+ var a = n(null);
8
+ function o(e) {
9
+ return e === "vertical" ? "horizontal" : "vertical";
10
+ }
11
+ function s(e, t, n) {
12
+ if (e === void 0) return {};
13
+ let r = n ? "absolute" : "fixed";
14
+ switch (e) {
15
+ case "top": return {
16
+ position: r,
17
+ top: t,
18
+ left: "50%",
19
+ transform: "translateX(-50%)"
20
+ };
21
+ case "bottom": return {
22
+ position: r,
23
+ bottom: t,
24
+ left: "50%",
25
+ transform: "translateX(-50%)"
26
+ };
27
+ case "left": return {
28
+ position: r,
29
+ left: t,
30
+ top: "50%",
31
+ transform: "translateY(-50%)"
32
+ };
33
+ case "right": return {
34
+ position: r,
35
+ right: t,
36
+ top: "50%",
37
+ transform: "translateY(-50%)"
38
+ };
39
+ }
40
+ }
41
+ function c({ children: n, className: r, theme: o = "dark", orientation: c = "horizontal", edge: l, edgeOffset: u = 16, relative: d = !1, anchor: f = null, placement: p = "bottom-start", anchorOffset: m = 6, viewportMargin: h = 8, ref: g, style: _, ...v }) {
42
+ let y = f !== null, { floatingRef: b, style: x } = e({
43
+ anchor: f,
44
+ placement: p,
45
+ offset: m,
46
+ viewportMargin: h
47
+ }), S = [
48
+ "hn-popover",
49
+ y ? "hn-popover--floating" : void 0,
50
+ r
51
+ ].filter(Boolean).join(" "), C = y ? {
52
+ ...x,
53
+ ..._
54
+ } : {
55
+ ...s(l, u, d),
56
+ ..._
57
+ }, w = (e) => {
58
+ b.current = e, typeof g == "function" ? g(e) : g != null && (g.current = e);
59
+ }, T = /* @__PURE__ */ t(a.Provider, {
60
+ value: c,
61
+ children: /* @__PURE__ */ t("div", {
62
+ ...v,
63
+ className: S,
64
+ "data-theme": o,
65
+ "data-orientation": c,
66
+ ref: w,
67
+ style: C,
68
+ children: n
69
+ })
70
+ });
71
+ return y && typeof document < "u" ? i(T, document.body) : T;
72
+ }
73
+ function l({ className: e, ...n }) {
74
+ let i = ["hn-popover__separator", e].filter(Boolean).join(" "), s = r(a);
75
+ return /* @__PURE__ */ t("hr", {
76
+ ...n,
77
+ "aria-orientation": o(s),
78
+ className: i
79
+ });
80
+ }
81
+ //#endregion
82
+ export { l as n, c as t };
package/dist/popover.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./popover-Bx4b_3E9.js";
1
+ import { n as e, t } from "./popover-baLHE3lf.js";
2
2
  export { t as Popover, e as PopoverSeparator };
@@ -0,0 +1,87 @@
1
+ import { useLayoutEffect as e, useRef as t, useState as n } from "react";
2
+ //#region src/components/popover/use-anchor-position.ts
3
+ var r = {
4
+ position: "fixed",
5
+ top: 0,
6
+ left: 0,
7
+ visibility: "hidden"
8
+ }, i = {
9
+ top: "bottom",
10
+ bottom: "top",
11
+ left: "right",
12
+ right: "left"
13
+ };
14
+ function a(e) {
15
+ let [t, n] = e.split("-");
16
+ return {
17
+ side: t,
18
+ align: n
19
+ };
20
+ }
21
+ function o(e, t, n, r, o, s, c) {
22
+ let l = window.innerWidth, u = window.innerHeight, { side: d, align: f } = a(r), p = (r) => {
23
+ switch (r) {
24
+ case "bottom": return e.bottom + o + n > u - c;
25
+ case "top": return e.top - o - n < c;
26
+ case "right": return e.right + o + t > l - c;
27
+ case "left": return e.left - o - t < c;
28
+ }
29
+ }, m = d;
30
+ if (p(d)) {
31
+ let e = i[d];
32
+ p(e) || (m = e);
33
+ }
34
+ let h = 0, g = 0;
35
+ switch (m) {
36
+ case "bottom":
37
+ h = e.bottom + o;
38
+ break;
39
+ case "top":
40
+ h = e.top - o - n;
41
+ break;
42
+ case "right":
43
+ g = e.right + o;
44
+ break;
45
+ case "left":
46
+ g = e.left - o - t;
47
+ break;
48
+ }
49
+ return m === "top" || m === "bottom" ? (g = f === "start" ? e.left : e.right - t, g += s) : (h = f === "start" ? e.top : e.bottom - n, h += s), g = Math.min(Math.max(g, c), Math.max(c, l - t - c)), h = Math.min(Math.max(h, c), Math.max(c, u - n - c)), {
50
+ left: g,
51
+ top: h
52
+ };
53
+ }
54
+ function s({ anchor: i, placement: a = "bottom-start", offset: s = 6, crossOffset: c = 0, viewportMargin: l = 8 }) {
55
+ let u = t(null), [d, f] = n(r);
56
+ return e(() => {
57
+ if (i === null) return;
58
+ let e = () => {
59
+ let e = u.current;
60
+ if (e === null) return;
61
+ let { left: t, top: n } = o(i.getBoundingClientRect(), e.offsetWidth, e.offsetHeight, a, s, c, l);
62
+ f({
63
+ position: "fixed",
64
+ left: t,
65
+ top: n
66
+ });
67
+ };
68
+ e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0);
69
+ let t = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
70
+ e();
71
+ });
72
+ return t?.observe(i), u.current !== null && t?.observe(u.current), () => {
73
+ window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0), t?.disconnect();
74
+ };
75
+ }, [
76
+ i,
77
+ a,
78
+ s,
79
+ c,
80
+ l
81
+ ]), {
82
+ floatingRef: u,
83
+ style: d
84
+ };
85
+ }
86
+ //#endregion
87
+ export { s as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamster-note/components",
3
- "version": "0.2.1-beta.2",
3
+ "version": "0.2.1-beta.3",
4
4
  "description": "Reusable React components for HamsterNote products.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,142 +0,0 @@
1
- /* empty css */
2
- import { r as e, t } from "./popover-Bx4b_3E9.js";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
- import { useEffect as i, useRef as a, useState as o } from "react";
5
- import { createPortal as s } from "react-dom";
6
- //#region src/components/menu/Menu.tsx
7
- function c({ children: e, className: t, ...r }) {
8
- let i = ["hn-menu", t].filter(Boolean).join(" ");
9
- return /* @__PURE__ */ n("div", {
10
- ...r,
11
- className: i,
12
- role: "menu",
13
- children: e
14
- });
15
- }
16
- function l({ children: e, className: t, shortcut: i, tone: a = "default", type: o = "button", ...s }) {
17
- let c = [
18
- "hn-menu__item",
19
- `hn-menu__item--${a}`,
20
- t
21
- ].filter(Boolean).join(" ");
22
- return /* @__PURE__ */ r("button", {
23
- ...s,
24
- className: c,
25
- role: "menuitem",
26
- type: o,
27
- children: [/* @__PURE__ */ n("span", {
28
- className: "hn-menu__item-label",
29
- children: e
30
- }), i != null && i !== "" ? /* @__PURE__ */ n("span", {
31
- className: "hn-menu__shortcut",
32
- children: i
33
- }) : null]
34
- });
35
- }
36
- function u({ className: e, ...t }) {
37
- let r = ["hn-menu__separator", e].filter(Boolean).join(" ");
38
- return /* @__PURE__ */ n("hr", {
39
- ...t,
40
- className: r
41
- });
42
- }
43
- function d({ children: e, className: t, ...r }) {
44
- let i = ["hn-menu__label", t].filter(Boolean).join(" ");
45
- return /* @__PURE__ */ n("div", {
46
- ...r,
47
- className: i,
48
- children: e
49
- });
50
- }
51
- var f = 150, p = 200;
52
- function m({ label: l, children: u, className: d, disabled: m = !1, "aria-label": h, ...g }) {
53
- let [_, v] = o(!1), y = a(null), b = a(null), [x, S] = o(null), C = a(null), { floatingRef: w, style: T } = e({
54
- anchor: _ ? x : null,
55
- placement: "right-start",
56
- offset: 2,
57
- crossOffset: -7
58
- }), E = () => {
59
- y.current !== null && (clearTimeout(y.current), y.current = null);
60
- }, D = (e, t) => {
61
- E(), y.current = setTimeout(() => {
62
- v(e), y.current = null;
63
- }, t);
64
- };
65
- i(() => () => {
66
- y.current !== null && (clearTimeout(y.current), y.current = null);
67
- }, []);
68
- let O = () => {
69
- m || D(!0, f);
70
- }, k = () => {
71
- D(!1, p);
72
- }, A = () => {
73
- m || (E(), v((e) => !e));
74
- }, j = () => {
75
- let e = C.current;
76
- if (e === null) return;
77
- let t = e.querySelector("[role=\"menuitem\"]");
78
- t === null ? e.focus() : t.focus();
79
- }, M = (e) => {
80
- if (!m) switch (e.key) {
81
- case "ArrowRight":
82
- case "Enter":
83
- case " ":
84
- e.preventDefault(), E(), v(!0), requestAnimationFrame(() => {
85
- j();
86
- });
87
- break;
88
- }
89
- }, N = (e) => {
90
- switch (e.key) {
91
- case "ArrowLeft":
92
- case "Escape":
93
- e.preventDefault(), E(), v(!1), b.current?.focus();
94
- break;
95
- }
96
- }, P = h ?? (typeof l == "string" ? l : void 0), F = [
97
- "hn-menu__submenu",
98
- _ ? "hn-menu__submenu--open" : void 0,
99
- d
100
- ].filter(Boolean).join(" "), I = (e) => {
101
- C.current = e, w.current = e;
102
- }, L = (e) => {
103
- b.current = e, S(e);
104
- };
105
- return /* @__PURE__ */ r("div", {
106
- ...g,
107
- className: F,
108
- onPointerEnter: m ? void 0 : O,
109
- onPointerLeave: m ? void 0 : k,
110
- children: [/* @__PURE__ */ r("button", {
111
- "aria-expanded": _,
112
- "aria-haspopup": "menu",
113
- className: "hn-menu__item hn-menu__submenu-trigger",
114
- disabled: m,
115
- onClick: A,
116
- onKeyDown: M,
117
- ref: L,
118
- role: "menuitem",
119
- type: "button",
120
- children: [/* @__PURE__ */ n("span", {
121
- className: "hn-menu__item-label",
122
- children: l
123
- }), /* @__PURE__ */ n("span", {
124
- "aria-hidden": "true",
125
- className: "hn-menu__submenu-chevron",
126
- children: "▸"
127
- })]
128
- }), _ ? s(/* @__PURE__ */ n("div", {
129
- className: "hn-menu__submenu-panel",
130
- ref: I,
131
- style: T,
132
- children: /* @__PURE__ */ n(t, { children: /* @__PURE__ */ n(c, {
133
- "aria-label": P,
134
- onKeyDown: N,
135
- tabIndex: -1,
136
- children: u
137
- }) })
138
- }), document.body) : null]
139
- });
140
- }
141
- //#endregion
142
- export { m as a, u as i, l as n, d as r, c as t };
@@ -1,166 +0,0 @@
1
- /* empty css */
2
- import { jsx as e } from "react/jsx-runtime";
3
- import { createContext as t, useContext as n, useLayoutEffect as r, useRef as i, useState as a } from "react";
4
- import { createPortal as o } from "react-dom";
5
- //#region src/components/popover/use-anchor-position.ts
6
- var s = {
7
- position: "fixed",
8
- top: 0,
9
- left: 0,
10
- visibility: "hidden"
11
- }, c = {
12
- top: "bottom",
13
- bottom: "top",
14
- left: "right",
15
- right: "left"
16
- };
17
- function l(e) {
18
- let [t, n] = e.split("-");
19
- return {
20
- side: t,
21
- align: n
22
- };
23
- }
24
- function u(e, t, n, r, i, a, o) {
25
- let s = window.innerWidth, u = window.innerHeight, { side: d, align: f } = l(r), p = (r) => {
26
- switch (r) {
27
- case "bottom": return e.bottom + i + n > u - o;
28
- case "top": return e.top - i - n < o;
29
- case "right": return e.right + i + t > s - o;
30
- case "left": return e.left - i - t < o;
31
- }
32
- }, m = d;
33
- if (p(d)) {
34
- let e = c[d];
35
- p(e) || (m = e);
36
- }
37
- let h = 0, g = 0;
38
- switch (m) {
39
- case "bottom":
40
- h = e.bottom + i;
41
- break;
42
- case "top":
43
- h = e.top - i - n;
44
- break;
45
- case "right":
46
- g = e.right + i;
47
- break;
48
- case "left":
49
- g = e.left - i - t;
50
- break;
51
- }
52
- return m === "top" || m === "bottom" ? (g = f === "start" ? e.left : e.right - t, g += a) : (h = f === "start" ? e.top : e.bottom - n, h += a), g = Math.min(Math.max(g, o), Math.max(o, s - t - o)), h = Math.min(Math.max(h, o), Math.max(o, u - n - o)), {
53
- left: g,
54
- top: h
55
- };
56
- }
57
- function d({ anchor: e, placement: t = "bottom-start", offset: n = 6, crossOffset: o = 0, viewportMargin: c = 8 }) {
58
- let l = i(null), [d, f] = a(s);
59
- return r(() => {
60
- if (e === null) return;
61
- let r = () => {
62
- let r = l.current;
63
- if (r === null) return;
64
- let { left: i, top: a } = u(e.getBoundingClientRect(), r.offsetWidth, r.offsetHeight, t, n, o, c);
65
- f({
66
- position: "fixed",
67
- left: i,
68
- top: a
69
- });
70
- };
71
- r(), window.addEventListener("resize", r), window.addEventListener("scroll", r, !0);
72
- let i = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
73
- r();
74
- });
75
- return i?.observe(e), l.current !== null && i?.observe(l.current), () => {
76
- window.removeEventListener("resize", r), window.removeEventListener("scroll", r, !0), i?.disconnect();
77
- };
78
- }, [
79
- e,
80
- t,
81
- n,
82
- o,
83
- c
84
- ]), {
85
- floatingRef: l,
86
- style: d
87
- };
88
- }
89
- //#endregion
90
- //#region src/components/popover/Popover.tsx
91
- var f = t(null);
92
- function p(e) {
93
- return e === "vertical" ? "horizontal" : "vertical";
94
- }
95
- function m(e, t, n) {
96
- if (e === void 0) return {};
97
- let r = n ? "absolute" : "fixed";
98
- switch (e) {
99
- case "top": return {
100
- position: r,
101
- top: t,
102
- left: "50%",
103
- transform: "translateX(-50%)"
104
- };
105
- case "bottom": return {
106
- position: r,
107
- bottom: t,
108
- left: "50%",
109
- transform: "translateX(-50%)"
110
- };
111
- case "left": return {
112
- position: r,
113
- left: t,
114
- top: "50%",
115
- transform: "translateY(-50%)"
116
- };
117
- case "right": return {
118
- position: r,
119
- right: t,
120
- top: "50%",
121
- transform: "translateY(-50%)"
122
- };
123
- }
124
- }
125
- function h({ children: t, className: n, theme: r = "dark", orientation: i = "horizontal", edge: a, edgeOffset: s = 16, relative: c = !1, anchor: l = null, placement: u = "bottom-start", anchorOffset: p = 6, viewportMargin: h = 8, ref: g, style: _, ...v }) {
126
- let y = l !== null, { floatingRef: b, style: x } = d({
127
- anchor: l,
128
- placement: u,
129
- offset: p,
130
- viewportMargin: h
131
- }), S = [
132
- "hn-popover",
133
- y ? "hn-popover--floating" : void 0,
134
- n
135
- ].filter(Boolean).join(" "), C = y ? {
136
- ...x,
137
- ..._
138
- } : {
139
- ...m(a, s, c),
140
- ..._
141
- }, w = (e) => {
142
- b.current = e, typeof g == "function" ? g(e) : g != null && (g.current = e);
143
- }, T = /* @__PURE__ */ e(f.Provider, {
144
- value: i,
145
- children: /* @__PURE__ */ e("div", {
146
- ...v,
147
- className: S,
148
- "data-theme": r,
149
- "data-orientation": i,
150
- ref: w,
151
- style: C,
152
- children: t
153
- })
154
- });
155
- return y && typeof document < "u" ? o(T, document.body) : T;
156
- }
157
- function g({ className: t, ...r }) {
158
- let i = ["hn-popover__separator", t].filter(Boolean).join(" "), a = n(f);
159
- return /* @__PURE__ */ e("hr", {
160
- ...r,
161
- "aria-orientation": p(a),
162
- className: i
163
- });
164
- }
165
- //#endregion
166
- export { g as n, d as r, h as t };