@dloizides/ui-tables 1.19.2 → 1.21.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/CHANGELOG.md +21 -0
- package/dist/index.d.mts +137 -1
- package/dist/index.d.ts +137 -1
- package/dist/index.js +323 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +308 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.21.0
|
|
4
|
+
|
|
5
|
+
**New `StatusLedger` (JOBS-UX-1 "Jobs page: one clear, consistent view of every job and source").**
|
|
6
|
+
|
|
7
|
+
A status-first ledger built on `DataTable` + `Filters`: one sortable, filterable table at or above
|
|
8
|
+
the breakpoint (768 by default, from `useWindowDimensions`), and a "needs a look first" feed below
|
|
9
|
+
it (bad then warn rows on top, then the rest). Filters: free text, status, group; sort by any column
|
|
10
|
+
with a `sortValue`, plus a 44px direction toggle. Generic row shape through accessors; every string
|
|
11
|
+
via `labels`/`statusLabel`; tone colours from the theme (`toneColors` overrides). Also exports
|
|
12
|
+
`StatusPill`, `RelativeTime` (tap swaps to absolute), `formatRelativeTime` and the pure
|
|
13
|
+
`filterLedgerRows` / `sortLedgerRows` / `splitNeedsLook` helpers. Additive, nothing existing changes.
|
|
14
|
+
|
|
15
|
+
## 1.20.0
|
|
16
|
+
|
|
17
|
+
**The rows-per-page menu opens above an RN-web Modal (UI-ZINDEX-SCALE-1 "Shared overlay z-index scale").**
|
|
18
|
+
|
|
19
|
+
react-native-web mounts `Modal` in a body-level layer at zIndex 9999. On web the `SizeDropdown`
|
|
20
|
+
menu portals to the body, and at zIndex 1000 it painted under an open Modal, so clicks fell through
|
|
21
|
+
to the dialog. The menu now uses `Z_INDEX.popover` (10000, below toasts) and the sticky header uses
|
|
22
|
+
`Z_INDEX.sticky` (2, unchanged), both from `@dloizides/design-tokens` ^1.13.0, which is now a dependency.
|
|
23
|
+
|
|
3
24
|
## 1.19.2
|
|
4
25
|
|
|
5
26
|
**The pager shrinks and wraps beside a title (TABLES-MOBILE-1 "Filter bar and pager overflow at 360").**
|
package/dist/index.d.mts
CHANGED
|
@@ -783,4 +783,140 @@ interface PagedRows<T> {
|
|
|
783
783
|
*/
|
|
784
784
|
declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
|
|
785
785
|
|
|
786
|
-
|
|
786
|
+
/** Ledger layout: `Auto` picks `Table` at or above the breakpoint and `Feed` below it. */
|
|
787
|
+
declare const enum LedgerLayout {
|
|
788
|
+
Auto = "auto",
|
|
789
|
+
Table = "table",
|
|
790
|
+
Feed = "feed"
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** Visual tone a status maps to; drives colour, glyph and "needs a look" ordering. */
|
|
794
|
+
declare const enum StatusTone {
|
|
795
|
+
Bad = "bad",
|
|
796
|
+
Warn = "warn",
|
|
797
|
+
Active = "active",
|
|
798
|
+
Good = "good",
|
|
799
|
+
Neutral = "neutral"
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
type SortValue = string | number | null | undefined;
|
|
803
|
+
/** A DataTable column that can also be sorted by `sortValue`. */
|
|
804
|
+
interface StatusLedgerColumn<T> extends DataTableColumn<T> {
|
|
805
|
+
sortValue?: (row: T) => SortValue;
|
|
806
|
+
}
|
|
807
|
+
/** Every user-facing string the ledger renders, already translated by the caller. */
|
|
808
|
+
interface StatusLedgerLabels {
|
|
809
|
+
status: string;
|
|
810
|
+
group: string;
|
|
811
|
+
search: string;
|
|
812
|
+
sortBy: string;
|
|
813
|
+
all: string;
|
|
814
|
+
sortAscending: string;
|
|
815
|
+
sortDescending: string;
|
|
816
|
+
sortDirectionHint: string;
|
|
817
|
+
clear: string;
|
|
818
|
+
clearHint: string;
|
|
819
|
+
results: string;
|
|
820
|
+
needsLook: string;
|
|
821
|
+
everythingElse: string;
|
|
822
|
+
allClear: string;
|
|
823
|
+
empty: string;
|
|
824
|
+
actions: string;
|
|
825
|
+
}
|
|
826
|
+
type ToneColors = Partial<Record<StatusTone, string>>;
|
|
827
|
+
interface StatusLedgerProps<T> {
|
|
828
|
+
rows: readonly T[];
|
|
829
|
+
columns: ReadonlyArray<StatusLedgerColumn<T>>;
|
|
830
|
+
keyExtractor: (row: T) => string;
|
|
831
|
+
getStatus: (row: T) => string;
|
|
832
|
+
statusLabel: (status: string) => string;
|
|
833
|
+
statusTone: (status: string) => StatusTone;
|
|
834
|
+
labels: StatusLedgerLabels;
|
|
835
|
+
getGroup?: (row: T) => string;
|
|
836
|
+
groupLabel?: (group: string) => string;
|
|
837
|
+
getSearchText?: (row: T) => string;
|
|
838
|
+
needsLook?: (row: T) => boolean;
|
|
839
|
+
getRowAccessibilityLabel?: (row: T) => string;
|
|
840
|
+
onRowPress?: (row: T) => void;
|
|
841
|
+
renderActions?: (row: T) => React.ReactNode;
|
|
842
|
+
toneColors?: ToneColors;
|
|
843
|
+
layout?: LedgerLayout;
|
|
844
|
+
breakpoint?: number;
|
|
845
|
+
loading?: boolean;
|
|
846
|
+
testID?: string;
|
|
847
|
+
}
|
|
848
|
+
interface LedgerFilter {
|
|
849
|
+
status: string;
|
|
850
|
+
group: string;
|
|
851
|
+
text: string;
|
|
852
|
+
}
|
|
853
|
+
interface LedgerAccessors<T> {
|
|
854
|
+
getStatus: (row: T) => string;
|
|
855
|
+
getGroup?: (row: T) => string;
|
|
856
|
+
getSearchText?: (row: T) => string;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/** Status-first ledger: one sortable, filterable table on wide screens, "needs a look first" on narrow ones. */
|
|
860
|
+
declare function StatusLedger<T>(props: StatusLedgerProps<T>): React.ReactElement;
|
|
861
|
+
|
|
862
|
+
interface StatusPillProps {
|
|
863
|
+
label: string;
|
|
864
|
+
tone: StatusTone;
|
|
865
|
+
color: string;
|
|
866
|
+
testID?: string;
|
|
867
|
+
}
|
|
868
|
+
/** A status label with a tone glyph, so the tone never relies on colour alone. */
|
|
869
|
+
declare function StatusPill({ label, tone, color, testID }: StatusPillProps): React.ReactElement;
|
|
870
|
+
|
|
871
|
+
type TimeInput = string | number | Date | null | undefined;
|
|
872
|
+
interface RelativeUnitStrings {
|
|
873
|
+
minutes: string;
|
|
874
|
+
hours: string;
|
|
875
|
+
days: string;
|
|
876
|
+
}
|
|
877
|
+
/** Caller-translated templates; `{{n}}` is replaced by the count, e.g. "{{n}} min ago". */
|
|
878
|
+
interface RelativeTimeStrings extends RelativeUnitStrings {
|
|
879
|
+
justNow: string;
|
|
880
|
+
never: string;
|
|
881
|
+
future?: RelativeUnitStrings;
|
|
882
|
+
}
|
|
883
|
+
/** Parses a time input to epoch ms; `null` when absent or unparseable. */
|
|
884
|
+
declare function toEpochMs(value: TimeInput): number | null;
|
|
885
|
+
/** One relative-time format for every ledger: just now, then minutes, hours, days. */
|
|
886
|
+
declare function formatRelativeTime(value: TimeInput, nowMs: number, strings: RelativeTimeStrings): string;
|
|
887
|
+
|
|
888
|
+
interface RelativeTimeProps {
|
|
889
|
+
value: TimeInput;
|
|
890
|
+
nowMs: number;
|
|
891
|
+
strings: RelativeTimeStrings;
|
|
892
|
+
hint: string;
|
|
893
|
+
formatAbsolute?: (epochMs: number) => string;
|
|
894
|
+
testID?: string;
|
|
895
|
+
}
|
|
896
|
+
/** Shows "5 min ago"; a tap or click swaps to the absolute time, which is also the accessible name. */
|
|
897
|
+
declare function RelativeTime({ value, nowMs, strings, hint, formatAbsolute, testID }: RelativeTimeProps): React.ReactElement;
|
|
898
|
+
|
|
899
|
+
/** Sort direction of a ledger column. */
|
|
900
|
+
declare const enum SortDirection {
|
|
901
|
+
Asc = "asc",
|
|
902
|
+
Desc = "desc"
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
declare const STATUS_LEDGER_TEST_ID = "ui-status-ledger";
|
|
906
|
+
declare const ledgerSectionTestID: (testID: string, section: string) => string;
|
|
907
|
+
declare const ledgerSortDirectionTestID: (testID: string) => string;
|
|
908
|
+
|
|
909
|
+
/** Keeps rows matching the status, group and free-text filter; an empty value matches all. */
|
|
910
|
+
declare function filterLedgerRows<T>(rows: readonly T[], filter: LedgerFilter, accessors: LedgerAccessors<T>): T[];
|
|
911
|
+
/** Stable sort by `sortValue`; missing values always sort last, whatever the direction. */
|
|
912
|
+
declare function sortLedgerRows<T>(rows: readonly T[], sortValue: (row: T) => SortValue, direction: SortDirection): T[];
|
|
913
|
+
declare const isAttentionTone: (tone: StatusTone) => boolean;
|
|
914
|
+
/** Splits rows into "needs a look" (worst tone first, input order kept within a tone) and the rest. */
|
|
915
|
+
declare function splitNeedsLook<T>(rows: readonly T[], needsLook: (row: T) => boolean, toneOf: (row: T) => StatusTone): {
|
|
916
|
+
attention: T[];
|
|
917
|
+
rest: T[];
|
|
918
|
+
};
|
|
919
|
+
/** Distinct non-empty values in first-seen order. */
|
|
920
|
+
declare function distinctValues<T>(rows: readonly T[], pick: (row: T) => string | undefined): string[];
|
|
921
|
+
|
|
922
|
+
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, type NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
package/dist/index.d.ts
CHANGED
|
@@ -783,4 +783,140 @@ interface PagedRows<T> {
|
|
|
783
783
|
*/
|
|
784
784
|
declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
|
|
785
785
|
|
|
786
|
-
|
|
786
|
+
/** Ledger layout: `Auto` picks `Table` at or above the breakpoint and `Feed` below it. */
|
|
787
|
+
declare const enum LedgerLayout {
|
|
788
|
+
Auto = "auto",
|
|
789
|
+
Table = "table",
|
|
790
|
+
Feed = "feed"
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** Visual tone a status maps to; drives colour, glyph and "needs a look" ordering. */
|
|
794
|
+
declare const enum StatusTone {
|
|
795
|
+
Bad = "bad",
|
|
796
|
+
Warn = "warn",
|
|
797
|
+
Active = "active",
|
|
798
|
+
Good = "good",
|
|
799
|
+
Neutral = "neutral"
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
type SortValue = string | number | null | undefined;
|
|
803
|
+
/** A DataTable column that can also be sorted by `sortValue`. */
|
|
804
|
+
interface StatusLedgerColumn<T> extends DataTableColumn<T> {
|
|
805
|
+
sortValue?: (row: T) => SortValue;
|
|
806
|
+
}
|
|
807
|
+
/** Every user-facing string the ledger renders, already translated by the caller. */
|
|
808
|
+
interface StatusLedgerLabels {
|
|
809
|
+
status: string;
|
|
810
|
+
group: string;
|
|
811
|
+
search: string;
|
|
812
|
+
sortBy: string;
|
|
813
|
+
all: string;
|
|
814
|
+
sortAscending: string;
|
|
815
|
+
sortDescending: string;
|
|
816
|
+
sortDirectionHint: string;
|
|
817
|
+
clear: string;
|
|
818
|
+
clearHint: string;
|
|
819
|
+
results: string;
|
|
820
|
+
needsLook: string;
|
|
821
|
+
everythingElse: string;
|
|
822
|
+
allClear: string;
|
|
823
|
+
empty: string;
|
|
824
|
+
actions: string;
|
|
825
|
+
}
|
|
826
|
+
type ToneColors = Partial<Record<StatusTone, string>>;
|
|
827
|
+
interface StatusLedgerProps<T> {
|
|
828
|
+
rows: readonly T[];
|
|
829
|
+
columns: ReadonlyArray<StatusLedgerColumn<T>>;
|
|
830
|
+
keyExtractor: (row: T) => string;
|
|
831
|
+
getStatus: (row: T) => string;
|
|
832
|
+
statusLabel: (status: string) => string;
|
|
833
|
+
statusTone: (status: string) => StatusTone;
|
|
834
|
+
labels: StatusLedgerLabels;
|
|
835
|
+
getGroup?: (row: T) => string;
|
|
836
|
+
groupLabel?: (group: string) => string;
|
|
837
|
+
getSearchText?: (row: T) => string;
|
|
838
|
+
needsLook?: (row: T) => boolean;
|
|
839
|
+
getRowAccessibilityLabel?: (row: T) => string;
|
|
840
|
+
onRowPress?: (row: T) => void;
|
|
841
|
+
renderActions?: (row: T) => React.ReactNode;
|
|
842
|
+
toneColors?: ToneColors;
|
|
843
|
+
layout?: LedgerLayout;
|
|
844
|
+
breakpoint?: number;
|
|
845
|
+
loading?: boolean;
|
|
846
|
+
testID?: string;
|
|
847
|
+
}
|
|
848
|
+
interface LedgerFilter {
|
|
849
|
+
status: string;
|
|
850
|
+
group: string;
|
|
851
|
+
text: string;
|
|
852
|
+
}
|
|
853
|
+
interface LedgerAccessors<T> {
|
|
854
|
+
getStatus: (row: T) => string;
|
|
855
|
+
getGroup?: (row: T) => string;
|
|
856
|
+
getSearchText?: (row: T) => string;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/** Status-first ledger: one sortable, filterable table on wide screens, "needs a look first" on narrow ones. */
|
|
860
|
+
declare function StatusLedger<T>(props: StatusLedgerProps<T>): React.ReactElement;
|
|
861
|
+
|
|
862
|
+
interface StatusPillProps {
|
|
863
|
+
label: string;
|
|
864
|
+
tone: StatusTone;
|
|
865
|
+
color: string;
|
|
866
|
+
testID?: string;
|
|
867
|
+
}
|
|
868
|
+
/** A status label with a tone glyph, so the tone never relies on colour alone. */
|
|
869
|
+
declare function StatusPill({ label, tone, color, testID }: StatusPillProps): React.ReactElement;
|
|
870
|
+
|
|
871
|
+
type TimeInput = string | number | Date | null | undefined;
|
|
872
|
+
interface RelativeUnitStrings {
|
|
873
|
+
minutes: string;
|
|
874
|
+
hours: string;
|
|
875
|
+
days: string;
|
|
876
|
+
}
|
|
877
|
+
/** Caller-translated templates; `{{n}}` is replaced by the count, e.g. "{{n}} min ago". */
|
|
878
|
+
interface RelativeTimeStrings extends RelativeUnitStrings {
|
|
879
|
+
justNow: string;
|
|
880
|
+
never: string;
|
|
881
|
+
future?: RelativeUnitStrings;
|
|
882
|
+
}
|
|
883
|
+
/** Parses a time input to epoch ms; `null` when absent or unparseable. */
|
|
884
|
+
declare function toEpochMs(value: TimeInput): number | null;
|
|
885
|
+
/** One relative-time format for every ledger: just now, then minutes, hours, days. */
|
|
886
|
+
declare function formatRelativeTime(value: TimeInput, nowMs: number, strings: RelativeTimeStrings): string;
|
|
887
|
+
|
|
888
|
+
interface RelativeTimeProps {
|
|
889
|
+
value: TimeInput;
|
|
890
|
+
nowMs: number;
|
|
891
|
+
strings: RelativeTimeStrings;
|
|
892
|
+
hint: string;
|
|
893
|
+
formatAbsolute?: (epochMs: number) => string;
|
|
894
|
+
testID?: string;
|
|
895
|
+
}
|
|
896
|
+
/** Shows "5 min ago"; a tap or click swaps to the absolute time, which is also the accessible name. */
|
|
897
|
+
declare function RelativeTime({ value, nowMs, strings, hint, formatAbsolute, testID }: RelativeTimeProps): React.ReactElement;
|
|
898
|
+
|
|
899
|
+
/** Sort direction of a ledger column. */
|
|
900
|
+
declare const enum SortDirection {
|
|
901
|
+
Asc = "asc",
|
|
902
|
+
Desc = "desc"
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
declare const STATUS_LEDGER_TEST_ID = "ui-status-ledger";
|
|
906
|
+
declare const ledgerSectionTestID: (testID: string, section: string) => string;
|
|
907
|
+
declare const ledgerSortDirectionTestID: (testID: string) => string;
|
|
908
|
+
|
|
909
|
+
/** Keeps rows matching the status, group and free-text filter; an empty value matches all. */
|
|
910
|
+
declare function filterLedgerRows<T>(rows: readonly T[], filter: LedgerFilter, accessors: LedgerAccessors<T>): T[];
|
|
911
|
+
/** Stable sort by `sortValue`; missing values always sort last, whatever the direction. */
|
|
912
|
+
declare function sortLedgerRows<T>(rows: readonly T[], sortValue: (row: T) => SortValue, direction: SortDirection): T[];
|
|
913
|
+
declare const isAttentionTone: (tone: StatusTone) => boolean;
|
|
914
|
+
/** Splits rows into "needs a look" (worst tone first, input order kept within a tone) and the rest. */
|
|
915
|
+
declare function splitNeedsLook<T>(rows: readonly T[], needsLook: (row: T) => boolean, toneOf: (row: T) => StatusTone): {
|
|
916
|
+
attention: T[];
|
|
917
|
+
rest: T[];
|
|
918
|
+
};
|
|
919
|
+
/** Distinct non-empty values in first-seen order. */
|
|
920
|
+
declare function distinctValues<T>(rows: readonly T[], pick: (row: T) => string | undefined): string[];
|
|
921
|
+
|
|
922
|
+
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, type NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|