@sincpro/web-ui 2.10.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -4
- package/dist/components/activity/Messages.d.ts +3 -23
- package/dist/components/activity/Messages.js +3 -17
- package/dist/components/activity/index.d.ts +2 -1
- package/dist/components/activity/index.js +2 -1
- package/dist/components/activity/messageKind.d.ts +23 -0
- package/dist/components/activity/messageKind.js +17 -0
- package/dist/components/assist/assist.d.ts +1 -1
- package/dist/components/assist/assist.js +1 -1
- package/dist/components/attachments/FileValue.d.ts +10 -0
- package/dist/components/attachments/FileValue.js +40 -0
- package/dist/components/attachments/index.d.ts +1 -0
- package/dist/components/attachments/index.js +3 -1
- package/dist/components/frame/model.js +1 -1
- package/dist/components/guide/index.d.ts +2 -1
- package/dist/components/guide/index.js +2 -1
- package/dist/components/guide/selector.d.ts +25 -0
- package/dist/components/guide/selector.js +14 -0
- package/dist/components/guide/target.d.ts +3 -25
- package/dist/components/guide/target.js +2 -14
- package/dist/components/listing/AxisLevels.d.ts +2 -5
- package/dist/components/listing/AxisLevels.js +5 -22
- package/dist/components/listing/ColumnsMenu.d.ts +3 -7
- package/dist/components/listing/ColumnsMenu.js +4 -8
- package/dist/components/listing/collapsed.d.ts +2 -0
- package/dist/components/listing/collapsed.js +8 -0
- package/dist/components/listing/columnSpecs.d.ts +34 -0
- package/dist/components/listing/columnSpecs.js +54 -0
- package/dist/components/listing/columns.d.ts +3 -21
- package/dist/components/listing/columns.js +2 -39
- package/dist/components/listing/index.d.ts +9 -5
- package/dist/components/listing/index.js +13 -6
- package/dist/components/listing/levels.d.ts +9 -0
- package/dist/components/listing/levels.js +27 -0
- package/dist/components/listing/pageSizes.d.ts +9 -0
- package/dist/components/listing/pageSizes.js +11 -0
- package/dist/components/listing/pages.d.ts +2 -9
- package/dist/components/listing/pages.js +5 -9
- package/dist/components/listing/tree.d.ts +2 -1
- package/dist/components/listing/tree.js +4 -5
- package/dist/components/preview/FilePreview.d.ts +3 -3
- package/dist/components/preview/FilePreview.js +3 -15
- package/dist/components/preview/index.d.ts +2 -1
- package/dist/components/preview/index.js +2 -1
- package/dist/components/preview/previewKind.d.ts +3 -0
- package/dist/components/preview/previewKind.js +17 -0
- package/dist/components/search/FilterBuilder.d.ts +5 -139
- package/dist/components/search/FilterBuilder.js +5 -579
- package/dist/components/search/JsonEditor.d.ts +2 -8
- package/dist/components/search/JsonEditor.js +5 -15
- package/dist/components/search/RuleValue.d.ts +2 -2
- package/dist/components/search/RuleValue.js +5 -4
- package/dist/components/search/datePeriods.js +1 -1
- package/dist/components/search/filterTree.d.ts +183 -0
- package/dist/components/search/filterTree.js +570 -0
- package/dist/components/search/formatJson.d.ts +8 -0
- package/dist/components/search/formatJson.js +17 -0
- package/dist/components/search/index.d.ts +5 -3
- package/dist/components/search/index.js +7 -3
- package/dist/components/search/query.js +1 -1
- package/dist/foundations/calendar.js +1 -1
- package/dist/foundations/catalog.d.ts +7 -8
- package/dist/foundations/catalog.js +10 -35
- package/dist/foundations/chart.js +1 -1
- package/dist/foundations/controlName.d.ts +12 -0
- package/dist/foundations/controlName.js +14 -0
- package/dist/foundations/copy.d.ts +3 -1130
- package/dist/foundations/copy.es.d.ts +1 -1
- package/dist/foundations/copy.js +13 -747
- package/dist/foundations/copyStore.d.ts +21 -0
- package/dist/foundations/copyStore.js +47 -0
- package/dist/foundations/density.d.ts +4 -8
- package/dist/foundations/density.js +2 -9
- package/dist/foundations/form.d.ts +2 -12
- package/dist/foundations/form.js +4 -14
- package/dist/foundations/index.d.ts +18 -11
- package/dist/foundations/index.js +21 -11
- package/dist/foundations/keys.d.ts +8 -0
- package/dist/foundations/keys.js +6 -0
- package/dist/foundations/pickBy.d.ts +16 -0
- package/dist/foundations/pickBy.js +17 -0
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/shortcut.d.ts +3 -9
- package/dist/foundations/shortcut.js +2 -7
- package/dist/foundations/sticky.d.ts +2 -6
- package/dist/foundations/sticky.js +5 -8
- package/dist/foundations/stickyStyle.d.ts +12 -0
- package/dist/foundations/stickyStyle.js +13 -0
- package/dist/foundations/surface.d.ts +2 -2
- package/dist/foundations/surface.js +4 -2
- package/dist/foundations/theme.d.ts +3 -13
- package/dist/foundations/theme.js +2 -15
- package/dist/foundations/themeChoice.d.ts +19 -0
- package/dist/foundations/themeChoice.js +22 -0
- package/dist/foundations/types.d.ts +3 -0
- package/dist/foundations/uiCopy.d.ts +1135 -0
- package/dist/foundations/uiCopy.js +749 -0
- package/dist/foundations/xlsx.d.ts +4 -10
- package/dist/foundations/xlsx.js +0 -0
- package/dist/foundations/xlsxDownload.d.ts +8 -0
- package/dist/foundations/xlsxDownload.js +28 -0
- package/dist/primitives/button/Button.d.ts +3 -15
- package/dist/primitives/button/Button.js +2 -65
- package/dist/primitives/button/classes.d.ts +21 -0
- package/dist/primitives/button/classes.js +65 -0
- package/dist/primitives/button/index.d.ts +2 -1
- package/dist/primitives/button/index.js +3 -1
- package/dist/primitives/field/Field.d.ts +2 -6
- package/dist/primitives/field/Field.js +4 -10
- package/dist/primitives/field/classes.d.ts +6 -0
- package/dist/primitives/field/classes.js +13 -0
- package/dist/primitives/field/index.d.ts +2 -1
- package/dist/primitives/field/index.js +3 -1
- package/dist/primitives/menu/Menu.d.ts +2 -19
- package/dist/primitives/menu/Menu.js +4 -30
- package/dist/primitives/menu/classes.d.ts +18 -0
- package/dist/primitives/menu/classes.js +33 -0
- package/dist/primitives/menu/index.d.ts +2 -1
- package/dist/primitives/menu/index.js +3 -1
- package/dist/primitives/table/EditableTable.d.ts +3 -37
- package/dist/primitives/table/EditableTable.js +2 -47
- package/dist/primitives/table/Table.d.ts +2 -4
- package/dist/primitives/table/Table.js +4 -11
- package/dist/primitives/table/cellTone.d.ts +5 -0
- package/dist/primitives/table/cellTone.js +13 -0
- package/dist/primitives/table/editRules.d.ts +43 -0
- package/dist/primitives/table/editRules.js +53 -0
- package/dist/primitives/table/index.d.ts +4 -2
- package/dist/primitives/table/index.js +4 -2
- package/dist/primitives/tag/Count.d.ts +2 -3
- package/dist/primitives/tag/Count.js +4 -5
- package/dist/primitives/tag/countText.d.ts +3 -0
- package/dist/primitives/tag/countText.js +7 -0
- package/dist/primitives/tag/index.d.ts +2 -1
- package/dist/primitives/tag/index.js +2 -1
- package/dist/primitives/value/DateValue.d.ts +2 -5
- package/dist/primitives/value/DateValue.js +6 -44
- package/dist/primitives/value/Meter.d.ts +3 -8
- package/dist/primitives/value/Meter.js +2 -9
- package/dist/primitives/value/RichText.d.ts +2 -4
- package/dist/primitives/value/RichText.js +5 -20
- package/dist/primitives/value/Value.d.ts +10 -7
- package/dist/primitives/value/Value.js +7 -24
- package/dist/primitives/value/format.d.ts +16 -0
- package/dist/primitives/value/format.js +81 -0
- package/dist/primitives/value/index.d.ts +7 -4
- package/dist/primitives/value/index.js +9 -4
- package/dist/primitives/value/meterLevel.d.ts +10 -0
- package/dist/primitives/value/meterLevel.js +12 -0
- package/dist/primitives/value/richTextPlain.d.ts +4 -0
- package/dist/primitives/value/richTextPlain.js +23 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,9 +123,36 @@ export default { plugins: { "@tailwindcss/postcss": {} } };
|
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
- **Server Components** may import from `@sincpro/web-ui`. Every module that needs the browser
|
|
126
|
-
(hooks, context, events) starts with `"use client"`, and a test keeps it that way
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
(hooks, context, events) starts with `"use client"`, and a test keeps it that way. What is
|
|
127
|
+
public and draws nothing lives in a module WITHOUT it, so a Server Component calls it and
|
|
128
|
+
gets a value, not a client reference: the looks (`buttonClasses`, `controlClasses`,
|
|
129
|
+
`menuTriggerClasses`, `CELL_TONE`, `byDensity`, `bySurface`), the formatters (`formatCount`,
|
|
130
|
+
`formatNumber`, `formatWith`, `formatDateTime`, `formatRelative`, `countText`), the words
|
|
131
|
+
(`installCopy`, `currentCopy`, `fillCopy`, `ENGLISH_COPY`), the theme's names
|
|
132
|
+
(`THEME_ATTRIBUTE`, `isTheme`), `writeXlsx`, the calendar, the pivot, the criteria and the
|
|
133
|
+
filter's tree (`describeFilter`, `treeFromFilter`) — `tests/serverBoundary.test.ts` holds
|
|
134
|
+
it. What needs a browser stays client: `downloadFile`, `downloadXlsx`, `applyTheme`,
|
|
135
|
+
`sanitizeRichText`. The views are client components: compose `Record` or `List` inside a
|
|
136
|
+
client component of your own.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
// app/invoices/page.tsx — a Server Component
|
|
140
|
+
import Link from "next/link";
|
|
141
|
+
import { buttonClasses, formatCount } from "@sincpro/web-ui";
|
|
142
|
+
|
|
143
|
+
export default async function Invoices() {
|
|
144
|
+
const pending = await countPending();
|
|
145
|
+
return (
|
|
146
|
+
<header>
|
|
147
|
+
<p>{formatCount(pending)} por cobrar</p>
|
|
148
|
+
<Link href="/invoices/new" className={buttonClasses("primary", "md")}>
|
|
149
|
+
Nueva factura
|
|
150
|
+
</Link>
|
|
151
|
+
</header>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
129
156
|
- **The language.** `installCopy` sets the one global there is — and on a server, one process
|
|
130
157
|
renders every page and every request. Installed in one page, it leaks into the next page the
|
|
131
158
|
server renders, which the browser then draws in English: a hydration error. Install it in a
|
|
@@ -142,6 +169,11 @@ export default { plugins: { "@tailwindcss/postcss": {} } };
|
|
|
142
169
|
}
|
|
143
170
|
```
|
|
144
171
|
|
|
172
|
+
A Server Component that formats (`formatCount`, `formatDateTime`, `describeFilter`) reads
|
|
173
|
+
the words installed in ITS module graph — the server components' copy of the package is not
|
|
174
|
+
the browser's. Install the language there too, at the top of a module your root layout
|
|
175
|
+
imports (the same for every request), or pass the locale: `formatCount(total, "es-BO")`.
|
|
176
|
+
|
|
145
177
|
- **webpack** (`next build --webpack`): a Server Component that imports from the package root
|
|
146
178
|
makes webpack send the WHOLE library to the browser (~1.2 MB gzip for one `Button`). Let Next
|
|
147
179
|
rewrite those imports — Turbopack, the default, does not need it:
|
|
@@ -266,7 +298,7 @@ of classes that change with the next refactor:
|
|
|
266
298
|
|
|
267
299
|
The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`,
|
|
268
300
|
`menu.section`, `menu.item`, `menu.fold`, `dialog`, `block`, `record-card`, `board.tile`,
|
|
269
|
-
`board.stat`, `board.stat.value`, `activity.changes`, `file-list`, `file-list.file`, `metric`, `metric.detail`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`,
|
|
301
|
+
`board.stat`, `board.stat.value`, `activity.changes`, `file-list`, `file-list.file`, `file-value`, `metric`, `metric.detail`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`,
|
|
270
302
|
`search.panel`, `search.suggestions`, `search.suggestion`, `search.record`, `search.advanced`,
|
|
271
303
|
`search.keys`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `yes-no`,
|
|
272
304
|
`table.head`, `row.ways`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type MessageKind, writeANote } from "./messageKind.js";
|
|
1
2
|
import type { AttachmentFile } from "../attachments/files.js";
|
|
2
|
-
import { type UiCopy } from "../../foundations/copy.js";
|
|
3
3
|
import { type ReactNode } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* The box to write in. What gets written is drawn by `Activity`, together with
|
|
@@ -38,28 +38,8 @@ export type Message = {
|
|
|
38
38
|
* (`FileList`). A message may be only its files: then `body` is empty. */
|
|
39
39
|
files?: readonly AttachmentFile[];
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export type MessageKind = {
|
|
44
|
-
id: string;
|
|
45
|
-
label: string;
|
|
46
|
-
/** It stays inside. Without this the kit assumes it leaves, which is the
|
|
47
|
-
* answer that errs on the side of asking. */
|
|
48
|
-
internal?: boolean;
|
|
49
|
-
/** Who gets it, in their own words: names for a mail, numbers for WhatsApp.
|
|
50
|
-
* Shown before sending, never after. */
|
|
51
|
-
recipients?: readonly string[];
|
|
52
|
-
placeholder?: string;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* WRITE A NOTE, the way every list has.
|
|
56
|
-
*
|
|
57
|
-
* It is a function and not a constant because its words come from the copy, and a
|
|
58
|
-
* constant would freeze them with whatever there was when the module loaded —that is, the
|
|
59
|
-
* factory ones— even if another is installed afterwards. Without `copy`, the installed ones; a
|
|
60
|
-
* component passes it those of its branch.
|
|
61
|
-
*/
|
|
62
|
-
export declare function writeANote(copy?: UiCopy): MessageKind;
|
|
41
|
+
export type { MessageKind };
|
|
42
|
+
export { writeANote };
|
|
63
43
|
export type MessageComposerProps = {
|
|
64
44
|
/** The ways of writing this record takes. Its own list because it is the
|
|
65
45
|
* application that knows whether there is WhatsApp, and to whose number. */
|
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { writeANote, } from "./messageKind.js";
|
|
4
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
5
|
import { Button } from "../../primitives/button/Button.js";
|
|
5
6
|
import { TextArea } from "../../primitives/field/Field.js";
|
|
6
7
|
import { Send, Users, X } from "lucide-react";
|
|
7
8
|
import { useState } from "react";
|
|
8
|
-
|
|
9
|
-
* WRITE A NOTE, the way every list has.
|
|
10
|
-
*
|
|
11
|
-
* It is a function and not a constant because its words come from the copy, and a
|
|
12
|
-
* constant would freeze them with whatever there was when the module loaded —that is, the
|
|
13
|
-
* factory ones— even if another is installed afterwards. Without `copy`, the installed ones; a
|
|
14
|
-
* component passes it those of its branch.
|
|
15
|
-
*/
|
|
16
|
-
export function writeANote(copy = currentCopy()) {
|
|
17
|
-
return {
|
|
18
|
-
id: "note",
|
|
19
|
-
label: copy.activity.writeNote,
|
|
20
|
-
internal: true,
|
|
21
|
-
placeholder: copy.activity.notePlaceholder,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
9
|
+
export { writeANote };
|
|
24
10
|
export function MessageComposer({ kinds, onSend, sending = false, footer, }) {
|
|
25
11
|
const copy = useUiCopy();
|
|
26
12
|
/* The default way is built in here and not in the signature: a parameter
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Activity, type ActivityAlert, type ActivityChange, type ActivityEvent, type ActivityLayout, type ActivityProps, useActivity, } from "./Activity.js";
|
|
2
2
|
export { ActivityBadge, type ActivityState, } from "./ActivityBadge.js";
|
|
3
|
-
export { type
|
|
3
|
+
export { type MessageKind, writeANote, } from "./messageKind.js";
|
|
4
|
+
export { type Message, MessageComposer, type MessageComposerProps, } from "./Messages.js";
|
|
4
5
|
export { Timeline, type TimelineItemProps, type TimelineProps, } from "./Timeline.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* ACTIVITY — everything around a record: its notices, its conversation and its history. */
|
|
2
2
|
export { Activity, useActivity, } from "./Activity.js";
|
|
3
3
|
export { ActivityBadge, } from "./ActivityBadge.js";
|
|
4
|
-
export {
|
|
4
|
+
export { writeANote, } from "./messageKind.js";
|
|
5
|
+
export { MessageComposer, } from "./Messages.js";
|
|
5
6
|
export { Timeline, } from "./Timeline.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type UiCopy } from "../../foundations/uiCopy.js";
|
|
2
|
+
/** A way of writing. `note` stays inside; everything else leaves, and what
|
|
3
|
+
* changes between them is only the channel and who is on the other side. */
|
|
4
|
+
export type MessageKind = {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** It stays inside. Without this the kit assumes it leaves, which is the
|
|
8
|
+
* answer that errs on the side of asking. */
|
|
9
|
+
internal?: boolean;
|
|
10
|
+
/** Who gets it, in their own words: names for a mail, numbers for WhatsApp.
|
|
11
|
+
* Shown before sending, never after. */
|
|
12
|
+
recipients?: readonly string[];
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* WRITE A NOTE, the way every list has.
|
|
17
|
+
*
|
|
18
|
+
* It is a function and not a constant because its words come from the copy, and a
|
|
19
|
+
* constant would freeze them with whatever there was when the module loaded —that is, the
|
|
20
|
+
* factory ones— even if another is installed afterwards. Without `copy`, the installed ones; a
|
|
21
|
+
* component passes it those of its branch.
|
|
22
|
+
*/
|
|
23
|
+
export declare function writeANote(copy?: UiCopy): MessageKind;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { currentCopy } from "../../foundations/uiCopy.js";
|
|
2
|
+
/**
|
|
3
|
+
* WRITE A NOTE, the way every list has.
|
|
4
|
+
*
|
|
5
|
+
* It is a function and not a constant because its words come from the copy, and a
|
|
6
|
+
* constant would freeze them with whatever there was when the module loaded —that is, the
|
|
7
|
+
* factory ones— even if another is installed afterwards. Without `copy`, the installed ones; a
|
|
8
|
+
* component passes it those of its branch.
|
|
9
|
+
*/
|
|
10
|
+
export function writeANote(copy = currentCopy()) {
|
|
11
|
+
return {
|
|
12
|
+
id: "note",
|
|
13
|
+
label: copy.activity.writeNote,
|
|
14
|
+
internal: true,
|
|
15
|
+
placeholder: copy.activity.notePlaceholder,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type UiCopy } from "../../foundations/
|
|
1
|
+
import { type UiCopy } from "../../foundations/uiCopy.js";
|
|
2
2
|
import type { ToastSpec } from "../../primitives/notice/Toast.js";
|
|
3
3
|
import { type LucideIcon } from "lucide-react";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fillCopy } from "../../foundations/
|
|
1
|
+
import { fillCopy } from "../../foundations/uiCopy.js";
|
|
2
2
|
import { Bot } from "lucide-react";
|
|
3
3
|
/* ==================================================================== *
|
|
4
4
|
* THE ASSISTANT'S CONTRACT — what every piece of this family agrees on.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type AttachmentFile } from "./files.js";
|
|
2
|
+
export type FileValueProps = {
|
|
3
|
+
/** The file — nothing at all when there is none. */
|
|
4
|
+
file: AttachmentFile | null | undefined;
|
|
5
|
+
/** `sm` (default): a table's line. `md`: a record's field, with its type and size. */
|
|
6
|
+
size?: "sm" | "md";
|
|
7
|
+
/** Download by code. Present = the name is a button that calls it, busy while it runs. */
|
|
8
|
+
onDownload?: (file: AttachmentFile) => void | Promise<unknown>;
|
|
9
|
+
};
|
|
10
|
+
export declare function FileValue({ file, size, onDownload }: FileValueProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { attachmentKind, fileExtension, formatFileSize, } from "./files.js";
|
|
4
|
+
import { FileThumb } from "./FileThumb.js";
|
|
5
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
/* A row opens its record on a click; downloading its file must not ALSO open it. */
|
|
8
|
+
const stay = (event) => event.stopPropagation();
|
|
9
|
+
/* The ring every name shares, as a button or as a link — `FileList`'s. */
|
|
10
|
+
const NAME = "min-w-0 cursor-pointer truncate rounded-control text-left font-medium text-ink outline-primary outline-offset-2 hover:underline hover:underline-offset-4 focus-visible:outline-2 forced-colors:outline-[Highlight] aria-busy:cursor-progress aria-busy:opacity-70";
|
|
11
|
+
export function FileValue({ file, size = "sm", onDownload }) {
|
|
12
|
+
const copy = useUiCopy();
|
|
13
|
+
const [busy, setBusy] = useState(false);
|
|
14
|
+
if (file === null || file === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
const kind = attachmentKind(file.name, file.type);
|
|
17
|
+
const picture = kind === "image" ? (file.thumbnail ?? file.url) : undefined;
|
|
18
|
+
const download = async () => {
|
|
19
|
+
if (onDownload === undefined || busy)
|
|
20
|
+
return;
|
|
21
|
+
setBusy(true);
|
|
22
|
+
try {
|
|
23
|
+
await onDownload(file);
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
setBusy(false);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const name = onDownload !== undefined ? (_jsx("button", { type: "button", title: file.name, "aria-busy": busy || undefined, onClick: (event) => {
|
|
30
|
+
stay(event);
|
|
31
|
+
void download();
|
|
32
|
+
}, className: NAME, children: file.name })) : file.url !== undefined ? (_jsx("a", { href: file.url, download: file.name, title: file.name, onClick: stay, className: NAME, children: file.name })) : (_jsx("span", { title: file.name, className: "min-w-0 truncate font-medium text-ink", children: file.name }));
|
|
33
|
+
if (size === "md") {
|
|
34
|
+
const extension = fileExtension(file.name).toUpperCase();
|
|
35
|
+
return (_jsxs("span", { "data-ui": "file-value", "data-size": "md", className: "flex max-w-full min-w-0 items-center gap-3", children: [_jsx(FileThumb, { file: file, kind: kind, size: "md" }), _jsxs("span", { className: "flex min-w-0 flex-col gap-0.5 text-meta", children: [name, _jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 text-micro text-muted tabular-nums", children: [extension === "" ? null : _jsx("span", { children: extension }), extension !== "" && file.size !== undefined ? _jsx("span", { "aria-hidden": true, children: "\u00B7" }) : null, file.size === undefined ? null : (_jsx("span", { className: "whitespace-nowrap", children: formatFileSize(file.size, copy.locale) }))] })] })] }));
|
|
36
|
+
}
|
|
37
|
+
return (_jsxs("span", { "data-ui": "file-value", "data-size": "sm", className: "inline-flex max-w-full min-w-0 items-center gap-2 align-middle", children: [picture === undefined ? (_jsx(FileThumb, { file: file, kind: kind, size: "sm" })) : (
|
|
38
|
+
/* Decorative: the name beside it says which file it is. */
|
|
39
|
+
_jsx("img", { src: picture, alt: "", loading: "lazy", className: "size-(--size-control-sm) shrink-0 rounded-control border border-line object-cover" })), name] }));
|
|
40
|
+
}
|
|
@@ -2,3 +2,4 @@ export { Attachments, type AttachmentsProps, } from "./Attachments.js";
|
|
|
2
2
|
export { downloadFile } from "./download.js";
|
|
3
3
|
export { FileList, type FileListLayout, type FileListProps, } from "./FileList.js";
|
|
4
4
|
export { type AttachmentFile, type AttachmentKind, attachmentKind, type AttachmentStatus, fileExtension, formatFileSize, } from "./files.js";
|
|
5
|
+
export { FileValue, type FileValueProps, } from "./FileValue.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* ATTACHMENTS — the files of a record (`Attachments`: add, remove, undo), files shown inside a
|
|
2
|
-
message, a card or a section (`FileList`),
|
|
2
|
+
message, a card or a section (`FileList`), one file as a value (`FileValue`), and how to save
|
|
3
|
+
one fetched by code. */
|
|
3
4
|
export { Attachments, } from "./Attachments.js";
|
|
4
5
|
export { downloadFile } from "./download.js";
|
|
5
6
|
export { FileList, } from "./FileList.js";
|
|
6
7
|
export { attachmentKind, fileExtension, formatFileSize, } from "./files.js";
|
|
8
|
+
export { FileValue, } from "./FileValue.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Guide, type GuideCloseReason, type GuideProps, type GuideStep, } from "./Guide.js";
|
|
2
2
|
export { GuideSpot } from "./GuideSpot.js";
|
|
3
3
|
export { type Box as GuideBox, type CardPlacement as GuideCardPlacement, type GuideSide, type Size as GuideSize, placeCard, } from "./place.js";
|
|
4
|
-
export {
|
|
4
|
+
export { type GuideTarget, selectorOf } from "./selector.js";
|
|
5
|
+
export { boxOf, findTarget, type Found as GuideMatch, } from "./target.js";
|
|
@@ -3,4 +3,5 @@ export { Guide, } from "./Guide.js";
|
|
|
3
3
|
export { GuideSpot } from "./GuideSpot.js";
|
|
4
4
|
/* The rules underneath, for an application that draws a tour of its own. */
|
|
5
5
|
export { placeCard, } from "./place.js";
|
|
6
|
-
export {
|
|
6
|
+
export { selectorOf } from "./selector.js";
|
|
7
|
+
export { boxOf, findTarget, } from "./target.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a step of a tour points at.
|
|
3
|
+
*
|
|
4
|
+
* Context: the anchors are the ones the system already keeps stable, so no component needs a
|
|
5
|
+
* prop to be pointed at:
|
|
6
|
+
*
|
|
7
|
+
* - `{ part }` — a web-ui part (`data-ui`, listed in the README and guarded by a test):
|
|
8
|
+
* `{ part: "sidebar.search" }`. With `key`, one item of a collection:
|
|
9
|
+
* `{ part: "navigation.item", key: "socios.cuotas" }`.
|
|
10
|
+
* - `{ spot }` — anything the application marked: `<GuideSpot id="cifras">` or its own
|
|
11
|
+
* element with `data-guide="cifras"`.
|
|
12
|
+
* - `{ selector }` — any CSS selector, for what has no name yet.
|
|
13
|
+
* - a function — a ref, or whatever the application computes at that moment.
|
|
14
|
+
*/
|
|
15
|
+
export type GuideTarget = {
|
|
16
|
+
part: string;
|
|
17
|
+
key?: string;
|
|
18
|
+
} | {
|
|
19
|
+
spot: string;
|
|
20
|
+
} | {
|
|
21
|
+
selector: string;
|
|
22
|
+
} | (() => Element | null | undefined);
|
|
23
|
+
/** The CSS selector a target names; `null` for a function. */
|
|
24
|
+
export declare function selectorOf(target: Exclude<GuideTarget, () => unknown>): string;
|
|
25
|
+
export declare function selectorOf(target: GuideTarget): string | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* A quoted attribute value: only `"` and `\` need escaping there — and unlike `CSS.escape`
|
|
2
|
+
this also runs where there is no DOM (a test, a server). */
|
|
3
|
+
const quoted = (value) => `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
4
|
+
export function selectorOf(target) {
|
|
5
|
+
if (typeof target === "function")
|
|
6
|
+
return null;
|
|
7
|
+
if ("part" in target) {
|
|
8
|
+
const part = `[data-ui=${quoted(target.part)}]`;
|
|
9
|
+
return target.key === undefined ? part : `${part}[data-key=${quoted(target.key)}]`;
|
|
10
|
+
}
|
|
11
|
+
if ("spot" in target)
|
|
12
|
+
return `[data-guide=${quoted(target.spot)}]`;
|
|
13
|
+
return target.selector;
|
|
14
|
+
}
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import type { Box } from "./place.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Context: the anchors are the ones the system already keeps stable, so no component needs a
|
|
6
|
-
* prop to be pointed at:
|
|
7
|
-
*
|
|
8
|
-
* - `{ part }` — a web-ui part (`data-ui`, listed in the README and guarded by a test):
|
|
9
|
-
* `{ part: "sidebar.search" }`. With `key`, one item of a collection:
|
|
10
|
-
* `{ part: "navigation.item", key: "socios.cuotas" }`.
|
|
11
|
-
* - `{ spot }` — anything the application marked: `<GuideSpot id="cifras">` or its own
|
|
12
|
-
* element with `data-guide="cifras"`.
|
|
13
|
-
* - `{ selector }` — any CSS selector, for what has no name yet.
|
|
14
|
-
* - a function — a ref, or whatever the application computes at that moment.
|
|
15
|
-
*/
|
|
16
|
-
export type GuideTarget = {
|
|
17
|
-
part: string;
|
|
18
|
-
key?: string;
|
|
19
|
-
} | {
|
|
20
|
-
spot: string;
|
|
21
|
-
} | {
|
|
22
|
-
selector: string;
|
|
23
|
-
} | (() => Element | null | undefined);
|
|
24
|
-
/** The CSS selector a target names; `null` for a function. */
|
|
25
|
-
export declare function selectorOf(target: Exclude<GuideTarget, () => unknown>): string;
|
|
26
|
-
export declare function selectorOf(target: GuideTarget): string | null;
|
|
2
|
+
import { type GuideTarget, selectorOf } from "./selector.js";
|
|
3
|
+
export type { GuideTarget };
|
|
4
|
+
export { selectorOf };
|
|
27
5
|
/** The element's box on screen, `null` when it has none — hidden, or not laid out. A
|
|
28
6
|
* `GuideSpot` measures as the union of what it wraps. */
|
|
29
7
|
export declare function boxOf(element: Element): Box | null;
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const quoted = (value) => `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
5
|
-
export function selectorOf(target) {
|
|
6
|
-
if (typeof target === "function")
|
|
7
|
-
return null;
|
|
8
|
-
if ("part" in target) {
|
|
9
|
-
const part = `[data-ui=${quoted(target.part)}]`;
|
|
10
|
-
return target.key === undefined ? part : `${part}[data-key=${quoted(target.key)}]`;
|
|
11
|
-
}
|
|
12
|
-
if ("spot" in target)
|
|
13
|
-
return `[data-guide=${quoted(target.spot)}]`;
|
|
14
|
-
return target.selector;
|
|
15
|
-
}
|
|
2
|
+
import { selectorOf } from "./selector.js";
|
|
3
|
+
export { selectorOf };
|
|
16
4
|
/** `display: contents` has no box of its own (a `GuideSpot`): its box is its children's. */
|
|
17
5
|
function wraps(element) {
|
|
18
6
|
return getComputedStyle(element).display === "contents";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { levelId, levelLabeler, namer } from "./levels.js";
|
|
1
2
|
import type { GroupableField, GroupLevel } from "../../foundations/grouping.js";
|
|
2
3
|
/**
|
|
3
4
|
* The levels of ONE axis, chosen on the screen: a tag per level with its ×, and «+» to add
|
|
@@ -6,11 +7,7 @@ import type { GroupableField, GroupLevel } from "../../foundations/grouping.js";
|
|
|
6
7
|
* Context: the pivot had it written inline, and the chart asks the same question twice
|
|
7
8
|
* (its axis and its series). Two copies would drift; this is the one both draw.
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
-
/** How a level is named: the field's label, and its grain when it is a date. */
|
|
11
|
-
export declare function levelLabeler(fields: readonly GroupableField[]): (level: GroupLevel) => string;
|
|
12
|
-
/** `fields` name what they list; anything else is named by `fallback`, then by its id. */
|
|
13
|
-
export declare function namer(fields: readonly GroupableField[], fallback?: (level: GroupLevel) => string): (level: GroupLevel) => string;
|
|
10
|
+
export { levelId, levelLabeler, namer };
|
|
14
11
|
export declare function AxisLevels({ name, levels, onChange, fields, used, labelOf: outerLabel, }: {
|
|
15
12
|
name: string;
|
|
16
13
|
levels: readonly GroupLevel[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { fromId, levelId, levelLabeler, namer, } from "./levels.js";
|
|
4
4
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
5
5
|
import { Menu } from "../../primitives/menu/Menu.js";
|
|
6
6
|
import { Tags } from "../../primitives/tag/Tags.js";
|
|
@@ -12,27 +12,10 @@ import { Plus } from "lucide-react";
|
|
|
12
12
|
* Context: the pivot had it written inline, and the chart asks the same question twice
|
|
13
13
|
* (its axis and its series). Two copies would drift; this is the one both draw.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
/** How a level is named: the field's label, and its grain when it is a date. */
|
|
21
|
-
export function levelLabeler(fields) {
|
|
22
|
-
return (level) => {
|
|
23
|
-
const field = fields.find((one) => one.field === level.field)?.label ?? level.field;
|
|
24
|
-
return level.grain === undefined
|
|
25
|
-
? field
|
|
26
|
-
: `${field} · ${grainName(level.grain).toLowerCase()}`;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/** `fields` name what they list; anything else is named by `fallback`, then by its id. */
|
|
30
|
-
export function namer(fields, fallback) {
|
|
31
|
-
const named = levelLabeler(fields);
|
|
32
|
-
return (level) => fallback !== undefined && !fields.some((one) => one.field === level.field)
|
|
33
|
-
? fallback(level)
|
|
34
|
-
: named(level);
|
|
35
|
-
}
|
|
15
|
+
/* `levelId`, `levelLabeler` and `namer` are plain (`levels.ts`), without the directive, so a
|
|
16
|
+
server component names a level the same way; re-exported so every path that read them here
|
|
17
|
+
keeps reading them. */
|
|
18
|
+
export { levelId, levelLabeler, namer };
|
|
36
19
|
export function AxisLevels({ name, levels, onChange, fields, used, labelOf: outerLabel, }) {
|
|
37
20
|
const words = useUiCopy().pivot;
|
|
38
21
|
const labelOf = namer(fields, outerLabel);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ColumnControl
|
|
1
|
+
import type { ColumnControl } from "./columns.js";
|
|
2
|
+
import { specsFromColumns } from "./columnSpecs.js";
|
|
2
3
|
import { type PathPick } from "../search/FieldPath.js";
|
|
3
4
|
import type { Surface } from "../../foundations/types.js";
|
|
4
5
|
/**
|
|
@@ -18,9 +19,4 @@ export declare function ColumnsMenu({ control, surface, addPath, }: {
|
|
|
18
19
|
surface?: Surface;
|
|
19
20
|
addPath?: PathPick;
|
|
20
21
|
}): import("react").JSX.Element | null;
|
|
21
|
-
export
|
|
22
|
-
id: string;
|
|
23
|
-
header: string;
|
|
24
|
-
optional?: boolean;
|
|
25
|
-
defaultHidden?: boolean;
|
|
26
|
-
}[], fallbackOptional: boolean): ColumnSpec[];
|
|
22
|
+
export { specsFromColumns };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { specsFromColumns } from "./columnSpecs.js";
|
|
3
4
|
import { FieldPath } from "../search/FieldPath.js";
|
|
4
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
6
|
import { Menu } from "../../primitives/menu/Menu.js";
|
|
@@ -47,11 +48,6 @@ export function ColumnsMenu({ control, surface, addPath, }) {
|
|
|
47
48
|
const menu = (_jsx(Menu, { label: copy.frame.columns, icon: Columns3, groups: groups, onSelect: control.toggle, closeOnSelect: false, active: hiddenOptional, ...(surface === undefined ? {} : { surface }), size: "sm" }));
|
|
48
49
|
return picker === null ? (menu) : (_jsxs("span", { className: "flex items-center gap-1.5", children: [menu, picker] }));
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
label: column.header,
|
|
54
|
-
optional: column.optional ?? fallbackOptional,
|
|
55
|
-
...(column.defaultHidden === true ? { defaultHidden: true } : {}),
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
51
|
+
/* `specsFromColumns` is plain (`columnSpecs.ts`), without the directive; re-exported so every
|
|
52
|
+
path that read it here keeps reading it. */
|
|
53
|
+
export { specsFromColumns };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* Without `"use client"`, apart from `useTreeControl` (`tree.ts`): the closed branches of a set
|
|
2
|
+
are a list of pile paths, and opening or closing one is a plain function. */
|
|
3
|
+
/** `key` opened if it was closed, closed if it was open. */
|
|
4
|
+
export function toggleCollapsed(collapsed, key) {
|
|
5
|
+
return collapsed.includes(key)
|
|
6
|
+
? collapsed.filter((one) => one !== key)
|
|
7
|
+
: [...collapsed, key];
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which columns of a set are on screen, as plain rules: the spec (required or optional,
|
|
3
|
+
* hidden at first), the default set, a toggle, the set reconciled. `useColumnControl`
|
|
4
|
+
* (`columns.ts`) keeps them in state; these live apart and without `"use client"`, so a server
|
|
5
|
+
* component — the page that reads the person's columns from a cookie — computes the same set.
|
|
6
|
+
*/
|
|
7
|
+
export type ColumnSpec = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
/** When true, the column may leave the view. Required columns stay, and
|
|
11
|
+
* the submenu shows them checked and disabled so the split is visible. */
|
|
12
|
+
optional?: boolean;
|
|
13
|
+
/** Odoo `optional="hide"`: start off. Only for optional columns. */
|
|
14
|
+
defaultHidden?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function isRequiredColumn(column: ColumnSpec): boolean;
|
|
17
|
+
export declare function defaultVisibleIds(columns: readonly ColumnSpec[]): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Required columns always stay. Unknown ids drop out. If everything optional
|
|
20
|
+
* was unchecked, the first column remains — a table with zero columns is not
|
|
21
|
+
* a table.
|
|
22
|
+
*/
|
|
23
|
+
export declare function reconcileVisible(columns: readonly ColumnSpec[], visibleIds: readonly string[]): string[];
|
|
24
|
+
export declare function toggleColumn(columns: readonly ColumnSpec[], visibleIds: readonly string[], id: string): string[];
|
|
25
|
+
export declare function visibleColumns<T extends {
|
|
26
|
+
id: string;
|
|
27
|
+
}>(columns: readonly T[], visibleIds: readonly string[]): T[];
|
|
28
|
+
/** A table's columns as specs: `header` is the label, `optional` falls back to the table's. */
|
|
29
|
+
export declare function specsFromColumns(columns: readonly {
|
|
30
|
+
id: string;
|
|
31
|
+
header: string;
|
|
32
|
+
optional?: boolean;
|
|
33
|
+
defaultHidden?: boolean;
|
|
34
|
+
}[], fallbackOptional: boolean): ColumnSpec[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which columns of a set are on screen, as plain rules: the spec (required or optional,
|
|
3
|
+
* hidden at first), the default set, a toggle, the set reconciled. `useColumnControl`
|
|
4
|
+
* (`columns.ts`) keeps them in state; these live apart and without `"use client"`, so a server
|
|
5
|
+
* component — the page that reads the person's columns from a cookie — computes the same set.
|
|
6
|
+
*/
|
|
7
|
+
export function isRequiredColumn(column) {
|
|
8
|
+
return column.optional !== true;
|
|
9
|
+
}
|
|
10
|
+
export function defaultVisibleIds(columns) {
|
|
11
|
+
return columns
|
|
12
|
+
.filter((column) => isRequiredColumn(column) || column.defaultHidden !== true)
|
|
13
|
+
.map((column) => column.id);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Required columns always stay. Unknown ids drop out. If everything optional
|
|
17
|
+
* was unchecked, the first column remains — a table with zero columns is not
|
|
18
|
+
* a table.
|
|
19
|
+
*/
|
|
20
|
+
export function reconcileVisible(columns, visibleIds) {
|
|
21
|
+
if (columns.length === 0)
|
|
22
|
+
return [];
|
|
23
|
+
const known = new Set(columns.map((column) => column.id));
|
|
24
|
+
const visible = new Set(visibleIds.filter((id) => known.has(id)));
|
|
25
|
+
for (const column of columns) {
|
|
26
|
+
if (isRequiredColumn(column))
|
|
27
|
+
visible.add(column.id);
|
|
28
|
+
}
|
|
29
|
+
if (visible.size === 0)
|
|
30
|
+
visible.add(columns[0].id);
|
|
31
|
+
return columns.filter((column) => visible.has(column.id)).map((column) => column.id);
|
|
32
|
+
}
|
|
33
|
+
export function toggleColumn(columns, visibleIds, id) {
|
|
34
|
+
const column = columns.find((one) => one.id === id);
|
|
35
|
+
if (column === undefined || isRequiredColumn(column)) {
|
|
36
|
+
return reconcileVisible(columns, visibleIds);
|
|
37
|
+
}
|
|
38
|
+
const current = reconcileVisible(columns, visibleIds);
|
|
39
|
+
const next = current.includes(id) ? current.filter((one) => one !== id) : [...current, id];
|
|
40
|
+
return reconcileVisible(columns, next);
|
|
41
|
+
}
|
|
42
|
+
export function visibleColumns(columns, visibleIds) {
|
|
43
|
+
const wanted = new Set(visibleIds);
|
|
44
|
+
return columns.filter((column) => wanted.has(column.id));
|
|
45
|
+
}
|
|
46
|
+
/** A table's columns as specs: `header` is the label, `optional` falls back to the table's. */
|
|
47
|
+
export function specsFromColumns(columns, fallbackOptional) {
|
|
48
|
+
return columns.map((column) => ({
|
|
49
|
+
id: column.id,
|
|
50
|
+
label: column.header,
|
|
51
|
+
optional: column.optional ?? fallbackOptional,
|
|
52
|
+
...(column.defaultHidden === true ? { defaultHidden: true } : {}),
|
|
53
|
+
}));
|
|
54
|
+
}
|