@artemis-apps/ui 0.0.0-stage → 0.1.1
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/brand/app-brands.d.ts +38 -0
- package/dist/brand/app-brands.js +110 -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/bridge.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/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/artemis-favicon.plugin.d.ts +10 -0
- package/dist/vite/artemis-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 +97 -3
- package/README.md +0 -3
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { PALETTE_TEXTURE_HEX } from './app-brands.js';
|
|
2
|
+
/**
|
|
3
|
+
* The kinds of files that have an icon of their own: what an app handling them (an editor, a
|
|
4
|
+
* previewer) shows next to its actions ("Open with Office", "New spreadsheet").
|
|
5
|
+
*/
|
|
6
|
+
export const FILE_KINDS = [
|
|
7
|
+
'document',
|
|
8
|
+
'spreadsheet',
|
|
9
|
+
'presentation',
|
|
10
|
+
'form',
|
|
11
|
+
'pdf',
|
|
12
|
+
'markdown',
|
|
13
|
+
'diagram',
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Every file icon: the kinds apps serve, then what `FileTypeIcon` draws by itself (the
|
|
17
|
+
* categories of files no app handles). Both sets share the same look, drawn by `fileIconSvg`; a
|
|
18
|
+
* folder is the drive's own mark (`favicons/drive.svg`).
|
|
19
|
+
*/
|
|
20
|
+
export const FILE_ICONS = [
|
|
21
|
+
...FILE_KINDS,
|
|
22
|
+
'image',
|
|
23
|
+
'video',
|
|
24
|
+
'audio',
|
|
25
|
+
'archive',
|
|
26
|
+
'code',
|
|
27
|
+
'text',
|
|
28
|
+
'other',
|
|
29
|
+
];
|
|
30
|
+
/** Strokes of the glyphs: one weight, round ends, like the app marks' rounded corners. */
|
|
31
|
+
const STROKE = 'fill="none" stroke="#fff" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"';
|
|
32
|
+
/** What has no colour of the palette (Markdown, plain text, the rest): a quiet grey. */
|
|
33
|
+
const GREY = { light: '#8b9099', dark: '#5f646d' };
|
|
34
|
+
/** A page with its corner folded. */
|
|
35
|
+
const PAGE = `<path ${STROKE} d="M13 5.5H8.75Q7.5 5.5 7.5 6.75V17.25Q7.5 18.5 8.75 18.5H15.25Q16.5 18.5 16.5 17.25V9ZM13 5.5V9H16.5"/>`;
|
|
36
|
+
export const FILE_ICON_DEFINITIONS = {
|
|
37
|
+
// Lines of text, the last one shorter.
|
|
38
|
+
document: {
|
|
39
|
+
title: 'Document',
|
|
40
|
+
colors: PALETTE_TEXTURE_HEX.blue,
|
|
41
|
+
glyph: `<path ${STROKE} d="M7 7.5H17M7 10.5H17M7 13.5H17M7 16.5H13"/>`,
|
|
42
|
+
},
|
|
43
|
+
// A table's inner rules only, no frame: a header column and two rows, splitting the column's
|
|
44
|
+
// visible height (its round caps included, 5.625 to 18.375) in even thirds.
|
|
45
|
+
spreadsheet: {
|
|
46
|
+
title: 'Spreadsheet',
|
|
47
|
+
colors: PALETTE_TEXTURE_HEX.green,
|
|
48
|
+
glyph: `<path ${STROKE} d="M10 6.5V17.5M6.5 9.875H17.5M6.5 14.125H17.5"/>`,
|
|
49
|
+
},
|
|
50
|
+
// A board on its stand.
|
|
51
|
+
presentation: {
|
|
52
|
+
title: 'Presentation',
|
|
53
|
+
colors: PALETTE_TEXTURE_HEX.orange,
|
|
54
|
+
glyph: `<rect ${STROKE} x="5.5" y="6" width="13" height="9" rx="1.5"/><path ${STROKE} d="M12 15V18.5M9.5 18.5H14.5M9 12L11 10L12.5 11.5L15 9"/>`,
|
|
55
|
+
},
|
|
56
|
+
// Two fields: a ticked box and an empty one, each with its label.
|
|
57
|
+
form: {
|
|
58
|
+
title: 'Form',
|
|
59
|
+
colors: PALETTE_TEXTURE_HEX.violet,
|
|
60
|
+
glyph: `<rect fill="#fff" x="6" y="6.75" width="4" height="4" rx="1"/><rect ${STROKE} x="6.5" y="13.75" width="3.5" height="3.5" rx="0.75"/><path ${STROKE} d="M12.5 8.75H18M12.5 15.5H18"/>`,
|
|
61
|
+
},
|
|
62
|
+
pdf: { title: 'PDF', colors: PALETTE_TEXTURE_HEX.red, glyph: PAGE },
|
|
63
|
+
// The Markdown mark: an M and an arrow pointing down, in a frame.
|
|
64
|
+
markdown: {
|
|
65
|
+
title: 'Markdown',
|
|
66
|
+
colors: GREY,
|
|
67
|
+
glyph: `<rect ${STROKE} x="4.5" y="7" width="15" height="10" rx="2"/><path ${STROKE} d="M7.5 14.5V9.5L9.75 12L12 9.5V14.5M15.5 9.5V14.5M13.75 12.75L15.5 14.5L17.25 12.75"/>`,
|
|
68
|
+
},
|
|
69
|
+
// Three nodes: one above, two below, linked.
|
|
70
|
+
diagram: {
|
|
71
|
+
title: 'Diagram',
|
|
72
|
+
colors: PALETTE_TEXTURE_HEX.cyan,
|
|
73
|
+
glyph: `<rect fill="#fff" x="9.5" y="5" width="5" height="4" rx="1"/><rect fill="#fff" x="5" y="15" width="5" height="4" rx="1"/><rect fill="#fff" x="14" y="15" width="5" height="4" rx="1"/><path ${STROKE} d="M12 9V12M7.5 15V12H16.5V15"/>`,
|
|
74
|
+
},
|
|
75
|
+
// A picture: its frame, the sun and a hill.
|
|
76
|
+
image: {
|
|
77
|
+
title: 'Image',
|
|
78
|
+
colors: PALETTE_TEXTURE_HEX.red,
|
|
79
|
+
glyph: `<rect ${STROKE} x="5.5" y="6.5" width="13" height="11" rx="1.5"/><circle fill="#fff" cx="9.5" cy="10" r="1.25"/><path ${STROKE} d="M5.75 16L10 12.25L13 14.75L14.75 13.25L18.25 16.25"/>`,
|
|
80
|
+
},
|
|
81
|
+
// A camera: its body and its lens.
|
|
82
|
+
video: {
|
|
83
|
+
title: 'Video',
|
|
84
|
+
colors: PALETTE_TEXTURE_HEX.orange,
|
|
85
|
+
glyph: `<rect ${STROKE} x="4.5" y="7.5" width="10.5" height="9" rx="1.5"/><path ${STROKE} d="M15 11L19.5 8.5V15.5L15 13Z"/>`,
|
|
86
|
+
},
|
|
87
|
+
// Two notes, beamed.
|
|
88
|
+
audio: {
|
|
89
|
+
title: 'Audio',
|
|
90
|
+
colors: PALETTE_TEXTURE_HEX.orange,
|
|
91
|
+
glyph: `<path ${STROKE} d="M10 16.5V7.5L17 6V15"/><circle fill="#fff" cx="8.25" cy="16.5" r="1.75"/><circle fill="#fff" cx="15.25" cy="15" r="1.75"/>`,
|
|
92
|
+
},
|
|
93
|
+
// A box: its lid, its body and the handle cut in it.
|
|
94
|
+
archive: {
|
|
95
|
+
title: 'Archive',
|
|
96
|
+
colors: PALETTE_TEXTURE_HEX.yellow,
|
|
97
|
+
glyph: `<rect ${STROKE} x="5.5" y="6.5" width="13" height="3.5" rx="1"/><path ${STROKE} d="M6.5 10V16.25Q6.5 17.5 7.75 17.5H16.25Q17.5 17.5 17.5 16.25V10M10.5 13H13.5"/>`,
|
|
98
|
+
},
|
|
99
|
+
// Angle brackets around a slash.
|
|
100
|
+
code: {
|
|
101
|
+
title: 'Code',
|
|
102
|
+
colors: PALETTE_TEXTURE_HEX.cyan,
|
|
103
|
+
glyph: `<path ${STROKE} d="M9 8.5L5.5 12L9 15.5M15 8.5L18.5 12L15 15.5M13 7L11 17"/>`,
|
|
104
|
+
},
|
|
105
|
+
// Lines of text of uneven lengths.
|
|
106
|
+
text: {
|
|
107
|
+
title: 'Text',
|
|
108
|
+
colors: GREY,
|
|
109
|
+
glyph: `<path ${STROKE} d="M7 7.5H17M7 10.5H14M7 13.5H17M7 16.5H12"/>`,
|
|
110
|
+
},
|
|
111
|
+
other: { title: 'File', colors: GREY, glyph: PAGE },
|
|
112
|
+
};
|
|
113
|
+
/** The icons of the kinds apps serve: the same as `FILE_ICON_DEFINITIONS`, for those only. */
|
|
114
|
+
export const FILE_KIND_ICONS = FILE_ICON_DEFINITIONS;
|
|
115
|
+
export function isFileKind(value) {
|
|
116
|
+
return FILE_KINDS.includes(value);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A file icon, as an SVG document: a rounded square in its colour (its gradient under the same
|
|
120
|
+
* quiet grain as the app marks), its white glyph over it. Those `FileTypeIcon` draws by itself
|
|
121
|
+
* are shipped as files in `brand/file-icons/`, kept in sync with this by a test.
|
|
122
|
+
*/
|
|
123
|
+
export function fileIconSvg(icon) {
|
|
124
|
+
const { title, colors, glyph } = FILE_ICON_DEFINITIONS[icon];
|
|
125
|
+
return [
|
|
126
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="64" height="64">',
|
|
127
|
+
`<title>${title}</title>`,
|
|
128
|
+
'<defs>',
|
|
129
|
+
'<linearGradient id="fill" x1="0.3" y1="0" x2="0.7" y2="1">',
|
|
130
|
+
`<stop offset="0" stop-color="${colors.light}"/><stop offset="1" stop-color="${colors.dark}"/>`,
|
|
131
|
+
'</linearGradient>',
|
|
132
|
+
'<filter id="grain" x="0" y="0" width="100%" height="100%">',
|
|
133
|
+
'<feTurbulence type="fractalNoise" baseFrequency="1.6" numOctaves="2" seed="7" stitchTiles="stitch"/>',
|
|
134
|
+
'<feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0"/>',
|
|
135
|
+
'</filter>',
|
|
136
|
+
'<clipPath id="tile"><rect width="24" height="24" rx="5.5"/></clipPath>',
|
|
137
|
+
'</defs>',
|
|
138
|
+
'<g clip-path="url(#tile)">',
|
|
139
|
+
'<rect width="24" height="24" fill="url(#fill)"/>',
|
|
140
|
+
'<rect width="24" height="24" filter="url(#grain)" opacity="0.3" style="mix-blend-mode:overlay"/>',
|
|
141
|
+
'</g>',
|
|
142
|
+
glyph,
|
|
143
|
+
'</svg>',
|
|
144
|
+
].join('');
|
|
145
|
+
}
|
|
146
|
+
/** A kind's icon, as an app serves it (`/icons/<kind>.svg`). */
|
|
147
|
+
export function kindIconSvg(kind) {
|
|
148
|
+
return fileIconSvg(kind);
|
|
149
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface AccountMenuProps {
|
|
3
|
+
/** Seed of the generated avatar (`avatar.seed`); ignored when `avatarUrl` is set. */
|
|
4
|
+
avatarSeed: string;
|
|
5
|
+
/** The uploaded picture, when the account has one. */
|
|
6
|
+
avatarUrl?: string;
|
|
7
|
+
name: string;
|
|
8
|
+
email: string;
|
|
9
|
+
onSignOut: () => void;
|
|
10
|
+
signingOut?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Adds a "Manage account" item: pass an empty link element (an `<a href>` to the core's
|
|
13
|
+
* account page, or the router's `<Link>` inside the core); it receives the item's content.
|
|
14
|
+
*/
|
|
15
|
+
manageAccountLink?: React.ReactElement<{
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/** Avatar button opening the signed-in account's menu (the topbar's `account` slot). */
|
|
20
|
+
export declare function AccountMenu({ avatarSeed, avatarUrl, name, email, onSignOut, signingOut, manageAccountLink, }: AccountMenuProps): React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useSharedMessages } from '@artemis-apps/translations/react';
|
|
3
|
+
import { SignOutIcon, UserCircleIcon } from '@phosphor-icons/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from './dropdown-menu.js';
|
|
6
|
+
import { EntityAvatar } from './entity-avatar.js';
|
|
7
|
+
/** Avatar button opening the signed-in account's menu (the topbar's `account` slot). */
|
|
8
|
+
export function AccountMenu({ avatarSeed, avatarUrl, name, email, onSignOut, signingOut = false, manageAccountLink, }) {
|
|
9
|
+
const t = useSharedMessages().ui.accountMenu;
|
|
10
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { "aria-label": t.label, className: "inline-flex size-8 items-center justify-center rounded-full outline-none transition-shadow hover:ring-4 hover:ring-muted focus-ring data-[state=open]:ring-4 data-[state=open]:ring-muted", children: _jsx(EntityAvatar, { name: avatarSeed, imageUrl: avatarUrl, size: 32 }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-64", children: [_jsxs(DropdownMenuLabel, { className: "flex items-center gap-3 py-2", children: [_jsx(EntityAvatar, { name: avatarSeed, imageUrl: avatarUrl, size: 36 }), _jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsx("span", { className: "truncate", children: name }), _jsx("span", { className: "truncate font-normal text-muted-foreground text-xs", children: email })] })] }), _jsx(DropdownMenuSeparator, {}), manageAccountLink && (_jsx(DropdownMenuItem, { asChild: true, children: React.cloneElement(manageAccountLink, {
|
|
11
|
+
children: (_jsxs(_Fragment, { children: [_jsx(UserCircleIcon, {}), t.manageAccount] })),
|
|
12
|
+
}) })), _jsxs(DropdownMenuItem, { disabled: signingOut, onSelect: onSignOut, children: [_jsx(SignOutIcon, {}), t.signOut] })] })] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
export declare const alertVariants: (props?: ({
|
|
4
|
+
variant?: "danger" | "default" | "destructive" | "info" | "success" | "warning" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export interface AlertProps extends React.ComponentProps<'div'>, VariantProps<typeof alertVariants> {
|
|
7
|
+
}
|
|
8
|
+
export declare function Alert({ className, variant, ...props }: AlertProps): React.JSX.Element;
|
|
9
|
+
export declare function AlertTitle({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
10
|
+
export declare function AlertDescription({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
export const alertVariants = cva('relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current', {
|
|
5
|
+
variants: {
|
|
6
|
+
variant: {
|
|
7
|
+
default: 'bg-card text-card-foreground',
|
|
8
|
+
info: 'border-info/25 bg-info-soft text-info-foreground *:data-[slot=alert-description]:text-info-foreground/90',
|
|
9
|
+
success: 'border-success/25 bg-success-soft text-success-foreground *:data-[slot=alert-description]:text-success-foreground/90',
|
|
10
|
+
warning: 'border-warning/40 bg-warning-soft text-warning-foreground *:data-[slot=alert-description]:text-warning-foreground/90',
|
|
11
|
+
danger: 'border-danger/25 bg-danger-soft text-danger-foreground *:data-[slot=alert-description]:text-danger-foreground/90',
|
|
12
|
+
/** Alias of `danger`. */
|
|
13
|
+
destructive: 'border-danger/25 bg-danger-soft text-danger-foreground *:data-[slot=alert-description]:text-danger-foreground/90',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: 'default',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
export function Alert({ className, variant, ...props }) {
|
|
21
|
+
return (_jsx("div", { "data-slot": "alert", role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
|
|
22
|
+
}
|
|
23
|
+
export function AlertTitle({ className, ...props }) {
|
|
24
|
+
return (_jsx("div", { "data-slot": "alert-title", className: cn('col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight', className), ...props }));
|
|
25
|
+
}
|
|
26
|
+
export function AlertDescription({ className, ...props }) {
|
|
27
|
+
return (_jsx("div", { "data-slot": "alert-description", className: cn('col-start-2 grid justify-items-start gap-1 text-muted-foreground text-sm [&_p]:leading-relaxed', className), ...props }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface AppSwitcherEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
/** Where the app lives (its web client's URL). */
|
|
6
|
+
href: string;
|
|
7
|
+
/** The app's icon, e.g. `<ContactsAppIcon size="lg" />`. */
|
|
8
|
+
icon: React.ReactNode;
|
|
9
|
+
/** The app being used: marked as the current page. */
|
|
10
|
+
current?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface AppSwitcherProps {
|
|
13
|
+
apps: readonly AppSwitcherEntry[];
|
|
14
|
+
/** Accessible name of the trigger and of the menu (not displayed). Defaults to "Apps". */
|
|
15
|
+
label?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The topbar's app launcher, placed next to the account avatar: a dots button opening a grid of
|
|
19
|
+
* the apps (icon above name), each a link. A menu: arrow keys move between apps, Enter opens one.
|
|
20
|
+
*/
|
|
21
|
+
export declare function AppSwitcher({ apps, label: labelProp }: AppSwitcherProps): React.JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useSharedMessages } from '@artemis-apps/translations/react';
|
|
3
|
+
import { DotsNineIcon } from '@phosphor-icons/react';
|
|
4
|
+
import { Button } from './button.js';
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from './dropdown-menu.js';
|
|
6
|
+
/**
|
|
7
|
+
* The topbar's app launcher, placed next to the account avatar: a dots button opening a grid of
|
|
8
|
+
* the apps (icon above name), each a link. A menu: arrow keys move between apps, Enter opens one.
|
|
9
|
+
*/
|
|
10
|
+
export function AppSwitcher({ apps, label: labelProp }) {
|
|
11
|
+
const t = useSharedMessages();
|
|
12
|
+
const label = labelProp ?? t.ui.appSwitcher.label;
|
|
13
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": label, className: "data-[state=open]:bg-accent", children: _jsx(DotsNineIcon, { weight: "bold", className: "size-6" }) }) }), _jsx(DropdownMenuContent, { "aria-label": label, align: "end", sideOffset: 8, className: "w-80", children: _jsx("div", { "data-slot": "app-switcher-grid", className: "grid grid-cols-3 gap-1", children: apps.map((app) => (_jsx(DropdownMenuItem, { asChild: true, children: _jsxs("a", { href: app.href, "aria-current": app.current ? 'page' : undefined,
|
|
14
|
+
// A menu item laid out as a tile: the menu's radius and focus tint, the current app
|
|
15
|
+
// marked like the sidebar's current page.
|
|
16
|
+
className: "flex-col gap-2 p-3 text-center aria-[current=page]:bg-primary-soft aria-[current=page]:font-medium", children: [_jsx("span", { "aria-hidden": true, className: "flex", children: app.icon }), _jsx("span", { className: "line-clamp-2 w-full break-words text-foreground text-xs leading-tight", children: app.name })] }) }, app.id))) }) })] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** What the area picks: elements carrying their id in this attribute. */
|
|
3
|
+
export declare const SELECTABLE_ATTRIBUTE = "data-selectable-id";
|
|
4
|
+
export interface AreaSelectionOptions {
|
|
5
|
+
/**
|
|
6
|
+
* A band starts: `additive` when Ctrl/⌘ or Shift is held, which adds to what is picked
|
|
7
|
+
* instead of replacing it.
|
|
8
|
+
*/
|
|
9
|
+
onStart: (additive: boolean) => void;
|
|
10
|
+
/** The ids of the elements the band covers now (`SELECTABLE_ATTRIBUTE`). */
|
|
11
|
+
onChange: (ids: string[]) => void;
|
|
12
|
+
/** No band, e.g. while the list is loading. */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Picks elements by drawing a band over them, as in a file manager: pressed beside them inside
|
|
17
|
+
* the scrolling element it is given (`ref`), the pointer draws a band that picks every element
|
|
18
|
+
* it touches (`SELECTABLE_ATTRIBUTE`), and scrolls near the edges. Pressing on an element leaves
|
|
19
|
+
* it to its own handlers (a click, a drag).
|
|
20
|
+
*/
|
|
21
|
+
export declare function useAreaSelection({ onStart, onChange, disabled }: AreaSelectionOptions): React.Dispatch<React.SetStateAction<HTMLElement | null>>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import SelectionArea from '@viselect/vanilla';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/** What the area picks: elements carrying their id in this attribute. */
|
|
4
|
+
export const SELECTABLE_ATTRIBUTE = 'data-selectable-id';
|
|
5
|
+
/** While a band is drawn, the text under it is not selected: the browser starts on the press. */
|
|
6
|
+
function holdTextSelection() {
|
|
7
|
+
window.getSelection()?.removeAllRanges();
|
|
8
|
+
const { style } = document.documentElement;
|
|
9
|
+
const previous = style.userSelect;
|
|
10
|
+
style.userSelect = 'none';
|
|
11
|
+
return () => {
|
|
12
|
+
style.userSelect = previous;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Picks elements by drawing a band over them, as in a file manager: pressed beside them inside
|
|
17
|
+
* the scrolling element it is given (`ref`), the pointer draws a band that picks every element
|
|
18
|
+
* it touches (`SELECTABLE_ATTRIBUTE`), and scrolls near the edges. Pressing on an element leaves
|
|
19
|
+
* it to its own handlers (a click, a drag).
|
|
20
|
+
*/
|
|
21
|
+
export function useAreaSelection({ onStart, onChange, disabled = false }) {
|
|
22
|
+
const callbacks = React.useRef({ onStart, onChange });
|
|
23
|
+
callbacks.current = { onStart, onChange };
|
|
24
|
+
const [container, setContainer] = React.useState(null);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
if (!container || disabled)
|
|
27
|
+
return;
|
|
28
|
+
const selector = `[${SELECTABLE_ATTRIBUTE}]`;
|
|
29
|
+
const area = new SelectionArea({
|
|
30
|
+
selectables: [selector],
|
|
31
|
+
startAreas: [container],
|
|
32
|
+
boundaries: [container],
|
|
33
|
+
selectionAreaClass: 'selection-area',
|
|
34
|
+
behaviour: {
|
|
35
|
+
startThreshold: 8,
|
|
36
|
+
overlap: 'keep',
|
|
37
|
+
intersect: 'touch',
|
|
38
|
+
scrolling: { speedDivider: 10, manualSpeed: 750, startScrollMargins: { x: 0, y: 24 } },
|
|
39
|
+
},
|
|
40
|
+
features: { touch: true, range: false, singleTap: { allow: false, intersect: 'native' } },
|
|
41
|
+
});
|
|
42
|
+
// The browser sends a click once the button is released: after a band, it isn't one. It is
|
|
43
|
+
// swallowed here, whenever it comes, until the next press.
|
|
44
|
+
let moved = false;
|
|
45
|
+
const swallowBandClick = (event) => {
|
|
46
|
+
if (!moved)
|
|
47
|
+
return;
|
|
48
|
+
moved = false;
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
};
|
|
52
|
+
container.addEventListener('click', swallowBandClick, { capture: true });
|
|
53
|
+
let releaseTextSelection;
|
|
54
|
+
area
|
|
55
|
+
.on('beforestart', ({ event }) => {
|
|
56
|
+
moved = false;
|
|
57
|
+
// The main button only, and beside the elements: on one, it's that element's press.
|
|
58
|
+
// (`TouchEvent` isn't defined everywhere: no `instanceof` on it.)
|
|
59
|
+
if (!event)
|
|
60
|
+
return false;
|
|
61
|
+
if ('button' in event && event.button !== 0)
|
|
62
|
+
return false;
|
|
63
|
+
return !event.target?.closest(selector);
|
|
64
|
+
})
|
|
65
|
+
.on('start', ({ event }) => {
|
|
66
|
+
moved = true;
|
|
67
|
+
releaseTextSelection = holdTextSelection();
|
|
68
|
+
const additive = !!event && (event.ctrlKey || event.metaKey || event.shiftKey);
|
|
69
|
+
if (!additive)
|
|
70
|
+
area.clearSelection();
|
|
71
|
+
callbacks.current.onStart(additive);
|
|
72
|
+
})
|
|
73
|
+
.on('move', ({ store }) => {
|
|
74
|
+
const ids = store.selected
|
|
75
|
+
.map((element) => element.getAttribute(SELECTABLE_ATTRIBUTE))
|
|
76
|
+
.filter((id) => id !== null);
|
|
77
|
+
callbacks.current.onChange(ids);
|
|
78
|
+
})
|
|
79
|
+
.on('stop', () => {
|
|
80
|
+
releaseTextSelection?.();
|
|
81
|
+
releaseTextSelection = undefined;
|
|
82
|
+
area.clearSelection(false, true);
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
releaseTextSelection?.();
|
|
86
|
+
container.removeEventListener('click', swallowBandClick, { capture: true });
|
|
87
|
+
area.destroy();
|
|
88
|
+
};
|
|
89
|
+
}, [container, disabled]);
|
|
90
|
+
return setContainer;
|
|
91
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/** What the person picked: a photo to upload, or the generated face of a seed. */
|
|
3
|
+
export type AvatarChoice = {
|
|
4
|
+
kind: 'photo';
|
|
5
|
+
file: File;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'generated';
|
|
8
|
+
seed: string;
|
|
9
|
+
};
|
|
10
|
+
export interface AvatarPickerDialogProps {
|
|
11
|
+
open: boolean;
|
|
12
|
+
onOpenChange: (open: boolean) => void;
|
|
13
|
+
/** Defaults to "Profile picture". */
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: React.ReactNode;
|
|
16
|
+
/** MIME types a photo may have (the server checks again). */
|
|
17
|
+
acceptedTypes: readonly string[];
|
|
18
|
+
/** Largest photo accepted, in bytes. */
|
|
19
|
+
maxBytes: number;
|
|
20
|
+
/** Saves the choice; the dialog closes when it resolves and shows its error when it rejects. */
|
|
21
|
+
onSave: (choice: AvatarChoice) => Promise<unknown>;
|
|
22
|
+
/** Draws a seed for a generated face. Defaults to a random UUID v4. */
|
|
23
|
+
newSeed?: () => string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Changes an avatar, for an account or a contact. Split in two: on the left a large drop zone
|
|
27
|
+
* for a photo (once chosen, the photo replaces it in a big circle, still accepting a drop),
|
|
28
|
+
* on the right a button that draws a generated face. One choice at a time; Save applies it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function AvatarPickerDialog({ open, onOpenChange, title, description, acceptedTypes, maxBytes, onSave, newSeed, }: AvatarPickerDialogProps): React.JSX.Element;
|
|
31
|
+
export interface EditableAvatarProps {
|
|
32
|
+
/** The avatar itself (an `EntityAvatar`). */
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
/** Accessible name, e.g. "Change your profile picture". */
|
|
35
|
+
label: string;
|
|
36
|
+
onClick: () => void;
|
|
37
|
+
className?: string;
|
|
38
|
+
}
|
|
39
|
+
/** An avatar that opens its editor: a camera appears over it on hover and focus. */
|
|
40
|
+
export declare function EditableAvatar({ children, label, onClick, className }: EditableAvatarProps): React.JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLocale, useSharedMessages } from '@artemis-apps/translations/react';
|
|
3
|
+
import { CameraIcon, ImageIcon, ShuffleIcon, SparkleIcon, XIcon } from '@phosphor-icons/react';
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { useDropzone } from 'react-dropzone';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import { Button } from './button.js';
|
|
8
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from './dialog.js';
|
|
9
|
+
import { EntityAvatar } from './entity-avatar.js';
|
|
10
|
+
const PREVIEW_SIZE = 176;
|
|
11
|
+
/** `image/png` → `PNG`, `image/webp` → `WebP`. */
|
|
12
|
+
function formatName(type) {
|
|
13
|
+
const subtype = type.split('/')[1] ?? type;
|
|
14
|
+
return subtype === 'webp' ? 'WebP' : subtype.toUpperCase();
|
|
15
|
+
}
|
|
16
|
+
/** `PNG, JPEG or WebP`, in the language spoken. */
|
|
17
|
+
function listFormats(types, locale) {
|
|
18
|
+
return new Intl.ListFormat(locale, { type: 'disjunction' }).format(types.map(formatName));
|
|
19
|
+
}
|
|
20
|
+
/** `1.5` (`1,5` in French): megabytes, to one decimal at most. */
|
|
21
|
+
function megabytes(bytes, locale) {
|
|
22
|
+
return new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(bytes / (1024 * 1024));
|
|
23
|
+
}
|
|
24
|
+
/** A round preview with a small remove button on its edge. */
|
|
25
|
+
function ChosenPreview({ children, removeLabel, onRemove, }) {
|
|
26
|
+
return (_jsxs("div", { className: "relative", children: [_jsx("div", { className: "overflow-hidden rounded-full shadow-lg ring-1 ring-border", style: { width: PREVIEW_SIZE, height: PREVIEW_SIZE }, children: children }), _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": removeLabel, title: removeLabel, onClick: (event) => {
|
|
27
|
+
// Inside the drop zone: removing must not open the file picker.
|
|
28
|
+
event.stopPropagation();
|
|
29
|
+
onRemove();
|
|
30
|
+
}, className: "absolute top-2 right-2 rounded-full text-muted-foreground shadow-sm", children: _jsx(XIcon, {}) })] }));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Changes an avatar, for an account or a contact. Split in two: on the left a large drop zone
|
|
34
|
+
* for a photo (once chosen, the photo replaces it in a big circle, still accepting a drop),
|
|
35
|
+
* on the right a button that draws a generated face. One choice at a time; Save applies it.
|
|
36
|
+
*/
|
|
37
|
+
export function AvatarPickerDialog({ open, onOpenChange, title, description, acceptedTypes, maxBytes, onSave, newSeed = () => crypto.randomUUID(), }) {
|
|
38
|
+
const messages = useSharedMessages();
|
|
39
|
+
const t = messages.ui.avatarPicker;
|
|
40
|
+
const locale = useLocale();
|
|
41
|
+
const [choice, setChoice] = useState();
|
|
42
|
+
const [problem, setProblem] = useState();
|
|
43
|
+
const [saving, setSaving] = useState(false);
|
|
44
|
+
const photo = choice?.kind === 'photo' ? choice.file : undefined;
|
|
45
|
+
const photoUrl = useMemo(() => (photo ? URL.createObjectURL(photo) : undefined), [photo]);
|
|
46
|
+
useEffect(() => () => {
|
|
47
|
+
if (photoUrl)
|
|
48
|
+
URL.revokeObjectURL(photoUrl);
|
|
49
|
+
}, [photoUrl]);
|
|
50
|
+
const formats = listFormats(acceptedTypes, locale);
|
|
51
|
+
const maxMegabytes = megabytes(maxBytes, locale);
|
|
52
|
+
function choose(next) {
|
|
53
|
+
setChoice(next);
|
|
54
|
+
setProblem(undefined);
|
|
55
|
+
}
|
|
56
|
+
function onDropRejected([rejection]) {
|
|
57
|
+
const code = rejection?.errors[0]?.code;
|
|
58
|
+
setProblem(code === 'file-too-large'
|
|
59
|
+
? t.tooLarge(maxMegabytes)
|
|
60
|
+
: code === 'too-many-files'
|
|
61
|
+
? t.tooMany
|
|
62
|
+
: t.wrongType(formats));
|
|
63
|
+
}
|
|
64
|
+
const dropzone = useDropzone({
|
|
65
|
+
accept: Object.fromEntries(acceptedTypes.map((type) => [type, []])),
|
|
66
|
+
maxSize: maxBytes,
|
|
67
|
+
multiple: false,
|
|
68
|
+
disabled: saving,
|
|
69
|
+
// Once a photo is shown, the zone only takes drops; the remove button brings it back.
|
|
70
|
+
noClick: photo !== undefined,
|
|
71
|
+
noKeyboard: photo !== undefined,
|
|
72
|
+
onDropAccepted: ([file]) => file && choose({ kind: 'photo', file }),
|
|
73
|
+
onDropRejected,
|
|
74
|
+
});
|
|
75
|
+
function changeOpen(next) {
|
|
76
|
+
if (saving)
|
|
77
|
+
return;
|
|
78
|
+
if (!next) {
|
|
79
|
+
setChoice(undefined);
|
|
80
|
+
setProblem(undefined);
|
|
81
|
+
}
|
|
82
|
+
onOpenChange(next);
|
|
83
|
+
}
|
|
84
|
+
async function save() {
|
|
85
|
+
if (!choice)
|
|
86
|
+
return;
|
|
87
|
+
setSaving(true);
|
|
88
|
+
setProblem(undefined);
|
|
89
|
+
try {
|
|
90
|
+
await onSave(choice);
|
|
91
|
+
setChoice(undefined);
|
|
92
|
+
onOpenChange(false);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
setProblem(error instanceof Error ? error.message : String(error));
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
setSaving(false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return (_jsx(Dialog, { open: open, onOpenChange: changeOpen, children: _jsxs(DialogContent, { className: "gap-6 sm:max-w-2xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: title ?? t.title }), _jsx(DialogDescription, { children: description ?? t.description })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] sm:gap-6", children: [_jsx("section", { "aria-label": t.uploadSection, className: "flex flex-col gap-3", children: _jsxs("div", { ...dropzone.getRootProps({
|
|
102
|
+
'aria-label': photo ? t.replacePhoto : t.choosePhoto,
|
|
103
|
+
className: cn('relative flex aspect-square flex-col items-center justify-center rounded-xl text-center outline-none transition-colors focus-ring', !photo &&
|
|
104
|
+
'cursor-pointer gap-3 border-2 border-dashed bg-muted/40 px-6 hover:border-primary/40 hover:bg-primary-soft/50', !photo && dropzone.isDragActive && 'border-primary bg-primary-soft', photo && dropzone.isDragActive && 'bg-primary-soft'),
|
|
105
|
+
}), children: [_jsx("input", { ...dropzone.getInputProps({ 'aria-label': t.photo }) }), photo && photoUrl ? (_jsx(ChosenPreview, { removeLabel: t.removePhoto, onRemove: () => choose(undefined), children: _jsx("img", { src: photoUrl, alt: t.yourPick, className: "size-full object-cover" }) })) : (_jsxs(_Fragment, { children: [_jsx(ImageIcon, { "aria-hidden": true, weight: "light", className: "size-9 text-muted-foreground" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("p", { className: "font-medium text-sm", children: dropzone.isDragActive ? t.dropItHere : t.dropHere }), _jsxs("p", { className: "text-muted-foreground text-sm", children: [t.browse.before, _jsx("span", { className: "font-medium text-primary", children: t.browse.link }), t.browse.after] })] }), _jsx("p", { className: "text-muted-foreground text-xs", children: t.limits(formats, maxMegabytes) })] }))] }) }), _jsxs("div", { "aria-hidden": true, className: "flex items-center gap-3 sm:flex-col", children: [_jsx("span", { className: "h-px flex-1 bg-border sm:h-auto sm:w-px" }), _jsx("span", { className: "text-muted-foreground text-xs uppercase tracking-wider", children: messages.common.or }), _jsx("span", { className: "h-px flex-1 bg-border sm:h-auto sm:w-px" })] }), _jsx("section", { "aria-label": t.generateSection, className: "flex flex-col gap-3", children: _jsx("div", { className: "flex aspect-square flex-col items-center justify-center gap-4 rounded-xl", children: choice?.kind === 'generated' ? (_jsxs(_Fragment, { children: [_jsx(ChosenPreview, { removeLabel: t.removeGenerated, onRemove: () => choose(undefined), children: _jsx(EntityAvatar, { name: choice.seed, size: PREVIEW_SIZE, label: t.generatedFace }) }), _jsxs(Button, { variant: "ghost", size: "sm", disabled: saving, onClick: () => choose({ kind: 'generated', seed: newSeed() }), children: [_jsx(ShuffleIcon, {}), t.another] })] })) : (_jsxs(Button, { variant: "outline", disabled: saving, onClick: () => choose({ kind: 'generated', seed: newSeed() }), children: [_jsx(SparkleIcon, {}), t.generate] })) }) })] }), _jsxs(DialogFooter, { className: "items-center sm:justify-between", children: [_jsx("p", { role: problem ? 'alert' : undefined, className: "min-h-5 text-danger-foreground text-sm", children: problem }), _jsxs("div", { className: "flex flex-col-reverse gap-2 sm:flex-row", children: [_jsx(Button, { variant: "ghost", disabled: saving, onClick: () => changeOpen(false), children: messages.common.cancel }), _jsx(Button, { disabled: !choice || saving, onClick: save, loading: saving, children: messages.common.save })] })] })] }) }));
|
|
106
|
+
}
|
|
107
|
+
/** An avatar that opens its editor: a camera appears over it on hover and focus. */
|
|
108
|
+
export function EditableAvatar({ children, label, onClick, className }) {
|
|
109
|
+
return (_jsxs("button", { type: "button", "aria-label": label, title: label, onClick: onClick, className: cn('group relative inline-flex shrink-0 rounded-full outline-none transition-shadow hover:ring-4 hover:ring-primary-soft focus-ring', className), children: [children, _jsx("span", { "aria-hidden": true, className: "absolute inset-0 flex items-center justify-center rounded-full bg-foreground/35 text-white opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 [&_svg]:size-6", children: _jsx(CameraIcon, {}) })] }));
|
|
110
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Avatar as AvatarPrimitive } from 'radix-ui';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
/** @deprecated Use `EntityAvatar` (generated avatars). Kept until every app has migrated. */
|
|
4
|
+
export declare function Avatar({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root>): React.JSX.Element;
|
|
5
|
+
export declare function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar as AvatarPrimitive } from 'radix-ui';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
/** @deprecated Use `EntityAvatar` (generated avatars). Kept until every app has migrated. */
|
|
5
|
+
export function Avatar({ className, ...props }) {
|
|
6
|
+
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", className: cn('relative flex size-8 shrink-0 overflow-hidden rounded-full', className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
export function AvatarFallback({ className, ...props }) {
|
|
9
|
+
return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: cn('flex size-full select-none items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs uppercase', className), ...props }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface BadgeListProps extends React.ComponentProps<'ul'> {
|
|
3
|
+
/** `Badge`s: each becomes an item of the list. */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/** A wrapping row of badges, read as a list. */
|
|
7
|
+
export declare function BadgeList({ className, children, ...props }: BadgeListProps): React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
/** A wrapping row of badges, read as a list. */
|
|
5
|
+
export function BadgeList({ className, children, ...props }) {
|
|
6
|
+
return (_jsx("ul", { "data-slot": "badge-list", className: cn('flex flex-wrap gap-1.5', className), ...props, children: React.Children.toArray(children).map((child) => (_jsx("li", { children: child }, React.isValidElement(child) ? child.key : String(child)))) }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
export declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "danger" | "default" | "destructive" | "info" | "outline" | "secondary" | "subtle" | "success" | "tag" | "tag-outline" | "warning" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export interface BadgeProps extends React.ComponentProps<'span'>, VariantProps<typeof badgeVariants> {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function Badge({ className, variant, asChild, ...props }: BadgeProps): React.JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { Slot as SlotPrimitive } from 'radix-ui';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
export const badgeVariants = cva('inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-full border px-2 py-0.5 font-medium text-xs transition-colors focus-visible:border-ring focus-ring [&>svg]:pointer-events-none [&>svg]:size-3', {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: 'border-transparent bg-primary text-primary-foreground',
|
|
9
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground',
|
|
10
|
+
outline: 'text-foreground',
|
|
11
|
+
/** A quiet chip in a list of tags (permissions, rights). */
|
|
12
|
+
tag: 'border-transparent bg-secondary font-normal text-secondary-foreground',
|
|
13
|
+
/** An outlined chip in a list of tags. */
|
|
14
|
+
'tag-outline': 'font-normal text-foreground',
|
|
15
|
+
/** A remark beside a name ("You", "Info"): outlined and muted. */
|
|
16
|
+
subtle: 'font-normal text-muted-foreground',
|
|
17
|
+
info: 'border-transparent bg-info-soft text-info-foreground',
|
|
18
|
+
success: 'border-transparent bg-success-soft text-success-foreground',
|
|
19
|
+
warning: 'border-transparent bg-warning-soft text-warning-foreground',
|
|
20
|
+
danger: 'border-transparent bg-danger-soft text-danger-foreground',
|
|
21
|
+
/** Alias of `danger`. */
|
|
22
|
+
destructive: 'border-transparent bg-danger-soft text-danger-foreground',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: 'default',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export function Badge({ className, variant, asChild = false, ...props }) {
|
|
30
|
+
const Comp = asChild ? SlotPrimitive.Slot : 'span';
|
|
31
|
+
return (_jsx(Comp, { "data-slot": "badge", "data-variant": variant ?? 'default', className: cn(badgeVariants({ variant }), className), ...props }));
|
|
32
|
+
}
|