beez-ui 0.8.2 → 0.9.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/CHANGELOG.md +29 -0
- package/README.md +12 -10
- package/dist/components/account-menu.d.ts +10 -0
- package/dist/components/account-menu.js +139 -118
- package/dist/components/file-upload.d.ts +14 -4
- package/dist/components/file-upload.js +304 -206
- package/dist/components/filter-presets-bar.d.ts +73 -0
- package/dist/components/filter-presets-bar.js +510 -0
- package/dist/components/reaction-button.d.ts +7 -2
- package/dist/components/reaction-button.js +59 -48
- package/dist/hooks.d.ts +10 -0
- package/dist/hooks.js +10 -0
- package/dist/index.d.ts +1 -23
- package/dist/index.js +1 -23
- package/dist/styles.css +1 -1
- package/package.json +11 -126
- package/dist/components/bouncing-dots-loader.d.ts +0 -19
- package/dist/components/bouncing-dots-loader.js +0 -47
- package/dist/components/confirm-delete-button.d.ts +0 -29
- package/dist/components/confirm-delete-button.js +0 -254
- package/dist/components/empty-state.d.ts +0 -24
- package/dist/components/empty-state.js +0 -37
- package/dist/components/error-state.d.ts +0 -20
- package/dist/components/error-state.js +0 -145
- package/dist/components/external-browser-handoff.d.ts +0 -27
- package/dist/components/external-browser-handoff.js +0 -306
- package/dist/components/info-popover.d.ts +0 -23
- package/dist/components/info-popover.js +0 -158
- package/dist/components/month-calendar-header.d.ts +0 -65
- package/dist/components/month-calendar-header.js +0 -337
- package/dist/components/month-grid.d.ts +0 -59
- package/dist/components/month-grid.js +0 -301
- package/dist/components/notification-bell.d.ts +0 -50
- package/dist/components/notification-bell.js +0 -338
- package/dist/components/notification-panel.d.ts +0 -56
- package/dist/components/notification-panel.js +0 -281
- package/dist/components/open-in-browser-cta.d.ts +0 -22
- package/dist/components/open-in-browser-cta.js +0 -61
- package/dist/components/pwa-update-control.d.ts +0 -18
- package/dist/components/pwa-update-control.js +0 -119
- package/dist/emoji-picker.d.ts +0 -27
- package/dist/emoji-picker.js +0 -283
- package/dist/hooks/use-minute-clock.d.ts +0 -23
- package/dist/hooks/use-minute-clock.js +0 -147
- package/dist/hooks/use-month-transition-direction.d.ts +0 -21
- package/dist/hooks/use-month-transition-direction.js +0 -110
- package/dist/lib/browser-navigation.d.ts +0 -21
- package/dist/lib/browser-navigation.js +0 -42
- package/dist/lib/in-app-browser.d.ts +0 -35
- package/dist/lib/in-app-browser.js +0 -80
- package/dist/lib/month-grid.d.ts +0 -42
- package/dist/lib/month-grid.js +0 -74
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/** Detects in-app browsers and builds deep links that reopen a URL in the default browser. */
|
|
2
|
-
/** User-agent fragments of apps that open links in their own embedded browser. */
|
|
3
|
-
const IN_APP_BROWSER_USER_AGENT_TOKENS = [
|
|
4
|
-
"MercadoPago",
|
|
5
|
-
"MercadoLibre",
|
|
6
|
-
"MLWebKit",
|
|
7
|
-
"FBAN",
|
|
8
|
-
"FBAV",
|
|
9
|
-
"Instagram",
|
|
10
|
-
"Line/",
|
|
11
|
-
"MicroMessenger",
|
|
12
|
-
"Twitter"
|
|
13
|
-
];
|
|
14
|
-
const IOS_DEVICE_TOKENS = [
|
|
15
|
-
"iPhone",
|
|
16
|
-
"iPad",
|
|
17
|
-
"iPod"
|
|
18
|
-
];
|
|
19
|
-
const ANDROID_DEVICE_TOKEN = "Android";
|
|
20
|
-
const SAFARI_USER_AGENT_TOKEN = "Safari/";
|
|
21
|
-
const IOS_MOBILE_USER_AGENT_TOKEN = "Mobile/";
|
|
22
|
-
const MERCADO_PAGO_USER_AGENT_TOKENS = [
|
|
23
|
-
"MercadoPago",
|
|
24
|
-
"MercadoLibre",
|
|
25
|
-
"MLWebKit"
|
|
26
|
-
];
|
|
27
|
-
/**
|
|
28
|
-
* Classifies a user agent: in-app browsers (social, messaging and payment apps, iOS web views)
|
|
29
|
-
* often block sign-in popups or lose sessions, so callers can offer to continue elsewhere.
|
|
30
|
-
* Safe on the server: pass the request `User-Agent` header.
|
|
31
|
-
*
|
|
32
|
-
* @param userAgent - User agent string, or nothing when unknown.
|
|
33
|
-
* @returns Whether it is an in-app browser and which platform it runs on.
|
|
34
|
-
*/
|
|
35
|
-
export function detectInAppBrowser(userAgent) {
|
|
36
|
-
if (!userAgent) {
|
|
37
|
-
return {
|
|
38
|
-
isInAppBrowser: false,
|
|
39
|
-
isIos: false,
|
|
40
|
-
isAndroid: false,
|
|
41
|
-
isMercadoPago: false
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const isIos = IOS_DEVICE_TOKENS.some((token) => userAgent.includes(token));
|
|
45
|
-
const isAndroid = userAgent.includes(ANDROID_DEVICE_TOKEN);
|
|
46
|
-
const isMercadoPago = MERCADO_PAGO_USER_AGENT_TOKENS.some((token) => userAgent.includes(token));
|
|
47
|
-
const hasInAppToken = IN_APP_BROWSER_USER_AGENT_TOKENS.some((token) => userAgent.includes(token));
|
|
48
|
-
const isIosWebView = isIos && userAgent.includes(IOS_MOBILE_USER_AGENT_TOKEN) && !userAgent.includes(SAFARI_USER_AGENT_TOKEN);
|
|
49
|
-
return {
|
|
50
|
-
isInAppBrowser: hasInAppToken || isIosWebView,
|
|
51
|
-
isIos,
|
|
52
|
-
isAndroid,
|
|
53
|
-
isMercadoPago
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const HTTPS_PROTOCOL = "https://";
|
|
57
|
-
const SAFARI_URL_SCHEME = "x-safari-https://";
|
|
58
|
-
const CHROME_ANDROID_NAVIGATION_URL_PREFIX = "googlechrome://navigate?url=";
|
|
59
|
-
export const EXTERNAL_BROWSER_PLATFORM = {
|
|
60
|
-
android: "android",
|
|
61
|
-
ios: "ios"
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Builds a deep link that asks the OS to open the given https URL in the
|
|
65
|
-
* user's default external browser instead of the in-app browser.
|
|
66
|
-
*
|
|
67
|
-
* @param input - Target URL and detected platform.
|
|
68
|
-
* @returns A deep-link URL for iOS Safari or Android Chrome. Returns null when
|
|
69
|
-
* the target URL does not use the https scheme.
|
|
70
|
-
*/
|
|
71
|
-
export function buildExternalBrowserUrl({ platform, targetHttpsUrl }) {
|
|
72
|
-
if (!targetHttpsUrl.startsWith(HTTPS_PROTOCOL)) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const urlWithoutScheme = targetHttpsUrl.slice(HTTPS_PROTOCOL.length);
|
|
76
|
-
if (platform === EXTERNAL_BROWSER_PLATFORM.ios) {
|
|
77
|
-
return SAFARI_URL_SCHEME + urlWithoutScheme;
|
|
78
|
-
}
|
|
79
|
-
return CHROME_ANDROID_NAVIGATION_URL_PREFIX + encodeURIComponent(targetHttpsUrl);
|
|
80
|
-
}
|
package/dist/lib/month-grid.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure, time-zone-free helpers for month calendars. Days are `YYYY-MM-DD` keys and months are
|
|
3
|
-
* `YYYY-MM` keys; the application decides which zone turns an instant into a day key.
|
|
4
|
-
*/
|
|
5
|
-
export declare const CALENDAR_WEEK_LENGTH = 7;
|
|
6
|
-
/** First day of the week: 0 is Sunday, 1 is Monday. */
|
|
7
|
-
export type CalendarWeekStart = 0 | 1;
|
|
8
|
-
/** One cell of the month grid. */
|
|
9
|
-
export interface MonthGridDay {
|
|
10
|
-
/** `YYYY-MM-DD` key of the cell. */
|
|
11
|
-
dateKey: string;
|
|
12
|
-
dayNumber: number;
|
|
13
|
-
/** False for padding days of the neighbour months. */
|
|
14
|
-
isCurrentMonth: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Builds the cells of a month grid, padding the first and last week with neighbour-month days.
|
|
18
|
-
* @param month - `YYYY-MM` month key.
|
|
19
|
-
* @param weekStartsOn - First day of the week; Monday by default.
|
|
20
|
-
* @returns Every cell of the grid, a multiple of seven.
|
|
21
|
-
*/
|
|
22
|
-
export declare function createMonthGridDays(month: string, weekStartsOn?: CalendarWeekStart): MonthGridDay[];
|
|
23
|
-
/**
|
|
24
|
-
* Splits grid cells into rows of seven days.
|
|
25
|
-
* @param days - Cells returned by {@link createMonthGridDays}.
|
|
26
|
-
* @returns One array per week.
|
|
27
|
-
*/
|
|
28
|
-
export declare function splitCalendarWeeks<TDay>(days: readonly TDay[]): TDay[][];
|
|
29
|
-
/**
|
|
30
|
-
* Indexes items by their day key, keeping input order within each day.
|
|
31
|
-
* @param items - Items, usually sorted by start.
|
|
32
|
-
* @param getDateKey - Reads the `YYYY-MM-DD` key of an item.
|
|
33
|
-
* @returns Record from day key to the items of that day.
|
|
34
|
-
*/
|
|
35
|
-
export declare function groupItemsByDateKey<TItem>(items: readonly TItem[], getDateKey: (item: TItem) => string): Record<string, TItem[]>;
|
|
36
|
-
/**
|
|
37
|
-
* Moves a month key by a number of months.
|
|
38
|
-
* @param month - `YYYY-MM` month key.
|
|
39
|
-
* @param monthOffset - Months to add; negative values go back.
|
|
40
|
-
* @returns The resulting `YYYY-MM` key.
|
|
41
|
-
*/
|
|
42
|
-
export declare function shiftMonthKey(month: string, monthOffset: number): string;
|
package/dist/lib/month-grid.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure, time-zone-free helpers for month calendars. Days are `YYYY-MM-DD` keys and months are
|
|
3
|
-
* `YYYY-MM` keys; the application decides which zone turns an instant into a day key.
|
|
4
|
-
*/
|
|
5
|
-
export const CALENDAR_WEEK_LENGTH = 7;
|
|
6
|
-
const MILLISECONDS_PER_DAY = 864e5;
|
|
7
|
-
const DATE_KEY_LENGTH = 10;
|
|
8
|
-
const MONTH_KEY_LENGTH = 7;
|
|
9
|
-
const MONTH_KEY_PATTERN = /^(\d{4})-(0[1-9]|1[0-2])$/;
|
|
10
|
-
/**
|
|
11
|
-
* Parses a `YYYY-MM` key.
|
|
12
|
-
* @param month - Month key.
|
|
13
|
-
* @returns The year and zero-based month index.
|
|
14
|
-
* @throws {RangeError} When the key is not a valid `YYYY-MM` month.
|
|
15
|
-
*/
|
|
16
|
-
function parseMonthKey(month) {
|
|
17
|
-
const match = MONTH_KEY_PATTERN.exec(month);
|
|
18
|
-
if (!match) throw new RangeError(`month-grid:parseMonthKey expected a YYYY-MM month, received "${month.slice(0, 20)}"`);
|
|
19
|
-
return {
|
|
20
|
-
year: Number(match[1]),
|
|
21
|
-
monthIndex: Number(match[2]) - 1
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Builds the cells of a month grid, padding the first and last week with neighbour-month days.
|
|
26
|
-
* @param month - `YYYY-MM` month key.
|
|
27
|
-
* @param weekStartsOn - First day of the week; Monday by default.
|
|
28
|
-
* @returns Every cell of the grid, a multiple of seven.
|
|
29
|
-
*/
|
|
30
|
-
export function createMonthGridDays(month, weekStartsOn = 1) {
|
|
31
|
-
const { year, monthIndex } = parseMonthKey(month);
|
|
32
|
-
const monthStartTime = Date.UTC(year, monthIndex, 1);
|
|
33
|
-
const daysInMonth = new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();
|
|
34
|
-
const leadingDays = (new Date(monthStartTime).getUTCDay() + CALENDAR_WEEK_LENGTH - weekStartsOn) % CALENDAR_WEEK_LENGTH;
|
|
35
|
-
const totalCells = Math.ceil((leadingDays + daysInMonth) / CALENDAR_WEEK_LENGTH) * CALENDAR_WEEK_LENGTH;
|
|
36
|
-
const firstCellTime = monthStartTime - leadingDays * MILLISECONDS_PER_DAY;
|
|
37
|
-
return Array.from({ length: totalCells }, (_, dayIndex) => {
|
|
38
|
-
const date = new Date(firstCellTime + dayIndex * MILLISECONDS_PER_DAY);
|
|
39
|
-
return {
|
|
40
|
-
dateKey: date.toISOString().slice(0, DATE_KEY_LENGTH),
|
|
41
|
-
dayNumber: date.getUTCDate(),
|
|
42
|
-
isCurrentMonth: date.getUTCMonth() === monthIndex
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Splits grid cells into rows of seven days.
|
|
48
|
-
* @param days - Cells returned by {@link createMonthGridDays}.
|
|
49
|
-
* @returns One array per week.
|
|
50
|
-
*/
|
|
51
|
-
export function splitCalendarWeeks(days) {
|
|
52
|
-
return Array.from({ length: Math.ceil(days.length / CALENDAR_WEEK_LENGTH) }, (_, weekIndex) => days.slice(weekIndex * CALENDAR_WEEK_LENGTH, (weekIndex + 1) * CALENDAR_WEEK_LENGTH));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Indexes items by their day key, keeping input order within each day.
|
|
56
|
-
* @param items - Items, usually sorted by start.
|
|
57
|
-
* @param getDateKey - Reads the `YYYY-MM-DD` key of an item.
|
|
58
|
-
* @returns Record from day key to the items of that day.
|
|
59
|
-
*/
|
|
60
|
-
export function groupItemsByDateKey(items, getDateKey) {
|
|
61
|
-
const groupedItems = {};
|
|
62
|
-
for (const item of items) (groupedItems[getDateKey(item)] ??= []).push(item);
|
|
63
|
-
return groupedItems;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Moves a month key by a number of months.
|
|
67
|
-
* @param month - `YYYY-MM` month key.
|
|
68
|
-
* @param monthOffset - Months to add; negative values go back.
|
|
69
|
-
* @returns The resulting `YYYY-MM` key.
|
|
70
|
-
*/
|
|
71
|
-
export function shiftMonthKey(month, monthOffset) {
|
|
72
|
-
const { year, monthIndex } = parseMonthKey(month);
|
|
73
|
-
return new Date(Date.UTC(year, monthIndex + monthOffset, 1)).toISOString().slice(0, MONTH_KEY_LENGTH);
|
|
74
|
-
}
|