@liveblocks/react-ui 2.0.0-alpha1 → 2.0.0-alpha2
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/components/Composer.js +2 -0
- package/dist/components/Composer.js.map +1 -1
- package/dist/components/Composer.mjs +2 -0
- package/dist/components/Composer.mjs.map +1 -1
- package/dist/components/InboxNotification.js +42 -0
- package/dist/components/InboxNotification.js.map +1 -1
- package/dist/components/InboxNotification.mjs +42 -0
- package/dist/components/InboxNotification.mjs.map +1 -1
- package/dist/index.d.mts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/overrides.js +2 -1
- package/dist/overrides.js.map +1 -1
- package/dist/overrides.mjs +2 -1
- package/dist/overrides.mjs.map +1 -1
- package/dist/shared.js +2 -2
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +2 -2
- package/dist/shared.mjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +7 -6
- package/src/styles/index.css +6 -0
- package/styles.css +1 -1
- package/styles.css.map +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommentData, CommentBody, BaseMetadata, InboxNotificationData, InboxNotificationThreadData, InboxNotificationCustomData, ThreadData } from '@liveblocks/core';
|
|
1
|
+
import { CommentData, CommentBody, BaseMetadata, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, DAD, ThreadData } from '@liveblocks/core';
|
|
2
2
|
import React, { ReactNode, ComponentPropsWithoutRef, MouseEvent, ComponentType, FormEvent, RefAttributes, ComponentProps, PropsWithChildren } from 'react';
|
|
3
3
|
|
|
4
4
|
declare type Direction = "ltr" | "rtl";
|
|
@@ -58,8 +58,10 @@ interface InboxNotificationOverrides {
|
|
|
58
58
|
INBOX_NOTIFICATION_MARK_AS_READ: string;
|
|
59
59
|
INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (list: ReactNode, room: ReactNode | undefined, count: number) => ReactNode;
|
|
60
60
|
INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode | undefined) => ReactNode;
|
|
61
|
+
INBOX_NOTIFICATION_TEXT_MENTION: (user: ReactNode, room: ReactNode | undefined) => ReactNode;
|
|
61
62
|
}
|
|
62
63
|
declare type Overrides = LocalizationOverrides & GlobalOverrides & ComposerOverrides & CommentOverrides & ThreadOverrides & InboxNotificationOverrides;
|
|
64
|
+
declare function useOverrides(overrides?: Partial<Overrides>): Overrides;
|
|
63
65
|
|
|
64
66
|
interface CommentProps extends ComponentPropsWithoutRef<"div"> {
|
|
65
67
|
/**
|
|
@@ -278,8 +280,11 @@ interface AvatarProps extends ComponentProps<"div"> {
|
|
|
278
280
|
}
|
|
279
281
|
|
|
280
282
|
declare type ComponentTypeWithRef<T extends keyof JSX.IntrinsicElements, P> = ComponentType<P & Pick<ComponentProps<T>, "ref">>;
|
|
281
|
-
declare type InboxNotificationKinds =
|
|
283
|
+
declare type InboxNotificationKinds = {
|
|
284
|
+
[K in keyof DAD]: ComponentTypeWithRef<"a", InboxNotificationCustomKindProps<K>>;
|
|
285
|
+
} & {
|
|
282
286
|
thread: ComponentTypeWithRef<"a", InboxNotificationThreadKindProps>;
|
|
287
|
+
textMention: ComponentTypeWithRef<"a", InboxNotificationTextMentionProps>;
|
|
283
288
|
};
|
|
284
289
|
interface InboxNotificationSharedProps {
|
|
285
290
|
/**
|
|
@@ -315,6 +320,16 @@ interface InboxNotificationThreadProps extends Omit<InboxNotificationProps, "kin
|
|
|
315
320
|
*/
|
|
316
321
|
showRoomName?: boolean;
|
|
317
322
|
}
|
|
323
|
+
interface InboxNotificationTextMentionProps extends Omit<InboxNotificationProps, "kinds">, InboxNotificationSharedProps {
|
|
324
|
+
/**
|
|
325
|
+
* The inbox notification to display.
|
|
326
|
+
*/
|
|
327
|
+
inboxNotification: InboxNotificationTextMentionData;
|
|
328
|
+
/**
|
|
329
|
+
* Whether to show the room name in the title.
|
|
330
|
+
*/
|
|
331
|
+
showRoomName?: boolean;
|
|
332
|
+
}
|
|
318
333
|
interface InboxNotificationCustomProps extends Omit<InboxNotificationProps, "kinds">, InboxNotificationSharedProps, SlotProp {
|
|
319
334
|
/**
|
|
320
335
|
* The inbox notification to display.
|
|
@@ -341,8 +356,11 @@ interface InboxNotificationCustomProps extends Omit<InboxNotificationProps, "kin
|
|
|
341
356
|
declare type InboxNotificationThreadKindProps = Omit<InboxNotificationProps, "kinds"> & {
|
|
342
357
|
inboxNotification: InboxNotificationThreadData;
|
|
343
358
|
};
|
|
344
|
-
declare type
|
|
345
|
-
inboxNotification:
|
|
359
|
+
declare type InboxNotificationTextMentionKindProps = Omit<InboxNotificationProps, "kinds"> & {
|
|
360
|
+
inboxNotification: InboxNotificationTextMentionData;
|
|
361
|
+
};
|
|
362
|
+
declare type InboxNotificationCustomKindProps<K extends `$${string}` = `$${string}`> = Omit<InboxNotificationProps, "kinds"> & {
|
|
363
|
+
inboxNotification: InboxNotificationCustomData<K>;
|
|
346
364
|
};
|
|
347
365
|
declare type InboxNotificationIconProps = ComponentProps<"div">;
|
|
348
366
|
declare type InboxNotificationAvatarProps = AvatarProps;
|
|
@@ -366,6 +384,7 @@ declare function InboxNotificationAvatar({ className, ...props }: InboxNotificat
|
|
|
366
384
|
*/
|
|
367
385
|
declare const InboxNotification: React.ForwardRefExoticComponent<InboxNotificationProps & React.RefAttributes<HTMLAnchorElement>> & {
|
|
368
386
|
Thread: React.ForwardRefExoticComponent<InboxNotificationThreadProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
387
|
+
TextMention: React.ForwardRefExoticComponent<InboxNotificationTextMentionProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
369
388
|
Custom: React.ForwardRefExoticComponent<InboxNotificationCustomProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
370
389
|
Icon: typeof InboxNotificationIcon;
|
|
371
390
|
Avatar: typeof InboxNotificationAvatar;
|
|
@@ -490,4 +509,4 @@ declare function LiveblocksUIConfig({ overrides, components, portalContainer, ch
|
|
|
490
509
|
*/
|
|
491
510
|
declare function useMentionSuggestions(search?: string): string[] | undefined;
|
|
492
511
|
|
|
493
|
-
export { Comment, CommentProps, Composer, ComposerProps, ComposerSubmitComment, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, Thread, ThreadProps, useMentionSuggestions };
|
|
512
|
+
export { Comment, CommentProps, Composer, ComposerProps, ComposerSubmitComment, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, Thread, ThreadProps, useMentionSuggestions, useOverrides };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommentData, CommentBody, BaseMetadata, InboxNotificationData, InboxNotificationThreadData, InboxNotificationCustomData, ThreadData } from '@liveblocks/core';
|
|
1
|
+
import { CommentData, CommentBody, BaseMetadata, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, DAD, ThreadData } from '@liveblocks/core';
|
|
2
2
|
import React, { ReactNode, ComponentPropsWithoutRef, MouseEvent, ComponentType, FormEvent, RefAttributes, ComponentProps, PropsWithChildren } from 'react';
|
|
3
3
|
|
|
4
4
|
declare type Direction = "ltr" | "rtl";
|
|
@@ -58,8 +58,10 @@ interface InboxNotificationOverrides {
|
|
|
58
58
|
INBOX_NOTIFICATION_MARK_AS_READ: string;
|
|
59
59
|
INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (list: ReactNode, room: ReactNode | undefined, count: number) => ReactNode;
|
|
60
60
|
INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode | undefined) => ReactNode;
|
|
61
|
+
INBOX_NOTIFICATION_TEXT_MENTION: (user: ReactNode, room: ReactNode | undefined) => ReactNode;
|
|
61
62
|
}
|
|
62
63
|
declare type Overrides = LocalizationOverrides & GlobalOverrides & ComposerOverrides & CommentOverrides & ThreadOverrides & InboxNotificationOverrides;
|
|
64
|
+
declare function useOverrides(overrides?: Partial<Overrides>): Overrides;
|
|
63
65
|
|
|
64
66
|
interface CommentProps extends ComponentPropsWithoutRef<"div"> {
|
|
65
67
|
/**
|
|
@@ -278,8 +280,11 @@ interface AvatarProps extends ComponentProps<"div"> {
|
|
|
278
280
|
}
|
|
279
281
|
|
|
280
282
|
declare type ComponentTypeWithRef<T extends keyof JSX.IntrinsicElements, P> = ComponentType<P & Pick<ComponentProps<T>, "ref">>;
|
|
281
|
-
declare type InboxNotificationKinds =
|
|
283
|
+
declare type InboxNotificationKinds = {
|
|
284
|
+
[K in keyof DAD]: ComponentTypeWithRef<"a", InboxNotificationCustomKindProps<K>>;
|
|
285
|
+
} & {
|
|
282
286
|
thread: ComponentTypeWithRef<"a", InboxNotificationThreadKindProps>;
|
|
287
|
+
textMention: ComponentTypeWithRef<"a", InboxNotificationTextMentionProps>;
|
|
283
288
|
};
|
|
284
289
|
interface InboxNotificationSharedProps {
|
|
285
290
|
/**
|
|
@@ -315,6 +320,16 @@ interface InboxNotificationThreadProps extends Omit<InboxNotificationProps, "kin
|
|
|
315
320
|
*/
|
|
316
321
|
showRoomName?: boolean;
|
|
317
322
|
}
|
|
323
|
+
interface InboxNotificationTextMentionProps extends Omit<InboxNotificationProps, "kinds">, InboxNotificationSharedProps {
|
|
324
|
+
/**
|
|
325
|
+
* The inbox notification to display.
|
|
326
|
+
*/
|
|
327
|
+
inboxNotification: InboxNotificationTextMentionData;
|
|
328
|
+
/**
|
|
329
|
+
* Whether to show the room name in the title.
|
|
330
|
+
*/
|
|
331
|
+
showRoomName?: boolean;
|
|
332
|
+
}
|
|
318
333
|
interface InboxNotificationCustomProps extends Omit<InboxNotificationProps, "kinds">, InboxNotificationSharedProps, SlotProp {
|
|
319
334
|
/**
|
|
320
335
|
* The inbox notification to display.
|
|
@@ -341,8 +356,11 @@ interface InboxNotificationCustomProps extends Omit<InboxNotificationProps, "kin
|
|
|
341
356
|
declare type InboxNotificationThreadKindProps = Omit<InboxNotificationProps, "kinds"> & {
|
|
342
357
|
inboxNotification: InboxNotificationThreadData;
|
|
343
358
|
};
|
|
344
|
-
declare type
|
|
345
|
-
inboxNotification:
|
|
359
|
+
declare type InboxNotificationTextMentionKindProps = Omit<InboxNotificationProps, "kinds"> & {
|
|
360
|
+
inboxNotification: InboxNotificationTextMentionData;
|
|
361
|
+
};
|
|
362
|
+
declare type InboxNotificationCustomKindProps<K extends `$${string}` = `$${string}`> = Omit<InboxNotificationProps, "kinds"> & {
|
|
363
|
+
inboxNotification: InboxNotificationCustomData<K>;
|
|
346
364
|
};
|
|
347
365
|
declare type InboxNotificationIconProps = ComponentProps<"div">;
|
|
348
366
|
declare type InboxNotificationAvatarProps = AvatarProps;
|
|
@@ -366,6 +384,7 @@ declare function InboxNotificationAvatar({ className, ...props }: InboxNotificat
|
|
|
366
384
|
*/
|
|
367
385
|
declare const InboxNotification: React.ForwardRefExoticComponent<InboxNotificationProps & React.RefAttributes<HTMLAnchorElement>> & {
|
|
368
386
|
Thread: React.ForwardRefExoticComponent<InboxNotificationThreadProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
387
|
+
TextMention: React.ForwardRefExoticComponent<InboxNotificationTextMentionProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
369
388
|
Custom: React.ForwardRefExoticComponent<InboxNotificationCustomProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
370
389
|
Icon: typeof InboxNotificationIcon;
|
|
371
390
|
Avatar: typeof InboxNotificationAvatar;
|
|
@@ -490,4 +509,4 @@ declare function LiveblocksUIConfig({ overrides, components, portalContainer, ch
|
|
|
490
509
|
*/
|
|
491
510
|
declare function useMentionSuggestions(search?: string): string[] | undefined;
|
|
492
511
|
|
|
493
|
-
export { Comment, CommentProps, Composer, ComposerProps, ComposerSubmitComment, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, Thread, ThreadProps, useMentionSuggestions };
|
|
512
|
+
export { Comment, CommentProps, Composer, ComposerProps, ComposerSubmitComment, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, Thread, ThreadProps, useMentionSuggestions, useOverrides };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var InboxNotification = require('./components/InboxNotification.js');
|
|
|
8
8
|
var InboxNotificationList = require('./components/InboxNotificationList.js');
|
|
9
9
|
var Thread = require('./components/Thread.js');
|
|
10
10
|
var config = require('./config.js');
|
|
11
|
+
var overrides = require('./overrides.js');
|
|
11
12
|
var shared = require('./shared.js');
|
|
12
13
|
|
|
13
14
|
core.detectDupes(version.PKG_NAME, version.PKG_VERSION, version.PKG_FORMAT);
|
|
@@ -18,5 +19,6 @@ exports.InboxNotification = InboxNotification.InboxNotification;
|
|
|
18
19
|
exports.InboxNotificationList = InboxNotificationList.InboxNotificationList;
|
|
19
20
|
exports.Thread = Thread.Thread;
|
|
20
21
|
exports.LiveblocksUIConfig = config.LiveblocksUIConfig;
|
|
22
|
+
exports.useOverrides = overrides.useOverrides;
|
|
21
23
|
exports.useMentionSuggestions = shared.useMentionSuggestions;
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport { useMentionSuggestions } from \"./shared\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationTextMentionKindProps,\n InboxNotificationTextMentionProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport { useOverrides } from \"./overrides\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport { useMentionSuggestions } from \"./shared\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export { InboxNotification } from './components/InboxNotification.mjs';
|
|
|
6
6
|
export { InboxNotificationList } from './components/InboxNotificationList.mjs';
|
|
7
7
|
export { Thread } from './components/Thread.mjs';
|
|
8
8
|
export { LiveblocksUIConfig } from './config.mjs';
|
|
9
|
+
export { useOverrides } from './overrides.mjs';
|
|
9
10
|
export { useMentionSuggestions } from './shared.mjs';
|
|
10
11
|
|
|
11
12
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport { useMentionSuggestions } from \"./shared\";\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationTextMentionKindProps,\n InboxNotificationTextMentionProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport { useOverrides } from \"./overrides\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport { useMentionSuggestions } from \"./shared\";\n"],"names":[],"mappings":";;;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
|
package/dist/overrides.js
CHANGED
|
@@ -61,7 +61,8 @@ const defaultOverrides = {
|
|
|
61
61
|
INBOX_NOTIFICATION_MORE: "More",
|
|
62
62
|
INBOX_NOTIFICATION_MARK_AS_READ: "Mark as read",
|
|
63
63
|
INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (list, room) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, list, " commented", room ? /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " in ", room) : /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " in a thread")),
|
|
64
|
-
INBOX_NOTIFICATION_THREAD_MENTION: (user, room) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, user, " mentioned you", room ? /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " in ", room) : null)
|
|
64
|
+
INBOX_NOTIFICATION_THREAD_MENTION: (user, room) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, user, " mentioned you", room ? /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " in ", room) : null),
|
|
65
|
+
INBOX_NOTIFICATION_TEXT_MENTION: (user, room) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, user, " mentioned you", room ? /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " in ", room) : null)
|
|
65
66
|
};
|
|
66
67
|
const OverridesContext = React.createContext(void 0);
|
|
67
68
|
function useOverrides(overrides) {
|
package/dist/overrides.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sources":["../src/overrides.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PropsWithChildren, ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport * as React from \"react\";\n\nimport { Emoji } from \"./components/internal/Emoji\";\nimport type { Direction } from \"./types\";\nimport { pluralize } from \"./utils/pluralize\";\n\nexport interface LocalizationOverrides {\n locale: string;\n dir: Direction;\n}\n\nexport interface GlobalOverrides {\n USER_SELF: string;\n USER_UNKNOWN: string;\n LIST_REMAINING: (count: number) => string;\n LIST_REMAINING_USERS: (count: number) => string;\n LIST_REMAINING_COMMENTS: (count: number) => string;\n EMOJI_PICKER_SEARCH_PLACEHOLDER: string;\n EMOJI_PICKER_EMPTY: ReactNode;\n EMOJI_PICKER_ERROR: (error: Error) => ReactNode;\n}\n\nexport interface CommentOverrides {\n COMMENT_EDITED: ReactNode;\n COMMENT_DELETED: ReactNode;\n COMMENT_MORE: string;\n COMMENT_EDIT: string;\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: string;\n COMMENT_EDIT_COMPOSER_CANCEL: string;\n COMMENT_EDIT_COMPOSER_SAVE: string;\n COMMENT_DELETE: string;\n COMMENT_ADD_REACTION: string;\n COMMENT_REACTION_LIST: (\n list: ReactNode,\n emoji: string,\n count: number\n ) => ReactNode;\n COMMENT_REACTION_DESCRIPTION: (emoji: string, count: number) => string;\n}\n\nexport interface ComposerOverrides {\n COMPOSER_INSERT_MENTION: string;\n COMPOSER_INSERT_EMOJI: string;\n COMPOSER_PLACEHOLDER: string;\n COMPOSER_SEND: string;\n}\n\nexport interface ThreadOverrides {\n THREAD_RESOLVE: string;\n THREAD_UNRESOLVE: string;\n THREAD_NEW_INDICATOR: string;\n THREAD_NEW_INDICATOR_DESCRIPTION: string;\n THREAD_COMPOSER_PLACEHOLDER: string;\n THREAD_COMPOSER_SEND: string;\n}\n\nexport interface InboxNotificationOverrides {\n INBOX_NOTIFICATION_MORE: string;\n INBOX_NOTIFICATION_MARK_AS_READ: string;\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode | undefined,\n count: number\n ) => ReactNode;\n INBOX_NOTIFICATION_THREAD_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n}\n\nexport type Overrides = LocalizationOverrides &\n GlobalOverrides &\n ComposerOverrides &\n CommentOverrides &\n ThreadOverrides &\n InboxNotificationOverrides;\n\ntype OverridesProviderProps = PropsWithChildren<{\n overrides?: Partial<Overrides>;\n}>;\n\nexport const defaultOverrides: Overrides = {\n locale: \"en\",\n dir: \"ltr\",\n USER_SELF: \"you\",\n USER_UNKNOWN: \"Anonymous\",\n LIST_REMAINING: (count) => `${count} more`,\n LIST_REMAINING_USERS: (count) => `${count} ${pluralize(count, \"other\")}`,\n LIST_REMAINING_COMMENTS: (count) =>\n `${count} more ${pluralize(count, \"comment\")}`,\n EMOJI_PICKER_SEARCH_PLACEHOLDER: \"Search…\",\n EMOJI_PICKER_EMPTY: \"No emoji found.\",\n EMOJI_PICKER_ERROR: () =>\n \"There was an error while getting the list of emoji.\",\n COMPOSER_INSERT_MENTION: \"Mention someone\",\n COMPOSER_INSERT_EMOJI: \"Add emoji\",\n COMPOSER_PLACEHOLDER: \"Write a comment…\",\n COMPOSER_SEND: \"Send\",\n COMMENT_EDITED: \"(edited)\",\n COMMENT_DELETED: \"This comment has been deleted.\",\n COMMENT_MORE: \"More\",\n COMMENT_EDIT: \"Edit comment\",\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: \"Edit comment…\",\n COMMENT_EDIT_COMPOSER_CANCEL: \"Cancel\",\n COMMENT_EDIT_COMPOSER_SAVE: \"Save\",\n COMMENT_DELETE: \"Delete comment\",\n COMMENT_ADD_REACTION: \"Add reaction\",\n COMMENT_REACTION_LIST: (list, emoji) => (\n <>\n {list} reacted with <Emoji emoji={emoji} />\n </>\n ),\n COMMENT_REACTION_DESCRIPTION: (emoji, count) =>\n `${count} ${pluralize(count, \"reaction\")}, react with ${emoji}`,\n THREAD_RESOLVE: \"Resolve thread\",\n THREAD_UNRESOLVE: \"Re-open thread\",\n THREAD_NEW_INDICATOR: \"New\",\n THREAD_NEW_INDICATOR_DESCRIPTION: \"New comments\",\n THREAD_COMPOSER_PLACEHOLDER: \"Reply to thread…\",\n THREAD_COMPOSER_SEND: \"Reply\",\n INBOX_NOTIFICATION_MORE: \"More\",\n INBOX_NOTIFICATION_MARK_AS_READ: \"Mark as read\",\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode\n ) => (\n <>\n {list} commented\n {room ? <> in {room}</> : <> in a thread</>}\n </>\n ),\n INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n};\n\nexport const OverridesContext = createContext<Overrides | undefined>(undefined);\n\nexport function useOverrides(overrides?: Partial<Overrides>): Overrides {\n const contextOverrides = useContext(OverridesContext);\n\n return useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...overrides,\n }),\n [contextOverrides, overrides]\n );\n}\n\nexport function OverridesProvider({\n children,\n overrides: providerOverrides,\n}: OverridesProviderProps) {\n const contextOverrides = useContext(OverridesContext);\n const overrides = useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...providerOverrides,\n }),\n [contextOverrides, providerOverrides]\n );\n\n return (\n <OverridesContext.Provider value={overrides}>\n {children}\n </OverridesContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"overrides.js","sources":["../src/overrides.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PropsWithChildren, ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport * as React from \"react\";\n\nimport { Emoji } from \"./components/internal/Emoji\";\nimport type { Direction } from \"./types\";\nimport { pluralize } from \"./utils/pluralize\";\n\nexport interface LocalizationOverrides {\n locale: string;\n dir: Direction;\n}\n\nexport interface GlobalOverrides {\n USER_SELF: string;\n USER_UNKNOWN: string;\n LIST_REMAINING: (count: number) => string;\n LIST_REMAINING_USERS: (count: number) => string;\n LIST_REMAINING_COMMENTS: (count: number) => string;\n EMOJI_PICKER_SEARCH_PLACEHOLDER: string;\n EMOJI_PICKER_EMPTY: ReactNode;\n EMOJI_PICKER_ERROR: (error: Error) => ReactNode;\n}\n\nexport interface CommentOverrides {\n COMMENT_EDITED: ReactNode;\n COMMENT_DELETED: ReactNode;\n COMMENT_MORE: string;\n COMMENT_EDIT: string;\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: string;\n COMMENT_EDIT_COMPOSER_CANCEL: string;\n COMMENT_EDIT_COMPOSER_SAVE: string;\n COMMENT_DELETE: string;\n COMMENT_ADD_REACTION: string;\n COMMENT_REACTION_LIST: (\n list: ReactNode,\n emoji: string,\n count: number\n ) => ReactNode;\n COMMENT_REACTION_DESCRIPTION: (emoji: string, count: number) => string;\n}\n\nexport interface ComposerOverrides {\n COMPOSER_INSERT_MENTION: string;\n COMPOSER_INSERT_EMOJI: string;\n COMPOSER_PLACEHOLDER: string;\n COMPOSER_SEND: string;\n}\n\nexport interface ThreadOverrides {\n THREAD_RESOLVE: string;\n THREAD_UNRESOLVE: string;\n THREAD_NEW_INDICATOR: string;\n THREAD_NEW_INDICATOR_DESCRIPTION: string;\n THREAD_COMPOSER_PLACEHOLDER: string;\n THREAD_COMPOSER_SEND: string;\n}\n\nexport interface InboxNotificationOverrides {\n INBOX_NOTIFICATION_MORE: string;\n INBOX_NOTIFICATION_MARK_AS_READ: string;\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode | undefined,\n count: number\n ) => ReactNode;\n INBOX_NOTIFICATION_THREAD_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n INBOX_NOTIFICATION_TEXT_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n}\n\nexport type Overrides = LocalizationOverrides &\n GlobalOverrides &\n ComposerOverrides &\n CommentOverrides &\n ThreadOverrides &\n InboxNotificationOverrides;\n\ntype OverridesProviderProps = PropsWithChildren<{\n overrides?: Partial<Overrides>;\n}>;\n\nexport const defaultOverrides: Overrides = {\n locale: \"en\",\n dir: \"ltr\",\n USER_SELF: \"you\",\n USER_UNKNOWN: \"Anonymous\",\n LIST_REMAINING: (count) => `${count} more`,\n LIST_REMAINING_USERS: (count) => `${count} ${pluralize(count, \"other\")}`,\n LIST_REMAINING_COMMENTS: (count) =>\n `${count} more ${pluralize(count, \"comment\")}`,\n EMOJI_PICKER_SEARCH_PLACEHOLDER: \"Search…\",\n EMOJI_PICKER_EMPTY: \"No emoji found.\",\n EMOJI_PICKER_ERROR: () =>\n \"There was an error while getting the list of emoji.\",\n COMPOSER_INSERT_MENTION: \"Mention someone\",\n COMPOSER_INSERT_EMOJI: \"Add emoji\",\n COMPOSER_PLACEHOLDER: \"Write a comment…\",\n COMPOSER_SEND: \"Send\",\n COMMENT_EDITED: \"(edited)\",\n COMMENT_DELETED: \"This comment has been deleted.\",\n COMMENT_MORE: \"More\",\n COMMENT_EDIT: \"Edit comment\",\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: \"Edit comment…\",\n COMMENT_EDIT_COMPOSER_CANCEL: \"Cancel\",\n COMMENT_EDIT_COMPOSER_SAVE: \"Save\",\n COMMENT_DELETE: \"Delete comment\",\n COMMENT_ADD_REACTION: \"Add reaction\",\n COMMENT_REACTION_LIST: (list, emoji) => (\n <>\n {list} reacted with <Emoji emoji={emoji} />\n </>\n ),\n COMMENT_REACTION_DESCRIPTION: (emoji, count) =>\n `${count} ${pluralize(count, \"reaction\")}, react with ${emoji}`,\n THREAD_RESOLVE: \"Resolve thread\",\n THREAD_UNRESOLVE: \"Re-open thread\",\n THREAD_NEW_INDICATOR: \"New\",\n THREAD_NEW_INDICATOR_DESCRIPTION: \"New comments\",\n THREAD_COMPOSER_PLACEHOLDER: \"Reply to thread…\",\n THREAD_COMPOSER_SEND: \"Reply\",\n INBOX_NOTIFICATION_MORE: \"More\",\n INBOX_NOTIFICATION_MARK_AS_READ: \"Mark as read\",\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode\n ) => (\n <>\n {list} commented\n {room ? <> in {room}</> : <> in a thread</>}\n </>\n ),\n INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n INBOX_NOTIFICATION_TEXT_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n};\n\nexport const OverridesContext = createContext<Overrides | undefined>(undefined);\n\nexport function useOverrides(overrides?: Partial<Overrides>): Overrides {\n const contextOverrides = useContext(OverridesContext);\n\n return useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...overrides,\n }),\n [contextOverrides, overrides]\n );\n}\n\nexport function OverridesProvider({\n children,\n overrides: providerOverrides,\n}: OverridesProviderProps) {\n const contextOverrides = useContext(OverridesContext);\n const overrides = useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...providerOverrides,\n }),\n [contextOverrides, providerOverrides]\n );\n\n return (\n <OverridesContext.Provider value={overrides}>\n {children}\n </OverridesContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyFO;AAAoC;AACjC;AACH;AACM;AACG;AACgB;AACuC;AAExB;AACZ;AACb;AAElB;AACuB;AACF;AACD;AACP;AACC;AACC;AACH;AACA;AACqB;AACL;AACF;AACZ;AACM;AAGG;AAAM;AAC7B;AAGwD;AAC1C;AACE;AACI;AACY;AACL;AACP;AACG;AACQ;AAQ/B;AAKA;AAOJ;AAEa;AAEN;AACL;AAEA;AAAO;AACE;AACF;AACA;AACA;AACL;AAC4B;AAEhC;AAEO;AAA2B;AAChC;AAEF;AACE;AACA;AAAkB;AACT;AACF;AACA;AACA;AACL;AACoC;AAGtC;AACG;AAAiC;AAItC;;;;;"}
|
package/dist/overrides.mjs
CHANGED
|
@@ -41,7 +41,8 @@ const defaultOverrides = {
|
|
|
41
41
|
INBOX_NOTIFICATION_MORE: "More",
|
|
42
42
|
INBOX_NOTIFICATION_MARK_AS_READ: "Mark as read",
|
|
43
43
|
INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (list, room) => /* @__PURE__ */ React.createElement(React.Fragment, null, list, " commented", room ? /* @__PURE__ */ React.createElement(React.Fragment, null, " in ", room) : /* @__PURE__ */ React.createElement(React.Fragment, null, " in a thread")),
|
|
44
|
-
INBOX_NOTIFICATION_THREAD_MENTION: (user, room) => /* @__PURE__ */ React.createElement(React.Fragment, null, user, " mentioned you", room ? /* @__PURE__ */ React.createElement(React.Fragment, null, " in ", room) : null)
|
|
44
|
+
INBOX_NOTIFICATION_THREAD_MENTION: (user, room) => /* @__PURE__ */ React.createElement(React.Fragment, null, user, " mentioned you", room ? /* @__PURE__ */ React.createElement(React.Fragment, null, " in ", room) : null),
|
|
45
|
+
INBOX_NOTIFICATION_TEXT_MENTION: (user, room) => /* @__PURE__ */ React.createElement(React.Fragment, null, user, " mentioned you", room ? /* @__PURE__ */ React.createElement(React.Fragment, null, " in ", room) : null)
|
|
45
46
|
};
|
|
46
47
|
const OverridesContext = createContext(void 0);
|
|
47
48
|
function useOverrides(overrides) {
|
package/dist/overrides.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.mjs","sources":["../src/overrides.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PropsWithChildren, ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport * as React from \"react\";\n\nimport { Emoji } from \"./components/internal/Emoji\";\nimport type { Direction } from \"./types\";\nimport { pluralize } from \"./utils/pluralize\";\n\nexport interface LocalizationOverrides {\n locale: string;\n dir: Direction;\n}\n\nexport interface GlobalOverrides {\n USER_SELF: string;\n USER_UNKNOWN: string;\n LIST_REMAINING: (count: number) => string;\n LIST_REMAINING_USERS: (count: number) => string;\n LIST_REMAINING_COMMENTS: (count: number) => string;\n EMOJI_PICKER_SEARCH_PLACEHOLDER: string;\n EMOJI_PICKER_EMPTY: ReactNode;\n EMOJI_PICKER_ERROR: (error: Error) => ReactNode;\n}\n\nexport interface CommentOverrides {\n COMMENT_EDITED: ReactNode;\n COMMENT_DELETED: ReactNode;\n COMMENT_MORE: string;\n COMMENT_EDIT: string;\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: string;\n COMMENT_EDIT_COMPOSER_CANCEL: string;\n COMMENT_EDIT_COMPOSER_SAVE: string;\n COMMENT_DELETE: string;\n COMMENT_ADD_REACTION: string;\n COMMENT_REACTION_LIST: (\n list: ReactNode,\n emoji: string,\n count: number\n ) => ReactNode;\n COMMENT_REACTION_DESCRIPTION: (emoji: string, count: number) => string;\n}\n\nexport interface ComposerOverrides {\n COMPOSER_INSERT_MENTION: string;\n COMPOSER_INSERT_EMOJI: string;\n COMPOSER_PLACEHOLDER: string;\n COMPOSER_SEND: string;\n}\n\nexport interface ThreadOverrides {\n THREAD_RESOLVE: string;\n THREAD_UNRESOLVE: string;\n THREAD_NEW_INDICATOR: string;\n THREAD_NEW_INDICATOR_DESCRIPTION: string;\n THREAD_COMPOSER_PLACEHOLDER: string;\n THREAD_COMPOSER_SEND: string;\n}\n\nexport interface InboxNotificationOverrides {\n INBOX_NOTIFICATION_MORE: string;\n INBOX_NOTIFICATION_MARK_AS_READ: string;\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode | undefined,\n count: number\n ) => ReactNode;\n INBOX_NOTIFICATION_THREAD_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n}\n\nexport type Overrides = LocalizationOverrides &\n GlobalOverrides &\n ComposerOverrides &\n CommentOverrides &\n ThreadOverrides &\n InboxNotificationOverrides;\n\ntype OverridesProviderProps = PropsWithChildren<{\n overrides?: Partial<Overrides>;\n}>;\n\nexport const defaultOverrides: Overrides = {\n locale: \"en\",\n dir: \"ltr\",\n USER_SELF: \"you\",\n USER_UNKNOWN: \"Anonymous\",\n LIST_REMAINING: (count) => `${count} more`,\n LIST_REMAINING_USERS: (count) => `${count} ${pluralize(count, \"other\")}`,\n LIST_REMAINING_COMMENTS: (count) =>\n `${count} more ${pluralize(count, \"comment\")}`,\n EMOJI_PICKER_SEARCH_PLACEHOLDER: \"Search…\",\n EMOJI_PICKER_EMPTY: \"No emoji found.\",\n EMOJI_PICKER_ERROR: () =>\n \"There was an error while getting the list of emoji.\",\n COMPOSER_INSERT_MENTION: \"Mention someone\",\n COMPOSER_INSERT_EMOJI: \"Add emoji\",\n COMPOSER_PLACEHOLDER: \"Write a comment…\",\n COMPOSER_SEND: \"Send\",\n COMMENT_EDITED: \"(edited)\",\n COMMENT_DELETED: \"This comment has been deleted.\",\n COMMENT_MORE: \"More\",\n COMMENT_EDIT: \"Edit comment\",\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: \"Edit comment…\",\n COMMENT_EDIT_COMPOSER_CANCEL: \"Cancel\",\n COMMENT_EDIT_COMPOSER_SAVE: \"Save\",\n COMMENT_DELETE: \"Delete comment\",\n COMMENT_ADD_REACTION: \"Add reaction\",\n COMMENT_REACTION_LIST: (list, emoji) => (\n <>\n {list} reacted with <Emoji emoji={emoji} />\n </>\n ),\n COMMENT_REACTION_DESCRIPTION: (emoji, count) =>\n `${count} ${pluralize(count, \"reaction\")}, react with ${emoji}`,\n THREAD_RESOLVE: \"Resolve thread\",\n THREAD_UNRESOLVE: \"Re-open thread\",\n THREAD_NEW_INDICATOR: \"New\",\n THREAD_NEW_INDICATOR_DESCRIPTION: \"New comments\",\n THREAD_COMPOSER_PLACEHOLDER: \"Reply to thread…\",\n THREAD_COMPOSER_SEND: \"Reply\",\n INBOX_NOTIFICATION_MORE: \"More\",\n INBOX_NOTIFICATION_MARK_AS_READ: \"Mark as read\",\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode\n ) => (\n <>\n {list} commented\n {room ? <> in {room}</> : <> in a thread</>}\n </>\n ),\n INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n};\n\nexport const OverridesContext = createContext<Overrides | undefined>(undefined);\n\nexport function useOverrides(overrides?: Partial<Overrides>): Overrides {\n const contextOverrides = useContext(OverridesContext);\n\n return useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...overrides,\n }),\n [contextOverrides, overrides]\n );\n}\n\nexport function OverridesProvider({\n children,\n overrides: providerOverrides,\n}: OverridesProviderProps) {\n const contextOverrides = useContext(OverridesContext);\n const overrides = useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...providerOverrides,\n }),\n [contextOverrides, providerOverrides]\n );\n\n return (\n <OverridesContext.Provider value={overrides}>\n {children}\n </OverridesContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"overrides.mjs","sources":["../src/overrides.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PropsWithChildren, ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport * as React from \"react\";\n\nimport { Emoji } from \"./components/internal/Emoji\";\nimport type { Direction } from \"./types\";\nimport { pluralize } from \"./utils/pluralize\";\n\nexport interface LocalizationOverrides {\n locale: string;\n dir: Direction;\n}\n\nexport interface GlobalOverrides {\n USER_SELF: string;\n USER_UNKNOWN: string;\n LIST_REMAINING: (count: number) => string;\n LIST_REMAINING_USERS: (count: number) => string;\n LIST_REMAINING_COMMENTS: (count: number) => string;\n EMOJI_PICKER_SEARCH_PLACEHOLDER: string;\n EMOJI_PICKER_EMPTY: ReactNode;\n EMOJI_PICKER_ERROR: (error: Error) => ReactNode;\n}\n\nexport interface CommentOverrides {\n COMMENT_EDITED: ReactNode;\n COMMENT_DELETED: ReactNode;\n COMMENT_MORE: string;\n COMMENT_EDIT: string;\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: string;\n COMMENT_EDIT_COMPOSER_CANCEL: string;\n COMMENT_EDIT_COMPOSER_SAVE: string;\n COMMENT_DELETE: string;\n COMMENT_ADD_REACTION: string;\n COMMENT_REACTION_LIST: (\n list: ReactNode,\n emoji: string,\n count: number\n ) => ReactNode;\n COMMENT_REACTION_DESCRIPTION: (emoji: string, count: number) => string;\n}\n\nexport interface ComposerOverrides {\n COMPOSER_INSERT_MENTION: string;\n COMPOSER_INSERT_EMOJI: string;\n COMPOSER_PLACEHOLDER: string;\n COMPOSER_SEND: string;\n}\n\nexport interface ThreadOverrides {\n THREAD_RESOLVE: string;\n THREAD_UNRESOLVE: string;\n THREAD_NEW_INDICATOR: string;\n THREAD_NEW_INDICATOR_DESCRIPTION: string;\n THREAD_COMPOSER_PLACEHOLDER: string;\n THREAD_COMPOSER_SEND: string;\n}\n\nexport interface InboxNotificationOverrides {\n INBOX_NOTIFICATION_MORE: string;\n INBOX_NOTIFICATION_MARK_AS_READ: string;\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode | undefined,\n count: number\n ) => ReactNode;\n INBOX_NOTIFICATION_THREAD_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n INBOX_NOTIFICATION_TEXT_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n}\n\nexport type Overrides = LocalizationOverrides &\n GlobalOverrides &\n ComposerOverrides &\n CommentOverrides &\n ThreadOverrides &\n InboxNotificationOverrides;\n\ntype OverridesProviderProps = PropsWithChildren<{\n overrides?: Partial<Overrides>;\n}>;\n\nexport const defaultOverrides: Overrides = {\n locale: \"en\",\n dir: \"ltr\",\n USER_SELF: \"you\",\n USER_UNKNOWN: \"Anonymous\",\n LIST_REMAINING: (count) => `${count} more`,\n LIST_REMAINING_USERS: (count) => `${count} ${pluralize(count, \"other\")}`,\n LIST_REMAINING_COMMENTS: (count) =>\n `${count} more ${pluralize(count, \"comment\")}`,\n EMOJI_PICKER_SEARCH_PLACEHOLDER: \"Search…\",\n EMOJI_PICKER_EMPTY: \"No emoji found.\",\n EMOJI_PICKER_ERROR: () =>\n \"There was an error while getting the list of emoji.\",\n COMPOSER_INSERT_MENTION: \"Mention someone\",\n COMPOSER_INSERT_EMOJI: \"Add emoji\",\n COMPOSER_PLACEHOLDER: \"Write a comment…\",\n COMPOSER_SEND: \"Send\",\n COMMENT_EDITED: \"(edited)\",\n COMMENT_DELETED: \"This comment has been deleted.\",\n COMMENT_MORE: \"More\",\n COMMENT_EDIT: \"Edit comment\",\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: \"Edit comment…\",\n COMMENT_EDIT_COMPOSER_CANCEL: \"Cancel\",\n COMMENT_EDIT_COMPOSER_SAVE: \"Save\",\n COMMENT_DELETE: \"Delete comment\",\n COMMENT_ADD_REACTION: \"Add reaction\",\n COMMENT_REACTION_LIST: (list, emoji) => (\n <>\n {list} reacted with <Emoji emoji={emoji} />\n </>\n ),\n COMMENT_REACTION_DESCRIPTION: (emoji, count) =>\n `${count} ${pluralize(count, \"reaction\")}, react with ${emoji}`,\n THREAD_RESOLVE: \"Resolve thread\",\n THREAD_UNRESOLVE: \"Re-open thread\",\n THREAD_NEW_INDICATOR: \"New\",\n THREAD_NEW_INDICATOR_DESCRIPTION: \"New comments\",\n THREAD_COMPOSER_PLACEHOLDER: \"Reply to thread…\",\n THREAD_COMPOSER_SEND: \"Reply\",\n INBOX_NOTIFICATION_MORE: \"More\",\n INBOX_NOTIFICATION_MARK_AS_READ: \"Mark as read\",\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode\n ) => (\n <>\n {list} commented\n {room ? <> in {room}</> : <> in a thread</>}\n </>\n ),\n INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n INBOX_NOTIFICATION_TEXT_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n};\n\nexport const OverridesContext = createContext<Overrides | undefined>(undefined);\n\nexport function useOverrides(overrides?: Partial<Overrides>): Overrides {\n const contextOverrides = useContext(OverridesContext);\n\n return useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...overrides,\n }),\n [contextOverrides, overrides]\n );\n}\n\nexport function OverridesProvider({\n children,\n overrides: providerOverrides,\n}: OverridesProviderProps) {\n const contextOverrides = useContext(OverridesContext);\n const overrides = useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...providerOverrides,\n }),\n [contextOverrides, providerOverrides]\n );\n\n return (\n <OverridesContext.Provider value={overrides}>\n {children}\n </OverridesContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;AAyFO;AAAoC;AACjC;AACH;AACM;AACG;AACgB;AACuC;AAExB;AACZ;AACb;AAElB;AACuB;AACF;AACD;AACP;AACC;AACC;AACH;AACA;AACqB;AACL;AACF;AACZ;AACM;AAGG;AAAM;AAC7B;AAGwD;AAC1C;AACE;AACI;AACY;AACL;AACP;AACG;AACQ;AAQ/B;AAKA;AAOJ;AAEa;AAEN;AACL;AAEA;AAAO;AACE;AACF;AACA;AACA;AACL;AAC4B;AAEhC;AAEO;AAA2B;AAChC;AAEF;AACE;AACA;AAAkB;AACT;AACF;AACA;AACA;AACL;AACoC;AAGtC;AACG;AAAiC;AAItC;;"}
|
package/dist/shared.js
CHANGED
|
@@ -16,7 +16,6 @@ function getMentionSuggestionsCacheForClient(client) {
|
|
|
16
16
|
}
|
|
17
17
|
function useMentionSuggestions(search) {
|
|
18
18
|
const client = react.useClient();
|
|
19
|
-
const mentionSuggestionsCache = getMentionSuggestionsCacheForClient(client);
|
|
20
19
|
const room = react.useRoom();
|
|
21
20
|
const [mentionSuggestions, setMentionSuggestions] = React.useState();
|
|
22
21
|
const lastInvokedAt = React.useRef();
|
|
@@ -29,6 +28,7 @@ function useMentionSuggestions(search) {
|
|
|
29
28
|
const mentionSuggestionsCacheKey = core.stringify(resolveMentionSuggestionsArgs);
|
|
30
29
|
let debounceTimeout;
|
|
31
30
|
let isCanceled = false;
|
|
31
|
+
const mentionSuggestionsCache = getMentionSuggestionsCacheForClient(client);
|
|
32
32
|
const getMentionSuggestions = async () => {
|
|
33
33
|
try {
|
|
34
34
|
lastInvokedAt.current = performance.now();
|
|
@@ -61,7 +61,7 @@ function useMentionSuggestions(search) {
|
|
|
61
61
|
isCanceled = true;
|
|
62
62
|
window.clearTimeout(debounceTimeout);
|
|
63
63
|
};
|
|
64
|
-
}, [room.id, search]);
|
|
64
|
+
}, [client, room.id, search]);
|
|
65
65
|
return mentionSuggestions;
|
|
66
66
|
}
|
|
67
67
|
function useCurrentUserIdFromRoom() {
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sources":["../src/shared.ts"],"sourcesContent":["import type { OpaqueClient } from \"@liveblocks/core\";\nimport { kInternal, raise, stringify } from \"@liveblocks/core\";\nimport {\n ClientContext,\n RoomContext,\n useClient,\n useRoom,\n useSelf,\n} from \"@liveblocks/react\";\nimport React, { useContext, useSyncExternalStore } from \"react\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\nconst _cachesByClient = new WeakMap<OpaqueClient, Map<string, string[]>>();\n\nfunction getMentionSuggestionsCacheForClient(client: OpaqueClient) {\n let cache = _cachesByClient.get(client);\n if (!cache) {\n cache = new Map();\n _cachesByClient.set(client, cache);\n }\n return cache;\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(search?: string) {\n const client = useClient();\n
|
|
1
|
+
{"version":3,"file":"shared.js","sources":["../src/shared.ts"],"sourcesContent":["import type { OpaqueClient } from \"@liveblocks/core\";\nimport { kInternal, raise, stringify } from \"@liveblocks/core\";\nimport {\n ClientContext,\n RoomContext,\n useClient,\n useRoom,\n useSelf,\n} from \"@liveblocks/react\";\nimport React, { useContext, useSyncExternalStore } from \"react\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\nconst _cachesByClient = new WeakMap<OpaqueClient, Map<string, string[]>>();\n\nfunction getMentionSuggestionsCacheForClient(client: OpaqueClient) {\n let cache = _cachesByClient.get(client);\n if (!cache) {\n cache = new Map();\n _cachesByClient.set(client, cache);\n }\n return cache;\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(search?: string) {\n const client = useClient();\n\n const room = useRoom();\n const [mentionSuggestions, setMentionSuggestions] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n React.useEffect(() => {\n const resolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions;\n\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId: room.id };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const mentionSuggestionsCache = getMentionSuggestionsCacheForClient(client);\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const mentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n setMentionSuggestions(mentionSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n mentionSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n setMentionSuggestions(\n mentionSuggestionsCache.get(mentionSuggestionsCacheKey)\n );\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [client, room.id, search]);\n\n return mentionSuggestions;\n}\n\nfunction useCurrentUserIdFromRoom() {\n return useSelf((user) => (typeof user.id === \"string\" ? user.id : null));\n}\n\nfunction useCurrentUserIdFromClient_withClient(client: OpaqueClient) {\n const currentUserIdStore = client[kInternal].currentUserIdStore;\n return useSyncExternalStore(\n currentUserIdStore.subscribe,\n currentUserIdStore.get,\n currentUserIdStore.get\n );\n}\n\nexport function useCurrentUserId(): string | null {\n const client = useContext(ClientContext);\n const room = useContext(RoomContext);\n\n // NOTE: These hooks are called conditionally, but in a way that will not\n // take different code paths between re-renders, so we can ignore the\n // rules-of-hooks lint warning here.\n /* eslint-disable react-hooks/rules-of-hooks */\n if (room !== null) {\n return useCurrentUserIdFromRoom();\n } else if (client !== null) {\n return useCurrentUserIdFromClient_withClient(client);\n } else {\n raise(\n \"LiveblocksProvider or RoomProvider are missing from the React tree.\"\n );\n }\n /* eslint-enable react-hooks/rules-of-hooks */\n}\n"],"names":["useClient","useRoom","kInternal","stringify","mentionSuggestions","useSelf","useSyncExternalStore","useContext","ClientContext","RoomContext","raise"],"mappings":"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"}
|
package/dist/shared.mjs
CHANGED
|
@@ -14,7 +14,6 @@ function getMentionSuggestionsCacheForClient(client) {
|
|
|
14
14
|
}
|
|
15
15
|
function useMentionSuggestions(search) {
|
|
16
16
|
const client = useClient();
|
|
17
|
-
const mentionSuggestionsCache = getMentionSuggestionsCacheForClient(client);
|
|
18
17
|
const room = useRoom();
|
|
19
18
|
const [mentionSuggestions, setMentionSuggestions] = React__default.useState();
|
|
20
19
|
const lastInvokedAt = React__default.useRef();
|
|
@@ -27,6 +26,7 @@ function useMentionSuggestions(search) {
|
|
|
27
26
|
const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);
|
|
28
27
|
let debounceTimeout;
|
|
29
28
|
let isCanceled = false;
|
|
29
|
+
const mentionSuggestionsCache = getMentionSuggestionsCacheForClient(client);
|
|
30
30
|
const getMentionSuggestions = async () => {
|
|
31
31
|
try {
|
|
32
32
|
lastInvokedAt.current = performance.now();
|
|
@@ -59,7 +59,7 @@ function useMentionSuggestions(search) {
|
|
|
59
59
|
isCanceled = true;
|
|
60
60
|
window.clearTimeout(debounceTimeout);
|
|
61
61
|
};
|
|
62
|
-
}, [room.id, search]);
|
|
62
|
+
}, [client, room.id, search]);
|
|
63
63
|
return mentionSuggestions;
|
|
64
64
|
}
|
|
65
65
|
function useCurrentUserIdFromRoom() {
|
package/dist/shared.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.mjs","sources":["../src/shared.ts"],"sourcesContent":["import type { OpaqueClient } from \"@liveblocks/core\";\nimport { kInternal, raise, stringify } from \"@liveblocks/core\";\nimport {\n ClientContext,\n RoomContext,\n useClient,\n useRoom,\n useSelf,\n} from \"@liveblocks/react\";\nimport React, { useContext, useSyncExternalStore } from \"react\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\nconst _cachesByClient = new WeakMap<OpaqueClient, Map<string, string[]>>();\n\nfunction getMentionSuggestionsCacheForClient(client: OpaqueClient) {\n let cache = _cachesByClient.get(client);\n if (!cache) {\n cache = new Map();\n _cachesByClient.set(client, cache);\n }\n return cache;\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(search?: string) {\n const client = useClient();\n
|
|
1
|
+
{"version":3,"file":"shared.mjs","sources":["../src/shared.ts"],"sourcesContent":["import type { OpaqueClient } from \"@liveblocks/core\";\nimport { kInternal, raise, stringify } from \"@liveblocks/core\";\nimport {\n ClientContext,\n RoomContext,\n useClient,\n useRoom,\n useSelf,\n} from \"@liveblocks/react\";\nimport React, { useContext, useSyncExternalStore } from \"react\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\nconst _cachesByClient = new WeakMap<OpaqueClient, Map<string, string[]>>();\n\nfunction getMentionSuggestionsCacheForClient(client: OpaqueClient) {\n let cache = _cachesByClient.get(client);\n if (!cache) {\n cache = new Map();\n _cachesByClient.set(client, cache);\n }\n return cache;\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(search?: string) {\n const client = useClient();\n\n const room = useRoom();\n const [mentionSuggestions, setMentionSuggestions] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n React.useEffect(() => {\n const resolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions;\n\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId: room.id };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const mentionSuggestionsCache = getMentionSuggestionsCacheForClient(client);\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const mentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n setMentionSuggestions(mentionSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n mentionSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n setMentionSuggestions(\n mentionSuggestionsCache.get(mentionSuggestionsCacheKey)\n );\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [client, room.id, search]);\n\n return mentionSuggestions;\n}\n\nfunction useCurrentUserIdFromRoom() {\n return useSelf((user) => (typeof user.id === \"string\" ? user.id : null));\n}\n\nfunction useCurrentUserIdFromClient_withClient(client: OpaqueClient) {\n const currentUserIdStore = client[kInternal].currentUserIdStore;\n return useSyncExternalStore(\n currentUserIdStore.subscribe,\n currentUserIdStore.get,\n currentUserIdStore.get\n );\n}\n\nexport function useCurrentUserId(): string | null {\n const client = useContext(ClientContext);\n const room = useContext(RoomContext);\n\n // NOTE: These hooks are called conditionally, but in a way that will not\n // take different code paths between re-renders, so we can ignore the\n // rules-of-hooks lint warning here.\n /* eslint-disable react-hooks/rules-of-hooks */\n if (room !== null) {\n return useCurrentUserIdFromRoom();\n } else if (client !== null) {\n return useCurrentUserIdFromClient_withClient(client);\n } else {\n raise(\n \"LiveblocksProvider or RoomProvider are missing from the React tree.\"\n );\n }\n /* eslint-enable react-hooks/rules-of-hooks */\n}\n"],"names":["React","mentionSuggestions"],"mappings":"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"}
|
package/dist/version.js
CHANGED
package/dist/version.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react-ui",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-alpha2",
|
|
4
4
|
"description": "A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -58,13 +58,14 @@
|
|
|
58
58
|
"lint": "eslint src/; stylelint src/styles/",
|
|
59
59
|
"lint:package": "publint --strict && attw --pack",
|
|
60
60
|
"test": "jest --silent --verbose --color=always",
|
|
61
|
+
"test:types": "ls test-d/* | xargs -n1 tsd --files",
|
|
61
62
|
"test:watch": "jest --silent --verbose --color=always --watch"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
65
|
"@floating-ui/react-dom": "^2.0.8",
|
|
65
|
-
"@liveblocks/client": "2.0.0-
|
|
66
|
-
"@liveblocks/core": "2.0.0-
|
|
67
|
-
"@liveblocks/react": "2.0.0-
|
|
66
|
+
"@liveblocks/client": "2.0.0-alpha2",
|
|
67
|
+
"@liveblocks/core": "2.0.0-alpha2",
|
|
68
|
+
"@liveblocks/react": "2.0.0-alpha2",
|
|
68
69
|
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
|
69
70
|
"@radix-ui/react-popover": "^1.0.7",
|
|
70
71
|
"@radix-ui/react-slot": "^1.0.2",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"slate": "^0.102.0",
|
|
75
76
|
"slate-history": "^0.100.0",
|
|
76
77
|
"slate-react": "^0.102.0",
|
|
77
|
-
"use-sync-external-store": "^1.2.
|
|
78
|
+
"use-sync-external-store": "^1.2.2"
|
|
78
79
|
},
|
|
79
80
|
"peerDependencies": {
|
|
80
81
|
"react": "^16.14.0 || ^17 || ^18"
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
87
88
|
"@testing-library/jest-dom": "^5.16.5",
|
|
88
89
|
"@testing-library/react": "^13.1.1",
|
|
89
|
-
"@types/use-sync-external-store": "^0.0.
|
|
90
|
+
"@types/use-sync-external-store": "^0.0.6",
|
|
90
91
|
"emojibase": "^15.3.0",
|
|
91
92
|
"eslint-plugin-react": "^7.33.2",
|
|
92
93
|
"eslint-plugin-react-hooks": "^4.6.0",
|
package/src/styles/index.css
CHANGED
|
@@ -98,6 +98,12 @@
|
|
|
98
98
|
var(--lb-foreground-contrast),
|
|
99
99
|
800
|
|
100
100
|
);
|
|
101
|
+
--lb-selection: color-mix-scale(
|
|
102
|
+
var(--lb-dynamic-background),
|
|
103
|
+
var(--lb-accent) 40%,
|
|
104
|
+
var(--lb-foreground-contrast),
|
|
105
|
+
800
|
|
106
|
+
);
|
|
101
107
|
|
|
102
108
|
overflow-wrap: break-word;
|
|
103
109
|
accent-color: var(--lb-accent);
|