oneslash-design-system 2.21.0 โ†’ 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +12 -1
  3. package/dist/cases/admin-inbox/split.jsx +22 -10
  4. package/dist/cases/admin-inbox.md +28 -23
  5. package/dist/cases/api-keys.md +1 -1
  6. package/dist/cases/app-shell/top-tabs.jsx +10 -4
  7. package/dist/cases/app-shell.md +13 -5
  8. package/dist/cases/breadcrumb/back-link.d.ts +1 -0
  9. package/dist/cases/breadcrumb/back-link.jsx +23 -0
  10. package/dist/cases/breadcrumb/trail.d.ts +1 -0
  11. package/dist/cases/breadcrumb/trail.jsx +28 -0
  12. package/dist/cases/breadcrumb.md +105 -0
  13. package/dist/cases/date-field/calendar.d.ts +1 -0
  14. package/dist/cases/date-field/calendar.jsx +80 -0
  15. package/dist/cases/date-field/typed.d.ts +1 -0
  16. package/dist/cases/date-field/typed.jsx +58 -0
  17. package/dist/cases/date-field.md +232 -0
  18. package/dist/cases/docs-component-page/reference.jsx +11 -1
  19. package/dist/cases/docs-component-page.md +19 -8
  20. package/dist/cases/file-upload/files.d.ts +1 -0
  21. package/dist/cases/file-upload/files.jsx +118 -0
  22. package/dist/cases/file-upload/picture.d.ts +1 -0
  23. package/dist/cases/file-upload/picture.jsx +50 -0
  24. package/dist/cases/file-upload.md +270 -0
  25. package/dist/cases/filter-menu.md +1 -1
  26. package/dist/cases/image-viewer/with-video.d.ts +1 -0
  27. package/dist/cases/image-viewer/with-video.jsx +42 -0
  28. package/dist/cases/image-viewer.md +72 -4
  29. package/dist/cases/master-detail/split.jsx +17 -10
  30. package/dist/cases/master-detail.md +26 -24
  31. package/dist/cases/message-reactions/picker.d.ts +1 -0
  32. package/dist/cases/message-reactions/picker.jsx +145 -0
  33. package/dist/cases/message-reactions/quick-pick.jsx +1 -1
  34. package/dist/cases/message-reactions.md +184 -3
  35. package/dist/cases/page-header.md +1 -1
  36. package/dist/cases/people-row/names.d.ts +1 -0
  37. package/dist/cases/people-row/names.jsx +20 -0
  38. package/dist/cases/people-row/stack.d.ts +1 -0
  39. package/dist/cases/people-row/stack.jsx +33 -0
  40. package/dist/cases/people-row.md +110 -0
  41. package/dist/cases/pricing-section/cards.jsx +3 -2
  42. package/dist/cases/pricing-section.md +4 -2
  43. package/dist/cases/profile-form/form.jsx +21 -10
  44. package/dist/cases/profile-form.md +38 -9
  45. package/dist/cases/settings-page/top-tabs.jsx +9 -6
  46. package/dist/cases/settings-page.md +13 -7
  47. package/dist/cases.json +312 -29
  48. package/dist/components/avatarStack.d.ts +22 -0
  49. package/dist/components/avatarStack.jsx +32 -0
  50. package/dist/components/breadcrumb.d.ts +12 -0
  51. package/dist/components/breadcrumb.jsx +24 -0
  52. package/dist/components/button.d.ts +2 -0
  53. package/dist/components/button.jsx +2 -2
  54. package/dist/components/calendar.d.ts +19 -0
  55. package/dist/components/calendar.jsx +126 -0
  56. package/dist/components/dateField.d.ts +35 -0
  57. package/dist/components/dateField.jsx +76 -0
  58. package/dist/components/dropZone.d.ts +53 -0
  59. package/dist/components/dropZone.jsx +136 -0
  60. package/dist/components/emojiPicker.d.ts +22 -0
  61. package/dist/components/emojiPicker.jsx +161 -0
  62. package/dist/components/itemList.d.ts +31 -0
  63. package/dist/components/itemList.jsx +81 -0
  64. package/dist/components/lightbox.d.ts +35 -8
  65. package/dist/components/lightbox.jsx +99 -23
  66. package/dist/components/menuItem.d.ts +1 -1
  67. package/dist/components/menuItem.jsx +4 -4
  68. package/dist/components/siteHeader.d.ts +13 -2
  69. package/dist/components/siteHeader.jsx +21 -12
  70. package/dist/components/tag.d.ts +6 -1
  71. package/dist/components/tag.jsx +10 -5
  72. package/dist/internal/date.d.ts +35 -0
  73. package/dist/internal/date.js +122 -0
  74. package/dist/internal/dropZone.d.ts +28 -0
  75. package/dist/internal/dropZone.js +42 -0
  76. package/dist/internal/emoji.d.ts +13 -0
  77. package/dist/internal/emoji.js +182 -0
  78. package/dist/internal/overlayStack.js +1 -1
  79. package/dist/internal/people.d.ts +1 -0
  80. package/dist/internal/people.js +12 -0
  81. package/dist/native-mapping.json +45 -3
  82. package/dist/stories/AvatarStack.stories.d.ts +7 -0
  83. package/dist/stories/AvatarStack.stories.jsx +46 -0
  84. package/dist/stories/Breadcrumb.stories.d.ts +7 -0
  85. package/dist/stories/Breadcrumb.stories.jsx +26 -0
  86. package/dist/stories/Button.stories.jsx +12 -8
  87. package/dist/stories/Calendar.stories.d.ts +6 -0
  88. package/dist/stories/Calendar.stories.jsx +15 -0
  89. package/dist/stories/Cases.generated.stories.d.ts +10 -0
  90. package/dist/stories/Cases.generated.stories.jsx +20 -0
  91. package/dist/stories/DateField.stories.d.ts +10 -0
  92. package/dist/stories/DateField.stories.jsx +132 -0
  93. package/dist/stories/DropZone.stories.d.ts +12 -0
  94. package/dist/stories/DropZone.stories.jsx +151 -0
  95. package/dist/stories/EmojiPicker.stories.d.ts +6 -0
  96. package/dist/stories/EmojiPicker.stories.jsx +92 -0
  97. package/dist/stories/ItemList.stories.d.ts +9 -0
  98. package/dist/stories/ItemList.stories.jsx +86 -0
  99. package/dist/stories/Lightbox.stories.d.ts +7 -0
  100. package/dist/stories/Lightbox.stories.jsx +88 -1
  101. package/dist/stories/MenuItem.stories.d.ts +1 -0
  102. package/dist/stories/MenuItem.stories.jsx +8 -0
  103. package/dist/stories/SiteHeader.stories.d.ts +4 -0
  104. package/dist/stories/SiteHeader.stories.jsx +89 -0
  105. package/package.json +3 -2
@@ -10,16 +10,18 @@ var WIDE = '(min-width: 768px)';
10
10
  /**
11
11
  * A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
12
12
  * links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
13
- * With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer.
13
+ * With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer, unless `sectionLinks` gives the menu
14
+ * the open section's pages.
14
15
  * While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
15
16
  * `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
16
17
  * Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
17
18
  */
18
19
  export default function SiteHeader(_a) {
19
- var brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.skipLabel, skipLabel = _c === void 0 ? 'Skip to content' : _c, _d = _a.mainId, mainId = _d === void 0 ? 'main' : _d;
20
+ var brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, sectionLinks = _a.sectionLinks, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.skipLabel, skipLabel = _c === void 0 ? 'Skip to content' : _c, _d = _a.mainId, mainId = _d === void 0 ? 'main' : _d;
20
21
  var drawerId = useId();
21
- // Without links or actions there is nothing for a Menu to hold
22
- var hasMenu = links.length > 0 || !!actions;
22
+ var sectionTitleId = useId();
23
+ // Without links, actions or section links there is nothing for a Menu to hold
24
+ var hasMenu = links.length > 0 || !!actions || !!(sectionLinks === null || sectionLinks === void 0 ? void 0 : sectionLinks.links.length);
23
25
  var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
24
26
  var barRef = useRef(null);
25
27
  // Set when widening closes the Drawer while focus was in it: the Menu IconButton it would go back to is hidden from md up
@@ -85,14 +87,15 @@ export default function SiteHeader(_a) {
85
87
  if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
86
88
  setMenuOpen(false);
87
89
  };
90
+ var list = function (items, vertical) { return (<ul className={"m-0 flex list-none p-0 ".concat(vertical ? 'flex-col gap-0.5' : 'flex-wrap items-center gap-x-1 gap-y-0.5')}>
91
+ {items.map(function (link) { return (<li key={link.href + link.label}>
92
+ <a href={link.href} aria-current={link.current ? 'page' : undefined} className={"block whitespace-nowrap rounded-control no-underline hover:bg-background-accent200 ".concat(vertical ? 'px-3 py-2.5 text-body1' : 'px-2 py-1.5 text-body2', " ").concat(link.current ? 'bg-background-accent100 text-fg-primary' : 'text-fg-secondary hover:text-fg-primary', " ").concat(focusRing)}>
93
+ {link.label}
94
+ </a>
95
+ </li>); })}
96
+ </ul>); };
88
97
  var linkList = function (vertical) { return (<nav aria-label="Main" className={vertical ? '' : 'hidden min-w-0 flex-1 md:block'}>
89
- <ul className={"m-0 flex list-none p-0 ".concat(vertical ? 'flex-col gap-0.5' : 'flex-wrap items-center gap-x-1 gap-y-0.5')}>
90
- {links.map(function (link) { return (<li key={link.href + link.label}>
91
- <a href={link.href} aria-current={link.current ? 'page' : undefined} className={"block whitespace-nowrap rounded-control no-underline hover:bg-background-accent200 ".concat(vertical ? 'px-3 py-2.5 text-body1' : 'px-2 py-1.5 text-body2', " ").concat(link.current ? 'bg-background-accent100 text-fg-primary' : 'text-fg-secondary hover:text-fg-primary', " ").concat(focusRing)}>
92
- {link.label}
93
- </a>
94
- </li>); })}
95
- </ul>
98
+ {list(links, vertical)}
96
99
  </nav>); };
97
100
  // The Drawer is a sibling of the header: a sticky header is a stacking context, and the panel must sit above the page
98
101
  return (<>
@@ -116,7 +119,13 @@ export default function SiteHeader(_a) {
116
119
  </header>
117
120
  {hasMenu && (<Drawer id={drawerId} isOpen={menuOpen} onClose={function () { return setMenuOpen(false); }} aria-label={menuLabel} side="start" size="small">
118
121
  <div onClick={closeOnChoice} className="flex flex-col gap-4">
119
- {linkList(true)}
122
+ {(links.length > 0 || !(sectionLinks === null || sectionLinks === void 0 ? void 0 : sectionLinks.links.length)) && linkList(true)}
123
+ {sectionLinks && sectionLinks.links.length > 0 && (<nav aria-labelledby={sectionTitleId}>
124
+ <h2 id={sectionTitleId} className="px-3 pb-1 text-caption text-fg-secondary">
125
+ {sectionLinks.title}
126
+ </h2>
127
+ {list(sectionLinks.links, true)}
128
+ </nav>)}
120
129
  {actions && <div className="flex flex-col items-start gap-2">{actions}</div>}
121
130
  </div>
122
131
  </Drawer>)}
@@ -23,6 +23,11 @@ interface TagProps {
23
23
  * `state="selected"` still gives the selected look then, but it is only a look. No effect without `onClick`.
24
24
  */
25
25
  toggle?: boolean;
26
+ /**
27
+ * Set by a row with the selected fill (`bg-primary-dark`), such as a selected `MenuItem`. A `dot` or `textOnly`
28
+ * tag then uses `primary-contrast` for its text, dot and border. A `contained` tag keeps its own fill.
29
+ */
30
+ onSelectedRow?: boolean;
26
31
  }
27
- export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, }: TagProps): React.JSX.Element;
32
+ export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, onSelectedRow, }: TagProps): React.JSX.Element;
28
33
  export {};
@@ -48,7 +48,7 @@ var colorConfig = {
48
48
  },
49
49
  };
50
50
  export default function Tag(_a) {
51
- var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d;
51
+ var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d, _e = _a.onSelectedRow, onSelectedRow = _e === void 0 ? false : _e;
52
52
  // Size and padding
53
53
  var sizeClasses = {
54
54
  medium: 'text-body2 px-2 py-1',
@@ -73,9 +73,14 @@ export default function Tag(_a) {
73
73
  else if (variant === 'contained') {
74
74
  bgClasses = 'bg-background-accent300';
75
75
  }
76
+ // On a selected row's fill only primary-contrast is readable; a contained tag keeps its own fill
77
+ var onRowFill = onSelectedRow && variant !== 'contained';
76
78
  // Font color
77
79
  var fontClasses = '';
78
- if (variant === 'dot') {
80
+ if (onRowFill) {
81
+ fontClasses = 'text-primary-contrast';
82
+ }
83
+ else if (variant === 'dot') {
79
84
  fontClasses = 'text-fg-primary';
80
85
  }
81
86
  else if (colorStyles) {
@@ -99,20 +104,20 @@ export default function Tag(_a) {
99
104
  }
100
105
  else if (colorStyles) {
101
106
  if (variant === 'textOnly' && colorStyles.hasBorderTextOnly) {
102
- borderClasses = "border ".concat(colorStyles.border);
107
+ borderClasses = onRowFill ? 'border border-primary-contrast' : "border ".concat(colorStyles.border);
103
108
  }
104
109
  else if (variant === 'contained') {
105
110
  borderClasses = "border ".concat(colorStyles.border);
106
111
  }
107
112
  }
108
113
  else if (isSelected && variant === 'textOnly') {
109
- borderClasses = 'border border-accent-main';
114
+ borderClasses = onRowFill ? 'border border-primary-contrast' : 'border border-accent-main';
110
115
  }
111
116
  else if (variant === 'contained') {
112
117
  borderClasses = 'border border-misc-divider';
113
118
  }
114
119
  // Dot color
115
- var dotColor = (colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.dot) || colorConfig.default.dot;
120
+ var dotColor = onRowFill ? 'bg-primary-contrast' : (colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.dot) || colorConfig.default.dot;
116
121
  var isDisabled = !!onClick && disabled;
117
122
  // Hover (only when not selected, not disabled, no color, and onClick is provided)
118
123
  var hoverClasses = !isSelected && !isDisabled && !color && variant === 'contained' && onClick
@@ -0,0 +1,35 @@
1
+ export declare const MONTH_NAMES: string[];
2
+ /** Days in a month, `month` 1 to 12 */
3
+ export declare function daysInMonth(year: number, month: number): number;
4
+ /** '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 */
5
+ export declare function parseTyped(text: string): string | null;
6
+ /** Whether the text is M/D/Y with a year of one to three digits, such as '11/16/26' */
7
+ export declare function shortYear(text: string): boolean;
8
+ /**
9
+ * Reads what was typed into a date field. Empty text is `{ value: '', error: null }`; text that is not a real date,
10
+ * 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.
11
+ */
12
+ export declare function readTyped(text: string, min?: string, max?: string): {
13
+ value: string;
14
+ text: string;
15
+ error: string | null;
16
+ };
17
+ /** '2026-11-16' to '11/16/2026' */
18
+ export declare function toTyped(value: string): string;
19
+ /** '2026-11-16' to 'Nov 16, 2026' */
20
+ export declare function formatLong(value: string): string;
21
+ /** '2026-11-16' to 'November 2026' */
22
+ export declare function monthLabel(value: string): string;
23
+ export declare function addDays(value: string, n: number): string;
24
+ /** Moves by whole months and keeps the day, clamped to the last day of a shorter month (Jan 31 + 1 is Feb 28) */
25
+ export declare function addMonths(value: string, n: number): string;
26
+ /** ISO day strings sort as text */
27
+ export declare function compare(a: string, b: string): -1 | 0 | 1;
28
+ /** The user's own date, from the local clock */
29
+ export declare function todayIso(): string;
30
+ /** 0 for Sunday to 6 for Saturday */
31
+ export declare function weekday(value: string): number;
32
+ /** The month of `value` as weeks from Sunday to Saturday; `null` for the cells outside the month */
33
+ export declare function monthGrid(value: string): (string | null)[][];
34
+ /** Whether `value` is within `min` and `max` (either may be missing) */
35
+ export declare function inRange(value: string, min?: string, max?: string): boolean;
@@ -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
+ }