@makoai/app-sdk 2.27.0 → 2.29.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 +142 -1
- package/components/combobox.tsx +150 -0
- package/components/filter-bar.tsx +15 -6
- package/components/index.ts +4 -1
- package/components/period-picker.tsx +54 -24
- package/components/period.ts +54 -5
- package/index.d.ts +4 -2
- package/index.js +10 -1
- package/locale.d.ts +122 -0
- package/locale.js +178 -0
- package/menu/filter-menu.tsx +26 -8
- package/package.json +7 -1
- package/ui-core.js +3 -1
- package/ui.css +53 -0
- package/ui.d.ts +77 -1
- package/ui.js +319 -46
package/ui.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
|
+
import type { FilterLabels } from "./locale.js";
|
|
3
|
+
|
|
4
|
+
export * from "./locale.js";
|
|
2
5
|
|
|
3
6
|
/** ok | warn | bad (or green | amber | red), plus loading and neutral. */
|
|
4
7
|
export type Tone =
|
|
@@ -71,6 +74,8 @@ export interface MultiSelectOption<V extends string = string> {
|
|
|
71
74
|
color?: string;
|
|
72
75
|
/** What the option covers, shown on hover. */
|
|
73
76
|
title?: string;
|
|
77
|
+
/** A count shown muted at the row's right edge (2.28). Search ignores it; the trigger never shows it. A number is formatted (1,234). */
|
|
78
|
+
count?: number | string;
|
|
74
79
|
/** A group (2.20): its row ticks every leaf under it; hover submenus: FilterMenu in `@makoai/app-sdk/menu`. */
|
|
75
80
|
children?: ReadonlyArray<MultiSelectOption<V>>;
|
|
76
81
|
}
|
|
@@ -108,6 +113,13 @@ export interface FilterItemsProps<V extends string = string> {
|
|
|
108
113
|
searchPlaceholder?: string;
|
|
109
114
|
/** Shown when no row matches. Default "No match". */
|
|
110
115
|
searchEmpty?: string;
|
|
116
|
+
/**
|
|
117
|
+
* BCP 47 tag (2.29), e.g. "fr-CH": All, Only, Search and No match in that
|
|
118
|
+
* language, from the SDK's strings table; counts format in it. Default English.
|
|
119
|
+
*/
|
|
120
|
+
locale?: string;
|
|
121
|
+
/** Override single texts on top of the locale (2.29). The explicit props win. */
|
|
122
|
+
labels?: Partial<FilterLabels>;
|
|
111
123
|
className?: string;
|
|
112
124
|
"aria-label"?: string;
|
|
113
125
|
}
|
|
@@ -159,6 +171,10 @@ export interface MultiSelectProps<V extends string = string> {
|
|
|
159
171
|
searchPlaceholder?: string;
|
|
160
172
|
/** Default "No match". */
|
|
161
173
|
searchEmpty?: string;
|
|
174
|
+
/** BCP 47 tag (2.29), e.g. "fr-CH": All, None, "N selected", Only, Search and No match in that language. Default English. */
|
|
175
|
+
locale?: string;
|
|
176
|
+
/** Override single texts on top of the locale (2.29). The explicit props win. */
|
|
177
|
+
labels?: Partial<FilterLabels>;
|
|
162
178
|
className?: string;
|
|
163
179
|
"aria-label"?: string;
|
|
164
180
|
}
|
|
@@ -406,8 +422,20 @@ export interface DataTableColumn<R = any> {
|
|
|
406
422
|
sticky?: boolean;
|
|
407
423
|
/** Default true. */
|
|
408
424
|
sortable?: boolean;
|
|
425
|
+
/**
|
|
426
|
+
* The first click's direction (2.29, TanStack Table's name). Default: true
|
|
427
|
+
* for `num` columns (largest first), false otherwise (A→Z). `false` on a
|
|
428
|
+
* days-to-renewal column sorts soonest first. The next click flips it.
|
|
429
|
+
*/
|
|
430
|
+
sortDescFirst?: boolean;
|
|
409
431
|
/** Header hover text, e.g. the column's definition. */
|
|
410
432
|
hint?: string;
|
|
433
|
+
/**
|
|
434
|
+
* The column's definition behind an "i" button beside its header. The
|
|
435
|
+
* button sits outside the sort button, so a click on it never sorts. It
|
|
436
|
+
* opens a popover with the label and this content. Default none.
|
|
437
|
+
*/
|
|
438
|
+
info?: React.ReactNode;
|
|
411
439
|
/**
|
|
412
440
|
* The column group's id. Adjacent columns with the same `group` share one
|
|
413
441
|
* label in a header row on top (see `DataTableProps.groups`); ungrouped
|
|
@@ -466,9 +494,23 @@ export interface DataTableLabels {
|
|
|
466
494
|
exportTitle: string;
|
|
467
495
|
/** Shown when the browser blocks the CSV download. */
|
|
468
496
|
exportFailed: string;
|
|
497
|
+
/** An expand chevron's aria-label, per row. Default "Show details". */
|
|
498
|
+
expand: (row: any) => string;
|
|
499
|
+
/** An open chevron's aria-label, per row. Default "Hide details". */
|
|
500
|
+
collapse: (row: any) => string;
|
|
501
|
+
/** A header "i" button's aria-label. Default "About MRR". */
|
|
502
|
+
info: (label: string) => string;
|
|
469
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Which rows show their detail row: `true` for every row, or the open rows'
|
|
506
|
+
* ids, `{ [String(rowKey(row))]: true }`. The shape of TanStack Table's
|
|
507
|
+
* `ExpandedState`, so one state can drive both.
|
|
508
|
+
*/
|
|
509
|
+
export type DataTableExpanded = true | Record<string, boolean>;
|
|
470
510
|
/** The English defaults of `DataTableLabels`. */
|
|
471
511
|
export const DATA_TABLE_LABELS: DataTableLabels;
|
|
512
|
+
/** The labels a DataTable uses for a locale (2.29), `labels` on top. */
|
|
513
|
+
export function dataTableLabels(locale?: string, labels?: Partial<DataTableLabels>): DataTableLabels;
|
|
472
514
|
export interface DataTableProps<R = any> {
|
|
473
515
|
/** Default [] (renders the empty state while loading). */
|
|
474
516
|
rows?: readonly R[];
|
|
@@ -513,6 +555,12 @@ export interface DataTableProps<R = any> {
|
|
|
513
555
|
* English default (`DATA_TABLE_LABELS`). The README has a full French set.
|
|
514
556
|
*/
|
|
515
557
|
labels?: Partial<DataTableLabels>;
|
|
558
|
+
/**
|
|
559
|
+
* BCP 47 tag (2.29), e.g. "fr-CH": every text above in that language from
|
|
560
|
+
* the SDK's strings table, the footer's numbers formatted in it, and the
|
|
561
|
+
* default `noun` translated ("lignes"). `labels` and `noun` win. Default English.
|
|
562
|
+
*/
|
|
563
|
+
locale?: string;
|
|
516
564
|
/** Fill the parent's height; the body scrolls inside the card. */
|
|
517
565
|
fill?: boolean;
|
|
518
566
|
/** Body scroll height when not `fill`. Default 70vh. */
|
|
@@ -533,6 +581,34 @@ export interface DataTableProps<R = any> {
|
|
|
533
581
|
exportFilename?: string;
|
|
534
582
|
/** Labels and classes for the column groups, by `DataTableColumn.group`. A group not listed shows its id. */
|
|
535
583
|
groups?: readonly DataTableGroup[];
|
|
584
|
+
/** Header labels wrap to 2 lines instead of ellipsizing on one. The sort icon stays beside them. Default false. */
|
|
585
|
+
wrapHeaders?: boolean;
|
|
586
|
+
/**
|
|
587
|
+
* Makes rows expandable: a chevron in each row's first cell opens a
|
|
588
|
+
* full-width detail row under it with this content. Enter or Space on the
|
|
589
|
+
* chevron toggles it. Detail rows never count in the pager, the sort or the
|
|
590
|
+
* CSV. Give rows a stable `rowKey` (or `id`): the state is keyed by it.
|
|
591
|
+
*/
|
|
592
|
+
renderExpanded?: (row: R) => React.ReactNode;
|
|
593
|
+
/** Which rows get a chevron. Default every row. */
|
|
594
|
+
canExpand?: (row: R) => boolean;
|
|
595
|
+
/** Controlled open rows; pair with `onExpandedChange`. */
|
|
596
|
+
expanded?: DataTableExpanded;
|
|
597
|
+
/** The open rows when uncontrolled. Default `{}`. */
|
|
598
|
+
defaultExpanded?: DataTableExpanded;
|
|
599
|
+
onExpandedChange?: (expanded: Record<string, boolean>) => void;
|
|
600
|
+
/**
|
|
601
|
+
* A total row pinned to the bottom of the scroll box (a sticky `<tfoot>`),
|
|
602
|
+
* bold with a rule on top. A row object, or a function of `rows` (the
|
|
603
|
+
* filtered rows the table got). Each column renders it with its `value`
|
|
604
|
+
* and `render`. It never sorts or pages and stays out of the CSV unless
|
|
605
|
+
* `exportTotalRow`. Hidden while there are no rows.
|
|
606
|
+
*/
|
|
607
|
+
totalRow?: R | ((rows: readonly R[]) => R | null | undefined) | null;
|
|
608
|
+
/** A click (or Enter or Space) on the total row, e.g. a drill-down. `rowLabel` names it. */
|
|
609
|
+
onTotalRowClick?: (row: R, event: React.SyntheticEvent) => void;
|
|
610
|
+
/** Append the total row to the CSV export. Default false. */
|
|
611
|
+
exportTotalRow?: boolean;
|
|
536
612
|
className?: string;
|
|
537
613
|
style?: React.CSSProperties;
|
|
538
614
|
}
|
|
@@ -558,7 +634,7 @@ export function columnLayout(columns: readonly Pick<DataTableColumn, "id" | "num
|
|
|
558
634
|
/** A sorted copy: stable, by `value(row)`, empty values (null, "", NaN) last both ways. */
|
|
559
635
|
export function sortRows<R>(rows: readonly R[], columns: readonly DataTableColumn<R>[], sort: DataTableSort | null | undefined): R[];
|
|
560
636
|
/** The sort after a header click: same column flips; a new one starts desc for `num`, else asc. */
|
|
561
|
-
export function nextSort(sort: DataTableSort | null | undefined, column: Pick<DataTableColumn, "id" | "num">): DataTableSort;
|
|
637
|
+
export function nextSort(sort: DataTableSort | null | undefined, column: Pick<DataTableColumn, "id" | "num" | "sortDescFirst">): DataTableSort;
|
|
562
638
|
/** Compare two cell values ascending: numbers, bigints, dates and two numeric strings by value; text A→Z. */
|
|
563
639
|
export function compareValues(a: unknown, b: unknown): number;
|
|
564
640
|
/** Paging math, 1-based and clamped: rows `start` (inclusive) to `end` (exclusive). */
|