@firetail/finchly-ux 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +267 -2
- package/dist/components/action-button.d.ts +12 -0
- package/dist/components/action-button.js +34 -0
- package/dist/components/action-button.js.map +1 -0
- package/dist/components/app-shell.d.ts +18 -0
- package/dist/components/app-shell.js +56 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/ask.d.ts +37 -0
- package/dist/components/ask.js +73 -0
- package/dist/components/ask.js.map +1 -0
- package/dist/components/bar.d.ts +11 -0
- package/dist/components/bar.js +187 -0
- package/dist/components/bar.js.map +1 -0
- package/dist/components/choosing.d.ts +18 -0
- package/dist/components/choosing.js +68 -0
- package/dist/components/choosing.js.map +1 -0
- package/dist/components/column-chart.d.ts +50 -0
- package/dist/components/column-chart.js +181 -0
- package/dist/components/column-chart.js.map +1 -0
- package/dist/components/composing.d.ts +40 -0
- package/dist/components/composing.js +101 -0
- package/dist/components/composing.js.map +1 -0
- package/dist/components/conversation.d.ts +50 -0
- package/dist/components/conversation.js +116 -0
- package/dist/components/conversation.js.map +1 -0
- package/dist/components/data-table.d.ts +43 -0
- package/dist/components/data-table.js +212 -0
- package/dist/components/data-table.js.map +1 -0
- package/dist/components/fields.d.ts +61 -0
- package/dist/components/fields.js +144 -0
- package/dist/components/fields.js.map +1 -0
- package/dist/components/file-button.d.ts +16 -0
- package/dist/components/file-button.js +39 -0
- package/dist/components/file-button.js.map +1 -0
- package/dist/components/form-dialog.d.ts +51 -0
- package/dist/components/form-dialog.js +113 -0
- package/dist/components/form-dialog.js.map +1 -0
- package/dist/components/link-button.d.ts +5 -0
- package/dist/components/link-button.js +24 -0
- package/dist/components/link-button.js.map +1 -0
- package/dist/components/link-tabs.d.ts +13 -0
- package/dist/components/link-tabs.js +26 -0
- package/dist/components/link-tabs.js.map +1 -0
- package/dist/components/markdown.d.ts +13 -0
- package/dist/components/markdown.js +132 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/page.d.ts +18 -0
- package/dist/components/page.js +45 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/palette.d.ts +16 -0
- package/dist/components/palette.js +27 -0
- package/dist/components/palette.js.map +1 -0
- package/dist/components/panel.d.ts +12 -0
- package/dist/components/panel.js +30 -0
- package/dist/components/panel.js.map +1 -0
- package/dist/components/pick-tile.d.ts +21 -0
- package/dist/components/pick-tile.js +40 -0
- package/dist/components/pick-tile.js.map +1 -0
- package/dist/components/provider-mark.d.ts +33 -0
- package/dist/components/provider-mark.js +58 -0
- package/dist/components/provider-mark.js.map +1 -0
- package/dist/components/provider.d.ts +17 -0
- package/dist/components/provider.js +39 -0
- package/dist/components/provider.js.map +1 -0
- package/dist/components/rows.d.ts +48 -0
- package/dist/components/rows.js +112 -0
- package/dist/components/rows.js.map +1 -0
- package/dist/components/side-nav.d.ts +23 -0
- package/dist/components/side-nav.js +41 -0
- package/dist/components/side-nav.js.map +1 -0
- package/dist/components/states.d.ts +19 -0
- package/dist/components/states.js +45 -0
- package/dist/components/states.js.map +1 -0
- package/dist/components/suggest-field.d.ts +19 -0
- package/dist/components/suggest-field.js +124 -0
- package/dist/components/suggest-field.js.map +1 -0
- package/dist/components/tag.d.ts +27 -0
- package/dist/components/tag.js +38 -0
- package/dist/components/tag.js.map +1 -0
- package/dist/components/text.d.ts +41 -0
- package/dist/components/text.js +97 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/tile.d.ts +30 -0
- package/dist/components/tile.js +68 -0
- package/dist/components/tile.js.map +1 -0
- package/dist/components/toast.d.ts +10 -0
- package/dist/components/toast.js +38 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/button.d.ts +8 -0
- package/dist/components/ui/button.js +45 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +57 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.js +20 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +24 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +92 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/dropdown-menu.js +65 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +89 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +16 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.js +14 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/native-select.d.ts +8 -0
- package/dist/components/ui/native-select.js +39 -0
- package/dist/components/ui/native-select.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +27 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.js +15 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +13 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +16 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +53 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +14 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.js +41 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +56 -0
- package/dist/lib/api.d.ts +49 -0
- package/dist/lib/api.js +80 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/chart.d.ts +35 -0
- package/dist/lib/chart.js +86 -0
- package/dist/lib/chart.js.map +1 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/events.d.ts +34 -0
- package/dist/lib/events.js +72 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/format.d.ts +16 -0
- package/dist/lib/format.js +71 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/hash.d.ts +2 -0
- package/dist/lib/hash.js +13 -0
- package/dist/lib/hash.js.map +1 -0
- package/dist/lib/launcher.d.ts +54 -0
- package/dist/lib/launcher.js +46 -0
- package/dist/lib/launcher.js.map +1 -0
- package/dist/lib/markdown-inline.d.ts +18 -0
- package/dist/lib/markdown-inline.js +155 -0
- package/dist/lib/markdown-inline.js.map +1 -0
- package/dist/lib/markdown.d.ts +40 -0
- package/dist/lib/markdown.js +198 -0
- package/dist/lib/markdown.js.map +1 -0
- package/dist/lib/marks.d.ts +17 -0
- package/dist/lib/marks.js +56 -0
- package/dist/lib/marks.js.map +1 -0
- package/dist/lib/over.d.ts +26 -0
- package/dist/lib/over.js +38 -0
- package/dist/lib/over.js.map +1 -0
- package/dist/lib/route.d.ts +15 -0
- package/dist/lib/route.js +29 -0
- package/dist/lib/route.js.map +1 -0
- package/dist/lib/table.d.ts +43 -0
- package/dist/lib/table.js +86 -0
- package/dist/lib/table.js.map +1 -0
- package/dist/lib/theme.d.ts +12 -0
- package/dist/lib/theme.js +42 -0
- package/dist/lib/theme.js.map +1 -0
- package/eslint/index.d.ts +8 -0
- package/eslint/index.js +135 -0
- package/eslint/page-imports.js +46 -0
- package/package.json +91 -4
- package/styles/styles.css +221 -0
- package/styles/tokens.css +99 -0
- package/tsconfig.app.json +21 -0
- package/vite/index.d.ts +16 -0
- package/vite/index.js +84 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Button } from "./ui/button.js";
|
|
2
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { PlusIcon } from "lucide-react";
|
|
5
|
+
// src/components/composing.tsx
|
|
6
|
+
/**
|
|
7
|
+
* One box to write in: the words, and under them what to start from
|
|
8
|
+
* (`footer`) and the way to send it. Enter sends; Shift and Enter is a
|
|
9
|
+
* new line. Nothing is sent while it is empty, or `busy`.
|
|
10
|
+
*
|
|
11
|
+
* @param attached what goes with what is written, such as files, drawn under the words
|
|
12
|
+
* @param withNothing whether there is something to send though nothing is written: files that are attached
|
|
13
|
+
* @param onFiles called with files pasted where the words are written, for a page that takes them
|
|
14
|
+
*/
|
|
15
|
+
function Composer({ label, placeholder, value, onChange, onSubmit, busy = false, action = "Send", busyAction, maxLength, footer, inputRef, attached, withNothing = false, onFiles }) {
|
|
16
|
+
const send = (event) => {
|
|
17
|
+
event?.preventDefault();
|
|
18
|
+
const text = value.trim();
|
|
19
|
+
if ((text !== "" || withNothing) && !busy) onSubmit(text);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
22
|
+
onSubmit: send,
|
|
23
|
+
className: "grid rounded-lg border border-input bg-card focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20",
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
26
|
+
ref: inputRef,
|
|
27
|
+
rows: 2,
|
|
28
|
+
maxLength,
|
|
29
|
+
"aria-label": label,
|
|
30
|
+
placeholder,
|
|
31
|
+
value,
|
|
32
|
+
onChange: (event) => onChange(event.target.value),
|
|
33
|
+
onKeyDown: (event) => {
|
|
34
|
+
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) send(event);
|
|
35
|
+
},
|
|
36
|
+
onPaste: (event) => {
|
|
37
|
+
const files = [...event.clipboardData.files];
|
|
38
|
+
if (!onFiles || files.length === 0) return;
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
onFiles(files);
|
|
41
|
+
},
|
|
42
|
+
className: "max-h-[40dvh] min-h-16 w-full resize-y bg-transparent px-3.5 pt-3 pb-1.5 outline-none placeholder:text-faint short:min-h-10 short:pt-2"
|
|
43
|
+
}),
|
|
44
|
+
attached ? /* @__PURE__ */ jsx("div", {
|
|
45
|
+
className: "max-h-16 overflow-y-auto px-3.5 pb-1 empty:hidden",
|
|
46
|
+
children: attached
|
|
47
|
+
}) : null,
|
|
48
|
+
/* @__PURE__ */ jsxs("div", {
|
|
49
|
+
className: "flex flex-col items-stretch gap-3 pt-2 pr-2.5 pb-2.5 pl-3.5 sm:flex-row sm:items-end",
|
|
50
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
51
|
+
className: "min-w-0 flex-1",
|
|
52
|
+
children: footer
|
|
53
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
54
|
+
type: "submit",
|
|
55
|
+
disabled: busy,
|
|
56
|
+
className: "flex-none",
|
|
57
|
+
children: busy ? busyAction ?? action : action
|
|
58
|
+
})]
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A part of a page that is closed until it is asked for: a title and a
|
|
65
|
+
* line about it, which open what is beneath. What is beneath is kept
|
|
66
|
+
* while it is closed, so that something half written is still there.
|
|
67
|
+
*/
|
|
68
|
+
function Expander({ title, description, icon, open, onOpenChange, children }) {
|
|
69
|
+
return /* @__PURE__ */ jsxs(Collapsible, {
|
|
70
|
+
open,
|
|
71
|
+
onOpenChange,
|
|
72
|
+
className: "rounded-xl border bg-card shadow-sm",
|
|
73
|
+
children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
74
|
+
className: "group/expander flex w-full cursor-pointer items-center gap-3 rounded-xl px-4.5 py-3.5 text-left",
|
|
75
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
className: "grid size-9.5 flex-none place-items-center rounded-lg bg-accent text-primary [&_svg]:size-5 [&_svg]:transition-transform [&_svg]:duration-200 group-data-panel-open/expander:[&_svg]:rotate-45 motion-reduce:[&_svg]:transition-none",
|
|
78
|
+
children: icon ?? /* @__PURE__ */ jsx(PlusIcon, {})
|
|
79
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
80
|
+
className: "grid min-w-0 gap-0.5",
|
|
81
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: "text-base leading-tight font-semibold",
|
|
83
|
+
children: title
|
|
84
|
+
}), description ? /* @__PURE__ */ jsx("span", {
|
|
85
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
86
|
+
children: description
|
|
87
|
+
}) : null]
|
|
88
|
+
})]
|
|
89
|
+
}), /* @__PURE__ */ jsx(CollapsibleContent, {
|
|
90
|
+
keepMounted: true,
|
|
91
|
+
className: "h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-200 ease-out data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none [&[hidden]]:hidden",
|
|
92
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: "grid gap-4 px-4.5 pt-1 pb-4.5",
|
|
94
|
+
children
|
|
95
|
+
})
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export { Composer, Expander };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=composing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composing.js","names":[],"sources":["../../src/components/composing.tsx"],"sourcesContent":["import type { FormEvent, ReactNode, Ref } from \"react\";\nimport { PlusIcon } from \"lucide-react\";\nimport { Button } from \"./ui/button\";\nimport { Collapsible, CollapsibleContent, CollapsibleTrigger } from \"./ui/collapsible\";\n\n/**\n * One box to write in: the words, and under them what to start from\n * (`footer`) and the way to send it. Enter sends; Shift and Enter is a\n * new line. Nothing is sent while it is empty, or `busy`.\n *\n * @param attached what goes with what is written, such as files, drawn under the words\n * @param withNothing whether there is something to send though nothing is written: files that are attached\n * @param onFiles called with files pasted where the words are written, for a page that takes them\n */\nexport function Composer({\n label,\n placeholder,\n value,\n onChange,\n onSubmit,\n busy = false,\n action = \"Send\",\n busyAction,\n maxLength,\n footer,\n inputRef,\n attached,\n withNothing = false,\n onFiles,\n}: {\n label: string;\n placeholder?: string;\n value: string;\n onChange: (value: string) => void;\n onSubmit: (text: string) => void;\n busy?: boolean;\n action?: string;\n /** What the button says while `busy`. */\n busyAction?: string;\n maxLength?: number;\n footer?: ReactNode;\n inputRef?: Ref<HTMLTextAreaElement>;\n attached?: ReactNode;\n withNothing?: boolean;\n onFiles?: (files: File[]) => void;\n}) {\n const send = (event?: FormEvent) => {\n event?.preventDefault();\n const text = value.trim();\n if ((text !== \"\" || withNothing) && !busy) onSubmit(text);\n };\n return (\n <form onSubmit={send} className=\"grid rounded-lg border border-input bg-card focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/20\">\n <textarea\n ref={inputRef}\n rows={2}\n maxLength={maxLength}\n aria-label={label}\n placeholder={placeholder}\n value={value}\n onChange={(event) => onChange(event.target.value)}\n onKeyDown={(event) => {\n // Not while a word is still being composed: there Enter chooses it.\n if (event.key === \"Enter\" && !event.shiftKey && !event.nativeEvent.isComposing) send(event);\n }}\n onPaste={(event) => {\n const files = [...event.clipboardData.files];\n if (!onFiles || files.length === 0) return;\n // A file that is pasted is given to the page, and is not written as words.\n event.preventDefault();\n onFiles(files);\n }}\n className=\"max-h-[40dvh] min-h-16 w-full resize-y bg-transparent px-3.5 pt-3 pb-1.5 outline-none placeholder:text-faint short:min-h-10 short:pt-2\"\n />\n {attached ? <div className=\"max-h-16 overflow-y-auto px-3.5 pb-1 empty:hidden\">{attached}</div> : null}\n <div className=\"flex flex-col items-stretch gap-3 pt-2 pr-2.5 pb-2.5 pl-3.5 sm:flex-row sm:items-end\">\n <div className=\"min-w-0 flex-1\">{footer}</div>\n <Button type=\"submit\" disabled={busy} className=\"flex-none\">\n {busy ? (busyAction ?? action) : action}\n </Button>\n </div>\n </form>\n );\n}\n\n/**\n * A part of a page that is closed until it is asked for: a title and a\n * line about it, which open what is beneath. What is beneath is kept\n * while it is closed, so that something half written is still there.\n */\nexport function Expander({ title, description, icon, open, onOpenChange, children }: { title: string; description?: string; /** Drawn before the title. A plus, which turns as it opens, unless given. */ icon?: ReactNode; open: boolean; onOpenChange: (open: boolean) => void; children: ReactNode }) {\n return (\n <Collapsible open={open} onOpenChange={onOpenChange} className=\"rounded-xl border bg-card shadow-sm\">\n <CollapsibleTrigger className=\"group/expander flex w-full cursor-pointer items-center gap-3 rounded-xl px-4.5 py-3.5 text-left\">\n <span aria-hidden=\"true\" className=\"grid size-9.5 flex-none place-items-center rounded-lg bg-accent text-primary [&_svg]:size-5 [&_svg]:transition-transform [&_svg]:duration-200 group-data-panel-open/expander:[&_svg]:rotate-45 motion-reduce:[&_svg]:transition-none\">\n {icon ?? <PlusIcon />}\n </span>\n <span className=\"grid min-w-0 gap-0.5\">\n <span className=\"text-base leading-tight font-semibold\">{title}</span>\n {description ? <span className=\"text-sm font-normal text-muted-foreground\">{description}</span> : null}\n </span>\n </CollapsibleTrigger>\n <CollapsibleContent keepMounted className=\"h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-200 ease-out data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none [&[hidden]]:hidden\">\n <div className=\"grid gap-4 px-4.5 pt-1 pb-4.5\">{children}</div>\n </CollapsibleContent>\n </Collapsible>\n );\n}\n"],"mappings":";;;;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A,QAAQ,oBAAC,UAAD,CAAW,CAAA;GAChB,CAAA,GACN,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAyC,UAAA;IAAY,CAAA,GACpE,cAAc,oBAAC,QAAD;KAAM,WAAU;KAA6C,UAAA;IAAkB,CAAA,IAAI,IAC9F;GACY,CAAA,CAAA;EACpB,CAAA,GAAA,oBAAC,oBAAD;GAAoB,aAAA;GAAY,WAAU;GACxC,UAAA,oBAAC,OAAD;IAAK,WAAU;IAAiC;GAAc,CAAA;EAC5C,CAAA,CACT;;AAEjB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type Tone } from "./tag";
|
|
3
|
+
/**
|
|
4
|
+
* What was said in a conversation, one thing under another. With
|
|
5
|
+
* `follow`, for one that is going on: it scrolls within itself, and the
|
|
6
|
+
* latest thing said is kept in sight as more arrives. It is put in
|
|
7
|
+
* something that gives it a height.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Thread({ label, follow, children }: {
|
|
10
|
+
label?: string;
|
|
11
|
+
follow?: boolean;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
/** What was asked, with what the agent did and answered: one turn of a conversation. */
|
|
15
|
+
export declare function Turn({ children }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
declare const BUBBLES: Record<"neutral" | "warn" | "danger", string>;
|
|
19
|
+
/**
|
|
20
|
+
* Something said in a conversation. What the person said (`asked`) is
|
|
21
|
+
* set to their side. `tone` is for where it stopped (`warn`) and for
|
|
22
|
+
* what went wrong (`danger`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function Bubble({ asked, tone, children }: {
|
|
25
|
+
asked?: boolean;
|
|
26
|
+
tone?: keyof typeof BUBBLES;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* Something done on the way to an answer, such as a tool that was
|
|
31
|
+
* called: a word for how it stands, what it is, and a few words about
|
|
32
|
+
* it. It opens to show what it was given and what came back.
|
|
33
|
+
*
|
|
34
|
+
* @param tag how it stands: "Calling", "Called", "Failed"
|
|
35
|
+
* @param name what it is, read exactly: a tool's name
|
|
36
|
+
* @param about a few words more: whose tool it is, how long it took
|
|
37
|
+
*/
|
|
38
|
+
export declare function Step({ tag, tone, name, about, open, children }: {
|
|
39
|
+
tag: string;
|
|
40
|
+
tone?: Tone;
|
|
41
|
+
name: string;
|
|
42
|
+
about?: ReactNode;
|
|
43
|
+
open?: boolean;
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
/** What a step was given, or what came back, as it was written: what is long is scrolled. */
|
|
47
|
+
export declare function StepDetail({ children }: {
|
|
48
|
+
children: string;
|
|
49
|
+
}): import("react").JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { Tag } from "./tag.js";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/conversation.tsx
|
|
6
|
+
/**
|
|
7
|
+
* What was said in a conversation, one thing under another. With
|
|
8
|
+
* `follow`, for one that is going on: it scrolls within itself, and the
|
|
9
|
+
* latest thing said is kept in sight as more arrives. It is put in
|
|
10
|
+
* something that gives it a height.
|
|
11
|
+
*/
|
|
12
|
+
function Thread({ label = "Conversation", follow = false, children }) {
|
|
13
|
+
const box = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const thread = box.current;
|
|
16
|
+
if (!follow || !thread) return;
|
|
17
|
+
let frame = null;
|
|
18
|
+
const latest = () => {
|
|
19
|
+
if (frame !== null) return;
|
|
20
|
+
frame = requestAnimationFrame(() => {
|
|
21
|
+
frame = null;
|
|
22
|
+
thread.scrollTop = thread.scrollHeight;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
latest();
|
|
26
|
+
const resized = new ResizeObserver(latest);
|
|
27
|
+
resized.observe(thread);
|
|
28
|
+
const said = new MutationObserver(latest);
|
|
29
|
+
said.observe(thread, {
|
|
30
|
+
childList: true,
|
|
31
|
+
subtree: true,
|
|
32
|
+
characterData: true
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
resized.disconnect();
|
|
36
|
+
said.disconnect();
|
|
37
|
+
if (frame !== null) cancelAnimationFrame(frame);
|
|
38
|
+
};
|
|
39
|
+
}, [follow]);
|
|
40
|
+
return /* @__PURE__ */ jsx("div", {
|
|
41
|
+
ref: box,
|
|
42
|
+
"data-slot": "thread",
|
|
43
|
+
"aria-live": "polite",
|
|
44
|
+
tabIndex: 0,
|
|
45
|
+
"aria-label": label,
|
|
46
|
+
className: cn("grid min-w-0 content-start gap-3", follow && "min-h-0 overflow-y-auto overscroll-contain p-0.5 [scrollbar-gutter:stable]"),
|
|
47
|
+
children
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** What was asked, with what the agent did and answered: one turn of a conversation. */
|
|
51
|
+
function Turn({ children }) {
|
|
52
|
+
return /* @__PURE__ */ jsx("div", {
|
|
53
|
+
"data-slot": "turn",
|
|
54
|
+
className: "grid min-w-0 gap-2",
|
|
55
|
+
children
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
var BUBBLES = {
|
|
59
|
+
neutral: "bg-card",
|
|
60
|
+
warn: "bg-card",
|
|
61
|
+
danger: "border-destructive bg-destructive-soft text-destructive"
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Something said in a conversation. What the person said (`asked`) is
|
|
65
|
+
* set to their side. `tone` is for where it stopped (`warn`) and for
|
|
66
|
+
* what went wrong (`danger`).
|
|
67
|
+
*/
|
|
68
|
+
function Bubble({ asked = false, tone = "neutral", children }) {
|
|
69
|
+
return /* @__PURE__ */ jsx("div", {
|
|
70
|
+
"data-slot": "bubble",
|
|
71
|
+
"data-tone": tone,
|
|
72
|
+
"data-asked": asked || void 0,
|
|
73
|
+
className: cn("min-w-0 rounded-xl border px-3.5 py-2.5 wrap-anywhere whitespace-pre-wrap", asked ? "max-w-[85%] justify-self-end bg-muted max-md:max-w-full" : BUBBLES[tone]),
|
|
74
|
+
children
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Something done on the way to an answer, such as a tool that was
|
|
79
|
+
* called: a word for how it stands, what it is, and a few words about
|
|
80
|
+
* it. It opens to show what it was given and what came back.
|
|
81
|
+
*
|
|
82
|
+
* @param tag how it stands: "Calling", "Called", "Failed"
|
|
83
|
+
* @param name what it is, read exactly: a tool's name
|
|
84
|
+
* @param about a few words more: whose tool it is, how long it took
|
|
85
|
+
*/
|
|
86
|
+
function Step({ tag, tone = "neutral", name, about, open = false, children }) {
|
|
87
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
88
|
+
"data-slot": "step",
|
|
89
|
+
open,
|
|
90
|
+
className: "min-w-0 rounded-lg border border-dashed border-input px-3 py-1.5 text-sm text-muted-foreground",
|
|
91
|
+
children: [/* @__PURE__ */ jsxs("summary", {
|
|
92
|
+
className: "flex cursor-pointer flex-wrap items-center gap-2",
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx(Tag, {
|
|
95
|
+
tone,
|
|
96
|
+
children: tag
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("span", {
|
|
99
|
+
className: "font-mono text-xs text-foreground wrap-anywhere",
|
|
100
|
+
children: name
|
|
101
|
+
}),
|
|
102
|
+
about ? /* @__PURE__ */ jsx("span", { children: about }) : null
|
|
103
|
+
]
|
|
104
|
+
}), children]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** What a step was given, or what came back, as it was written: what is long is scrolled. */
|
|
108
|
+
function StepDetail({ children }) {
|
|
109
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
110
|
+
className: "mt-2 mb-1 max-h-64 overflow-y-auto rounded-lg bg-muted px-2.5 py-2 font-mono text-xs leading-normal wrap-anywhere whitespace-pre-wrap",
|
|
111
|
+
children
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export { Bubble, Step, StepDetail, Thread, Turn };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=conversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.js","names":[],"sources":["../../src/components/conversation.tsx"],"sourcesContent":["import { useEffect, useRef, type ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { Tag, type Tone } from \"./tag\";\n\n/**\n * What was said in a conversation, one thing under another. With\n * `follow`, for one that is going on: it scrolls within itself, and the\n * latest thing said is kept in sight as more arrives. It is put in\n * something that gives it a height.\n */\nexport function Thread({ label = \"Conversation\", follow = false, children }: { label?: string; follow?: boolean; children: ReactNode }) {\n const box = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const thread = box.current;\n if (!follow || !thread) return;\n // After layout, and once for however much arrived in a frame: a streamed answer changes many times in one.\n let frame: number | null = null;\n const latest = () => {\n if (frame !== null) return;\n frame = requestAnimationFrame(() => {\n frame = null;\n thread.scrollTop = thread.scrollHeight;\n });\n };\n latest();\n const resized = new ResizeObserver(latest);\n resized.observe(thread);\n const said = new MutationObserver(latest);\n said.observe(thread, { childList: true, subtree: true, characterData: true });\n return () => {\n resized.disconnect();\n said.disconnect();\n if (frame !== null) cancelAnimationFrame(frame);\n };\n }, [follow]);\n return (\n <div ref={box} data-slot=\"thread\" aria-live=\"polite\" tabIndex={0} aria-label={label} className={cn(\"grid min-w-0 content-start gap-3\", follow && \"min-h-0 overflow-y-auto overscroll-contain p-0.5 [scrollbar-gutter:stable]\")}>\n {children}\n </div>\n );\n}\n\n/** What was asked, with what the agent did and answered: one turn of a conversation. */\nexport function Turn({ children }: { children: ReactNode }) {\n return (\n <div data-slot=\"turn\" className=\"grid min-w-0 gap-2\">\n {children}\n </div>\n );\n}\n\nconst BUBBLES: Record<\"neutral\" | \"warn\" | \"danger\", string> = {\n neutral: \"bg-card\",\n warn: \"bg-card\",\n danger: \"border-destructive bg-destructive-soft text-destructive\",\n};\n\n/**\n * Something said in a conversation. What the person said (`asked`) is\n * set to their side. `tone` is for where it stopped (`warn`) and for\n * what went wrong (`danger`).\n */\nexport function Bubble({ asked = false, tone = \"neutral\", children }: { asked?: boolean; tone?: keyof typeof BUBBLES; children: ReactNode }) {\n return (\n <div data-slot=\"bubble\" data-tone={tone} data-asked={asked || undefined} className={cn(\"min-w-0 rounded-xl border px-3.5 py-2.5 wrap-anywhere whitespace-pre-wrap\", asked ? \"max-w-[85%] justify-self-end bg-muted max-md:max-w-full\" : BUBBLES[tone])}>\n {children}\n </div>\n );\n}\n\n/**\n * Something done on the way to an answer, such as a tool that was\n * called: a word for how it stands, what it is, and a few words about\n * it. It opens to show what it was given and what came back.\n *\n * @param tag how it stands: \"Calling\", \"Called\", \"Failed\"\n * @param name what it is, read exactly: a tool's name\n * @param about a few words more: whose tool it is, how long it took\n */\nexport function Step({ tag, tone = \"neutral\", name, about, open = false, children }: { tag: string; tone?: Tone; name: string; about?: ReactNode; open?: boolean; children?: ReactNode }) {\n return (\n <details data-slot=\"step\" open={open} className=\"min-w-0 rounded-lg border border-dashed border-input px-3 py-1.5 text-sm text-muted-foreground\">\n <summary className=\"flex cursor-pointer flex-wrap items-center gap-2\">\n <Tag tone={tone}>{tag}</Tag>\n <span className=\"font-mono text-xs text-foreground wrap-anywhere\">{name}</span>\n {about ? <span>{about}</span> : null}\n </summary>\n {children}\n </details>\n );\n}\n\n/** What a step was given, or what came back, as it was written: what is long is scrolled. */\nexport function StepDetail({ children }: { children: string }) {\n return <pre className=\"mt-2 mb-1 max-h-64 overflow-y-auto rounded-lg bg-muted px-2.5 py-2 font-mono text-xs leading-normal wrap-anywhere whitespace-pre-wrap\">{children}</pre>;\n}\n"],"mappings":";;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iH;CACxL,OACE,qBAAC,WAAD;EAAS,aAAU;EAAa;EAAM,WAAU;EAAhD,UAAA,CACE,qBAAC,WAAD;GAAS,WAAU;GAAnB,UAAA;IACE,oBAAC,KAAD;KAAW;KAAO,UAAA;IAAS,CAAA;IAC3B,oBAAC,QAAD;KAAM,WAAU;KAAmD,UAAA;IAAW,CAAA;IAC7E,QAAQ,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,IAAI;GACzB;EACR,CAAA,GAAA,QACM;;AAEb;;AAGA,SAAgB,WAAW,EAAE,YAAkC;CAC7D,OAAO,oBAAC,OAAD;EAAK,WAAU;EAAyI;CAAc,CAAA;AAC/K"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface Column<Row> {
|
|
3
|
+
/** The column's title. Empty for a column of things to do, which is read out as "Actions". */
|
|
4
|
+
header: string;
|
|
5
|
+
cell: (row: Row) => ReactNode;
|
|
6
|
+
/** `end` for a column of things to do, or of numbers. */
|
|
7
|
+
align?: "start" | "end";
|
|
8
|
+
/**
|
|
9
|
+
* What the column says of a row, in words or as a number: what it is
|
|
10
|
+
* sorted, searched and chosen by. Left out, what `cell` gives where
|
|
11
|
+
* that is text or a number, and nothing where it is more than that.
|
|
12
|
+
*/
|
|
13
|
+
text?: (row: Row) => string | number | null | undefined;
|
|
14
|
+
/** For a column that says a time: when, as the platform gives it. It is sorted and narrowed by date, not by how it reads. */
|
|
15
|
+
time?: (row: Row) => string | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What a tenant has, as a table: one row for each thing, and in each row
|
|
19
|
+
* what can be done with it. `empty` says there is nothing, in a few words.
|
|
20
|
+
*
|
|
21
|
+
* Any column with a title sorts. On a phone each row is set out as a
|
|
22
|
+
* card, every value beside the name of its column. A table long enough
|
|
23
|
+
* to need it also has one search box, a choice for each column that says
|
|
24
|
+
* one of a few things, and a range of dates where a column says a time.
|
|
25
|
+
* A page that searches for itself passes `search={false}`, and one that
|
|
26
|
+
* narrows for itself `controls={false}`.
|
|
27
|
+
*
|
|
28
|
+
* A column that is `null` or `false` is left out, so that one can be
|
|
29
|
+
* shown only to those it is for.
|
|
30
|
+
*/
|
|
31
|
+
export declare function DataTable<Row>({ columns, rows, rowKey, empty, controls, search }: {
|
|
32
|
+
columns: Array<Column<Row> | null | false>;
|
|
33
|
+
rows: Row[];
|
|
34
|
+
rowKey: (row: Row) => string;
|
|
35
|
+
empty: string;
|
|
36
|
+
controls?: boolean;
|
|
37
|
+
search?: boolean;
|
|
38
|
+
}): import("react").JSX.Element;
|
|
39
|
+
/** A cell's main line, with a fainter line beneath it. */
|
|
40
|
+
export declare function CellTitle({ title, sub }: {
|
|
41
|
+
title: ReactNode;
|
|
42
|
+
sub?: ReactNode;
|
|
43
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { AS_LISTED, choicesOf, narrowed } from "../lib/table.js";
|
|
3
|
+
import { SearchField } from "./choosing.js";
|
|
4
|
+
import { Button } from "./ui/button.js";
|
|
5
|
+
import { Input } from "./ui/input.js";
|
|
6
|
+
import { NativeSelect, NativeSelectOption } from "./ui/native-select.js";
|
|
7
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "./ui/table.js";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
|
|
11
|
+
// src/components/data-table.tsx
|
|
12
|
+
/** A field of the controls above a table, with what it is called above it. */
|
|
13
|
+
function Control({ label, phone = false, children }) {
|
|
14
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
15
|
+
className: cn("grid min-w-0 gap-1 text-sm text-muted-foreground max-sm:flex-1 max-sm:basis-32", phone && "sm:hidden"),
|
|
16
|
+
children: [/* @__PURE__ */ jsx("span", { children: label }), children]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
var CELL = "px-4 py-2.5 max-sm:grid max-sm:grid-cols-[6.5rem_minmax(0,1fr)] max-sm:items-baseline max-sm:gap-2.5 max-sm:px-0 max-sm:py-1 max-sm:text-left max-sm:*:min-w-0 max-sm:*:justify-self-start max-sm:whitespace-normal max-sm:wrap-anywhere max-sm:empty:hidden max-sm:before:text-xs max-sm:before:font-semibold max-sm:before:tracking-wide max-sm:before:text-faint max-sm:before:uppercase max-sm:before:content-[attr(data-label)]";
|
|
20
|
+
/** A cell that is the row's own name, or a column of things to do: on a phone it stands by itself, with no title beside it. */
|
|
21
|
+
var UNLABELLED = "max-sm:block max-sm:before:content-none";
|
|
22
|
+
/**
|
|
23
|
+
* What a tenant has, as a table: one row for each thing, and in each row
|
|
24
|
+
* what can be done with it. `empty` says there is nothing, in a few words.
|
|
25
|
+
*
|
|
26
|
+
* Any column with a title sorts. On a phone each row is set out as a
|
|
27
|
+
* card, every value beside the name of its column. A table long enough
|
|
28
|
+
* to need it also has one search box, a choice for each column that says
|
|
29
|
+
* one of a few things, and a range of dates where a column says a time.
|
|
30
|
+
* A page that searches for itself passes `search={false}`, and one that
|
|
31
|
+
* narrows for itself `controls={false}`.
|
|
32
|
+
*
|
|
33
|
+
* A column that is `null` or `false` is left out, so that one can be
|
|
34
|
+
* shown only to those it is for.
|
|
35
|
+
*/
|
|
36
|
+
function DataTable({ columns, rows, rowKey, empty, controls = true, search = true }) {
|
|
37
|
+
const [how, setHow] = useState(AS_LISTED);
|
|
38
|
+
if (rows.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
39
|
+
className: "p-4 text-muted-foreground",
|
|
40
|
+
children: empty
|
|
41
|
+
});
|
|
42
|
+
const shown = columns.filter((column) => Boolean(column));
|
|
43
|
+
const narrows = controls && rows.length >= 8;
|
|
44
|
+
const choices = shown.map((column) => narrows ? choicesOf(column, rows) : null);
|
|
45
|
+
const dated = narrows && shown.some((column) => column.time && rows.some((row) => column.time?.(row)));
|
|
46
|
+
const listed = narrowed(shown, rows, how);
|
|
47
|
+
const sortBy = (place) => setHow((before) => ({
|
|
48
|
+
...before,
|
|
49
|
+
sort: place,
|
|
50
|
+
descending: before.sort === place ? !before.descending : false
|
|
51
|
+
}));
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [narrows ? /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: "flex flex-wrap items-end gap-x-3.5 gap-y-2.5 border-b px-4 py-3",
|
|
54
|
+
children: [
|
|
55
|
+
search ? /* @__PURE__ */ jsx(SearchField, {
|
|
56
|
+
label: "Search",
|
|
57
|
+
value: how.search,
|
|
58
|
+
onChange: (value) => setHow((before) => ({
|
|
59
|
+
...before,
|
|
60
|
+
search: value
|
|
61
|
+
}))
|
|
62
|
+
}) : null,
|
|
63
|
+
shown.map((column, place) => choices[place] ? /* @__PURE__ */ jsx(Control, {
|
|
64
|
+
label: column.header,
|
|
65
|
+
children: /* @__PURE__ */ jsxs(NativeSelect, {
|
|
66
|
+
"aria-label": `Filter ${column.header}`,
|
|
67
|
+
value: how.chosen[place] ?? "",
|
|
68
|
+
onChange: (event) => setHow((before) => ({
|
|
69
|
+
...before,
|
|
70
|
+
chosen: {
|
|
71
|
+
...before.chosen,
|
|
72
|
+
[place]: event.target.value
|
|
73
|
+
}
|
|
74
|
+
})),
|
|
75
|
+
children: [/* @__PURE__ */ jsx(NativeSelectOption, {
|
|
76
|
+
value: "",
|
|
77
|
+
children: "Any"
|
|
78
|
+
}), choices[place].map((value) => /* @__PURE__ */ jsx(NativeSelectOption, {
|
|
79
|
+
value,
|
|
80
|
+
children: value
|
|
81
|
+
}, value))]
|
|
82
|
+
})
|
|
83
|
+
}, place) : null),
|
|
84
|
+
dated ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Control, {
|
|
85
|
+
label: "From",
|
|
86
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
87
|
+
type: "date",
|
|
88
|
+
"aria-label": "From date",
|
|
89
|
+
value: how.from,
|
|
90
|
+
onChange: (event) => setHow((before) => ({
|
|
91
|
+
...before,
|
|
92
|
+
from: event.target.value
|
|
93
|
+
}))
|
|
94
|
+
})
|
|
95
|
+
}), /* @__PURE__ */ jsx(Control, {
|
|
96
|
+
label: "To",
|
|
97
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
98
|
+
type: "date",
|
|
99
|
+
"aria-label": "To date",
|
|
100
|
+
value: how.to,
|
|
101
|
+
onChange: (event) => setHow((before) => ({
|
|
102
|
+
...before,
|
|
103
|
+
to: event.target.value
|
|
104
|
+
}))
|
|
105
|
+
})
|
|
106
|
+
})] }) : null,
|
|
107
|
+
/* @__PURE__ */ jsx(Control, {
|
|
108
|
+
label: "Sort by",
|
|
109
|
+
phone: true,
|
|
110
|
+
children: /* @__PURE__ */ jsxs(NativeSelect, {
|
|
111
|
+
"aria-label": "Sort by",
|
|
112
|
+
value: how.sort < 0 ? "" : String(how.sort),
|
|
113
|
+
onChange: (event) => setHow((before) => ({
|
|
114
|
+
...before,
|
|
115
|
+
sort: event.target.value === "" ? -1 : Number(event.target.value),
|
|
116
|
+
descending: false
|
|
117
|
+
})),
|
|
118
|
+
children: [/* @__PURE__ */ jsx(NativeSelectOption, {
|
|
119
|
+
value: "",
|
|
120
|
+
children: "As listed"
|
|
121
|
+
}), shown.map((column, place) => column.header === "" ? null : /* @__PURE__ */ jsx(NativeSelectOption, {
|
|
122
|
+
value: String(place),
|
|
123
|
+
children: column.header
|
|
124
|
+
}, place))]
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ jsxs("span", {
|
|
128
|
+
className: "ml-auto flex min-h-9 items-center gap-2.5 whitespace-nowrap",
|
|
129
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
130
|
+
role: "status",
|
|
131
|
+
className: "text-sm text-muted-foreground",
|
|
132
|
+
children: [
|
|
133
|
+
listed.length,
|
|
134
|
+
" of ",
|
|
135
|
+
rows.length
|
|
136
|
+
]
|
|
137
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
138
|
+
variant: "outline",
|
|
139
|
+
size: "sm",
|
|
140
|
+
onClick: () => setHow(AS_LISTED),
|
|
141
|
+
children: "Reset"
|
|
142
|
+
})]
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
}) : null, /* @__PURE__ */ jsxs(Table, {
|
|
146
|
+
role: "table",
|
|
147
|
+
className: "tabular-nums max-sm:block",
|
|
148
|
+
children: [/* @__PURE__ */ jsx(TableHeader, {
|
|
149
|
+
role: "rowgroup",
|
|
150
|
+
className: "max-sm:sr-only",
|
|
151
|
+
children: /* @__PURE__ */ jsx(TableRow, {
|
|
152
|
+
role: "row",
|
|
153
|
+
children: shown.map((column, place) => /* @__PURE__ */ jsx(TableHead, {
|
|
154
|
+
role: "columnheader",
|
|
155
|
+
scope: "col",
|
|
156
|
+
"aria-sort": column.header === "" ? void 0 : how.sort !== place ? "none" : how.descending ? "descending" : "ascending",
|
|
157
|
+
className: column.align === "end" ? "px-4 text-right" : "px-4",
|
|
158
|
+
children: column.header === "" ? /* @__PURE__ */ jsx("span", {
|
|
159
|
+
className: "sr-only",
|
|
160
|
+
children: "Actions"
|
|
161
|
+
}) : /* @__PURE__ */ jsxs("button", {
|
|
162
|
+
type: "button",
|
|
163
|
+
onClick: () => sortBy(place),
|
|
164
|
+
className: "inline-flex cursor-pointer items-center gap-1 rounded-sm font-medium hover:text-foreground",
|
|
165
|
+
children: [column.header, how.sort !== place ? null : how.descending ? /* @__PURE__ */ jsx(ArrowDownIcon, {
|
|
166
|
+
"aria-hidden": "true",
|
|
167
|
+
className: "size-3.5"
|
|
168
|
+
}) : /* @__PURE__ */ jsx(ArrowUpIcon, {
|
|
169
|
+
"aria-hidden": "true",
|
|
170
|
+
className: "size-3.5"
|
|
171
|
+
})]
|
|
172
|
+
})
|
|
173
|
+
}, place))
|
|
174
|
+
})
|
|
175
|
+
}), /* @__PURE__ */ jsxs(TableBody, {
|
|
176
|
+
role: "rowgroup",
|
|
177
|
+
className: "max-sm:block",
|
|
178
|
+
children: [listed.map((row) => /* @__PURE__ */ jsx(TableRow, {
|
|
179
|
+
role: "row",
|
|
180
|
+
className: "max-sm:block max-sm:px-4 max-sm:py-2.5",
|
|
181
|
+
children: shown.map((column, place) => /* @__PURE__ */ jsx(TableCell, {
|
|
182
|
+
role: "cell",
|
|
183
|
+
"data-label": column.header === "" || place === 0 ? void 0 : column.header,
|
|
184
|
+
className: cn(CELL, column.align === "end" && "text-right", (column.header === "" || place === 0) && UNLABELLED),
|
|
185
|
+
children: column.cell(row)
|
|
186
|
+
}, place))
|
|
187
|
+
}, rowKey(row))), listed.length === 0 ? /* @__PURE__ */ jsx(TableRow, {
|
|
188
|
+
role: "row",
|
|
189
|
+
className: "max-sm:block max-sm:px-4 max-sm:py-2.5",
|
|
190
|
+
children: /* @__PURE__ */ jsx(TableCell, {
|
|
191
|
+
role: "cell",
|
|
192
|
+
colSpan: shown.length,
|
|
193
|
+
className: "px-4 py-2.5 text-muted-foreground max-sm:block max-sm:px-0",
|
|
194
|
+
children: "No matching rows."
|
|
195
|
+
})
|
|
196
|
+
}) : null]
|
|
197
|
+
})]
|
|
198
|
+
})] });
|
|
199
|
+
}
|
|
200
|
+
/** A cell's main line, with a fainter line beneath it. */
|
|
201
|
+
function CellTitle({ title, sub }) {
|
|
202
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
203
|
+
className: "font-medium",
|
|
204
|
+
children: [title, sub ? /* @__PURE__ */ jsx("div", {
|
|
205
|
+
className: "text-xs font-normal text-muted-foreground",
|
|
206
|
+
children: sub
|
|
207
|
+
}) : null]
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
export { CellTitle, DataTable };
|
|
211
|
+
|
|
212
|
+
//# sourceMappingURL=data-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table.js","names":["_Fragment"],"sources":["../../src/components/data-table.tsx"],"sourcesContent":["import { useState, type ReactNode } from \"react\";\nimport { ArrowDownIcon, ArrowUpIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { AS_LISTED, FEW, choicesOf, narrowed, type Narrowing } from \"../lib/table\";\nimport { SearchField } from \"./choosing\";\nimport { Button } from \"./ui/button\";\nimport { Input } from \"./ui/input\";\nimport { NativeSelect, NativeSelectOption } from \"./ui/native-select\";\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from \"./ui/table\";\n\nexport interface Column<Row> {\n /** The column's title. Empty for a column of things to do, which is read out as \"Actions\". */\n header: string;\n cell: (row: Row) => ReactNode;\n /** `end` for a column of things to do, or of numbers. */\n align?: \"start\" | \"end\";\n /**\n * What the column says of a row, in words or as a number: what it is\n * sorted, searched and chosen by. Left out, what `cell` gives where\n * that is text or a number, and nothing where it is more than that.\n */\n text?: (row: Row) => string | number | null | undefined;\n /** For a column that says a time: when, as the platform gives it. It is sorted and narrowed by date, not by how it reads. */\n time?: (row: Row) => string | null | undefined;\n}\n\n/** A field of the controls above a table, with what it is called above it. */\nfunction Control({ label, phone = false, children }: { label: string; phone?: boolean; children: ReactNode }) {\n return (\n <label className={cn(\"grid min-w-0 gap-1 text-sm text-muted-foreground max-sm:flex-1 max-sm:basis-32\", phone && \"sm:hidden\")}>\n <span>{label}</span>\n {children}\n </label>\n );\n}\n\nconst CELL = \"px-4 py-2.5 max-sm:grid max-sm:grid-cols-[6.5rem_minmax(0,1fr)] max-sm:items-baseline max-sm:gap-2.5 max-sm:px-0 max-sm:py-1 max-sm:text-left max-sm:*:min-w-0 max-sm:*:justify-self-start max-sm:whitespace-normal max-sm:wrap-anywhere max-sm:empty:hidden max-sm:before:text-xs max-sm:before:font-semibold max-sm:before:tracking-wide max-sm:before:text-faint max-sm:before:uppercase max-sm:before:content-[attr(data-label)]\";\n/** A cell that is the row's own name, or a column of things to do: on a phone it stands by itself, with no title beside it. */\nconst UNLABELLED = \"max-sm:block max-sm:before:content-none\";\n\n/**\n * What a tenant has, as a table: one row for each thing, and in each row\n * what can be done with it. `empty` says there is nothing, in a few words.\n *\n * Any column with a title sorts. On a phone each row is set out as a\n * card, every value beside the name of its column. A table long enough\n * to need it also has one search box, a choice for each column that says\n * one of a few things, and a range of dates where a column says a time.\n * A page that searches for itself passes `search={false}`, and one that\n * narrows for itself `controls={false}`.\n *\n * A column that is `null` or `false` is left out, so that one can be\n * shown only to those it is for.\n */\nexport function DataTable<Row>({ columns, rows, rowKey, empty, controls = true, search = true }: { columns: Array<Column<Row> | null | false>; rows: Row[]; rowKey: (row: Row) => string; empty: string; controls?: boolean; search?: boolean }) {\n const [how, setHow] = useState<Narrowing>(AS_LISTED);\n if (rows.length === 0) return <p className=\"p-4 text-muted-foreground\">{empty}</p>;\n const shown = columns.filter((column): column is Column<Row> => Boolean(column));\n const narrows = controls && rows.length >= FEW;\n const choices = shown.map((column) => (narrows ? choicesOf(column, rows) : null));\n const dated = narrows && shown.some((column) => column.time && rows.some((row) => column.time?.(row)));\n const listed = narrowed(shown, rows, how);\n const sortBy = (place: number) => setHow((before) => ({ ...before, sort: place, descending: before.sort === place ? !before.descending : false }));\n\n return (\n <>\n {narrows ? (\n <div className=\"flex flex-wrap items-end gap-x-3.5 gap-y-2.5 border-b px-4 py-3\">\n {search ? <SearchField label=\"Search\" value={how.search} onChange={(value) => setHow((before) => ({ ...before, search: value }))} /> : null}\n {shown.map((column, place) =>\n choices[place] ? (\n <Control key={place} label={column.header}>\n <NativeSelect aria-label={`Filter ${column.header}`} value={how.chosen[place] ?? \"\"} onChange={(event) => setHow((before) => ({ ...before, chosen: { ...before.chosen, [place]: event.target.value } }))}>\n <NativeSelectOption value=\"\">Any</NativeSelectOption>\n {choices[place].map((value) => (\n <NativeSelectOption key={value} value={value}>\n {value}\n </NativeSelectOption>\n ))}\n </NativeSelect>\n </Control>\n ) : null,\n )}\n {dated ? (\n <>\n <Control label=\"From\">\n <Input type=\"date\" aria-label=\"From date\" value={how.from} onChange={(event) => setHow((before) => ({ ...before, from: event.target.value }))} />\n </Control>\n <Control label=\"To\">\n <Input type=\"date\" aria-label=\"To date\" value={how.to} onChange={(event) => setHow((before) => ({ ...before, to: event.target.value }))} />\n </Control>\n </>\n ) : null}\n {/* On a phone the headings are not shown, so what to sort by is chosen here. */}\n <Control label=\"Sort by\" phone>\n <NativeSelect aria-label=\"Sort by\" value={how.sort < 0 ? \"\" : String(how.sort)} onChange={(event) => setHow((before) => ({ ...before, sort: event.target.value === \"\" ? -1 : Number(event.target.value), descending: false }))}>\n <NativeSelectOption value=\"\">As listed</NativeSelectOption>\n {shown.map((column, place) =>\n column.header === \"\" ? null : (\n <NativeSelectOption key={place} value={String(place)}>\n {column.header}\n </NativeSelectOption>\n ),\n )}\n </NativeSelect>\n </Control>\n <span className=\"ml-auto flex min-h-9 items-center gap-2.5 whitespace-nowrap\">\n <span role=\"status\" className=\"text-sm text-muted-foreground\">\n {listed.length} of {rows.length}\n </span>\n <Button variant=\"outline\" size=\"sm\" onClick={() => setHow(AS_LISTED)}>\n Reset\n </Button>\n </span>\n </div>\n ) : null}\n {/* The roles are said outright: as cards on a phone these are no longer laid out as a table, and are one all the same. */}\n <Table role=\"table\" className=\"tabular-nums max-sm:block\">\n <TableHeader role=\"rowgroup\" className=\"max-sm:sr-only\">\n <TableRow role=\"row\">\n {shown.map((column, place) => (\n <TableHead key={place} role=\"columnheader\" scope=\"col\" aria-sort={column.header === \"\" ? undefined : how.sort !== place ? \"none\" : how.descending ? \"descending\" : \"ascending\"} className={column.align === \"end\" ? \"px-4 text-right\" : \"px-4\"}>\n {column.header === \"\" ? (\n <span className=\"sr-only\">Actions</span>\n ) : (\n <button type=\"button\" onClick={() => sortBy(place)} className=\"inline-flex cursor-pointer items-center gap-1 rounded-sm font-medium hover:text-foreground\">\n {column.header}\n {how.sort !== place ? null : how.descending ? <ArrowDownIcon aria-hidden=\"true\" className=\"size-3.5\" /> : <ArrowUpIcon aria-hidden=\"true\" className=\"size-3.5\" />}\n </button>\n )}\n </TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody role=\"rowgroup\" className=\"max-sm:block\">\n {listed.map((row) => (\n <TableRow key={rowKey(row)} role=\"row\" className=\"max-sm:block max-sm:px-4 max-sm:py-2.5\">\n {shown.map((column, place) => (\n <TableCell key={place} role=\"cell\" data-label={column.header === \"\" || place === 0 ? undefined : column.header} className={cn(CELL, column.align === \"end\" && \"text-right\", (column.header === \"\" || place === 0) && UNLABELLED)}>\n {column.cell(row)}\n </TableCell>\n ))}\n </TableRow>\n ))}\n {listed.length === 0 ? (\n <TableRow role=\"row\" className=\"max-sm:block max-sm:px-4 max-sm:py-2.5\">\n <TableCell role=\"cell\" colSpan={shown.length} className=\"px-4 py-2.5 text-muted-foreground max-sm:block max-sm:px-0\">\n No matching rows.\n </TableCell>\n </TableRow>\n ) : null}\n </TableBody>\n </Table>\n </>\n );\n}\n\n/** A cell's main line, with a fainter line beneath it. */\nexport function CellTitle({ title, sub }: { title: ReactNode; sub?: ReactNode }) {\n return (\n <div className=\"font-medium\">\n {title}\n {sub ? <div className=\"text-xs font-normal text-muted-foreground\">{sub}</div> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAS,QAAQ,EAAE,OAAO,QAAQ,OAAO,YAAqE;CAC5G,OACE,qBAAC,SAAD;EAAO,WAAW,GAAG,kFAAkF,SAAS,WAAW;EAA3H,UAAA,CACE,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,GAClB,QACI;;AAEX;AAEA,IAAM,OAAO;;AAEb,IAAM,aAAa;;;;;;;;;;;;;;;AAgBnB,SAAgB,UAAe,EAAE,SAAS,MAAM,QAAQ,OAAO,WAAW,MAAM,SAAS,QAAwJ;CAC/O,MAAM,CAAC,KAAK,UAAU,SAAoB,SAAS;CACnD,IAAI,KAAK,WAAW,GAAG,OAAO,oBAAC,KAAD;EAAG,WAAU;EAA6B,UAAA;CAAS,CAAA;CACjF,MAAM,QAAQ,QAAQ,QAAQ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gB,UAAU,EAAE,OAAO,OAA8C;CAC/E,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,OACA,MAAM,oBAAC,OAAD;GAAK,WAAU;GAA6C,UAAA;EAAS,CAAA,IAAI,IAC7E;;AAET"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import { Checkbox } from "./ui/checkbox";
|
|
3
|
+
import { Input } from "./ui/input";
|
|
4
|
+
import { Textarea } from "./ui/textarea";
|
|
5
|
+
import { NativeSelect } from "./ui/native-select";
|
|
6
|
+
/** A labelled input. `hint` is said below it. Its value is read by name, from the form it is in. */
|
|
7
|
+
export declare function TextField({ label, hint, ...input }: {
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: ReactNode;
|
|
10
|
+
name: string;
|
|
11
|
+
} & Omit<ComponentProps<typeof Input>, "name">): import("react").JSX.Element;
|
|
12
|
+
/** A labelled choice of one from a few. `options` are pairs of a value and what it is called. */
|
|
13
|
+
export declare function SelectField({ label, hint, options, ...select }: {
|
|
14
|
+
label: string;
|
|
15
|
+
hint?: ReactNode;
|
|
16
|
+
name: string;
|
|
17
|
+
options: Array<[value: string, label: string]>;
|
|
18
|
+
} & Omit<ComponentProps<typeof NativeSelect>, "name" | "children">): import("react").JSX.Element;
|
|
19
|
+
/** A labelled box for several lines. */
|
|
20
|
+
export declare function TextareaField({ label, hint, ...textarea }: {
|
|
21
|
+
label: string;
|
|
22
|
+
hint?: ReactNode;
|
|
23
|
+
} & ComponentProps<typeof Textarea>): import("react").JSX.Element;
|
|
24
|
+
/** Something that is so or is not, with its label beside it. */
|
|
25
|
+
export declare function CheckboxField({ label, hint, ...checkbox }: {
|
|
26
|
+
label: string;
|
|
27
|
+
hint?: ReactNode;
|
|
28
|
+
} & ComponentProps<typeof Checkbox>): import("react").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* A labelled choice of any number from a list, all in sight. `value` is
|
|
31
|
+
* what is chosen, kept by the page.
|
|
32
|
+
*
|
|
33
|
+
* @param rows how many are in sight at once
|
|
34
|
+
*/
|
|
35
|
+
export declare function MultiSelectField({ label, hint, options, value, onChange, rows, disabled }: {
|
|
36
|
+
label: string;
|
|
37
|
+
hint?: ReactNode;
|
|
38
|
+
options: Array<[value: string, label: string]>;
|
|
39
|
+
value: string[];
|
|
40
|
+
onChange: (value: string[]) => void;
|
|
41
|
+
rows?: number;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
}): import("react").JSX.Element;
|
|
44
|
+
/**
|
|
45
|
+
* A labelled choice of one from a few, all in sight, each with a line
|
|
46
|
+
* about it (`about`). One that cannot be chosen is still shown, so that
|
|
47
|
+
* it can say why. `value` is what is chosen, kept by the page.
|
|
48
|
+
*/
|
|
49
|
+
export declare function RadioField<Value extends string>({ label, hint, options, value, onChange, disabled }: {
|
|
50
|
+
label: string;
|
|
51
|
+
hint?: ReactNode;
|
|
52
|
+
options: Array<{
|
|
53
|
+
value: Value;
|
|
54
|
+
label: string;
|
|
55
|
+
about?: ReactNode;
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
value: Value;
|
|
59
|
+
onChange: (value: Value) => void;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
}): import("react").JSX.Element;
|