@krizaka/ui 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/dist/audio-player.d.ts +113 -0
- package/dist/audio-player.js +207 -0
- package/dist/audio-player.js.map +1 -0
- package/dist/chunk-2USC2YT6.js +17 -0
- package/dist/chunk-2USC2YT6.js.map +1 -0
- package/dist/chunk-EUPTXKH7.js +95 -0
- package/dist/chunk-EUPTXKH7.js.map +1 -0
- package/dist/chunk-RUPRYJ45.js +82 -0
- package/dist/chunk-RUPRYJ45.js.map +1 -0
- package/dist/chunk-XUMJA5ZI.js +283 -0
- package/dist/chunk-XUMJA5ZI.js.map +1 -0
- package/dist/chunk-YH4LMWRU.js +92 -0
- package/dist/chunk-YH4LMWRU.js.map +1 -0
- package/dist/chunk-YX6CNVJA.js +94 -0
- package/dist/chunk-YX6CNVJA.js.map +1 -0
- package/dist/chunk-ZIXB33X7.js +95 -0
- package/dist/chunk-ZIXB33X7.js.map +1 -0
- package/dist/combobox.d.ts +188 -0
- package/dist/combobox.js +16 -0
- package/dist/combobox.js.map +1 -0
- package/dist/data-table.d.ts +246 -0
- package/dist/data-table.js +290 -0
- package/dist/data-table.js.map +1 -0
- package/dist/date-picker.d.ts +288 -0
- package/dist/date-picker.js +364 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/file-upload.d.ts +238 -0
- package/dist/file-upload.js +437 -0
- package/dist/file-upload.js.map +1 -0
- package/dist/filter-bar.d.ts +139 -0
- package/dist/filter-bar.js +155 -0
- package/dist/filter-bar.js.map +1 -0
- package/dist/image-cropper.d.ts +115 -0
- package/dist/image-cropper.js +166 -0
- package/dist/image-cropper.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/media-capture.d.ts +155 -0
- package/dist/media-capture.js +242 -0
- package/dist/media-capture.js.map +1 -0
- package/dist/native/media-capture.d.ts +49 -0
- package/dist/native/media-capture.js +113 -0
- package/dist/native/media-capture.js.map +1 -0
- package/dist/native/video-player.d.ts +50 -0
- package/dist/native/video-player.js +69 -0
- package/dist/native/video-player.js.map +1 -0
- package/dist/native.d.ts +94 -3
- package/dist/native.js +195 -73
- package/dist/native.js.map +1 -1
- package/dist/pagination.d.ts +141 -0
- package/dist/pagination.js +165 -0
- package/dist/pagination.js.map +1 -0
- package/dist/search-field.d.ts +100 -0
- package/dist/search-field.js +167 -0
- package/dist/search-field.js.map +1 -0
- package/dist/tag-input.d.ts +44 -0
- package/dist/tag-input.js +67 -0
- package/dist/tag-input.js.map +1 -0
- package/dist/video-player.d.ts +204 -0
- package/dist/video-player.js +371 -0
- package/dist/video-player.js.map +1 -0
- package/dist/video-trimmer.d.ts +142 -0
- package/dist/video-trimmer.js +193 -0
- package/dist/video-trimmer.js.map +1 -0
- package/package.json +233 -5
- package/registry/alert.json +1 -1
- package/registry/audio-player.json +282 -0
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/button.json +1 -1
- package/registry/card.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/combobox.json +475 -0
- package/registry/command.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/data-table.json +500 -0
- package/registry/date-picker.json +978 -0
- package/registry/dialog.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/examples/audio-player/podcast.d.ts +4 -0
- package/registry/examples/audio-player/podcast.js +22 -0
- package/registry/examples/audio-player/podcast.tsx +19 -0
- package/registry/examples/audio-player/voice-note.d.ts +4 -0
- package/registry/examples/audio-player/voice-note.js +12 -0
- package/registry/examples/audio-player/voice-note.tsx +12 -0
- package/registry/examples/combobox/async.d.ts +4 -0
- package/registry/examples/combobox/async.js +23 -0
- package/registry/examples/combobox/async.tsx +22 -0
- package/registry/examples/combobox/creatable.d.ts +4 -0
- package/registry/examples/combobox/creatable.js +32 -0
- package/registry/examples/combobox/creatable.tsx +28 -0
- package/registry/examples/combobox/invalid.d.ts +4 -0
- package/registry/examples/combobox/invalid.js +23 -0
- package/registry/examples/combobox/invalid.tsx +17 -0
- package/registry/examples/combobox/multiple.d.ts +4 -0
- package/registry/examples/combobox/multiple.js +29 -0
- package/registry/examples/combobox/multiple.tsx +26 -0
- package/registry/examples/data-table/cards.d.ts +4 -0
- package/registry/examples/data-table/cards.js +21 -0
- package/registry/examples/data-table/cards.tsx +20 -0
- package/registry/examples/data-table/empty.d.ts +4 -0
- package/registry/examples/data-table/empty.js +26 -0
- package/registry/examples/data-table/empty.tsx +21 -0
- package/registry/examples/data-table/error.d.ts +4 -0
- package/registry/examples/data-table/error.js +28 -0
- package/registry/examples/data-table/error.tsx +29 -0
- package/registry/examples/data-table/jobs.d.ts +4 -0
- package/registry/examples/data-table/jobs.js +37 -0
- package/registry/examples/data-table/jobs.tsx +36 -0
- package/registry/examples/data-table/loading.d.ts +4 -0
- package/registry/examples/data-table/loading.js +16 -0
- package/registry/examples/data-table/loading.tsx +12 -0
- package/registry/examples/data-table/virtualized.d.ts +4 -0
- package/registry/examples/data-table/virtualized.js +21 -0
- package/registry/examples/data-table/virtualized.tsx +20 -0
- package/registry/examples/date-picker/calendar.d.ts +4 -0
- package/registry/examples/date-picker/calendar.js +14 -0
- package/registry/examples/date-picker/calendar.tsx +16 -0
- package/registry/examples/date-picker/french.d.ts +4 -0
- package/registry/examples/date-picker/french.js +20 -0
- package/registry/examples/date-picker/french.tsx +14 -0
- package/registry/examples/date-picker/open.d.ts +4 -0
- package/registry/examples/date-picker/open.js +11 -0
- package/registry/examples/date-picker/open.tsx +8 -0
- package/registry/examples/date-picker/range.d.ts +4 -0
- package/registry/examples/date-picker/range.js +29 -0
- package/registry/examples/date-picker/range.tsx +25 -0
- package/registry/examples/date-picker/schedule.d.ts +4 -0
- package/registry/examples/date-picker/schedule.js +26 -0
- package/registry/examples/date-picker/schedule.tsx +22 -0
- package/registry/examples/file-upload/images.d.ts +4 -0
- package/registry/examples/file-upload/images.js +32 -0
- package/registry/examples/file-upload/images.tsx +25 -0
- package/registry/examples/file-upload/states.d.ts +4 -0
- package/registry/examples/file-upload/states.js +28 -0
- package/registry/examples/file-upload/states.tsx +23 -0
- package/registry/examples/file-upload/tus.d.ts +4 -0
- package/registry/examples/file-upload/tus.js +23 -0
- package/registry/examples/file-upload/tus.tsx +26 -0
- package/registry/examples/file-upload/video.d.ts +4 -0
- package/registry/examples/file-upload/video.js +39 -0
- package/registry/examples/file-upload/video.tsx +36 -0
- package/registry/examples/filter-bar/address.d.ts +4 -0
- package/registry/examples/filter-bar/address.js +29 -0
- package/registry/examples/filter-bar/address.tsx +27 -0
- package/registry/examples/filter-bar/jobs.d.ts +4 -0
- package/registry/examples/filter-bar/jobs.js +37 -0
- package/registry/examples/filter-bar/jobs.tsx +37 -0
- package/registry/examples/filter-bar/menu.d.ts +4 -0
- package/registry/examples/filter-bar/menu.js +27 -0
- package/registry/examples/filter-bar/menu.tsx +23 -0
- package/registry/examples/image-cropper/avatar.d.ts +4 -0
- package/registry/examples/image-cropper/avatar.js +13 -0
- package/registry/examples/image-cropper/avatar.tsx +14 -0
- package/registry/examples/image-cropper/banner.d.ts +4 -0
- package/registry/examples/image-cropper/banner.js +11 -0
- package/registry/examples/image-cropper/banner.tsx +10 -0
- package/registry/examples/image-cropper/vertical-video.d.ts +4 -0
- package/registry/examples/image-cropper/vertical-video.js +12 -0
- package/registry/examples/image-cropper/vertical-video.tsx +16 -0
- package/registry/examples/media-capture/clip.d.ts +4 -0
- package/registry/examples/media-capture/clip.js +20 -0
- package/registry/examples/media-capture/clip.tsx +18 -0
- package/registry/examples/media-capture/native/photo.d.ts +4 -0
- package/registry/examples/media-capture/native/photo.dark.png +0 -0
- package/registry/examples/media-capture/native/photo.js +27 -0
- package/registry/examples/media-capture/native/photo.light.png +0 -0
- package/registry/examples/media-capture/native/photo.tsx +20 -0
- package/registry/examples/media-capture/profile-photo.d.ts +4 -0
- package/registry/examples/media-capture/profile-photo.js +24 -0
- package/registry/examples/media-capture/profile-photo.tsx +20 -0
- package/registry/examples/pagination/cursor.d.ts +4 -0
- package/registry/examples/pagination/cursor.js +24 -0
- package/registry/examples/pagination/cursor.tsx +20 -0
- package/registry/examples/pagination/links.d.ts +4 -0
- package/registry/examples/pagination/links.js +11 -0
- package/registry/examples/pagination/links.tsx +6 -0
- package/registry/examples/pagination/native/cursor.d.ts +4 -0
- package/registry/examples/pagination/native/cursor.dark.png +0 -0
- package/registry/examples/pagination/native/cursor.js +19 -0
- package/registry/examples/pagination/native/cursor.light.png +0 -0
- package/registry/examples/pagination/native/cursor.tsx +13 -0
- package/registry/examples/pagination/native/pages.d.ts +4 -0
- package/registry/examples/pagination/native/pages.dark.png +0 -0
- package/registry/examples/pagination/native/pages.js +21 -0
- package/registry/examples/pagination/native/pages.light.png +0 -0
- package/registry/examples/pagination/native/pages.tsx +14 -0
- package/registry/examples/pagination/results.d.ts +4 -0
- package/registry/examples/pagination/results.js +23 -0
- package/registry/examples/pagination/results.tsx +19 -0
- package/registry/examples/pagination/table-footer.d.ts +4 -0
- package/registry/examples/pagination/table-footer.js +31 -0
- package/registry/examples/pagination/table-footer.tsx +27 -0
- package/registry/examples/search-field/global.d.ts +4 -0
- package/registry/examples/search-field/global.js +19 -0
- package/registry/examples/search-field/global.tsx +15 -0
- package/registry/examples/search-field/native/default.d.ts +4 -0
- package/registry/examples/search-field/native/default.dark.png +0 -0
- package/registry/examples/search-field/native/default.js +13 -0
- package/registry/examples/search-field/native/default.light.png +0 -0
- package/registry/examples/search-field/native/default.tsx +7 -0
- package/registry/examples/search-field/suggestions.d.ts +4 -0
- package/registry/examples/search-field/suggestions.js +30 -0
- package/registry/examples/search-field/suggestions.tsx +27 -0
- package/registry/examples/search-field/toolbar.d.ts +4 -0
- package/registry/examples/search-field/toolbar.js +17 -0
- package/registry/examples/search-field/toolbar.tsx +21 -0
- package/registry/examples/tag-input/recipients.d.ts +4 -0
- package/registry/examples/tag-input/recipients.js +23 -0
- package/registry/examples/tag-input/recipients.tsx +20 -0
- package/registry/examples/tag-input/video-tags.d.ts +4 -0
- package/registry/examples/tag-input/video-tags.js +26 -0
- package/registry/examples/tag-input/video-tags.tsx +22 -0
- package/registry/examples/video-player/default.d.ts +4 -0
- package/registry/examples/video-player/default.js +12 -0
- package/registry/examples/video-player/default.tsx +8 -0
- package/registry/examples/video-player/gated.d.ts +4 -0
- package/registry/examples/video-player/gated.js +26 -0
- package/registry/examples/video-player/gated.tsx +23 -0
- package/registry/examples/video-player/native/default.d.ts +4 -0
- package/registry/examples/video-player/native/default.dark.png +0 -0
- package/registry/examples/video-player/native/default.js +18 -0
- package/registry/examples/video-player/native/default.light.png +0 -0
- package/registry/examples/video-player/native/default.tsx +12 -0
- package/registry/examples/video-player/signed-source.d.ts +4 -0
- package/registry/examples/video-player/signed-source.js +16 -0
- package/registry/examples/video-player/signed-source.tsx +15 -0
- package/registry/examples/video-player/vertical.d.ts +4 -0
- package/registry/examples/video-player/vertical.js +12 -0
- package/registry/examples/video-player/vertical.tsx +12 -0
- package/registry/examples/video-trimmer/custom.d.ts +4 -0
- package/registry/examples/video-trimmer/custom.js +24 -0
- package/registry/examples/video-trimmer/custom.tsx +26 -0
- package/registry/examples/video-trimmer/filmstrip.d.ts +4 -0
- package/registry/examples/video-trimmer/filmstrip.js +15 -0
- package/registry/examples/video-trimmer/filmstrip.tsx +13 -0
- package/registry/examples/video-trimmer/playhead.d.ts +4 -0
- package/registry/examples/video-trimmer/playhead.js +15 -0
- package/registry/examples/video-trimmer/playhead.tsx +13 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +471 -0
- package/registry/filter-bar.json +347 -0
- package/registry/glow-card.json +1 -1
- package/registry/image-cropper.json +313 -0
- package/registry/index.json +255 -1
- package/registry/iso.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/media-capture.json +347 -0
- package/registry/meter.json +3 -3
- package/registry/nav-bar.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/pagination.json +475 -0
- package/registry/popover.json +1 -1
- package/registry/progress.json +5 -5
- package/registry/radio-group.json +1 -1
- package/registry/search-field.json +436 -0
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +363 -0
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/video-player.json +598 -0
- package/registry/video-trimmer.json +385 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/listbox.ts
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
function useListbox({ count, isDisabled = () => false, onPick, open, setOpen }) {
|
|
6
|
+
const id = React.useId();
|
|
7
|
+
const listId = `${id}-list`;
|
|
8
|
+
const [chosen, setActive] = React.useState(-1);
|
|
9
|
+
const active = open ? Math.min(chosen, count - 1) : -1;
|
|
10
|
+
const optionId = (index) => `${id}-opt-${index}`;
|
|
11
|
+
const step = (from, delta) => {
|
|
12
|
+
for (let i = 1; i <= count; i += 1) {
|
|
13
|
+
const next = (from + delta * i + count * 2) % count;
|
|
14
|
+
if (!isDisabled(next)) return next;
|
|
15
|
+
}
|
|
16
|
+
return -1;
|
|
17
|
+
};
|
|
18
|
+
const first = () => step(-1, 1);
|
|
19
|
+
const last = () => step(count, -1);
|
|
20
|
+
const onKeyDown = (event) => {
|
|
21
|
+
switch (event.key) {
|
|
22
|
+
case "ArrowDown":
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
if (!open) {
|
|
25
|
+
setOpen(true);
|
|
26
|
+
setActive(event.altKey ? -1 : first());
|
|
27
|
+
} else setActive(active < 0 ? first() : step(active, 1));
|
|
28
|
+
return true;
|
|
29
|
+
case "ArrowUp":
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
if (!open) {
|
|
32
|
+
setOpen(true);
|
|
33
|
+
setActive(last());
|
|
34
|
+
} else setActive(active < 0 ? last() : step(active, -1));
|
|
35
|
+
return true;
|
|
36
|
+
case "Home":
|
|
37
|
+
case "End":
|
|
38
|
+
if (!open || count === 0) return false;
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
setActive(event.key === "Home" ? first() : last());
|
|
41
|
+
return true;
|
|
42
|
+
case "Enter":
|
|
43
|
+
if (!open || active < 0) return false;
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
onPick(active);
|
|
46
|
+
return true;
|
|
47
|
+
case "Escape":
|
|
48
|
+
if (!open) return false;
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
setOpen(false);
|
|
52
|
+
return true;
|
|
53
|
+
case "Tab":
|
|
54
|
+
if (open) setOpen(false);
|
|
55
|
+
return false;
|
|
56
|
+
default:
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (active < 0 || typeof document === "undefined") return;
|
|
62
|
+
document.getElementById(`${id}-opt-${active}`)?.scrollIntoView?.({ block: "nearest" });
|
|
63
|
+
}, [active, id]);
|
|
64
|
+
return {
|
|
65
|
+
listId,
|
|
66
|
+
active,
|
|
67
|
+
setActive,
|
|
68
|
+
optionId,
|
|
69
|
+
onKeyDown,
|
|
70
|
+
/** The ARIA of the text input. */
|
|
71
|
+
inputProps: {
|
|
72
|
+
role: "combobox",
|
|
73
|
+
"aria-expanded": open,
|
|
74
|
+
"aria-controls": listId,
|
|
75
|
+
"aria-autocomplete": "list",
|
|
76
|
+
"aria-activedescendant": open && active >= 0 ? optionId(active) : void 0
|
|
77
|
+
},
|
|
78
|
+
/** The ARIA and pointer handlers of option `i` (a mouse down keeps the focus in the input). */
|
|
79
|
+
optionProps: (index, selected) => ({
|
|
80
|
+
id: optionId(index),
|
|
81
|
+
role: "option",
|
|
82
|
+
"aria-selected": selected,
|
|
83
|
+
"aria-disabled": isDisabled(index) || void 0,
|
|
84
|
+
"data-active": index === active ? "" : void 0,
|
|
85
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
86
|
+
onMouseMove: () => !isDisabled(index) && index !== active && setActive(index),
|
|
87
|
+
onClick: () => !isDisabled(index) && onPick(index)
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
useListbox
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=chunk-ZIXB33X7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/listbox.ts"],"sourcesContent":["// The ARIA 1.2 combobox engine shared by `combobox`, `tag-input` and `search-field` (client): the focus stays in the\n// text input, the active option is pointed at by `aria-activedescendant`, the arrows walk the enabled options, Enter\n// picks, Escape closes. The caller renders the input and the options; this hook gives them their ARIA and keys.\nimport * as React from \"react\";\n\nexport type ListboxOptions = {\n /** How many options are shown. */\n count: number;\n /** Whether option `i` can be picked. */\n isDisabled?: (index: number) => boolean;\n /** Called when option `i` is picked (Enter or a click). */\n onPick: (index: number) => void;\n /** Whether the list is shown. */\n open: boolean;\n /** Opens or closes the list. */\n setOpen: (open: boolean) => void;\n};\n\nexport function useListbox({ count, isDisabled = () => false, onPick, open, setOpen }: ListboxOptions) {\n const id = React.useId();\n const listId = `${id}-list`;\n const [chosen, setActive] = React.useState(-1);\n // The active option is cleared when the list closes and stays inside it when it shrinks.\n const active = open ? Math.min(chosen, count - 1) : -1;\n const optionId = (index: number) => `${id}-opt-${index}`;\n\n const step = (from: number, delta: 1 | -1) => {\n for (let i = 1; i <= count; i += 1) {\n const next = (from + delta * i + count * 2) % count;\n if (!isDisabled(next)) return next;\n }\n return -1;\n };\n const first = () => step(-1, 1);\n const last = () => step(count, -1);\n\n /** Keys of the text input. Returns `true` when the key was handled (the caller then does nothing else with it). */\n const onKeyDown = (event: React.KeyboardEvent): boolean => {\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n if (!open) {\n setOpen(true);\n setActive(event.altKey ? -1 : first());\n } else setActive(active < 0 ? first() : step(active, 1));\n return true;\n case \"ArrowUp\":\n event.preventDefault();\n if (!open) {\n setOpen(true);\n setActive(last());\n } else setActive(active < 0 ? last() : step(active, -1));\n return true;\n case \"Home\":\n case \"End\":\n if (!open || count === 0) return false;\n event.preventDefault();\n setActive(event.key === \"Home\" ? first() : last());\n return true;\n case \"Enter\":\n if (!open || active < 0) return false;\n event.preventDefault();\n onPick(active);\n return true;\n case \"Escape\":\n if (!open) return false;\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n return true;\n case \"Tab\":\n if (open) setOpen(false);\n return false;\n default:\n return false;\n }\n };\n\n // Keeps the active option in view while the arrows walk a long list.\n React.useEffect(() => {\n if (active < 0 || typeof document === \"undefined\") return;\n document.getElementById(`${id}-opt-${active}`)?.scrollIntoView?.({ block: \"nearest\" });\n }, [active, id]);\n\n return {\n listId,\n active,\n setActive,\n optionId,\n onKeyDown,\n /** The ARIA of the text input. */\n inputProps: {\n role: \"combobox\" as const,\n \"aria-expanded\": open,\n \"aria-controls\": listId,\n \"aria-autocomplete\": \"list\" as const,\n \"aria-activedescendant\": open && active >= 0 ? optionId(active) : undefined,\n },\n /** The ARIA and pointer handlers of option `i` (a mouse down keeps the focus in the input). */\n optionProps: (index: number, selected: boolean) => ({\n id: optionId(index),\n role: \"option\" as const,\n \"aria-selected\": selected,\n \"aria-disabled\": isDisabled(index) || undefined,\n \"data-active\": index === active ? \"\" : undefined,\n onMouseDown: (event: React.MouseEvent) => event.preventDefault(),\n onMouseMove: () => !isDisabled(index) && index !== active && setActive(index),\n onClick: () => !isDisabled(index) && onPick(index),\n }),\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
declare const combobox: tailwind_variants.TVReturnType<{
|
|
5
|
+
[key: string]: {
|
|
6
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
7
|
+
input?: tailwind_variants.ClassValue;
|
|
8
|
+
label?: tailwind_variants.ClassValue;
|
|
9
|
+
option?: tailwind_variants.ClassValue;
|
|
10
|
+
list?: tailwind_variants.ClassValue;
|
|
11
|
+
status?: tailwind_variants.ClassValue;
|
|
12
|
+
hint?: tailwind_variants.ClassValue;
|
|
13
|
+
root?: tailwind_variants.ClassValue;
|
|
14
|
+
check?: tailwind_variants.ClassValue;
|
|
15
|
+
description?: tailwind_variants.ClassValue;
|
|
16
|
+
error?: tailwind_variants.ClassValue;
|
|
17
|
+
control?: tailwind_variants.ClassValue;
|
|
18
|
+
icon?: tailwind_variants.ClassValue;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
[x: string]: {
|
|
23
|
+
[x: string]: tailwind_variants.ClassValue | {
|
|
24
|
+
input?: tailwind_variants.ClassValue;
|
|
25
|
+
label?: tailwind_variants.ClassValue;
|
|
26
|
+
option?: tailwind_variants.ClassValue;
|
|
27
|
+
list?: tailwind_variants.ClassValue;
|
|
28
|
+
status?: tailwind_variants.ClassValue;
|
|
29
|
+
hint?: tailwind_variants.ClassValue;
|
|
30
|
+
root?: tailwind_variants.ClassValue;
|
|
31
|
+
check?: tailwind_variants.ClassValue;
|
|
32
|
+
description?: tailwind_variants.ClassValue;
|
|
33
|
+
error?: tailwind_variants.ClassValue;
|
|
34
|
+
control?: tailwind_variants.ClassValue;
|
|
35
|
+
icon?: tailwind_variants.ClassValue;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
} | {}, {
|
|
39
|
+
root: string;
|
|
40
|
+
label: string;
|
|
41
|
+
control: string;
|
|
42
|
+
input: string;
|
|
43
|
+
icon: string;
|
|
44
|
+
list: string;
|
|
45
|
+
option: string;
|
|
46
|
+
check: string;
|
|
47
|
+
description: string;
|
|
48
|
+
status: string;
|
|
49
|
+
hint: string;
|
|
50
|
+
error: string;
|
|
51
|
+
}, undefined, {
|
|
52
|
+
[key: string]: {
|
|
53
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
54
|
+
input?: tailwind_variants.ClassValue;
|
|
55
|
+
label?: tailwind_variants.ClassValue;
|
|
56
|
+
option?: tailwind_variants.ClassValue;
|
|
57
|
+
list?: tailwind_variants.ClassValue;
|
|
58
|
+
status?: tailwind_variants.ClassValue;
|
|
59
|
+
hint?: tailwind_variants.ClassValue;
|
|
60
|
+
root?: tailwind_variants.ClassValue;
|
|
61
|
+
check?: tailwind_variants.ClassValue;
|
|
62
|
+
description?: tailwind_variants.ClassValue;
|
|
63
|
+
error?: tailwind_variants.ClassValue;
|
|
64
|
+
control?: tailwind_variants.ClassValue;
|
|
65
|
+
icon?: tailwind_variants.ClassValue;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
} | {}, {
|
|
69
|
+
root: string;
|
|
70
|
+
label: string;
|
|
71
|
+
control: string;
|
|
72
|
+
input: string;
|
|
73
|
+
icon: string;
|
|
74
|
+
list: string;
|
|
75
|
+
option: string;
|
|
76
|
+
check: string;
|
|
77
|
+
description: string;
|
|
78
|
+
status: string;
|
|
79
|
+
hint: string;
|
|
80
|
+
error: string;
|
|
81
|
+
}, tailwind_variants.TVReturnTypeLike<unknown, {
|
|
82
|
+
root: string;
|
|
83
|
+
label: string;
|
|
84
|
+
control: string;
|
|
85
|
+
input: string;
|
|
86
|
+
icon: string;
|
|
87
|
+
list: string;
|
|
88
|
+
option: string;
|
|
89
|
+
check: string;
|
|
90
|
+
description: string;
|
|
91
|
+
status: string;
|
|
92
|
+
hint: string;
|
|
93
|
+
error: string;
|
|
94
|
+
}>>;
|
|
95
|
+
type ComboboxOption = {
|
|
96
|
+
/** What the app stores. */
|
|
97
|
+
value: string;
|
|
98
|
+
/** What the person reads, passed translated. */
|
|
99
|
+
label: string;
|
|
100
|
+
/** A second line under the label. */
|
|
101
|
+
description?: string;
|
|
102
|
+
/** Shown but not choosable. */
|
|
103
|
+
disabled?: boolean;
|
|
104
|
+
};
|
|
105
|
+
type ComboboxLabels = {
|
|
106
|
+
/** No option matches ("No results"). */
|
|
107
|
+
empty: string;
|
|
108
|
+
/** While `onSearch` runs ("Searching…"). */
|
|
109
|
+
loading: string;
|
|
110
|
+
/** `onSearch` failed ("Search unavailable"). */
|
|
111
|
+
error: string;
|
|
112
|
+
/** The option that creates a value: `(query) => "Create “" + query + "”"`. */
|
|
113
|
+
create: (query: string) => string;
|
|
114
|
+
/** A chip's remove button: `(label) => "Remove " + label`. */
|
|
115
|
+
remove: (label: string) => string;
|
|
116
|
+
/** The button that empties a single choice ("Clear"). */
|
|
117
|
+
clear: string;
|
|
118
|
+
/** The button that opens the list ("Show options"). */
|
|
119
|
+
toggle: string;
|
|
120
|
+
/** Announced when the results change: `(n) => n + " results"`. */
|
|
121
|
+
results: (count: number) => string;
|
|
122
|
+
};
|
|
123
|
+
declare const comboboxLabels: ComboboxLabels;
|
|
124
|
+
type BaseProps = {
|
|
125
|
+
/** The visible label of the field, passed translated (also its accessible name). */
|
|
126
|
+
label: string;
|
|
127
|
+
/** Hides the label visually, keeping it as the accessible name (a search bar with its own context). */
|
|
128
|
+
hideLabel?: boolean;
|
|
129
|
+
/** The options, filtered as the person types (by `filter`). */
|
|
130
|
+
options?: readonly ComboboxOption[];
|
|
131
|
+
/** Fetches the options for a query (debounced by `debounce`); the `signal` aborts when a newer query starts. */
|
|
132
|
+
onSearch?: (query: string, signal: AbortSignal) => Promise<readonly ComboboxOption[]>;
|
|
133
|
+
/** The wait, in ms, between the last key and `onSearch`. Default 250. */
|
|
134
|
+
debounce?: number;
|
|
135
|
+
/** Whether an option matches a query. Default: its label contains the query, ignoring case and accents. */
|
|
136
|
+
filter?: (option: ComboboxOption, query: string) => boolean;
|
|
137
|
+
/** Offers to create the query as a new value when no option has that exact label. */
|
|
138
|
+
creatable?: boolean;
|
|
139
|
+
/** Turns a query into the created option (an id from the server…). Default `{ value: query, label: query }`. */
|
|
140
|
+
onCreate?: (query: string) => ComboboxOption;
|
|
141
|
+
/** Keys that create the query at once, as Enter does (`[","]` for tags); a paste is split on them too. */
|
|
142
|
+
separators?: readonly string[];
|
|
143
|
+
/** The input's placeholder, passed translated. */
|
|
144
|
+
placeholder?: string;
|
|
145
|
+
/** A help text under the field. */
|
|
146
|
+
hint?: string;
|
|
147
|
+
/** An error under the field: marks it invalid and is read with it. */
|
|
148
|
+
error?: string;
|
|
149
|
+
/** Not available. */
|
|
150
|
+
disabled?: boolean;
|
|
151
|
+
/** The name of a hidden input holding the value(s), for a plain `<form>` post. */
|
|
152
|
+
name?: string;
|
|
153
|
+
/** The words, passed translated; English by default. */
|
|
154
|
+
labels?: Partial<ComboboxLabels>;
|
|
155
|
+
/** Classes merged on the root. */
|
|
156
|
+
className?: string;
|
|
157
|
+
/** The id of the text input (default: generated). */
|
|
158
|
+
id?: string;
|
|
159
|
+
};
|
|
160
|
+
type SingleProps = BaseProps & {
|
|
161
|
+
/** One value (default) or several. */
|
|
162
|
+
multiple?: false;
|
|
163
|
+
/** The chosen option (controlled), `null` for none. */
|
|
164
|
+
value?: ComboboxOption | null;
|
|
165
|
+
/** The chosen option at first, uncontrolled. */
|
|
166
|
+
defaultValue?: ComboboxOption | null;
|
|
167
|
+
/** Called with the chosen option, or `null` when it is cleared. */
|
|
168
|
+
onValueChange?: (value: ComboboxOption | null) => void;
|
|
169
|
+
/** Most options that can be chosen (several values only). */
|
|
170
|
+
maxSelected?: never;
|
|
171
|
+
};
|
|
172
|
+
type MultipleProps = BaseProps & {
|
|
173
|
+
/** Several values, shown as chips. */
|
|
174
|
+
multiple: true;
|
|
175
|
+
/** The chosen options (controlled). */
|
|
176
|
+
value?: readonly ComboboxOption[];
|
|
177
|
+
/** The chosen options at first, uncontrolled. */
|
|
178
|
+
defaultValue?: readonly ComboboxOption[];
|
|
179
|
+
/** Called with every chosen option. */
|
|
180
|
+
onValueChange?: (value: ComboboxOption[]) => void;
|
|
181
|
+
/** Most options that can be chosen; the list stops offering more past it. */
|
|
182
|
+
maxSelected?: number;
|
|
183
|
+
};
|
|
184
|
+
type ComboboxProps = SingleProps | MultipleProps;
|
|
185
|
+
/** A text field that suggests, filters and completes: one value or several (chips), static or fetched, creatable. */
|
|
186
|
+
declare function Combobox(props: ComboboxProps): React.JSX.Element;
|
|
187
|
+
|
|
188
|
+
export { Combobox, type ComboboxLabels, type ComboboxOption, type ComboboxProps, combobox, comboboxLabels };
|
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Combobox,
|
|
4
|
+
combobox,
|
|
5
|
+
comboboxLabels
|
|
6
|
+
} from "./chunk-XUMJA5ZI.js";
|
|
7
|
+
import "./chunk-YH4LMWRU.js";
|
|
8
|
+
import "./chunk-ZIXB33X7.js";
|
|
9
|
+
import "./chunk-EUPTXKH7.js";
|
|
10
|
+
import "./chunk-YX6CNVJA.js";
|
|
11
|
+
export {
|
|
12
|
+
Combobox,
|
|
13
|
+
combobox,
|
|
14
|
+
comboboxLabels
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=combobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
declare const dataTable: tailwind_variants.TVReturnType<{
|
|
5
|
+
layout: {
|
|
6
|
+
table: {};
|
|
7
|
+
auto: {
|
|
8
|
+
table: string;
|
|
9
|
+
caption: string;
|
|
10
|
+
thead: string;
|
|
11
|
+
headRow: string;
|
|
12
|
+
th: string;
|
|
13
|
+
tbody: string;
|
|
14
|
+
tr: string;
|
|
15
|
+
td: string;
|
|
16
|
+
select: string;
|
|
17
|
+
};
|
|
18
|
+
cards: {
|
|
19
|
+
table: string;
|
|
20
|
+
caption: string;
|
|
21
|
+
thead: string;
|
|
22
|
+
headRow: string;
|
|
23
|
+
th: string;
|
|
24
|
+
tbody: string;
|
|
25
|
+
tr: string;
|
|
26
|
+
td: string;
|
|
27
|
+
select: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
density: {
|
|
31
|
+
comfortable: {};
|
|
32
|
+
compact: {
|
|
33
|
+
th: string;
|
|
34
|
+
td: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}, {
|
|
38
|
+
root: string;
|
|
39
|
+
scroller: string;
|
|
40
|
+
table: string;
|
|
41
|
+
caption: string;
|
|
42
|
+
thead: string;
|
|
43
|
+
headRow: string;
|
|
44
|
+
th: string;
|
|
45
|
+
sortButton: string;
|
|
46
|
+
tbody: string;
|
|
47
|
+
tr: string;
|
|
48
|
+
td: string;
|
|
49
|
+
select: string;
|
|
50
|
+
message: string;
|
|
51
|
+
skeleton: string;
|
|
52
|
+
footer: string;
|
|
53
|
+
}, undefined, {
|
|
54
|
+
layout: {
|
|
55
|
+
table: {};
|
|
56
|
+
auto: {
|
|
57
|
+
table: string;
|
|
58
|
+
caption: string;
|
|
59
|
+
thead: string;
|
|
60
|
+
headRow: string;
|
|
61
|
+
th: string;
|
|
62
|
+
tbody: string;
|
|
63
|
+
tr: string;
|
|
64
|
+
td: string;
|
|
65
|
+
select: string;
|
|
66
|
+
};
|
|
67
|
+
cards: {
|
|
68
|
+
table: string;
|
|
69
|
+
caption: string;
|
|
70
|
+
thead: string;
|
|
71
|
+
headRow: string;
|
|
72
|
+
th: string;
|
|
73
|
+
tbody: string;
|
|
74
|
+
tr: string;
|
|
75
|
+
td: string;
|
|
76
|
+
select: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
density: {
|
|
80
|
+
comfortable: {};
|
|
81
|
+
compact: {
|
|
82
|
+
th: string;
|
|
83
|
+
td: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}, {
|
|
87
|
+
root: string;
|
|
88
|
+
scroller: string;
|
|
89
|
+
table: string;
|
|
90
|
+
caption: string;
|
|
91
|
+
thead: string;
|
|
92
|
+
headRow: string;
|
|
93
|
+
th: string;
|
|
94
|
+
sortButton: string;
|
|
95
|
+
tbody: string;
|
|
96
|
+
tr: string;
|
|
97
|
+
td: string;
|
|
98
|
+
select: string;
|
|
99
|
+
message: string;
|
|
100
|
+
skeleton: string;
|
|
101
|
+
footer: string;
|
|
102
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
103
|
+
layout: {
|
|
104
|
+
table: {};
|
|
105
|
+
auto: {
|
|
106
|
+
table: string;
|
|
107
|
+
caption: string;
|
|
108
|
+
thead: string;
|
|
109
|
+
headRow: string;
|
|
110
|
+
th: string;
|
|
111
|
+
tbody: string;
|
|
112
|
+
tr: string;
|
|
113
|
+
td: string;
|
|
114
|
+
select: string;
|
|
115
|
+
};
|
|
116
|
+
cards: {
|
|
117
|
+
table: string;
|
|
118
|
+
caption: string;
|
|
119
|
+
thead: string;
|
|
120
|
+
headRow: string;
|
|
121
|
+
th: string;
|
|
122
|
+
tbody: string;
|
|
123
|
+
tr: string;
|
|
124
|
+
td: string;
|
|
125
|
+
select: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
density: {
|
|
129
|
+
comfortable: {};
|
|
130
|
+
compact: {
|
|
131
|
+
th: string;
|
|
132
|
+
td: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}, {
|
|
136
|
+
root: string;
|
|
137
|
+
scroller: string;
|
|
138
|
+
table: string;
|
|
139
|
+
caption: string;
|
|
140
|
+
thead: string;
|
|
141
|
+
headRow: string;
|
|
142
|
+
th: string;
|
|
143
|
+
sortButton: string;
|
|
144
|
+
tbody: string;
|
|
145
|
+
tr: string;
|
|
146
|
+
td: string;
|
|
147
|
+
select: string;
|
|
148
|
+
message: string;
|
|
149
|
+
skeleton: string;
|
|
150
|
+
footer: string;
|
|
151
|
+
}>>;
|
|
152
|
+
type SortDirection = "ascending" | "descending";
|
|
153
|
+
type DataTableSort = {
|
|
154
|
+
column: string;
|
|
155
|
+
direction: SortDirection;
|
|
156
|
+
} | null;
|
|
157
|
+
type Sortable = string | number | boolean | Date | null | undefined;
|
|
158
|
+
type DataTableColumn<T> = {
|
|
159
|
+
/** A key of the column (and of the row, for the default cell and sort). */
|
|
160
|
+
id: string;
|
|
161
|
+
/** The column's name, passed translated: the header, and the label of the value in a card. */
|
|
162
|
+
header: string;
|
|
163
|
+
/** What a cell shows. Default: `value(row)`, or `row[id]`. */
|
|
164
|
+
cell?: (row: T) => React.ReactNode;
|
|
165
|
+
/** The value sorted on (and shown by default): a string, a number, a date. Default `row[id]`. */
|
|
166
|
+
value?: (row: T) => Sortable;
|
|
167
|
+
/** The header becomes a sort button (ascending → descending → none). */
|
|
168
|
+
sortable?: boolean;
|
|
169
|
+
/** Text alignment: `end` for amounts and counts. */
|
|
170
|
+
align?: "start" | "center" | "end";
|
|
171
|
+
/** A CSS width (`"8rem"`, `"30%"`). */
|
|
172
|
+
width?: string;
|
|
173
|
+
/** In a card: `title` (the heading of the card), `label` (default: "Header value"), `hidden`. */
|
|
174
|
+
card?: "title" | "label" | "hidden";
|
|
175
|
+
/** Hides the header visually (an actions column), keeping it for screen readers. */
|
|
176
|
+
headerHidden?: boolean;
|
|
177
|
+
};
|
|
178
|
+
type DataTableLabels = {
|
|
179
|
+
/** The checkbox of the header ("Select all rows"). */
|
|
180
|
+
selectAll: string;
|
|
181
|
+
/** The checkbox of a row: `(name) => "Select " + name`, the name from `rowLabel`. */
|
|
182
|
+
selectRow: (name: string) => string;
|
|
183
|
+
/** Read while the rows load ("Loading"). */
|
|
184
|
+
loading: string;
|
|
185
|
+
/** The default empty state ("Nothing to show"). */
|
|
186
|
+
empty: string;
|
|
187
|
+
};
|
|
188
|
+
declare const dataTableLabels: DataTableLabels;
|
|
189
|
+
type DataTableProps<T> = {
|
|
190
|
+
/** The rows, in the order the server gave (sorted here unless `manualSort`). */
|
|
191
|
+
rows: readonly T[];
|
|
192
|
+
/** The columns, in order. */
|
|
193
|
+
columns: readonly DataTableColumn<T>[];
|
|
194
|
+
/** A stable id per row: the React key and the selection's value. */
|
|
195
|
+
getRowId: (row: T) => string;
|
|
196
|
+
/** What the table lists ("Jobs", "Your videos"): its `<caption>`, hidden unless `showCaption`. */
|
|
197
|
+
caption: string;
|
|
198
|
+
/** Shows the caption above the table. */
|
|
199
|
+
showCaption?: boolean;
|
|
200
|
+
/** The sorted column (controlled), `null` for none. */
|
|
201
|
+
sort?: DataTableSort;
|
|
202
|
+
/** The sort at first, uncontrolled. */
|
|
203
|
+
defaultSort?: DataTableSort;
|
|
204
|
+
/** Called when a header asks for a new sort. */
|
|
205
|
+
onSortChange?: (sort: DataTableSort) => void;
|
|
206
|
+
/** The server sorts (`onSortChange` fetches): the rows are shown as given. */
|
|
207
|
+
manualSort?: boolean;
|
|
208
|
+
/** Adds a checkbox per row and one in the header. */
|
|
209
|
+
selectable?: boolean;
|
|
210
|
+
/** The ids selected (controlled). */
|
|
211
|
+
selected?: readonly string[];
|
|
212
|
+
/** The ids selected at first, uncontrolled. */
|
|
213
|
+
defaultSelected?: readonly string[];
|
|
214
|
+
/** Called with the new selection. */
|
|
215
|
+
onSelectedChange?: (selected: string[]) => void;
|
|
216
|
+
/** The name of a row in its checkbox's label (default: its id). */
|
|
217
|
+
rowLabel?: (row: T) => string;
|
|
218
|
+
/** Rows are loading: skeleton rows (`loadingRows` of them) and `aria-busy`. */
|
|
219
|
+
loading?: boolean;
|
|
220
|
+
/** How many skeleton rows while loading. Default 5. */
|
|
221
|
+
loadingRows?: number;
|
|
222
|
+
/** A failure, shown in place of the rows (an `Alert`, a retry button); announced. */
|
|
223
|
+
error?: React.ReactNode;
|
|
224
|
+
/** Shown when there is no row (an `EmptyState`). Default: `labels.empty`. */
|
|
225
|
+
empty?: React.ReactNode;
|
|
226
|
+
/** `auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one. */
|
|
227
|
+
layout?: "auto" | "table" | "cards";
|
|
228
|
+
/** comfortable (default) · compact. */
|
|
229
|
+
density?: "comfortable" | "compact";
|
|
230
|
+
/** Renders only the rows in view (fixed `rowHeight`, a scrolling body of `height` px). Forces the table layout. */
|
|
231
|
+
virtualize?: {
|
|
232
|
+
rowHeight: number;
|
|
233
|
+
height: number;
|
|
234
|
+
overscan?: number;
|
|
235
|
+
};
|
|
236
|
+
/** Under the table: a `Pagination`, a total. */
|
|
237
|
+
footer?: React.ReactNode;
|
|
238
|
+
/** The words, passed translated; English by default. */
|
|
239
|
+
labels?: Partial<DataTableLabels>;
|
|
240
|
+
/** Classes merged on the root. */
|
|
241
|
+
className?: string;
|
|
242
|
+
};
|
|
243
|
+
/** A table of records: sort, selection, loading / empty / error, cards on a phone, windowing for long lists. */
|
|
244
|
+
declare function DataTable<T>({ rows, columns, getRowId, caption, showCaption, sort: sortProp, defaultSort, onSortChange, manualSort, selectable, selected: selectedProp, defaultSelected, onSelectedChange, rowLabel, loading, loadingRows, error, empty, layout, density, virtualize, footer, labels: given, className, }: DataTableProps<T>): React.JSX.Element;
|
|
245
|
+
|
|
246
|
+
export { DataTable, type DataTableColumn, type DataTableLabels, type DataTableProps, type DataTableSort, type SortDirection, dataTable, dataTableLabels };
|