@alulore/kumiko 0.18.3 → 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 +36 -0
  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,15 @@
1
+ /** How far the pagination has shrunk to fit: as asked, without the pages beside the current one, or compact. */
2
+ export type PaginationFit = 0 | 1 | 2;
3
+ /**
4
+ * The loosest level whose measured width fits the room. A level not measured yet is only reached by stepping
5
+ * down from the one above it once that one is seen to overflow.
6
+ */
7
+ export declare function nextFit(current: PaginationFit, needs: readonly (number | undefined)[], room: number): PaginationFit;
8
+ /**
9
+ * Watches the pagination's width and steps it down a level whenever its list of pages overflows, and back up
10
+ * once the room comes back. The server and the first paint get level 0.
11
+ */
12
+ export declare function usePaginationFit(enabled: boolean): {
13
+ fit: PaginationFit;
14
+ rootRef: (element: HTMLElement | null) => void;
15
+ };
@@ -0,0 +1,52 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ const levels = [0, 1, 2];
3
+ /**
4
+ * The loosest level whose measured width fits the room. A level not measured yet is only reached by stepping
5
+ * down from the one above it once that one is seen to overflow.
6
+ */
7
+ export function nextFit(current, needs, room) {
8
+ for (const level of levels) {
9
+ const need = needs[level];
10
+ if (need !== undefined && need <= room) {
11
+ return level;
12
+ }
13
+ }
14
+ const need = needs[current];
15
+ if (current < 2 && need !== undefined && need > room) {
16
+ return current === 0 ? 1 : 2;
17
+ }
18
+ return current;
19
+ }
20
+ const listSelector = ':scope > [data-slot="pagination-list"]';
21
+ /**
22
+ * Watches the pagination's width and steps it down a level whenever its list of pages overflows, and back up
23
+ * once the room comes back. The server and the first paint get level 0.
24
+ */
25
+ export function usePaginationFit(enabled) {
26
+ const [fit, setFit] = useState(0);
27
+ const [root, setRoot] = useState(null);
28
+ const current = useRef(0);
29
+ const needs = useRef([]);
30
+ const measure = useCallback(() => {
31
+ const list = root?.querySelector(listSelector);
32
+ if (!enabled || !root || !list) {
33
+ return;
34
+ }
35
+ needs.current[current.current] = list.scrollWidth;
36
+ const next = nextFit(current.current, needs.current, root.clientWidth);
37
+ if (next !== current.current) {
38
+ current.current = next;
39
+ setFit(next);
40
+ }
41
+ }, [enabled, root]);
42
+ useLayoutEffect(measure);
43
+ useEffect(() => {
44
+ if (!root || !enabled) {
45
+ return undefined;
46
+ }
47
+ const observer = new ResizeObserver(measure);
48
+ observer.observe(root);
49
+ return () => observer.disconnect();
50
+ }, [root, enabled, measure]);
51
+ return { fit: enabled ? fit : 0, rootRef: setRoot };
52
+ }
@@ -0,0 +1,4 @@
1
+ export declare function PreviousIcon(): React.JSX.Element;
2
+ export declare function NextIcon(): React.JSX.Element;
3
+ export declare function FirstIcon(): React.JSX.Element;
4
+ export declare function LastIcon(): React.JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ function Glyph({ d }) {
3
+ return (_jsx("svg", { "data-slot": "pagination-icon", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: d }) }));
4
+ }
5
+ export function PreviousIcon() {
6
+ return _jsx(Glyph, { d: "M10 3.5 5.5 8l4.5 4.5" });
7
+ }
8
+ export function NextIcon() {
9
+ return _jsx(Glyph, { d: "M6 3.5 10.5 8 6 12.5" });
10
+ }
11
+ export function FirstIcon() {
12
+ return _jsx(Glyph, { d: "M8.5 3.5 4 8l4.5 4.5M12.5 3.5 8 8l4.5 4.5" });
13
+ }
14
+ export function LastIcon() {
15
+ return _jsx(Glyph, { d: "M3.5 3.5 8 8l-4.5 4.5M7.5 3.5 12 8l-4.5 4.5" });
16
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The words the pagination shows and reads out. Numbers arrive already formatted for the pagination's `locale`,
3
+ * so a translation only places them.
4
+ */
5
+ export interface PaginationLabels {
6
+ /** The name of the navigation landmark. */
7
+ navigation: string;
8
+ previous: string;
9
+ next: string;
10
+ first: string;
11
+ last: string;
12
+ /** The name of a page's link, read out with its number. */
13
+ page: (page: string) => string;
14
+ /** Where the reader is, shown by the simple and compact layouts. */
15
+ pageOf: (page: string, pages: string) => string;
16
+ /** Which items the page shows, out of how many. */
17
+ range: (from: string, to: string, total: string) => string;
18
+ rowsPerPage: string;
19
+ jumpTo: string;
20
+ go: string;
21
+ }
22
+ /** The English words every pagination starts from. Pass `labels` to replace any of them. */
23
+ export declare const paginationLabels: PaginationLabels;
@@ -0,0 +1,14 @@
1
+ /** The English words every pagination starts from. Pass `labels` to replace any of them. */
2
+ export const paginationLabels = {
3
+ navigation: "Pagination",
4
+ previous: "Previous",
5
+ next: "Next",
6
+ first: "First page",
7
+ last: "Last page",
8
+ page: (page) => `Page ${page}`,
9
+ pageOf: (page, pages) => `Page ${page} of ${pages}`,
10
+ range: (from, to, total) => `Showing ${from}–${to} of ${total}`,
11
+ rowsPerPage: "Rows per page",
12
+ jumpTo: "Go to page",
13
+ go: "Go"
14
+ };
@@ -0,0 +1,7 @@
1
+ /** The first and last item a page holds, out of the total: page 2 of 20 a page, of 95, holds 21 to 40. */
2
+ export declare function itemRange(page: number, pageSize: number, total: number): {
3
+ from: number;
4
+ to: number;
5
+ };
6
+ /** Reads a typed page number, in Western or the locale's own digits, and keeps it within the pages. */
7
+ export declare function pageFromText(text: string, pageCount: number): number | null;
@@ -0,0 +1,24 @@
1
+ /** The first and last item a page holds, out of the total: page 2 of 20 a page, of 95, holds 21 to 40. */
2
+ export function itemRange(page, pageSize, total) {
3
+ if (total <= 0) {
4
+ return { from: 0, to: 0 };
5
+ }
6
+ return { from: (page - 1) * pageSize + 1, to: Math.min(page * pageSize, total) };
7
+ }
8
+ /** The value of a decimal digit from any script, such as Arabic-Indic ٣: how far it sits from its script's zero. */
9
+ function digitValue(digit) {
10
+ const code = digit.codePointAt(0) ?? 0;
11
+ let zero = code;
12
+ while (code - zero < 9 && /\p{Nd}/u.test(String.fromCodePoint(zero - 1))) {
13
+ zero -= 1;
14
+ }
15
+ return code - zero;
16
+ }
17
+ /** Reads a typed page number, in Western or the locale's own digits, and keeps it within the pages. */
18
+ export function pageFromText(text, pageCount) {
19
+ const digits = text.trim().replaceAll(/\p{Nd}/gu, (digit) => String(digitValue(digit)));
20
+ if (!/^\d+$/u.test(digits)) {
21
+ return null;
22
+ }
23
+ return Math.min(Math.max(Number(digits), 1), Math.max(pageCount, 1));
24
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Makes paging glide: page numbers slide to their new places when the range moves (a number coming into the
3
+ * range fades in), and the indicator slides to the current page. Both run on the `move` tokens, so reduced
4
+ * motion and the still preset make them jump.
5
+ */
6
+ export declare function usePaginationMotion(list: HTMLElement | null, page: number, range: string): void;
@@ -0,0 +1,71 @@
1
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import { createFlip } from "../motion";
3
+ const itemsSelector = ":scope > [data-flip-key]";
4
+ const indicatorSelector = ':scope > [data-slot="pagination-indicator"]';
5
+ /**
6
+ * Puts the indicator over the current page's link, measured within the landmark. The link is found by its page,
7
+ * since ui-sdk marks it current only after this runs. Layout offsets ignore the
8
+ * `translate` a sliding page carries, so it goes straight to where the page comes to rest. With no current link
9
+ * in sight (the simple and compact layouts) it hides.
10
+ */
11
+ function placeIndicator(list, page, instant) {
12
+ const root = list.parentElement;
13
+ const indicator = root?.querySelector(indicatorSelector);
14
+ if (!root || !indicator) {
15
+ return;
16
+ }
17
+ const item = list.querySelector(`:scope > [data-flip-key="${page}"]`);
18
+ const link = item?.firstElementChild;
19
+ const shown = item !== null && link instanceof HTMLElement && link.offsetParent !== null;
20
+ indicator.toggleAttribute("data-hidden", !shown);
21
+ root.toggleAttribute("data-indicator", shown);
22
+ if (!shown) {
23
+ return;
24
+ }
25
+ indicator.toggleAttribute("data-instant", instant || !Object.hasOwn(indicator.dataset, "placed"));
26
+ // A sliding item is the link's offset parent while its translate runs.
27
+ const within = link.offsetParent === item ? 0 : -item.offsetLeft;
28
+ const withinTop = link.offsetParent === item ? 0 : -item.offsetTop;
29
+ indicator.style.setProperty("--_x", `${list.offsetLeft + item.offsetLeft + link.offsetLeft + within}px`);
30
+ indicator.style.setProperty("--_y", `${list.offsetTop + item.offsetTop + link.offsetTop + withinTop}px`);
31
+ indicator.style.setProperty("--_w", `${link.offsetWidth}px`);
32
+ indicator.style.setProperty("--_ih", `${link.offsetHeight}px`);
33
+ indicator.dataset.placed = "";
34
+ }
35
+ /**
36
+ * Makes paging glide: page numbers slide to their new places when the range moves (a number coming into the
37
+ * range fades in), and the indicator slides to the current page. Both run on the `move` tokens, so reduced
38
+ * motion and the still preset make them jump.
39
+ */
40
+ export function usePaginationMotion(list, page, range) {
41
+ const [flip, setFlip] = useState(null);
42
+ const current = useRef(page);
43
+ current.current = page;
44
+ useLayoutEffect(() => {
45
+ if (!list) {
46
+ return;
47
+ }
48
+ const next = createFlip({ items: () => list.querySelectorAll(itemsSelector) });
49
+ next.play(true);
50
+ setFlip(next);
51
+ }, [list]);
52
+ useLayoutEffect(() => {
53
+ if (!list || !flip) {
54
+ return;
55
+ }
56
+ flip.play(true);
57
+ placeIndicator(list, page, false);
58
+ }, [list, flip, page, range]);
59
+ useEffect(() => {
60
+ const root = list?.parentElement;
61
+ if (!list || !root) {
62
+ return undefined;
63
+ }
64
+ const observer = new ResizeObserver(() => {
65
+ flip?.rest();
66
+ placeIndicator(list, current.current, true);
67
+ });
68
+ observer.observe(root);
69
+ return () => observer.disconnect();
70
+ }, [list, flip]);
71
+ }