@alulore/kumiko 0.17.3 → 0.18.2
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/dist/avatar/avatar-name.d.ts +12 -0
- package/dist/avatar/avatar-name.js +42 -0
- package/dist/avatar/avatar.css +274 -0
- package/dist/avatar/avatar.d.ts +72 -0
- package/dist/avatar/avatar.js +45 -0
- package/dist/avatar/index.d.ts +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/board/board-api.d.ts +1 -0
- package/dist/board/board-selection.d.ts +1 -0
- package/dist/board/board-slots.d.ts +7 -0
- package/dist/board/board-slots.js +2 -1
- package/dist/board/refused-home.js +26 -1
- package/dist/dialog/dialog.css +7 -1
- package/dist/dialog/dialog.d.ts +9 -0
- package/dist/dialog/dialog.js +20 -0
- package/dist/dialog/index.d.ts +4 -3
- package/dist/dialog/index.js +4 -3
- package/dist/drawer/drawer.css +514 -0
- package/dist/drawer/drawer.d.ts +55 -0
- package/dist/drawer/drawer.js +43 -0
- package/dist/drawer/index.d.ts +2 -0
- package/dist/drawer/index.js +2 -0
- package/dist/file-input/file-dropzone.d.ts +67 -0
- package/dist/file-input/file-dropzone.js +97 -0
- package/dist/file-input/file-input.css +505 -0
- package/dist/file-input/file-input.d.ts +29 -0
- package/dist/file-input/file-input.js +21 -0
- package/dist/file-input/file-preview.d.ts +15 -0
- package/dist/file-input/file-preview.js +41 -0
- package/dist/file-input/index.d.ts +4 -0
- package/dist/file-input/index.js +4 -0
- package/dist/hover-card/hover-card.js +2 -0
- package/dist/media-viewer/index.d.ts +1 -0
- package/dist/media-viewer/index.js +1 -0
- package/dist/media-viewer/labels.d.ts +27 -0
- package/dist/media-viewer/labels.js +23 -0
- package/dist/media-viewer/media-viewer.d.ts +3 -0
- package/dist/media-viewer/media-viewer.js +6 -3
- package/dist/media-viewer/video-controls.js +4 -2
- package/dist/media-viewer/viewer-chrome.js +11 -5
- package/dist/menu/menu.js +2 -0
- package/dist/motion/settle-close.d.ts +5 -0
- package/dist/motion/settle-close.js +78 -0
- package/dist/otp-input/index.d.ts +2 -0
- package/dist/otp-input/index.js +2 -0
- package/dist/otp-input/otp-input.css +336 -0
- package/dist/otp-input/otp-input.d.ts +56 -0
- package/dist/otp-input/otp-input.js +44 -0
- package/dist/popover/index.d.ts +2 -1
- package/dist/popover/index.js +2 -1
- package/dist/popover/popover.d.ts +3 -0
- package/dist/popover/popover.js +8 -0
- package/dist/server-render.test.d.ts +1 -0
- package/dist/server-render.test.js +57 -0
- package/dist/skeleton/index.d.ts +1 -0
- package/dist/skeleton/index.js +1 -0
- package/dist/skeleton/skeleton.css +143 -0
- package/dist/skeleton/skeleton.d.ts +44 -0
- package/dist/skeleton/skeleton.js +22 -0
- package/dist/smooth-caret/smooth-caret.css +4 -2
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/tabs.css +616 -0
- package/dist/tabs/tabs.d.ts +51 -0
- package/dist/tabs/tabs.js +20 -0
- package/dist/titlebar/index.d.ts +1 -1
- package/dist/titlebar/index.js +1 -1
- package/dist/titlebar/titlebar.d.ts +15 -2
- package/dist/titlebar/titlebar.js +18 -9
- package/dist/toast/index.d.ts +2 -1
- package/dist/toast/index.js +2 -1
- package/dist/tooltip/tooltip.js +2 -0
- package/package.json +59 -5
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FileInputItem, FileInputList, FileInputTrigger, formatFileSize } from "@ui-sdk/react/file-input";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Progress } from "../progress/progress";
|
|
5
|
+
import { FileInput, FileInputDropzone, FileInputIcon, FileInputRemoveButton } from "./file-input";
|
|
6
|
+
import { FilePreview } from "./file-preview";
|
|
7
|
+
export const fileDropzoneLabels = {
|
|
8
|
+
list: "Files",
|
|
9
|
+
overlay: "Drop to add",
|
|
10
|
+
rejected: "Not added",
|
|
11
|
+
dismiss: "Dismiss",
|
|
12
|
+
uploading: "Uploading",
|
|
13
|
+
uploaded: "Uploaded",
|
|
14
|
+
failed: "Upload failed",
|
|
15
|
+
reasons: {
|
|
16
|
+
"file-type": "This type of file isn't accepted",
|
|
17
|
+
"file-too-large": "Too large",
|
|
18
|
+
"file-too-small": "Too small",
|
|
19
|
+
"too-many-files": "Too many files"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function wordsFor(multiple, labels = {}) {
|
|
23
|
+
return {
|
|
24
|
+
...fileDropzoneLabels,
|
|
25
|
+
browse: multiple ? "Browse files" : "Choose a file",
|
|
26
|
+
...labels,
|
|
27
|
+
reasons: { ...fileDropzoneLabels.reasons, ...labels.reasons }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function statusWord(status, words) {
|
|
31
|
+
if (status.phase === "uploading") {
|
|
32
|
+
return words.uploading;
|
|
33
|
+
}
|
|
34
|
+
return status.phase === "done" ? words.uploaded : words.failed;
|
|
35
|
+
}
|
|
36
|
+
/** One file in the list: its preview, name, size and where its upload stands. */
|
|
37
|
+
function FileRow({ file, status, words, locale, thumbnails }) {
|
|
38
|
+
const uploading = status?.phase === "uploading";
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsx(FilePreview, { file: file, thumbnail: thumbnails }), _jsx("span", { "data-slot": "file-input-item-name", children: file.name }), _jsxs("span", { "data-slot": "file-input-item-meta", children: [_jsx("span", { children: formatFileSize(file.size, locale) }), status ? (_jsx("span", { "data-slot": "file-input-item-status", "data-phase": status.phase, children: status.phase === "failed" && status.reason
|
|
40
|
+
? status.reason
|
|
41
|
+
: statusWord(status, words) })) : null] }), uploading ? (_jsx(Progress, { size: "sm", value: status.progress ?? null, "aria-label": `${words.uploading} ${file.name}` })) : null, _jsx(FileInputRemoveButton, { label: words.remove?.(file.name) })] }));
|
|
42
|
+
}
|
|
43
|
+
/** The files the last choice, drop or paste turned away, with why. Ui-sdk announces them; this list is visual. */
|
|
44
|
+
function Rejections({ rejected, words, describe, onDismiss }) {
|
|
45
|
+
if (rejected.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const why = (rejection) => describe?.(rejection) ??
|
|
49
|
+
rejection.reasons.map((reason) => words.reasons[reason] ?? reason).join(", ");
|
|
50
|
+
return (_jsxs("div", { "data-slot": "file-input-rejections", children: [_jsx("ul", { "aria-label": words.rejected, children: rejected.map((rejection, index) => (_jsxs("li", { children: [_jsx("span", { "data-slot": "file-input-rejection-name", children: rejection.file.name }), _jsx("span", { "data-slot": "file-input-rejection-reason", children: why(rejection) })] }, `${index}:${rejection.file.name}`))) }), _jsx("button", { type: "button", "data-slot": "file-input-rejections-dismiss", onClick: onDismiss, children: words.dismiss })] }));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The zone with its icon, words and button. The button look hides all but the button in CSS, so a container
|
|
54
|
+
* word can pick it too.
|
|
55
|
+
*/
|
|
56
|
+
function Zone({ multiple, title, hint, icon, words }) {
|
|
57
|
+
return (_jsxs(FileInputDropzone, { children: [icon === undefined ? _jsx(FileInputIcon, {}) : icon, _jsxs("span", { "data-slot": "file-input-text", children: [_jsx("span", { "data-slot": "file-input-title", children: title ?? (multiple ? "Drag files here" : "Drag a file here") }), hint ? _jsx("span", { "data-slot": "file-input-hint", children: hint }) : null] }), _jsx(FileInputTrigger, { children: words.browse })] }));
|
|
58
|
+
}
|
|
59
|
+
/** The full-page layer that shows while files are over the window. */
|
|
60
|
+
function PageDrop({ words }) {
|
|
61
|
+
return (_jsx(FileInputDropzone, { target: "document", children: _jsxs("span", { "data-slot": "file-input-overlay", children: [_jsx(FileInputIcon, {}), words.overlay] }) }));
|
|
62
|
+
}
|
|
63
|
+
function Files({ status, words, locale, thumbnails }) {
|
|
64
|
+
return (_jsx(FileInputList, { "aria-label": words.list, children: _jsx(FileInputItem, { children: ({ file }) => (_jsx(FileRow, { file: file, status: status?.(file), words: words, locale: locale, thumbnails: thumbnails })) }) }));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The files the last choice turned away. A choice that adds files clears them, even when it turns some away
|
|
68
|
+
* too: ui-sdk reports the change first and the rejections after it.
|
|
69
|
+
*/
|
|
70
|
+
function useRejections({ onReject, onValueChange }) {
|
|
71
|
+
const [rejected, setRejected] = useState([]);
|
|
72
|
+
return {
|
|
73
|
+
rejected,
|
|
74
|
+
dismiss: () => setRejected([]),
|
|
75
|
+
handlers: {
|
|
76
|
+
onValueChange: (value, details) => {
|
|
77
|
+
setRejected([]);
|
|
78
|
+
onValueChange?.(value, details);
|
|
79
|
+
},
|
|
80
|
+
onReject: (next, details) => {
|
|
81
|
+
setRejected(next);
|
|
82
|
+
onReject?.(next, details);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A file input in one line: a drop zone with a button, the files it holds, and the files it turned away. It
|
|
89
|
+
* takes files from the picker, drops and pastes, checks them against `accept`, `maxSize` and the rest, and submits
|
|
90
|
+
* them with a form when it has a `name`. Uploading them is the app's job; pass `status` to show how each goes.
|
|
91
|
+
*/
|
|
92
|
+
export function FileDropzone({ title, hint, icon, pageDrop = false, showList = true, thumbnails = true, status, describeRejection, locale, labels, onReject, onValueChange, ...props }) {
|
|
93
|
+
const multiple = props.multiple || props.directory;
|
|
94
|
+
const words = wordsFor(multiple, labels);
|
|
95
|
+
const { rejected, dismiss, handlers } = useRejections({ onReject, onValueChange });
|
|
96
|
+
return (_jsxs(FileInput, { "data-kumiko-file-dropzone": "", ...props, ...handlers, children: [_jsx(Zone, { multiple: multiple, title: title, hint: hint, icon: icon, words: words }), pageDrop ? _jsx(PageDrop, { words: words }) : null, _jsx(Rejections, { rejected: rejected, words: words, describe: describeRejection, onDismiss: dismiss }), showList ? (_jsx(Files, { status: status, words: words, locale: locale, thumbnails: thumbnails })) : null] }));
|
|
97
|
+
}
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
@import "../progress/progress.css";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Styles ui-sdk's file input. Ui-sdk picks, drops, pastes, checks and submits the files; Kumiko draws the zone, the
|
|
6
|
+
* button, the list and the turned-away files. The button's hit area stretches over its zone, so a click anywhere
|
|
7
|
+
* on the zone opens the picker while the button stays the one Tab stop.
|
|
8
|
+
*/
|
|
9
|
+
@layer kumiko {
|
|
10
|
+
:where(:root) {
|
|
11
|
+
--kumiko-file-input-radius: 0.875rem;
|
|
12
|
+
--kumiko-file-input-border-width: 1.5px;
|
|
13
|
+
--kumiko-file-input-border: color-mix(in oklab, currentColor 24%, transparent);
|
|
14
|
+
--kumiko-file-input-bg: color-mix(in oklab, currentColor 3%, transparent);
|
|
15
|
+
--kumiko-file-input-hover-bg: color-mix(in oklab, currentColor 6%, transparent);
|
|
16
|
+
--kumiko-file-input-padding: 1.75rem 1.25rem;
|
|
17
|
+
--kumiko-file-input-compact-padding: 0.75rem 0.875rem;
|
|
18
|
+
--kumiko-file-input-gap: 0.75rem;
|
|
19
|
+
--kumiko-file-input-icon-size: 1.75rem;
|
|
20
|
+
--kumiko-file-input-hint-fg: color-mix(in oklab, currentColor 62%, transparent);
|
|
21
|
+
--kumiko-file-input-trigger-bg: color-mix(in oklab, currentColor 8%, transparent);
|
|
22
|
+
--kumiko-file-input-trigger-hover-bg: color-mix(in oklab, currentColor 13%, transparent);
|
|
23
|
+
--kumiko-file-input-trigger-radius: 0.625rem;
|
|
24
|
+
--kumiko-file-input-item-bg: color-mix(in oklab, currentColor 4%, transparent);
|
|
25
|
+
--kumiko-file-input-item-radius: 0.75rem;
|
|
26
|
+
--kumiko-file-input-preview-size: 2.5rem;
|
|
27
|
+
--kumiko-file-input-done: light-dark(oklch(0.52 0.13 150), oklch(0.75 0.13 150));
|
|
28
|
+
--kumiko-file-input-overlay-bg: color-mix(in oklab, Canvas 72%, transparent);
|
|
29
|
+
--kumiko-file-input-overlay-blur: 6px;
|
|
30
|
+
--kumiko-file-input-overlay-z: 50;
|
|
31
|
+
--kumiko-file-input-focus-ring: Highlight;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* The tokens that fall back to the text input's resolve on each part, not on the root, so an input token set on
|
|
36
|
+
* any container reaches the file input inside it.
|
|
37
|
+
*/
|
|
38
|
+
:where([data-slot^="file-input"], [data-slot^="file-preview"]) {
|
|
39
|
+
--_file-accent: var(--kumiko-file-input-accent, var(--kumiko-input-accent, Highlight));
|
|
40
|
+
--_file-reject: var(
|
|
41
|
+
--kumiko-file-input-reject,
|
|
42
|
+
var(--kumiko-input-invalid, light-dark(oklch(0.55 0.19 25), oklch(0.72 0.15 25)))
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:where([data-slot="file-input"]) {
|
|
47
|
+
display: grid;
|
|
48
|
+
gap: var(--kumiko-file-input-gap);
|
|
49
|
+
min-inline-size: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* The zone: a dashed box with the icon, the words and the button in a centred column. */
|
|
53
|
+
:where([data-slot="file-input-dropzone"]:not([data-page-wide])) {
|
|
54
|
+
position: relative;
|
|
55
|
+
display: grid;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
padding: var(--kumiko-file-input-padding);
|
|
58
|
+
border: var(--kumiko-file-input-border-width) dashed var(--kumiko-file-input-border);
|
|
59
|
+
border-radius: var(--kumiko-file-input-radius);
|
|
60
|
+
background: var(--kumiko-file-input-bg);
|
|
61
|
+
text-align: center;
|
|
62
|
+
gap: var(--kumiko-file-input-gap);
|
|
63
|
+
justify-items: center;
|
|
64
|
+
transition:
|
|
65
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-enter-ease),
|
|
66
|
+
border-color var(--kumiko-fade-duration) var(--kumiko-enter-ease);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:where([data-slot="file-input-icon"]) {
|
|
70
|
+
inline-size: var(--kumiko-file-input-icon-size);
|
|
71
|
+
block-size: var(--kumiko-file-input-icon-size);
|
|
72
|
+
fill: none;
|
|
73
|
+
stroke: currentColor;
|
|
74
|
+
stroke-linecap: round;
|
|
75
|
+
stroke-linejoin: round;
|
|
76
|
+
stroke-width: 1.75;
|
|
77
|
+
color: var(--kumiko-file-input-hint-fg);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:where([data-slot="file-input-text"]) {
|
|
81
|
+
display: grid;
|
|
82
|
+
gap: 0.25rem;
|
|
83
|
+
min-inline-size: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:where([data-slot="file-input-title"]) {
|
|
87
|
+
font-weight: 600;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:where([data-slot="file-input-hint"]) {
|
|
91
|
+
color: var(--kumiko-file-input-hint-fg);
|
|
92
|
+
font-size: 0.875em;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* The button. In a zone its hit area covers the zone, so a click anywhere opens the picker. */
|
|
96
|
+
:where([data-slot="file-input-trigger"]) {
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
min-block-size: 2.25rem;
|
|
100
|
+
margin: 0;
|
|
101
|
+
padding: 0.5rem 0.875rem;
|
|
102
|
+
border: 0;
|
|
103
|
+
border-radius: var(--kumiko-file-input-trigger-radius);
|
|
104
|
+
background: var(--kumiko-file-input-trigger-bg);
|
|
105
|
+
color: inherit;
|
|
106
|
+
font: inherit;
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
transition: background-color var(--kumiko-fade-duration) var(--kumiko-enter-ease);
|
|
112
|
+
|
|
113
|
+
&:focus-visible {
|
|
114
|
+
outline: 2px solid var(--kumiko-file-input-focus-ring);
|
|
115
|
+
outline-offset: 2px;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:where(
|
|
120
|
+
[data-slot="file-input-dropzone"]:not([data-page-wide]) [data-slot="file-input-trigger"]
|
|
121
|
+
) {
|
|
122
|
+
position: static;
|
|
123
|
+
|
|
124
|
+
&::after {
|
|
125
|
+
position: absolute;
|
|
126
|
+
border-radius: inherit;
|
|
127
|
+
content: "";
|
|
128
|
+
inset: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&:focus-visible {
|
|
132
|
+
outline: none;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* The zone shows the focus ring, since the whole zone is the button's target. */
|
|
137
|
+
:where(
|
|
138
|
+
[data-slot="file-input-dropzone"]:not([data-page-wide]):has(
|
|
139
|
+
[data-slot="file-input-trigger"]:focus-visible
|
|
140
|
+
)
|
|
141
|
+
) {
|
|
142
|
+
outline: 2px solid var(--kumiko-file-input-focus-ring);
|
|
143
|
+
outline-offset: 2px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Anything else interactive in a zone sits above the stretched button, so it still takes its own presses. */
|
|
147
|
+
:where(
|
|
148
|
+
[data-slot="file-input-dropzone"]:not([data-page-wide])
|
|
149
|
+
:is(a, button, input, select, textarea, [tabindex]):not(
|
|
150
|
+
[data-slot="file-input-trigger"]
|
|
151
|
+
)
|
|
152
|
+
) {
|
|
153
|
+
position: relative;
|
|
154
|
+
z-index: 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@media (hover: hover) and (pointer: fine) {
|
|
158
|
+
:where([data-slot="file-input-dropzone"]:not([data-page-wide], [data-disabled]):hover) {
|
|
159
|
+
background: var(--kumiko-file-input-hover-bg);
|
|
160
|
+
|
|
161
|
+
& [data-slot="file-input-trigger"] {
|
|
162
|
+
background: var(--kumiko-file-input-trigger-hover-bg);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
:where([data-slot="file-input-trigger"]:not([data-disabled]):hover) {
|
|
167
|
+
background: var(--kumiko-file-input-trigger-hover-bg);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Files over the zone: the accent when it would take them, the reject colour when it wouldn't. */
|
|
172
|
+
:where([data-slot="file-input-dropzone"]:not([data-page-wide])[data-drag-accept]) {
|
|
173
|
+
border-style: solid;
|
|
174
|
+
border-color: var(--_file-accent);
|
|
175
|
+
background: color-mix(in oklab, var(--_file-accent) 10%, transparent);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
:where([data-slot="file-input-dropzone"]:not([data-page-wide])[data-drag-reject]) {
|
|
179
|
+
border-style: solid;
|
|
180
|
+
border-color: var(--_file-reject);
|
|
181
|
+
background: color-mix(in oklab, var(--_file-reject) 10%, transparent);
|
|
182
|
+
cursor: no-drop;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
:where([data-slot="file-input"][data-disabled]) {
|
|
186
|
+
opacity: var(--kumiko-file-input-disabled-opacity, 0.55);
|
|
187
|
+
|
|
188
|
+
& [data-slot="file-input-trigger"] {
|
|
189
|
+
cursor: not-allowed;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* Compact: one row, the icon and words at the start and the button at the end. */
|
|
194
|
+
:where(
|
|
195
|
+
[data-slot="file-input"]:is(
|
|
196
|
+
[data-look="compact"],
|
|
197
|
+
:not([data-look]):is([data-kumiko-file-input~="compact"] *)
|
|
198
|
+
)
|
|
199
|
+
[data-slot="file-input-dropzone"]:not([data-page-wide])
|
|
200
|
+
) {
|
|
201
|
+
display: flex;
|
|
202
|
+
padding: var(--kumiko-file-input-compact-padding);
|
|
203
|
+
text-align: start;
|
|
204
|
+
align-items: center;
|
|
205
|
+
|
|
206
|
+
& [data-slot="file-input-icon"] {
|
|
207
|
+
flex: none;
|
|
208
|
+
inline-size: calc(var(--kumiko-file-input-icon-size) * 0.8);
|
|
209
|
+
block-size: calc(var(--kumiko-file-input-icon-size) * 0.8);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
& [data-slot="file-input-text"] {
|
|
213
|
+
flex: 1;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
& [data-slot="file-input-trigger"] {
|
|
217
|
+
flex: none;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Button: the zone's frame and words go, and the button stays. It still takes drops and pastes. */
|
|
222
|
+
:where(
|
|
223
|
+
[data-slot="file-input"]:is(
|
|
224
|
+
[data-look="button"],
|
|
225
|
+
:not([data-look]):is([data-kumiko-file-input~="button"] *)
|
|
226
|
+
)
|
|
227
|
+
) {
|
|
228
|
+
& [data-slot="file-input-dropzone"]:not([data-page-wide]) {
|
|
229
|
+
display: contents;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
& [data-slot="file-input-trigger"] {
|
|
233
|
+
justify-self: start;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
&
|
|
237
|
+
[data-slot="file-input-dropzone"]:not([data-page-wide])
|
|
238
|
+
> :is([data-slot="file-input-icon"], [data-slot="file-input-text"]) {
|
|
239
|
+
display: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
& [data-slot="file-input-trigger"]::after {
|
|
243
|
+
content: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
& [data-slot="file-input-trigger"]:focus-visible {
|
|
247
|
+
outline: 2px solid var(--kumiko-file-input-focus-ring);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&[data-dragging] [data-slot="file-input-trigger"] {
|
|
251
|
+
outline: 2px solid var(--_file-accent);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* The page-wide zone: a layer over the page that shows while files are over the window. Drops go through it. */
|
|
256
|
+
:where([data-slot="file-input-dropzone"][data-page-wide]) {
|
|
257
|
+
position: fixed;
|
|
258
|
+
z-index: var(--kumiko-file-input-overlay-z);
|
|
259
|
+
display: grid;
|
|
260
|
+
visibility: hidden;
|
|
261
|
+
background: var(--kumiko-file-input-overlay-bg);
|
|
262
|
+
opacity: 0;
|
|
263
|
+
backdrop-filter: blur(var(--kumiko-file-input-overlay-blur));
|
|
264
|
+
inset: 0;
|
|
265
|
+
place-items: center;
|
|
266
|
+
pointer-events: none;
|
|
267
|
+
transition:
|
|
268
|
+
opacity var(--kumiko-fade-duration) var(--kumiko-enter-ease),
|
|
269
|
+
visibility 0s linear var(--kumiko-fade-duration);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
:where([data-slot="file-input-dropzone"][data-page-wide][data-dragging]) {
|
|
273
|
+
visibility: visible;
|
|
274
|
+
opacity: 1;
|
|
275
|
+
transition:
|
|
276
|
+
opacity var(--kumiko-fade-duration) var(--kumiko-enter-ease),
|
|
277
|
+
visibility 0s;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
:where([data-slot="file-input-overlay"]) {
|
|
281
|
+
display: grid;
|
|
282
|
+
padding: 2rem 2.5rem;
|
|
283
|
+
border: var(--kumiko-file-input-border-width) dashed var(--_file-accent);
|
|
284
|
+
border-radius: var(--kumiko-file-input-radius);
|
|
285
|
+
font-size: 1.125rem;
|
|
286
|
+
font-weight: 600;
|
|
287
|
+
gap: var(--kumiko-file-input-gap);
|
|
288
|
+
justify-items: center;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
:where(
|
|
292
|
+
[data-slot="file-input-dropzone"][data-page-wide][data-drag-reject]
|
|
293
|
+
[data-slot="file-input-overlay"]
|
|
294
|
+
) {
|
|
295
|
+
border-color: var(--_file-reject);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* The list: one row per file, with its preview, name, size and upload, and a × at the end. */
|
|
299
|
+
:where([data-slot="file-input-list"]) {
|
|
300
|
+
display: grid;
|
|
301
|
+
gap: 0.5rem;
|
|
302
|
+
|
|
303
|
+
&:empty {
|
|
304
|
+
display: none;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
:where([data-slot="file-input-item"]) {
|
|
309
|
+
display: grid;
|
|
310
|
+
box-sizing: border-box;
|
|
311
|
+
padding: 0.5rem 0.5rem 0.5rem 0.625rem;
|
|
312
|
+
border-radius: var(--kumiko-file-input-item-radius);
|
|
313
|
+
background: var(--kumiko-file-input-item-bg);
|
|
314
|
+
align-items: center;
|
|
315
|
+
column-gap: 0.75rem;
|
|
316
|
+
grid-template:
|
|
317
|
+
"preview name remove" auto
|
|
318
|
+
"preview meta remove" auto
|
|
319
|
+
"preview progress remove" auto / auto minmax(0, 1fr) auto;
|
|
320
|
+
|
|
321
|
+
&:focus-visible {
|
|
322
|
+
outline: 2px solid var(--kumiko-file-input-focus-ring);
|
|
323
|
+
outline-offset: 1px;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
:where([data-slot="file-preview"]) {
|
|
328
|
+
display: grid;
|
|
329
|
+
overflow: hidden;
|
|
330
|
+
inline-size: var(--kumiko-file-input-preview-size);
|
|
331
|
+
block-size: var(--kumiko-file-input-preview-size);
|
|
332
|
+
border-radius: 0.5rem;
|
|
333
|
+
background: color-mix(in oklab, currentColor 9%, transparent);
|
|
334
|
+
grid-area: preview;
|
|
335
|
+
place-items: center;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
:where([data-slot="file-preview-image"]) {
|
|
339
|
+
inline-size: 100%;
|
|
340
|
+
block-size: 100%;
|
|
341
|
+
object-fit: cover;
|
|
342
|
+
animation: kumiko-file-preview-in var(--kumiko-fade-duration) var(--kumiko-enter-ease);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@keyframes kumiko-file-preview-in {
|
|
346
|
+
from {
|
|
347
|
+
opacity: 0;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
:where([data-slot="file-preview-badge"]) {
|
|
352
|
+
color: var(--kumiko-file-input-hint-fg);
|
|
353
|
+
font-size: 0.625rem;
|
|
354
|
+
font-weight: 700;
|
|
355
|
+
letter-spacing: 0.04em;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
:where([data-slot="file-input-item-name"]) {
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
font-weight: 500;
|
|
361
|
+
text-overflow: ellipsis;
|
|
362
|
+
white-space: nowrap;
|
|
363
|
+
grid-area: name;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
:where([data-slot="file-input-item-meta"]) {
|
|
367
|
+
display: flex;
|
|
368
|
+
color: var(--kumiko-file-input-hint-fg);
|
|
369
|
+
font-size: 0.8125em;
|
|
370
|
+
gap: 0.5rem;
|
|
371
|
+
grid-area: meta;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
:where([data-slot="file-input-item-status"][data-phase="done"]) {
|
|
375
|
+
color: var(--kumiko-file-input-done);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
:where([data-slot="file-input-item-status"][data-phase="failed"]) {
|
|
379
|
+
color: var(--_file-reject);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
:where([data-slot="file-input-item"] > [data-slot="progress"]) {
|
|
383
|
+
margin-block-start: 0.375rem;
|
|
384
|
+
grid-area: progress;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
:where([data-kumiko-file-remove]) {
|
|
388
|
+
position: relative;
|
|
389
|
+
display: inline-grid;
|
|
390
|
+
box-sizing: border-box;
|
|
391
|
+
inline-size: 2rem;
|
|
392
|
+
block-size: 2rem;
|
|
393
|
+
margin: 0;
|
|
394
|
+
padding: 0;
|
|
395
|
+
border: 0;
|
|
396
|
+
border-radius: 999px;
|
|
397
|
+
background: transparent;
|
|
398
|
+
color: var(--kumiko-file-input-hint-fg);
|
|
399
|
+
font: inherit;
|
|
400
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
401
|
+
grid-area: remove;
|
|
402
|
+
place-items: center;
|
|
403
|
+
transition:
|
|
404
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-enter-ease),
|
|
405
|
+
color var(--kumiko-fade-duration) var(--kumiko-enter-ease);
|
|
406
|
+
|
|
407
|
+
& > svg {
|
|
408
|
+
inline-size: 1rem;
|
|
409
|
+
block-size: 1rem;
|
|
410
|
+
fill: none;
|
|
411
|
+
stroke: currentColor;
|
|
412
|
+
stroke-linecap: round;
|
|
413
|
+
stroke-width: 1.75;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/* The press area reaches the touch target, though the × is drawn smaller. */
|
|
417
|
+
&::after {
|
|
418
|
+
position: absolute;
|
|
419
|
+
content: "";
|
|
420
|
+
inline-size: var(--kumiko-touch-target, 2.75rem);
|
|
421
|
+
block-size: var(--kumiko-touch-target, 2.75rem);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
@media (hover: hover) and (pointer: fine) {
|
|
426
|
+
:where([data-kumiko-file-remove]:not([data-disabled]):hover) {
|
|
427
|
+
background: var(--kumiko-file-input-trigger-bg);
|
|
428
|
+
color: inherit;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* The files the last choice turned away, with why, and a button to clear them. */
|
|
433
|
+
:where([data-slot="file-input-rejections"]) {
|
|
434
|
+
display: flex;
|
|
435
|
+
box-sizing: border-box;
|
|
436
|
+
padding: 0.625rem 0.75rem;
|
|
437
|
+
border-radius: var(--kumiko-file-input-item-radius);
|
|
438
|
+
background: color-mix(in oklab, var(--_file-reject) 10%, transparent);
|
|
439
|
+
font-size: 0.875em;
|
|
440
|
+
align-items: start;
|
|
441
|
+
gap: 0.75rem;
|
|
442
|
+
|
|
443
|
+
& ul {
|
|
444
|
+
display: grid;
|
|
445
|
+
flex: 1;
|
|
446
|
+
min-inline-size: 0;
|
|
447
|
+
margin: 0;
|
|
448
|
+
padding: 0;
|
|
449
|
+
gap: 0.25rem;
|
|
450
|
+
list-style: none;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
& li {
|
|
454
|
+
display: flex;
|
|
455
|
+
flex-wrap: wrap;
|
|
456
|
+
column-gap: 0.5rem;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
:where([data-slot="file-input-rejection-name"]) {
|
|
461
|
+
overflow: hidden;
|
|
462
|
+
font-weight: 600;
|
|
463
|
+
text-overflow: ellipsis;
|
|
464
|
+
white-space: nowrap;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
:where([data-slot="file-input-rejection-reason"]) {
|
|
468
|
+
color: var(--_file-reject);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
:where([data-slot="file-input-rejections-dismiss"]) {
|
|
472
|
+
flex: none;
|
|
473
|
+
margin: 0;
|
|
474
|
+
padding: 0.125rem 0.375rem;
|
|
475
|
+
border: 0;
|
|
476
|
+
border-radius: 0.375rem;
|
|
477
|
+
background: transparent;
|
|
478
|
+
color: inherit;
|
|
479
|
+
font: inherit;
|
|
480
|
+
font-weight: 600;
|
|
481
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
482
|
+
|
|
483
|
+
&:focus-visible {
|
|
484
|
+
outline: 2px solid var(--kumiko-file-input-focus-ring);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
@media (forced-colors: active) {
|
|
489
|
+
:where([data-slot="file-input-dropzone"]:not([data-page-wide])) {
|
|
490
|
+
border-color: CanvasText;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
:where([data-slot="file-input-dropzone"][data-drag-accept]) {
|
|
494
|
+
border-color: Highlight;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
:where(
|
|
498
|
+
[data-slot="file-input-trigger"],
|
|
499
|
+
[data-slot="file-input-item"],
|
|
500
|
+
[data-slot="file-preview"]
|
|
501
|
+
) {
|
|
502
|
+
border: 1px solid CanvasText;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileInput as SdkFileInput, FileInputDropzone as SdkFileInputDropzone, FileInputItemRemove } from "@ui-sdk/react/file-input";
|
|
2
|
+
/**
|
|
3
|
+
* How the file input looks: a dashed zone with an icon, a title and a button; one compact row; or just the
|
|
4
|
+
* button. A click anywhere on a zone or a row opens the picker.
|
|
5
|
+
*/
|
|
6
|
+
export type FileInputLook = "zone" | "compact" | "button";
|
|
7
|
+
export type FileInputProps = React.ComponentProps<typeof SdkFileInput> & {
|
|
8
|
+
/**
|
|
9
|
+
* Without it, `data-kumiko-file-input="compact"` or `"button"` on any container picks.
|
|
10
|
+
* @defaultValue "zone"
|
|
11
|
+
*/
|
|
12
|
+
look?: FileInputLook;
|
|
13
|
+
};
|
|
14
|
+
/** Ui-sdk's file input, with Kumiko's look. */
|
|
15
|
+
export declare function FileInput({ look, ...props }: FileInputProps): React.JSX.Element | null;
|
|
16
|
+
export type FileInputDropzoneProps = React.ComponentProps<typeof SdkFileInputDropzone>;
|
|
17
|
+
/**
|
|
18
|
+
* Ui-sdk's drop zone. With `target="document"` it takes files dropped anywhere on the page, and Kumiko draws it
|
|
19
|
+
* as a full-page layer that shows only while files are over the window.
|
|
20
|
+
*/
|
|
21
|
+
export declare function FileInputDropzone(props: FileInputDropzoneProps): React.JSX.Element;
|
|
22
|
+
export interface FileInputRemoveButtonProps extends React.ComponentProps<typeof FileInputItemRemove> {
|
|
23
|
+
/** What screen readers call it. Without it, ui-sdk names it "Remove" and the file's name. */
|
|
24
|
+
label?: string;
|
|
25
|
+
}
|
|
26
|
+
/** A × that removes its item's file. */
|
|
27
|
+
export declare function FileInputRemoveButton({ label, children, ...props }: FileInputRemoveButtonProps): React.JSX.Element;
|
|
28
|
+
/** An upload arrow for a drop zone. */
|
|
29
|
+
export declare function FileInputIcon(props: React.ComponentProps<"svg">): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FileInput as SdkFileInput, FileInputDropzone as SdkFileInputDropzone, FileInputItemRemove } from "@ui-sdk/react/file-input";
|
|
3
|
+
/** Ui-sdk's file input, with Kumiko's look. */
|
|
4
|
+
export function FileInput({ look, ...props }) {
|
|
5
|
+
return _jsx(SdkFileInput, { "data-look": look, ...props });
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Ui-sdk's drop zone. With `target="document"` it takes files dropped anywhere on the page, and Kumiko draws it
|
|
9
|
+
* as a full-page layer that shows only while files are over the window.
|
|
10
|
+
*/
|
|
11
|
+
export function FileInputDropzone(props) {
|
|
12
|
+
return (_jsx(SdkFileInputDropzone, { "data-page-wide": props.target === "document" ? "" : undefined, ...props }));
|
|
13
|
+
}
|
|
14
|
+
/** A × that removes its item's file. */
|
|
15
|
+
export function FileInputRemoveButton({ label, children, ...props }) {
|
|
16
|
+
return (_jsx(FileInputItemRemove, { "aria-label": label, "data-kumiko-file-remove": "", ...props, children: children ?? (_jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": true, focusable: "false", children: _jsx("path", { d: "M4 4l8 8M12 4l-8 8" }) })) }));
|
|
17
|
+
}
|
|
18
|
+
/** An upload arrow for a drop zone. */
|
|
19
|
+
export function FileInputIcon(props) {
|
|
20
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": true, focusable: "false", "data-slot": "file-input-icon", ...props, children: _jsx("path", { d: "M12 15V4M7.5 8.5 12 4l4.5 4.5M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4" }) }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The extension a file's badge shows, like `"PDF"`: at most four letters, upper case. */
|
|
2
|
+
export declare function extensionOf(name: string): string;
|
|
3
|
+
/** Whether a browser can draw the file as a picture. */
|
|
4
|
+
export declare function isPicture(file: File): boolean;
|
|
5
|
+
export interface FilePreviewProps extends React.ComponentProps<"span"> {
|
|
6
|
+
file: File;
|
|
7
|
+
/** Shows a picture's thumbnail instead of its badge. @defaultValue true */
|
|
8
|
+
thumbnail?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A small square for a file: the picture itself for an image, or a page badge with the file's extension. A
|
|
12
|
+
* picture the browser can't decode shows the badge too. Screen readers skip it; the file's name is written beside
|
|
13
|
+
* it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function FilePreview({ file, thumbnail, ...props }: FilePreviewProps): React.JSX.Element;
|