oneslash-design-system 2.22.0 → 2.23.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/README.md +1 -1
- package/dist/DESIGN.md +12 -1
- package/dist/cases/admin-inbox/split.jsx +22 -10
- package/dist/cases/admin-inbox.md +28 -23
- package/dist/cases/api-keys.md +1 -1
- package/dist/cases/breadcrumb/back-link.d.ts +1 -0
- package/dist/cases/breadcrumb/back-link.jsx +23 -0
- package/dist/cases/breadcrumb/trail.d.ts +1 -0
- package/dist/cases/breadcrumb/trail.jsx +28 -0
- package/dist/cases/breadcrumb.md +105 -0
- package/dist/cases/date-field/calendar.d.ts +1 -0
- package/dist/cases/date-field/calendar.jsx +80 -0
- package/dist/cases/date-field/typed.d.ts +1 -0
- package/dist/cases/date-field/typed.jsx +58 -0
- package/dist/cases/date-field.md +232 -0
- package/dist/cases/docs-component-page/reference.jsx +11 -1
- package/dist/cases/docs-component-page.md +19 -8
- package/dist/cases/file-upload/files.d.ts +1 -0
- package/dist/cases/file-upload/files.jsx +118 -0
- package/dist/cases/file-upload/picture.d.ts +1 -0
- package/dist/cases/file-upload/picture.jsx +50 -0
- package/dist/cases/file-upload.md +270 -0
- package/dist/cases/filter-menu.md +1 -1
- package/dist/cases/image-viewer/with-video.d.ts +1 -0
- package/dist/cases/image-viewer/with-video.jsx +42 -0
- package/dist/cases/image-viewer.md +72 -4
- package/dist/cases/master-detail/split.jsx +17 -10
- package/dist/cases/master-detail.md +26 -24
- package/dist/cases/message-reactions/picker.d.ts +1 -0
- package/dist/cases/message-reactions/picker.jsx +145 -0
- package/dist/cases/message-reactions/quick-pick.jsx +1 -1
- package/dist/cases/message-reactions.md +184 -3
- package/dist/cases/page-header.md +1 -1
- package/dist/cases/people-row/names.d.ts +1 -0
- package/dist/cases/people-row/names.jsx +20 -0
- package/dist/cases/people-row/stack.d.ts +1 -0
- package/dist/cases/people-row/stack.jsx +33 -0
- package/dist/cases/people-row.md +110 -0
- package/dist/cases/profile-form/form.jsx +21 -10
- package/dist/cases/profile-form.md +38 -9
- package/dist/cases.json +306 -25
- package/dist/components/avatarStack.d.ts +22 -0
- package/dist/components/avatarStack.jsx +32 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.jsx +24 -0
- package/dist/components/calendar.d.ts +19 -0
- package/dist/components/calendar.jsx +126 -0
- package/dist/components/dateField.d.ts +35 -0
- package/dist/components/dateField.jsx +76 -0
- package/dist/components/dropZone.d.ts +53 -0
- package/dist/components/dropZone.jsx +136 -0
- package/dist/components/emojiPicker.d.ts +22 -0
- package/dist/components/emojiPicker.jsx +161 -0
- package/dist/components/itemList.d.ts +31 -0
- package/dist/components/itemList.jsx +81 -0
- package/dist/components/lightbox.d.ts +33 -9
- package/dist/components/lightbox.jsx +58 -27
- package/dist/components/menuItem.d.ts +1 -1
- package/dist/components/menuItem.jsx +3 -3
- package/dist/components/popover.jsx +7 -2
- package/dist/internal/date.d.ts +35 -0
- package/dist/internal/date.js +122 -0
- package/dist/internal/dropZone.d.ts +28 -0
- package/dist/internal/dropZone.js +42 -0
- package/dist/internal/emoji.d.ts +13 -0
- package/dist/internal/emoji.js +182 -0
- package/dist/internal/overlayStack.js +1 -1
- package/dist/internal/people.d.ts +1 -0
- package/dist/internal/people.js +12 -0
- package/dist/native-mapping.json +45 -3
- package/dist/stories/AvatarStack.stories.d.ts +7 -0
- package/dist/stories/AvatarStack.stories.jsx +46 -0
- package/dist/stories/Breadcrumb.stories.d.ts +7 -0
- package/dist/stories/Breadcrumb.stories.jsx +26 -0
- package/dist/stories/Calendar.stories.d.ts +6 -0
- package/dist/stories/Calendar.stories.jsx +15 -0
- package/dist/stories/Cases.generated.stories.d.ts +10 -0
- package/dist/stories/Cases.generated.stories.jsx +20 -0
- package/dist/stories/DateField.stories.d.ts +10 -0
- package/dist/stories/DateField.stories.jsx +132 -0
- package/dist/stories/DropZone.stories.d.ts +12 -0
- package/dist/stories/DropZone.stories.jsx +151 -0
- package/dist/stories/EmojiPicker.stories.d.ts +6 -0
- package/dist/stories/EmojiPicker.stories.jsx +92 -0
- package/dist/stories/ItemList.stories.d.ts +9 -0
- package/dist/stories/ItemList.stories.jsx +86 -0
- package/dist/stories/Lightbox.stories.d.ts +4 -0
- package/dist/stories/Lightbox.stories.jsx +44 -0
- package/dist/stories/Popover.stories.d.ts +1 -0
- package/dist/stories/Popover.stories.jsx +17 -0
- package/package.json +3 -2
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Day maths on ISO day strings ('YYYY-MM-DD'). Every step goes through Date.UTC and the getUTC*
|
|
2
|
+
// methods, so the local time zone and its daylight-saving changes can never move a day.
|
|
3
|
+
// Only todayIso reads the local clock, because "today" is the user's own date.
|
|
4
|
+
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
5
|
+
export var MONTH_NAMES = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
6
|
+
var pad = function (n, width) {
|
|
7
|
+
if (width === void 0) { width = 2; }
|
|
8
|
+
return String(n).padStart(width, '0');
|
|
9
|
+
};
|
|
10
|
+
function parts(iso) {
|
|
11
|
+
return [Number(iso.slice(0, 4)), Number(iso.slice(5, 7)), Number(iso.slice(8, 10))];
|
|
12
|
+
}
|
|
13
|
+
/** Days in a month, `month` 1 to 12 */
|
|
14
|
+
export function daysInMonth(year, month) {
|
|
15
|
+
return new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
16
|
+
}
|
|
17
|
+
function iso(year, month, day) {
|
|
18
|
+
return "".concat(pad(year, 4), "-").concat(pad(month), "-").concat(pad(day));
|
|
19
|
+
}
|
|
20
|
+
function fromUtc(d) {
|
|
21
|
+
return iso(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
|
|
22
|
+
}
|
|
23
|
+
function valid(year, month, day) {
|
|
24
|
+
// Date.UTC reads years 0 to 99 as 1900 to 1999, and no one types a year before 1000
|
|
25
|
+
if (year < 1000 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month))
|
|
26
|
+
return null;
|
|
27
|
+
return iso(year, month, day);
|
|
28
|
+
}
|
|
29
|
+
/** 'M/D/YYYY', 'MM/DD/YYYY' or 'YYYY-MM-DD' to an ISO day; null for any other text or a day that does not exist */
|
|
30
|
+
export function parseTyped(text) {
|
|
31
|
+
var t = text.trim();
|
|
32
|
+
var us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(t);
|
|
33
|
+
if (us)
|
|
34
|
+
return valid(Number(us[3]), Number(us[1]), Number(us[2]));
|
|
35
|
+
var isoForm = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t);
|
|
36
|
+
if (isoForm)
|
|
37
|
+
return valid(Number(isoForm[1]), Number(isoForm[2]), Number(isoForm[3]));
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/** Whether the text is M/D/Y with a year of one to three digits, such as '11/16/26' */
|
|
41
|
+
export function shortYear(text) {
|
|
42
|
+
return /^\d{1,2}\/\d{1,2}\/\d{1,3}$/.test(text.trim());
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reads what was typed into a date field. Empty text is `{ value: '', error: null }`; text that is not a real date,
|
|
46
|
+
* or is outside `min`/`max`, is `{ value: '', error: <why> }`; a good date is its ISO day, its text as MM/DD/YYYY and no error.
|
|
47
|
+
*/
|
|
48
|
+
export function readTyped(text, min, max) {
|
|
49
|
+
if (!text.trim())
|
|
50
|
+
return { value: '', text: '', error: null };
|
|
51
|
+
var day = parseTyped(text);
|
|
52
|
+
var error = !day
|
|
53
|
+
? shortYear(text) ? 'Enter the year in four digits, like 2026.' : 'Enter a real date as MM/DD/YYYY.'
|
|
54
|
+
: min && compare(day, min) < 0
|
|
55
|
+
? "Choose ".concat(formatLong(min), " or later.")
|
|
56
|
+
: max && compare(day, max) > 0
|
|
57
|
+
? "Choose ".concat(formatLong(max), " or earlier.")
|
|
58
|
+
: null;
|
|
59
|
+
if (error || !day)
|
|
60
|
+
return { value: '', text: text, error: error };
|
|
61
|
+
return { value: day, text: toTyped(day), error: null };
|
|
62
|
+
}
|
|
63
|
+
/** '2026-11-16' to '11/16/2026' */
|
|
64
|
+
export function toTyped(value) {
|
|
65
|
+
var _a = parts(value), y = _a[0], m = _a[1], d = _a[2];
|
|
66
|
+
return "".concat(pad(m), "/").concat(pad(d), "/").concat(pad(y, 4));
|
|
67
|
+
}
|
|
68
|
+
/** '2026-11-16' to 'Nov 16, 2026' */
|
|
69
|
+
export function formatLong(value) {
|
|
70
|
+
var _a = parts(value), y = _a[0], m = _a[1], d = _a[2];
|
|
71
|
+
return "".concat(MONTHS[m - 1], " ").concat(d, ", ").concat(y);
|
|
72
|
+
}
|
|
73
|
+
/** '2026-11-16' to 'November 2026' */
|
|
74
|
+
export function monthLabel(value) {
|
|
75
|
+
var _a = parts(value), y = _a[0], m = _a[1];
|
|
76
|
+
return "".concat(MONTH_NAMES[m - 1], " ").concat(y);
|
|
77
|
+
}
|
|
78
|
+
export function addDays(value, n) {
|
|
79
|
+
var _a = parts(value), y = _a[0], m = _a[1], d = _a[2];
|
|
80
|
+
return fromUtc(new Date(Date.UTC(y, m - 1, d + n)));
|
|
81
|
+
}
|
|
82
|
+
/** Moves by whole months and keeps the day, clamped to the last day of a shorter month (Jan 31 + 1 is Feb 28) */
|
|
83
|
+
export function addMonths(value, n) {
|
|
84
|
+
var _a = parts(value), y = _a[0], m = _a[1], d = _a[2];
|
|
85
|
+
var first = new Date(Date.UTC(y, m - 1 + n, 1));
|
|
86
|
+
var year = first.getUTCFullYear();
|
|
87
|
+
var month = first.getUTCMonth() + 1;
|
|
88
|
+
return iso(year, month, Math.min(d, daysInMonth(year, month)));
|
|
89
|
+
}
|
|
90
|
+
/** ISO day strings sort as text */
|
|
91
|
+
export function compare(a, b) {
|
|
92
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
93
|
+
}
|
|
94
|
+
/** The user's own date, from the local clock */
|
|
95
|
+
export function todayIso() {
|
|
96
|
+
var now = new Date();
|
|
97
|
+
return iso(now.getFullYear(), now.getMonth() + 1, now.getDate());
|
|
98
|
+
}
|
|
99
|
+
/** 0 for Sunday to 6 for Saturday */
|
|
100
|
+
export function weekday(value) {
|
|
101
|
+
var _a = parts(value), y = _a[0], m = _a[1], d = _a[2];
|
|
102
|
+
return new Date(Date.UTC(y, m - 1, d)).getUTCDay();
|
|
103
|
+
}
|
|
104
|
+
/** The month of `value` as weeks from Sunday to Saturday; `null` for the cells outside the month */
|
|
105
|
+
export function monthGrid(value) {
|
|
106
|
+
var _a = parts(value), y = _a[0], m = _a[1];
|
|
107
|
+
var lead = weekday(iso(y, m, 1));
|
|
108
|
+
var total = daysInMonth(y, m);
|
|
109
|
+
var cells = Array(lead).fill(null);
|
|
110
|
+
for (var d = 1; d <= total; d++)
|
|
111
|
+
cells.push(iso(y, m, d));
|
|
112
|
+
while (cells.length % 7)
|
|
113
|
+
cells.push(null);
|
|
114
|
+
var weeks = [];
|
|
115
|
+
for (var i = 0; i < cells.length; i += 7)
|
|
116
|
+
weeks.push(cells.slice(i, i + 7));
|
|
117
|
+
return weeks;
|
|
118
|
+
}
|
|
119
|
+
/** Whether `value` is within `min` and `max` (either may be missing) */
|
|
120
|
+
export function inRange(value, min, max) {
|
|
121
|
+
return !(min && compare(value, min) < 0) && !(max && compare(value, max) > 0);
|
|
122
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type FileRejection = {
|
|
2
|
+
name: string;
|
|
3
|
+
reason: 'type' | 'size' | 'count';
|
|
4
|
+
};
|
|
5
|
+
type FileInfo = {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
size: number;
|
|
9
|
+
};
|
|
10
|
+
interface CheckOptions {
|
|
11
|
+
/** MIME types ('image/png'), wildcards ('image/*') or extensions ('.pdf'). Left out, every file is accepted. */
|
|
12
|
+
accept?: string[];
|
|
13
|
+
/** The largest file, in bytes */
|
|
14
|
+
maxBytes?: number;
|
|
15
|
+
multiple: boolean;
|
|
16
|
+
/** With `multiple`: the most files in one choice. Left out, no limit. */
|
|
17
|
+
maxFiles?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the indexes of the files to keep and the files to refuse with a reason. A wrong type or a file over
|
|
21
|
+
* `maxBytes` is refused as `type` or `size`. A good file past the number allowed (one, unless `multiple`; then
|
|
22
|
+
* `maxFiles`) is refused as `count`, in order.
|
|
23
|
+
*/
|
|
24
|
+
export declare function checkFiles(files: FileInfo[], { accept, maxBytes, multiple, maxFiles }: CheckOptions): {
|
|
25
|
+
accepted: number[];
|
|
26
|
+
rejected: FileRejection[];
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Checks a set of files against what a DropZone accepts. Pure, so it can be tested without a browser.
|
|
2
|
+
function matchesType(file, pattern) {
|
|
3
|
+
var p = pattern.trim().toLowerCase();
|
|
4
|
+
if (!p)
|
|
5
|
+
return false;
|
|
6
|
+
var name = file.name.toLowerCase();
|
|
7
|
+
if (p.startsWith('.'))
|
|
8
|
+
return name.endsWith(p);
|
|
9
|
+
// A file with no type (some systems give none) is matched by extension only
|
|
10
|
+
if (!file.type)
|
|
11
|
+
return false;
|
|
12
|
+
var type = file.type.toLowerCase();
|
|
13
|
+
if (p.endsWith('/*'))
|
|
14
|
+
return type.startsWith(p.slice(0, -1));
|
|
15
|
+
return type === p;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the indexes of the files to keep and the files to refuse with a reason. A wrong type or a file over
|
|
19
|
+
* `maxBytes` is refused as `type` or `size`. A good file past the number allowed (one, unless `multiple`; then
|
|
20
|
+
* `maxFiles`) is refused as `count`, in order.
|
|
21
|
+
*/
|
|
22
|
+
export function checkFiles(files, _a) {
|
|
23
|
+
var accept = _a.accept, maxBytes = _a.maxBytes, multiple = _a.multiple, maxFiles = _a.maxFiles;
|
|
24
|
+
var limit = multiple ? (maxFiles !== null && maxFiles !== void 0 ? maxFiles : Infinity) : 1;
|
|
25
|
+
var accepted = [];
|
|
26
|
+
var rejected = [];
|
|
27
|
+
files.forEach(function (file, index) {
|
|
28
|
+
if (accept && accept.length > 0 && !accept.some(function (p) { return matchesType(file, p); })) {
|
|
29
|
+
rejected.push({ name: file.name, reason: 'type' });
|
|
30
|
+
}
|
|
31
|
+
else if (maxBytes !== undefined && file.size > maxBytes) {
|
|
32
|
+
rejected.push({ name: file.name, reason: 'size' });
|
|
33
|
+
}
|
|
34
|
+
else if (accepted.length >= limit) {
|
|
35
|
+
rejected.push({ name: file.name, reason: 'count' });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
accepted.push(index);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return { accepted: accepted, rejected: rejected };
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type EmojiEntry = {
|
|
2
|
+
char: string;
|
|
3
|
+
name: string;
|
|
4
|
+
keywords: string[];
|
|
5
|
+
};
|
|
6
|
+
export type EmojiGroup = {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
emojis: EmojiEntry[];
|
|
10
|
+
};
|
|
11
|
+
export declare const quickEmoji: EmojiEntry[];
|
|
12
|
+
export declare const emojiGroups: EmojiGroup[];
|
|
13
|
+
export declare function searchEmoji(groups: EmojiGroup[], query: string): EmojiEntry[];
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// A small built-in emoji set with names written by hand, for EmojiPicker.
|
|
2
|
+
// Every emoji is from Unicode 12.0 (2019) or older, one code point (or one plus U+FE0F), with no skin tone
|
|
3
|
+
// and no joined sequence, so every supported system draws it as one glyph. An app can pass its own groups.
|
|
4
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
5
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
6
|
+
if (ar || !(i in from)) {
|
|
7
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
8
|
+
ar[i] = from[i];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
12
|
+
};
|
|
13
|
+
var e = function (char, name, keywords) {
|
|
14
|
+
if (keywords === void 0) { keywords = []; }
|
|
15
|
+
return ({ char: char, name: name, keywords: keywords });
|
|
16
|
+
};
|
|
17
|
+
// The six people react with most, the same as the quick pick in the reactions case
|
|
18
|
+
export var quickEmoji = [
|
|
19
|
+
e('👍', 'Thumbs up', ['yes', 'agree', 'like', 'approve', '+1']),
|
|
20
|
+
e('❤️', 'Heart', ['love', 'red']),
|
|
21
|
+
e('😂', 'Tears of joy', ['laugh', 'funny', 'lol']),
|
|
22
|
+
e('🎉', 'Party popper', ['celebrate', 'congrats', 'tada']),
|
|
23
|
+
e('👀', 'Eyes', ['look', 'watching', 'seen']),
|
|
24
|
+
e('🚀', 'Rocket', ['launch', 'ship', 'fast']),
|
|
25
|
+
];
|
|
26
|
+
var thumbsUp = quickEmoji[0], heart = quickEmoji[1], tearsOfJoy = quickEmoji[2], partyPopper = quickEmoji[3], eyes = quickEmoji[4], rocket = quickEmoji[5];
|
|
27
|
+
export var emojiGroups = [
|
|
28
|
+
{
|
|
29
|
+
id: 'faces',
|
|
30
|
+
label: 'Faces',
|
|
31
|
+
emojis: [
|
|
32
|
+
e('😀', 'Grinning face', ['smile', 'happy']),
|
|
33
|
+
e('😄', 'Big smile', ['happy', 'grin']),
|
|
34
|
+
tearsOfJoy,
|
|
35
|
+
e('🙂', 'Slight smile', ['happy', 'fine']),
|
|
36
|
+
e('😉', 'Wink', ['joke']),
|
|
37
|
+
e('😊', 'Blush', ['happy', 'smile']),
|
|
38
|
+
e('😍', 'Heart eyes', ['love']),
|
|
39
|
+
e('🥰', 'Smiling face with hearts', ['love', 'adore']),
|
|
40
|
+
e('😎', 'Cool', ['sunglasses']),
|
|
41
|
+
e('🤔', 'Thinking', ['hmm', 'wonder']),
|
|
42
|
+
e('😅', 'Nervous laugh', ['sweat', 'phew']),
|
|
43
|
+
e('😮', 'Surprised', ['wow', 'oh']),
|
|
44
|
+
e('😢', 'Crying', ['sad', 'tear']),
|
|
45
|
+
e('😴', 'Sleeping', ['tired', 'sleep']),
|
|
46
|
+
eyes,
|
|
47
|
+
e('🤯', 'Mind blown', ['shocked', 'wow']),
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'hands',
|
|
52
|
+
label: 'Hands',
|
|
53
|
+
emojis: [
|
|
54
|
+
thumbsUp,
|
|
55
|
+
e('👎', 'Thumbs down', ['no', 'disagree', 'dislike', '-1']),
|
|
56
|
+
e('👏', 'Clap', ['applause', 'bravo']),
|
|
57
|
+
e('🙌', 'Raised hands', ['hooray', 'celebrate']),
|
|
58
|
+
e('🙏', 'Folded hands', ['please', 'thanks', 'pray']),
|
|
59
|
+
e('👋', 'Wave', ['hello', 'hi', 'bye']),
|
|
60
|
+
e('👌', 'OK hand', ['okay', 'fine']),
|
|
61
|
+
e('✌️', 'Victory hand', ['peace']),
|
|
62
|
+
e('🤞', 'Crossed fingers', ['luck', 'hope']),
|
|
63
|
+
e('💪', 'Flexed biceps', ['strong', 'muscle']),
|
|
64
|
+
e('👊', 'Fist bump', ['punch']),
|
|
65
|
+
e('🤝', 'Handshake', ['deal', 'agree']),
|
|
66
|
+
e('👉', 'Pointing right', ['this', 'next']),
|
|
67
|
+
e('👆', 'Pointing up', ['this', 'above']),
|
|
68
|
+
e('✋', 'Raised hand', ['stop', 'high five']),
|
|
69
|
+
e('🤙', 'Call me', ['phone', 'shaka']),
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'symbols',
|
|
74
|
+
label: 'Hearts and symbols',
|
|
75
|
+
emojis: [
|
|
76
|
+
heart,
|
|
77
|
+
e('🧡', 'Orange heart', ['love']),
|
|
78
|
+
e('💛', 'Yellow heart', ['love']),
|
|
79
|
+
e('💚', 'Green heart', ['love']),
|
|
80
|
+
e('💙', 'Blue heart', ['love']),
|
|
81
|
+
e('💜', 'Purple heart', ['love']),
|
|
82
|
+
e('🖤', 'Black heart', ['love']),
|
|
83
|
+
e('💯', 'Hundred points', ['perfect', '100']),
|
|
84
|
+
e('✅', 'Check mark', ['done', 'yes', 'complete']),
|
|
85
|
+
e('❌', 'Cross mark', ['no', 'wrong']),
|
|
86
|
+
e('❗', 'Exclamation mark', ['important', 'alert']),
|
|
87
|
+
e('❓', 'Question mark', ['question', 'unsure']),
|
|
88
|
+
e('⭐', 'Star', ['favorite']),
|
|
89
|
+
e('✨', 'Sparkles', ['new', 'shiny']),
|
|
90
|
+
e('🔥', 'Fire', ['hot', 'lit']),
|
|
91
|
+
e('⚡', 'Lightning', ['fast', 'power', 'zap']),
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'work',
|
|
96
|
+
label: 'Work',
|
|
97
|
+
emojis: [
|
|
98
|
+
e('💻', 'Laptop', ['computer', 'code']),
|
|
99
|
+
e('📅', 'Calendar', ['date', 'schedule']),
|
|
100
|
+
e('📌', 'Pin', ['pushpin', 'important']),
|
|
101
|
+
e('📎', 'Paperclip', ['attach', 'file']),
|
|
102
|
+
e('📝', 'Note', ['memo', 'write']),
|
|
103
|
+
e('📊', 'Bar chart', ['stats', 'data']),
|
|
104
|
+
e('📈', 'Chart going up', ['growth', 'up', 'trend']),
|
|
105
|
+
e('💡', 'Light bulb', ['idea']),
|
|
106
|
+
e('🔍', 'Magnifying glass', ['search', 'look']),
|
|
107
|
+
e('🔒', 'Lock', ['private', 'secure']),
|
|
108
|
+
e('📣', 'Megaphone', ['announce', 'news']),
|
|
109
|
+
e('📦', 'Package', ['box', 'release', 'ship']),
|
|
110
|
+
e('🐛', 'Bug', ['issue', 'error']),
|
|
111
|
+
e('⏰', 'Alarm clock', ['deadline', 'time']),
|
|
112
|
+
e('💬', 'Speech bubble', ['comment', 'chat']),
|
|
113
|
+
e('📧', 'Email', ['mail', 'message']),
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'celebration',
|
|
118
|
+
label: 'Celebration',
|
|
119
|
+
emojis: [
|
|
120
|
+
partyPopper,
|
|
121
|
+
e('🎊', 'Confetti ball', ['celebrate', 'party']),
|
|
122
|
+
e('🥳', 'Partying face', ['party', 'birthday']),
|
|
123
|
+
e('🎂', 'Birthday cake', ['birthday', 'cake']),
|
|
124
|
+
e('🎁', 'Gift', ['present', 'birthday']),
|
|
125
|
+
e('🎈', 'Balloon', ['party', 'birthday']),
|
|
126
|
+
e('🏆', 'Trophy', ['win', 'winner', 'award']),
|
|
127
|
+
e('🥇', 'Gold medal', ['first', 'win']),
|
|
128
|
+
rocket,
|
|
129
|
+
e('🌟', 'Glowing star', ['shine', 'star']),
|
|
130
|
+
e('🍾', 'Champagne', ['celebrate', 'bottle']),
|
|
131
|
+
e('🥂', 'Cheers', ['toast', 'drink']),
|
|
132
|
+
e('🎯', 'Bullseye', ['target', 'goal']),
|
|
133
|
+
e('🏁', 'Finish flag', ['finish', 'done', 'race']),
|
|
134
|
+
e('🎶', 'Music', ['notes', 'song']),
|
|
135
|
+
e('👑', 'Crown', ['king', 'queen', 'best']),
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 'nature',
|
|
140
|
+
label: 'Nature and food',
|
|
141
|
+
emojis: [
|
|
142
|
+
e('☀️', 'Sun', ['sunny', 'weather']),
|
|
143
|
+
e('🌈', 'Rainbow', ['weather']),
|
|
144
|
+
e('❄️', 'Snowflake', ['snow', 'cold', 'winter']),
|
|
145
|
+
e('🌱', 'Seedling', ['grow', 'plant', 'new']),
|
|
146
|
+
e('🌸', 'Cherry blossom', ['flower', 'spring']),
|
|
147
|
+
e('🌻', 'Sunflower', ['flower', 'summer']),
|
|
148
|
+
e('🍀', 'Four leaf clover', ['luck', 'lucky']),
|
|
149
|
+
e('🌲', 'Tree', ['evergreen', 'forest']),
|
|
150
|
+
e('🐶', 'Dog', ['puppy', 'pet']),
|
|
151
|
+
e('🐱', 'Cat', ['kitten', 'pet']),
|
|
152
|
+
e('🍕', 'Pizza', ['food', 'lunch']),
|
|
153
|
+
e('🍔', 'Burger', ['food', 'lunch']),
|
|
154
|
+
e('🍩', 'Donut', ['doughnut', 'food', 'sweet']),
|
|
155
|
+
e('🍎', 'Apple', ['fruit', 'food']),
|
|
156
|
+
e('☕', 'Coffee', ['tea', 'drink', 'break']),
|
|
157
|
+
e('🍪', 'Cookie', ['food', 'sweet']),
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
// The emoji whose name or a keyword has a word starting with the query, ignoring case, each once.
|
|
162
|
+
// An empty query matches every emoji.
|
|
163
|
+
export function searchEmoji(groups, query) {
|
|
164
|
+
var q = query.trim().toLowerCase();
|
|
165
|
+
var seen = new Set();
|
|
166
|
+
var found = [];
|
|
167
|
+
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
|
168
|
+
var group = groups_1[_i];
|
|
169
|
+
for (var _a = 0, _b = group.emojis; _a < _b.length; _a++) {
|
|
170
|
+
var emoji = _b[_a];
|
|
171
|
+
if (seen.has(emoji.char))
|
|
172
|
+
continue;
|
|
173
|
+
var words = __spreadArray([emoji.name], emoji.keywords, true).flatMap(function (w) { return w.toLowerCase().split(/\s+/); });
|
|
174
|
+
var match = !q || emoji.name.toLowerCase().startsWith(q) || emoji.keywords.some(function (k) { return k.toLowerCase().startsWith(q); }) || words.some(function (w) { return w.startsWith(q); });
|
|
175
|
+
if (!match)
|
|
176
|
+
continue;
|
|
177
|
+
seen.add(emoji.char);
|
|
178
|
+
found.push(emoji);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return found;
|
|
182
|
+
}
|
|
@@ -46,7 +46,7 @@ export function unlockScroll() {
|
|
|
46
46
|
if (--locks === 0)
|
|
47
47
|
document.body.style.overflow = savedOverflow;
|
|
48
48
|
}
|
|
49
|
-
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
49
|
+
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), video[controls], audio[controls], [tabindex]:not([tabindex="-1"])';
|
|
50
50
|
// For the first focus and the Tab trap: the same, minus a hidden input, which matches but cannot take focus
|
|
51
51
|
export var PICKABLE = FOCUSABLE.replace('input:not([disabled])', 'input:not([disabled]):not([type="hidden"])');
|
|
52
52
|
// Keeps Tab and Shift+Tab inside the panel: from the last element to the first and back.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function peopleLabel(names: string[]): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// A short spoken name for a group: up to three names, then two and a count.
|
|
2
|
+
export function peopleLabel(names) {
|
|
3
|
+
if (names.length === 0)
|
|
4
|
+
return '';
|
|
5
|
+
if (names.length === 1)
|
|
6
|
+
return names[0];
|
|
7
|
+
if (names.length === 2)
|
|
8
|
+
return "".concat(names[0], " and ").concat(names[1]);
|
|
9
|
+
if (names.length === 3)
|
|
10
|
+
return "".concat(names[0], ", ").concat(names[1], " and ").concat(names[2]);
|
|
11
|
+
return "".concat(names[0], ", ").concat(names[1], " and ").concat(names.length - 2, " others");
|
|
12
|
+
}
|
package/dist/native-mapping.json
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
"compose": "`NavigationSuiteScaffold`; on a phone a `ModalNavigationDrawer` around a `Scaffold`",
|
|
19
19
|
"note": "The split view collapses to a stack on iPhone and shows and hides the sidebar itself. The skip link is web only."
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
"ods": "avatarStack",
|
|
23
|
+
"swiftui": "An `HStack(spacing: -8)` of avatars, each with a ring in the background color and a count `Text` in a circle past the limit, with `.accessibilityElement(children: .combine)` and a label naming the people",
|
|
24
|
+
"compose": "A `Row` with `Arrangement.spacedBy((-8).dp)` of avatars and a count circle, with `semantics(mergeDescendants = true)` and a label naming the people",
|
|
25
|
+
"note": "To list everyone, make the stack a `Button` that opens a popover (iPad, Mac) or a sheet (iPhone) / a `DropdownMenu` or `ModalBottomSheet`."
|
|
26
|
+
},
|
|
21
27
|
{
|
|
22
28
|
"ods": "button",
|
|
23
29
|
"swiftui": "`Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary",
|
|
@@ -29,6 +35,18 @@
|
|
|
29
35
|
"swiftui": "the provider's own button where one exists (`SignInWithAppleButton`), else an asset in the app",
|
|
30
36
|
"compose": "an asset in the app"
|
|
31
37
|
},
|
|
38
|
+
{
|
|
39
|
+
"ods": "breadcrumb",
|
|
40
|
+
"swiftui": "Not applicable: web page pattern",
|
|
41
|
+
"compose": "Not applicable: web page pattern",
|
|
42
|
+
"note": "The system back button and the navigation title say where the person is."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"ods": "calendar",
|
|
46
|
+
"swiftui": "`DatePicker` with `.datePickerStyle(.graphical)` and `in:` for the range",
|
|
47
|
+
"compose": "`DatePicker` with a `DatePickerState` whose `selectableDates` holds the range",
|
|
48
|
+
"note": "The system calendar draws the month, today and the chosen day, and moves with the keyboard. Inside a field, use `dateField`."
|
|
49
|
+
},
|
|
32
50
|
{
|
|
33
51
|
"ods": "checkBox",
|
|
34
52
|
"swiftui": "`Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS)",
|
|
@@ -52,12 +70,30 @@
|
|
|
52
70
|
"compose": "An `OutlinedTextField` with `readOnly = true` and a `trailingIcon` `TextButton` that calls `LocalClipboard`",
|
|
53
71
|
"note": "Show \"Copied\" for 2 seconds only after the write succeeds. Announce it for VoiceOver / TalkBack. A secret shown once gets the line under it."
|
|
54
72
|
},
|
|
73
|
+
{
|
|
74
|
+
"ods": "dateField",
|
|
75
|
+
"swiftui": "`DatePicker` with `.datePickerStyle(.compact)` and `in:` for the range",
|
|
76
|
+
"compose": "`DatePicker` in a `DatePickerDialog`, opened from a read-only `OutlinedTextField`, with `selectableDates` for the range",
|
|
77
|
+
"note": "The system picker cannot hold a day outside the range, so there is no out-of-range message. Store the day as `YYYY-MM-DD`, not a time."
|
|
78
|
+
},
|
|
55
79
|
{
|
|
56
80
|
"ods": "drawer",
|
|
57
81
|
"swiftui": "`.sheet` with `.presentationDetents` on iPhone; `.inspector` on iPad and Mac",
|
|
58
82
|
"compose": "`ModalNavigationDrawer` for `side=\"start\"`; `ModalBottomSheet` for `side=\"end\"`",
|
|
59
83
|
"note": "The system sheet, inspector and drawer handle the scrim, swipe to close and focus. `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`."
|
|
60
84
|
},
|
|
85
|
+
{
|
|
86
|
+
"ods": "dropZone",
|
|
87
|
+
"swiftui": "`PhotosPicker` for pictures, or `.fileImporter` for files, behind a `Button`; add `.dropDestination(for:)` on macOS and iPad",
|
|
88
|
+
"compose": "`rememberLauncherForActivityResult` with `PickVisualMedia()` for pictures, or `OpenDocument()` for files, started from a `Button`",
|
|
89
|
+
"note": "iPhone and Android have no drop target: the Button is the whole control. Check the type and size when the system hands the file back, and report the reason so the screen can write the error."
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"ods": "emojiPicker",
|
|
93
|
+
"swiftui": "No system picker control: a reaction offers a few presets in a `contextMenu`, and text takes emoji from the system emoji keyboard",
|
|
94
|
+
"compose": "`EmojiPickerView` from `androidx.emoji2:emoji2-emojipicker`, in an `AndroidView` inside a `ModalBottomSheet`",
|
|
95
|
+
"note": "The system keyboard and `EmojiPickerView` bring the full set, skin tones and search, so the built-in 96 are web only."
|
|
96
|
+
},
|
|
61
97
|
{
|
|
62
98
|
"ods": "emptyBox",
|
|
63
99
|
"swiftui": "`ContentUnavailableView`",
|
|
@@ -114,6 +150,12 @@
|
|
|
114
150
|
"swiftui": "`Image` / `AsyncImage`",
|
|
115
151
|
"compose": "`Image` with the app's image loader"
|
|
116
152
|
},
|
|
153
|
+
{
|
|
154
|
+
"ods": "itemList",
|
|
155
|
+
"swiftui": "`List(selection:)` inside a `NavigationSplitView`",
|
|
156
|
+
"compose": "A `LazyColumn` in a list-detail scaffold (`ListDetailPaneScaffold`), with `Modifier.onKeyEvent` for the arrows",
|
|
157
|
+
"note": "The system list moves its selection with the arrow keys and opens the detail; on iPhone and on a phone a row opens the detail."
|
|
158
|
+
},
|
|
117
159
|
{
|
|
118
160
|
"ods": "layout",
|
|
119
161
|
"swiftui": "Not applicable: web page pattern",
|
|
@@ -122,9 +164,9 @@
|
|
|
122
164
|
},
|
|
123
165
|
{
|
|
124
166
|
"ods": "lightbox",
|
|
125
|
-
"swiftui": "`.fullScreenCover` holding a `TabView` with `.tabViewStyle(.page)`, one page per image",
|
|
126
|
-
"compose": "A full-width `Dialog` (`usePlatformDefaultWidth = false`) holding a `HorizontalPager`",
|
|
127
|
-
"note": "
|
|
167
|
+
"swiftui": "`.fullScreenCover` holding a `TabView` with `.tabViewStyle(.page)`, one page per image; a `VideoPlayer` (AVKit) on a video page",
|
|
168
|
+
"compose": "A full-width `Dialog` (`usePlatformDefaultWidth = false`) holding a `HorizontalPager`; a Media3 `PlayerView` with subtitles on a video page",
|
|
169
|
+
"note": "The system pager gives the swipe; keep a Close button and say \"2 of 5\" in the title. A video uses the system player and its captions, never starts by itself, and pauses when its page is left or the viewer closes."
|
|
128
170
|
},
|
|
129
171
|
{
|
|
130
172
|
"ods": "line",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import AvatarStack from "../components/avatarStack";
|
|
3
|
+
declare const meta: Meta<typeof AvatarStack>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof AvatarStack>;
|
|
6
|
+
export declare const Sizes: Story;
|
|
7
|
+
export declare const WithPopover: Story;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
import AvatarStack from "../components/avatarStack";
|
|
3
|
+
import Popover from "../components/popover";
|
|
4
|
+
import List from "../components/list";
|
|
5
|
+
import { Stack } from "../components/layout";
|
|
6
|
+
var meta = {
|
|
7
|
+
title: "Components/AvatarStack",
|
|
8
|
+
component: AvatarStack,
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
var everyone = [
|
|
12
|
+
{ name: "Dana Lee" },
|
|
13
|
+
{ name: "Ben Carter" },
|
|
14
|
+
{ name: "Omar Reyes" },
|
|
15
|
+
{ name: "Mia Park" },
|
|
16
|
+
{ name: "Leo Grant" },
|
|
17
|
+
{ name: "Ana Silva" },
|
|
18
|
+
{ name: "Sam Ortiz" },
|
|
19
|
+
{ name: "Ivy Chen" },
|
|
20
|
+
{ name: "Noah Webb" },
|
|
21
|
+
];
|
|
22
|
+
export var Sizes = {
|
|
23
|
+
render: function () { return (<Stack gap="large" align="start">
|
|
24
|
+
{[24, 32].map(function (size) { return (<Stack key={size} gap="medium" align="start">
|
|
25
|
+
{[1, 3, 4, 9].map(function (n) { return (<AvatarStack key={n} people={everyone.slice(0, n)} size={size}/>); })}
|
|
26
|
+
</Stack>); })}
|
|
27
|
+
</Stack>); },
|
|
28
|
+
};
|
|
29
|
+
function PopoverBox() {
|
|
30
|
+
var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
|
|
31
|
+
var triggerRef = useRef(null);
|
|
32
|
+
return (<div style={{ paddingBottom: "220px" }}>
|
|
33
|
+
<AvatarStack people={everyone.slice(0, 6)} onClick={function (event) {
|
|
34
|
+
triggerRef.current = event.currentTarget;
|
|
35
|
+
setAnchor(anchor ? null : event.currentTarget);
|
|
36
|
+
}}/>
|
|
37
|
+
<Popover open={anchor !== null} anchorEl={anchor} onClose={function () { return setAnchor(null); }} returnFocus>
|
|
38
|
+
<div style={{ padding: "12px 16px" }}>
|
|
39
|
+
<List items={everyone.slice(0, 6).map(function (p) { return p.name; })}/>
|
|
40
|
+
</div>
|
|
41
|
+
</Popover>
|
|
42
|
+
</div>);
|
|
43
|
+
}
|
|
44
|
+
export var WithPopover = {
|
|
45
|
+
render: function () { return <PopoverBox />; },
|
|
46
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Breadcrumb from "../components/breadcrumb";
|
|
3
|
+
declare const meta: Meta<typeof Breadcrumb>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Breadcrumb>;
|
|
6
|
+
export declare const Trail: Story;
|
|
7
|
+
export declare const LongLabels: Story;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Breadcrumb from "../components/breadcrumb";
|
|
2
|
+
var meta = {
|
|
3
|
+
title: "Components/Breadcrumb",
|
|
4
|
+
component: Breadcrumb,
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
export var Trail = {
|
|
8
|
+
args: {
|
|
9
|
+
items: [
|
|
10
|
+
{ label: "Docs", href: "/docs" },
|
|
11
|
+
{ label: "Components", href: "/docs/components" },
|
|
12
|
+
{ label: "Code Block" },
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
// Also shot at 375px: a long last label wraps and the page does not scroll sideways
|
|
17
|
+
export var LongLabels = {
|
|
18
|
+
tags: ["shell"],
|
|
19
|
+
args: {
|
|
20
|
+
items: [
|
|
21
|
+
{ label: "Docs", href: "/docs" },
|
|
22
|
+
{ label: "Components", href: "/docs/components" },
|
|
23
|
+
{ label: "A very long page title that keeps going well past the width of a phone" },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import Calendar from "../components/calendar";
|
|
3
|
+
var meta = {
|
|
4
|
+
title: "Components/Calendar",
|
|
5
|
+
component: Calendar,
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
function InlineBox() {
|
|
9
|
+
var _a = useState("2026-11-16"), value = _a[0], setValue = _a[1];
|
|
10
|
+
return <Calendar id="start" aria-label="Start date" value={value} onChange={setValue} min="2026-11-03" max="2026-11-27"/>;
|
|
11
|
+
}
|
|
12
|
+
// On the page, not in a Popover. Days before Nov 3 and after Nov 27 cannot be picked.
|
|
13
|
+
export var Inline = {
|
|
14
|
+
render: function () { return <InlineBox />; },
|
|
15
|
+
};
|