@kybernesis/cards-react 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +23 -2
- package/dist/CardView.d.ts +93 -0
- package/dist/CardView.js +340 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.d.ts +11 -0
- package/dist/styles.js +182 -0
- package/package.json +46 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kybernesis/cards-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components that draw [`@kybernesis/cards`](../cards) cards. One frame for every card, one body per type, the same in every app that shows them.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { CardStack, cardStyles, type CardContext } from "@kybernesis/cards-react";
|
|
7
|
+
|
|
8
|
+
const ctx: CardContext = {
|
|
9
|
+
agentUrl,
|
|
10
|
+
openUrl: (url) => window.open(url, "_blank", "noopener"),
|
|
11
|
+
onSay: (text) => send(text),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
<>
|
|
15
|
+
<style>{cardStyles}</style>
|
|
16
|
+
<CardStack cards={cards} ctx={ctx} />
|
|
17
|
+
</>;
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The host does everything that touches the outside: opening links, fetching pictures and artifacts from the agent, sending a `say` sentence. Leave a callback out and the card draws without it (no Open button, no preview), never broken.
|
|
21
|
+
|
|
22
|
+
Theme it with `--kyb-*` variables on any ancestor: `--kyb-ink`, `--kyb-ink-secondary`, `--kyb-ink-tertiary`, `--kyb-ink-inverse`, `--kyb-surface`, `--kyb-surface-raised`, `--kyb-stroke`, `--kyb-stroke-strong`, `--kyb-hover`, `--kyb-selected`, `--kyb-good`, `--kyb-bad`, `--kyb-font-label`, `--kyb-font-mono`, `--kyb-fs-xs`, `--kyb-fs-sm`, `--kyb-fs-base`, `--kyb-lh-base`, `--kyb-shadow-menu`. Each has a light default.
|
|
23
|
+
|
|
24
|
+
Artifacts run in a sandboxed frame with no origin and no network. A host whose own content policy blocks scripts in frames passes `renderArtifactHtml` to draw them its own way.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type ApprovalData, type ArtifactData, type Card } from "@kybernesis/cards";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Cards in a reply: what a tool handed back, drawn instead of described.
|
|
5
|
+
*
|
|
6
|
+
* Every card shares one frame (a title, where the data came from, the body,
|
|
7
|
+
* at most a few buttons), so a new type is only a new body. A card is data,
|
|
8
|
+
* never markup; the only thing here that runs anything is an artifact, which
|
|
9
|
+
* runs in a sandboxed frame that cannot reach the agent or the network.
|
|
10
|
+
*
|
|
11
|
+
* Ink and greys only. Green and red appear where they mean good and bad: a
|
|
12
|
+
* change, a check, a diff line. Nothing else is coloured.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here knows which app it is in. Opening a link, fetching a picture
|
|
15
|
+
* or an artifact, and sending a sentence are the host's, through `CardContext`;
|
|
16
|
+
* a host that cannot do one leaves it out and the card draws without it.
|
|
17
|
+
*/
|
|
18
|
+
export type Loaded<T> = ({
|
|
19
|
+
ok: true;
|
|
20
|
+
} & T) | {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
24
|
+
export interface CardContext {
|
|
25
|
+
/** The agent's base URL, for pictures and artifacts on its own origin. */
|
|
26
|
+
agentUrl?: string;
|
|
27
|
+
/** Open an address in the browser. Paths on the agent arrive already resolved against `agentUrl`. */
|
|
28
|
+
openUrl(url: string): void;
|
|
29
|
+
/** A `say` action: sent as the person's next message, only when pressed. Absent hides `say` buttons. */
|
|
30
|
+
onSay?(text: string): void;
|
|
31
|
+
/** Open an artifact in full. Absent hides Open. */
|
|
32
|
+
onOpenArtifact?(artifactId: string, title?: string, version?: number): void;
|
|
33
|
+
/** Fetch a picture the agent serves, as a data URL. Absent: only `data:` and http(s) pictures draw. */
|
|
34
|
+
loadImage?(src: string): Promise<Loaded<{
|
|
35
|
+
dataUrl: string;
|
|
36
|
+
}>>;
|
|
37
|
+
/** Fetch an artifact's content. Absent: the artifact card shows its details and Open, no preview. */
|
|
38
|
+
loadArtifact?(artifactId: string, version?: number): Promise<Loaded<{
|
|
39
|
+
content: string;
|
|
40
|
+
format?: string;
|
|
41
|
+
}>>;
|
|
42
|
+
/**
|
|
43
|
+
* Draw an artifact's page in the card the host's own way, such as from its
|
|
44
|
+
* share link. Return nothing to fall back to `loadArtifact`.
|
|
45
|
+
*/
|
|
46
|
+
renderArtifact?(artifact: ArtifactData, title?: string): ReactNode;
|
|
47
|
+
/** Draw an artifact's HTML in place of the sandboxed frame, for hosts that cannot run one. */
|
|
48
|
+
renderArtifactHtml?(html: string, mode: "inline" | "preview" | "full"): ReactNode;
|
|
49
|
+
/** Save or open a file the agent links to. Absent: the file opens as a link. */
|
|
50
|
+
openFile?(url: string, name: string): void;
|
|
51
|
+
/** The host's markdown, for markdown artifacts. Absent: shown as plain text. */
|
|
52
|
+
renderMarkdown?(text: string): ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export declare function formatSize(bytes: number): string;
|
|
55
|
+
/**
|
|
56
|
+
* The frame's own content policy, first in the document: inline code and data
|
|
57
|
+
* only, no network. The sandbox already gives it no origin; this also stops it
|
|
58
|
+
* loading a script or an image from anywhere.
|
|
59
|
+
*/
|
|
60
|
+
export declare function withPolicy(html: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* An artifact drawn in the conversation: its content in a sandboxed frame
|
|
63
|
+
* (`allow-scripts` without `allow-same-origin`, so it has no origin of its own
|
|
64
|
+
* and cannot reach the agent, the app, or the network), or markdown through
|
|
65
|
+
* the host's renderer.
|
|
66
|
+
*/
|
|
67
|
+
export declare function ArtifactFrame({ artifactId, version, className, mode, ctx, }: {
|
|
68
|
+
artifactId: string;
|
|
69
|
+
version?: number;
|
|
70
|
+
className?: string;
|
|
71
|
+
mode?: "inline" | "preview" | "full";
|
|
72
|
+
ctx: CardContext;
|
|
73
|
+
}): ReactNode;
|
|
74
|
+
export declare function dateLabel(iso?: string): string | undefined;
|
|
75
|
+
/** An event's time as a person reads it: "Thu 29 Oct, 2:00 PM – 3:00 PM". A date alone stays a date. */
|
|
76
|
+
export declare function whenLabel(when?: string, until?: string): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* What an approval would do, as the thing itself: the email with its
|
|
79
|
+
* recipients and body, the event with its time and people. Read-only; the
|
|
80
|
+
* buttons belong to the question that holds it.
|
|
81
|
+
*/
|
|
82
|
+
export declare function ApprovalBody({ data }: {
|
|
83
|
+
data: ApprovalData;
|
|
84
|
+
}): ReactNode;
|
|
85
|
+
export declare function CardView({ card, ctx }: {
|
|
86
|
+
card: Card;
|
|
87
|
+
ctx: CardContext;
|
|
88
|
+
}): ReactNode;
|
|
89
|
+
/** Several cards, in the order they arrived. */
|
|
90
|
+
export declare function CardStack({ cards, ctx }: {
|
|
91
|
+
cards: Card[];
|
|
92
|
+
ctx: CardContext;
|
|
93
|
+
}): ReactNode;
|
package/dist/CardView.js
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cardTitle, isKnownCard, money, routineSchedule, withUnit, } from "@kybernesis/cards";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
const isHttp = (url) => /^https?:\/\//i.test(url);
|
|
5
|
+
function resolve(url, ctx) {
|
|
6
|
+
// A path is on the agent's own address.
|
|
7
|
+
return isHttp(url) ? url : ctx.agentUrl ? new URL(url, ctx.agentUrl).toString() : null;
|
|
8
|
+
}
|
|
9
|
+
function openUrl(url, ctx) {
|
|
10
|
+
const target = resolve(url, ctx);
|
|
11
|
+
if (target)
|
|
12
|
+
ctx.openUrl(target);
|
|
13
|
+
}
|
|
14
|
+
function openFile(url, name, ctx) {
|
|
15
|
+
if (ctx.openFile)
|
|
16
|
+
ctx.openFile(url, name);
|
|
17
|
+
else
|
|
18
|
+
openUrl(url, ctx);
|
|
19
|
+
}
|
|
20
|
+
export function formatSize(bytes) {
|
|
21
|
+
if (bytes < 1024)
|
|
22
|
+
return `${bytes} B`;
|
|
23
|
+
if (bytes < 1024 * 1024)
|
|
24
|
+
return `${Math.round(bytes / 1024)} KB`;
|
|
25
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
26
|
+
}
|
|
27
|
+
function Wait({ className }) {
|
|
28
|
+
return (_jsx("div", { className: className, role: "status", "aria-label": "Loading", children: _jsx("span", { className: "kspin" }) }));
|
|
29
|
+
}
|
|
30
|
+
function usable(a, ctx) {
|
|
31
|
+
if (a.artifact)
|
|
32
|
+
return !!ctx.onOpenArtifact;
|
|
33
|
+
if (a.say)
|
|
34
|
+
return !!ctx.onSay;
|
|
35
|
+
return !!a.url;
|
|
36
|
+
}
|
|
37
|
+
function Actions({ actions, ctx }) {
|
|
38
|
+
const shown = actions?.filter((a) => usable(a, ctx)) ?? [];
|
|
39
|
+
if (!shown.length)
|
|
40
|
+
return null;
|
|
41
|
+
return (_jsx("div", { className: "kcard__actions", children: shown.map((a, i) => (_jsx("button", { type: "button", className: `kbtn${a.primary ? " kbtn--primary" : ""}`, onClick: () => {
|
|
42
|
+
if (a.artifact)
|
|
43
|
+
ctx.onOpenArtifact?.(a.artifact);
|
|
44
|
+
else if (a.url)
|
|
45
|
+
openUrl(a.url, ctx);
|
|
46
|
+
else if (a.say)
|
|
47
|
+
ctx.onSay?.(a.say);
|
|
48
|
+
}, children: a.label }, i))) }));
|
|
49
|
+
}
|
|
50
|
+
function toneClass(tone) {
|
|
51
|
+
return tone === "good" ? " is-good" : tone === "bad" ? " is-bad" : "";
|
|
52
|
+
}
|
|
53
|
+
function Tiles({ tiles }) {
|
|
54
|
+
return (_jsx("div", { className: "kstats", children: tiles.map((t, i) => (_jsxs("div", { className: "kstats__tile", children: [_jsx("div", { className: "klabel", children: t.label }), _jsx("div", { className: "kstats__value", children: t.value }), t.change ? _jsx("div", { className: `kstats__change${toneClass(t.tone)}`, children: t.change }) : null] }, i))) }));
|
|
55
|
+
}
|
|
56
|
+
/** A line, area or bar chart as SVG, with the values under the pointer. */
|
|
57
|
+
function Chart({ data }) {
|
|
58
|
+
const W = 600;
|
|
59
|
+
const H = 160;
|
|
60
|
+
const [hover, setHover] = useState(null);
|
|
61
|
+
const ref = useRef(null);
|
|
62
|
+
const n = data.x.length;
|
|
63
|
+
const all = data.series.flatMap((s) => s.values);
|
|
64
|
+
const lo = Math.min(0, ...all);
|
|
65
|
+
const hi = Math.max(...all, lo + 1);
|
|
66
|
+
const y = (v) => H - 6 - ((v - lo) / (hi - lo)) * (H - 12);
|
|
67
|
+
const x = (i) => (n <= 1 ? W / 2 : (i / (n - 1)) * W);
|
|
68
|
+
const fmt = (v) => withUnit(v.toLocaleString(), data.unit);
|
|
69
|
+
const bars = data.kind === "bar";
|
|
70
|
+
// Where point i sits across the plot, as a share of its width: bars sit in the middle of their slot.
|
|
71
|
+
const across = (i) => (bars ? (i + 0.5) / Math.max(1, n) : x(i) / W);
|
|
72
|
+
const marks = data.series.map((s, si) => {
|
|
73
|
+
if (data.kind === "bar") {
|
|
74
|
+
const group = W / Math.max(1, n);
|
|
75
|
+
const width = (group * 0.7) / data.series.length;
|
|
76
|
+
return s.values.map((v, i) => (_jsx("rect", { className: `kchart__bar kchart__s${si}`, x: i * group + group * 0.15 + si * width, y: Math.min(y(v), y(0)), width: Math.max(1, width - 1), height: Math.abs(y(0) - y(v)) }, `${si}-${i}`)));
|
|
77
|
+
}
|
|
78
|
+
const points = s.values.map((v, i) => `${x(i)},${y(v)}`).join(" ");
|
|
79
|
+
return (_jsxs("g", { children: [data.kind === "area" && si === 0 ? (_jsx("polygon", { className: `kchart__area kchart__s${si}`, points: `${x(0)},${y(lo)} ${points} ${x(s.values.length - 1)},${y(lo)}` })) : null, _jsx("polyline", { className: `kchart__line kchart__s${si}`, points: points, vectorEffect: "non-scaling-stroke" })] }, si));
|
|
80
|
+
});
|
|
81
|
+
const label = (i) => data.x[i] ?? "";
|
|
82
|
+
// Every label while they fit (a week of days); otherwise the ends and the middle.
|
|
83
|
+
const ticks = n <= (bars ? 12 : 8) ? [...Array(n).keys()] : [0, Math.floor((n - 1) / 2), n - 1];
|
|
84
|
+
return (_jsxs("div", { className: "kchart", children: [data.series.length > 1 ? (_jsx("div", { className: "kchart__legend", children: data.series.map((s, si) => (_jsxs("span", { className: "kchart__key", children: [_jsx("span", { className: `kchart__swatch kchart__s${si}` }), s.name] }, si))) })) : null, _jsxs("div", { className: "kchart__plot", children: [_jsxs("div", { className: "kchart__y", children: [_jsx("span", { children: fmt(hi) }), _jsx("span", { children: fmt(lo) })] }), _jsxs("div", { className: "kchart__frame", children: [_jsxs("svg", { ref: ref, viewBox: `0 0 ${W} ${H}`, preserveAspectRatio: "none", className: "kchart__svg", onMouseMove: (e) => {
|
|
85
|
+
const box = ref.current?.getBoundingClientRect();
|
|
86
|
+
if (!box || n === 0)
|
|
87
|
+
return;
|
|
88
|
+
const share = (e.clientX - box.left) / box.width;
|
|
89
|
+
const at = bars ? Math.floor(share * n) : Math.round(share * (n - 1));
|
|
90
|
+
setHover(Math.max(0, Math.min(n - 1, at)));
|
|
91
|
+
}, onMouseLeave: () => setHover(null), children: [_jsx("line", { className: "kchart__base", x1: 0, x2: W, y1: y(0), y2: y(0), vectorEffect: "non-scaling-stroke" }), marks, hover !== null ? (_jsx("line", { className: "kchart__rule", x1: across(hover) * W, x2: across(hover) * W, y1: 0, y2: H, vectorEffect: "non-scaling-stroke" })) : null] }), hover !== null ? (_jsxs("div", { className: "kchart__tip", style: { left: `${across(hover) * 100}%` }, children: [_jsx("div", { className: "klabel", children: label(hover) }), data.series.map((s, si) => (_jsxs("div", { children: [data.series.length > 1 ? `${s.name} ` : "", _jsx("strong", { children: fmt(s.values[hover] ?? 0) })] }, si)))] })) : null, _jsx("div", { className: bars ? "kchart__x kchart__x--slots" : "kchart__x", style: bars ? { gridTemplateColumns: `repeat(${n}, 1fr)` } : undefined, children: bars
|
|
92
|
+
? data.x.map((_, i) => _jsx("span", { children: ticks.includes(i) ? label(i) : "" }, i))
|
|
93
|
+
: ticks.map((i) => _jsx("span", { children: label(i) }, i)) })] })] })] }));
|
|
94
|
+
}
|
|
95
|
+
/** A picture: inline data, a public address, or one the host fetches from the agent. */
|
|
96
|
+
function AgentImage({ src, alt, ctx }) {
|
|
97
|
+
const [state, setState] = useState(null);
|
|
98
|
+
const [big, setBig] = useState(false);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
let live = true;
|
|
101
|
+
if (src.startsWith("data:image/")) {
|
|
102
|
+
setState({ url: src });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!ctx.loadImage) {
|
|
106
|
+
setState(isHttp(src) ? { url: src } : { error: "This picture is on the agent and can't be shown here." });
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!ctx.agentUrl && !isHttp(src)) {
|
|
110
|
+
setState({ error: "No agent address to fetch this from." });
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
setState(null);
|
|
114
|
+
void ctx.loadImage(src).then((r) => {
|
|
115
|
+
if (live)
|
|
116
|
+
setState(r.ok ? { url: r.dataUrl } : { error: r.error });
|
|
117
|
+
});
|
|
118
|
+
return () => {
|
|
119
|
+
live = false;
|
|
120
|
+
};
|
|
121
|
+
}, [src, ctx.agentUrl, ctx.loadImage]);
|
|
122
|
+
if (!state)
|
|
123
|
+
return _jsx(Wait, { className: "kshot__wait" });
|
|
124
|
+
if (!state.url) {
|
|
125
|
+
return (_jsxs("div", { className: "kshot__missing", children: [state.error, isHttp(src) ? (_jsx("button", { type: "button", className: "kbtn", onClick: () => ctx.openUrl(src), children: "Open in browser" })) : null] }));
|
|
126
|
+
}
|
|
127
|
+
return (_jsx("img", { className: `kshot__img${big ? " kshot__img--big" : ""}`, src: state.url, alt: alt, onClick: () => setBig((b) => !b), title: big ? "Smaller" : "Larger" }));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The frame's own content policy, first in the document: inline code and data
|
|
131
|
+
* only, no network. The sandbox already gives it no origin; this also stops it
|
|
132
|
+
* loading a script or an image from anywhere.
|
|
133
|
+
*/
|
|
134
|
+
export function withPolicy(html) {
|
|
135
|
+
const csp = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:";
|
|
136
|
+
return `<meta http-equiv="Content-Security-Policy" content="${csp}">${html}`;
|
|
137
|
+
}
|
|
138
|
+
const MODE_CLASS = { inline: "kartifact--inline", preview: "kartifact--preview", full: "" };
|
|
139
|
+
/**
|
|
140
|
+
* An artifact drawn in the conversation: its content in a sandboxed frame
|
|
141
|
+
* (`allow-scripts` without `allow-same-origin`, so it has no origin of its own
|
|
142
|
+
* and cannot reach the agent, the app, or the network), or markdown through
|
|
143
|
+
* the host's renderer.
|
|
144
|
+
*/
|
|
145
|
+
export function ArtifactFrame({ artifactId, version, className, mode = "full", ctx, }) {
|
|
146
|
+
const [state, setState] = useState(null);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
let live = true;
|
|
149
|
+
setState(null);
|
|
150
|
+
if (!ctx.loadArtifact) {
|
|
151
|
+
setState({ error: "This artifact can't be shown here." });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
void ctx.loadArtifact(artifactId, version).then((r) => {
|
|
155
|
+
if (live)
|
|
156
|
+
setState(r.ok ? { content: r.content, format: r.format } : { error: r.error });
|
|
157
|
+
});
|
|
158
|
+
return () => {
|
|
159
|
+
live = false;
|
|
160
|
+
};
|
|
161
|
+
}, [artifactId, version, ctx.loadArtifact]);
|
|
162
|
+
const classes = [MODE_CLASS[mode], className].filter(Boolean).join(" ");
|
|
163
|
+
if (!state)
|
|
164
|
+
return _jsx(Wait, { className: `kartifact__wait ${classes}` });
|
|
165
|
+
if (state.error)
|
|
166
|
+
return _jsx("div", { className: `kartifact__missing ${classes}`, children: state.error });
|
|
167
|
+
if (state.format === "markdown") {
|
|
168
|
+
return (_jsx("div", { className: `kartifact__doc ${classes}`, children: ctx.renderMarkdown ? ctx.renderMarkdown(state.content ?? "") : _jsx("div", { className: "kartifact__plain", children: state.content }) }));
|
|
169
|
+
}
|
|
170
|
+
if (ctx.renderArtifactHtml) {
|
|
171
|
+
return _jsx("div", { className: `kartifact__host ${classes}`, children: ctx.renderArtifactHtml(state.content ?? "", mode) });
|
|
172
|
+
}
|
|
173
|
+
return (_jsx("iframe", { className: `kartifact__frame ${classes}`, sandbox: "allow-scripts", srcDoc: withPolicy(state.content ?? ""), title: "Artifact", referrerPolicy: "no-referrer" }));
|
|
174
|
+
}
|
|
175
|
+
export function dateLabel(iso) {
|
|
176
|
+
if (!iso)
|
|
177
|
+
return undefined;
|
|
178
|
+
const at = Date.parse(iso);
|
|
179
|
+
if (Number.isNaN(at))
|
|
180
|
+
return undefined;
|
|
181
|
+
return new Date(at).toLocaleString([], { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
|
|
182
|
+
}
|
|
183
|
+
function ArtifactBody({ data, title, ctx }) {
|
|
184
|
+
const meta = [
|
|
185
|
+
data.format === "markdown" ? "Document" : "Page",
|
|
186
|
+
data.version ? `v${data.version}` : undefined,
|
|
187
|
+
dateLabel(data.updatedAt) ? `updated ${dateLabel(data.updatedAt)}` : undefined,
|
|
188
|
+
].filter(Boolean);
|
|
189
|
+
// A host without its own viewer opens the share link, when there is one.
|
|
190
|
+
const link = data.url;
|
|
191
|
+
const open = ctx.onOpenArtifact ?? (link ? () => openUrl(link, ctx) : undefined);
|
|
192
|
+
const drawn = ctx.renderArtifact?.(data, title);
|
|
193
|
+
return (_jsxs(_Fragment, { children: [drawn != null ? (_jsx("div", { className: "kartifact__host", children: drawn })) : !ctx.loadArtifact ? null : data.display === "inline" ? (_jsx(ArtifactFrame, { artifactId: data.artifactId, version: data.version, mode: "inline", ctx: ctx })) : open ? (
|
|
194
|
+
// A document shows its top as a preview; the whole thing opens on a click.
|
|
195
|
+
_jsx("button", { type: "button", className: "kartifact__preview", "aria-label": `Open ${title ?? "artifact"}`, onClick: () => open(data.artifactId, title, data.version), children: _jsx(ArtifactFrame, { artifactId: data.artifactId, version: data.version, mode: "preview", ctx: ctx }) })) : (_jsx("div", { className: "kartifact__preview", children: _jsx(ArtifactFrame, { artifactId: data.artifactId, version: data.version, mode: "preview", ctx: ctx }) })), _jsx("div", { className: "kartifact__row", children: _jsx("span", { className: "kartifact__meta", children: meta.join(" · ") }) }), open ? (_jsx("div", { className: "kcard__actions", children: _jsx("button", { type: "button", className: "kbtn kbtn--primary", onClick: () => open(data.artifactId, title, data.version), children: "Open" }) })) : null] }));
|
|
196
|
+
}
|
|
197
|
+
/** An event's time as a person reads it: "Thu 29 Oct, 2:00 PM – 3:00 PM". A date alone stays a date. */
|
|
198
|
+
export function whenLabel(when, until) {
|
|
199
|
+
if (!when)
|
|
200
|
+
return undefined;
|
|
201
|
+
const dateOnly = /^\d{4}-\d{2}-\d{2}$/;
|
|
202
|
+
const at = Date.parse(when);
|
|
203
|
+
if (Number.isNaN(at))
|
|
204
|
+
return until ? `${when} – ${until}` : when;
|
|
205
|
+
if (dateOnly.test(when)) {
|
|
206
|
+
return new Date(`${when}T00:00:00`).toLocaleDateString([], { weekday: "short", day: "numeric", month: "short" });
|
|
207
|
+
}
|
|
208
|
+
const start = new Date(at);
|
|
209
|
+
const head = start.toLocaleString([], { weekday: "short", day: "numeric", month: "short", hour: "numeric", minute: "2-digit" });
|
|
210
|
+
const end = until ? Date.parse(until) : NaN;
|
|
211
|
+
if (Number.isNaN(end))
|
|
212
|
+
return head;
|
|
213
|
+
const sameDay = new Date(end).toDateString() === start.toDateString();
|
|
214
|
+
const tail = new Date(end).toLocaleString([], sameDay ? { hour: "numeric", minute: "2-digit" } : { weekday: "short", day: "numeric", month: "short", hour: "numeric", minute: "2-digit" });
|
|
215
|
+
return `${head} – ${tail}`;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* What an approval would do, as the thing itself: the email with its
|
|
219
|
+
* recipients and body, the event with its time and people. Read-only; the
|
|
220
|
+
* buttons belong to the question that holds it.
|
|
221
|
+
*/
|
|
222
|
+
export function ApprovalBody({ data }) {
|
|
223
|
+
const rows = [];
|
|
224
|
+
if (data.kind === "email") {
|
|
225
|
+
if (data.to?.length)
|
|
226
|
+
rows.push(["To", data.to.join(", ")]);
|
|
227
|
+
if (data.cc?.length)
|
|
228
|
+
rows.push(["Cc", data.cc.join(", ")]);
|
|
229
|
+
if (data.subject)
|
|
230
|
+
rows.push(["Subject", data.subject]);
|
|
231
|
+
}
|
|
232
|
+
else if (data.kind === "event") {
|
|
233
|
+
if (data.subject)
|
|
234
|
+
rows.push(["Event", data.subject]);
|
|
235
|
+
const when = whenLabel(data.when, data.until);
|
|
236
|
+
if (when)
|
|
237
|
+
rows.push(["When", when]);
|
|
238
|
+
if (data.where)
|
|
239
|
+
rows.push(["Where", data.where]);
|
|
240
|
+
if (data.people?.length)
|
|
241
|
+
rows.push(["With", data.people.join(", ")]);
|
|
242
|
+
}
|
|
243
|
+
else if (data.kind === "message") {
|
|
244
|
+
if (data.channel)
|
|
245
|
+
rows.push(["In", data.channel]);
|
|
246
|
+
if (data.to?.length)
|
|
247
|
+
rows.push(["To", data.to.join(", ")]);
|
|
248
|
+
}
|
|
249
|
+
for (const f of data.fields ?? [])
|
|
250
|
+
rows.push([f.label, f.value]);
|
|
251
|
+
return (_jsxs("div", { className: "kapproval", children: [rows.length ? (_jsx("dl", { className: "kapproval__rows", children: rows.map(([label, value], i) => (_jsxs("div", { className: "kapproval__row", children: [_jsx("dt", { className: "klabel", children: label }), _jsx("dd", { children: value })] }, i))) })) : null, data.body ? _jsx("div", { className: "kapproval__body", children: data.body }) : null] }));
|
|
252
|
+
}
|
|
253
|
+
function CheckGlyph({ state }) {
|
|
254
|
+
if (state === "passed" || state === "done")
|
|
255
|
+
return _jsx("span", { className: "kglyph is-good", children: "\u2713" });
|
|
256
|
+
if (state === "failed")
|
|
257
|
+
return _jsx("span", { className: "kglyph is-bad", children: "\u2717" });
|
|
258
|
+
if (state === "running")
|
|
259
|
+
return _jsx("span", { className: "kglyph", children: "\u2026" });
|
|
260
|
+
if (state === "skipped")
|
|
261
|
+
return _jsx("span", { className: "kglyph", children: "\u2013" });
|
|
262
|
+
return _jsx("span", { className: "kglyph", children: "\u25CB" });
|
|
263
|
+
}
|
|
264
|
+
function FileGlyph() {
|
|
265
|
+
return (_jsxs("svg", { className: "kfile__icon", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z" }), _jsx("path", { d: "M14 3v5h5" })] }));
|
|
266
|
+
}
|
|
267
|
+
function Body({ card, ctx }) {
|
|
268
|
+
switch (card.card) {
|
|
269
|
+
case "stats":
|
|
270
|
+
return _jsx(Tiles, { tiles: card.data.tiles });
|
|
271
|
+
case "chart":
|
|
272
|
+
return _jsx(Chart, { data: card.data });
|
|
273
|
+
case "table": {
|
|
274
|
+
const d = card.data;
|
|
275
|
+
const cell = (v) => (v === null || v === undefined ? "" : typeof v === "number" ? v.toLocaleString() : String(v));
|
|
276
|
+
return (_jsxs("div", { className: "ktable", children: [_jsxs("table", { children: [_jsx("thead", { children: _jsx("tr", { children: d.columns.map((c) => (_jsx("th", { style: c.align === "right" ? { textAlign: "right" } : undefined, children: c.label }, c.key))) }) }), _jsx("tbody", { children: d.rows.map((r, i) => (_jsx("tr", { children: d.columns.map((c) => (_jsx("td", { style: c.align === "right" || typeof r[c.key] === "number" ? { textAlign: "right" } : undefined, children: cell(r[c.key]) }, c.key))) }, i))) })] }), d.total && d.total > d.rows.length ? (_jsxs("div", { className: "ktable__more", children: ["Showing ", d.rows.length.toLocaleString(), " of ", d.total.toLocaleString(), " rows"] })) : null] }));
|
|
277
|
+
}
|
|
278
|
+
case "checklist":
|
|
279
|
+
return (_jsx("ul", { className: "kcheck", children: card.data.items.map((item, i) => (_jsxs("li", { className: `kcheck__item kcheck__item--${item.state}`, children: [_jsx(CheckGlyph, { state: item.state }), _jsxs("span", { children: [item.text, item.detail ? _jsxs("span", { className: "kcheck__detail", children: [" ", item.detail] }) : null] })] }, i))) }));
|
|
280
|
+
case "brief": {
|
|
281
|
+
const d = card.data;
|
|
282
|
+
return (_jsxs("div", { className: "kbrief", children: [_jsxs("div", { className: "kbrief__head", children: [_jsx("span", { className: "kbrief__initial", children: (d.initial ?? d.name.slice(0, 1)).toUpperCase() }), _jsxs("div", { children: [_jsx("div", { className: "kbrief__name", children: d.name }), d.subtitle ? _jsx("div", { className: "kbrief__sub", children: d.subtitle }) : null] })] }), d.points?.length ? (_jsx("ul", { className: "kbrief__points", children: d.points.map((p, i) => (_jsx("li", { children: p }, i))) })) : null, d.facts?.length ? (_jsx("dl", { className: "kbrief__facts", children: d.facts.map((f, i) => (_jsxs("div", { children: [_jsx("dt", { className: "klabel", children: f.label }), _jsx("dd", { children: f.value })] }, i))) })) : null, d.tiles?.length ? _jsx(Tiles, { tiles: d.tiles }) : null] }));
|
|
283
|
+
}
|
|
284
|
+
case "link": {
|
|
285
|
+
const d = card.data;
|
|
286
|
+
return (_jsxs("button", { type: "button", className: "klink", onClick: () => openUrl(d.url, ctx), children: [d.description ? _jsx("div", { className: "klink__desc", children: d.description }) : null, _jsx("div", { className: "klink__url", children: d.site ?? d.url })] }));
|
|
287
|
+
}
|
|
288
|
+
case "screenshot": {
|
|
289
|
+
const d = card.data;
|
|
290
|
+
return (_jsxs("div", { className: "kshot", children: [_jsx(AgentImage, { src: d.image, alt: d.caption ?? "Screenshot", ctx: ctx }), d.caption || d.site ? (_jsxs("div", { className: "kshot__caption", children: [d.caption, d.site ? _jsx("span", { className: "kshot__site", children: d.site }) : null] })) : null] }));
|
|
291
|
+
}
|
|
292
|
+
case "file": {
|
|
293
|
+
const d = card.data;
|
|
294
|
+
return (_jsxs("div", { className: "kfile", children: [_jsx(FileGlyph, {}), _jsxs("div", { className: "kfile__name", children: [d.name, d.size ? _jsx("span", { className: "kfile__size", children: formatSize(d.size) }) : null] }), isHttp(d.url) ? (_jsx("button", { type: "button", className: "kbtn", onClick: () => openFile(d.url, d.name, ctx), children: "Open" })) : null] }));
|
|
295
|
+
}
|
|
296
|
+
case "artifact":
|
|
297
|
+
return _jsx(ArtifactBody, { data: card.data, title: card.title, ctx: ctx });
|
|
298
|
+
case "pull-request": {
|
|
299
|
+
const d = card.data;
|
|
300
|
+
return (_jsxs("div", { className: "kpr", children: [d.summary ? _jsx("div", { className: "kpr__summary", children: d.summary }) : null, d.additions !== undefined || d.deletions !== undefined ? (_jsxs("div", { className: "kpr__delta", children: [_jsxs("span", { className: "is-good", children: ["+", d.additions ?? 0] }), " ", _jsxs("span", { className: "is-bad", children: ["\u2212", d.deletions ?? 0] })] })) : null, d.checks?.length ? (_jsx("ul", { className: "kcheck", children: d.checks.map((c, i) => (_jsxs("li", { className: "kcheck__item", children: [_jsx(CheckGlyph, { state: c.state }), _jsxs("span", { children: [c.name, c.detail ? _jsxs("span", { className: "kcheck__detail", children: [" ", c.detail] }) : null] })] }, i))) })) : null, d.diff ? (_jsxs("div", { className: "kdiff", children: [_jsx("div", { className: "kdiff__file", children: d.diff.file }), d.diff.lines.map((line, i) => (_jsx("div", { className: `kdiff__line${line.startsWith("+") ? " is-good" : line.startsWith("-") ? " is-bad" : ""}`, children: line }, i)))] })) : null, d.reviewer ? _jsxs("div", { className: "kpr__meta", children: ["Review: ", d.reviewer] }) : null, _jsxs("div", { className: "kcard__actions", children: [_jsx("button", { type: "button", className: "kbtn", onClick: () => openUrl(d.url, ctx), children: "View pull request" }), d.preview ? (_jsx("button", { type: "button", className: "kbtn", onClick: () => openUrl(d.preview, ctx), children: "Preview" })) : null] })] }));
|
|
301
|
+
}
|
|
302
|
+
case "receipt": {
|
|
303
|
+
const d = card.data;
|
|
304
|
+
return (_jsxs("div", { className: "kreceipt", children: [_jsx("div", { className: "kreceipt__amount", children: money(d.amount, d.currency) }), d.orderId ? _jsxs("div", { className: "kreceipt__meta", children: ["Order ", d.orderId] }) : null, d.note ? _jsx("div", { className: "kreceipt__note", children: d.note }) : null, d.file && isHttp(d.file.url) ? (_jsx("button", { type: "button", className: "kbtn", onClick: () => openFile(d.file.url, d.file.name, ctx), children: d.file.name })) : null] }));
|
|
305
|
+
}
|
|
306
|
+
case "remembered":
|
|
307
|
+
return _jsx("div", { className: "kremember", children: card.data.fact });
|
|
308
|
+
case "approval":
|
|
309
|
+
return _jsx(ApprovalBody, { data: card.data });
|
|
310
|
+
case "form":
|
|
311
|
+
// A form is answered where it was asked; shown anywhere else, it lists what it asks.
|
|
312
|
+
return (_jsx("ol", { className: "kform__list", children: card.data.fields.map((f) => (_jsx("li", { children: f.label }, f.id))) }));
|
|
313
|
+
case "routine": {
|
|
314
|
+
const d = card.data;
|
|
315
|
+
return (_jsxs("div", { className: "kroutine", children: [_jsx("div", { children: routineSchedule(d) }), d.nextRun ? _jsxs("div", { className: "kroutine__meta", children: ["Next run ", dateLabel(d.nextRun)] }) : null, d.posts?.length ? _jsxs("div", { className: "kroutine__meta", children: ["Posts to ", d.posts.join(", ")] }) : null] }));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const SOURCE_DEFAULTS = {
|
|
320
|
+
remembered: "Memory",
|
|
321
|
+
artifact: "Artifact",
|
|
322
|
+
screenshot: "Computer",
|
|
323
|
+
receipt: "Payments",
|
|
324
|
+
"pull-request": "GitHub",
|
|
325
|
+
routine: "Routine",
|
|
326
|
+
form: "Question",
|
|
327
|
+
};
|
|
328
|
+
export function CardView({ card, ctx }) {
|
|
329
|
+
const title = cardTitle(card);
|
|
330
|
+
const source = card.source ?? SOURCE_DEFAULTS[card.card];
|
|
331
|
+
const known = isKnownCard(card);
|
|
332
|
+
const compact = card.card === "remembered";
|
|
333
|
+
return (_jsxs("div", { className: `kcard kcard--${known ? card.card : "unknown"}${compact ? " kcard--compact" : ""}`, children: [title || source ? (_jsxs("div", { className: "kcard__head", children: [title ? _jsx("span", { className: "kcard__title", children: title }) : _jsx("span", { className: "kcard__title" }), source ? _jsx("span", { className: "klabel kcard__source", children: source }) : null] })) : null, known ? _jsx(Body, { card: card, ctx: ctx }) : _jsx("div", { className: "kcard__text", children: card.text }), _jsx(Actions, { actions: card.card === "artifact" ? card.actions?.filter((a) => !a.artifact) : card.actions, ctx: ctx })] }));
|
|
334
|
+
}
|
|
335
|
+
/** Several cards, in the order they arrived. */
|
|
336
|
+
export function CardStack({ cards, ctx }) {
|
|
337
|
+
if (cards.length === 0)
|
|
338
|
+
return null;
|
|
339
|
+
return (_jsx("div", { className: "kcards", children: cards.map((card, i) => (_jsx(CardView, { card: card, ctx: ctx }, card.id ?? i))) }));
|
|
340
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cards' stylesheet, as text, so a host with no CSS pipeline (a plugin
|
|
3
|
+
* that ships one script) can put it in a <style> element, and a host with one
|
|
4
|
+
* can import the same rules.
|
|
5
|
+
*
|
|
6
|
+
* Every colour, font and size reads a `--kyb-*` variable with a light default.
|
|
7
|
+
* A host maps its own theme onto them on any ancestor, e.g.
|
|
8
|
+
* `--kyb-ink: var(--text-primary)`, which is how one set of rules follows
|
|
9
|
+
* each app's light and dark modes.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cardStyles: string;
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cards' stylesheet, as text, so a host with no CSS pipeline (a plugin
|
|
3
|
+
* that ships one script) can put it in a <style> element, and a host with one
|
|
4
|
+
* can import the same rules.
|
|
5
|
+
*
|
|
6
|
+
* Every colour, font and size reads a `--kyb-*` variable with a light default.
|
|
7
|
+
* A host maps its own theme onto them on any ancestor, e.g.
|
|
8
|
+
* `--kyb-ink: var(--text-primary)`, which is how one set of rules follows
|
|
9
|
+
* each app's light and dark modes.
|
|
10
|
+
*/
|
|
11
|
+
export const cardStyles = `
|
|
12
|
+
.kcard .is-good { color: var(--kyb-good, #15803d); }
|
|
13
|
+
.kcard .is-bad { color: var(--kyb-bad, #dc2626); }
|
|
14
|
+
|
|
15
|
+
/* Cards: one frame for every type. */
|
|
16
|
+
.kcards { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
|
|
17
|
+
.kcard {
|
|
18
|
+
border: 1px solid var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); border-radius: 12px; background: var(--kyb-surface, #ffffff);
|
|
19
|
+
padding: 13px 15px; font-size: var(--kyb-fs-base, 14px); line-height: var(--kyb-lh-base, 19px);
|
|
20
|
+
}
|
|
21
|
+
.kcard--compact { padding: 9px 13px; }
|
|
22
|
+
.kcard__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
|
|
23
|
+
.kcard--compact .kcard__head { margin-bottom: 4px; }
|
|
24
|
+
.kcard__title { flex: 1; min-width: 0; font-weight: 600; }
|
|
25
|
+
.klabel {
|
|
26
|
+
font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
|
|
27
|
+
color: var(--kyb-ink-tertiary, #8b91a0);
|
|
28
|
+
}
|
|
29
|
+
.kcard__source { flex: none; }
|
|
30
|
+
.kcard__text { white-space: pre-wrap; color: var(--kyb-ink-secondary, #5c6270); }
|
|
31
|
+
.kcard__actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
|
|
32
|
+
|
|
33
|
+
.kstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--kyb-stroke, rgba(22, 24, 29, 0.09)); border: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); border-radius: 8px; overflow: hidden; }
|
|
34
|
+
.kstats__tile { background: var(--kyb-surface, #ffffff); padding: 10px 12px; }
|
|
35
|
+
.kstats__value { font-size: 22px; line-height: 28px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 3px; }
|
|
36
|
+
.kstats__change { font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-secondary, #5c6270); font-variant-numeric: tabular-nums; }
|
|
37
|
+
.kstats__change.is-good { color: var(--kyb-good, #15803d); }
|
|
38
|
+
.kstats__change.is-bad { color: var(--kyb-bad, #dc2626); }
|
|
39
|
+
|
|
40
|
+
.kchart__legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-secondary, #5c6270); }
|
|
41
|
+
.kchart__key { display: inline-flex; align-items: center; gap: 6px; }
|
|
42
|
+
.kchart__swatch { width: 10px; height: 2px; background: currentColor; }
|
|
43
|
+
.kchart__plot { display: flex; gap: 8px; }
|
|
44
|
+
.kchart__y { display: flex; flex-direction: column; justify-content: space-between; font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 10px; color: var(--kyb-ink-tertiary, #8b91a0); text-align: right; padding-bottom: 20px; min-width: 32px; }
|
|
45
|
+
.kchart__frame { position: relative; flex: 1; min-width: 0; }
|
|
46
|
+
.kchart__svg { display: block; width: 100%; height: 160px; overflow: visible; }
|
|
47
|
+
.kchart__line { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
|
|
48
|
+
.kchart__area { stroke: none; opacity: 0.06; }
|
|
49
|
+
.kchart__base { stroke: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); stroke-width: 1; }
|
|
50
|
+
.kchart__rule { stroke: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); stroke-width: 1; }
|
|
51
|
+
.kchart__s0 { stroke: var(--kyb-ink, #16181d); fill: var(--kyb-ink, #16181d); color: var(--kyb-ink, #16181d); }
|
|
52
|
+
.kchart__s1 { stroke: var(--kyb-ink-secondary, #5c6270); fill: var(--kyb-ink-secondary, #5c6270); color: var(--kyb-ink-secondary, #5c6270); }
|
|
53
|
+
.kchart__s2 { stroke: var(--kyb-ink-tertiary, #8b91a0); fill: var(--kyb-ink-tertiary, #8b91a0); color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
54
|
+
.kchart__s3 { stroke: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); fill: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); color: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); }
|
|
55
|
+
.kchart__line.kchart__s0, .kchart__line.kchart__s1, .kchart__line.kchart__s2, .kchart__line.kchart__s3 { fill: none; }
|
|
56
|
+
.kchart__x { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 10px; color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
57
|
+
.kchart__x--slots { display: grid; text-align: center; }
|
|
58
|
+
.kchart__x--slots span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
|
|
59
|
+
.kchart__tip {
|
|
60
|
+
position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
|
|
61
|
+
background: var(--kyb-surface-raised, #ffffff); border: 1px solid var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); border-radius: 6px;
|
|
62
|
+
padding: 5px 8px; font-size: var(--kyb-fs-xs, 12px); box-shadow: var(--kyb-shadow-menu, 0 10px 34px rgba(16, 18, 24, 0.18));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ktable { overflow-x: auto; }
|
|
66
|
+
.ktable__more { margin-top: 8px; font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
67
|
+
|
|
68
|
+
.kcheck { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
|
|
69
|
+
.kcheck__item { display: flex; gap: 9px; align-items: baseline; }
|
|
70
|
+
.kcheck__item--skipped, .kcheck__item--waiting { color: var(--kyb-ink-secondary, #5c6270); }
|
|
71
|
+
.kcheck__detail { color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
72
|
+
.kglyph { flex: none; width: 14px; text-align: center; color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
73
|
+
.kglyph.is-good { color: var(--kyb-good, #15803d); }
|
|
74
|
+
.kglyph.is-bad { color: var(--kyb-bad, #dc2626); }
|
|
75
|
+
|
|
76
|
+
.kbrief__head { display: flex; gap: 11px; align-items: center; }
|
|
77
|
+
.kbrief__initial {
|
|
78
|
+
width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; flex: none;
|
|
79
|
+
background: var(--kyb-ink, #16181d); color: var(--kyb-ink-inverse, #ffffff); font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 15px;
|
|
80
|
+
}
|
|
81
|
+
.kbrief__name { font-weight: 600; }
|
|
82
|
+
.kbrief__sub { font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-secondary, #5c6270); }
|
|
83
|
+
.kbrief__points { margin: 10px 0 0; padding-left: 18px; }
|
|
84
|
+
.kbrief__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0 0; }
|
|
85
|
+
.kbrief__facts dd { margin: 2px 0 0; }
|
|
86
|
+
.kbrief .kstats { margin-top: 12px; }
|
|
87
|
+
|
|
88
|
+
.klink { display: block; width: 100%; text-align: left; padding: 0; }
|
|
89
|
+
.klink__desc { color: var(--kyb-ink-secondary, #5c6270); margin-bottom: 4px; }
|
|
90
|
+
.klink__url { font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-tertiary, #8b91a0); text-decoration: underline; text-decoration-color: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); }
|
|
91
|
+
|
|
92
|
+
.kshot__img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); cursor: zoom-in; }
|
|
93
|
+
.kshot__img--big { max-height: none; cursor: zoom-out; }
|
|
94
|
+
.kshot__wait, .kartifact__wait { display: grid; place-items: center; height: 120px; color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
95
|
+
.kshot__missing, .kartifact__missing { display: flex; gap: 10px; align-items: center; color: var(--kyb-ink-secondary, #5c6270); font-size: var(--kyb-fs-sm, 13px); }
|
|
96
|
+
.kshot__caption { margin-top: 8px; font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-secondary, #5c6270); display: flex; gap: 10px; }
|
|
97
|
+
.kshot__site { margin-left: auto; font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 10px; color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
98
|
+
|
|
99
|
+
.kfile { display: flex; align-items: center; gap: 10px; }
|
|
100
|
+
.kfile__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
101
|
+
.kfile__size { margin-left: 8px; color: var(--kyb-ink-tertiary, #8b91a0); font-size: var(--kyb-fs-sm, 13px); }
|
|
102
|
+
|
|
103
|
+
.kartifact__frame { display: block; width: 100%; border: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); border-radius: 8px; background: #fff; }
|
|
104
|
+
.kartifact--inline { height: 360px; margin-bottom: 10px; }
|
|
105
|
+
.kartifact__doc.kartifact--inline { overflow: auto; padding: 4px 2px; }
|
|
106
|
+
.kartifact__meta { font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
107
|
+
.kartifact__preview {
|
|
108
|
+
display: block; width: 100%; padding: 0; margin-bottom: 10px; border: 0; background: none; cursor: pointer; text-align: left;
|
|
109
|
+
position: relative; overflow: hidden; border-radius: 8px;
|
|
110
|
+
}
|
|
111
|
+
/* The top of the page, faded out, and not interactive: a click opens it. */
|
|
112
|
+
.kartifact--preview { height: 200px; pointer-events: none; overflow: hidden; }
|
|
113
|
+
.kartifact__preview::after {
|
|
114
|
+
content: ""; position: absolute; inset: auto 0 0 0; height: 64px; pointer-events: none;
|
|
115
|
+
background: linear-gradient(to bottom, transparent, var(--kyb-surface, #ffffff));
|
|
116
|
+
}
|
|
117
|
+
/* A page is white in both themes, so it fades into its own white, inside its border. */
|
|
118
|
+
.kartifact__preview:has(.kartifact__frame)::after {
|
|
119
|
+
inset: auto 1px 1px 1px; border-radius: 0 0 7px 7px;
|
|
120
|
+
background: linear-gradient(to bottom, rgb(255 255 255 / 0), #fff);
|
|
121
|
+
}
|
|
122
|
+
.kartifact__preview:hover .kartifact__frame, .kartifact__preview:hover .kartifact__doc { border-color: var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); }
|
|
123
|
+
.kartifact__doc.kartifact--preview { border: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); border-radius: 8px; padding: 10px 14px; }
|
|
124
|
+
.kartifact__row + .kcard__actions { margin-top: 10px; }
|
|
125
|
+
|
|
126
|
+
.kpr__summary { color: var(--kyb-ink-secondary, #5c6270); }
|
|
127
|
+
.kpr__delta { margin: 8px 0; font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 11px; }
|
|
128
|
+
.kpr__meta { margin-top: 8px; font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-tertiary, #8b91a0); }
|
|
129
|
+
.kpr .kcheck { margin-top: 8px; }
|
|
130
|
+
.kdiff { margin-top: 10px; border: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); border-radius: 8px; overflow: hidden; font-family: var(--kyb-font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: 12px; }
|
|
131
|
+
.kdiff__file { padding: 5px 10px; background: var(--kyb-hover, rgba(22, 24, 29, 0.045)); color: var(--kyb-ink-secondary, #5c6270); border-bottom: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); }
|
|
132
|
+
.kdiff__line { padding: 0 10px; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
|
|
133
|
+
.kdiff__line.is-good { background: color-mix(in srgb, var(--kyb-good, #15803d) 9%, transparent); color: inherit; }
|
|
134
|
+
.kdiff__line.is-bad { background: color-mix(in srgb, var(--kyb-bad, #dc2626) 9%, transparent); color: inherit; }
|
|
135
|
+
|
|
136
|
+
.kreceipt__amount { font-size: 22px; line-height: 28px; font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
137
|
+
.kreceipt__meta { font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 11px; color: var(--kyb-ink-tertiary, #8b91a0); margin-top: 2px; }
|
|
138
|
+
.kreceipt__note { margin: 8px 0; color: var(--kyb-ink-secondary, #5c6270); }
|
|
139
|
+
.kremember { color: var(--kyb-ink-secondary, #5c6270); }
|
|
140
|
+
.kroutine__meta { font-size: var(--kyb-fs-sm, 13px); color: var(--kyb-ink-tertiary, #8b91a0); margin-top: 3px; }
|
|
141
|
+
|
|
142
|
+
/* Asks drawn on the card frame: approvals, forms, sign-in, a purchase. */
|
|
143
|
+
.kcard.is-done { padding: 9px 13px; }
|
|
144
|
+
.kcard.is-done .kcard__head { margin-bottom: 2px; align-items: center; }
|
|
145
|
+
.kpill {
|
|
146
|
+
flex: none; font-family: var(--kyb-font-label, ui-monospace, monospace); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
|
|
147
|
+
padding: 2px 7px; border-radius: 999px; border: 1px solid var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); color: var(--kyb-ink-secondary, #5c6270);
|
|
148
|
+
}
|
|
149
|
+
.kpill.is-good { color: var(--kyb-good, #15803d); border-color: currentColor; }
|
|
150
|
+
.kapproval__rows { margin: 0; display: grid; gap: 4px; }
|
|
151
|
+
.kapproval__row { display: grid; grid-template-columns: 68px 1fr; gap: 10px; align-items: baseline; }
|
|
152
|
+
.kapproval__row dt { padding-top: 1px; }
|
|
153
|
+
.kapproval__row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
|
|
154
|
+
.kapproval__body {
|
|
155
|
+
margin-top: 10px; padding: 10px 12px; border: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); border-radius: 8px;
|
|
156
|
+
white-space: pre-wrap; overflow-wrap: anywhere; color: var(--kyb-ink-secondary, #5c6270); max-height: 260px; overflow: auto;
|
|
157
|
+
}
|
|
158
|
+
.kform { display: flex; flex-direction: column; gap: 10px; }
|
|
159
|
+
.kform__choices { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
160
|
+
.kform__list { margin: 0; padding-left: 18px; color: var(--kyb-ink-secondary, #5c6270); }
|
|
161
|
+
.kbtn {
|
|
162
|
+
height: 30px; padding: 0 13px; border: 0; border-radius: 8px; cursor: pointer;
|
|
163
|
+
font: inherit; font-size: var(--kyb-fs-base, 14px); font-weight: 500;
|
|
164
|
+
color: var(--kyb-ink, #16181d); background: var(--kyb-hover, rgba(22, 24, 29, 0.045));
|
|
165
|
+
}
|
|
166
|
+
.kbtn:hover { background: var(--kyb-selected, rgba(22, 24, 29, 0.075)); }
|
|
167
|
+
.kbtn--primary { background: var(--kyb-ink, #16181d); color: var(--kyb-ink-inverse, #ffffff); }
|
|
168
|
+
.kbtn--primary:hover { opacity: 0.87; background: var(--kyb-ink, #16181d); }
|
|
169
|
+
.klink { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
|
|
170
|
+
.ktable table { border-collapse: collapse; width: 100%; font-size: var(--kyb-fs-sm, 13px); }
|
|
171
|
+
.ktable th { text-align: left; font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); }
|
|
172
|
+
.ktable td { padding: 4px 8px; border-bottom: 1px solid var(--kyb-stroke, rgba(22, 24, 29, 0.09)); font-variant-numeric: tabular-nums; }
|
|
173
|
+
.kartifact__plain { white-space: pre-wrap; }
|
|
174
|
+
.kartifact__host { margin-bottom: 10px; }
|
|
175
|
+
.kspin {
|
|
176
|
+
width: 16px; height: 16px; border-radius: 50%; display: inline-block;
|
|
177
|
+
border: 2px solid var(--kyb-stroke-strong, rgba(22, 24, 29, 0.16)); border-top-color: var(--kyb-ink-secondary, #5c6270);
|
|
178
|
+
animation: kspin 0.8s linear infinite;
|
|
179
|
+
}
|
|
180
|
+
@keyframes kspin { to { transform: rotate(360deg); } }
|
|
181
|
+
@media (prefers-reduced-motion: reduce) { .kspin { animation: none; } }
|
|
182
|
+
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/cards-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React components that draw Kybernesis cards: one frame and one body per card type, themed by CSS variables, with the host's own way to open links, artifacts and files.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/KybernesisAI/platform.git",
|
|
10
|
+
"directory": "packages/cards-react"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"NOTICE",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json",
|
|
28
|
+
"prepack": "tsc -p tsconfig.build.json",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"prepublishOnly": "node ../../scripts/prepublish.mjs",
|
|
31
|
+
"test": "node --test \"test/**/*.test.mjs\""
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@kybernesis/cards": "^0.4.0",
|
|
35
|
+
"react": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@kybernesis/cards": "^0.4.0",
|
|
39
|
+
"@types/node": "^24.0.0",
|
|
40
|
+
"@types/react": "^19.0.0",
|
|
41
|
+
"react": "^19.0.0",
|
|
42
|
+
"react-dom": "^19.0.0",
|
|
43
|
+
"typescript": "^5.9.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|