@ismou-workspace/ui 0.0.0-stage → 0.1.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/README.md +17 -2
- package/dist/brand/app-brands.d.ts +59 -0
- package/dist/brand/app-brands.js +130 -0
- package/dist/brand/app-icon.d.ts +34 -0
- package/dist/brand/app-icon.js +65 -0
- package/dist/brand/app-logo.d.ts +14 -0
- package/dist/brand/app-logo.js +27 -0
- package/dist/brand/favicons/account.svg +1 -0
- package/dist/brand/favicons/admin.svg +1 -0
- package/dist/brand/favicons/calendar.svg +1 -0
- package/dist/brand/favicons/contacts.svg +1 -0
- package/dist/brand/favicons/core.svg +1 -0
- package/dist/brand/favicons/drive.svg +1 -0
- package/dist/brand/favicons/google.svg +1 -0
- package/dist/brand/favicons/office.svg +1 -0
- package/dist/brand/file-icons/archive.svg +1 -0
- package/dist/brand/file-icons/audio.svg +1 -0
- package/dist/brand/file-icons/code.svg +1 -0
- package/dist/brand/file-icons/diagram.svg +1 -0
- package/dist/brand/file-icons/document.svg +1 -0
- package/dist/brand/file-icons/form.svg +1 -0
- package/dist/brand/file-icons/image.svg +1 -0
- package/dist/brand/file-icons/markdown.svg +1 -0
- package/dist/brand/file-icons/other.svg +1 -0
- package/dist/brand/file-icons/pdf.svg +1 -0
- package/dist/brand/file-icons/presentation.svg +1 -0
- package/dist/brand/file-icons/spreadsheet.svg +1 -0
- package/dist/brand/file-icons/text.svg +1 -0
- package/dist/brand/file-icons/video.svg +1 -0
- package/dist/brand/grain-surface.d.ts +8 -0
- package/dist/brand/grain-surface.js +10 -0
- package/dist/brand/kind-icons.d.ts +36 -0
- package/dist/brand/kind-icons.js +149 -0
- package/dist/components/account-menu.d.ts +20 -0
- package/dist/components/account-menu.js +13 -0
- package/dist/components/alert.d.ts +10 -0
- package/dist/components/alert.js +28 -0
- package/dist/components/app-switcher.d.ts +21 -0
- package/dist/components/app-switcher.js +17 -0
- package/dist/components/area-selection.d.ts +21 -0
- package/dist/components/area-selection.js +91 -0
- package/dist/components/avatar-picker-dialog.d.ts +40 -0
- package/dist/components/avatar-picker-dialog.js +110 -0
- package/dist/components/avatar.d.ts +5 -0
- package/dist/components/avatar.js +10 -0
- package/dist/components/badge-list.d.ts +7 -0
- package/dist/components/badge-list.js +7 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +32 -0
- package/dist/components/breadcrumbs.d.ts +20 -0
- package/dist/components/breadcrumbs.js +16 -0
- package/dist/components/button.d.ts +12 -0
- package/dist/components/button.js +38 -0
- package/dist/components/caption.d.ts +3 -0
- package/dist/components/caption.js +6 -0
- package/dist/components/card.d.ts +8 -0
- package/dist/components/card.js +23 -0
- package/dist/components/checkbox-field.d.ts +10 -0
- package/dist/components/checkbox-field.js +8 -0
- package/dist/components/checkbox.d.ts +3 -0
- package/dist/components/checkbox.js +7 -0
- package/dist/components/code.d.ts +16 -0
- package/dist/components/code.js +32 -0
- package/dist/components/color-dot.d.ts +11 -0
- package/dist/components/color-dot.js +34 -0
- package/dist/components/corner-mark.d.ts +14 -0
- package/dist/components/corner-mark.js +27 -0
- package/dist/components/date-range-field.d.ts +9 -0
- package/dist/components/date-range-field.js +9 -0
- package/dist/components/description-list.d.ts +11 -0
- package/dist/components/description-list.js +10 -0
- package/dist/components/dialog.d.ts +16 -0
- package/dist/components/dialog.js +38 -0
- package/dist/components/drag-and-drop.d.ts +60 -0
- package/dist/components/drag-and-drop.js +141 -0
- package/dist/components/dropdown-menu.d.ts +27 -0
- package/dist/components/dropdown-menu.js +44 -0
- package/dist/components/entity-avatar.d.ts +28 -0
- package/dist/components/entity-avatar.js +22 -0
- package/dist/components/entity-menu.d.ts +67 -0
- package/dist/components/entity-menu.js +74 -0
- package/dist/components/error-alert.d.ts +7 -0
- package/dist/components/error-alert.js +9 -0
- package/dist/components/event-chip.d.ts +16 -0
- package/dist/components/event-chip.js +19 -0
- package/dist/components/fab.d.ts +21 -0
- package/dist/components/fab.js +14 -0
- package/dist/components/file-drop-zone.d.ts +35 -0
- package/dist/components/file-drop-zone.js +44 -0
- package/dist/components/file-type-icon.d.ts +44 -0
- package/dist/components/file-type-icon.js +147 -0
- package/dist/components/icon-image.d.ts +10 -0
- package/dist/components/icon-image.js +11 -0
- package/dist/components/identity.d.ts +27 -0
- package/dist/components/identity.js +22 -0
- package/dist/components/inline-field.d.ts +40 -0
- package/dist/components/inline-field.js +110 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +14 -0
- package/dist/components/item-list.d.ts +11 -0
- package/dist/components/item-list.js +15 -0
- package/dist/components/label.d.ts +3 -0
- package/dist/components/label.js +6 -0
- package/dist/components/mini-month.d.ts +15 -0
- package/dist/components/mini-month.js +35 -0
- package/dist/components/placeholder-avatar.d.ts +12 -0
- package/dist/components/placeholder-avatar.js +6 -0
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/popover.js +16 -0
- package/dist/components/progress-list.d.ts +31 -0
- package/dist/components/progress-list.js +15 -0
- package/dist/components/progress-ring.d.ts +13 -0
- package/dist/components/progress-ring.js +14 -0
- package/dist/components/progress.d.ts +10 -0
- package/dist/components/progress.js +12 -0
- package/dist/components/search-box.d.ts +25 -0
- package/dist/components/search-box.js +56 -0
- package/dist/components/searchable-options.d.ts +32 -0
- package/dist/components/searchable-options.js +17 -0
- package/dist/components/section-label.d.ts +7 -0
- package/dist/components/section-label.js +8 -0
- package/dist/components/segmented-control.d.ts +21 -0
- package/dist/components/segmented-control.js +9 -0
- package/dist/components/select-menu.d.ts +38 -0
- package/dist/components/select-menu.js +26 -0
- package/dist/components/selection-bar.d.ts +17 -0
- package/dist/components/selection-bar.js +15 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +6 -0
- package/dist/components/share-dialog.d.ts +63 -0
- package/dist/components/share-dialog.js +74 -0
- package/dist/components/sheet.d.ts +20 -0
- package/dist/components/sheet.js +24 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +5 -0
- package/dist/components/spinner.d.ts +3 -0
- package/dist/components/spinner.js +8 -0
- package/dist/components/table.d.ts +7 -0
- package/dist/components/table.js +20 -0
- package/dist/components/text-link.d.ts +9 -0
- package/dist/components/text-link.js +9 -0
- package/dist/components/text.d.ts +13 -0
- package/dist/components/text.js +8 -0
- package/dist/components/toaster.d.ts +8 -0
- package/dist/components/toaster.js +27 -0
- package/dist/components/viewer-dialog.d.ts +37 -0
- package/dist/components/viewer-dialog.js +53 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +87 -0
- package/dist/layout/app-frame.d.ts +42 -0
- package/dist/layout/app-frame.js +62 -0
- package/dist/layout/app-shell.d.ts +11 -0
- package/dist/layout/app-shell.js +7 -0
- package/dist/layout/document-title.d.ts +14 -0
- package/dist/layout/document-title.js +39 -0
- package/dist/layout/empty-state.d.ts +16 -0
- package/dist/layout/empty-state.js +19 -0
- package/dist/layout/entity-header.d.ts +14 -0
- package/dist/layout/entity-header.js +6 -0
- package/dist/layout/form-field.d.ts +10 -0
- package/dist/layout/form-field.js +9 -0
- package/dist/layout/form-grid.d.ts +6 -0
- package/dist/layout/form-grid.js +9 -0
- package/dist/layout/full-page-message.d.ts +10 -0
- package/dist/layout/full-page-message.js +5 -0
- package/dist/layout/full-page-surface.d.ts +12 -0
- package/dist/layout/full-page-surface.js +8 -0
- package/dist/layout/month-grid.d.ts +31 -0
- package/dist/layout/month-grid.js +12 -0
- package/dist/layout/page-header.d.ts +14 -0
- package/dist/layout/page-header.js +11 -0
- package/dist/layout/panel.d.ts +15 -0
- package/dist/layout/panel.js +12 -0
- package/dist/layout/retry-message.d.ts +8 -0
- package/dist/layout/retry-message.js +9 -0
- package/dist/layout/route-error-message.d.ts +9 -0
- package/dist/layout/route-error-message.js +9 -0
- package/dist/layout/row-list.d.ts +87 -0
- package/dist/layout/row-list.js +67 -0
- package/dist/layout/settings-section.d.ts +14 -0
- package/dist/layout/settings-section.js +11 -0
- package/dist/layout/sidebar-nav.d.ts +79 -0
- package/dist/layout/sidebar-nav.js +59 -0
- package/dist/layout/sign-in-layout.d.ts +19 -0
- package/dist/layout/sign-in-layout.js +11 -0
- package/dist/layout/sortable-row-list.d.ts +27 -0
- package/dist/layout/sortable-row-list.js +61 -0
- package/dist/layout/stack.d.ts +41 -0
- package/dist/layout/stack.js +51 -0
- package/dist/layout/tile-grid.d.ts +75 -0
- package/dist/layout/tile-grid.js +71 -0
- package/dist/layout/time-grid.d.ts +40 -0
- package/dist/layout/time-grid.js +63 -0
- package/dist/layout/use-favicon.d.ts +5 -0
- package/dist/layout/use-favicon.js +20 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/initials.d.ts +2 -0
- package/dist/lib/initials.js +7 -0
- package/dist/mascot/mascot.d.ts +23 -0
- package/dist/mascot/mascot.definition.json +14 -0
- package/dist/mascot/mascot.js +49 -0
- package/dist/mascot/use-thinking-motion.d.ts +8 -0
- package/dist/mascot/use-thinking-motion.js +68 -0
- package/dist/styles.css +385 -0
- package/dist/vite/ismou-favicon.plugin.d.ts +10 -0
- package/dist/vite/ismou-favicon.plugin.js +67 -0
- package/dist/vite/phosphor-icons.plugin.d.ts +8 -0
- package/dist/vite/phosphor-icons.plugin.js +61 -0
- package/package.json +98 -3
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import folderIcon from '../brand/favicons/drive.svg';
|
|
5
|
+
import archiveIcon from '../brand/file-icons/archive.svg';
|
|
6
|
+
import audioIcon from '../brand/file-icons/audio.svg';
|
|
7
|
+
import codeIcon from '../brand/file-icons/code.svg';
|
|
8
|
+
import documentIcon from '../brand/file-icons/document.svg';
|
|
9
|
+
import imageIcon from '../brand/file-icons/image.svg';
|
|
10
|
+
import otherIcon from '../brand/file-icons/other.svg';
|
|
11
|
+
import pdfIcon from '../brand/file-icons/pdf.svg';
|
|
12
|
+
import presentationIcon from '../brand/file-icons/presentation.svg';
|
|
13
|
+
import spreadsheetIcon from '../brand/file-icons/spreadsheet.svg';
|
|
14
|
+
import textIcon from '../brand/file-icons/text.svg';
|
|
15
|
+
import videoIcon from '../brand/file-icons/video.svg';
|
|
16
|
+
import { cn } from '../lib/cn.js';
|
|
17
|
+
import { CornerMark } from './corner-mark.js';
|
|
18
|
+
const EXTENSIONS = {
|
|
19
|
+
zip: 'archive',
|
|
20
|
+
rar: 'archive',
|
|
21
|
+
'7z': 'archive',
|
|
22
|
+
tar: 'archive',
|
|
23
|
+
gz: 'archive',
|
|
24
|
+
xls: 'spreadsheet',
|
|
25
|
+
xlsx: 'spreadsheet',
|
|
26
|
+
ods: 'spreadsheet',
|
|
27
|
+
csv: 'spreadsheet',
|
|
28
|
+
ppt: 'presentation',
|
|
29
|
+
pptx: 'presentation',
|
|
30
|
+
odp: 'presentation',
|
|
31
|
+
key: 'presentation',
|
|
32
|
+
doc: 'document',
|
|
33
|
+
docx: 'document',
|
|
34
|
+
odt: 'document',
|
|
35
|
+
rtf: 'document',
|
|
36
|
+
pages: 'document',
|
|
37
|
+
md: 'text',
|
|
38
|
+
txt: 'text',
|
|
39
|
+
log: 'text',
|
|
40
|
+
js: 'code',
|
|
41
|
+
jsx: 'code',
|
|
42
|
+
ts: 'code',
|
|
43
|
+
tsx: 'code',
|
|
44
|
+
json: 'code',
|
|
45
|
+
html: 'code',
|
|
46
|
+
css: 'code',
|
|
47
|
+
py: 'code',
|
|
48
|
+
java: 'code',
|
|
49
|
+
c: 'code',
|
|
50
|
+
cpp: 'code',
|
|
51
|
+
cs: 'code',
|
|
52
|
+
go: 'code',
|
|
53
|
+
rs: 'code',
|
|
54
|
+
rb: 'code',
|
|
55
|
+
php: 'code',
|
|
56
|
+
sh: 'code',
|
|
57
|
+
sql: 'code',
|
|
58
|
+
xml: 'code',
|
|
59
|
+
yaml: 'code',
|
|
60
|
+
yml: 'code',
|
|
61
|
+
};
|
|
62
|
+
/** Its category, from the declared type first, the name's extension otherwise. */
|
|
63
|
+
export function fileCategoryOf(contentType, name = '') {
|
|
64
|
+
const type = (contentType ?? '').toLowerCase();
|
|
65
|
+
if (type === 'application/pdf')
|
|
66
|
+
return 'pdf';
|
|
67
|
+
if (type.startsWith('image/'))
|
|
68
|
+
return 'image';
|
|
69
|
+
if (type.startsWith('video/'))
|
|
70
|
+
return 'video';
|
|
71
|
+
if (type.startsWith('audio/'))
|
|
72
|
+
return 'audio';
|
|
73
|
+
const dot = name.lastIndexOf('.');
|
|
74
|
+
const extension = dot > 0 ? name.slice(dot + 1).toLowerCase() : '';
|
|
75
|
+
if (extension === 'pdf')
|
|
76
|
+
return 'pdf';
|
|
77
|
+
const byExtension = EXTENSIONS[extension];
|
|
78
|
+
if (byExtension)
|
|
79
|
+
return byExtension;
|
|
80
|
+
if (type.startsWith('text/'))
|
|
81
|
+
return 'text';
|
|
82
|
+
return 'other';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Each category's icon, as shipped in `brand/file-icons/` (generated by `fileIconSvg`, like the
|
|
86
|
+
* kinds' icons apps serve): a tile of its colour under a quiet grain, a white glyph of what it
|
|
87
|
+
* holds. A folder is the drive's own mark (a folder, not a file: `favicons/drive.svg`). Pictures
|
|
88
|
+
* rather than markup: a whole image keeps its glyph centred at any position.
|
|
89
|
+
*/
|
|
90
|
+
const CATEGORY_ICONS = {
|
|
91
|
+
folder: folderIcon,
|
|
92
|
+
image: imageIcon,
|
|
93
|
+
video: videoIcon,
|
|
94
|
+
audio: audioIcon,
|
|
95
|
+
pdf: pdfIcon,
|
|
96
|
+
archive: archiveIcon,
|
|
97
|
+
spreadsheet: spreadsheetIcon,
|
|
98
|
+
presentation: presentationIcon,
|
|
99
|
+
document: documentIcon,
|
|
100
|
+
code: codeIcon,
|
|
101
|
+
text: textIcon,
|
|
102
|
+
other: otherIcon,
|
|
103
|
+
};
|
|
104
|
+
const fileTypeIconVariants = cva('flex shrink-0 select-none object-contain', {
|
|
105
|
+
variants: {
|
|
106
|
+
size: {
|
|
107
|
+
/** Beside a name, as a hint of what it is. */
|
|
108
|
+
xs: 'size-5',
|
|
109
|
+
/** A compact row, a menu, a drag preview. */
|
|
110
|
+
sm: 'size-6',
|
|
111
|
+
/** A row of a list. */
|
|
112
|
+
md: 'size-10',
|
|
113
|
+
/** A detail panel's header. */
|
|
114
|
+
lg: 'size-14',
|
|
115
|
+
/** A grid tile's media. */
|
|
116
|
+
xl: 'size-16',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
defaultVariants: { size: 'md' },
|
|
120
|
+
});
|
|
121
|
+
/** A thumbnail's corners (the icons draw their own): about a quarter of the tile, like theirs. */
|
|
122
|
+
const THUMBNAIL_RADII = {
|
|
123
|
+
xs: 'rounded-sm',
|
|
124
|
+
sm: 'rounded-md',
|
|
125
|
+
md: 'rounded-lg',
|
|
126
|
+
lg: 'rounded-xl',
|
|
127
|
+
xl: 'rounded-xl',
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* What a file or a folder is, at a glance: the file's own thumbnail when there is one, else the
|
|
131
|
+
* icon of its kind an app serves, else the icon of its category, with an optional badge over its
|
|
132
|
+
* corner.
|
|
133
|
+
*/
|
|
134
|
+
export function FileTypeIcon({ kind, contentType, name, thumbnailUrl, fit, iconUrl, badge, size, className, }) {
|
|
135
|
+
const [failed, setFailed] = useState(new Set());
|
|
136
|
+
const category = kind === 'folder' ? 'folder' : fileCategoryOf(contentType, name);
|
|
137
|
+
// The first picture that loads: the thumbnail, the kind's icon, then the category's.
|
|
138
|
+
const shown = [thumbnailUrl, kind === 'file' ? iconUrl : undefined].find((url) => url !== undefined && !failed.has(url)) ?? CATEGORY_ICONS[category];
|
|
139
|
+
const picture = (_jsx("img", { src: shown, alt: "", loading: "lazy", draggable: false, onError: () => setFailed((current) => new Set(current).add(shown)), "data-slot": "file-type-icon", "data-category": category, className: cn(fileTypeIconVariants({ size }), shown === thumbnailUrl && [
|
|
140
|
+
'bg-muted',
|
|
141
|
+
THUMBNAIL_RADII[size ?? 'md'],
|
|
142
|
+
fit && ['object-cover', fit === 'top' ? 'object-top' : 'object-center'],
|
|
143
|
+
], className) }));
|
|
144
|
+
if (!badge)
|
|
145
|
+
return picture;
|
|
146
|
+
return (_jsxs("span", { "data-slot": "file-type-icon-badged", className: "relative flex shrink-0", children: [picture, _jsx(CornerMark, { size: size, children: badge })] }));
|
|
147
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface IconImageProps {
|
|
2
|
+
/** Where the picture is served (an app's icon for a kind of file it handles). */
|
|
3
|
+
src: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A picture standing where a Phosphor icon would (a menu item, a button): the same size, kept
|
|
8
|
+
* whole. One that can't be loaded leaves its room empty, so labels stay aligned.
|
|
9
|
+
*/
|
|
10
|
+
export declare function IconImage({ src, className }: IconImageProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
/**
|
|
5
|
+
* A picture standing where a Phosphor icon would (a menu item, a button): the same size, kept
|
|
6
|
+
* whole. One that can't be loaded leaves its room empty, so labels stay aligned.
|
|
7
|
+
*/
|
|
8
|
+
export function IconImage({ src, className }) {
|
|
9
|
+
const [failed, setFailed] = useState(false);
|
|
10
|
+
return (_jsx("img", { src: src, alt: "", draggable: false, onError: () => setFailed(true), "data-slot": "icon-image", className: cn('pointer-events-none size-4 shrink-0 object-contain', failed && 'invisible', className) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
declare const identityVariants: (props?: ({
|
|
4
|
+
size?: "md" | "sm" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export interface IdentityProps extends Omit<React.ComponentProps<'div'>, 'title'>, VariantProps<typeof identityVariants> {
|
|
7
|
+
/** The avatar, icon or logo. */
|
|
8
|
+
media?: React.ReactNode;
|
|
9
|
+
/** The name: text, or a link. */
|
|
10
|
+
title: React.ReactNode;
|
|
11
|
+
/** A small icon on the name's line, before it (a file's type under its picture). */
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
/** Shown after the name, e.g. a "You" badge. */
|
|
14
|
+
badge?: React.ReactNode;
|
|
15
|
+
/** The line under the name, muted (an email, an address). */
|
|
16
|
+
description?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/** Who or what an entity is: its picture, its name and what helps recognize it. */
|
|
19
|
+
export declare function Identity({ media, title, icon, badge, description, size, className, ...props }: IdentityProps): React.JSX.Element;
|
|
20
|
+
export interface InlineIdentityProps {
|
|
21
|
+
/** A small icon, e.g. an `AppIcon` of size `inline`. */
|
|
22
|
+
media?: React.ReactNode;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/** A name with its icon inside a sentence: "via [icon] Contacts". */
|
|
26
|
+
export declare function InlineIdentity({ media, children }: InlineIdentityProps): React.JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
const identityVariants = cva('flex min-w-0 items-center text-sm', {
|
|
5
|
+
variants: {
|
|
6
|
+
size: {
|
|
7
|
+
/** Inline with text or in an option: a small mark, a plain name. */
|
|
8
|
+
sm: 'gap-2',
|
|
9
|
+
/** A row of a list: an avatar, a name in medium weight. */
|
|
10
|
+
md: 'gap-3.5',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: { size: 'md' },
|
|
14
|
+
});
|
|
15
|
+
/** Who or what an entity is: its picture, its name and what helps recognize it. */
|
|
16
|
+
export function Identity({ media, title, icon, badge, description, size, className, ...props }) {
|
|
17
|
+
return (_jsxs("div", { "data-slot": "identity", className: cn(identityVariants({ size }), className), ...props, children: [media && _jsx("span", { className: "flex shrink-0", children: media }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsxs("span", { "data-slot": "identity-line", className: "flex min-w-0 items-center gap-2", children: [icon && _jsx("span", { className: "flex shrink-0", children: icon }), _jsx("span", { className: cn('truncate', size !== 'sm' && 'font-medium'), children: title }), badge] }), description && (_jsx("span", { className: "truncate text-muted-foreground text-xs", children: description }))] })] }));
|
|
18
|
+
}
|
|
19
|
+
/** A name with its icon inside a sentence: "via [icon] Contacts". */
|
|
20
|
+
export function InlineIdentity({ media, children }) {
|
|
21
|
+
return (_jsxs("span", { "data-slot": "inline-identity", className: "inline-flex items-center gap-1 align-bottom font-medium text-foreground", children: [media, children] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface InlineFieldProps {
|
|
3
|
+
/** The saved value, shown when not editing. */
|
|
4
|
+
value: string;
|
|
5
|
+
/**
|
|
6
|
+
* Saves a new value (called only when it changed). While its promise is pending the field
|
|
7
|
+
* stays in edit mode, read-only, with a spinner; a rejection keeps the field open with the
|
|
8
|
+
* draft so the caller can show `error` and the person can retry or press Escape.
|
|
9
|
+
*/
|
|
10
|
+
onCommit: (value: string) => void | Promise<void>;
|
|
11
|
+
/** Visible label above the value; also names the button and the input. */
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
/** Shown, muted, when the value is empty. Also the input placeholder. */
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
type?: 'text' | 'email' | 'tel' | 'date';
|
|
16
|
+
/** Error message under the field; marks the input invalid. */
|
|
17
|
+
error?: React.ReactNode;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** The account may not change it: the value as plain text, under its label. */
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
/** Called when Escape abandons the edit (the value is restored), e.g. to clear `error`. */
|
|
22
|
+
onCancel?: () => void;
|
|
23
|
+
/** Called when the field enters (`true`) or leaves (`false`) edit mode. */
|
|
24
|
+
onEditingChange?: (editing: boolean) => void;
|
|
25
|
+
/** Id of the input (generated by default). */
|
|
26
|
+
id?: string;
|
|
27
|
+
autoComplete?: string;
|
|
28
|
+
/**
|
|
29
|
+
* A Phosphor icon before the field, aligned with its value. `null` keeps the room empty, so
|
|
30
|
+
* the field lines up with its neighbours that have an icon.
|
|
31
|
+
*/
|
|
32
|
+
icon?: React.ReactNode;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A value that edits in place, with its label above (and its icon before, if any). At rest it is
|
|
37
|
+
* a button showing the value (or the placeholder); a click or keyboard focus turns it into an
|
|
38
|
+
* underline-only input. Enter or blur commits, Escape cancels and restores the value.
|
|
39
|
+
*/
|
|
40
|
+
export declare function InlineField({ icon, className, ...props }: InlineFieldProps): React.JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PencilSimpleIcon } from '@phosphor-icons/react';
|
|
3
|
+
import { useId, useRef, useState } from 'react';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
import { Spinner } from './spinner.js';
|
|
6
|
+
/**
|
|
7
|
+
* A value that edits in place, with its label above (and its icon before, if any). At rest it is
|
|
8
|
+
* a button showing the value (or the placeholder); a click or keyboard focus turns it into an
|
|
9
|
+
* underline-only input. Enter or blur commits, Escape cancels and restores the value.
|
|
10
|
+
*/
|
|
11
|
+
export function InlineField({ icon, className, ...props }) {
|
|
12
|
+
if (icon === undefined)
|
|
13
|
+
return _jsx(InlineFieldControl, { className: className, ...props });
|
|
14
|
+
return (_jsxs("div", { "data-slot": "inline-field-row", className: cn('flex min-w-0 items-start gap-3', className), children: [_jsx("span", { "aria-hidden": true, className: "mt-7 flex size-4 shrink-0 text-muted-foreground [&_svg]:size-4", children: icon }), _jsx(InlineFieldControl, { className: "flex-1", ...props })] }));
|
|
15
|
+
}
|
|
16
|
+
/** The field itself, without its icon. */
|
|
17
|
+
function InlineFieldControl({ value, onCommit, label, placeholder, type = 'text', error, disabled = false, readOnly = false, onCancel, onEditingChange, id, autoComplete, className, }) {
|
|
18
|
+
const generatedId = useId();
|
|
19
|
+
const inputId = id ?? `${generatedId}-input`;
|
|
20
|
+
const labelId = `${generatedId}-label`;
|
|
21
|
+
const valueId = `${generatedId}-value`;
|
|
22
|
+
const errorId = `${generatedId}-error`;
|
|
23
|
+
const [editing, setEditing] = useState(false);
|
|
24
|
+
const [draft, setDraft] = useState(value);
|
|
25
|
+
const [pending, setPending] = useState(false);
|
|
26
|
+
const display = useRef(null);
|
|
27
|
+
/** Set by a pointer press, so the focus that follows it isn't taken for keyboard focus. */
|
|
28
|
+
const pointerFocus = useRef(false);
|
|
29
|
+
/** Set when we return focus to the button ourselves, so it doesn't reopen the editor. */
|
|
30
|
+
const programmaticFocus = useRef(false);
|
|
31
|
+
/** Guards against a second commit (e.g. the blur that follows Enter) while one is running. */
|
|
32
|
+
const busy = useRef(false);
|
|
33
|
+
const startEditing = () => {
|
|
34
|
+
if (disabled || editing)
|
|
35
|
+
return;
|
|
36
|
+
setDraft(value);
|
|
37
|
+
setEditing(true);
|
|
38
|
+
onEditingChange?.(true);
|
|
39
|
+
};
|
|
40
|
+
/** Leaves edit mode. `busy` stays set until the input is gone, so its last blur is ignored. */
|
|
41
|
+
const finish = (refocus) => {
|
|
42
|
+
setEditing(false);
|
|
43
|
+
onEditingChange?.(false);
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
busy.current = false;
|
|
46
|
+
if (refocus) {
|
|
47
|
+
// Focus events fire synchronously, so the flag only covers this call.
|
|
48
|
+
programmaticFocus.current = true;
|
|
49
|
+
display.current?.focus();
|
|
50
|
+
programmaticFocus.current = false;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const commit = async (refocus) => {
|
|
55
|
+
if (busy.current)
|
|
56
|
+
return;
|
|
57
|
+
busy.current = true;
|
|
58
|
+
const next = draft.trim();
|
|
59
|
+
if (next === value) {
|
|
60
|
+
finish(refocus);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
setPending(true);
|
|
64
|
+
try {
|
|
65
|
+
await onCommit(next);
|
|
66
|
+
setPending(false);
|
|
67
|
+
finish(refocus);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// The caller owns the error message (`error`); the draft stays for a retry.
|
|
71
|
+
setPending(false);
|
|
72
|
+
busy.current = false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const cancel = () => {
|
|
76
|
+
if (busy.current)
|
|
77
|
+
return;
|
|
78
|
+
busy.current = true;
|
|
79
|
+
setDraft(value);
|
|
80
|
+
onCancel?.();
|
|
81
|
+
finish(true);
|
|
82
|
+
};
|
|
83
|
+
const describedBy = error ? errorId : undefined;
|
|
84
|
+
if (readOnly) {
|
|
85
|
+
return (_jsxs("div", { "data-slot": "inline-field", className: cn('flex min-w-0 flex-col gap-1', className), children: [label && _jsx("span", { className: "font-medium text-muted-foreground text-xs", children: label }), _jsx("span", { className: cn('flex h-8 items-center truncate text-sm', !value && 'text-muted-foreground/70'), children: value || '—' })] }));
|
|
86
|
+
}
|
|
87
|
+
return (_jsxs("div", { "data-slot": "inline-field", className: cn('flex min-w-0 flex-col gap-1', className), children: [label &&
|
|
88
|
+
(editing ? (_jsx("label", { id: labelId, htmlFor: inputId, className: "font-medium text-muted-foreground text-xs", children: label })) : (_jsx("span", { id: labelId, className: "font-medium text-muted-foreground text-xs", children: label }))), editing ? (_jsxs("div", { className: "relative", children: [_jsx("input", { id: inputId, type: type, value: draft, placeholder: placeholder, autoComplete: autoComplete,
|
|
89
|
+
// The field opens on an explicit request (click or focus), so focus follows it.
|
|
90
|
+
// biome-ignore lint/a11y/noAutofocus: focus moves into the editor the person opened.
|
|
91
|
+
autoFocus: true, readOnly: pending, "aria-busy": pending || undefined, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy, onFocus: (event) => event.currentTarget.select(), onChange: (event) => setDraft(event.target.value), onBlur: () => void commit(false), onKeyDown: (event) => {
|
|
92
|
+
if (event.key === 'Enter') {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
void commit(true);
|
|
95
|
+
}
|
|
96
|
+
else if (event.key === 'Escape') {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
cancel();
|
|
99
|
+
}
|
|
100
|
+
}, className: cn('-mx-px h-8 w-full min-w-0 rounded-none border-0 border-input border-b bg-transparent px-px pr-6 text-sm outline-none transition-colors placeholder:text-muted-foreground/70', 'focus:border-ring', 'aria-invalid:border-danger', pending && 'text-muted-foreground') }), pending && _jsx(Spinner, { className: "absolute top-1/2 right-0 size-3.5 -translate-y-1/2" })] })) : (_jsxs("button", { ref: display, type: "button", disabled: disabled, "aria-labelledby": label ? `${labelId} ${valueId}` : valueId, "aria-describedby": describedBy, onPointerDown: () => {
|
|
101
|
+
pointerFocus.current = true;
|
|
102
|
+
}, onFocus: () => {
|
|
103
|
+
const fromPointer = pointerFocus.current;
|
|
104
|
+
const fromUs = programmaticFocus.current;
|
|
105
|
+
pointerFocus.current = false;
|
|
106
|
+
programmaticFocus.current = false;
|
|
107
|
+
if (!fromPointer && !fromUs)
|
|
108
|
+
startEditing();
|
|
109
|
+
}, onClick: startEditing, className: cn('group/inline-field -mx-px flex h-8 w-full min-w-0 items-center gap-2 border-transparent border-b px-px text-left text-sm outline-none transition-colors', 'enabled:cursor-text enabled:hover:border-input enabled:hover:border-dashed', 'focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-60', error && 'border-danger'), children: [_jsx("span", { id: valueId, className: cn('truncate', !value && 'text-muted-foreground/70'), children: value || placeholder || '—' }), !disabled && (_jsx(PencilSimpleIcon, { "aria-hidden": true, className: "ml-auto size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/inline-field:opacity-100" }))] })), error && (_jsx("p", { id: errorId, className: "text-danger-foreground text-xs", children: error }))] }));
|
|
110
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface InputProps extends Omit<React.ComponentProps<'input'>, 'size'> {
|
|
3
|
+
/** Matches the buttons of the same size: `sm` in a toolbar of filters, `lg` on sign-in pages. */
|
|
4
|
+
size?: 'default' | 'sm' | 'lg';
|
|
5
|
+
/**
|
|
6
|
+
* Text that always follows the value, inside the field but not part of it (a file's
|
|
7
|
+
* extension, a unit). The input's props (`id`, `aria-*`) stay on the input itself.
|
|
8
|
+
*/
|
|
9
|
+
suffix?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare function Input({ className, type, size, suffix, ...props }: InputProps): React.JSX.Element;
|
|
12
|
+
export interface TextareaProps extends React.ComponentProps<'textarea'> {
|
|
13
|
+
/** Monospaced, for data people paste (a manifest). */
|
|
14
|
+
code?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Several lines of text: a description, or pasted data. */
|
|
17
|
+
export declare function Textarea({ className, code, ...props }: TextareaProps): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
const FIELD_CLASSES = 'flex h-9 w-full min-w-0 rounded-md border border-input bg-card text-base shadow-xs transition-[color,box-shadow] md:text-sm data-[size=sm]:h-8 data-[size=sm]:text-sm data-[size=lg]:h-10';
|
|
4
|
+
const VALUE_CLASSES = 'outline-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50';
|
|
5
|
+
export function Input({ className, type, size = 'default', suffix, ...props }) {
|
|
6
|
+
if (suffix !== undefined) {
|
|
7
|
+
return (_jsxs("div", { "data-slot": "input-group", "data-size": size, className: cn(FIELD_CLASSES, 'items-center', 'focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50', 'has-aria-invalid:border-danger has-aria-invalid:ring-danger/20', 'has-disabled:cursor-not-allowed has-disabled:opacity-50', className), children: [_jsx("input", { type: type, "data-slot": "input", className: cn(VALUE_CLASSES, 'h-full min-w-0 flex-1 bg-transparent py-1 pl-3'), ...props }), _jsx("span", { "data-slot": "input-suffix", className: "shrink-0 select-none pr-3 text-muted-foreground", children: suffix })] }));
|
|
8
|
+
}
|
|
9
|
+
return (_jsx("input", { type: type, "data-slot": "input", "data-size": size, className: cn(FIELD_CLASSES, VALUE_CLASSES, 'px-3 py-1 file:inline-flex file:h-7 file:border-0 file:bg-transparent file:font-medium file:text-foreground file:text-sm', 'focus-visible:border-ring focus-ring', 'aria-invalid:border-danger aria-invalid:ring-danger/20', className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
/** Several lines of text: a description, or pasted data. */
|
|
12
|
+
export function Textarea({ className, code = false, ...props }) {
|
|
13
|
+
return (_jsx("textarea", { "data-slot": "textarea", className: cn('flex min-h-24 w-full min-w-0 rounded-md border border-input bg-card px-3 py-2 text-base shadow-xs outline-none transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'focus-visible:border-ring focus-ring', 'aria-invalid:border-danger aria-invalid:ring-danger/20', code && 'min-h-64 font-mono text-xs md:text-xs', className), ...props }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/** Sentences to read one after the other (consequences, rules), as bullets. */
|
|
3
|
+
export declare function BulletList({ className, ...props }: React.ComponentProps<'ul'>): React.JSX.Element;
|
|
4
|
+
/** A list of `ChecklistItem`s. */
|
|
5
|
+
export declare function Checklist({ className, ...props }: React.ComponentProps<'ul'>): React.JSX.Element;
|
|
6
|
+
export interface ChecklistItemProps {
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/** Something granted or verified: a check mark, what it is, and what it means. */
|
|
11
|
+
export declare function ChecklistItem({ title, description }: ChecklistItemProps): React.JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckIcon } from '@phosphor-icons/react';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
/** Sentences to read one after the other (consequences, rules), as bullets. */
|
|
5
|
+
export function BulletList({ className, ...props }) {
|
|
6
|
+
return (_jsx("ul", { "data-slot": "bullet-list", className: cn('flex max-w-prose list-disc flex-col gap-2 pl-5 text-sm leading-relaxed marker:text-muted-foreground', className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
/** A list of `ChecklistItem`s. */
|
|
9
|
+
export function Checklist({ className, ...props }) {
|
|
10
|
+
return _jsx("ul", { "data-slot": "checklist", className: cn('flex flex-col gap-3', className), ...props });
|
|
11
|
+
}
|
|
12
|
+
/** Something granted or verified: a check mark, what it is, and what it means. */
|
|
13
|
+
export function ChecklistItem({ title, description }) {
|
|
14
|
+
return (_jsxs("li", { "data-slot": "checklist-item", className: "flex items-start gap-3", children: [_jsx("span", { className: "mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-foreground", children: _jsx(CheckIcon, { "aria-hidden": true, className: "size-3" }) }), _jsxs("div", { className: "grid gap-0.5 text-sm", children: [_jsx("span", { children: title }), description && _jsx("span", { className: "text-muted-foreground", children: description })] })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Label as LabelPrimitive } from 'radix-ui';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
export function Label({ className, ...props }) {
|
|
5
|
+
return (_jsx(LabelPrimitive.Root, { "data-slot": "label", className: cn('flex select-none items-center gap-2 font-medium text-sm leading-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', className), ...props }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface MiniMonthProps {
|
|
3
|
+
/** Any day of the month shown. */
|
|
4
|
+
month: Date;
|
|
5
|
+
onMonthChange: (month: Date) => void;
|
|
6
|
+
/** The day picked, marked. */
|
|
7
|
+
selected?: Date;
|
|
8
|
+
onSelect: (day: Date) => void;
|
|
9
|
+
/** Marked too, more quietly. Defaults to now. */
|
|
10
|
+
today?: Date;
|
|
11
|
+
/** 0: Sunday, 1: Monday (the default). */
|
|
12
|
+
weekStartsOn?: 0 | 1;
|
|
13
|
+
}
|
|
14
|
+
/** A small month to pick a day from: six weeks, the month's name and arrows to the others. */
|
|
15
|
+
export declare function MiniMonth({ month, onMonthChange, selected, onSelect, today, weekStartsOn, }: MiniMonthProps): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { capitalize } from '@ismou-workspace/translations';
|
|
3
|
+
import { useLocale, useSharedMessages } from '@ismou-workspace/translations/react';
|
|
4
|
+
import { CaretLeftIcon, CaretRightIcon } from '@phosphor-icons/react';
|
|
5
|
+
import { addDays, addMonths, isSameDay, isSameMonth, startOfMonth, startOfWeek } from 'date-fns';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { cn } from '../lib/cn.js';
|
|
8
|
+
import { Button } from './button.js';
|
|
9
|
+
/** A small month to pick a day from: six weeks, the month's name and arrows to the others. */
|
|
10
|
+
export function MiniMonth({ month, onMonthChange, selected, onSelect, today = new Date(), weekStartsOn = 1, }) {
|
|
11
|
+
const first = startOfWeek(startOfMonth(month), { weekStartsOn });
|
|
12
|
+
const days = Array.from({ length: 42 }, (_, index) => addDays(first, index));
|
|
13
|
+
const t = useSharedMessages().ui.miniMonth;
|
|
14
|
+
const locale = useLocale();
|
|
15
|
+
const formats = React.useMemo(() => ({
|
|
16
|
+
weekday: new Intl.DateTimeFormat(locale, { weekday: 'narrow' }),
|
|
17
|
+
month: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }),
|
|
18
|
+
day: new Intl.DateTimeFormat(locale, {
|
|
19
|
+
weekday: 'long',
|
|
20
|
+
day: 'numeric',
|
|
21
|
+
month: 'long',
|
|
22
|
+
year: 'numeric',
|
|
23
|
+
}),
|
|
24
|
+
dayNumber: new Intl.DateTimeFormat(locale, { day: 'numeric' }),
|
|
25
|
+
}), [locale]);
|
|
26
|
+
const weekdays = days.slice(0, 7).map((day) => formats.weekday.format(day));
|
|
27
|
+
return (_jsxs("div", { "data-slot": "mini-month", className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 pl-2", children: [_jsx("span", { className: "font-medium text-sm", "aria-live": "polite", children: capitalize(formats.month.format(month), locale) }), _jsxs("div", { className: "flex", children: [_jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": t.previousMonth, className: "text-muted-foreground", onClick: () => onMonthChange(addMonths(month, -1)), children: _jsx(CaretLeftIcon, {}) }), _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": t.nextMonth, className: "text-muted-foreground", onClick: () => onMonthChange(addMonths(month, 1)), children: _jsx(CaretRightIcon, {}) })] })] }), _jsxs("div", { className: "grid grid-cols-7 text-center", children: [weekdays.map((weekday, index) => (_jsx("span", { "aria-hidden": true, className: "py-1 text-muted-foreground text-xs", children: weekday }, `${index}-${weekday}`))), days.map((day) => {
|
|
28
|
+
const isSelected = selected !== undefined && isSameDay(day, selected);
|
|
29
|
+
return (_jsx("button", { type: "button", "aria-label": capitalize(formats.day.format(day), locale), "aria-pressed": isSelected, onClick: () => onSelect(day), className: cn('mx-auto flex size-7 items-center justify-center rounded-full text-xs tabular-nums outline-none transition-colors hover:bg-accent focus-ring', !isSameMonth(day, month) && 'text-muted-foreground/70', isSameDay(day, today) && 'font-semibold',
|
|
30
|
+
// Selected, it sits on the primary: its text takes the primary's foreground.
|
|
31
|
+
isSelected
|
|
32
|
+
? 'primary-texture-subtle hover:brightness-105'
|
|
33
|
+
: isSameDay(day, today) && 'text-primary'), children: formats.dayNumber.format(day) }, day.toISOString()));
|
|
34
|
+
})] })] }));
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface PlaceholderAvatarProps {
|
|
3
|
+
/** Diameter in CSS pixels, like `EntityAvatar`'s. */
|
|
4
|
+
size?: number;
|
|
5
|
+
/** `circle` stands for a person, `square` for an app. */
|
|
6
|
+
shape?: 'circle' | 'square';
|
|
7
|
+
/** A small icon inside, e.g. a "prohibited" mark. */
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Where an avatar or an app icon would be, for something that no longer exists. */
|
|
12
|
+
export declare function PlaceholderAvatar({ size, shape, icon, className, }: PlaceholderAvatarProps): React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
/** Where an avatar or an app icon would be, for something that no longer exists. */
|
|
4
|
+
export function PlaceholderAvatar({ size = 32, shape = 'circle', icon, className, }) {
|
|
5
|
+
return (_jsx("span", { "aria-hidden": true, "data-slot": "placeholder-avatar", style: { width: size, height: size }, className: cn('flex shrink-0 items-center justify-center border border-dashed text-muted-foreground [&_svg]:size-3', shape === 'circle' ? 'rounded-full' : 'rounded-md', className), children: icon }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Popover as PopoverPrimitive } from 'radix-ui';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
export declare function Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>): React.JSX.Element;
|
|
4
|
+
export declare function PopoverTrigger(props: React.ComponentProps<typeof PopoverPrimitive.Trigger>): React.JSX.Element;
|
|
5
|
+
export declare function PopoverAnchor(props: React.ComponentProps<typeof PopoverPrimitive.Anchor>): React.JSX.Element;
|
|
6
|
+
/** A floating surface (searchable pickers, filters): a card, as floating surfaces are. */
|
|
7
|
+
export declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover as PopoverPrimitive } from 'radix-ui';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
export function Popover(props) {
|
|
5
|
+
return _jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
6
|
+
}
|
|
7
|
+
export function PopoverTrigger(props) {
|
|
8
|
+
return _jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
9
|
+
}
|
|
10
|
+
export function PopoverAnchor(props) {
|
|
11
|
+
return _jsx(PopoverPrimitive.Anchor, { "data-slot": "popover-anchor", ...props });
|
|
12
|
+
}
|
|
13
|
+
/** A floating surface (searchable pickers, filters): a card, as floating surfaces are. */
|
|
14
|
+
export function PopoverContent({ className, align = 'start', sideOffset = 4, ...props }) {
|
|
15
|
+
return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-xl border bg-popover p-1.5 text-popover-foreground shadow-md outline-hidden data-[state=closed]:animate-out data-[state=open]:animate-in', className), ...props }) }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type ProgressProps } from './progress.tsx';
|
|
3
|
+
export interface ProgressListProps {
|
|
4
|
+
/** What the tasks are, as a small heading: "Uploading 3 files". */
|
|
5
|
+
title: React.ReactNode;
|
|
6
|
+
/** A small control at the end of the heading, e.g. clearing the finished tasks. */
|
|
7
|
+
action?: React.ReactNode;
|
|
8
|
+
/** Its `ProgressListItem`s. */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** A quiet line under the tasks, e.g. how to retry the failed ones. */
|
|
11
|
+
footer?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tasks running side by side (uploads, imports), each with its own progress, under a heading.
|
|
15
|
+
* Made to fill a popover: the heading, the tasks and the footer share one inset.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ProgressList({ title, action, children, footer }: ProgressListProps): React.JSX.Element;
|
|
18
|
+
export interface ProgressListItemProps {
|
|
19
|
+
/** A small picture of what the task works on (a file's type). */
|
|
20
|
+
media?: React.ReactNode;
|
|
21
|
+
title: React.ReactNode;
|
|
22
|
+
/** Where it stands: "42% of 3 MB", or why it failed. */
|
|
23
|
+
description?: React.ReactNode;
|
|
24
|
+
/** From 0 to 100; `null` while unknown. Omit once there is nothing left to show. */
|
|
25
|
+
value?: number | null;
|
|
26
|
+
tone?: ProgressProps['tone'];
|
|
27
|
+
/** Accessible name of the bar, e.g. "Upload of report.pdf". */
|
|
28
|
+
progressLabel?: string;
|
|
29
|
+
}
|
|
30
|
+
/** One task of a `ProgressList`: what it is, where it stands, and its bar while it runs. */
|
|
31
|
+
export declare function ProgressListItem({ media, title, description, value, tone, progressLabel, }: ProgressListItemProps): React.JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Identity } from './identity.js';
|
|
3
|
+
import { Progress } from './progress.js';
|
|
4
|
+
import { SectionLabel } from './section-label.js';
|
|
5
|
+
/**
|
|
6
|
+
* Tasks running side by side (uploads, imports), each with its own progress, under a heading.
|
|
7
|
+
* Made to fill a popover: the heading, the tasks and the footer share one inset.
|
|
8
|
+
*/
|
|
9
|
+
export function ProgressList({ title, action, children, footer }) {
|
|
10
|
+
return (_jsxs("div", { "data-slot": "progress-list", className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex h-8 items-center justify-between gap-2 pl-2", children: [_jsx(SectionLabel, { asChild: true, children: _jsx("h2", { children: title }) }), action] }), _jsx("ul", { className: "flex max-h-80 flex-col gap-px overflow-y-auto", children: children }), footer && _jsx("p", { className: "px-2 pt-1 pb-1.5 text-muted-foreground text-xs", children: footer })] }));
|
|
11
|
+
}
|
|
12
|
+
/** One task of a `ProgressList`: what it is, where it stands, and its bar while it runs. */
|
|
13
|
+
export function ProgressListItem({ media, title, description, value, tone, progressLabel, }) {
|
|
14
|
+
return (_jsxs("li", { "data-slot": "progress-list-item", className: "flex flex-col gap-2 rounded-md p-2", children: [_jsx(Identity, { size: "sm", media: media, title: title, description: description }), value !== undefined && _jsx(Progress, { "aria-label": progressLabel, value: value, tone: tone })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface ProgressRingProps {
|
|
3
|
+
/** From 0 to 100. */
|
|
4
|
+
value: number;
|
|
5
|
+
/** Accessible name, e.g. "Uploading 3 files". */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Drawn in the middle of the ring, e.g. an icon. */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** `success` once done, `danger` when something failed; the ring and its mark take it. */
|
|
10
|
+
tone?: 'primary' | 'success' | 'danger';
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function ProgressRing({ value, label, children, tone, className, }: ProgressRingProps): React.JSX.Element;
|