@kjun-ui/react 0.18.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 (76) hide show
  1. package/dist/index.cjs +1911 -1281
  2. package/dist/index.js +1998 -1366
  3. package/dist/styles.css +644 -411
  4. package/dist/types/packages/react/src/app-navigation.d.cts +12 -8
  5. package/dist/types/packages/react/src/app-navigation.d.ts +12 -8
  6. package/dist/types/packages/react/src/display.d.cts +8 -2
  7. package/dist/types/packages/react/src/display.d.ts +8 -2
  8. package/dist/types/packages/react/src/drawer.d.cts +3 -5
  9. package/dist/types/packages/react/src/drawer.d.ts +3 -5
  10. package/dist/types/packages/react/src/fab.d.cts +3 -3
  11. package/dist/types/packages/react/src/fab.d.ts +3 -3
  12. package/dist/types/packages/react/src/feedback.d.cts +12 -3
  13. package/dist/types/packages/react/src/feedback.d.ts +12 -3
  14. package/dist/types/packages/react/src/index.d.cts +2 -0
  15. package/dist/types/packages/react/src/index.d.ts +2 -0
  16. package/dist/types/packages/react/src/layout-primitives.d.cts +24 -24
  17. package/dist/types/packages/react/src/layout-primitives.d.ts +24 -24
  18. package/dist/types/packages/react/src/modal.d.cts +3 -1
  19. package/dist/types/packages/react/src/modal.d.ts +3 -1
  20. package/dist/types/packages/react/src/provider.d.cts +4 -1
  21. package/dist/types/packages/react/src/provider.d.ts +4 -1
  22. package/dist/types/packages/react/src/skeleton-phase.d.cts +2 -0
  23. package/dist/types/packages/react/src/skeleton-phase.d.ts +2 -0
  24. package/dist/types/packages/react/src/skeletons.d.cts +19 -4
  25. package/dist/types/packages/react/src/skeletons.d.ts +19 -4
  26. package/dist/types/packages/react/src/table-cards.d.cts +6 -3
  27. package/dist/types/packages/react/src/table-cards.d.ts +6 -3
  28. package/dist/types/packages/react/src/table-list.d.cts +2 -6
  29. package/dist/types/packages/react/src/table-list.d.ts +2 -6
  30. package/dist/types/packages/react/src/table-model.d.cts +1 -0
  31. package/dist/types/packages/react/src/table-model.d.ts +1 -0
  32. package/dist/types/packages/react/src/table-toolbar.d.cts +1 -1
  33. package/dist/types/packages/react/src/table-toolbar.d.ts +1 -1
  34. package/dist/types/packages/react/src/table-totals.d.cts +5 -0
  35. package/dist/types/packages/react/src/table-totals.d.ts +5 -0
  36. package/dist/types/packages/react/src/toast-stack.d.cts +7 -2
  37. package/dist/types/packages/react/src/toast-stack.d.ts +7 -2
  38. package/dist/types/shared/package-runtime/chart-skeleton.d.cts +15 -3
  39. package/dist/types/shared/package-runtime/chart-skeleton.d.ts +15 -3
  40. package/dist/types/shared/package-runtime/drawer-geometry.d.cts +2 -3
  41. package/dist/types/shared/package-runtime/drawer-geometry.d.ts +2 -3
  42. package/dist/types/shared/package-runtime/feedback-dialog.d.cts +5 -4
  43. package/dist/types/shared/package-runtime/feedback-dialog.d.ts +5 -4
  44. package/dist/types/shared/package-runtime/feedback-motion.d.cts +2 -5
  45. package/dist/types/shared/package-runtime/feedback-motion.d.ts +2 -5
  46. package/dist/types/shared/package-runtime/feedback-prompt.d.cts +58 -0
  47. package/dist/types/shared/package-runtime/feedback-prompt.d.ts +58 -0
  48. package/dist/types/shared/package-runtime/market-layout.d.cts +0 -1
  49. package/dist/types/shared/package-runtime/market-layout.d.ts +0 -1
  50. package/dist/types/shared/package-runtime/messages/ko.d.cts +7 -0
  51. package/dist/types/shared/package-runtime/messages/ko.d.ts +7 -0
  52. package/dist/types/shared/package-runtime/messages-context.d.cts +7 -0
  53. package/dist/types/shared/package-runtime/messages-context.d.ts +7 -0
  54. package/dist/types/shared/package-runtime/safe-area.d.cts +20 -0
  55. package/dist/types/shared/package-runtime/safe-area.d.ts +20 -0
  56. package/dist/types/shared/package-runtime/skeleton-text.d.cts +12 -0
  57. package/dist/types/shared/package-runtime/skeleton-text.d.ts +12 -0
  58. package/dist/types/shared/package-runtime/stable-value.d.cts +3 -0
  59. package/dist/types/shared/package-runtime/stable-value.d.ts +3 -0
  60. package/dist/types/shared/package-runtime/table-presentation.d.cts +38 -2
  61. package/dist/types/shared/package-runtime/table-presentation.d.ts +38 -2
  62. package/dist/types/shared/package-runtime/table.d.cts +6 -0
  63. package/dist/types/shared/package-runtime/table.d.ts +6 -0
  64. package/dist/types/shared/package-runtime/toast-entry.d.cts +3 -0
  65. package/dist/types/shared/package-runtime/toast-entry.d.ts +3 -0
  66. package/dist/types/shared/package-runtime/toast-placement.d.cts +4 -0
  67. package/dist/types/shared/package-runtime/toast-placement.d.ts +4 -0
  68. package/dist/types/shared/package-runtime/toast-presence.d.cts +12 -0
  69. package/dist/types/shared/package-runtime/toast-presence.d.ts +12 -0
  70. package/dist/types/shared/package-runtime/toast-presentation.d.cts +42 -0
  71. package/dist/types/shared/package-runtime/toast-presentation.d.ts +42 -0
  72. package/dist/types/shared/package-runtime/toast-swipe.d.cts +20 -0
  73. package/dist/types/shared/package-runtime/toast-swipe.d.ts +20 -0
  74. package/dist/types/shared/package-runtime/use-toast-stack.d.cts +22 -0
  75. package/dist/types/shared/package-runtime/use-toast-stack.d.ts +22 -0
  76. package/package.json +3 -3
@@ -13,9 +13,14 @@ export declare const useKjunMessages: () => {
13
13
  save: string;
14
14
  close: string;
15
15
  closeNotification: string;
16
+ notifications: string;
17
+ moreNotifications: (count: number) => string;
18
+ showNotifications: string;
19
+ collapseNotifications: string;
16
20
  confirmTitle: string;
17
21
  promptTitle: string;
18
22
  invalidInput: string;
23
+ typeToConfirm: (value: string) => string;
19
24
  dialog: string;
20
25
  panel: string;
21
26
  details: string;
@@ -110,6 +115,8 @@ export declare const useKjunMessages: () => {
110
115
  collapse: string;
111
116
  showDetails: string;
112
117
  ascending: string;
118
+ sortBy: string;
119
+ defaultOrder: string;
113
120
  descending: string;
114
121
  tabs: string;
115
122
  showPath: string;
@@ -0,0 +1,20 @@
1
+ export interface KjunSafeArea {
2
+ /** Top inset in px (status bar, notch). */
3
+ top?: number;
4
+ /** Bottom inset in px (home indicator). */
5
+ bottom?: number;
6
+ }
7
+ export interface ResolvedSafeArea {
8
+ top: number;
9
+ bottom: number;
10
+ }
11
+ /** A provider's own values, else the parent's, never negative. */
12
+ export declare function resolveSafeArea(area?: KjunSafeArea, parent?: ResolvedSafeArea): ResolvedSafeArea;
13
+ /**
14
+ * Web: a provider that receives a safe area writes it as CSS variables; without one, components fall back to the
15
+ * browser's env(safe-area-inset-*) (which needs viewport-fit=cover). Nested providers inherit their parent's values.
16
+ */
17
+ export declare function safeAreaVars(area?: KjunSafeArea): Record<string, string>;
18
+ /** The web inset for an edge component; safeArea={false} drops it where the app already reserved the space. */
19
+ export declare const webSafeTop: (on?: boolean) => "var(--_kjun-safe-area-top)" | "0px";
20
+ export declare const webSafeBottom: (on?: boolean) => "0px" | "var(--_kjun-safe-area-bottom)";
@@ -0,0 +1,20 @@
1
+ export interface KjunSafeArea {
2
+ /** Top inset in px (status bar, notch). */
3
+ top?: number;
4
+ /** Bottom inset in px (home indicator). */
5
+ bottom?: number;
6
+ }
7
+ export interface ResolvedSafeArea {
8
+ top: number;
9
+ bottom: number;
10
+ }
11
+ /** A provider's own values, else the parent's, never negative. */
12
+ export declare function resolveSafeArea(area?: KjunSafeArea, parent?: ResolvedSafeArea): ResolvedSafeArea;
13
+ /**
14
+ * Web: a provider that receives a safe area writes it as CSS variables; without one, components fall back to the
15
+ * browser's env(safe-area-inset-*) (which needs viewport-fit=cover). Nested providers inherit their parent's values.
16
+ */
17
+ export declare function safeAreaVars(area?: KjunSafeArea): Record<string, string>;
18
+ /** The web inset for an edge component; safeArea={false} drops it where the app already reserved the space. */
19
+ export declare const webSafeTop: (on?: boolean) => "var(--_kjun-safe-area-top)" | "0px";
20
+ export declare const webSafeBottom: (on?: boolean) => "0px" | "var(--_kjun-safe-area-bottom)";
@@ -0,0 +1,12 @@
1
+ import { type TypographyRole } from "@kjun-ui/tokens";
2
+ type Percent = `${number}%`;
3
+ /** A paragraph that does not look like every other one, with a short last line. */
4
+ export declare function skeletonTextWidths(rows: number): Percent[];
5
+ /** The web line box of a type role; without a role the line takes the surrounding text's line height. */
6
+ export declare function skeletonLineBox(role?: TypographyRole): string;
7
+ /**
8
+ * A negative animation delay that puts a skeleton mounted now on the same pulse as every other one,
9
+ * so skeletons that appear at different times still brighten and dim together.
10
+ */
11
+ export declare function skeletonPhase(now?: number): string;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ import { type TypographyRole } from "@kjun-ui/tokens";
2
+ type Percent = `${number}%`;
3
+ /** A paragraph that does not look like every other one, with a short last line. */
4
+ export declare function skeletonTextWidths(rows: number): Percent[];
5
+ /** The web line box of a type role; without a role the line takes the surrounding text's line height. */
6
+ export declare function skeletonLineBox(role?: TypographyRole): string;
7
+ /**
8
+ * A negative animation delay that puts a skeleton mounted now on the same pulse as every other one,
9
+ * so skeletons that appear at different times still brighten and dim together.
10
+ */
11
+ export declare function skeletonPhase(now?: number): string;
12
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function shallowEqual(a: unknown, b: unknown): boolean;
2
+ /** Returns the last value passed in while new values stay shallowly equal to it. */
3
+ export declare function stableValue<T>(): (next: T) => T;
@@ -0,0 +1,3 @@
1
+ export declare function shallowEqual(a: unknown, b: unknown): boolean;
2
+ /** Returns the last value passed in while new values stay shallowly equal to it. */
3
+ export declare function stableValue<T>(): (next: T) => T;
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { TableColumn, TableCardSection, TableProps, useTableModel } from "./table.cjs";
2
+ import type { TableColumn, TableCardSection, TableProps, TableSort, useTableModel } from "./table.cjs";
3
3
  import { type TableRowGroup } from "./table-groups.cjs";
4
4
  export declare function tablePresentation<Row extends object>(props: TableProps<Row, unknown>, mobile: boolean): {
5
5
  card: boolean;
@@ -13,8 +13,28 @@ export declare function tablePresentation<Row extends object>(props: TableProps<
13
13
  actions: TableColumn<Row> | undefined;
14
14
  inline: TableColumn<Row>[];
15
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";
16
25
  columnsForSection(row: Row, section: TableCardSection): TableColumn<Row>[];
17
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;
18
38
  export declare function columnFormat<Format>(column: {
19
39
  key: string;
20
40
  format?: Format;
@@ -33,6 +53,8 @@ export interface TableTotal {
33
53
  value: ReactNode;
34
54
  }
35
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;
36
58
  export interface TableGroupingProps<Row extends object> {
37
59
  groups: TableRowGroup<Row>[] | null;
38
60
  collapsed: string[];
@@ -40,7 +62,8 @@ export interface TableGroupingProps<Row extends object> {
40
62
  groupLabel: (group: TableRowGroup<Row>) => ReactNode;
41
63
  summary: ((column: TableColumn<Row>, rows: Row[]) => ReactNode) | null;
42
64
  }
43
- export type TableCellRole = "title" | "listTitle" | "listMeta" | "listValue";
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";
44
67
  export interface TableRowsProps<Row extends object> {
45
68
  initialLoading: boolean;
46
69
  skeletonRows: number;
@@ -60,6 +83,12 @@ export interface TableRowsProps<Row extends object> {
60
83
  export interface TableCardsProps<Row extends object> extends TableRowsProps<Row> {
61
84
  layout: ReturnType<typeof tablePresentation<Row>>;
62
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;
63
92
  }
64
93
  export interface TableGridProps<Row extends object, Height> extends TableRowsProps<Row>, TableGroupingProps<Row> {
65
94
  state: TableRowsProps<Row>["state"] & Pick<ReturnType<typeof useTableModel<Row>>, "all" | "some" | "toggleAll" | "sort" | "sortColumn">;
@@ -85,4 +114,11 @@ export interface TableToolbarProps<Row extends object> {
85
114
  searchChange: (value: string) => void;
86
115
  searchPlaceholder: string;
87
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;
88
124
  }
@@ -1,5 +1,5 @@
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
3
  import { type TableRowGroup } from "./table-groups.js";
4
4
  export declare function tablePresentation<Row extends object>(props: TableProps<Row, unknown>, mobile: boolean): {
5
5
  card: boolean;
@@ -13,8 +13,28 @@ export declare function tablePresentation<Row extends object>(props: TableProps<
13
13
  actions: TableColumn<Row> | undefined;
14
14
  inline: TableColumn<Row>[];
15
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";
16
25
  columnsForSection(row: Row, section: TableCardSection): TableColumn<Row>[];
17
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;
18
38
  export declare function columnFormat<Format>(column: {
19
39
  key: string;
20
40
  format?: Format;
@@ -33,6 +53,8 @@ export interface TableTotal {
33
53
  value: ReactNode;
34
54
  }
35
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;
36
58
  export interface TableGroupingProps<Row extends object> {
37
59
  groups: TableRowGroup<Row>[] | null;
38
60
  collapsed: string[];
@@ -40,7 +62,8 @@ export interface TableGroupingProps<Row extends object> {
40
62
  groupLabel: (group: TableRowGroup<Row>) => ReactNode;
41
63
  summary: ((column: TableColumn<Row>, rows: Row[]) => ReactNode) | null;
42
64
  }
43
- export type TableCellRole = "title" | "listTitle" | "listMeta" | "listValue";
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";
44
67
  export interface TableRowsProps<Row extends object> {
45
68
  initialLoading: boolean;
46
69
  skeletonRows: number;
@@ -60,6 +83,12 @@ export interface TableRowsProps<Row extends object> {
60
83
  export interface TableCardsProps<Row extends object> extends TableRowsProps<Row> {
61
84
  layout: ReturnType<typeof tablePresentation<Row>>;
62
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;
63
92
  }
64
93
  export interface TableGridProps<Row extends object, Height> extends TableRowsProps<Row>, TableGroupingProps<Row> {
65
94
  state: TableRowsProps<Row>["state"] & Pick<ReturnType<typeof useTableModel<Row>>, "all" | "some" | "toggleAll" | "sort" | "sortColumn">;
@@ -85,4 +114,11 @@ export interface TableToolbarProps<Row extends object> {
85
114
  searchChange: (value: string) => void;
86
115
  searchPlaceholder: string;
87
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;
88
124
  }
@@ -68,6 +68,10 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
68
68
  cardTitle?: string | null;
69
69
  cardSubtitle?: string | null;
70
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;
71
75
  expandable?: boolean;
72
76
  expandedRows?: (string | number)[];
73
77
  expandSingle?: boolean;
@@ -111,6 +115,8 @@ export declare function useTableModel<Row extends object>(props: TableProps<Row,
111
115
  expanded: (string | number)[];
112
116
  searchChange: (q: string) => void;
113
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;
114
120
  toggleRow: (row: Row) => void | undefined;
115
121
  toggleAll: () => void | undefined;
116
122
  toggleExpand: (row: Row, index: number) => void;
@@ -68,6 +68,10 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
68
68
  cardTitle?: string | null;
69
69
  cardSubtitle?: string | null;
70
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;
71
75
  expandable?: boolean;
72
76
  expandedRows?: (string | number)[];
73
77
  expandSingle?: boolean;
@@ -111,6 +115,8 @@ export declare function useTableModel<Row extends object>(props: TableProps<Row,
111
115
  expanded: (string | number)[];
112
116
  searchChange: (q: string) => void;
113
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;
114
120
  toggleRow: (row: Row) => void | undefined;
115
121
  toggleAll: () => void | undefined;
116
122
  toggleExpand: (row: Row, index: number) => void;
@@ -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;
@@ -0,0 +1,22 @@
1
+ import type { createFeedbackController } from "@kjun-ui/tokens";
2
+ import type { PresentedToast } from "./toast-presence.cjs";
3
+ type Controller = ReturnType<typeof createFeedbackController>;
4
+ /** Stack state shared by the React and Native stacks: what to draw, whether it is expanded, and what screen readers
5
+ * should hear about toasts that are folded or waiting and so have no card of their own to announce them. */
6
+ export declare function useToastStack(items: PresentedToast[], controller: Controller, { placement, narrow }: {
7
+ placement: "top" | "bottom";
8
+ narrow: boolean;
9
+ }): {
10
+ stack: {
11
+ items: PresentedToast[];
12
+ folded: boolean;
13
+ behind: number;
14
+ toggle: boolean;
15
+ uniform: boolean;
16
+ unseen: PresentedToast[];
17
+ };
18
+ expanded: boolean;
19
+ setExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
20
+ announcement: string;
21
+ };
22
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { createFeedbackController } from "@kjun-ui/tokens";
2
+ import type { PresentedToast } from "./toast-presence.js";
3
+ type Controller = ReturnType<typeof createFeedbackController>;
4
+ /** Stack state shared by the React and Native stacks: what to draw, whether it is expanded, and what screen readers
5
+ * should hear about toasts that are folded or waiting and so have no card of their own to announce them. */
6
+ export declare function useToastStack(items: PresentedToast[], controller: Controller, { placement, narrow }: {
7
+ placement: "top" | "bottom";
8
+ narrow: boolean;
9
+ }): {
10
+ stack: {
11
+ items: PresentedToast[];
12
+ folded: boolean;
13
+ behind: number;
14
+ toggle: boolean;
15
+ uniform: boolean;
16
+ unseen: PresentedToast[];
17
+ };
18
+ expanded: boolean;
19
+ setExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
20
+ announcement: string;
21
+ };
22
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kjun-ui/react",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://ui.kjun.dev",
6
6
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "dependencies": {
44
- "@kjun-ui/tokens": "0.18.0",
44
+ "@kjun-ui/tokens": "0.19.0",
45
45
  "react-aria-components": "1.21.1",
46
- "@kjun-ui/icons": "0.18.0"
46
+ "@kjun-ui/icons": "0.19.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": "^19.2.3",