@hamster-note/components 0.2.1-beta.3 → 0.4.0-beta.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 +341 -73
- package/dist/Icon-BuZRZcjv.js +1143 -0
- package/dist/button-mmBNcoG1.js +45 -0
- package/dist/button.js +1 -1
- package/dist/components/button/Button.d.ts +5 -3
- 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 +1 -15
- package/dist/components/menu/Menu.d.ts +11 -19
- 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/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/components/theme/theme.d.ts +1 -87
- package/dist/{confirm-3eBmopl8.js → confirm-DKgVMWkR.js} +4 -5
- package/dist/confirm.js +1 -1
- package/dist/dialog-DI_yumUn.js +102 -0
- package/dist/dialog.js +1 -1
- package/dist/drawer-Cpe3Yf3K.js +120 -0
- package/dist/drawer.js +1 -1
- package/dist/hamster-note-components.css +1 -1
- package/dist/icon-u7jiIYal.js +5 -0
- package/dist/icon.js +2 -1
- package/dist/index.js +10 -9
- package/dist/menu-B4WwCQyw.js +179 -0
- package/dist/menu.js +1 -1
- package/dist/{popover-baLHE3lf.js → popover-D00SlGpL.js} +1 -1
- package/dist/popover.js +1 -1
- package/dist/shared/icon-names.d.ts +15 -0
- package/dist/shared/icons.d.ts +1216 -0
- package/dist/shared/theme.d.ts +87 -0
- package/dist/shared/tokens.d.ts +67 -0
- 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/shared-data.test.d.ts +1 -0
- package/dist/test/theme-and-popover.test.d.ts +1 -0
- package/dist/{theme-C0p_hpKk.js → theme-DNK-xd31.js} +30 -22
- package/dist/theme-context-CdWvVVP8.js +8 -0
- package/dist/theme.js +1 -1
- package/dist/use-anchor-position-D3QBcIet.js +166 -0
- package/dist-native/badge.d.ts +10 -0
- package/dist-native/badge.js +7 -0
- package/dist-native/button.d.ts +16 -0
- package/dist-native/button.js +7 -0
- package/dist-native/chunk-6RD26X3W.js +78 -0
- package/dist-native/chunk-6SR5ZHDD.js +13 -0
- package/dist-native/chunk-6VYUVVCP.js +27 -0
- package/dist-native/chunk-7LN4VNRB.js +124 -0
- package/dist-native/chunk-CF76TWL4.js +85 -0
- package/dist-native/chunk-ENTYQ6M4.js +256 -0
- package/dist-native/chunk-GSG6CXIE.js +1688 -0
- package/dist-native/chunk-JHT74YG3.js +186 -0
- package/dist-native/chunk-KPDK62A5.js +106 -0
- package/dist-native/chunk-PLFX4RVR.js +134 -0
- package/dist-native/chunk-QUGLAOXA.js +49 -0
- package/dist-native/chunk-S2EUKEYI.js +35 -0
- package/dist-native/chunk-VTE5RPMO.js +38 -0
- package/dist-native/chunk-YJ4H3ZBQ.js +145 -0
- package/dist-native/chunk-ZTQATW6Y.js +127 -0
- package/dist-native/confirm.d.ts +24 -0
- package/dist-native/confirm.js +14 -0
- package/dist-native/dialog.d.ts +8 -0
- package/dist-native/dialog.js +10 -0
- package/dist-native/drawer.d.ts +13 -0
- package/dist-native/drawer.js +10 -0
- package/dist-native/focus-C0k0lLui.d.ts +9 -0
- package/dist-native/icon.d.ts +28 -0
- package/dist-native/icon.js +9 -0
- package/dist-native/index.d.ts +20 -0
- package/dist-native/index.js +84 -0
- package/dist-native/kbd.d.ts +9 -0
- package/dist-native/kbd.js +7 -0
- package/dist-native/loading.d.ts +19 -0
- package/dist-native/loading.js +11 -0
- package/dist-native/menu.d.ts +31 -0
- package/dist-native/menu.js +17 -0
- package/dist-native/modal-panel-BOpp1oRC.d.ts +23 -0
- package/dist-native/note-card.d.ts +13 -0
- package/dist-native/note-card.js +7 -0
- package/dist-native/popover.d.ts +34 -0
- package/dist-native/popover.js +8 -0
- package/dist-native/position-CkPoZ5AD.d.ts +3 -0
- package/dist-native/text-field.d.ts +13 -0
- package/dist-native/text-field.js +7 -0
- package/dist-native/theme.d.ts +120 -0
- package/dist-native/theme.js +16 -0
- package/dist-native/tokens-DHoNd-yT.d.ts +41 -0
- package/package.json +151 -6
- package/dist/button-DRz0VTkf.js +0 -18
- package/dist/dialog-B4xS5zlK.js +0 -53
- package/dist/drawer-DoeuGAHD.js +0 -60
- package/dist/icon-DNZLJUqH.js +0 -517
- package/dist/menu-Dj-Dje_l.js +0 -153
- package/dist/use-anchor-position-DWle8yoL.js +0 -87
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题色配置(accent 主色)。
|
|
3
|
+
*
|
|
4
|
+
* 设计哲学:组件库所有组件只引用全局 token(见 tokens.css 的 :root),
|
|
5
|
+
* 主题切换通过在包裹层重定义同名 token、经 CSS 级联让子树自动继承
|
|
6
|
+
* (Popover 的 dark/light 即是这一范式)。本文件是 accent 主题色的
|
|
7
|
+
* 唯一数据源:ThemeProvider 读取这里的预设值,内联下发到包裹 div 的
|
|
8
|
+
* style 上,子树所有组件经 var(--hn-color-accent) 等拿到新色值。
|
|
9
|
+
*
|
|
10
|
+
* 预设色刻意避开既有语义色(danger #fb7185 / success #4ade80 /
|
|
11
|
+
* warning #fbbf24),避免主题色与语义色产生视觉冲突。
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* 预设主题色表。
|
|
15
|
+
*
|
|
16
|
+
* 每个预设包含三个字段,分别对应 tokens.css 中被 accent 影响的三个 token:
|
|
17
|
+
* - accent:主色,映射到 --hn-color-accent
|
|
18
|
+
* - accentHover:hover 态色,映射到 --hn-color-accent-hover
|
|
19
|
+
* - focusRingColor:焦点环颜色(不含 box-shadow 前缀,仅颜色部分),
|
|
20
|
+
* ThemeProvider 会拼成 `0 0 0 3px ${focusRingColor}` 写入 --hn-focus-ring
|
|
21
|
+
*
|
|
22
|
+
* `violet` 与 tokens.css 的默认值完全一致,作为 ThemeProvider 的默认预设,
|
|
23
|
+
* 保证不传 accent 时视觉与未包裹 ThemeProvider 时完全等价(零 Breaking Change)。
|
|
24
|
+
*/
|
|
25
|
+
export declare const THEME_ACCENTS: {
|
|
26
|
+
readonly violet: {
|
|
27
|
+
readonly accent: "#7c83ff";
|
|
28
|
+
readonly accentHover: "#9197ff";
|
|
29
|
+
readonly focusRingColor: "rgb(145 151 255 / 42%)";
|
|
30
|
+
};
|
|
31
|
+
readonly blue: {
|
|
32
|
+
readonly accent: "#60a5fa";
|
|
33
|
+
readonly accentHover: "#7db6fb";
|
|
34
|
+
readonly focusRingColor: "rgb(96 165 250 / 42%)";
|
|
35
|
+
};
|
|
36
|
+
readonly teal: {
|
|
37
|
+
readonly accent: "#2dd4bf";
|
|
38
|
+
readonly accentHover: "#4fdcc9";
|
|
39
|
+
readonly focusRingColor: "rgb(45 212 191 / 42%)";
|
|
40
|
+
};
|
|
41
|
+
readonly orange: {
|
|
42
|
+
readonly accent: "#fb923c";
|
|
43
|
+
readonly accentHover: "#fca45c";
|
|
44
|
+
readonly focusRingColor: "rgb(251 146 60 / 42%)";
|
|
45
|
+
};
|
|
46
|
+
readonly pink: {
|
|
47
|
+
readonly accent: "#f472b6";
|
|
48
|
+
readonly accentHover: "#f68cc4";
|
|
49
|
+
readonly focusRingColor: "rgb(244 114 182 / 42%)";
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 预设主题色名:`violet` | `blue` | `teal` | `orange` | `pink`。
|
|
54
|
+
*/
|
|
55
|
+
export type ThemeAccentPreset = keyof typeof THEME_ACCENTS;
|
|
56
|
+
/**
|
|
57
|
+
* 主题色入参类型。
|
|
58
|
+
*
|
|
59
|
+
* 用 `ThemeAccentPreset | (string & {})` 的交叉技巧保留两个能力:
|
|
60
|
+
* 1. 传入预设名时获得自动补全(IDE 列出五个预设);
|
|
61
|
+
* 2. 传入任意 CSS 颜色字符串时仍类型合法(`(string & {})` 让 TS 不会
|
|
62
|
+
* 把 string 收窄成字面量联合,避免「自定义颜色」用法被类型拒绝)。
|
|
63
|
+
*/
|
|
64
|
+
export type ThemeAccent = ThemeAccentPreset | (string & {});
|
|
65
|
+
/**
|
|
66
|
+
* 判断字符串是否是预设主题色名。
|
|
67
|
+
*
|
|
68
|
+
* 用于 Demo 或使用方在拿到一个 accent 字符串时区分「预设」与「自定义」
|
|
69
|
+
* 两种来源:预设走 ThemeProvider 内联下发的精确派生值,自定义走
|
|
70
|
+
* theme.css 中 `[data-accent='custom']` 的 color-mix 派生。
|
|
71
|
+
*/
|
|
72
|
+
export declare function isThemeAccentPreset(value: string): value is ThemeAccentPreset;
|
|
73
|
+
/**
|
|
74
|
+
* 明暗模式。
|
|
75
|
+
*
|
|
76
|
+
* 与 accent 主题色正交:accent 重定义 `--hn-color-accent` 等 accent 三件套,
|
|
77
|
+
* mode 重定义 `--hn-color-surface` / `--hn-color-text` / `--hn-color-border`
|
|
78
|
+
* 等全套表面与文字 token。两个轴独立组合,例如可以同时「浅色背景 + 蓝色 accent」。
|
|
79
|
+
*
|
|
80
|
+
* - `dark`(默认):与 tokens.css 的 :root 默认值一致,不传时视觉无变化;
|
|
81
|
+
* - `light`:重定义全套表面/文字/边框 token 为浅色配色。
|
|
82
|
+
*
|
|
83
|
+
* 实际的 token 覆盖值定义在 theme.css 的 `.hn-theme[data-mode='light']` 与
|
|
84
|
+
* `.hn-theme[data-mode='dark']` 规则中,ThemeProvider 只负责把 mode 写到
|
|
85
|
+
* 根 div 的 `data-mode` 属性上,CSS 级联完成其余工作。
|
|
86
|
+
*/
|
|
87
|
+
export type ThemeMode = 'dark' | 'light';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const BUTTON_SIZES: {
|
|
2
|
+
readonly small: {
|
|
3
|
+
readonly height: 30;
|
|
4
|
+
readonly padding: 11;
|
|
5
|
+
readonly fontSize: 12;
|
|
6
|
+
};
|
|
7
|
+
readonly medium: {
|
|
8
|
+
readonly height: 36;
|
|
9
|
+
readonly padding: 14;
|
|
10
|
+
readonly fontSize: 13;
|
|
11
|
+
};
|
|
12
|
+
readonly large: {
|
|
13
|
+
readonly height: 42;
|
|
14
|
+
readonly padding: 18;
|
|
15
|
+
readonly fontSize: 14;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const NUMERIC_TOKENS: {
|
|
19
|
+
readonly radius: {
|
|
20
|
+
readonly small: 6;
|
|
21
|
+
readonly medium: 8;
|
|
22
|
+
readonly large: 12;
|
|
23
|
+
};
|
|
24
|
+
readonly spacing: {
|
|
25
|
+
readonly buttonGap: 8;
|
|
26
|
+
readonly fieldGap: 7;
|
|
27
|
+
readonly fieldPadding: 11;
|
|
28
|
+
readonly panelPadding: 12;
|
|
29
|
+
};
|
|
30
|
+
readonly fontSize: {
|
|
31
|
+
readonly small: 12;
|
|
32
|
+
readonly medium: 13;
|
|
33
|
+
readonly large: 14;
|
|
34
|
+
};
|
|
35
|
+
readonly layer: {
|
|
36
|
+
readonly popover: 1000;
|
|
37
|
+
readonly menu: 1000;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const MODE_COLORS: {
|
|
41
|
+
readonly dark: {
|
|
42
|
+
readonly surface: "#111114";
|
|
43
|
+
readonly surfaceHover: "#17171b";
|
|
44
|
+
readonly text: "#f4f4f5";
|
|
45
|
+
readonly textMuted: "#92929d";
|
|
46
|
+
readonly border: "rgba(255,255,255,0.1)";
|
|
47
|
+
readonly borderStrong: "rgba(255,255,255,0.17)";
|
|
48
|
+
readonly danger: "#fb7185";
|
|
49
|
+
readonly dangerHover: "#fc8a9b";
|
|
50
|
+
readonly success: "#4ade80";
|
|
51
|
+
readonly warning: "#fbbf24";
|
|
52
|
+
readonly onDanger: "#09090b";
|
|
53
|
+
};
|
|
54
|
+
readonly light: {
|
|
55
|
+
readonly surface: "#ffffff";
|
|
56
|
+
readonly surfaceHover: "#f4f4f6";
|
|
57
|
+
readonly text: "#18181b";
|
|
58
|
+
readonly textMuted: "#63636d";
|
|
59
|
+
readonly border: "rgba(0,0,0,0.1)";
|
|
60
|
+
readonly borderStrong: "rgba(0,0,0,0.18)";
|
|
61
|
+
readonly danger: "#e11d48";
|
|
62
|
+
readonly dangerHover: "#be123c";
|
|
63
|
+
readonly success: "#16a34a";
|
|
64
|
+
readonly warning: "#d97706";
|
|
65
|
+
readonly onDanger: "#ffffff";
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { t as e } from "./theme-context-CdWvVVP8.js";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/shared/theme.ts
|
|
5
|
+
var n = {
|
|
5
6
|
violet: {
|
|
6
7
|
accent: "#7c83ff",
|
|
7
8
|
accentHover: "#9197ff",
|
|
@@ -28,20 +29,20 @@ var t = {
|
|
|
28
29
|
focusRingColor: "rgb(244 114 182 / 42%)"
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
function
|
|
32
|
-
return e in
|
|
32
|
+
function r(e) {
|
|
33
|
+
return e in n;
|
|
33
34
|
}
|
|
34
35
|
//#endregion
|
|
35
36
|
//#region src/components/theme/ThemeProvider.tsx
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
let
|
|
37
|
+
function i(e) {
|
|
38
|
+
if (r(e)) {
|
|
39
|
+
let t = n[e];
|
|
39
40
|
return {
|
|
40
41
|
dataAccent: e,
|
|
41
42
|
style: {
|
|
42
|
-
"--hn-color-accent":
|
|
43
|
-
"--hn-color-accent-hover":
|
|
44
|
-
"--hn-focus-ring": `0 0 0 3px ${
|
|
43
|
+
"--hn-color-accent": t.accent,
|
|
44
|
+
"--hn-color-accent-hover": t.accentHover,
|
|
45
|
+
"--hn-focus-ring": `0 0 0 3px ${t.focusRingColor}`
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
48
|
}
|
|
@@ -50,18 +51,25 @@ function r(e) {
|
|
|
50
51
|
style: { "--hn-color-accent": e }
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
let { dataAccent:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
function a({ accent: n = "violet", children: r, className: a, mode: o = "dark", style: s }) {
|
|
55
|
+
let { dataAccent: c, style: l } = i(n), u = ["hn-theme", a].filter(Boolean).join(" "), d = {
|
|
56
|
+
...l,
|
|
57
|
+
...s
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ t(e, {
|
|
60
|
+
value: {
|
|
61
|
+
accent: c,
|
|
62
|
+
mode: o,
|
|
63
|
+
style: d
|
|
62
64
|
},
|
|
63
|
-
children:
|
|
65
|
+
children: /* @__PURE__ */ t("div", {
|
|
66
|
+
className: u,
|
|
67
|
+
"data-accent": c,
|
|
68
|
+
"data-mode": o,
|
|
69
|
+
style: d,
|
|
70
|
+
children: r
|
|
71
|
+
})
|
|
64
72
|
});
|
|
65
73
|
}
|
|
66
74
|
//#endregion
|
|
67
|
-
export {
|
|
75
|
+
export { n, r, a as t };
|
package/dist/theme.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./theme-
|
|
1
|
+
import { n as e, r as t, t as n } from "./theme-DNK-xd31.js";
|
|
2
2
|
export { e as THEME_ACCENTS, n as ThemeProvider, t as isThemeAccentPreset };
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
}, a = {
|
|
14
|
+
"top-start": {
|
|
15
|
+
side: "top",
|
|
16
|
+
align: "start"
|
|
17
|
+
},
|
|
18
|
+
top: {
|
|
19
|
+
side: "top",
|
|
20
|
+
align: "center"
|
|
21
|
+
},
|
|
22
|
+
"top-end": {
|
|
23
|
+
side: "top",
|
|
24
|
+
align: "end"
|
|
25
|
+
},
|
|
26
|
+
"bottom-start": {
|
|
27
|
+
side: "bottom",
|
|
28
|
+
align: "start"
|
|
29
|
+
},
|
|
30
|
+
bottom: {
|
|
31
|
+
side: "bottom",
|
|
32
|
+
align: "center"
|
|
33
|
+
},
|
|
34
|
+
"bottom-end": {
|
|
35
|
+
side: "bottom",
|
|
36
|
+
align: "end"
|
|
37
|
+
},
|
|
38
|
+
"left-start": {
|
|
39
|
+
side: "left",
|
|
40
|
+
align: "start"
|
|
41
|
+
},
|
|
42
|
+
left: {
|
|
43
|
+
side: "left",
|
|
44
|
+
align: "center"
|
|
45
|
+
},
|
|
46
|
+
"left-end": {
|
|
47
|
+
side: "left",
|
|
48
|
+
align: "end"
|
|
49
|
+
},
|
|
50
|
+
"right-start": {
|
|
51
|
+
side: "right",
|
|
52
|
+
align: "start"
|
|
53
|
+
},
|
|
54
|
+
right: {
|
|
55
|
+
side: "right",
|
|
56
|
+
align: "center"
|
|
57
|
+
},
|
|
58
|
+
"right-end": {
|
|
59
|
+
side: "right",
|
|
60
|
+
align: "end"
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function o({ anchorRect: e, crossOffset: t, floatingHeight: n, floatingWidth: r, offset: o, placement: s, viewportHeight: c, viewportMargin: l, viewportWidth: u }) {
|
|
64
|
+
let { side: d, align: f } = a[s], p = (t) => {
|
|
65
|
+
switch (t) {
|
|
66
|
+
case "bottom": return e.bottom + o + n > c - l;
|
|
67
|
+
case "top": return e.top - o - n < l;
|
|
68
|
+
case "right": return e.right + o + r > u - l;
|
|
69
|
+
case "left": return e.left - o - r < l;
|
|
70
|
+
}
|
|
71
|
+
}, m = d;
|
|
72
|
+
if (p(d)) {
|
|
73
|
+
let e = i[d];
|
|
74
|
+
p(e) || (m = e);
|
|
75
|
+
}
|
|
76
|
+
let h = 0, g = 0;
|
|
77
|
+
switch (m) {
|
|
78
|
+
case "bottom":
|
|
79
|
+
h = e.bottom + o;
|
|
80
|
+
break;
|
|
81
|
+
case "top":
|
|
82
|
+
h = e.top - o - n;
|
|
83
|
+
break;
|
|
84
|
+
case "right":
|
|
85
|
+
g = e.right + o;
|
|
86
|
+
break;
|
|
87
|
+
case "left":
|
|
88
|
+
g = e.left - o - r;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
if (m === "top" || m === "bottom") {
|
|
92
|
+
switch (f) {
|
|
93
|
+
case "start":
|
|
94
|
+
g = e.left;
|
|
95
|
+
break;
|
|
96
|
+
case "center":
|
|
97
|
+
g = e.left + (e.width - r) / 2;
|
|
98
|
+
break;
|
|
99
|
+
case "end":
|
|
100
|
+
g = e.right - r;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
g += t;
|
|
104
|
+
} else {
|
|
105
|
+
switch (f) {
|
|
106
|
+
case "start":
|
|
107
|
+
h = e.top;
|
|
108
|
+
break;
|
|
109
|
+
case "center":
|
|
110
|
+
h = e.top + (e.height - n) / 2;
|
|
111
|
+
break;
|
|
112
|
+
case "end":
|
|
113
|
+
h = e.bottom - n;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
h += t;
|
|
117
|
+
}
|
|
118
|
+
return g = Math.min(Math.max(g, l), Math.max(l, u - r - l)), h = Math.min(Math.max(h, l), Math.max(l, c - n - l)), {
|
|
119
|
+
left: g,
|
|
120
|
+
top: h
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function s({ anchor: i, placement: a = "bottom-start", offset: s = 6, crossOffset: c = 0, viewportMargin: l = 8 }) {
|
|
124
|
+
let u = t(null), [d, f] = n(r);
|
|
125
|
+
return e(() => {
|
|
126
|
+
if (i === null) return;
|
|
127
|
+
let e = () => {
|
|
128
|
+
let e = u.current;
|
|
129
|
+
if (e === null) return;
|
|
130
|
+
let { left: t, top: n } = o({
|
|
131
|
+
anchorRect: i.getBoundingClientRect(),
|
|
132
|
+
crossOffset: c,
|
|
133
|
+
floatingHeight: e.offsetHeight,
|
|
134
|
+
floatingWidth: e.offsetWidth,
|
|
135
|
+
offset: s,
|
|
136
|
+
placement: a,
|
|
137
|
+
viewportHeight: window.innerHeight,
|
|
138
|
+
viewportMargin: l,
|
|
139
|
+
viewportWidth: window.innerWidth
|
|
140
|
+
});
|
|
141
|
+
f({
|
|
142
|
+
position: "fixed",
|
|
143
|
+
left: t,
|
|
144
|
+
top: n
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0);
|
|
148
|
+
let t = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
|
|
149
|
+
e();
|
|
150
|
+
});
|
|
151
|
+
return t?.observe(i), u.current !== null && t?.observe(u.current), () => {
|
|
152
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0), t?.disconnect();
|
|
153
|
+
};
|
|
154
|
+
}, [
|
|
155
|
+
i,
|
|
156
|
+
a,
|
|
157
|
+
s,
|
|
158
|
+
c,
|
|
159
|
+
l
|
|
160
|
+
]), {
|
|
161
|
+
floatingRef: u,
|
|
162
|
+
style: d
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { s as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { TextProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type BadgeTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
|
|
5
|
+
interface BadgeProps extends TextProps {
|
|
6
|
+
tone?: BadgeTone;
|
|
7
|
+
}
|
|
8
|
+
declare function Badge({ tone, style, ...props }: BadgeProps): react.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { Badge, type BadgeProps, type BadgeTone };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { PressableProps, View } from 'react-native';
|
|
4
|
+
import { B as BUTTON_SIZES } from './tokens-DHoNd-yT.js';
|
|
5
|
+
|
|
6
|
+
type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'info' | 'ghost';
|
|
7
|
+
type ButtonSize = keyof typeof BUTTON_SIZES;
|
|
8
|
+
interface ButtonProps extends Omit<PressableProps, 'children'> {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
variant?: ButtonVariant;
|
|
11
|
+
size?: ButtonSize;
|
|
12
|
+
ghost?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<View>>;
|
|
15
|
+
|
|
16
|
+
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUTTON_SIZES,
|
|
3
|
+
useTheme
|
|
4
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
5
|
+
|
|
6
|
+
// native/button.tsx
|
|
7
|
+
import { Children, forwardRef } from "react";
|
|
8
|
+
import { Pressable, Text } from "react-native";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var Button = forwardRef(function Button2({
|
|
11
|
+
children,
|
|
12
|
+
variant = "secondary",
|
|
13
|
+
size = "medium",
|
|
14
|
+
ghost = false,
|
|
15
|
+
disabled,
|
|
16
|
+
onPress,
|
|
17
|
+
style,
|
|
18
|
+
accessibilityState,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) {
|
|
21
|
+
const t = useTheme();
|
|
22
|
+
const c = t.colors;
|
|
23
|
+
const s = BUTTON_SIZES[size];
|
|
24
|
+
const v = variant === "ghost" ? "secondary" : variant;
|
|
25
|
+
const g = ghost || variant === "ghost";
|
|
26
|
+
const action = v === "primary" ? c.accent : v === "secondary" ? c.surface : c[v];
|
|
27
|
+
const fg = g ? v === "secondary" ? c.textMuted : action : v === "secondary" ? c.text : v === "danger" ? c.onDanger : c.onSemantic;
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
Pressable,
|
|
30
|
+
{
|
|
31
|
+
...props,
|
|
32
|
+
ref,
|
|
33
|
+
accessibilityRole: "button",
|
|
34
|
+
accessibilityState: { ...accessibilityState, disabled: Boolean(disabled) },
|
|
35
|
+
disabled,
|
|
36
|
+
onPress: (e) => {
|
|
37
|
+
if (!disabled) onPress?.(e);
|
|
38
|
+
},
|
|
39
|
+
style: (state) => [
|
|
40
|
+
{
|
|
41
|
+
minHeight: Math.max(44, s.height),
|
|
42
|
+
minWidth: 44,
|
|
43
|
+
paddingHorizontal: s.padding,
|
|
44
|
+
paddingVertical: 8,
|
|
45
|
+
flexDirection: "row",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
gap: t.spacing.buttonGap,
|
|
49
|
+
borderWidth: 1,
|
|
50
|
+
borderRadius: t.radius.medium,
|
|
51
|
+
borderColor: !g && v === "secondary" ? c.border : "transparent",
|
|
52
|
+
backgroundColor: g ? state.pressed ? c.surfaceHover : "transparent" : state.pressed ? v === "primary" ? c.accentHover : v === "secondary" ? c.surfaceHover : action : action,
|
|
53
|
+
opacity: disabled ? 0.42 : state.pressed ? 0.85 : 1
|
|
54
|
+
},
|
|
55
|
+
typeof style === "function" ? style(state) : style
|
|
56
|
+
],
|
|
57
|
+
children: Children.map(
|
|
58
|
+
children,
|
|
59
|
+
(child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx(
|
|
60
|
+
Text,
|
|
61
|
+
{
|
|
62
|
+
style: {
|
|
63
|
+
color: fg,
|
|
64
|
+
fontSize: t.fontSize[size === "small" ? "small" : size === "large" ? "large" : "medium"],
|
|
65
|
+
fontWeight: "600",
|
|
66
|
+
flexShrink: 1
|
|
67
|
+
},
|
|
68
|
+
children: child
|
|
69
|
+
}
|
|
70
|
+
) : child
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
Button
|
|
78
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ModalPanel
|
|
3
|
+
} from "./chunk-PLFX4RVR.js";
|
|
4
|
+
|
|
5
|
+
// native/drawer.tsx
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var containers = {
|
|
8
|
+
top: { padding: 0, alignItems: "stretch", justifyContent: "flex-start" },
|
|
9
|
+
bottom: { padding: 0, alignItems: "stretch", justifyContent: "flex-end" },
|
|
10
|
+
left: { padding: 0, alignItems: "flex-start", justifyContent: "center" },
|
|
11
|
+
right: { padding: 0, alignItems: "flex-end", justifyContent: "center" }
|
|
12
|
+
};
|
|
13
|
+
function Drawer({ placement = "right", ...props }) {
|
|
14
|
+
const horizontal = placement === "left" || placement === "right";
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
ModalPanel,
|
|
17
|
+
{
|
|
18
|
+
...props,
|
|
19
|
+
containerStyle: containers[placement],
|
|
20
|
+
panelStyle: horizontal ? { width: "88%", height: "100%", maxWidth: 420 } : { width: "100%", maxWidth: "100%", maxHeight: "88%" }
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
Drawer
|
|
27
|
+
};
|