@kjun-ui/react 0.17.0 → 0.19.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.
Files changed (156) hide show
  1. package/dist/index.cjs +4267 -1765
  2. package/dist/index.js +4272 -1767
  3. package/dist/styles.css +1612 -577
  4. package/dist/types/packages/react/src/actions.d.cts +12 -3
  5. package/dist/types/packages/react/src/actions.d.ts +12 -3
  6. package/dist/types/packages/react/src/app-navigation.d.cts +31 -8
  7. package/dist/types/packages/react/src/app-navigation.d.ts +31 -8
  8. package/dist/types/packages/react/src/calendar.d.cts +30 -0
  9. package/dist/types/packages/react/src/calendar.d.ts +30 -0
  10. package/dist/types/packages/react/src/carousel.d.cts +39 -0
  11. package/dist/types/packages/react/src/carousel.d.ts +39 -0
  12. package/dist/types/packages/react/src/controls.d.cts +16 -11
  13. package/dist/types/packages/react/src/controls.d.ts +16 -11
  14. package/dist/types/packages/react/src/date-picker.d.cts +34 -6
  15. package/dist/types/packages/react/src/date-picker.d.ts +34 -6
  16. package/dist/types/packages/react/src/display.d.cts +15 -3
  17. package/dist/types/packages/react/src/display.d.ts +15 -3
  18. package/dist/types/packages/react/src/drawer.d.cts +3 -5
  19. package/dist/types/packages/react/src/drawer.d.ts +3 -5
  20. package/dist/types/packages/react/src/dropdown.d.cts +35 -3
  21. package/dist/types/packages/react/src/dropdown.d.ts +35 -3
  22. package/dist/types/packages/react/src/fab.d.cts +3 -3
  23. package/dist/types/packages/react/src/fab.d.ts +3 -3
  24. package/dist/types/packages/react/src/feedback.d.cts +12 -3
  25. package/dist/types/packages/react/src/feedback.d.ts +12 -3
  26. package/dist/types/packages/react/src/financial-display.d.cts +10 -1
  27. package/dist/types/packages/react/src/financial-display.d.ts +10 -1
  28. package/dist/types/packages/react/src/financial.d.cts +2 -2
  29. package/dist/types/packages/react/src/financial.d.ts +2 -2
  30. package/dist/types/packages/react/src/index.d.cts +10 -6
  31. package/dist/types/packages/react/src/index.d.ts +10 -6
  32. package/dist/types/packages/react/src/layers.d.cts +1 -1
  33. package/dist/types/packages/react/src/layers.d.ts +1 -1
  34. package/dist/types/packages/react/src/layout-primitives.d.cts +24 -24
  35. package/dist/types/packages/react/src/layout-primitives.d.ts +24 -24
  36. package/dist/types/packages/react/src/list.d.cts +27 -4
  37. package/dist/types/packages/react/src/list.d.ts +27 -4
  38. package/dist/types/packages/react/src/market-model.d.cts +8 -1
  39. package/dist/types/packages/react/src/market-model.d.ts +8 -1
  40. package/dist/types/packages/react/src/modal.d.cts +3 -1
  41. package/dist/types/packages/react/src/modal.d.ts +3 -1
  42. package/dist/types/packages/react/src/navigation.d.cts +24 -42
  43. package/dist/types/packages/react/src/navigation.d.ts +24 -42
  44. package/dist/types/packages/react/src/number-display.d.cts +12 -12
  45. package/dist/types/packages/react/src/number-display.d.ts +12 -12
  46. package/dist/types/packages/react/src/popover.d.cts +9 -4
  47. package/dist/types/packages/react/src/popover.d.ts +9 -4
  48. package/dist/types/packages/react/src/provider.d.cts +4 -1
  49. package/dist/types/packages/react/src/provider.d.ts +4 -1
  50. package/dist/types/packages/react/src/select-control.d.cts +3 -1
  51. package/dist/types/packages/react/src/select-control.d.ts +3 -1
  52. package/dist/types/packages/react/src/select.d.cts +2 -2
  53. package/dist/types/packages/react/src/select.d.ts +2 -2
  54. package/dist/types/packages/react/src/skeleton-phase.d.cts +2 -0
  55. package/dist/types/packages/react/src/skeleton-phase.d.ts +2 -0
  56. package/dist/types/packages/react/src/skeletons.d.cts +19 -4
  57. package/dist/types/packages/react/src/skeletons.d.ts +19 -4
  58. package/dist/types/packages/react/src/table-cards.d.cts +6 -3
  59. package/dist/types/packages/react/src/table-cards.d.ts +6 -3
  60. package/dist/types/packages/react/src/table-grid.d.cts +1 -1
  61. package/dist/types/packages/react/src/table-grid.d.ts +1 -1
  62. package/dist/types/packages/react/src/table-list.d.cts +10 -0
  63. package/dist/types/packages/react/src/table-list.d.ts +10 -0
  64. package/dist/types/packages/react/src/table-model.d.cts +2 -0
  65. package/dist/types/packages/react/src/table-model.d.ts +2 -0
  66. package/dist/types/packages/react/src/table-toolbar.d.cts +1 -1
  67. package/dist/types/packages/react/src/table-toolbar.d.ts +1 -1
  68. package/dist/types/packages/react/src/table-totals.d.cts +5 -0
  69. package/dist/types/packages/react/src/table-totals.d.ts +5 -0
  70. package/dist/types/packages/react/src/tabs.d.cts +38 -0
  71. package/dist/types/packages/react/src/tabs.d.ts +38 -0
  72. package/dist/types/packages/react/src/textarea.d.cts +29 -0
  73. package/dist/types/packages/react/src/textarea.d.ts +29 -0
  74. package/dist/types/packages/react/src/time-picker.d.cts +10 -1
  75. package/dist/types/packages/react/src/time-picker.d.ts +10 -1
  76. package/dist/types/packages/react/src/toast-stack.d.cts +7 -2
  77. package/dist/types/packages/react/src/toast-stack.d.ts +7 -2
  78. package/dist/types/shared/package-runtime/accordion-state.d.cts +11 -0
  79. package/dist/types/shared/package-runtime/accordion-state.d.ts +11 -0
  80. package/dist/types/shared/package-runtime/action-size.d.cts +1 -1
  81. package/dist/types/shared/package-runtime/action-size.d.ts +1 -1
  82. package/dist/types/shared/package-runtime/alert-action-size.d.cts +2 -0
  83. package/dist/types/shared/package-runtime/alert-action-size.d.ts +2 -0
  84. package/dist/types/shared/package-runtime/badge-tone.d.cts +59 -0
  85. package/dist/types/shared/package-runtime/badge-tone.d.ts +59 -0
  86. package/dist/types/shared/package-runtime/breadcrumb.d.cts +20 -0
  87. package/dist/types/shared/package-runtime/breadcrumb.d.ts +20 -0
  88. package/dist/types/shared/package-runtime/calendar.d.cts +106 -0
  89. package/dist/types/shared/package-runtime/calendar.d.ts +106 -0
  90. package/dist/types/shared/package-runtime/carousel-scroll.d.cts +22 -0
  91. package/dist/types/shared/package-runtime/carousel-scroll.d.ts +22 -0
  92. package/dist/types/shared/package-runtime/carousel.d.cts +47 -0
  93. package/dist/types/shared/package-runtime/carousel.d.ts +47 -0
  94. package/dist/types/shared/package-runtime/center-option.d.cts +1 -0
  95. package/dist/types/shared/package-runtime/center-option.d.ts +1 -0
  96. package/dist/types/shared/package-runtime/chart-skeleton.d.cts +15 -3
  97. package/dist/types/shared/package-runtime/chart-skeleton.d.ts +15 -3
  98. package/dist/types/shared/package-runtime/drawer-geometry.d.cts +2 -3
  99. package/dist/types/shared/package-runtime/drawer-geometry.d.ts +2 -3
  100. package/dist/types/shared/package-runtime/feedback-dialog.d.cts +5 -4
  101. package/dist/types/shared/package-runtime/feedback-dialog.d.ts +5 -4
  102. package/dist/types/shared/package-runtime/feedback-motion.d.cts +2 -5
  103. package/dist/types/shared/package-runtime/feedback-motion.d.ts +2 -5
  104. package/dist/types/shared/package-runtime/feedback-prompt.d.cts +58 -0
  105. package/dist/types/shared/package-runtime/feedback-prompt.d.ts +58 -0
  106. package/dist/types/shared/package-runtime/list-row.d.cts +14 -0
  107. package/dist/types/shared/package-runtime/list-row.d.ts +14 -0
  108. package/dist/types/shared/package-runtime/market-layout.d.cts +0 -1
  109. package/dist/types/shared/package-runtime/market-layout.d.ts +0 -1
  110. package/dist/types/shared/package-runtime/messages/ko.d.cts +45 -5
  111. package/dist/types/shared/package-runtime/messages/ko.d.ts +45 -5
  112. package/dist/types/shared/package-runtime/messages-context.d.cts +45 -5
  113. package/dist/types/shared/package-runtime/messages-context.d.ts +45 -5
  114. package/dist/types/shared/package-runtime/navigation-badge.d.cts +12 -0
  115. package/dist/types/shared/package-runtime/navigation-badge.d.ts +12 -0
  116. package/dist/types/shared/package-runtime/navigation.d.cts +1 -1
  117. package/dist/types/shared/package-runtime/navigation.d.ts +1 -1
  118. package/dist/types/shared/package-runtime/safe-area.d.cts +20 -0
  119. package/dist/types/shared/package-runtime/safe-area.d.ts +20 -0
  120. package/dist/types/shared/package-runtime/scroll-fade.d.cts +25 -0
  121. package/dist/types/shared/package-runtime/scroll-fade.d.ts +25 -0
  122. package/dist/types/shared/package-runtime/skeleton-text.d.cts +12 -0
  123. package/dist/types/shared/package-runtime/skeleton-text.d.ts +12 -0
  124. package/dist/types/shared/package-runtime/sparkline.d.cts +58 -0
  125. package/dist/types/shared/package-runtime/sparkline.d.ts +58 -0
  126. package/dist/types/shared/package-runtime/stable-value.d.cts +3 -0
  127. package/dist/types/shared/package-runtime/stable-value.d.ts +3 -0
  128. package/dist/types/shared/package-runtime/table-groups.d.cts +11 -0
  129. package/dist/types/shared/package-runtime/table-groups.d.ts +11 -0
  130. package/dist/types/shared/package-runtime/table-model.d.cts +25 -2
  131. package/dist/types/shared/package-runtime/table-model.d.ts +25 -2
  132. package/dist/types/shared/package-runtime/table-presentation.d.cts +67 -5
  133. package/dist/types/shared/package-runtime/table-presentation.d.ts +67 -5
  134. package/dist/types/shared/package-runtime/table.d.cts +24 -2
  135. package/dist/types/shared/package-runtime/table.d.ts +24 -2
  136. package/dist/types/shared/package-runtime/textarea-grow.d.cts +1 -0
  137. package/dist/types/shared/package-runtime/textarea-grow.d.ts +1 -0
  138. package/dist/types/shared/package-runtime/textarea.d.cts +53 -0
  139. package/dist/types/shared/package-runtime/textarea.d.ts +53 -0
  140. package/dist/types/shared/package-runtime/time-segments.d.cts +25 -0
  141. package/dist/types/shared/package-runtime/time-segments.d.ts +25 -0
  142. package/dist/types/shared/package-runtime/toast-entry.d.cts +3 -0
  143. package/dist/types/shared/package-runtime/toast-entry.d.ts +3 -0
  144. package/dist/types/shared/package-runtime/toast-placement.d.cts +4 -0
  145. package/dist/types/shared/package-runtime/toast-placement.d.ts +4 -0
  146. package/dist/types/shared/package-runtime/toast-presence.d.cts +12 -0
  147. package/dist/types/shared/package-runtime/toast-presence.d.ts +12 -0
  148. package/dist/types/shared/package-runtime/toast-presentation.d.cts +42 -0
  149. package/dist/types/shared/package-runtime/toast-presentation.d.ts +42 -0
  150. package/dist/types/shared/package-runtime/toast-swipe.d.cts +20 -0
  151. package/dist/types/shared/package-runtime/toast-swipe.d.ts +20 -0
  152. package/dist/types/shared/package-runtime/use-toast-stack.d.cts +22 -0
  153. package/dist/types/shared/package-runtime/use-toast-stack.d.ts +22 -0
  154. package/package.json +3 -3
  155. package/dist/types/shared/package-runtime/relative-time.d.cts +0 -1
  156. package/dist/types/shared/package-runtime/relative-time.d.ts +0 -1
@@ -1,7 +1,11 @@
1
1
  import type { ReactNode } from "react";
2
- import type { TableColumn, TableCardSection, TableProps, useTableModel } from "./table.js";
2
+ import type { TableColumn, TableCardSection, TableProps, TableSort, useTableModel } from "./table.js";
3
+ import { type TableRowGroup } from "./table-groups.js";
3
4
  export declare function tablePresentation<Row extends object>(props: TableProps<Row, unknown>, mobile: boolean): {
4
5
  card: boolean;
6
+ list: boolean;
7
+ listValue: TableColumn<Row> | undefined;
8
+ listMeta: TableColumn<Row> | undefined;
5
9
  visible: TableColumn<Row>[];
6
10
  title: TableColumn<Row> | undefined;
7
11
  subtitle: TableColumn<Row> | undefined;
@@ -9,40 +13,89 @@ export declare function tablePresentation<Row extends object>(props: TableProps<
9
13
  actions: TableColumn<Row> | undefined;
10
14
  inline: TableColumn<Row>[];
11
15
  sections: TableCardSection[];
16
+ highlight: TableColumn<Row> | undefined;
17
+ cardLayout: "rows" | "stacked" | "tiles";
18
+ tiles: boolean;
19
+ /** The actions column in the card's footer row (an inline one sits in the header instead). */
20
+ footerActions: TableColumn<Row> | undefined;
21
+ /** One footer row holds the expand toggle and the row actions. */
22
+ cardFooter: boolean;
23
+ /** A section's field arrangement: rows cards put every field on a label-value line. */
24
+ cardBody(section: TableCardSection): "metrics" | "grid" | "stack" | "rows";
12
25
  columnsForSection(row: Row, section: TableCardSection): TableColumn<Row>[];
13
26
  };
27
+ /** Narrow layouts have no header row to sort by, so the toolbar offers each sortable column in both orders. */
28
+ export declare function tableSortOptions<Row extends object>(props: TableProps<Row, unknown>, messages: {
29
+ defaultOrder: string;
30
+ ascending: string;
31
+ descending: string;
32
+ }): {
33
+ value: string;
34
+ label: string;
35
+ }[];
36
+ export declare const tableSortValue: (sort: TableSort) => string;
37
+ export declare function tableSortFromValue(value: unknown): TableSort;
14
38
  export declare function columnFormat<Format>(column: {
15
39
  key: string;
16
40
  format?: Format;
17
41
  }): Format | undefined;
18
- export declare function tableCellValue<Row extends object>(props: TableProps<Row, unknown>, column: TableColumn<Row>, row: Row, index: number): {
42
+ /** locale is the KjunProvider locale, so numbers group the way the app's language does. */
43
+ export declare function tableCellValue<Row extends object>(props: TableProps<Row, unknown>, column: TableColumn<Row>, row: Row, index: number, locale?: string): {
19
44
  value: unknown;
20
45
  body: ReactNode;
21
46
  };
47
+ /** A summary cell: the app's function, or the kind computed and shown through the column's format. */
48
+ export declare function tableSummaryValue<Row extends object>(props: TableProps<Row, unknown>, column: TableColumn<Row>, rows: Row[], locale?: string): ReactNode;
49
+ /** Narrow layouts keep the summary as one closing block: each summarized column's label and total. */
50
+ export interface TableTotal {
51
+ key: string;
52
+ label: string;
53
+ value: ReactNode;
54
+ }
55
+ export declare function tableTotals<Row extends object>(props: TableProps<Row, unknown>, rows: Row[], locale?: string): TableTotal[];
56
+ /** A group's accessible name: its label when that is text, else the grouped value. */
57
+ export declare function tableGroupName<Row extends object>(label: unknown, group: TableRowGroup<Row>): string;
58
+ export interface TableGroupingProps<Row extends object> {
59
+ groups: TableRowGroup<Row>[] | null;
60
+ collapsed: string[];
61
+ toggleGroup: (key: string) => void;
62
+ groupLabel: (group: TableRowGroup<Row>) => ReactNode;
63
+ summary: ((column: TableColumn<Row>, rows: Row[]) => ReactNode) | null;
64
+ }
65
+ /** Card parts: a card value starts at its label (cardValue) or ends a label-value line (cardRowValue); tiles use smaller titles and highlights. */
66
+ export type TableCellRole = "title" | "listTitle" | "listMeta" | "listValue" | "cardValue" | "cardRowValue" | "cardSubtitle" | "cardHighlight" | "tileTitle" | "tileHighlight";
22
67
  export interface TableRowsProps<Row extends object> {
23
68
  initialLoading: boolean;
24
69
  skeletonRows: number;
25
70
  /** A loadingDelay is still running: the skeleton keeps its space but stays out of sight. */
26
71
  skeletonHidden?: boolean;
27
- state: Pick<ReturnType<typeof useTableModel<Row>>, "rows" | "key" | "expanded" | "selectedRow">;
72
+ state: Pick<ReturnType<typeof useTableModel<Row>>, "rows" | "rowIndex" | "key" | "expanded" | "selectedRow">;
28
73
  onRowClick: TableProps<Row>["onRowClick"];
29
74
  selectable: boolean;
30
75
  expandable: boolean;
31
76
  checkbox: (row: Row, index: number) => ReactNode;
32
77
  expand: (row: Row, index: number) => ReactNode;
33
- cell: (column: TableColumn<Row>, row: Row, index: number, role?: "title") => ReactNode;
78
+ cell: (column: TableColumn<Row>, row: Row, index: number, role?: TableCellRole) => ReactNode;
34
79
  renderExpand: TableProps<Row>["renderExpand"];
35
80
  emptyContent: ReactNode;
36
81
  emptyText: string;
37
82
  }
38
83
  export interface TableCardsProps<Row extends object> extends TableRowsProps<Row> {
39
84
  layout: ReturnType<typeof tablePresentation<Row>>;
85
+ totals?: TableTotal[];
86
+ /** groupBy groups: each one opens with a header line (label, count and, with two or more rows, its subtotals) above its cards. */
87
+ groups?: TableRowGroup<Row>[] | null;
88
+ groupLabel?: (group: TableRowGroup<Row>) => ReactNode;
89
+ groupTotals?: (rows: Row[]) => TableTotal[];
90
+ /** The cell's plain text, for a value read out with its label where the label is not drawn (tile highlight on Native). */
91
+ cellText?: (column: TableColumn<Row>, row: Row, index: number) => string | undefined;
40
92
  }
41
- export interface TableGridProps<Row extends object, Height> extends TableRowsProps<Row> {
93
+ export interface TableGridProps<Row extends object, Height> extends TableRowsProps<Row>, TableGroupingProps<Row> {
42
94
  state: TableRowsProps<Row>["state"] & Pick<ReturnType<typeof useTableModel<Row>>, "all" | "some" | "toggleAll" | "sort" | "sortColumn">;
43
95
  visible: TableColumn<Row>[];
44
96
  maxHeight?: Height;
45
97
  stickyHeader: boolean;
98
+ stickyOffset?: number;
46
99
  sortable?: boolean;
47
100
  compact: boolean;
48
101
  striped: boolean;
@@ -51,6 +104,8 @@ export interface TableGridProps<Row extends object, Height> extends TableRowsPro
51
104
  export interface TableToolbarProps<Row extends object> {
52
105
  selectable: boolean;
53
106
  selected: Row[];
107
+ /** Every visible row is selected: the bar drops its select-all action. */
108
+ allSelected: boolean;
54
109
  toggleAll: () => void;
55
110
  clearSelection: () => void;
56
111
  renderSelectionToolbar: TableProps<Row>["renderSelectionToolbar"];
@@ -59,4 +114,11 @@ export interface TableToolbarProps<Row extends object> {
59
114
  searchChange: (value: string) => void;
60
115
  searchPlaceholder: string;
61
116
  toolbar: ReactNode;
117
+ /** Narrow layouts only: the sort choices (tableSortOptions), the chosen one and the change. */
118
+ sortOptions?: {
119
+ value: string;
120
+ label: string;
121
+ }[];
122
+ sortValue?: string;
123
+ sortChange?: (value: string) => void;
62
124
  }
@@ -1,6 +1,9 @@
1
1
  import { type TableSort, type QueryDisplayProps } from "@kjun-ui/tokens";
2
2
  export type { TableSort } from "@kjun-ui/tokens";
3
3
  import { type ReactNode } from "react";
4
+ import type { TableSummaryKind } from "./table-groups.cjs";
5
+ export type { TableSummaryKind } from "./table-groups.cjs";
6
+ import { type TableCompare } from "./table-model.cjs";
4
7
  export { getValue } from "./table-model.cjs";
5
8
  export interface TableColumn<Row extends object = Record<string, unknown>> {
6
9
  key: string;
@@ -9,6 +12,8 @@ export interface TableColumn<Row extends object = Record<string, unknown>> {
9
12
  width?: number | string;
10
13
  align?: "left" | "center" | "right";
11
14
  type?: "number" | "date" | "datetime" | "text";
15
+ /** The column's own sort order for two cell values (ascending); by default dates, numbers and text compare naturally. */
16
+ compare?: TableCompare;
12
17
  format?: (value: unknown, row: Row) => ReactNode;
13
18
  render?: (value: unknown, row: Row, index: number) => ReactNode;
14
19
  pill?: boolean;
@@ -51,22 +56,35 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
51
56
  searchable?: boolean;
52
57
  searchPlaceholder?: string;
53
58
  stickyHeader?: boolean;
59
+ /** Without maxHeight a sticky header sticks under the page scroll; this is its distance from the viewport top (px). */
60
+ stickyOffset?: number;
54
61
  maxHeight?: MaxHeight;
55
62
  pagination?: TablePagination | null;
56
63
  compact?: boolean;
57
64
  striped?: boolean;
58
65
  ariaLabel?: string;
59
- responsive?: "card" | "compact" | "none" | null;
66
+ responsive?: "card" | "list" | "compact" | "none" | null;
60
67
  mobileColumns?: string[];
61
68
  cardTitle?: string | null;
62
69
  cardSubtitle?: string | null;
63
70
  cardSections?: TableCardSection[];
71
+ /** Card shape on narrow screens: "stacked" (default) field grid, "rows" label-value lines, or "tiles" two small cards a row. */
72
+ cardLayout?: "stacked" | "rows" | "tiles";
73
+ /** Column shown large under the card's title (a total, a balance); tiles show it as their main value. */
74
+ cardHighlight?: string | null;
64
75
  expandable?: boolean;
65
76
  expandedRows?: (string | number)[];
66
77
  expandSingle?: boolean;
67
78
  rowClass?: string | ((row: Row, index: number) => string);
68
79
  selectable?: boolean;
69
80
  selected?: Row[];
81
+ /** Row field (dot path) whose values split the rows into collapsible groups. */
82
+ groupBy?: string;
83
+ renderGroupLabel?: (value: unknown, rows: Row[]) => ReactNode;
84
+ /** Per column key: a subtotal under each group and a total row at the end. */
85
+ summary?: Partial<Record<string, TableSummaryKind | ((rows: Row[], column: TableColumn<Row>) => ReactNode)>>;
86
+ /** Shows computed summaries, for columns whose cells are drawn by renderCell rather than a column format. */
87
+ summaryFormat?: (value: number | null, column: TableColumn<Row>, kind: TableSummaryKind) => ReactNode;
70
88
  toolbar?: ReactNode;
71
89
  emptyContent?: ReactNode;
72
90
  renderCell?: (value: unknown, column: TableColumn<Row>, row: Row, index: number) => ReactNode;
@@ -84,8 +102,10 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
84
102
  onSearch?: (query: string) => void;
85
103
  onRetry?: () => void;
86
104
  }
87
- export declare function useTableModel<Row extends object>(props: TableProps<Row, unknown>): {
105
+ /** locale is the KjunProvider locale for text order; the platform wrapper passes it. */
106
+ export declare function useTableModel<Row extends object>(props: TableProps<Row, unknown>, locale?: string): {
88
107
  rows: Row[];
108
+ rowIndex: (row: Row) => number;
89
109
  key: (row: Row, index?: number) => string | number;
90
110
  sort: TableSort;
91
111
  search: string;
@@ -95,6 +115,8 @@ export declare function useTableModel<Row extends object>(props: TableProps<Row,
95
115
  expanded: (string | number)[];
96
116
  searchChange: (q: string) => void;
97
117
  sortColumn: (col: TableColumn<Row>) => void;
118
+ /** The narrow-screen sort choice: an exact key and order, or { key: "" } for the data's own order. */
119
+ sortTo: (next: TableSort) => void;
98
120
  toggleRow: (row: Row) => void | undefined;
99
121
  toggleAll: () => void | undefined;
100
122
  toggleExpand: (row: Row, index: number) => void;
@@ -1,6 +1,9 @@
1
1
  import { type TableSort, type QueryDisplayProps } from "@kjun-ui/tokens";
2
2
  export type { TableSort } from "@kjun-ui/tokens";
3
3
  import { type ReactNode } from "react";
4
+ import type { TableSummaryKind } from "./table-groups.js";
5
+ export type { TableSummaryKind } from "./table-groups.js";
6
+ import { type TableCompare } from "./table-model.js";
4
7
  export { getValue } from "./table-model.js";
5
8
  export interface TableColumn<Row extends object = Record<string, unknown>> {
6
9
  key: string;
@@ -9,6 +12,8 @@ export interface TableColumn<Row extends object = Record<string, unknown>> {
9
12
  width?: number | string;
10
13
  align?: "left" | "center" | "right";
11
14
  type?: "number" | "date" | "datetime" | "text";
15
+ /** The column's own sort order for two cell values (ascending); by default dates, numbers and text compare naturally. */
16
+ compare?: TableCompare;
12
17
  format?: (value: unknown, row: Row) => ReactNode;
13
18
  render?: (value: unknown, row: Row, index: number) => ReactNode;
14
19
  pill?: boolean;
@@ -51,22 +56,35 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
51
56
  searchable?: boolean;
52
57
  searchPlaceholder?: string;
53
58
  stickyHeader?: boolean;
59
+ /** Without maxHeight a sticky header sticks under the page scroll; this is its distance from the viewport top (px). */
60
+ stickyOffset?: number;
54
61
  maxHeight?: MaxHeight;
55
62
  pagination?: TablePagination | null;
56
63
  compact?: boolean;
57
64
  striped?: boolean;
58
65
  ariaLabel?: string;
59
- responsive?: "card" | "compact" | "none" | null;
66
+ responsive?: "card" | "list" | "compact" | "none" | null;
60
67
  mobileColumns?: string[];
61
68
  cardTitle?: string | null;
62
69
  cardSubtitle?: string | null;
63
70
  cardSections?: TableCardSection[];
71
+ /** Card shape on narrow screens: "stacked" (default) field grid, "rows" label-value lines, or "tiles" two small cards a row. */
72
+ cardLayout?: "stacked" | "rows" | "tiles";
73
+ /** Column shown large under the card's title (a total, a balance); tiles show it as their main value. */
74
+ cardHighlight?: string | null;
64
75
  expandable?: boolean;
65
76
  expandedRows?: (string | number)[];
66
77
  expandSingle?: boolean;
67
78
  rowClass?: string | ((row: Row, index: number) => string);
68
79
  selectable?: boolean;
69
80
  selected?: Row[];
81
+ /** Row field (dot path) whose values split the rows into collapsible groups. */
82
+ groupBy?: string;
83
+ renderGroupLabel?: (value: unknown, rows: Row[]) => ReactNode;
84
+ /** Per column key: a subtotal under each group and a total row at the end. */
85
+ summary?: Partial<Record<string, TableSummaryKind | ((rows: Row[], column: TableColumn<Row>) => ReactNode)>>;
86
+ /** Shows computed summaries, for columns whose cells are drawn by renderCell rather than a column format. */
87
+ summaryFormat?: (value: number | null, column: TableColumn<Row>, kind: TableSummaryKind) => ReactNode;
70
88
  toolbar?: ReactNode;
71
89
  emptyContent?: ReactNode;
72
90
  renderCell?: (value: unknown, column: TableColumn<Row>, row: Row, index: number) => ReactNode;
@@ -84,8 +102,10 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
84
102
  onSearch?: (query: string) => void;
85
103
  onRetry?: () => void;
86
104
  }
87
- export declare function useTableModel<Row extends object>(props: TableProps<Row, unknown>): {
105
+ /** locale is the KjunProvider locale for text order; the platform wrapper passes it. */
106
+ export declare function useTableModel<Row extends object>(props: TableProps<Row, unknown>, locale?: string): {
88
107
  rows: Row[];
108
+ rowIndex: (row: Row) => number;
89
109
  key: (row: Row, index?: number) => string | number;
90
110
  sort: TableSort;
91
111
  search: string;
@@ -95,6 +115,8 @@ export declare function useTableModel<Row extends object>(props: TableProps<Row,
95
115
  expanded: (string | number)[];
96
116
  searchChange: (q: string) => void;
97
117
  sortColumn: (col: TableColumn<Row>) => void;
118
+ /** The narrow-screen sort choice: an exact key and order, or { key: "" } for the data's own order. */
119
+ sortTo: (next: TableSort) => void;
98
120
  toggleRow: (row: Row) => void | undefined;
99
121
  toggleAll: () => void | undefined;
100
122
  toggleExpand: (row: Row, index: number) => void;
@@ -0,0 +1 @@
1
+ export declare function growTextarea(element: HTMLTextAreaElement | null, minimum: number, maximum: number): void;
@@ -0,0 +1 @@
1
+ export declare function growTextarea(element: HTMLTextAreaElement | null, minimum: number, maximum: number): void;
@@ -0,0 +1,53 @@
1
+ import { type InputSize } from "@kjun-ui/tokens";
2
+ export declare const textareaMaxRows = 6;
3
+ /** Border-box height for a number of text rows at a field size. */
4
+ export declare function textareaRowsHeight(size: InputSize, rows: number, footer?: boolean): number;
5
+ /** The [minimum, maximum] border-box height; a maximum below the minimum keeps the field at `rows`. */
6
+ export declare function textareaBounds(size: InputSize, rows: number, maxRows: number, footer?: boolean): readonly [
7
+ number,
8
+ number
9
+ ];
10
+ /** The counter text; it counts like the maxLength attribute (UTF-16 units), so it agrees with what typing allows. */
11
+ export declare function textareaCount(value: string, maxLength?: number): {
12
+ length: number;
13
+ text: string;
14
+ over: boolean;
15
+ };
16
+ export type TextareaResize = "none" | "vertical" | "horizontal" | "both";
17
+ /** A field the user can drag taller keeps the height they chose, so it does not also grow with its text. */
18
+ export declare const textareaGrows: (minimum: number, maximum: number, resize?: TextareaResize) => boolean;
19
+ /** The text inset: with a footer the wrapper carries the border, so the text keeps the field's own inset. */
20
+ export declare function textareaPadding(size: InputSize, footer: boolean): {
21
+ top: 16 | 12 | 8;
22
+ x: 20 | 16 | 12;
23
+ bottom: 4;
24
+ } | {
25
+ top: 16 | 12 | 8;
26
+ x: number;
27
+ bottom: 16 | 12 | 8;
28
+ };
29
+ /** Whether the composer may send: some text within maxLength, an enabled and editable field, nothing already sending. */
30
+ export declare function textareaCanSubmit({ value, maxLength, disabled, readOnly, submitting }: {
31
+ value: string | null | undefined;
32
+ maxLength?: number;
33
+ disabled?: boolean;
34
+ readOnly?: boolean;
35
+ submitting?: boolean;
36
+ }): boolean;
37
+ /** "mod-enter" sends on Ctrl/⌘+Enter; "enter" sends on Enter and leaves Shift+Enter for a new line. */
38
+ export type TextareaSubmitKey = "mod-enter" | "enter";
39
+ /**
40
+ * Whether this key press sends. Korean and other IME input confirm a syllable with Enter, and Safari reports that
41
+ * Enter with isComposing false but keyCode 229, so both mean "still composing".
42
+ */
43
+ export declare function textareaSubmitKey(event: {
44
+ key: string;
45
+ shiftKey?: boolean;
46
+ metaKey?: boolean;
47
+ ctrlKey?: boolean;
48
+ altKey?: boolean;
49
+ isComposing?: boolean;
50
+ keyCode?: number;
51
+ }, mode?: TextareaSubmitKey): boolean;
52
+ /** Characters left to announce near the limit (the last tenth, at least ten), or null while there is room. */
53
+ export declare function textareaRemaining(value: string, maxLength?: number): number | null;
@@ -0,0 +1,53 @@
1
+ import { type InputSize } from "@kjun-ui/tokens";
2
+ export declare const textareaMaxRows = 6;
3
+ /** Border-box height for a number of text rows at a field size. */
4
+ export declare function textareaRowsHeight(size: InputSize, rows: number, footer?: boolean): number;
5
+ /** The [minimum, maximum] border-box height; a maximum below the minimum keeps the field at `rows`. */
6
+ export declare function textareaBounds(size: InputSize, rows: number, maxRows: number, footer?: boolean): readonly [
7
+ number,
8
+ number
9
+ ];
10
+ /** The counter text; it counts like the maxLength attribute (UTF-16 units), so it agrees with what typing allows. */
11
+ export declare function textareaCount(value: string, maxLength?: number): {
12
+ length: number;
13
+ text: string;
14
+ over: boolean;
15
+ };
16
+ export type TextareaResize = "none" | "vertical" | "horizontal" | "both";
17
+ /** A field the user can drag taller keeps the height they chose, so it does not also grow with its text. */
18
+ export declare const textareaGrows: (minimum: number, maximum: number, resize?: TextareaResize) => boolean;
19
+ /** The text inset: with a footer the wrapper carries the border, so the text keeps the field's own inset. */
20
+ export declare function textareaPadding(size: InputSize, footer: boolean): {
21
+ top: 16 | 12 | 8;
22
+ x: 20 | 16 | 12;
23
+ bottom: 4;
24
+ } | {
25
+ top: 16 | 12 | 8;
26
+ x: number;
27
+ bottom: 16 | 12 | 8;
28
+ };
29
+ /** Whether the composer may send: some text within maxLength, an enabled and editable field, nothing already sending. */
30
+ export declare function textareaCanSubmit({ value, maxLength, disabled, readOnly, submitting }: {
31
+ value: string | null | undefined;
32
+ maxLength?: number;
33
+ disabled?: boolean;
34
+ readOnly?: boolean;
35
+ submitting?: boolean;
36
+ }): boolean;
37
+ /** "mod-enter" sends on Ctrl/⌘+Enter; "enter" sends on Enter and leaves Shift+Enter for a new line. */
38
+ export type TextareaSubmitKey = "mod-enter" | "enter";
39
+ /**
40
+ * Whether this key press sends. Korean and other IME input confirm a syllable with Enter, and Safari reports that
41
+ * Enter with isComposing false but keyCode 229, so both mean "still composing".
42
+ */
43
+ export declare function textareaSubmitKey(event: {
44
+ key: string;
45
+ shiftKey?: boolean;
46
+ metaKey?: boolean;
47
+ ctrlKey?: boolean;
48
+ altKey?: boolean;
49
+ isComposing?: boolean;
50
+ keyCode?: number;
51
+ }, mode?: TextareaSubmitKey): boolean;
52
+ /** Characters left to announce near the limit (the last tenth, at least ten), or null while there is room. */
53
+ export declare function textareaRemaining(value: string, maxLength?: number): number | null;
@@ -0,0 +1,25 @@
1
+ import type { createTimeDomain, TimePrecision } from "@kjun-ui/tokens";
2
+ import type { KjunMessages } from "./messages/ko.cjs";
3
+ type TimeDomain = ReturnType<typeof createTimeDomain>;
4
+ export type HourCycle = 12 | 24;
5
+ export type TimeSegmentOption = {
6
+ value: number;
7
+ label: string;
8
+ };
9
+ export interface TimeSegmentModel {
10
+ key: "period" | "hour" | "minute" | "second";
11
+ label: string;
12
+ value: number | null;
13
+ options: TimeSegmentOption[];
14
+ /** The time after choosing this option; the same value when nothing in the domain matches. */
15
+ pick: (option: number) => string | null;
16
+ }
17
+ export declare function timeSegments(domain: TimeDomain, value: string | null, { precision, hourCycle, messages, periodFirst }: {
18
+ precision: TimePrecision;
19
+ hourCycle?: HourCycle;
20
+ messages: KjunMessages;
21
+ periodFirst?: boolean;
22
+ }): TimeSegmentModel[];
23
+ /** Korean and other East Asian clocks put 오전/오후 before the hour; most others put AM/PM after it. */
24
+ export declare const periodLeads: (language?: string) => boolean;
25
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { createTimeDomain, TimePrecision } from "@kjun-ui/tokens";
2
+ import type { KjunMessages } from "./messages/ko.js";
3
+ type TimeDomain = ReturnType<typeof createTimeDomain>;
4
+ export type HourCycle = 12 | 24;
5
+ export type TimeSegmentOption = {
6
+ value: number;
7
+ label: string;
8
+ };
9
+ export interface TimeSegmentModel {
10
+ key: "period" | "hour" | "minute" | "second";
11
+ label: string;
12
+ value: number | null;
13
+ options: TimeSegmentOption[];
14
+ /** The time after choosing this option; the same value when nothing in the domain matches. */
15
+ pick: (option: number) => string | null;
16
+ }
17
+ export declare function timeSegments(domain: TimeDomain, value: string | null, { precision, hourCycle, messages, periodFirst }: {
18
+ precision: TimePrecision;
19
+ hourCycle?: HourCycle;
20
+ messages: KjunMessages;
21
+ periodFirst?: boolean;
22
+ }): TimeSegmentModel[];
23
+ /** Korean and other East Asian clocks put 오전/오후 before the hour; most others put AM/PM after it. */
24
+ export declare const periodLeads: (language?: string) => boolean;
25
+ export {};
@@ -0,0 +1,3 @@
1
+ /** Toasts that arrive within one stack move of the last arrival wait for it to finish, then enter together, so a burst
2
+ * shifts the stack once instead of once per toast. Returns how long the newest arrivals still wait (0 = none). */
3
+ export declare function toastEntryDelay(lastEntry: number, now: number, reduced: boolean): number;
@@ -0,0 +1,3 @@
1
+ /** Toasts that arrive within one stack move of the last arrival wait for it to finish, then enter together, so a burst
2
+ * shifts the stack once instead of once per toast. Returns how long the newest arrivals still wait (0 = none). */
3
+ export declare function toastEntryDelay(lastEntry: number, now: number, reduced: boolean): number;
@@ -0,0 +1,4 @@
1
+ /** Where KjunFeedbackProvider stacks toasts: the top (default) or the bottom of the screen, right-aligned on wide web. */
2
+ export type ToastPlacement = "top" | "bottom";
3
+ /** Toasts enter from, and leave toward, their screen edge. */
4
+ export declare const toastEdgeShift: (placement?: ToastPlacement) => number;
@@ -0,0 +1,4 @@
1
+ /** Where KjunFeedbackProvider stacks toasts: the top (default) or the bottom of the screen, right-aligned on wide web. */
2
+ export type ToastPlacement = "top" | "bottom";
3
+ /** Toasts enter from, and leave toward, their screen edge. */
4
+ export declare const toastEdgeShift: (placement?: ToastPlacement) => number;
@@ -0,0 +1,12 @@
1
+ import { type ToastItem } from "@kjun-ui/tokens";
2
+ export interface PresentedToast {
3
+ toast: ToastItem;
4
+ exiting: boolean;
5
+ born: number;
6
+ }
7
+ /** What the stacks draw from the controller's toasts: a leaving toast stays for its exit motion, and toasts that
8
+ * arrive within one stack move of the last arrival wait, then enter together. Framework wrappers only call sync. */
9
+ export declare function createToastPresence(publish: (items: PresentedToast[]) => void): {
10
+ sync: (toasts: ToastItem[], reduced: boolean) => void;
11
+ destroy(): void;
12
+ };
@@ -0,0 +1,12 @@
1
+ import { type ToastItem } from "@kjun-ui/tokens";
2
+ export interface PresentedToast {
3
+ toast: ToastItem;
4
+ exiting: boolean;
5
+ born: number;
6
+ }
7
+ /** What the stacks draw from the controller's toasts: a leaving toast stays for its exit motion, and toasts that
8
+ * arrive within one stack move of the last arrival wait, then enter together. Framework wrappers only call sync. */
9
+ export declare function createToastPresence(publish: (items: PresentedToast[]) => void): {
10
+ sync: (toasts: ToastItem[], reduced: boolean) => void;
11
+ destroy(): void;
12
+ };
@@ -0,0 +1,42 @@
1
+ import { type ToastItem } from "@kjun-ui/tokens";
2
+ export type ToastTone = "success" | "warning" | "danger" | "info";
3
+ /** What every platform draws for one toast; the views only render it. */
4
+ export declare function toastPresentation(toast: ToastItem): {
5
+ tone: ToastTone;
6
+ icon: string;
7
+ compact: boolean;
8
+ closable: boolean;
9
+ sideAction: boolean;
10
+ role: "alert" | "status";
11
+ live: "assertive" | "polite";
12
+ spoken: string;
13
+ };
14
+ /** A horizontal swipe past this distance closes the toast; a shorter one springs back. */
15
+ export declare const toastSwipeDistance: () => 64;
16
+ /** Swipe progress as the card's fade: fully visible at rest, half faded at the closing distance. */
17
+ export declare const toastSwipeOpacity: (dx: number) => number;
18
+ /** Order on screen, nearest the edge toasts enter from first: capsules, then cards, each newest first.
19
+ * The bottom placement mirrors it so the newest stays nearest its own edge. */
20
+ export declare function orderToasts<T extends {
21
+ toast: ToastItem;
22
+ }>(items: T[], placement?: "top" | "bottom"): T[];
23
+ export interface ToastStackItem {
24
+ toast: ToastItem;
25
+ exiting: boolean;
26
+ }
27
+ /** What a stack draws. Toasts waiting beyond maxToasts are counted, not drawn, until the stack is expanded. On a narrow
28
+ * screen several toasts also fold behind one front card (the newest danger toast, else the newest). */
29
+ export declare function toastStackLayout<T extends ToastStackItem>(items: T[], { placement, narrow, expanded }: {
30
+ placement?: "top" | "bottom";
31
+ narrow?: boolean;
32
+ expanded?: boolean;
33
+ }): {
34
+ items: T[];
35
+ folded: boolean;
36
+ behind: number;
37
+ toggle: boolean;
38
+ uniform: boolean;
39
+ unseen: T[];
40
+ };
41
+ /** Card edges drawn behind the stack's last card: one per waiting toast, at most two. */
42
+ export declare const toastPeekDepth: (behind: number) => number;
@@ -0,0 +1,42 @@
1
+ import { type ToastItem } from "@kjun-ui/tokens";
2
+ export type ToastTone = "success" | "warning" | "danger" | "info";
3
+ /** What every platform draws for one toast; the views only render it. */
4
+ export declare function toastPresentation(toast: ToastItem): {
5
+ tone: ToastTone;
6
+ icon: string;
7
+ compact: boolean;
8
+ closable: boolean;
9
+ sideAction: boolean;
10
+ role: "alert" | "status";
11
+ live: "assertive" | "polite";
12
+ spoken: string;
13
+ };
14
+ /** A horizontal swipe past this distance closes the toast; a shorter one springs back. */
15
+ export declare const toastSwipeDistance: () => 64;
16
+ /** Swipe progress as the card's fade: fully visible at rest, half faded at the closing distance. */
17
+ export declare const toastSwipeOpacity: (dx: number) => number;
18
+ /** Order on screen, nearest the edge toasts enter from first: capsules, then cards, each newest first.
19
+ * The bottom placement mirrors it so the newest stays nearest its own edge. */
20
+ export declare function orderToasts<T extends {
21
+ toast: ToastItem;
22
+ }>(items: T[], placement?: "top" | "bottom"): T[];
23
+ export interface ToastStackItem {
24
+ toast: ToastItem;
25
+ exiting: boolean;
26
+ }
27
+ /** What a stack draws. Toasts waiting beyond maxToasts are counted, not drawn, until the stack is expanded. On a narrow
28
+ * screen several toasts also fold behind one front card (the newest danger toast, else the newest). */
29
+ export declare function toastStackLayout<T extends ToastStackItem>(items: T[], { placement, narrow, expanded }: {
30
+ placement?: "top" | "bottom";
31
+ narrow?: boolean;
32
+ expanded?: boolean;
33
+ }): {
34
+ items: T[];
35
+ folded: boolean;
36
+ behind: number;
37
+ toggle: boolean;
38
+ uniform: boolean;
39
+ unseen: T[];
40
+ };
41
+ /** Card edges drawn behind the stack's last card: one per waiting toast, at most two. */
42
+ export declare const toastPeekDepth: (behind: number) => number;
@@ -0,0 +1,20 @@
1
+ /** Touch and pen swipes sideways on a web toast: past the distance it closes, short of it the card springs back.
2
+ * Vertical moves stay page scrolls, and presses on its buttons stay presses. */
3
+ export declare function attachToastSwipe(card: HTMLElement, { hold, release, close }: {
4
+ hold(): void;
5
+ release(): void;
6
+ close(): void;
7
+ }): () => void;
8
+ /** Focus returns to where it was when the toast appeared, but only if it is inside the leaving toast. */
9
+ export declare function restoreToastFocus(surface: HTMLElement | null, previous: Element | null): void;
10
+ /** The whole web stack holds still while a mouse pointer or focus is on any of its toasts, so cards never move under
11
+ * the hand reaching for them. Touch is left out: a tap sends no pointer-leave until the next tap elsewhere, which would
12
+ * freeze the stack. A press outside the stack calls `outside`, and Escape inside it calls `escape` (both fold it). */
13
+ export declare function attachToastStack(root: HTMLElement, { hold, release, outside, escape }: {
14
+ hold(reason: "pointer" | "focus"): void;
15
+ release(reason: "pointer" | "focus"): void;
16
+ outside(): void;
17
+ escape(): boolean;
18
+ }): () => void;
19
+ /** A swipe that closes a card carries it on in the swipe's direction instead of the usual exit toward the edge. */
20
+ export declare function flingToast(card: HTMLElement, dx: number): void;
@@ -0,0 +1,20 @@
1
+ /** Touch and pen swipes sideways on a web toast: past the distance it closes, short of it the card springs back.
2
+ * Vertical moves stay page scrolls, and presses on its buttons stay presses. */
3
+ export declare function attachToastSwipe(card: HTMLElement, { hold, release, close }: {
4
+ hold(): void;
5
+ release(): void;
6
+ close(): void;
7
+ }): () => void;
8
+ /** Focus returns to where it was when the toast appeared, but only if it is inside the leaving toast. */
9
+ export declare function restoreToastFocus(surface: HTMLElement | null, previous: Element | null): void;
10
+ /** The whole web stack holds still while a mouse pointer or focus is on any of its toasts, so cards never move under
11
+ * the hand reaching for them. Touch is left out: a tap sends no pointer-leave until the next tap elsewhere, which would
12
+ * freeze the stack. A press outside the stack calls `outside`, and Escape inside it calls `escape` (both fold it). */
13
+ export declare function attachToastStack(root: HTMLElement, { hold, release, outside, escape }: {
14
+ hold(reason: "pointer" | "focus"): void;
15
+ release(reason: "pointer" | "focus"): void;
16
+ outside(): void;
17
+ escape(): boolean;
18
+ }): () => void;
19
+ /** A swipe that closes a card carries it on in the swipe's direction instead of the usual exit toward the edge. */
20
+ export declare function flingToast(card: HTMLElement, dx: number): void;