@hamster-note/components 0.3.0 → 0.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- 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 +3 -2
- package/dist/components/icon/icon-names.d.ts +1 -15
- package/dist/components/theme/theme.d.ts +1 -87
- package/dist/{confirm-Faavk_5T.js → confirm-DKgVMWkR.js} +2 -2
- package/dist/confirm.js +1 -1
- package/dist/{dialog-BYlEUJ_j.js → dialog-DI_yumUn.js} +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{drawer-BV9RFSna.js → drawer-Cpe3Yf3K.js} +1 -1
- package/dist/drawer.js +1 -1
- package/dist/hamster-note-components.css +1 -1
- package/dist/{icon-BFAcjkFI.js → icon-u7jiIYal.js} +1 -1
- package/dist/icon.js +2 -2
- package/dist/index.js +7 -7
- 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/shared-data.test.d.ts +1 -0
- package/dist/{theme-CVNLJL1G.js → theme-DNK-xd31.js} +1 -1
- package/dist/theme.js +1 -1
- 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 +137 -5
- package/dist/Icon-BBSPOBTI.js +0 -531
- package/dist/button-DjMS8bKj.js +0 -20
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Popover
|
|
3
|
+
} from "./chunk-ENTYQ6M4.js";
|
|
4
|
+
import {
|
|
5
|
+
useTheme
|
|
6
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
7
|
+
|
|
8
|
+
// native/menu.tsx
|
|
9
|
+
import {
|
|
10
|
+
Children,
|
|
11
|
+
Fragment,
|
|
12
|
+
isValidElement,
|
|
13
|
+
useEffect,
|
|
14
|
+
useRef,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { Pressable, Text, View } from "react-native";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
function MenuItem(_props) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function MenuSubmenu(_props) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function MenuLabel(_props) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function MenuSeparator() {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
function parse(children, prefix = "") {
|
|
32
|
+
return Children.toArray(children).flatMap((child, index) => {
|
|
33
|
+
if (!isValidElement(child)) return [];
|
|
34
|
+
const key = `${prefix}/${index}`;
|
|
35
|
+
if (child.type === Fragment)
|
|
36
|
+
return parse(child.props.children, key);
|
|
37
|
+
if (child.type === MenuItem)
|
|
38
|
+
return [{ key, kind: "item", props: child.props }];
|
|
39
|
+
if (child.type === MenuSubmenu) {
|
|
40
|
+
const props = child.props;
|
|
41
|
+
return [{ key, kind: "submenu", props, children: parse(props.children, key) }];
|
|
42
|
+
}
|
|
43
|
+
if (child.type === MenuLabel)
|
|
44
|
+
return [{ key, kind: "label", props: child.props }];
|
|
45
|
+
if (child.type === MenuSeparator)
|
|
46
|
+
return [{ key, kind: "separator", props: { children: null } }];
|
|
47
|
+
throw new Error("Menu children must be MenuItem, MenuSubmenu, MenuLabel or MenuSeparator.");
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function Menu({ children, open, onClose, ...props }) {
|
|
51
|
+
const t = useTheme();
|
|
52
|
+
const [path, setPath] = useState([]);
|
|
53
|
+
const [returnKey, setReturnKey] = useState(null);
|
|
54
|
+
const firstRef = useRef(null);
|
|
55
|
+
const consumed = useRef(false);
|
|
56
|
+
const live = useRef(open);
|
|
57
|
+
live.current = open;
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!open) {
|
|
60
|
+
setPath([]);
|
|
61
|
+
setReturnKey(null);
|
|
62
|
+
} else consumed.current = false;
|
|
63
|
+
}, [open]);
|
|
64
|
+
let entries = parse(children);
|
|
65
|
+
const labels = [];
|
|
66
|
+
for (const key of path) {
|
|
67
|
+
const entry = entries.find((e) => e.key === key && e.kind === "submenu");
|
|
68
|
+
if (!entry) break;
|
|
69
|
+
labels.push(entry.props.label ?? "");
|
|
70
|
+
entries = entry.children ?? [];
|
|
71
|
+
}
|
|
72
|
+
const focusEntry = entries.find((e) => e.key === returnKey && !e.props.disabled) ?? entries.find((e) => (e.kind === "item" || e.kind === "submenu") && !e.props.disabled);
|
|
73
|
+
const back = () => {
|
|
74
|
+
if (!path.length) return false;
|
|
75
|
+
setReturnKey(path[path.length - 1] ?? null);
|
|
76
|
+
setPath(path.slice(0, -1));
|
|
77
|
+
return true;
|
|
78
|
+
};
|
|
79
|
+
const close = () => {
|
|
80
|
+
if (!consumed.current && live.current) {
|
|
81
|
+
consumed.current = true;
|
|
82
|
+
onClose();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return /* @__PURE__ */ jsxs(
|
|
86
|
+
Popover,
|
|
87
|
+
{
|
|
88
|
+
...props,
|
|
89
|
+
open,
|
|
90
|
+
onClose: close,
|
|
91
|
+
onBack: back,
|
|
92
|
+
initialFocusRef: firstRef,
|
|
93
|
+
focusKey: `${path.join(":")}:${returnKey ?? ""}`,
|
|
94
|
+
children: [
|
|
95
|
+
path.length > 0 ? /* @__PURE__ */ jsx(
|
|
96
|
+
Pressable,
|
|
97
|
+
{
|
|
98
|
+
accessibilityRole: "button",
|
|
99
|
+
accessibilityLabel: "\u8FD4\u56DE\u4E0A\u4E00\u7EA7",
|
|
100
|
+
onPress: back,
|
|
101
|
+
style: { minHeight: 44, justifyContent: "center" },
|
|
102
|
+
children: /* @__PURE__ */ jsxs(Text, { style: { color: t.colors.text }, children: [
|
|
103
|
+
"\u2039 ",
|
|
104
|
+
labels[labels.length - 1]
|
|
105
|
+
] })
|
|
106
|
+
}
|
|
107
|
+
) : null,
|
|
108
|
+
/* @__PURE__ */ jsx(View, { accessibilityRole: "menu", children: entries.map(
|
|
109
|
+
(e) => e.kind === "separator" ? /* @__PURE__ */ jsx(
|
|
110
|
+
View,
|
|
111
|
+
{
|
|
112
|
+
style: { height: 1, backgroundColor: t.colors.border, marginVertical: 4 }
|
|
113
|
+
},
|
|
114
|
+
e.key
|
|
115
|
+
) : e.kind === "label" ? /* @__PURE__ */ jsx(
|
|
116
|
+
Text,
|
|
117
|
+
{
|
|
118
|
+
accessibilityRole: "header",
|
|
119
|
+
style: { color: t.colors.textMuted, padding: 8, fontSize: t.fontSize.small },
|
|
120
|
+
children: e.props.children
|
|
121
|
+
},
|
|
122
|
+
e.key
|
|
123
|
+
) : /* @__PURE__ */ jsxs(
|
|
124
|
+
Pressable,
|
|
125
|
+
{
|
|
126
|
+
ref: e.key === focusEntry?.key ? firstRef : void 0,
|
|
127
|
+
accessibilityRole: "menuitem",
|
|
128
|
+
accessibilityLabel: e.props.accessibilityLabel ?? e.props.label,
|
|
129
|
+
accessibilityState: {
|
|
130
|
+
disabled: Boolean(e.props.disabled),
|
|
131
|
+
...e.kind === "submenu" ? { expanded: false } : {}
|
|
132
|
+
},
|
|
133
|
+
disabled: e.props.disabled,
|
|
134
|
+
onPress: () => {
|
|
135
|
+
if (e.props.disabled || consumed.current || !live.current) return;
|
|
136
|
+
if (e.kind === "submenu") {
|
|
137
|
+
setReturnKey(null);
|
|
138
|
+
setPath([...path, e.key]);
|
|
139
|
+
} else {
|
|
140
|
+
consumed.current = true;
|
|
141
|
+
try {
|
|
142
|
+
e.props.onPress?.();
|
|
143
|
+
} finally {
|
|
144
|
+
onClose();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
style: ({ pressed }) => ({
|
|
149
|
+
minHeight: 44,
|
|
150
|
+
padding: 10,
|
|
151
|
+
borderRadius: t.radius.small,
|
|
152
|
+
flexDirection: "row",
|
|
153
|
+
justifyContent: "space-between",
|
|
154
|
+
backgroundColor: pressed ? t.colors.surfaceHover : "transparent",
|
|
155
|
+
opacity: e.props.disabled ? 0.42 : 1
|
|
156
|
+
}),
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx(
|
|
159
|
+
Text,
|
|
160
|
+
{
|
|
161
|
+
style: {
|
|
162
|
+
color: e.props.tone === "danger" ? t.colors.danger : t.colors.text,
|
|
163
|
+
fontSize: t.fontSize.large,
|
|
164
|
+
flexShrink: 1
|
|
165
|
+
},
|
|
166
|
+
children: e.kind === "submenu" ? e.props.label : e.props.children
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
e.kind === "submenu" || e.props.shortcut ? /* @__PURE__ */ jsx(Text, { style: { color: t.colors.textMuted }, children: e.kind === "submenu" ? "\u203A" : e.props.shortcut }) : null
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
e.key
|
|
173
|
+
)
|
|
174
|
+
) })
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export {
|
|
181
|
+
MenuItem,
|
|
182
|
+
MenuSubmenu,
|
|
183
|
+
MenuLabel,
|
|
184
|
+
MenuSeparator,
|
|
185
|
+
Menu
|
|
186
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTheme
|
|
3
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
4
|
+
|
|
5
|
+
// native/loading.tsx
|
|
6
|
+
import {
|
|
7
|
+
createContext,
|
|
8
|
+
useCallback,
|
|
9
|
+
useContext,
|
|
10
|
+
useLayoutEffect,
|
|
11
|
+
useRef,
|
|
12
|
+
useState
|
|
13
|
+
} from "react";
|
|
14
|
+
import { ActivityIndicator, Modal, Text, View } from "react-native";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var sizes = {
|
|
17
|
+
small: "small",
|
|
18
|
+
medium: "small",
|
|
19
|
+
large: "large"
|
|
20
|
+
};
|
|
21
|
+
function Loading({
|
|
22
|
+
text,
|
|
23
|
+
size = "medium",
|
|
24
|
+
style,
|
|
25
|
+
accessibilityLabel,
|
|
26
|
+
...props
|
|
27
|
+
}) {
|
|
28
|
+
const { colors, fontSize } = useTheme();
|
|
29
|
+
return /* @__PURE__ */ jsxs(
|
|
30
|
+
View,
|
|
31
|
+
{
|
|
32
|
+
...props,
|
|
33
|
+
accessible: true,
|
|
34
|
+
accessibilityRole: "progressbar",
|
|
35
|
+
accessibilityLabel: accessibilityLabel ?? text ?? "\u6B63\u5728\u52A0\u8F7D",
|
|
36
|
+
accessibilityState: { busy: true },
|
|
37
|
+
style: [{ flexDirection: "row", alignItems: "center", gap: 8 }, style],
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
ActivityIndicator,
|
|
41
|
+
{
|
|
42
|
+
color: colors.accent,
|
|
43
|
+
size: sizes[size],
|
|
44
|
+
style: size === "small" ? { transform: [{ scale: 0.8 }] } : void 0
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
text && /* @__PURE__ */ jsx(Text, { style: { color: colors.text, fontSize: fontSize[size], flexShrink: 1 }, children: text })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
var LoadingContext = createContext(null);
|
|
53
|
+
function LoadingProvider({ children }) {
|
|
54
|
+
const active = useRef(true);
|
|
55
|
+
const requests = useRef(/* @__PURE__ */ new Map());
|
|
56
|
+
const [latest, setLatest] = useState();
|
|
57
|
+
const update = useCallback(() => setLatest(Array.from(requests.current.values()).at(-1)), []);
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
active.current = true;
|
|
60
|
+
return () => {
|
|
61
|
+
active.current = false;
|
|
62
|
+
requests.current.clear();
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
const show = useCallback(
|
|
66
|
+
(options = {}) => {
|
|
67
|
+
if (!active.current) return () => {
|
|
68
|
+
};
|
|
69
|
+
const id = Symbol();
|
|
70
|
+
requests.current.set(id, options);
|
|
71
|
+
update();
|
|
72
|
+
return () => {
|
|
73
|
+
if (requests.current.delete(id) && active.current) update();
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
[update]
|
|
77
|
+
);
|
|
78
|
+
return /* @__PURE__ */ jsxs(LoadingContext.Provider, { value: show, children: [
|
|
79
|
+
children,
|
|
80
|
+
/* @__PURE__ */ jsx(Modal, { visible: latest !== void 0, transparent: true, onRequestClose: () => {
|
|
81
|
+
}, children: /* @__PURE__ */ jsx(
|
|
82
|
+
View,
|
|
83
|
+
{
|
|
84
|
+
accessibilityViewIsModal: true,
|
|
85
|
+
style: {
|
|
86
|
+
flex: 1,
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
justifyContent: "center",
|
|
89
|
+
backgroundColor: "rgba(0,0,0,0.5)"
|
|
90
|
+
},
|
|
91
|
+
children: /* @__PURE__ */ jsx(Loading, { ...latest })
|
|
92
|
+
}
|
|
93
|
+
) })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function useLoading() {
|
|
97
|
+
const show = useContext(LoadingContext);
|
|
98
|
+
if (!show) throw new Error("useLoading \u5FC5\u987B\u5728 LoadingProvider \u5185\u8C03\u7528\u3002");
|
|
99
|
+
return show;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
Loading,
|
|
104
|
+
LoadingProvider,
|
|
105
|
+
useLoading
|
|
106
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useModalLifecycle
|
|
3
|
+
} from "./chunk-7LN4VNRB.js";
|
|
4
|
+
import {
|
|
5
|
+
Button
|
|
6
|
+
} from "./chunk-6RD26X3W.js";
|
|
7
|
+
import {
|
|
8
|
+
useTheme
|
|
9
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
10
|
+
|
|
11
|
+
// native/modal-panel.tsx
|
|
12
|
+
import {
|
|
13
|
+
Modal,
|
|
14
|
+
Pressable,
|
|
15
|
+
ScrollView,
|
|
16
|
+
StyleSheet,
|
|
17
|
+
Text,
|
|
18
|
+
View
|
|
19
|
+
} from "react-native";
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
function ModalPanel({
|
|
22
|
+
open,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
children,
|
|
26
|
+
onClose,
|
|
27
|
+
closeLabel = "\u5173\u95ED",
|
|
28
|
+
closeOnBackdrop = true,
|
|
29
|
+
closeOnSystemBack = true,
|
|
30
|
+
style,
|
|
31
|
+
triggerRef,
|
|
32
|
+
fallbackFocusRef,
|
|
33
|
+
initialFocusRef,
|
|
34
|
+
containerStyle,
|
|
35
|
+
panelStyle,
|
|
36
|
+
focusKey,
|
|
37
|
+
dismissDisabled = false
|
|
38
|
+
}) {
|
|
39
|
+
const { colors, fontSize, radius, spacing } = useTheme();
|
|
40
|
+
const modal = useModalLifecycle({
|
|
41
|
+
open,
|
|
42
|
+
onClose,
|
|
43
|
+
triggerRef,
|
|
44
|
+
fallbackFocusRef,
|
|
45
|
+
initialFocusRef,
|
|
46
|
+
focusKey
|
|
47
|
+
});
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
Modal,
|
|
50
|
+
{
|
|
51
|
+
visible: open,
|
|
52
|
+
transparent: true,
|
|
53
|
+
animationType: "none",
|
|
54
|
+
onShow: modal.onShow,
|
|
55
|
+
onDismiss: modal.onDismiss,
|
|
56
|
+
onRequestClose: closeOnSystemBack ? modal.requestClose : () => {
|
|
57
|
+
},
|
|
58
|
+
children: /* @__PURE__ */ jsxs(
|
|
59
|
+
View,
|
|
60
|
+
{
|
|
61
|
+
accessibilityViewIsModal: true,
|
|
62
|
+
onAccessibilityEscape: closeOnSystemBack ? modal.requestClose : void 0,
|
|
63
|
+
style: [
|
|
64
|
+
{ flex: 1, alignItems: "center", justifyContent: "center", padding: 16 },
|
|
65
|
+
containerStyle
|
|
66
|
+
],
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
Pressable,
|
|
70
|
+
{
|
|
71
|
+
accessible: false,
|
|
72
|
+
importantForAccessibility: "no",
|
|
73
|
+
style: [StyleSheet.absoluteFill, { backgroundColor: "rgba(0,0,0,0.45)" }],
|
|
74
|
+
onPress: closeOnBackdrop ? modal.requestClose : void 0
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsxs(
|
|
78
|
+
View,
|
|
79
|
+
{
|
|
80
|
+
onLayout: modal.onLayout,
|
|
81
|
+
style: [
|
|
82
|
+
{
|
|
83
|
+
width: "100%",
|
|
84
|
+
maxWidth: 460,
|
|
85
|
+
maxHeight: "100%",
|
|
86
|
+
backgroundColor: colors.surface,
|
|
87
|
+
borderColor: colors.border,
|
|
88
|
+
borderWidth: 1,
|
|
89
|
+
borderRadius: radius.large,
|
|
90
|
+
padding: spacing.panelPadding,
|
|
91
|
+
gap: spacing.fieldGap
|
|
92
|
+
},
|
|
93
|
+
panelStyle,
|
|
94
|
+
style
|
|
95
|
+
],
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", gap: 8 }, children: [
|
|
98
|
+
/* @__PURE__ */ jsx(
|
|
99
|
+
Text,
|
|
100
|
+
{
|
|
101
|
+
ref: modal.titleRef,
|
|
102
|
+
accessible: true,
|
|
103
|
+
accessibilityRole: "header",
|
|
104
|
+
style: { flex: 1, color: colors.text, fontSize: fontSize.large, fontWeight: "600" },
|
|
105
|
+
children: title
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
Button,
|
|
110
|
+
{
|
|
111
|
+
ref: modal.closeRef,
|
|
112
|
+
ghost: true,
|
|
113
|
+
accessibilityLabel: closeLabel,
|
|
114
|
+
disabled: dismissDisabled,
|
|
115
|
+
onPress: modal.requestClose,
|
|
116
|
+
children: "\xD7"
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }),
|
|
120
|
+
description && /* @__PURE__ */ jsx(Text, { style: { color: colors.textMuted }, children: description }),
|
|
121
|
+
/* @__PURE__ */ jsx(ScrollView, { keyboardShouldPersistTaps: "handled", style: { flexGrow: 0, flexShrink: 1 }, children })
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
ModalPanel
|
|
134
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTheme
|
|
3
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
4
|
+
|
|
5
|
+
// native/note-card.tsx
|
|
6
|
+
import { Pressable, Text, View } from "react-native";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
function NoteCard({
|
|
9
|
+
title,
|
|
10
|
+
excerpt,
|
|
11
|
+
meta,
|
|
12
|
+
selected = false,
|
|
13
|
+
onPress,
|
|
14
|
+
style,
|
|
15
|
+
accessibilityState,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const { colors, fontSize, radius, spacing } = useTheme();
|
|
19
|
+
const cardStyle = {
|
|
20
|
+
backgroundColor: selected ? colors.surfaceHover : colors.surface,
|
|
21
|
+
borderColor: selected ? colors.accent : colors.border,
|
|
22
|
+
borderWidth: 1,
|
|
23
|
+
borderRadius: radius.medium,
|
|
24
|
+
padding: spacing.panelPadding,
|
|
25
|
+
gap: spacing.fieldGap,
|
|
26
|
+
minHeight: 44
|
|
27
|
+
};
|
|
28
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
/* @__PURE__ */ jsx(Text, { style: { color: colors.text, fontSize: fontSize.large, fontWeight: "600" }, children: title }),
|
|
30
|
+
/* @__PURE__ */ jsx(Text, { style: { color: colors.text, fontSize: fontSize.medium }, children: excerpt }),
|
|
31
|
+
/* @__PURE__ */ jsx(Text, { style: { color: colors.textMuted, fontSize: fontSize.small }, children: meta })
|
|
32
|
+
] });
|
|
33
|
+
const state = { ...accessibilityState, selected };
|
|
34
|
+
return onPress ? /* @__PURE__ */ jsx(
|
|
35
|
+
Pressable,
|
|
36
|
+
{
|
|
37
|
+
...props,
|
|
38
|
+
accessibilityRole: "button",
|
|
39
|
+
accessibilityState: state,
|
|
40
|
+
onPress,
|
|
41
|
+
style: ({ pressed }) => [cardStyle, pressed && { opacity: 0.8 }, style],
|
|
42
|
+
children: content
|
|
43
|
+
}
|
|
44
|
+
) : /* @__PURE__ */ jsx(View, { ...props, accessibilityState: state, style: [cardStyle, style], children: content });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
NoteCard
|
|
49
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTheme
|
|
3
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
4
|
+
|
|
5
|
+
// native/badge.tsx
|
|
6
|
+
import { Text } from "react-native";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
function Badge({ tone = "neutral", style, ...props }) {
|
|
9
|
+
const { colors, fontSize, radius } = useTheme();
|
|
10
|
+
const color = tone === "neutral" ? colors.text : colors[tone];
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Text,
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
style: [
|
|
16
|
+
{
|
|
17
|
+
alignSelf: "flex-start",
|
|
18
|
+
backgroundColor: colors.surfaceHover,
|
|
19
|
+
borderColor: tone === "neutral" ? colors.borderStrong : color,
|
|
20
|
+
borderWidth: 1,
|
|
21
|
+
borderRadius: radius.small,
|
|
22
|
+
color,
|
|
23
|
+
fontSize: fontSize.small,
|
|
24
|
+
paddingHorizontal: 8,
|
|
25
|
+
paddingVertical: 2
|
|
26
|
+
},
|
|
27
|
+
style
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
Badge
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTheme
|
|
3
|
+
} from "./chunk-YJ4H3ZBQ.js";
|
|
4
|
+
|
|
5
|
+
// native/kbd.tsx
|
|
6
|
+
import { Fragment } from "react";
|
|
7
|
+
import { Text, View } from "react-native";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function Kbd({ children, keys, style, ...props }) {
|
|
10
|
+
const { colors, fontSize, radius } = useTheme();
|
|
11
|
+
const keyStyle = {
|
|
12
|
+
backgroundColor: colors.surfaceHover,
|
|
13
|
+
borderColor: colors.borderStrong,
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderRadius: radius.small,
|
|
16
|
+
color: colors.text,
|
|
17
|
+
fontSize: fontSize.small,
|
|
18
|
+
paddingHorizontal: 6,
|
|
19
|
+
paddingVertical: 2
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
View,
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
accessible: true,
|
|
26
|
+
accessibilityLabel: props.accessibilityLabel ?? (keys?.length ? keys.join(" + ") : void 0),
|
|
27
|
+
style: [{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 4 }, style],
|
|
28
|
+
children: keys?.length ? keys.map((key, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
index > 0 && /* @__PURE__ */ jsx(Text, { style: { color: colors.textMuted }, children: "+" }),
|
|
30
|
+
/* @__PURE__ */ jsx(Text, { style: keyStyle, children: key })
|
|
31
|
+
] }, index)) : /* @__PURE__ */ jsx(Text, { style: keyStyle, children })
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
Kbd
|
|
38
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// native/theme.tsx
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
// src/shared/theme.ts
|
|
5
|
+
var THEME_ACCENTS = {
|
|
6
|
+
// 默认紫:与 tokens.css 现有默认值保持一致,包裹后视觉无变化
|
|
7
|
+
violet: {
|
|
8
|
+
accent: "#7c83ff",
|
|
9
|
+
accentHover: "#9197ff",
|
|
10
|
+
focusRingColor: "rgb(145 151 255 / 42%)"
|
|
11
|
+
},
|
|
12
|
+
// 蓝:偏冷的专业感,hover 向白色提亮
|
|
13
|
+
blue: {
|
|
14
|
+
accent: "#60a5fa",
|
|
15
|
+
accentHover: "#7db6fb",
|
|
16
|
+
focusRingColor: "rgb(96 165 250 / 42%)"
|
|
17
|
+
},
|
|
18
|
+
// 青绿:清新但与 success(#4ade80) 拉开足够距离
|
|
19
|
+
teal: {
|
|
20
|
+
accent: "#2dd4bf",
|
|
21
|
+
accentHover: "#4fdcc9",
|
|
22
|
+
focusRingColor: "rgb(45 212 191 / 42%)"
|
|
23
|
+
},
|
|
24
|
+
// 橙:暖色强调,与 warning(#fbbf24) 同色系但饱和度更高
|
|
25
|
+
orange: {
|
|
26
|
+
accent: "#fb923c",
|
|
27
|
+
accentHover: "#fca45c",
|
|
28
|
+
focusRingColor: "rgb(251 146 60 / 42%)"
|
|
29
|
+
},
|
|
30
|
+
// 粉:与 danger(#fb7185) 同色系但更柔,适合个性化场景
|
|
31
|
+
pink: {
|
|
32
|
+
accent: "#f472b6",
|
|
33
|
+
accentHover: "#f68cc4",
|
|
34
|
+
focusRingColor: "rgb(244 114 182 / 42%)"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/shared/tokens.ts
|
|
39
|
+
var BUTTON_SIZES = {
|
|
40
|
+
small: { height: 30, padding: 11, fontSize: 12 },
|
|
41
|
+
medium: { height: 36, padding: 14, fontSize: 13 },
|
|
42
|
+
large: { height: 42, padding: 18, fontSize: 14 }
|
|
43
|
+
};
|
|
44
|
+
var NUMERIC_TOKENS = {
|
|
45
|
+
radius: { small: 6, medium: 8, large: 12 },
|
|
46
|
+
spacing: { buttonGap: 8, fieldGap: 7, fieldPadding: 11, panelPadding: 12 },
|
|
47
|
+
fontSize: { small: 12, medium: 13, large: 14 },
|
|
48
|
+
layer: { popover: 1e3, menu: 1e3 }
|
|
49
|
+
};
|
|
50
|
+
var MODE_COLORS = {
|
|
51
|
+
dark: {
|
|
52
|
+
surface: "#111114",
|
|
53
|
+
surfaceHover: "#17171b",
|
|
54
|
+
text: "#f4f4f5",
|
|
55
|
+
textMuted: "#92929d",
|
|
56
|
+
border: "rgba(255,255,255,0.1)",
|
|
57
|
+
borderStrong: "rgba(255,255,255,0.17)",
|
|
58
|
+
danger: "#fb7185",
|
|
59
|
+
dangerHover: "#fc8a9b",
|
|
60
|
+
success: "#4ade80",
|
|
61
|
+
warning: "#fbbf24",
|
|
62
|
+
onDanger: "#09090b"
|
|
63
|
+
},
|
|
64
|
+
light: {
|
|
65
|
+
surface: "#ffffff",
|
|
66
|
+
surfaceHover: "#f4f4f6",
|
|
67
|
+
text: "#18181b",
|
|
68
|
+
textMuted: "#63636d",
|
|
69
|
+
border: "rgba(0,0,0,0.1)",
|
|
70
|
+
borderStrong: "rgba(0,0,0,0.18)",
|
|
71
|
+
danger: "#e11d48",
|
|
72
|
+
dangerHover: "#be123c",
|
|
73
|
+
success: "#16a34a",
|
|
74
|
+
warning: "#d97706",
|
|
75
|
+
onDanger: "#ffffff"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// native/theme.tsx
|
|
80
|
+
import { jsx } from "react/jsx-runtime";
|
|
81
|
+
function resolveAccent(accent) {
|
|
82
|
+
if (typeof accent === "object") return accent;
|
|
83
|
+
if (Object.hasOwn(THEME_ACCENTS, accent)) {
|
|
84
|
+
const preset = THEME_ACCENTS[accent];
|
|
85
|
+
return {
|
|
86
|
+
...preset,
|
|
87
|
+
focusRingColor: preset.focusRingColor.replace(
|
|
88
|
+
/rgb\((\d+) (\d+) (\d+) \/ 42%\)/,
|
|
89
|
+
"rgba($1,$2,$3,0.42)"
|
|
90
|
+
)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (!/^#[\da-f]{6}$/i.test(accent))
|
|
94
|
+
throw new Error("Native accent must be a preset, #RRGGBB, or AccentColors.");
|
|
95
|
+
const rgb = [1, 3, 5].map((i) => parseInt(accent.slice(i, i + 2), 16));
|
|
96
|
+
return {
|
|
97
|
+
accent,
|
|
98
|
+
accentHover: "#" + rgb.map(
|
|
99
|
+
(v) => Math.round(v * 0.84 + 255 * 0.16).toString(16).padStart(2, "0")
|
|
100
|
+
).join(""),
|
|
101
|
+
focusRingColor: `rgba(${rgb.join(",")},0.42)`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function createTheme(mode = "dark", accent = "violet", tokens = {}) {
|
|
105
|
+
return {
|
|
106
|
+
mode,
|
|
107
|
+
colors: {
|
|
108
|
+
...MODE_COLORS[mode],
|
|
109
|
+
info: "#aeb2ff",
|
|
110
|
+
onSemantic: "#09090b",
|
|
111
|
+
...resolveAccent(accent)
|
|
112
|
+
},
|
|
113
|
+
radius: { ...NUMERIC_TOKENS.radius, ...tokens.radius },
|
|
114
|
+
spacing: { ...NUMERIC_TOKENS.spacing, ...tokens.spacing },
|
|
115
|
+
fontSize: { ...NUMERIC_TOKENS.fontSize, ...tokens.fontSize },
|
|
116
|
+
layer: { ...NUMERIC_TOKENS.layer, ...tokens.layer }
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var ThemeContext = createContext(createTheme());
|
|
120
|
+
function ThemeProvider({
|
|
121
|
+
children,
|
|
122
|
+
mode = "dark",
|
|
123
|
+
accent = "violet",
|
|
124
|
+
tokens,
|
|
125
|
+
theme
|
|
126
|
+
}) {
|
|
127
|
+
const value = useMemo(
|
|
128
|
+
() => theme ?? createTheme(mode, accent, tokens),
|
|
129
|
+
[theme, mode, accent, tokens]
|
|
130
|
+
);
|
|
131
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
132
|
+
}
|
|
133
|
+
function useTheme() {
|
|
134
|
+
return useContext(ThemeContext);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export {
|
|
138
|
+
THEME_ACCENTS,
|
|
139
|
+
BUTTON_SIZES,
|
|
140
|
+
NUMERIC_TOKENS,
|
|
141
|
+
resolveAccent,
|
|
142
|
+
createTheme,
|
|
143
|
+
ThemeProvider,
|
|
144
|
+
useTheme
|
|
145
|
+
};
|