@alulore/kumiko 0.18.2 → 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 (147) hide show
  1. package/dist/dialog/ask.d.ts +7 -0
  2. package/dist/dialog/ask.js +8 -0
  3. package/dist/dialog/dialog-content.d.ts +23 -0
  4. package/dist/dialog/dialog-content.js +15 -0
  5. package/dist/dialog/dialog-entry.d.ts +14 -0
  6. package/dist/dialog/dialog-entry.js +111 -0
  7. package/dist/dialog/dialog-labels.d.ts +23 -0
  8. package/dist/dialog/dialog-labels.js +16 -0
  9. package/dist/dialog/dialog-store.d.ts +139 -0
  10. package/dist/dialog/dialog-store.js +296 -0
  11. package/dist/dialog/dialog.css +39 -1
  12. package/dist/dialog/dialog.d.ts +0 -3
  13. package/dist/dialog/dialog.js +0 -6
  14. package/dist/dialog/index.d.ts +8 -2
  15. package/dist/dialog/index.js +7 -2
  16. package/dist/dialog/leave-guard.d.ts +24 -0
  17. package/dist/dialog/leave-guard.js +98 -0
  18. package/dist/dialog/nest.d.ts +14 -0
  19. package/dist/dialog/nest.js +26 -0
  20. package/dist/dialog/open-dialog.d.ts +16 -0
  21. package/dist/dialog/open-dialog.js +13 -0
  22. package/dist/dialog/overlay-host.d.ts +27 -0
  23. package/dist/dialog/overlay-host.js +47 -0
  24. package/dist/dialog/question-dialog.d.ts +21 -0
  25. package/dist/dialog/question-dialog.js +78 -0
  26. package/dist/drawer/drawer.css +18 -16
  27. package/dist/menu/menu.css +21 -17
  28. package/dist/otp-input/otp-input.css +38 -37
  29. package/dist/page/index.d.ts +8 -0
  30. package/dist/page/index.js +8 -0
  31. package/dist/page/page-action.d.ts +26 -0
  32. package/dist/page/page-action.js +23 -0
  33. package/dist/page/page-actions.d.ts +10 -0
  34. package/dist/page/page-actions.js +66 -0
  35. package/dist/page/page-back.d.ts +11 -0
  36. package/dist/page/page-back.js +17 -0
  37. package/dist/page/page-breadcrumbs.d.ts +21 -0
  38. package/dist/page/page-breadcrumbs.js +60 -0
  39. package/dist/page/page-context.d.ts +5 -0
  40. package/dist/page/page-context.js +13 -0
  41. package/dist/page/page-fit.d.ts +26 -0
  42. package/dist/page/page-fit.js +36 -0
  43. package/dist/page/page-header.d.ts +26 -0
  44. package/dist/page/page-header.js +16 -0
  45. package/dist/page/page-icons.d.ts +4 -0
  46. package/dist/page/page-icons.js +13 -0
  47. package/dist/page/page-labels.d.ts +12 -0
  48. package/dist/page/page-labels.js +6 -0
  49. package/dist/page/page-section.d.ts +14 -0
  50. package/dist/page/page-section.js +9 -0
  51. package/dist/page/page.css +422 -0
  52. package/dist/page/page.d.ts +16 -0
  53. package/dist/page/page.js +12 -0
  54. package/dist/page/use-measured-fit.d.ts +22 -0
  55. package/dist/page/use-measured-fit.js +75 -0
  56. package/dist/page/use-stuck.d.ts +7 -0
  57. package/dist/page/use-stuck.js +31 -0
  58. package/dist/pagination/index.d.ts +3 -0
  59. package/dist/pagination/index.js +3 -0
  60. package/dist/pagination/pagination-extras.d.ts +28 -0
  61. package/dist/pagination/pagination-extras.js +42 -0
  62. package/dist/pagination/pagination-fit.d.ts +15 -0
  63. package/dist/pagination/pagination-fit.js +52 -0
  64. package/dist/pagination/pagination-icons.d.ts +4 -0
  65. package/dist/pagination/pagination-icons.js +16 -0
  66. package/dist/pagination/pagination-labels.d.ts +23 -0
  67. package/dist/pagination/pagination-labels.js +14 -0
  68. package/dist/pagination/pagination-math.d.ts +7 -0
  69. package/dist/pagination/pagination-math.js +24 -0
  70. package/dist/pagination/pagination-motion.d.ts +6 -0
  71. package/dist/pagination/pagination-motion.js +71 -0
  72. package/dist/pagination/pagination.css +455 -0
  73. package/dist/pagination/pagination.d.ts +59 -0
  74. package/dist/pagination/pagination.js +77 -0
  75. package/dist/select/select.css +6 -10
  76. package/dist/server-render.test.js +49 -0
  77. package/dist/sidebar/app-shell.d.ts +54 -0
  78. package/dist/sidebar/app-shell.js +28 -0
  79. package/dist/sidebar/index.d.ts +9 -0
  80. package/dist/sidebar/index.js +8 -0
  81. package/dist/sidebar/shell-context.d.ts +30 -0
  82. package/dist/sidebar/shell-context.js +20 -0
  83. package/dist/sidebar/shell-sheet.d.ts +7 -0
  84. package/dist/sidebar/shell-sheet.js +12 -0
  85. package/dist/sidebar/shell-top-bar.d.ts +8 -0
  86. package/dist/sidebar/shell-top-bar.js +25 -0
  87. package/dist/sidebar/sidebar-body.d.ts +5 -0
  88. package/dist/sidebar/sidebar-body.js +37 -0
  89. package/dist/sidebar/sidebar-icons.d.ts +4 -0
  90. package/dist/sidebar/sidebar-icons.js +13 -0
  91. package/dist/sidebar/sidebar-item.d.ts +26 -0
  92. package/dist/sidebar/sidebar-item.js +68 -0
  93. package/dist/sidebar/sidebar-labels.d.ts +14 -0
  94. package/dist/sidebar/sidebar-labels.js +7 -0
  95. package/dist/sidebar/sidebar-marker.d.ts +12 -0
  96. package/dist/sidebar/sidebar-marker.js +77 -0
  97. package/dist/sidebar/sidebar-storage.d.ts +18 -0
  98. package/dist/sidebar/sidebar-storage.js +27 -0
  99. package/dist/sidebar/sidebar-toggle.d.ts +7 -0
  100. package/dist/sidebar/sidebar-toggle.js +18 -0
  101. package/dist/sidebar/sidebar.css +587 -0
  102. package/dist/sidebar/sidebar.d.ts +19 -0
  103. package/dist/sidebar/sidebar.js +31 -0
  104. package/dist/sidebar/use-collapsed.d.ts +13 -0
  105. package/dist/sidebar/use-collapsed.js +20 -0
  106. package/dist/sidebar/use-narrow.d.ts +4 -0
  107. package/dist/sidebar/use-narrow.js +18 -0
  108. package/dist/sidebar/use-shell-focus.d.ts +8 -0
  109. package/dist/sidebar/use-shell-focus.js +30 -0
  110. package/dist/sidebar/use-shell-shortcut.d.ts +4 -0
  111. package/dist/sidebar/use-shell-shortcut.js +32 -0
  112. package/dist/sidebar/use-shell-state.d.ts +18 -0
  113. package/dist/sidebar/use-shell-state.js +47 -0
  114. package/dist/slider/slider.css +9 -6
  115. package/dist/smooth-caret/caret-geometry.js +10 -4
  116. package/dist/table/data-table-props.d.ts +96 -0
  117. package/dist/table/data-table-props.js +1 -0
  118. package/dist/table/data-table.d.ts +7 -0
  119. package/dist/table/data-table.js +59 -0
  120. package/dist/table/index.d.ts +7 -0
  121. package/dist/table/index.js +5 -0
  122. package/dist/table/table-actions.d.ts +9 -0
  123. package/dist/table/table-actions.js +24 -0
  124. package/dist/table/table-builder.d.ts +60 -0
  125. package/dist/table/table-builder.js +99 -0
  126. package/dist/table/table-cells.d.ts +19 -0
  127. package/dist/table/table-cells.js +67 -0
  128. package/dist/table/table-columns.d.ts +38 -0
  129. package/dist/table/table-columns.js +119 -0
  130. package/dist/table/table-icons.d.ts +3 -0
  131. package/dist/table/table-icons.js +8 -0
  132. package/dist/table/table-labels.d.ts +24 -0
  133. package/dist/table/table-labels.js +17 -0
  134. package/dist/table/table-model.d.ts +28 -0
  135. package/dist/table/table-model.js +69 -0
  136. package/dist/table/table-sections.d.ts +25 -0
  137. package/dist/table/table-sections.js +79 -0
  138. package/dist/table/table-state.d.ts +42 -0
  139. package/dist/table/table-state.js +81 -0
  140. package/dist/table/table-types.d.ts +86 -0
  141. package/dist/table/table-types.js +1 -0
  142. package/dist/table/table.css +919 -0
  143. package/dist/table/use-table-view.d.ts +30 -0
  144. package/dist/table/use-table-view.js +147 -0
  145. package/dist/toast/index.d.ts +1 -2
  146. package/dist/toast/index.js +1 -2
  147. package/package.json +44 -1
@@ -0,0 +1,30 @@
1
+ import type { DataTableProps, PagingOptions } from "./data-table-props";
2
+ import { type TableLabels } from "./table-labels";
3
+ import { type TableEvent } from "./table-state";
4
+ import type { TableBody, TableColumn, TableState } from "./table-types";
5
+ export interface PageRow<Row> {
6
+ id: string;
7
+ row: Row;
8
+ }
9
+ /** Everything the parts of the table draw, worked out in one place from the props and the state. */
10
+ export interface TableView<Row extends object> {
11
+ words: TableLabels;
12
+ format: (value: number) => string;
13
+ state: TableState;
14
+ dispatch: (event: TableEvent) => void;
15
+ dataColumns: TableColumn<Row>[];
16
+ pageRows: PageRow<Row>[];
17
+ total: number;
18
+ pageCount: number;
19
+ page: number;
20
+ body: TableBody;
21
+ paging: PagingOptions | false;
22
+ selectedCount: number;
23
+ selectedRows: Row[];
24
+ pageSelected: "none" | "some" | "all";
25
+ rowName: (row: Row) => string;
26
+ linkColumnId: string | undefined;
27
+ loadingRows: number;
28
+ }
29
+ /** Works out what the table shows: the page's rows, the counts, the selection and the body. */
30
+ export declare function useTableView<Row extends object>(props: DataTableProps<Row>): TableView<Row>;
@@ -0,0 +1,147 @@
1
+ import { announce } from "@ui-sdk/core";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { isActionsColumn } from "./table-columns";
4
+ import { tableLabels } from "./table-labels";
5
+ import { useTableModel } from "./table-model";
6
+ import { bodyOf, changeOf, nextState, pageSelection, shownPage } from "./table-state";
7
+ function defaultRowId(row) {
8
+ if ("id" in row && (typeof row.id === "string" || typeof row.id === "number")) {
9
+ return String(row.id);
10
+ }
11
+ throw new Error("DataTable: the rows have no string or number `id`. Pass the `rowId` prop.");
12
+ }
13
+ function startState(props) {
14
+ const paging = props.paging === false ? undefined : props.paging;
15
+ return {
16
+ sort: props.sort?.initial ?? [],
17
+ search: "",
18
+ page: 1,
19
+ pageSize: paging?.pageSize ?? paging?.pageSizes?.[0] ?? 20,
20
+ selected: [],
21
+ ...props.defaultState
22
+ };
23
+ }
24
+ /**
25
+ * The one state value and the one way to change it: events through `nextState`. Each event builds on the
26
+ * latest state, even when two arrive in the same moment, as a new page size followed by the page step does.
27
+ */
28
+ function useTableState(props) {
29
+ const [own, setOwn] = useState(() => startState(props));
30
+ const state = props.state ?? own;
31
+ const latest = useRef(state);
32
+ const rendered = useRef(state);
33
+ latest.current = state;
34
+ rendered.current = state;
35
+ const multi = props.sort?.multi ?? false;
36
+ const dispatch = (event) => {
37
+ const next = nextState(latest.current, event, multi);
38
+ if (next === latest.current) {
39
+ return next;
40
+ }
41
+ latest.current = next;
42
+ if (props.state === undefined) {
43
+ setOwn(next);
44
+ }
45
+ else {
46
+ // A parent may reject the change: once this moment is over, build on what it passes back.
47
+ queueMicrotask(() => {
48
+ latest.current = rendered.current;
49
+ });
50
+ }
51
+ props.onStateChange?.(next, changeOf[event.type]);
52
+ return next;
53
+ };
54
+ return { state, dispatch };
55
+ }
56
+ /** Reads out the result count after a search changes it. A sort is announced where it is pressed. */
57
+ function useSearchAnnouncement(search, total, say) {
58
+ const previous = useRef(search);
59
+ const sayRef = useRef(say);
60
+ sayRef.current = say;
61
+ useEffect(() => {
62
+ const before = previous.current;
63
+ previous.current = search;
64
+ if (search !== "" || before !== "") {
65
+ sayRef.current(total);
66
+ }
67
+ }, [search, total]);
68
+ }
69
+ function useFormat(locale) {
70
+ return useMemo(() => {
71
+ const formatter = new Intl.NumberFormat(locale);
72
+ return (value) => formatter.format(value);
73
+ }, [locale]);
74
+ }
75
+ function loadingRowsOf(loading) {
76
+ return typeof loading === "object" ? (loading.rows ?? 5) : 5;
77
+ }
78
+ /** The rows after search and sort, cut to the page shown. With `serverSide` the data already is the page. */
79
+ function usePaged(props, state, rowId) {
80
+ const { serverSide } = props;
81
+ const rows = useTableModel({
82
+ data: props.data,
83
+ columns: props.columns,
84
+ state,
85
+ locale: props.locale,
86
+ serverSide: serverSide !== undefined,
87
+ rowId
88
+ });
89
+ const paging = props.paging ?? { pageSize: 20 };
90
+ const total = serverSide ? serverSide.rowCount : rows.length;
91
+ const size = paging ? state.pageSize : Number.POSITIVE_INFINITY;
92
+ const pageCount = paging ? Math.max(1, Math.ceil(total / size)) : 1;
93
+ const page = shownPage(state.page, pageCount);
94
+ const slice = serverSide || !paging ? rows : rows.slice((page - 1) * size, page * size);
95
+ const pageRows = slice.map((row) => ({ id: row.id, row: row.original }));
96
+ return { paging, total, pageCount, page, pageRows };
97
+ }
98
+ /** The selected rows: with the whole list known, only ids still in it; with `serverSide`, those on this page. */
99
+ function selectedOf(props, state, paged, rowId) {
100
+ const chosen = new Set(state.selected);
101
+ const known = props.serverSide ? paged.pageRows.map((item) => item.row) : [...props.data];
102
+ const selectedRows = known.filter((row) => chosen.has(rowId(row)));
103
+ return {
104
+ selectedRows,
105
+ selectedCount: props.serverSide ? state.selected.length : selectedRows.length,
106
+ pageSelected: pageSelection(state.selected, paged.pageRows.map((item) => item.id))
107
+ };
108
+ }
109
+ /** Works out what the table shows: the page's rows, the counts, the selection and the body. */
110
+ export function useTableView(props) {
111
+ const words = { ...tableLabels, ...props.labels };
112
+ const format = useFormat(props.locale);
113
+ const { state, dispatch } = useTableState(props);
114
+ const rowId = props.rowId ?? defaultRowId;
115
+ const dataColumns = props.columns.filter((column) => !isActionsColumn(column));
116
+ const paged = usePaged(props, state, rowId);
117
+ const linkColumnId = props.rowLink || props.onRowPress ? (props.rowLinkColumn ?? dataColumns[0]?.id) : undefined;
118
+ const nameColumn = dataColumns.find((column) => column.id === linkColumnId) ?? dataColumns[0];
119
+ useSearchAnnouncement(state.search, paged.total, (count) => {
120
+ announce(words.results(format(count)));
121
+ });
122
+ return {
123
+ ...paged,
124
+ ...selectedOf(props, state, paged, rowId),
125
+ words,
126
+ format,
127
+ state,
128
+ dispatch: (event) => {
129
+ const next = dispatch(event);
130
+ const rule = event.type === "sort" ? next.sort[0] : undefined;
131
+ const sorted = dataColumns.find((column) => column.id === rule?.id);
132
+ if (rule && sorted) {
133
+ announce(words.sorted(sorted.label, rule.desc, format(paged.total)));
134
+ }
135
+ },
136
+ dataColumns,
137
+ body: bodyOf({
138
+ loading: Boolean(props.loading),
139
+ total: props.serverSide ? props.serverSide.rowCount : props.data.length,
140
+ searching: state.search.trim() !== "",
141
+ shown: paged.pageRows.length
142
+ }),
143
+ rowName: (row) => props.rowName?.(row) ?? nameColumn?.text(row) ?? rowId(row),
144
+ linkColumnId,
145
+ loadingRows: loadingRowsOf(props.loading)
146
+ };
147
+ }
@@ -1,3 +1,2 @@
1
1
  export { createToaster, Toast, toast, ToastAction, ToastClose, ToastDescription, ToastRegion, ToastTitle, type ToastActionData, type ToastActionDetails, type ToastActionProps, type ToastButtonState, type ToastCancel, type ToastCloseProps, type ToastData, type ToastDismissDetails, type ToastDismissReason, type Toaster, type ToastItem, type ToastOptions, type ToastPauseReason, type ToastRegionOptions, type ToastRegionProps, type ToastRegionState, type ToastState, type ToastType } from "@ui-sdk/react/toast";
2
- export { OverlayHost } from "../dialog/dialog";
3
- export { type OverlayHostProps } from "@ui-sdk/react/overlays";
2
+ export { OverlayHost, type OverlayHostProps } from "../dialog/overlay-host";
@@ -1,3 +1,2 @@
1
1
  export { createToaster, Toast, toast, ToastAction, ToastClose, ToastDescription, ToastRegion, ToastTitle } from "@ui-sdk/react/toast";
2
- export { OverlayHost } from "../dialog/dialog";
3
- export {} from "@ui-sdk/react/overlays";
2
+ export { OverlayHost } from "../dialog/overlay-host";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alulore/kumiko",
3
- "version": "0.18.2",
3
+ "version": "0.19.0",
4
4
  "description": "Polished, cozy React components with gentle motion, built on ui-sdk. Every look and behaviour can be switched with props and CSS tokens.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -133,6 +133,15 @@
133
133
  "source": "./src/otp-input/otp-input.css",
134
134
  "default": "./dist/otp-input/otp-input.css"
135
135
  },
136
+ "./pagination": {
137
+ "source": "./src/pagination/index.ts",
138
+ "types": "./dist/pagination/index.d.ts",
139
+ "default": "./dist/pagination/index.js"
140
+ },
141
+ "./pagination.css": {
142
+ "source": "./src/pagination/pagination.css",
143
+ "default": "./dist/pagination/pagination.css"
144
+ },
136
145
  "./popover": {
137
146
  "source": "./src/popover/index.ts",
138
147
  "types": "./dist/popover/index.d.ts",
@@ -210,6 +219,33 @@
210
219
  "source": "./src/switch/switch.css",
211
220
  "default": "./dist/switch/switch.css"
212
221
  },
222
+ "./sidebar": {
223
+ "source": "./src/sidebar/index.ts",
224
+ "types": "./dist/sidebar/index.d.ts",
225
+ "default": "./dist/sidebar/index.js"
226
+ },
227
+ "./sidebar.css": {
228
+ "source": "./src/sidebar/sidebar.css",
229
+ "default": "./dist/sidebar/sidebar.css"
230
+ },
231
+ "./page": {
232
+ "source": "./src/page/index.ts",
233
+ "types": "./dist/page/index.d.ts",
234
+ "default": "./dist/page/index.js"
235
+ },
236
+ "./page.css": {
237
+ "source": "./src/page/page.css",
238
+ "default": "./dist/page/page.css"
239
+ },
240
+ "./table": {
241
+ "source": "./src/table/index.ts",
242
+ "types": "./dist/table/index.d.ts",
243
+ "default": "./dist/table/index.js"
244
+ },
245
+ "./table.css": {
246
+ "source": "./src/table/table.css",
247
+ "default": "./dist/table/table.css"
248
+ },
213
249
  "./tabs": {
214
250
  "source": "./src/tabs/index.ts",
215
251
  "types": "./dist/tabs/index.d.ts",
@@ -344,6 +380,7 @@
344
380
  "test:prove": "bun tooling/prove-tests.ts"
345
381
  },
346
382
  "devDependencies": {
383
+ "@tanstack/react-table": "^9.3.1",
347
384
  "@types/react": "^19.3.0",
348
385
  "@types/react-dom": "^19.3.0",
349
386
  "@ui-sdk/core": "0.1.0-beta.13",
@@ -358,9 +395,15 @@
358
395
  "vitest-browser-react": "^2.3.0"
359
396
  },
360
397
  "peerDependencies": {
398
+ "@tanstack/react-table": "^9.3.1",
361
399
  "@ui-sdk/core": "0.1.0-beta.13",
362
400
  "@ui-sdk/react": "0.1.0-beta.13",
363
401
  "react": "^19.3.1",
364
402
  "react-dom": "^19.3.1"
403
+ },
404
+ "peerDependenciesMeta": {
405
+ "@tanstack/react-table": {
406
+ "optional": true
407
+ }
365
408
  }
366
409
  }