@agimon-ai/po-native-components 0.0.0-alpha.3 → 0.0.0-alpha.31
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/LICENSE +149 -22
- package/dist/components/AgentAvatar.d.mts +14 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +87 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +2 -2
- package/dist/components/Badge.mjs.map +1 -1
- package/dist/components/Button.mjs +2 -2
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +5 -34
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +43 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/Dialog.mjs +5 -5
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +3 -3
- package/dist/components/Dot.mjs.map +1 -1
- package/dist/components/DropdownMenu.mjs +1 -1
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +137 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/Input.mjs +2 -2
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/List.mjs +1 -1
- package/dist/components/Markdown.d.mts +8 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +199 -18
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +2 -1
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +20 -24
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/Sheet.mjs +1 -1
- package/dist/components/SheetFrame.mjs +2 -2
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +132 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.mjs +1 -1
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +40 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/icons/iconGlyphs.d.mts +90 -54
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +36 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +37 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +10 -1
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +9 -4
- package/dist/index.mjs +9 -4
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/markdown.mjs +101 -5
- package/dist/lib/markdown.mjs.map +1 -1
- package/package.json +23 -20
package/LICENSE
CHANGED
|
@@ -1,22 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
2
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
|
|
6
|
+
Licensor: Agimon Pty Ltd
|
|
7
|
+
Licensed Work: Po, the software in the Po source repository and the
|
|
8
|
+
packages released from it, in each version released by
|
|
9
|
+
the Licensor.
|
|
10
|
+
The Licensed Work is (c) 2026 Agimon Pty Ltd.
|
|
11
|
+
Material identified as third-party in the "Third-party
|
|
12
|
+
components" section at the end of this file or in a
|
|
13
|
+
NOTICE file, and any package or directory whose own
|
|
14
|
+
license file grants a different license, is not part of
|
|
15
|
+
the Licensed Work and remains under its own license.
|
|
16
|
+
Additional Use Grant: You may make production use of the Licensed Work if
|
|
17
|
+
your use is Eligible Use. "Eligible Use" is production use that falls
|
|
18
|
+
within at least one of the following:
|
|
19
|
+
|
|
20
|
+
(a) Personal Use. Use by an individual for their own personal purposes,
|
|
21
|
+
and not on behalf of, or for the benefit of, an employer, client, or
|
|
22
|
+
other Organization. Use by an individual in the course of employment
|
|
23
|
+
or engagement by an Organization is use by that Organization.
|
|
24
|
+
|
|
25
|
+
(b) Small Organization Use. Use by or on behalf of an Organization whose
|
|
26
|
+
Annual Revenue is less than USD 1,000,000.
|
|
27
|
+
|
|
28
|
+
(c) Non-profit, Education and Research Use. Use, regardless of Annual
|
|
29
|
+
Revenue, by (i) an Organization registered or recognized as a
|
|
30
|
+
non-profit or charitable organization under the laws of its
|
|
31
|
+
jurisdiction, for its non-profit purposes; (ii) an accredited school,
|
|
32
|
+
college, or university, for teaching, learning, or academic research;
|
|
33
|
+
or (iii) a publicly funded research institution, for its research.
|
|
34
|
+
|
|
35
|
+
(d) Service Provider Use. Use by a consultant, contractor, agency, or other
|
|
36
|
+
service provider, regardless of its own Annual Revenue, solely to
|
|
37
|
+
build, deploy, host, operate, or support the Licensed Work for a client
|
|
38
|
+
whose own use would be Eligible Use under (a), (b), or (c). A service
|
|
39
|
+
provider's use for its own purposes is Eligible Use only if the service
|
|
40
|
+
provider itself qualifies under (b) or (c).
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Hosted services. Offering the Licensed Work to third parties as a hosted
|
|
44
|
+
or managed service whose primary value is the Licensed Work is Eligible
|
|
45
|
+
Use only if each such third party's own use would be Eligible Use.
|
|
46
|
+
|
|
47
|
+
Definitions. "Organization" means any company, partnership, sole
|
|
48
|
+
proprietorship, trust, association, government body, or other entity, and
|
|
49
|
+
includes an individual acting in a business or professional capacity.
|
|
50
|
+
"Affiliate" means any entity that directly or indirectly controls, is
|
|
51
|
+
controlled by, or is under common control with an Organization, where
|
|
52
|
+
"control" means ownership of more than 50% of the voting interests of an
|
|
53
|
+
entity or the power to direct its management and policies by contract or
|
|
54
|
+
otherwise. "Annual Revenue" means the total gross revenue of an
|
|
55
|
+
Organization and all of its Affiliates combined, from all sources and
|
|
56
|
+
whether or not related to the Licensed Work, for its most recently
|
|
57
|
+
completed fiscal year, or, if it has not completed a fiscal year, for the
|
|
58
|
+
twelve months before the use (or since its formation, if shorter),
|
|
59
|
+
converted into US dollars at the average exchange rate for that period.
|
|
60
|
+
Proceeds of equity or debt financing are not revenue.
|
|
61
|
+
|
|
62
|
+
Threshold. If an Organization stops qualifying under (b), its existing
|
|
63
|
+
production use remains Eligible Use for 90 days after it stops
|
|
64
|
+
qualifying, after which it must obtain a commercial license or stop
|
|
65
|
+
production use. Use that was Eligible Use when it occurred never requires
|
|
66
|
+
a commercial license after the fact.
|
|
67
|
+
Change Date: Four years from the date a version of the Licensed Work
|
|
68
|
+
is first publicly released by the Licensor.
|
|
69
|
+
Change License: Apache License, Version 2.0
|
|
70
|
+
|
|
71
|
+
For information about alternative licensing arrangements for the Licensed
|
|
72
|
+
Work, please visit: https://agimon.ai/licensing
|
|
73
|
+
|
|
74
|
+
Notice
|
|
75
|
+
|
|
76
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
77
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
78
|
+
under an Open Source License, as stated in this License.
|
|
79
|
+
|
|
80
|
+
-----------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
Business Source License 1.1
|
|
83
|
+
|
|
84
|
+
Terms
|
|
85
|
+
|
|
86
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
87
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
88
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
89
|
+
production use.
|
|
90
|
+
|
|
91
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
92
|
+
available distribution of a specific version of the Licensed Work under this
|
|
93
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
94
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
95
|
+
above terminate.
|
|
96
|
+
|
|
97
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
98
|
+
currently in effect as described in this License, you must purchase a
|
|
99
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
100
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
101
|
+
|
|
102
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
103
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
104
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
105
|
+
for each version of the Licensed Work released by Licensor.
|
|
106
|
+
|
|
107
|
+
You must conspicuously display this License on each original or modified copy
|
|
108
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
109
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
110
|
+
License apply to your use of that work.
|
|
111
|
+
|
|
112
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
113
|
+
terminate your rights under this License for the current and all other
|
|
114
|
+
versions of the Licensed Work.
|
|
115
|
+
|
|
116
|
+
This License does not grant you any right in any trademark or logo of
|
|
117
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
118
|
+
Licensor as expressly required by this License).
|
|
119
|
+
|
|
120
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
121
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
122
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
124
|
+
TITLE.
|
|
125
|
+
|
|
126
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
127
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
128
|
+
as long as you comply with the Covenants of Licensor below.
|
|
129
|
+
|
|
130
|
+
Covenants of Licensor
|
|
131
|
+
|
|
132
|
+
In consideration of the right to use this License’s text and the “Business
|
|
133
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
134
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
135
|
+
|
|
136
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
137
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
138
|
+
where “compatible” means that software provided under the Change License can
|
|
139
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
140
|
+
later version. Licensor may specify additional Change Licenses without
|
|
141
|
+
limitation.
|
|
142
|
+
|
|
143
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
144
|
+
impose any additional restriction on the right granted in this License, as
|
|
145
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
146
|
+
|
|
147
|
+
3. To specify a Change Date.
|
|
148
|
+
|
|
149
|
+
4. Not to modify this License in any other way.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/components/AgentAvatar.d.ts
|
|
2
|
+
/** How an agent is doing, as the avatar's corner dot shows it. */
|
|
3
|
+
export type AgentState = 'running' | 'waiting' | 'done' | 'failed';
|
|
4
|
+
/** One letter for a first name, two for a hyphenated agent name (`po-developer` is PD). */
|
|
5
|
+
export declare function agentInitials(name: string): string;
|
|
6
|
+
/** An agent's face: its initials on a tint fixed by `seed`, with its state as a corner dot. */
|
|
7
|
+
export declare function AgentAvatar({ name, seed, state, size }: {
|
|
8
|
+
name: string;
|
|
9
|
+
seed?: string;
|
|
10
|
+
state?: AgentState;
|
|
11
|
+
size?: 'sm' | 'md';
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=AgentAvatar.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentAvatar.d.mts","names":[],"sources":["../../src/components/AgentAvatar.tsx"],"mappings":";;YAQY;;wBAGI,cAAc;;wBA6Bd,cACd,MACA,MACA,OACA;EAEA;EACA;EACA,QAAQ;EACR;oBACD,IAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { Dot } from "./Dot.mjs";
|
|
3
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
5
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/AgentAvatar.tsx
|
|
9
|
+
/** One letter for a first name, two for a hyphenated agent name (`po-developer` is PD). */
|
|
10
|
+
function agentInitials(name) {
|
|
11
|
+
return name.split(/[-_.\s]+/u).filter(Boolean).slice(0, 2).map((part) => part.charAt(0).toUpperCase()).join("");
|
|
12
|
+
}
|
|
13
|
+
const TINTS = [
|
|
14
|
+
"green",
|
|
15
|
+
"teal",
|
|
16
|
+
"blue",
|
|
17
|
+
"cyan",
|
|
18
|
+
"yellow",
|
|
19
|
+
"violet"
|
|
20
|
+
];
|
|
21
|
+
function tintFor(seed) {
|
|
22
|
+
let hash = 0;
|
|
23
|
+
for (const char of seed) hash = (hash * 31 + char.charCodeAt(0)) % 997;
|
|
24
|
+
return TINTS[hash % TINTS.length] ?? "green";
|
|
25
|
+
}
|
|
26
|
+
const RING = 2;
|
|
27
|
+
const STATE_DOT = {
|
|
28
|
+
running: "green",
|
|
29
|
+
waiting: "yellow",
|
|
30
|
+
done: "neutral",
|
|
31
|
+
failed: "red"
|
|
32
|
+
};
|
|
33
|
+
/** An agent's face: its initials on a tint fixed by `seed`, with its state as a corner dot. */
|
|
34
|
+
function AgentAvatar({ name, seed = name, state, size = "md" }) {
|
|
35
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
36
|
+
accessible: true,
|
|
37
|
+
accessibilityRole: "image",
|
|
38
|
+
accessibilityLabel: state ? `${name}, ${state}` : name,
|
|
39
|
+
testID: "agent-avatar",
|
|
40
|
+
style: styles.frame,
|
|
41
|
+
children: [/* @__PURE__ */ jsx(View, {
|
|
42
|
+
style: styles.face(tintFor(seed), size === "sm" ? 24 : 32),
|
|
43
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
44
|
+
style: styles.initials,
|
|
45
|
+
children: agentInitials(name)
|
|
46
|
+
})
|
|
47
|
+
}), state ? /* @__PURE__ */ jsx(Dot, {
|
|
48
|
+
tone: STATE_DOT[state],
|
|
49
|
+
size: "md",
|
|
50
|
+
pulse: state === "running",
|
|
51
|
+
style: styles.dot
|
|
52
|
+
}) : null]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const styles = StyleSheet.create((theme) => ({
|
|
56
|
+
frame: { flexShrink: 0 },
|
|
57
|
+
face: (tint, side) => ({
|
|
58
|
+
width: side,
|
|
59
|
+
height: side,
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
borderRadius: theme.borderRadius.full,
|
|
63
|
+
backgroundColor: theme.colors[`tint-${tint}`],
|
|
64
|
+
uni__dependencies: [0]
|
|
65
|
+
}),
|
|
66
|
+
initials: {
|
|
67
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
68
|
+
fontSize: theme.fontSize.sm,
|
|
69
|
+
lineHeight: theme.lineHeight.sm,
|
|
70
|
+
color: theme.colors.hi,
|
|
71
|
+
uni__dependencies: [0]
|
|
72
|
+
},
|
|
73
|
+
dot: {
|
|
74
|
+
position: "absolute",
|
|
75
|
+
right: -4,
|
|
76
|
+
bottom: -4,
|
|
77
|
+
width: theme.spacing(2) + 4,
|
|
78
|
+
height: theme.spacing(2) + 4,
|
|
79
|
+
borderWidth: RING,
|
|
80
|
+
borderColor: theme.colors.panel,
|
|
81
|
+
uni__dependencies: [0]
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
export { AgentAvatar, agentInitials };
|
|
87
|
+
//# sourceMappingURL=AgentAvatar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentAvatar.mjs","names":["DotTone","StyleSheet","fontOf","Dot","AgentState","agentInitials","name","split","filter","Boolean","slice","map","part","charAt","toUpperCase","join","TINTS","const","Tint","tintFor","seed","hash","char","charCodeAt","length","RING","STATE_DOT","Readonly","Record","running","waiting","done","failed","AgentAvatar","state","size","styles","frame","face","initials","dot","create","theme","flexShrink","tint","side","width","height","alignItems","justifyContent","borderRadius","full","backgroundColor","colors","uni__dependencies","fontFamily","sans","fontSize","sm","lineHeight","color","hi","position","right","bottom","spacing","borderWidth","borderColor","panel"],"sources":["../../src/components/AgentAvatar.tsx"],"sourcesContent":["import type { DotTone } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { Dot } from './Dot';\n\n/** How an agent is doing, as the avatar's corner dot shows it. */\nexport type AgentState = 'running' | 'waiting' | 'done' | 'failed';\n\n/** One letter for a first name, two for a hyphenated agent name (`po-developer` is PD). */\nexport function agentInitials(name: string): string {\n return name\n .split(/[-_.\\s]+/u)\n .filter(Boolean)\n .slice(0, 2)\n .map((part) => part.charAt(0).toUpperCase())\n .join('');\n}\n\n// ponytail: mirrors po-web-components AgentAvatar's tint hash; keep the two in step so a seed reads the same tint.\nconst TINTS = ['green', 'teal', 'blue', 'cyan', 'yellow', 'violet'] as const;\ntype Tint = (typeof TINTS)[number];\n\nfunction tintFor(seed: string): Tint {\n let hash = 0;\n for (const char of seed) hash = (hash * 31 + char.charCodeAt(0)) % 997;\n return TINTS[hash % TINTS.length] ?? 'green';\n}\n\nconst RING = 2;\n\nconst STATE_DOT: Readonly<Record<AgentState, DotTone>> = {\n running: 'green',\n waiting: 'yellow',\n done: 'neutral',\n failed: 'red',\n};\n\n/** An agent's face: its initials on a tint fixed by `seed`, with its state as a corner dot. */\nexport function AgentAvatar({\n name,\n seed = name,\n state,\n size = 'md',\n}: {\n name: string;\n seed?: string;\n state?: AgentState;\n size?: 'sm' | 'md';\n}) {\n return (\n <View\n accessible\n accessibilityRole=\"image\"\n accessibilityLabel={state ? `${name}, ${state}` : name}\n testID=\"agent-avatar\"\n style={styles.frame}\n >\n <View style={styles.face(tintFor(seed), size === 'sm' ? 24 : 32)}>\n <Text style={styles.initials}>{agentInitials(name)}</Text>\n </View>\n {state ? <Dot tone={STATE_DOT[state]} size=\"md\" pulse={state === 'running'} style={styles.dot} /> : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { flexShrink: 0 },\n // `size-6` and `size-8`.\n face: (tint: Tint, side: number) => ({\n width: side,\n height: side,\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: theme.borderRadius.full,\n backgroundColor: theme.colors[`tint-${tint}`],\n }),\n initials: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.hi,\n },\n // `-right-0.5 -bottom-0.5 ring-2 ring-po-panel`: a ring sits outside the dot, a border inside, so the box grows by it.\n dot: {\n position: 'absolute',\n right: -2 - RING,\n bottom: -2 - RING,\n width: theme.spacing(2) + 2 * RING,\n height: theme.spacing(2) + 2 * RING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AAOD;EACPE,QAAQF;EACRG,YAAY;EACZC,gBAAgB;EAChBC,cAAcR,MAAMQ,aAAaC;EACjCC,iBAAiBV,MAAMW,OAAO,QAAQT;EAAOU,mBAAA,CAAA,CAAA;CAC/C;CACAf,UAAU;EACRgB,YAAYrD,OAAOwC,MAAMa,WAAWC,IAAI;EACxCC,UAAUf,MAAMe,SAASC;EACzBC,YAAYjB,MAAMiB,WAAWD;EAC7BE,OAAOlB,MAAMW,OAAOQ;EAAEP,mBAAA,CAAA,CAAA;CACxB;CAEAd,KAAK;EACHsB,UAAU;EACVC,OAAO;EACPC,QAAQ;EACRlB,OAAOJ,MAAMuB,QAAQ,CAAC,IAAI;EAC1BlB,QAAQL,MAAMuB,QAAQ,CAAC,IAAI;EAC3BC,aAAazC;EACb0C,aAAazB,MAAMW,OAAOe;EAAKd,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChipTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { ChipTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/components/Badge.d.ts
|
|
5
5
|
export type BadgeTone = ChipTone;
|
|
@@ -2,12 +2,12 @@ import { fontOf } from "../lib/fonts.mjs";
|
|
|
2
2
|
import { CHIP_INK } from "../lib/tone.mjs";
|
|
3
3
|
import { wrapText } from "../lib/wrapText.mjs";
|
|
4
4
|
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
6
5
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
6
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/Badge.tsx
|
|
10
|
-
/** `border-
|
|
10
|
+
/** `border-po-<accent>/40`. */
|
|
11
11
|
const EDGE_ALPHA_PERCENT = 40;
|
|
12
12
|
/** An outlined chip in one of the accent tones. */
|
|
13
13
|
function Badge({ tone = "neutral", size = "sm", children, style, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.mjs","names":["ChipTone","withAlpha","ReactNode","StyleProp","ViewProps","ViewStyle","StyleSheet","useUnistyles","fontOf","CHIP_INK","wrapText","BadgeTone","BadgeSize","EDGE_ALPHA_PERCENT","BadgeProps","Omit","tone","size","children","style","Badge","props","theme","_styles","styles","useVariants","edge","undefined","borderColor","colors","badge","label","create","ink","color","flexDirection","alignItems","alignSelf","gap","spacing","borderRadius","DEFAULT","borderWidth","border","variants","xs","paddingHorizontal","paddingVertical","sm","md","lg","uni__dependencies","fontFamily","sans","neutral","blue","green","yellow","red","magenta","violet","cyan","orange","teal","fontSize","lineHeight","fontWeight","semibold","base"],"sources":["../../src/components/Badge.tsx"],"sourcesContent":["import { type ChipTone, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { CHIP_INK } from '../lib/tone';\nimport { wrapText } from '../lib/wrapText';\n\nexport type BadgeTone = ChipTone;\nexport type BadgeSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `border-
|
|
1
|
+
{"version":3,"file":"Badge.mjs","names":["ChipTone","withAlpha","ReactNode","StyleProp","ViewProps","ViewStyle","StyleSheet","useUnistyles","fontOf","CHIP_INK","wrapText","BadgeTone","BadgeSize","EDGE_ALPHA_PERCENT","BadgeProps","Omit","tone","size","children","style","Badge","props","theme","_styles","styles","useVariants","edge","undefined","borderColor","colors","badge","label","create","ink","color","flexDirection","alignItems","alignSelf","gap","spacing","borderRadius","DEFAULT","borderWidth","border","variants","xs","paddingHorizontal","paddingVertical","sm","md","lg","uni__dependencies","fontFamily","sans","neutral","blue","green","yellow","red","magenta","violet","cyan","orange","teal","fontSize","lineHeight","fontWeight","semibold","base"],"sources":["../../src/components/Badge.tsx"],"sourcesContent":["import { type ChipTone, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { CHIP_INK } from '../lib/tone';\nimport { wrapText } from '../lib/wrapText';\n\nexport type BadgeTone = ChipTone;\nexport type BadgeSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `border-po-<accent>/40`. */\nconst EDGE_ALPHA_PERCENT = 40;\n\nexport interface BadgeProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: BadgeTone;\n /** The same rungs Button names, so a chip can sit beside a button of any size. */\n size?: BadgeSize;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** An outlined chip in one of the accent tones. */\nexport function Badge({ tone = 'neutral', size = 'sm', children, style, ...props }: BadgeProps) {\n const { theme } = useUnistyles();\n styles.useVariants({ tone, size });\n // Alpha mixes are computed in render from useUnistyles(), not in StyleSheet.create: on web Unistyles hands\n // the stylesheet CSS variables, which withAlpha cannot read.\n const edge =\n tone === 'neutral' ? undefined : { borderColor: withAlpha(theme.colors[CHIP_INK[tone]], EDGE_ALPHA_PERCENT) };\n return (\n <View style={[styles.badge, edge, style]} {...props}>\n {wrapText(children, styles.label)}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const ink = (tone: ChipTone) => ({ color: theme.colors[CHIP_INK[tone]] });\n return {\n badge: {\n flexDirection: 'row',\n alignItems: 'center',\n alignSelf: 'flex-start',\n gap: theme.spacing(1.5),\n borderRadius: theme.borderRadius.DEFAULT,\n borderWidth: 1,\n borderColor: theme.colors.border,\n variants: {\n size: {\n xs: { paddingHorizontal: theme.spacing(1.5), paddingVertical: 1 },\n sm: { paddingHorizontal: theme.spacing(2), paddingVertical: theme.spacing(0.5) },\n md: { paddingHorizontal: theme.spacing(2.5), paddingVertical: theme.spacing(1) },\n lg: { paddingHorizontal: theme.spacing(3), paddingVertical: theme.spacing(1.5) },\n },\n },\n },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n variants: {\n tone: {\n neutral: ink('neutral'),\n blue: ink('blue'),\n green: ink('green'),\n yellow: ink('yellow'),\n red: ink('red'),\n magenta: ink('magenta'),\n violet: ink('violet'),\n cyan: ink('cyan'),\n orange: ink('orange'),\n teal: ink('teal'),\n },\n size: {\n xs: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm, fontWeight: theme.fontWeight.semibold },\n sm: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n md: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n lg: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n },\n },\n },\n };\n});\n"],"mappings":";;;;;;;;;;AAaA,MAAMa,qBAAqB;;AAW3B,SAAgBO,MAAM,EAAEJ,OAAO,WAAWC,OAAO,MAAMC,UAAUC,OAAO,GAAGE,SAAqB;CAC9F,MAAM,EAAEC,UAAUf,aAAa;CAAE,MAAAgB,UAAAC;CAAA;EAAA,MAAAA,SAAAD,QAAAE,YACd;GAAET;GAAMC;EAAK,CAAC;EAGjC,MAAMS,OACJV,SAAS,YAAYW,SAAY,EAAEC,aAAa3B,UAAUqB,MAAMO,OAAOpB,SAASO,QAAQH,kBAAkB,EAAE;EAC9G,OACE,oBAAC,MAAD;GAAM,OAAO;IAACW,OAAOM;IAAOJ;IAAMP;GAAK;GAAG,GAAIE;aAC3CX,SAASQ,UAAUM,OAAOO,KAAK;EAC5B;CACN;AACJ;AAEA,MAAMP,SAASlB,WAAW0B,QAAQV,UAAU;CAC1C,MAAMW,OAAOjB,UAAoB,EAAEkB,OAAOZ,MAAM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AWjB;KAAG;KACnEC,IAAI;MAAEe,UAAU1C,MAAM0C,SAAShB;MAAIiB,YAAY3C,MAAM2C,WAAWjB;KAAG;KACnEE,IAAI;MAAEc,UAAU1C,MAAM0C,SAASI;MAAMH,YAAY3C,MAAM2C,WAAWG;KAAK;IACzE;GACF;GAACjB,mBAAA,CAAA,GAAA,CAAA;EACH;CACF;AACF,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { wrapText } from "../lib/wrapText.mjs";
|
|
|
3
3
|
import { IconColorContext } from "../icons/IconColorContext.mjs";
|
|
4
4
|
import { impactLight } from "../lib/haptics.mjs";
|
|
5
5
|
import { Spinner } from "./Spinner.mjs";
|
|
6
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
6
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
7
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ const MIN_TAP_TARGET = 44;
|
|
|
14
14
|
const DISABLED_OPACITY = .4;
|
|
15
15
|
const PRESSED_FILL_OPACITY = .85;
|
|
16
16
|
const RIPPLE_ALPHA_PERCENT = 20;
|
|
17
|
-
/** `hover:border-
|
|
17
|
+
/** `hover:border-po-green/50`. */
|
|
18
18
|
const PRESSED_EDGE_ALPHA_PERCENT = 50;
|
|
19
19
|
/** The visual height of each size, from which hitSlop pads the tap target to 44pt. */
|
|
20
20
|
const SIZE_HEIGHT = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","names":["NativeColorToken","withAlpha","ReactNode","PressableProps","StyleProp","ViewStyle","StyleSheet","useUnistyles","IconColorContext","fontOf","impactLight","wrapText","Spinner","ButtonVariant","ButtonSize","MIN_TAP_TARGET","DISABLED_OPACITY","PRESSED_FILL_OPACITY","RIPPLE_ALPHA_PERCENT","PRESSED_EDGE_ALPHA_PERCENT","SIZE_HEIGHT","Readonly","Record","xs","sm","md","lg","icon","card","INK","rest","pressed","primary","secondary","outline","ghost","subtle","danger","success","link","HAPTIC_VARIANTS","ReadonlySet","Set","ButtonProps","Omit","variant","size","loading","loadingLabel","children","style","Button","disabled","onPress","hitSlop","accessibilityState","props","theme","_styles","styles","useVariants","inactive","slop","Math","max","ink","busy","undefined","text","color","colors","borderless","event","has","button","borderColor","green","token","label","labelPressed","create","flexDirection","alignItems","justifyContent","gap","spacing","borderRadius","borderWidth","overflow","variants","backgroundColor","selected","border","panel","red","height","paddingHorizontal","DEFAULT","width","padding","alignSelf","minHeight","paddingVertical","uni__dependencies","opacity","deep","fontFamily","sans","fontWeight","medium","semibold","fontSize","lineHeight","base","textDecorationLine"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import { type NativeColorToken, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport type { ReactNode } from 'react';\nimport { Pressable, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { IconColorContext } from '../icons/IconColorContext';\nimport { fontOf } from '../lib/fonts';\nimport { impactLight } from '../lib/haptics';\nimport { wrapText } from '../lib/wrapText';\nimport { Spinner } from './Spinner';\n\nexport type ButtonVariant =\n | 'primary'\n | 'secondary'\n | 'outline'\n | 'ghost'\n | 'subtle'\n | 'danger'\n | 'danger-outline'\n | 'success'\n | 'link';\nexport type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'icon' | 'icon-md' | 'card';\n\n/** Apple's and Google's minimum tap target; a smaller visual box makes up the rest with hitSlop. */\nconst MIN_TAP_TARGET = 44;\nconst DISABLED_OPACITY = 0.4;\nconst PRESSED_FILL_OPACITY = 0.85;\nconst RIPPLE_ALPHA_PERCENT = 20;\n/** `hover:border-doom-green/50`. */\nconst PRESSED_EDGE_ALPHA_PERCENT = 50;\n\n/** The visual height of each size, from which hitSlop pads the tap target to 44pt. */\nconst SIZE_HEIGHT: Readonly<Record<ButtonSize, number>> = {\n xs: 24,\n sm: 28,\n md: 32,\n lg: 36,\n icon: 24,\n 'icon-md': 32,\n card: MIN_TAP_TARGET,\n};\n\n/** The label ink of each variant, and the ink it lifts to while pressed (the web hover). */\nconst INK: Readonly<Record<ButtonVariant, { rest: NativeColorToken; pressed: NativeColorToken }>> = {\n primary: { rest: 'on-selected', pressed: 'on-selected' },\n secondary: { rest: 'magenta', pressed: 'magenta' },\n outline: { rest: 'dim', pressed: 'hi' },\n ghost: { rest: 'dim', pressed: 'hi' },\n subtle: { rest: 'dim', pressed: 'hi' },\n danger: { rest: 'rail', pressed: 'rail' },\n 'danger-outline': { rest: 'red', pressed: 'red' },\n success: { rest: 'rail', pressed: 'rail' },\n link: { rest: 'blue', pressed: 'blue' },\n};\n\n/** Presses that commit something get a light impact; the rest stay quiet. */\nconst HAPTIC_VARIANTS: ReadonlySet<ButtonVariant> = new Set(['primary', 'danger', 'success']);\n\nexport interface ButtonProps extends Omit<PressableProps, 'children' | 'style'> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Work is in flight: the button shows a spinner and stops accepting presses. */\n loading?: boolean;\n /** What the spinner announces while loading; omit it and the wait is silent. */\n loadingLabel?: string;\n /** A bare string is drawn as the label; elements (an icon, a card's lines) render as given. */\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The one button: every variant is a theme token, a press dims or lifts it, and committing presses buzz once. */\nexport function Button({\n variant = 'outline',\n size = 'md',\n loading = false,\n loadingLabel,\n disabled,\n onPress,\n children,\n style,\n hitSlop,\n accessibilityState,\n ...props\n}: ButtonProps) {\n const { theme } = useUnistyles();\n styles.useVariants({ variant, size });\n const inactive = (disabled ?? false) || loading;\n const slop = Math.max(0, (MIN_TAP_TARGET - SIZE_HEIGHT[size]) / 2);\n const ink = INK[variant];\n return (\n <Pressable\n accessibilityRole={variant === 'link' ? 'link' : 'button'}\n accessibilityState={{ ...accessibilityState, disabled: inactive, busy: loading }}\n accessibilityValue={loading && loadingLabel !== undefined ? { text: loadingLabel } : undefined}\n disabled={inactive}\n hitSlop={hitSlop ?? slop}\n android_ripple={{ color: withAlpha(theme.colors[ink.pressed], RIPPLE_ALPHA_PERCENT), borderless: false }}\n onPress={(event) => {\n if (HAPTIC_VARIANTS.has(variant)) impactLight();\n onPress?.(event);\n }}\n style={({ pressed }) => [\n styles.button,\n pressed && styles.pressed,\n // Alpha mixes are computed in render from useUnistyles(), not in StyleSheet.create: on web Unistyles hands\n // the stylesheet CSS variables, which withAlpha cannot read.\n pressed && variant === 'outline' && { borderColor: withAlpha(theme.colors.green, PRESSED_EDGE_ALPHA_PERCENT) },\n inactive && styles.disabled,\n style,\n ]}\n {...props}\n >\n {({ pressed }) => {\n const token = pressed ? ink.pressed : ink.rest;\n return (\n <IconColorContext.Provider value={token}>\n {loading ? <Spinner color={token} /> : null}\n {wrapText(children, [styles.label, pressed && styles.labelPressed, { color: theme.colors[token] }])}\n </IconColorContext.Provider>\n );\n }}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n button: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: theme.spacing(1.5),\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: 'transparent',\n overflow: 'hidden',\n variants: {\n variant: {\n primary: { backgroundColor: theme.colors.selected },\n secondary: { borderColor: theme.colors['edge-magenta'], backgroundColor: theme.colors['tint-magenta'] },\n outline: { borderColor: theme.colors.border },\n ghost: {},\n subtle: { backgroundColor: theme.colors.panel },\n danger: { backgroundColor: theme.colors.red },\n 'danger-outline': { borderColor: theme.colors['edge-red'], backgroundColor: theme.colors['tint-red'] },\n success: { backgroundColor: theme.colors.green },\n link: {},\n },\n size: {\n xs: { height: SIZE_HEIGHT.xs, paddingHorizontal: theme.spacing(1.5), borderRadius: theme.borderRadius.DEFAULT },\n sm: { height: SIZE_HEIGHT.sm, paddingHorizontal: theme.spacing(2.5) },\n md: { height: SIZE_HEIGHT.md, paddingHorizontal: theme.spacing(3) },\n lg: { height: SIZE_HEIGHT.lg, paddingHorizontal: theme.spacing(3.5) },\n icon: {\n width: SIZE_HEIGHT.icon,\n height: SIZE_HEIGHT.icon,\n padding: 0,\n borderRadius: theme.borderRadius.DEFAULT,\n },\n 'icon-md': { width: SIZE_HEIGHT['icon-md'], height: SIZE_HEIGHT['icon-md'], padding: 0 },\n card: {\n alignSelf: 'stretch',\n flexDirection: 'column',\n alignItems: 'stretch',\n justifyContent: 'flex-start',\n gap: theme.spacing(1),\n minHeight: SIZE_HEIGHT.card,\n paddingHorizontal: 11,\n paddingVertical: theme.spacing(2.5),\n },\n },\n },\n },\n pressed: {\n variants: {\n variant: {\n primary: { opacity: PRESSED_FILL_OPACITY },\n secondary: { opacity: PRESSED_FILL_OPACITY },\n outline: {},\n ghost: { backgroundColor: theme.colors.panel },\n subtle: { backgroundColor: theme.colors.deep },\n danger: { opacity: PRESSED_FILL_OPACITY },\n 'danger-outline': { opacity: PRESSED_FILL_OPACITY },\n success: { opacity: PRESSED_FILL_OPACITY },\n link: {},\n },\n },\n },\n disabled: { opacity: DISABLED_OPACITY },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontWeight: theme.fontWeight.medium,\n variants: {\n variant: {\n primary: { fontWeight: theme.fontWeight.semibold },\n secondary: { fontWeight: theme.fontWeight.semibold },\n outline: {},\n ghost: {},\n subtle: {},\n danger: { fontWeight: theme.fontWeight.semibold },\n 'danger-outline': { fontWeight: theme.fontWeight.semibold },\n success: { fontWeight: theme.fontWeight.semibold },\n link: {},\n },\n size: {\n xs: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n sm: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n md: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n lg: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n icon: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n 'icon-md': { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n card: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n },\n },\n },\n labelPressed: {\n variants: {\n variant: {\n primary: {},\n secondary: {},\n outline: {},\n ghost: {},\n subtle: {},\n danger: {},\n 'danger-outline': {},\n success: {},\n link: { textDecorationLine: 'underline' },\n },\n },\n },\n}));\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAMe,iBAAiB;AACvB,MAAMC,mBAAmB;AACzB,MAAMC,uBAAuB;AAC7B,MAAMC,uBAAuB;;AAE7B,MAAMC,6BAA6B;;AAGnC,MAAMC,cAAoD;CACxDG,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,MAAM;CACN,WAAW;CACXC,MAAMb;AACR;;AAGA,MAAMc,MAA8F;CAClGG,SAAS;EAAEF,MAAM;EAAeC,SAAS;CAAc;CACvDE,WAAW;EAAEH,MAAM;EAAWC,SAAS;CAAU;CACjDG,SAAS;EAAEJ,MAAM;EAAOC,SAAS;CAAK;CACtCI,OAAO;EAAEL,MAAM;EAAOC,SAAS;CAAK;CACpCK,QAAQ;EAAEN,MAAM;EAAOC,SAAS;CAAK;CACrCM,QAAQ;EAAEP,MAAM;EAAQC,SAAS;CAAO;CACxC,kBAAkB;EAAED,MAAM;EAAOC,SAAS;CAAM;CAChDO,SAAS;EAAER,MAAM;EAAQC,SAAS;CAAO;CACzCQ,MAAM;EAAET,MAAM;EAAQC,SAAS;CAAO;AACxC;;AAGA,MAAMS,kCAA8C,IAAIE,IAAI;CAAC;CAAW;CAAU;AAAS,CAAC;;AAe5F,SAAgBS,OAAO,EACrBN,UAAU,WACVC,OAAO,MACPC,UAAU,OACVC,cACAI,UACAC,SACAJ,UACAC,OACAI,SACAC,oBACA,GAAGC,SACW;CACd,MAAM,EAAEC,UAAUlD,aAAa;CAAE,MAAAmD,UAAAC;CAAA;EAAA,MAAAA,SAAAD,QAAAE,YACd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AG;IACnEA,IAAI;KAAEuF,UAAUtD,MAAMsD,SAASvF;KAAIwF,YAAYvD,MAAMuD,WAAWxF;IAAG;IACnEC,IAAI;KAAEsF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IACvEvF,IAAI;KAAEqF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IACvEtF,MAAM;KAAEoF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IACzE,WAAW;KAAEF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IAC9ErF,MAAM;KAAEmF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;GAC3E;EACF;EAACV,mBAAA,CAAA,GAAA,CAAA;CACH;CACAxB,cAAc;EACZU,UAAU,EACR5C,SAAS;GACPb,SAAS,CAAC;GACVC,WAAW,CAAC;GACZC,SAAS,CAAC;GACVC,OAAO,CAAC;GACRC,QAAQ,CAAC;GACTC,QAAQ,CAAC;GACT,kBAAkB,CAAC;GACnBC,SAAS,CAAC;GACVC,MAAM,EAAE2E,oBAAoB,YAAY;EAC1C,EACF;EAACX,mBAAA,CAAA,CAAA;CACH;AACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"Button.mjs","names":["NativeColorToken","withAlpha","ReactNode","PressableProps","StyleProp","ViewStyle","StyleSheet","useUnistyles","IconColorContext","fontOf","impactLight","wrapText","Spinner","ButtonVariant","ButtonSize","MIN_TAP_TARGET","DISABLED_OPACITY","PRESSED_FILL_OPACITY","RIPPLE_ALPHA_PERCENT","PRESSED_EDGE_ALPHA_PERCENT","SIZE_HEIGHT","Readonly","Record","xs","sm","md","lg","icon","card","INK","rest","pressed","primary","secondary","outline","ghost","subtle","danger","success","link","HAPTIC_VARIANTS","ReadonlySet","Set","ButtonProps","Omit","variant","size","loading","loadingLabel","children","style","Button","disabled","onPress","hitSlop","accessibilityState","props","theme","_styles","styles","useVariants","inactive","slop","Math","max","ink","busy","undefined","text","color","colors","borderless","event","has","button","borderColor","green","token","label","labelPressed","create","flexDirection","alignItems","justifyContent","gap","spacing","borderRadius","borderWidth","overflow","variants","backgroundColor","selected","border","panel","red","height","paddingHorizontal","DEFAULT","width","padding","alignSelf","minHeight","paddingVertical","uni__dependencies","opacity","deep","fontFamily","sans","fontWeight","medium","semibold","fontSize","lineHeight","base","textDecorationLine"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import { type NativeColorToken, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport type { ReactNode } from 'react';\nimport { Pressable, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { IconColorContext } from '../icons/IconColorContext';\nimport { fontOf } from '../lib/fonts';\nimport { impactLight } from '../lib/haptics';\nimport { wrapText } from '../lib/wrapText';\nimport { Spinner } from './Spinner';\n\nexport type ButtonVariant =\n | 'primary'\n | 'secondary'\n | 'outline'\n | 'ghost'\n | 'subtle'\n | 'danger'\n | 'danger-outline'\n | 'success'\n | 'link';\nexport type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'icon' | 'icon-md' | 'card';\n\n/** Apple's and Google's minimum tap target; a smaller visual box makes up the rest with hitSlop. */\nconst MIN_TAP_TARGET = 44;\nconst DISABLED_OPACITY = 0.4;\nconst PRESSED_FILL_OPACITY = 0.85;\nconst RIPPLE_ALPHA_PERCENT = 20;\n/** `hover:border-po-green/50`. */\nconst PRESSED_EDGE_ALPHA_PERCENT = 50;\n\n/** The visual height of each size, from which hitSlop pads the tap target to 44pt. */\nconst SIZE_HEIGHT: Readonly<Record<ButtonSize, number>> = {\n xs: 24,\n sm: 28,\n md: 32,\n lg: 36,\n icon: 24,\n 'icon-md': 32,\n card: MIN_TAP_TARGET,\n};\n\n/** The label ink of each variant, and the ink it lifts to while pressed (the web hover). */\nconst INK: Readonly<Record<ButtonVariant, { rest: NativeColorToken; pressed: NativeColorToken }>> = {\n primary: { rest: 'on-selected', pressed: 'on-selected' },\n secondary: { rest: 'magenta', pressed: 'magenta' },\n outline: { rest: 'dim', pressed: 'hi' },\n ghost: { rest: 'dim', pressed: 'hi' },\n subtle: { rest: 'dim', pressed: 'hi' },\n danger: { rest: 'rail', pressed: 'rail' },\n 'danger-outline': { rest: 'red', pressed: 'red' },\n success: { rest: 'rail', pressed: 'rail' },\n link: { rest: 'blue', pressed: 'blue' },\n};\n\n/** Presses that commit something get a light impact; the rest stay quiet. */\nconst HAPTIC_VARIANTS: ReadonlySet<ButtonVariant> = new Set(['primary', 'danger', 'success']);\n\nexport interface ButtonProps extends Omit<PressableProps, 'children' | 'style'> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Work is in flight: the button shows a spinner and stops accepting presses. */\n loading?: boolean;\n /** What the spinner announces while loading; omit it and the wait is silent. */\n loadingLabel?: string;\n /** A bare string is drawn as the label; elements (an icon, a card's lines) render as given. */\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The one button: every variant is a theme token, a press dims or lifts it, and committing presses buzz once. */\nexport function Button({\n variant = 'outline',\n size = 'md',\n loading = false,\n loadingLabel,\n disabled,\n onPress,\n children,\n style,\n hitSlop,\n accessibilityState,\n ...props\n}: ButtonProps) {\n const { theme } = useUnistyles();\n styles.useVariants({ variant, size });\n const inactive = (disabled ?? false) || loading;\n const slop = Math.max(0, (MIN_TAP_TARGET - SIZE_HEIGHT[size]) / 2);\n const ink = INK[variant];\n return (\n <Pressable\n accessibilityRole={variant === 'link' ? 'link' : 'button'}\n accessibilityState={{ ...accessibilityState, disabled: inactive, busy: loading }}\n accessibilityValue={loading && loadingLabel !== undefined ? { text: loadingLabel } : undefined}\n disabled={inactive}\n hitSlop={hitSlop ?? slop}\n android_ripple={{ color: withAlpha(theme.colors[ink.pressed], RIPPLE_ALPHA_PERCENT), borderless: false }}\n onPress={(event) => {\n if (HAPTIC_VARIANTS.has(variant)) impactLight();\n onPress?.(event);\n }}\n style={({ pressed }) => [\n styles.button,\n pressed && styles.pressed,\n // Alpha mixes are computed in render from useUnistyles(), not in StyleSheet.create: on web Unistyles hands\n // the stylesheet CSS variables, which withAlpha cannot read.\n pressed && variant === 'outline' && { borderColor: withAlpha(theme.colors.green, PRESSED_EDGE_ALPHA_PERCENT) },\n inactive && styles.disabled,\n style,\n ]}\n {...props}\n >\n {({ pressed }) => {\n const token = pressed ? ink.pressed : ink.rest;\n return (\n <IconColorContext.Provider value={token}>\n {loading ? <Spinner color={token} /> : null}\n {wrapText(children, [styles.label, pressed && styles.labelPressed, { color: theme.colors[token] }])}\n </IconColorContext.Provider>\n );\n }}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n button: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: theme.spacing(1.5),\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: 'transparent',\n overflow: 'hidden',\n variants: {\n variant: {\n primary: { backgroundColor: theme.colors.selected },\n secondary: { borderColor: theme.colors['edge-magenta'], backgroundColor: theme.colors['tint-magenta'] },\n outline: { borderColor: theme.colors.border },\n ghost: {},\n subtle: { backgroundColor: theme.colors.panel },\n danger: { backgroundColor: theme.colors.red },\n 'danger-outline': { borderColor: theme.colors['edge-red'], backgroundColor: theme.colors['tint-red'] },\n success: { backgroundColor: theme.colors.green },\n link: {},\n },\n size: {\n xs: { height: SIZE_HEIGHT.xs, paddingHorizontal: theme.spacing(1.5), borderRadius: theme.borderRadius.DEFAULT },\n sm: { height: SIZE_HEIGHT.sm, paddingHorizontal: theme.spacing(2.5) },\n md: { height: SIZE_HEIGHT.md, paddingHorizontal: theme.spacing(3) },\n lg: { height: SIZE_HEIGHT.lg, paddingHorizontal: theme.spacing(3.5) },\n icon: {\n width: SIZE_HEIGHT.icon,\n height: SIZE_HEIGHT.icon,\n padding: 0,\n borderRadius: theme.borderRadius.DEFAULT,\n },\n 'icon-md': { width: SIZE_HEIGHT['icon-md'], height: SIZE_HEIGHT['icon-md'], padding: 0 },\n card: {\n alignSelf: 'stretch',\n flexDirection: 'column',\n alignItems: 'stretch',\n justifyContent: 'flex-start',\n gap: theme.spacing(1),\n minHeight: SIZE_HEIGHT.card,\n paddingHorizontal: 11,\n paddingVertical: theme.spacing(2.5),\n },\n },\n },\n },\n pressed: {\n variants: {\n variant: {\n primary: { opacity: PRESSED_FILL_OPACITY },\n secondary: { opacity: PRESSED_FILL_OPACITY },\n outline: {},\n ghost: { backgroundColor: theme.colors.panel },\n subtle: { backgroundColor: theme.colors.deep },\n danger: { opacity: PRESSED_FILL_OPACITY },\n 'danger-outline': { opacity: PRESSED_FILL_OPACITY },\n success: { opacity: PRESSED_FILL_OPACITY },\n link: {},\n },\n },\n },\n disabled: { opacity: DISABLED_OPACITY },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontWeight: theme.fontWeight.medium,\n variants: {\n variant: {\n primary: { fontWeight: theme.fontWeight.semibold },\n secondary: { fontWeight: theme.fontWeight.semibold },\n outline: {},\n ghost: {},\n subtle: {},\n danger: { fontWeight: theme.fontWeight.semibold },\n 'danger-outline': { fontWeight: theme.fontWeight.semibold },\n success: { fontWeight: theme.fontWeight.semibold },\n link: {},\n },\n size: {\n xs: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n sm: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n md: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n lg: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n icon: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n 'icon-md': { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n card: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n },\n },\n },\n labelPressed: {\n variants: {\n variant: {\n primary: {},\n secondary: {},\n outline: {},\n ghost: {},\n subtle: {},\n danger: {},\n 'danger-outline': {},\n success: {},\n link: { textDecorationLine: 'underline' },\n },\n },\n },\n}));\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAMe,iBAAiB;AACvB,MAAMC,mBAAmB;AACzB,MAAMC,uBAAuB;AAC7B,MAAMC,uBAAuB;;AAE7B,MAAMC,6BAA6B;;AAGnC,MAAMC,cAAoD;CACxDG,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,MAAM;CACN,WAAW;CACXC,MAAMb;AACR;;AAGA,MAAMc,MAA8F;CAClGG,SAAS;EAAEF,MAAM;EAAeC,SAAS;CAAc;CACvDE,WAAW;EAAEH,MAAM;EAAWC,SAAS;CAAU;CACjDG,SAAS;EAAEJ,MAAM;EAAOC,SAAS;CAAK;CACtCI,OAAO;EAAEL,MAAM;EAAOC,SAAS;CAAK;CACpCK,QAAQ;EAAEN,MAAM;EAAOC,SAAS;CAAK;CACrCM,QAAQ;EAAEP,MAAM;EAAQC,SAAS;CAAO;CACxC,kBAAkB;EAAED,MAAM;EAAOC,SAAS;CAAM;CAChDO,SAAS;EAAER,MAAM;EAAQC,SAAS;CAAO;CACzCQ,MAAM;EAAET,MAAM;EAAQC,SAAS;CAAO;AACxC;;AAGA,MAAMS,kCAA8C,IAAIE,IAAI;CAAC;CAAW;CAAU;AAAS,CAAC;;AAe5F,SAAgBS,OAAO,EACrBN,UAAU,WACVC,OAAO,MACPC,UAAU,OACVC,cACAI,UACAC,SACAJ,UACAC,OACAI,SACAC,oBACA,GAAGC,SACW;CACd,MAAM,EAAEC,UAAUlD,aAAa;CAAE,MAAAmD,UAAAC;CAAA;EAAA,MAAAA,SAAAD,QAAAE,YACd;GAAEf;GAASC;EAAK,CAAC;EACpC,MAAMe,YAAYT,YAAY,UAAUL;EACxC,MAAMe,OAAOC,KAAKC,IAAI,IAAIjD,iBAAiBK,YAAY0B,SAAS,CAAC;EACjE,MAAMmB,MAAMpC,IAAIgB;EAChB,OACE,oBAAC,WAAD;GACE,mBAA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UtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IACvEtF,MAAM;KAAEoF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IACzE,WAAW;KAAEF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;IAC9ErF,MAAM;KAAEmF,UAAUtD,MAAMsD,SAASE;KAAMD,YAAYvD,MAAMuD,WAAWC;IAAK;GAC3E;EACF;EAACV,mBAAA,CAAA,GAAA,CAAA;CACH;CACAxB,cAAc;EACZU,UAAU,EACR5C,SAAS;GACPb,SAAS,CAAC;GACVC,WAAW,CAAC;GACZC,SAAS,CAAC;GACVC,OAAO,CAAC;GACRC,QAAQ,CAAC;GACTC,QAAQ,CAAC;GACT,kBAAkB,CAAC;GACnBC,SAAS,CAAC;GACVC,MAAM,EAAE2E,oBAAoB,YAAY;EAC1C,EACF;EAACX,mBAAA,CAAA,CAAA;CACH;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.d.mts","names":[],"sources":["../../src/components/CodeBlock.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.mts","names":[],"sources":["../../src/components/CodeBlock.tsx"],"mappings":";iBAciB;;EAEf;;EAEA;;wBAGc,YAAY,MAAM,YAAY,iCAAc,IAAA"}
|
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { CheckIcon, CopyIcon } from "../icons/icons.mjs";
|
|
2
|
+
import { CopyButton } from "./CopyButton.mjs";
|
|
4
3
|
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
6
4
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
7
|
-
import {
|
|
5
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
8
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
7
|
import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
|
|
10
|
-
import { setStringAsync } from "expo-clipboard";
|
|
11
8
|
|
|
12
9
|
//#region src/components/CodeBlock.tsx
|
|
13
|
-
/** How long the control stays acknowledged before returning to its icon. */
|
|
14
|
-
const FEEDBACK_MS = 1500;
|
|
15
|
-
const LABELS = {
|
|
16
|
-
idle: "copy",
|
|
17
|
-
copied: "copied",
|
|
18
|
-
failed: "copying failed"
|
|
19
|
-
};
|
|
20
10
|
function CodeBlock({ text, language }) {
|
|
21
|
-
const [state, setState] = useState("idle");
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (state === "idle") return void 0;
|
|
24
|
-
const timer = setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
25
|
-
return () => clearTimeout(timer);
|
|
26
|
-
}, [state]);
|
|
27
|
-
const label = LABELS[state];
|
|
28
11
|
return /* @__PURE__ */ jsxs(View, {
|
|
29
12
|
style: styles.block,
|
|
30
13
|
accessibilityLabel: language === void 0 ? void 0 : `${language} code`,
|
|
@@ -37,21 +20,9 @@ function CodeBlock({ text, language }) {
|
|
|
37
20
|
style: styles.code,
|
|
38
21
|
children: text
|
|
39
22
|
})
|
|
40
|
-
}), /* @__PURE__ */ jsx(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
accessibilityLabel: label,
|
|
44
|
-
onPress: () => {
|
|
45
|
-
setStringAsync(text).then((saved) => setState(saved ? "copied" : "failed"), () => setState("failed"));
|
|
46
|
-
},
|
|
47
|
-
style: styles.copy,
|
|
48
|
-
children: state === "copied" ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
49
|
-
size: 12,
|
|
50
|
-
color: "green"
|
|
51
|
-
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
52
|
-
size: 12,
|
|
53
|
-
color: "faint"
|
|
54
|
-
})
|
|
23
|
+
}), /* @__PURE__ */ jsx(CopyButton, {
|
|
24
|
+
text,
|
|
25
|
+
style: styles.copy
|
|
55
26
|
})]
|
|
56
27
|
});
|
|
57
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.mjs","names":["
|
|
1
|
+
{"version":3,"file":"CodeBlock.mjs","names":["StyleSheet","fontOf","CopyButton","CodeBlockProps","text","language","CodeBlock","styles","block","undefined","scroll","code","copy","create","theme","borderRadius","DEFAULT","borderWidth","borderColor","colors","border","backgroundColor","deep","uni__dependencies","padding","spacing","paddingRight","color","fontFamily","mono","fontSize","sm","lineHeight","lineHeightRelaxed","position","top","right"],"sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import { ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { CopyButton } from './CopyButton';\n\n/*\n * A fenced code block: the source in selectable mono type that scrolls\n * sideways rather than wrapping, and a copy button that says when it worked.\n *\n * ponytail: no syntax colouring and no mermaid diagrams yet; a mermaid fence\n * shows its source, which is still the whole content.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The fence's language word, such as `ts`; the web reads it from a `language-*` class. */\n language?: string;\n}\n\nexport function CodeBlock({ text, language }: CodeBlockProps) {\n return (\n <View style={styles.block} accessibilityLabel={language === undefined ? undefined : `${language} code`}>\n <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.scroll}>\n <Text selectable style={styles.code}>\n {text}\n </Text>\n </ScrollView>\n <CopyButton text={text} style={styles.copy} />\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n block: {\n borderRadius: theme.borderRadius.DEFAULT,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: theme.colors.deep,\n },\n // The right padding keeps the first line clear of the copy button.\n scroll: { padding: theme.spacing(2.5), paddingRight: theme.spacing(9) },\n code: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n copy: { position: 'absolute', top: theme.spacing(1.5), right: theme.spacing(1.5) },\n}));\n"],"mappings":";;;;;;;;;AAqBA,SAAgBM,UAAU,EAAEF,MAAMC,YAA4B;CAC5D,OACE,qBAAC,MAAD;EAAM,OAAOE,OAAOC;EAAO,oBAAoBH,aAAaI,SAAYA,SAAY,GAAGJ,SAAQ;YAA/F,CACE,oBAAC,YAAD;GAAY;GAAW,gCAAgC;GAAO,uBAAuBE,OAAOG;aAC1F,oBAAC,MAAD;IAAM;IAAW,OAAOH,OAAOI;cAC5BP;GACG;EACI,IACZ,oBAAC,YAAD;GAAkBA;GAAM,OAAOG,OAAOK;EAAK,EACvC;;AAEV;AAEA,MAAML,SAASP,WAAWa,QAAQC,WAAW;CAC3CN,OAAO;EACLO,cAAcD,MAAMC,aAAaC;EACjCC,aAAa;EACbC,aAAaJ,MAAMK,OAAOC;EAC1BC,iBAAiBP,MAAMK,OAAOG;EAAIC,mBAAA,CAAA,CAAA;CACpC;CAEAb,QAAQ;EAAEc,SAASV,MAAMW,QAAQ,GAAG;EAAGC,cAAcZ,MAAMW,QAAQ,CAAC;EAACF,mBAAA,CAAA,CAAA;CAAC;CACtEZ,MAAM;EACJgB,OAAOb,MAAMK,OAAOf;EACpBwB,YAAY3B,OAAOa,MAAMc,WAAWC,IAAI;EACxCC,UAAUhB,MAAMgB,SAASC;EACzBC,YAAYlB,MAAMmB,kBAAkBF;EAAER,mBAAA,CAAA,CAAA;CACxC;CACAX,MAAM;EAAEsB,UAAU;EAAYC,KAAKrB,MAAMW,QAAQ,GAAG;EAAGW,OAAOtB,MAAMW,QAAQ,GAAG;EAACF,mBAAA,CAAA,CAAA;CAAC;AACnF,EAAE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
//#region src/components/CopyButton.d.ts
|
|
3
|
+
export interface CopyButtonProps {
|
|
4
|
+
/** The text the press puts on the clipboard. */
|
|
5
|
+
text: string;
|
|
6
|
+
/** What is copied, announced before the state, such as `path`. */
|
|
7
|
+
label?: string;
|
|
8
|
+
style?: StyleProp<ViewStyle>;
|
|
9
|
+
}
|
|
10
|
+
/** A quiet icon button that copies text and says, briefly, whether it worked. */
|
|
11
|
+
export declare function CopyButton({ text, label, style }: CopyButtonProps): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=CopyButton.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.d.mts","names":[],"sources":["../../src/components/CopyButton.tsx"],"mappings":";;iBAkBiB;;EAEf;;EAEA;EACA,QAAQ,UAAU;;;wBAIJ,aAAa,MAAM,OAAO,SAAS,kCAAe,IAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Button } from "./Button.mjs";
|
|
2
|
+
import { CheckIcon, CopyIcon } from "../icons/icons.mjs";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { setStringAsync } from "expo-clipboard";
|
|
6
|
+
|
|
7
|
+
//#region src/components/CopyButton.tsx
|
|
8
|
+
/** How long the control stays acknowledged before returning to its icon. */
|
|
9
|
+
const FEEDBACK_MS = 1500;
|
|
10
|
+
const LABELS = {
|
|
11
|
+
idle: "copy",
|
|
12
|
+
copied: "copied",
|
|
13
|
+
failed: "copying failed"
|
|
14
|
+
};
|
|
15
|
+
/** A quiet icon button that copies text and says, briefly, whether it worked. */
|
|
16
|
+
function CopyButton({ text, label, style }) {
|
|
17
|
+
const [state, setState] = useState("idle");
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (state === "idle") return void 0;
|
|
20
|
+
const timer = setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
21
|
+
return () => clearTimeout(timer);
|
|
22
|
+
}, [state]);
|
|
23
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
24
|
+
variant: "ghost",
|
|
25
|
+
size: "icon",
|
|
26
|
+
accessibilityLabel: label === void 0 ? LABELS[state] : `${LABELS[state]} ${label}`,
|
|
27
|
+
onPress: () => {
|
|
28
|
+
setStringAsync(text).then((saved) => setState(saved ? "copied" : "failed"), () => setState("failed"));
|
|
29
|
+
},
|
|
30
|
+
style,
|
|
31
|
+
children: state === "copied" ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
32
|
+
size: 12,
|
|
33
|
+
color: "green"
|
|
34
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
35
|
+
size: 12,
|
|
36
|
+
color: "faint"
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { CopyButton };
|
|
43
|
+
//# sourceMappingURL=CopyButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.mjs","names":["setStringAsync","useEffect","useState","StyleProp","ViewStyle","CheckIcon","CopyIcon","Button","FEEDBACK_MS","CopyState","LABELS","Readonly","Record","idle","copied","failed","CopyButtonProps","text","label","style","CopyButton","state","setState","undefined","timer","setTimeout","clearTimeout","then","saved"],"sources":["../../src/components/CopyButton.tsx"],"sourcesContent":["import { setStringAsync } from 'expo-clipboard';\nimport { useEffect, useState } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { CheckIcon, CopyIcon } from '../icons/icons';\nimport { Button } from './Button';\n\n/** How long the control stays acknowledged before returning to its icon. */\nconst FEEDBACK_MS = 1500;\n\ntype CopyState = 'idle' | 'copied' | 'failed';\n\nconst LABELS: Readonly<Record<CopyState, string>> = {\n idle: 'copy',\n copied: 'copied',\n failed: 'copying failed',\n};\n\nexport interface CopyButtonProps {\n /** The text the press puts on the clipboard. */\n text: string;\n /** What is copied, announced before the state, such as `path`. */\n label?: string;\n style?: StyleProp<ViewStyle>;\n}\n\n/** A quiet icon button that copies text and says, briefly, whether it worked. */\nexport function CopyButton({ text, label, style }: CopyButtonProps) {\n const [state, setState] = useState<CopyState>('idle');\n\n useEffect(() => {\n if (state === 'idle') return undefined;\n const timer = setTimeout(() => setState('idle'), FEEDBACK_MS);\n return () => clearTimeout(timer);\n }, [state]);\n\n return (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n accessibilityLabel={label === undefined ? LABELS[state] : `${LABELS[state]} ${label}`}\n onPress={() => {\n setStringAsync(text).then(\n (saved) => setState(saved ? 'copied' : 'failed'),\n () => setState('failed'),\n );\n }}\n style={style}\n >\n {state === 'copied' ? <CheckIcon size={12} color=\"green\" /> : <CopyIcon size={12} color=\"faint\" />}\n </Button>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAMQ,cAAc;AAIpB,MAAME,SAA8C;CAClDG,MAAM;CACNC,QAAQ;CACRC,QAAQ;AACV;;AAWA,SAAgBK,WAAW,EAAEH,MAAMC,OAAOC,SAA0B;CAClE,MAAM,CAACE,OAAOC,YAAYpB,SAAoB,MAAM;CAEpDD,gBAAgB;EACd,IAAIoB,UAAU,QAAQ,OAAOE;EAC7B,MAAMC,QAAQC,iBAAiBH,SAAS,MAAM,GAAGd,WAAW;EAC5D,aAAakB,aAAaF,KAAK;CACjC,GAAG,CAACH,KAAK,CAAC;CAEV,OACE,oBAAC,QAAD;EACE,SAAQ;EACR,MAAK;EACL,oBAAoBH,UAAUK,SAAYb,OAAOW,SAAS,GAAGX,OAAOW,OAAM,GAAIH;EAC9E,eAAe;GACblB,eAAeiB,IAAI,CAAC,CAACU,MAClBC,UAAUN,SAASM,QAAQ,WAAW,QAAQ,SACzCN,SAAS,QAAQ,CACzB;EACF;EACOH;YAENE,UAAU,WAAW,oBAAC,WAAD;GAAW,MAAM;GAAI,OAAM;EAAO,KAAM,oBAAC,UAAD;GAAU,MAAM;GAAI,OAAM;EAAO;CACzF;AAEZ"}
|