@sincpro/web-ui 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/activity/Activity.d.ts +13 -14
- package/dist/components/activity/Activity.js +1 -1
- package/dist/components/activity/Messages.d.ts +5 -5
- package/dist/components/activity/Messages.js +8 -8
- package/dist/components/form/Form.js +6 -6
- package/dist/components/form/index.js +2 -2
- package/dist/components/frame/FrameView.d.ts +5 -5
- package/dist/components/frame/FrameView.js +4 -4
- package/dist/components/listing/GroupingLevels.d.ts +22 -22
- package/dist/components/listing/GroupingLevels.js +9 -9
- package/dist/components/listing/Listing.d.ts +11 -11
- package/dist/components/listing/Listing.js +11 -11
- package/dist/components/listing/ListingBar.js +11 -11
- package/dist/components/listing/Row.d.ts +19 -19
- package/dist/components/listing/Row.js +25 -25
- package/dist/components/listing/SortMenu.d.ts +36 -36
- package/dist/components/listing/SortMenu.js +6 -6
- package/dist/components/listing/grouping.d.ts +16 -16
- package/dist/components/listing/grouping.js +6 -6
- package/dist/components/listing/index.js +1 -1
- package/dist/components/listing/modelColumns.d.ts +25 -25
- package/dist/components/listing/modelColumns.js +24 -24
- package/dist/components/listing/pages.js +4 -4
- package/dist/components/listing/set.d.ts +18 -18
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +22 -22
- package/dist/components/search/CriteriaBuilder.js +31 -31
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +12 -12
- package/dist/components/search/FilterBuilder.d.ts +67 -67
- package/dist/components/search/FilterBuilder.js +104 -104
- package/dist/components/search/JoinWord.d.ts +1 -1
- package/dist/components/search/JoinWord.js +14 -14
- package/dist/components/search/JsonEditor.d.ts +8 -8
- package/dist/components/search/JsonEditor.js +16 -16
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +110 -110
- package/dist/components/search/criteria.d.ts +61 -61
- package/dist/components/search/criteria.js +39 -39
- package/dist/components/search/datePeriods.d.ts +47 -48
- package/dist/components/search/datePeriods.js +29 -29
- package/dist/components/search/dateRanges.d.ts +27 -27
- package/dist/components/search/dateRanges.js +16 -16
- package/dist/components/search/index.js +13 -13
- package/dist/components/search/model.d.ts +28 -28
- package/dist/components/search/model.js +21 -21
- package/dist/components/search/query.d.ts +71 -71
- package/dist/components/search/query.js +119 -119
- package/dist/components/shell/AppFrame.js +3 -3
- package/dist/components/shell/index.js +1 -1
- package/dist/foundations/calendar.d.ts +27 -27
- package/dist/foundations/calendar.js +72 -72
- package/dist/foundations/chart.d.ts +57 -57
- package/dist/foundations/chart.js +27 -27
- package/dist/foundations/copy.d.ts +96 -94
- package/dist/foundations/copy.es.js +1 -0
- package/dist/foundations/copy.js +1 -0
- package/dist/foundations/grouping.d.ts +175 -175
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +21 -21
- package/dist/foundations/pivot.d.ts +133 -131
- package/dist/foundations/pivot.js +54 -54
- package/dist/foundations/pivotSheet.d.ts +36 -36
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/slots.d.ts +38 -38
- package/dist/foundations/slots.js +18 -18
- package/dist/foundations/sticky.d.ts +28 -28
- package/dist/foundations/sticky.js +59 -59
- package/dist/foundations/xlsx.d.ts +47 -47
- package/dist/foundations/xlsx.js +0 -0
- package/dist/primitives/block/Line.d.ts +4 -4
- package/dist/primitives/block/Line.js +28 -28
- package/dist/primitives/block/index.js +2 -2
- package/dist/primitives/cell/index.js +2 -2
- package/dist/primitives/choice/index.js +3 -3
- package/dist/primitives/date/Calendar.d.ts +7 -1
- package/dist/primitives/date/Calendar.js +13 -3
- package/dist/primitives/date/DatePicker.d.ts +4 -1
- package/dist/primitives/date/DatePicker.js +2 -2
- package/dist/primitives/date/index.js +3 -3
- package/dist/primitives/disclosure/index.js +1 -1
- package/dist/primitives/menu/Menu.d.ts +3 -3
- package/dist/primitives/notice/Callout.d.ts +30 -30
- package/dist/primitives/notice/Callout.js +6 -6
- package/dist/primitives/overlay/index.js +3 -3
- package/dist/primitives/picker/Picker.d.ts +6 -0
- package/dist/primitives/picker/Picker.js +27 -4
- package/dist/primitives/picker/index.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +32 -32
- package/dist/primitives/table/DataTable.js +24 -24
- package/dist/primitives/table/EditableTable.d.ts +10 -10
- package/dist/primitives/table/EditableTable.js +9 -9
- package/dist/primitives/table/ReportTable.js +7 -7
- package/dist/primitives/table/SheetTable.d.ts +13 -13
- package/dist/primitives/table/SheetTable.js +14 -14
- package/dist/primitives/table/Table.js +8 -8
- package/dist/primitives/tabs/Tabs.d.ts +46 -46
- package/dist/primitives/tabs/Tabs.js +7 -7
- package/dist/primitives/tag/index.js +2 -2
- package/dist/primitives/toolbar/index.js +1 -1
- package/dist/primitives/value/Copyable.d.ts +22 -22
- package/dist/primitives/value/Copyable.js +9 -9
- package/dist/tokens.css +17 -17
- package/dist/views/list/List.d.ts +36 -36
- package/dist/views/list/List.js +19 -19
- package/dist/views/list/ListView.js +74 -74
- package/dist/views/list/columns.d.ts +10 -10
- package/dist/views/list/columns.js +10 -10
- package/dist/views/list/derive.d.ts +30 -30
- package/dist/views/list/derive.js +49 -49
- package/dist/views/list/index.js +2 -2
- package/dist/views/list/presentations.js +3 -3
- package/dist/views/list/types.d.ts +109 -109
- package/dist/views/record/Record.d.ts +14 -14
- package/dist/views/record/Record.js +24 -24
- package/dist/views/record/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
/* ==================================================================== *
|
|
4
|
-
*
|
|
4
|
+
* THE STACK OF STICKY THINGS
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Three bands stay at the top while a long view is scrolled, and each
|
|
7
|
+
* one has to sit BELOW the previous one:
|
|
8
8
|
*
|
|
9
9
|
* ┌─ TopNav ─────────────────────────────────┐ top: 0
|
|
10
|
-
* ├─
|
|
10
|
+
* ├─ list bar ───────────────────────────────┤ top: height of the TopNav
|
|
11
11
|
* │ 🔍 buscar… ⚙3 1–80 / 187 ‹ › │
|
|
12
|
-
* ├─
|
|
12
|
+
* ├─ table header ───────────────────────────┤ top: the two above
|
|
13
13
|
* │ número │ cliente │ fecha │ total │
|
|
14
14
|
* ├──────────────────────────────────────────┤
|
|
15
|
-
* │ …
|
|
15
|
+
* │ …the rows, which do scroll away… │
|
|
16
16
|
*
|
|
17
|
-
* **
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* **None of the three has a fixed height.** The `TopNav` grows when it wraps;
|
|
18
|
+
* the list bar has two lines, or one when compact, or three when
|
|
19
|
+
* the search chips wrap. A hand-written `top-[52px]` is right in
|
|
20
|
+
* one window and leaves a gap or an overlap in the others — and it is the kind
|
|
21
|
+
* of number nobody touches again when the bar changes.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* That is why each band MEASURES what it takes and adds it to `--sticky-top` for whatever
|
|
24
|
+
* comes below. The variable cascades, so each layer reads the one above without
|
|
25
|
+
* any of them knowing how many layers there are.
|
|
26
26
|
*
|
|
27
|
-
* ──
|
|
27
|
+
* ── The rule for whoever opens a box with its own scroll ────────────
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Inside a box with a height and `overflow`, it is the box that scrolls and not
|
|
30
|
+
* the page, so what is sticky sticks to the box's edge: there the stack
|
|
31
|
+
* starts from zero again. That is `stickyReset()`.
|
|
32
32
|
* ==================================================================== */
|
|
33
|
-
/**
|
|
33
|
+
/** The variable that says at what height the next thing to stick starts. */
|
|
34
34
|
export const STICKY_TOP = "--sticky-top";
|
|
35
|
-
/**
|
|
35
|
+
/** What goes in the `style` of something sticky: it sticks below what is already there. */
|
|
36
36
|
export const stickyTop = { top: `var(${STICKY_TOP}, 0px)` };
|
|
37
|
-
/**
|
|
37
|
+
/** For a box with its own scroll: inside, the stack starts from zero. */
|
|
38
38
|
export function stickyReset() {
|
|
39
39
|
return { [STICKY_TOP]: "0px" };
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* A TABLE'S BOX: when it has to be a scroll container and when not.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* `overflow-x: auto` **
|
|
47
|
-
* `visible`
|
|
48
|
-
*
|
|
49
|
-
*
|
|
44
|
+
* The system's three tables have the same dilemma and used to solve it with three
|
|
45
|
+
* copies of the same measurement. The dilemma is CSS's and cannot be dodged:
|
|
46
|
+
* `overflow-x: auto` **forces** `overflow-y: auto` —the specification says that
|
|
47
|
+
* `visible` next to a value that is neither `visible` nor `clip` computes to `auto`—,
|
|
48
|
+
* so as soon as the box allows horizontal scroll it becomes the scroller, and
|
|
49
|
+
* the sticky header sticks to ITS edge instead of the page's.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
51
|
+
* From there come the three cases, and they are the only ones:
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
53
|
+
* own height the box really scrolls. `auto`, and the stack of sticky
|
|
54
|
+
* things starts from zero inside.
|
|
55
|
+
* no height, fits no box is needed. `clip` —trims the rounded corners
|
|
56
|
+
* without being a scroller— and the header sticks
|
|
57
|
+
* to the page, below the list bar.
|
|
58
|
+
* no height, does not fit horizontal scroll comes back, and the header goes
|
|
59
|
+
* away with the rows. It is the price, and it is what there is.
|
|
60
60
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* Returns the class and the style already resolved so that no table has to
|
|
62
|
+
* decide it on its own again.
|
|
63
63
|
*/
|
|
64
64
|
export function useScrollBox(options) {
|
|
65
65
|
const ref = useRef(null);
|
|
@@ -69,11 +69,11 @@ export function useScrollBox(options) {
|
|
|
69
69
|
const node = ref.current;
|
|
70
70
|
if (node === null || !crece)
|
|
71
71
|
return;
|
|
72
|
-
/*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
/* The CONTENT is measured and not the box, and that is the difference between this
|
|
73
|
+
working and getting stuck: with `overflow: clip` the box stops being a
|
|
74
|
+
scroll container, so its `scrollWidth` becomes its own width
|
|
75
|
+
and would never report overflow again. Once clipped, it would stay
|
|
76
|
+
clipped forever. The child does know how wide it really is. */
|
|
77
77
|
const dentro = node.firstElementChild;
|
|
78
78
|
const medir = () => {
|
|
79
79
|
const ancho = dentro === null ? node.scrollWidth : dentro.getBoundingClientRect().width;
|
|
@@ -84,8 +84,8 @@ export function useScrollBox(options) {
|
|
|
84
84
|
return;
|
|
85
85
|
const observer = new ResizeObserver(medir);
|
|
86
86
|
observer.observe(node);
|
|
87
|
-
/*
|
|
88
|
-
|
|
87
|
+
/* The content too: the columns change width without the box
|
|
88
|
+
changing size. */
|
|
89
89
|
if (dentro !== null)
|
|
90
90
|
observer.observe(dentro);
|
|
91
91
|
return () => observer.disconnect();
|
|
@@ -104,12 +104,12 @@ export function useScrollBox(options) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* Measures an element's height and returns the style that pushes the stack for its
|
|
108
|
+
* siblings below.
|
|
109
109
|
*
|
|
110
|
-
* `useLayoutEffect`
|
|
111
|
-
*
|
|
112
|
-
*
|
|
110
|
+
* `useLayoutEffect` and `ResizeObserver` and not a declared height: the height depends
|
|
111
|
+
* on whether the search chips wrapped, and that is only known after
|
|
112
|
+
* painting.
|
|
113
113
|
*/
|
|
114
114
|
export function useStickyLayer() {
|
|
115
115
|
const ref = useRef(null);
|
|
@@ -118,12 +118,12 @@ export function useStickyLayer() {
|
|
|
118
118
|
const node = ref.current;
|
|
119
119
|
if (node === null)
|
|
120
120
|
return;
|
|
121
|
-
/*
|
|
122
|
-
`calc(var(--sticky-top) + 44px)`. Context:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
/* The value below is computed in JS and written in PIXELS, not as
|
|
122
|
+
`calc(var(--sticky-top) + 44px)`. Context: that form looks natural and
|
|
123
|
+
does not work — setting `--sticky-top` on an element while reading `var(--sticky-top)`
|
|
124
|
+
from the SAME element is a cycle, CSS declares it invalid, and the
|
|
125
|
+
descendants inherit «nothing»: everything stuck at 0 and the bands
|
|
126
|
+
overlapped. It was measured in the browser, not deduced. */
|
|
127
127
|
const measure = () => {
|
|
128
128
|
const inherited = Number.parseFloat(getComputedStyle(node).getPropertyValue(STICKY_TOP));
|
|
129
129
|
const above = Number.isFinite(inherited) ? inherited : 0;
|
|
@@ -134,9 +134,9 @@ export function useStickyLayer() {
|
|
|
134
134
|
return;
|
|
135
135
|
const observer = new ResizeObserver(measure);
|
|
136
136
|
observer.observe(node);
|
|
137
|
-
/*
|
|
138
|
-
—
|
|
139
|
-
|
|
137
|
+
/* The height of a layer ABOVE changes without this observer noticing
|
|
138
|
+
—the `TopNav` wraps when narrowed—, so it is also re-measured when the
|
|
139
|
+
window is resized, which is when that happens. */
|
|
140
140
|
window.addEventListener("resize", measure);
|
|
141
141
|
return () => {
|
|
142
142
|
observer.disconnect();
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WRITING AN EXCEL SPREADSHEET, with no library.
|
|
3
3
|
*
|
|
4
|
-
* ──
|
|
4
|
+
* ── Why there is no dependency ──────────────────────────────────────
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `stored` —
|
|
9
|
-
*
|
|
6
|
+
* An `.xlsx` is a ZIP with six XML files inside, and the ZIP only gets hard
|
|
7
|
+
* when it has to compress. **There is nothing to compress**: the format admits
|
|
8
|
+
* `stored` entries —method 0, the bytes as they are— and Excel opens them all the same. All that
|
|
9
|
+
* is left of the ZIP is a CRC32 and three headers of fixed positions.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* On the other side, the libraries of the trade weigh between half a megabyte and one, bring their
|
|
12
|
+
* own model of workbook, styles and formulas, and this design system is
|
|
13
|
+
* published as source for whoever consumes it to compile — including, some
|
|
14
|
+
* day, a phone. A megabyte of spreadsheet writer inside a package of
|
|
15
|
+
* components is carried by everyone who imports a button.
|
|
16
16
|
*
|
|
17
|
-
* ──
|
|
17
|
+
* ── What it does and what it does not ───────────────────────────────
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* It does what a grid needs in order not to lie on the way out: text and numbers in their
|
|
20
|
+
* real type, merged cells, number format per cell, bold, column
|
|
21
|
+
* width and frozen panes. **An absent cell is not written**, which is how
|
|
22
|
+
* the format says «there is nothing here» — a hole is still a hole
|
|
23
|
+
* inside the file.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* It does no formulas, colors, borders, or multiple sheets. The day one of
|
|
26
|
+
* those is needed it is added here; none changes the shape of what is already there.
|
|
27
27
|
*
|
|
28
|
-
* ──
|
|
28
|
+
* ── Where this ends and the browser begins ──────────────────────────
|
|
29
29
|
*
|
|
30
|
-
* `writeXlsx`
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* `writeXlsx` returns BYTES and not a file: `Uint8Array` exists
|
|
31
|
+
* everywhere, and so the same thing serves to download a file, to send it over the network or
|
|
32
|
+
* to write it in a test. Downloading it is `downloadXlsx`, which is the only
|
|
33
|
+
* function of this file that needs a browser.
|
|
34
34
|
*/
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
/** A cell. The position goes in the cell and not in a matrix because a grid
|
|
36
|
+
* with holes is mostly empty, and a matrix of 288 positions for 40
|
|
37
|
+
* values is a matrix that has to be filled with something. */
|
|
38
38
|
export type XlsxCell = {
|
|
39
|
-
/**
|
|
39
|
+
/** Zero-based, like the indices of everything else. */
|
|
40
40
|
row: number;
|
|
41
41
|
column: number;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
42
|
+
/** A number goes in as a number: without that, Excel receives text and does not sum, which is
|
|
43
|
+
* the first thing somebody tries to do with an exported spreadsheet. */
|
|
44
44
|
value: string | number;
|
|
45
45
|
bold?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
/** The Excel format code —`#,##0.00`, `0.0%`, `#,##0 "Bs."`—, which is
|
|
47
|
+
* something other than a JavaScript function: a file cannot carry a
|
|
48
|
+
* function inside. */
|
|
49
49
|
format?: string;
|
|
50
50
|
};
|
|
51
|
-
/**
|
|
51
|
+
/** A merge: from where, and how many rows and columns it covers. */
|
|
52
52
|
export type XlsxMerge = {
|
|
53
53
|
row: number;
|
|
54
54
|
column: number;
|
|
@@ -56,31 +56,31 @@ export type XlsxMerge = {
|
|
|
56
56
|
columns: number;
|
|
57
57
|
};
|
|
58
58
|
export type XlsxSheet = {
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
/** The name of the tab. Excel forbids `[]:*?/\` and more than 31 characters, and
|
|
60
|
+
* an invalid name does not give an error: it gives a file that does not open. It is trimmed
|
|
61
|
+
* here. */
|
|
62
62
|
name: string;
|
|
63
63
|
cells: readonly XlsxCell[];
|
|
64
64
|
merges?: readonly XlsxMerge[];
|
|
65
|
-
/**
|
|
65
|
+
/** The width of each column, in characters. Missing = the default width. */
|
|
66
66
|
widths?: readonly number[];
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
/** How many rows from the top and columns from the left stay still when
|
|
68
|
+
* scrolling. It is the same as what `sticky` does in the grid, and for the same
|
|
69
|
+
* reason: a number without its label is a loose number. */
|
|
70
70
|
freeze?: {
|
|
71
71
|
rows: number;
|
|
72
72
|
columns: number;
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
-
/**
|
|
75
|
+
/** The name of a column in Excel notation: 0 → A, 25 → Z, 26 → AA. */
|
|
76
76
|
export declare function columnName(index: number): string;
|
|
77
|
-
/**
|
|
77
|
+
/** The bytes of an `.xlsx` with one sheet. */
|
|
78
78
|
export declare function writeXlsx(sheet: XlsxSheet): Uint8Array<ArrayBuffer>;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Download the bytes as a file.
|
|
81
81
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
82
|
+
* It is the only function of this file that needs a browser, and that is why it is
|
|
83
|
+
* separate from `writeXlsx`: what is written and what is downloaded are two things, and
|
|
84
|
+
* on the other side —the server, a phone, a test— the second does not exist.
|
|
85
85
|
*/
|
|
86
86
|
export declare function downloadXlsx(name: string, bytes: Uint8Array): void;
|
package/dist/foundations/xlsx.js
CHANGED
|
Binary file
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
export declare function Line({ start, center, end,
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* What each side ASKS for before the line splits. Both ask for the
|
|
5
|
+
* same —it is what centres the centre— so it is a single value and not two.
|
|
6
6
|
*/
|
|
7
7
|
asks,
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
8
|
+
/** What the centre asks for. `auto` is «whatever it measures»; a search field asks for
|
|
9
|
+
* its maximum width, which is what keeps it from stretching to 700 px. */
|
|
10
10
|
centerAsks, gap, align, }: {
|
|
11
11
|
start?: ReactNode;
|
|
12
12
|
center?: ReactNode;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* ==================================================================== *
|
|
3
|
-
*
|
|
3
|
+
* THE THREE-ZONE LINE — and why the centre is centred against the LINE.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* It is the shape of the product's two bands: the record's —where I
|
|
6
|
+
* come from · what hangs from this · which of eighty I am— and the list's —where
|
|
7
|
+
* I come from · what I am looking for · which page—. Both have the same
|
|
8
|
+
* problem and so they have a single solution.
|
|
9
9
|
*
|
|
10
|
-
* ──
|
|
10
|
+
* ── The problem: the centre was not in the centre ───────────────────
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* With `mx-auto`, or with an `auto 1fr max-content` grid, the centre ends up
|
|
13
|
+
* wherever there is room LEFT OVER. And then a fifty-character name on the
|
|
14
|
+
* left —which in this product is normal— pushes the buttons against the
|
|
15
|
+
* right edge, and the same screen with a short name draws them somewhere
|
|
16
|
+
* else. Two records in a row put their controls in two different places:
|
|
17
|
+
* that is not a centre, it is a remainder.
|
|
18
18
|
*
|
|
19
|
-
* ──
|
|
19
|
+
* ── The rule: both sides ASK for the same thing ─────────────────────
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* The sides ask for the same width and grow evenly, so what is left over is
|
|
22
|
+
* split in two equal halves and the centre falls in the middle of the line, with
|
|
23
|
+
* or without breadcrumbs, with or without a pager. What does not fit in a half is clipped
|
|
24
|
+
* inside its half —that is what `min-w-0` is for— instead of pushing the neighbour.
|
|
25
25
|
*
|
|
26
|
-
* ──
|
|
26
|
+
* ── And it splits by itself ─────────────────────────────────────────
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
28
|
+
* There is no threshold here: no media query, no container query, no branch
|
|
29
|
+
* per density. Each zone declares what it ASKS for and `flex-wrap` decides: in
|
|
30
|
+
* a narrow band the centre no longer fits beside the breadcrumbs and drops whole
|
|
31
|
+
* to the next row, with the pager behind it. It is what a list row does,
|
|
32
|
+
* and for the same reason: a threshold does not know whether the line carries three
|
|
33
|
+
* counters or nine.
|
|
34
34
|
* ==================================================================== */
|
|
35
35
|
export function Line({ start, center, end,
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* What each side ASKS for before the line splits. Both ask for the
|
|
38
|
+
* same —it is what centres the centre— so it is a single value and not two.
|
|
39
39
|
*/
|
|
40
40
|
asks = "var(--container-trail)",
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
41
|
+
/** What the centre asks for. `auto` is «whatever it measures»; a search field asks for
|
|
42
|
+
* its maximum width, which is what keeps it from stretching to 700 px. */
|
|
43
43
|
centerAsks = "auto", gap = "gap-x-4 gap-y-2", align = "items-center", }) {
|
|
44
44
|
return (_jsxs("div", { className: `flex min-w-0 flex-wrap ${align} ${gap}`, children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center", style: { flexBasis: asks }, children: start }), _jsx("div", { className: "flex min-w-0 shrink items-center justify-center", style: { flexBasis: centerAsks, flexGrow: 0 }, children: center }), _jsx("div", { className: "flex min-w-0 flex-1 items-center justify-end", style: { flexBasis: asks }, children: end })] }));
|
|
45
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* The structure of a view: where each section starts and ends. */
|
|
2
2
|
export { Block, Rule, } from "./Block.js";
|
|
3
3
|
export { FullWidth, SectionGrid } from "./SectionGrid.js";
|
|
4
|
-
/*
|
|
5
|
-
|
|
4
|
+
/* The three-zone line: what centres the centre against the LINE and not against
|
|
5
|
+
what is left over. Both bands use it — the record's and the list's. */
|
|
6
6
|
export { Line } from "./Line.js";
|
|
7
7
|
export { Step, Steps, useSteps, } from "./Steps.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
1
|
+
/* THE CELL WIDGETS — what goes inside a cell, a row or a card with hierarchy:
|
|
2
|
+
the main thing in ink, what tells it apart small and quiet, and the photo if there is one. */
|
|
3
3
|
export { CellStack, Thumb } from "./CellStack.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*
|
|
2
|
-
(RadioGroup, SegmentedControl),
|
|
3
|
-
|
|
1
|
+
/* THE CHOICES — pick one of many by typing (ComboBox), one of a few in sight
|
|
2
|
+
(RadioGroup, SegmentedControl), turn on or off (Switch), a value in a range (Slider)
|
|
3
|
+
and search for loose text (SearchField). The value is always plain data. */
|
|
4
4
|
export { ComboBox } from "./ComboBox.js";
|
|
5
5
|
export { KanbanState, } from "./KanbanState.js";
|
|
6
6
|
export {} from "./options.js";
|
|
@@ -7,10 +7,16 @@ export type CalendarProps = {
|
|
|
7
7
|
max?: string;
|
|
8
8
|
/** A day that cannot be chosen — a holiday, a closed day. Receives the ISO date. */
|
|
9
9
|
isUnavailable?: (date: string) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The day it is for the business, as an ISO date: marked as today, and where the calendar
|
|
12
|
+
* opens when nothing is chosen. Without it, the browser's own day — which is another one when
|
|
13
|
+
* the company is in another zone, or past midnight somewhere else.
|
|
14
|
+
*/
|
|
15
|
+
today?: string;
|
|
10
16
|
"aria-label"?: string;
|
|
11
17
|
};
|
|
12
18
|
/** One month, to pick one day. */
|
|
13
|
-
export declare function Calendar({ value, onChange, min, max, isUnavailable, ...rest }: CalendarProps): import("react").JSX.Element;
|
|
19
|
+
export declare function Calendar({ value, onChange, min, max, isUnavailable, today, ...rest }: CalendarProps): import("react").JSX.Element;
|
|
14
20
|
export type RangeCalendarProps = {
|
|
15
21
|
/** The chosen span, as ISO dates. */
|
|
16
22
|
value?: {
|
|
@@ -6,7 +6,8 @@ import { focusRing, tv } from "../../foundations/variants.js";
|
|
|
6
6
|
import { listOptionStyles } from "../field/aria.js";
|
|
7
7
|
import { Popover } from "../overlay/Popover.js";
|
|
8
8
|
import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
|
|
9
|
-
import {
|
|
9
|
+
import { useContext } from "react";
|
|
10
|
+
import { Button as AriaButton, Calendar as AriaCalendar, CalendarCell, CalendarContext, CalendarGrid, CalendarGridBody, CalendarGridHeader, CalendarHeaderCell, CalendarHeading, CalendarMonthPicker, CalendarYearPicker, ListBox, ListBoxItem, RangeCalendar as AriaRangeCalendar, Select as AriaSelect, SelectValue, useLocale, } from "react-aria-components";
|
|
10
11
|
/**
|
|
11
12
|
* The month grid — on its own, or inside the popover of a date picker.
|
|
12
13
|
*
|
|
@@ -84,7 +85,8 @@ function defined(props) {
|
|
|
84
85
|
return Object.fromEntries(Object.entries(props).filter(([, v]) => v !== undefined));
|
|
85
86
|
}
|
|
86
87
|
/** One month, to pick one day. */
|
|
87
|
-
export function Calendar({ value, onChange, min, max, isUnavailable, ...rest }) {
|
|
88
|
+
export function Calendar({ value, onChange, min, max, isUnavailable, today, ...rest }) {
|
|
89
|
+
const inPicker = useContext(CalendarContext) != null;
|
|
88
90
|
const props = defined({
|
|
89
91
|
value: iso(value),
|
|
90
92
|
onChange: onChange === undefined ? undefined : (next) => onChange(next.toString()),
|
|
@@ -93,8 +95,16 @@ export function Calendar({ value, onChange, min, max, isUnavailable, ...rest })
|
|
|
93
95
|
isDateUnavailable: isUnavailable === undefined
|
|
94
96
|
? undefined
|
|
95
97
|
: (date) => isUnavailable(date.toString()),
|
|
98
|
+
// Loose, it opens on the business's today when nothing is chosen. Inside a picker the value
|
|
99
|
+
// comes from React Aria's context, not from `value`: opening on today there would hide the
|
|
100
|
+
// chosen day (the picker opens on it, and on `today` only when empty — its placeholder).
|
|
101
|
+
defaultFocusedValue: inPicker || value ? undefined : (iso(today) ?? undefined),
|
|
96
102
|
});
|
|
97
|
-
return (_jsx(AriaLocale, { children: _jsxs(AriaCalendar, { ...rest, ...props, className: "w-fit", children: [_jsx(Header, { jump: true }), _jsxs(CalendarGrid, { className: "border-separate border-spacing-0.5", children: [_jsx(WeekDays, {}), _jsx(CalendarGridBody, { children: (date) => _jsx(CalendarCell, { date: date, className:
|
|
103
|
+
return (_jsx(AriaLocale, { children: _jsxs(AriaCalendar, { ...rest, ...props, className: "w-fit", children: [_jsx(Header, { jump: true }), _jsxs(CalendarGrid, { className: "border-separate border-spacing-0.5", children: [_jsx(WeekDays, {}), _jsx(CalendarGridBody, { children: (date) => (_jsx(CalendarCell, { date: date, className: (state) => dayCell({
|
|
104
|
+
...state,
|
|
105
|
+
// React Aria's «today» is the browser's; the business's, when it is given.
|
|
106
|
+
isToday: today === undefined ? state.isToday : date.toString() === today,
|
|
107
|
+
}) })) })] })] }) }));
|
|
98
108
|
}
|
|
99
109
|
const rangeDay = tv({
|
|
100
110
|
extend: focusRing,
|
|
@@ -25,9 +25,12 @@ export declare function DateField({ value, onChange, id: ownId, describedBy: own
|
|
|
25
25
|
onChange?: (next: string | null) => void;
|
|
26
26
|
}): import("react").JSX.Element;
|
|
27
27
|
/** A date typed by segments, or picked on a calendar from the button. */
|
|
28
|
-
export declare function DatePicker({ value, onChange, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, disabled, min, max, mode, "aria-label": ariaLabel, }: Shared & {
|
|
28
|
+
export declare function DatePicker({ value, onChange, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, disabled, min, max, mode, today, "aria-label": ariaLabel, }: Shared & {
|
|
29
29
|
value: string | null;
|
|
30
30
|
onChange?: (next: string | null) => void;
|
|
31
|
+
/** The day it is for the business, as an ISO date — what its calendar marks as today
|
|
32
|
+
* (`Calendar today`). Without it, the browser's. */
|
|
33
|
+
today?: string;
|
|
31
34
|
}): import("react").JSX.Element;
|
|
32
35
|
export type DateRangeValue = {
|
|
33
36
|
start: string;
|
|
@@ -74,7 +74,7 @@ export function DateField({ value, onChange, id: ownId, describedBy: ownDescribe
|
|
|
74
74
|
return (_jsx(AriaLocale, { children: _jsx(AriaDateField, { id: id, "aria-labelledby": labelledBy, "aria-label": controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, value: parse(value), onChange: (next) => onChange?.(next === null ? null : next.toString()), minValue: parse(min) ?? undefined, maxValue: parse(max) ?? undefined, isInvalid: invalid, isDisabled: disabled, className: "w-full", children: _jsx(FieldGroup, { children: _jsx(Segments, {}) }) }) }));
|
|
75
75
|
}
|
|
76
76
|
/** A date typed by segments, or picked on a calendar from the button. */
|
|
77
|
-
export function DatePicker({ value, onChange, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, disabled = false, min, max, mode, "aria-label": ariaLabel, }) {
|
|
77
|
+
export function DatePicker({ value, onChange, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, disabled = false, min, max, mode, today, "aria-label": ariaLabel, }) {
|
|
78
78
|
const { id, labelledBy, describedBy, invalid } = useFieldIds({
|
|
79
79
|
id: ownId,
|
|
80
80
|
describedBy: ownDescribedBy,
|
|
@@ -83,7 +83,7 @@ export function DatePicker({ value, onChange, id: ownId, describedBy: ownDescrib
|
|
|
83
83
|
const read = useReadDate();
|
|
84
84
|
if (useFormMode(mode) === "read")
|
|
85
85
|
return _jsx(ReadValue, { value: read(value) });
|
|
86
|
-
return (_jsx(AriaLocale, { children: _jsxs(AriaDatePicker, { id: id, "aria-labelledby": labelledBy, "aria-label": controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, value: parse(value), onChange: (next) => onChange?.(next === null ? null : next.toString()), minValue: parse(min) ?? undefined, maxValue: parse(max) ?? undefined, isInvalid: invalid, isDisabled: disabled, className: "w-full", children: [_jsxs(FieldGroup, { children: [_jsx(Segments, {}), _jsx(FieldButton, { className: "mr-1 ml-auto", children: _jsx(CalendarDays, { "aria-hidden": true, className: "size-(--size-icon-md)", strokeWidth: 2 }) })] }), _jsx(Popover, { placement: "bottom end", children: _jsx(Dialog, { className: "p-3 outline-0", children: _jsx(Calendar, {}) }) })] }) }));
|
|
86
|
+
return (_jsx(AriaLocale, { children: _jsxs(AriaDatePicker, { id: id, "aria-labelledby": labelledBy, "aria-label": controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, value: parse(value), onChange: (next) => onChange?.(next === null ? null : next.toString()), minValue: parse(min) ?? undefined, maxValue: parse(max) ?? undefined, ...(today === undefined ? {} : { placeholderValue: parse(today) ?? undefined }), isInvalid: invalid, isDisabled: disabled, className: "w-full", children: [_jsxs(FieldGroup, { children: [_jsx(Segments, {}), _jsx(FieldButton, { className: "mr-1 ml-auto", children: _jsx(CalendarDays, { "aria-hidden": true, className: "size-(--size-icon-md)", strokeWidth: 2 }) })] }), _jsx(Popover, { placement: "bottom end", children: _jsx(Dialog, { className: "p-3 outline-0", children: _jsx(Calendar, { ...(today === undefined ? {} : { today }) }) }) })] }) }));
|
|
87
87
|
}
|
|
88
88
|
/** A span of days — a period of a report, the validity of a contract — typed or picked on
|
|
89
89
|
* two months at once. */
|