@liveblocks/react-ui
Version:
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.
226 lines (221 loc) • 7.62 kB
JavaScript
"use client";
;
var jsxRuntime = require('react/jsx-runtime');
var core = require('@liveblocks/core');
var react = require('react');
var Emoji = require('./components/internal/Emoji.cjs');
var Duration = require('./primitives/Duration.cjs');
var pluralize = require('./utils/pluralize.cjs');
const MINIMUM_VISIBLE_DURATION = 3 * 1e3;
function isDurationVisible(from, to) {
return Duration.getDuration(from, to ?? Date.now()) >= MINIMUM_VISIBLE_DURATION;
}
const defaultOverrides = {
locale: "en",
dir: "ltr",
USER_SELF: "you",
USER_UNKNOWN: "Anonymous",
COPY_TO_CLIPBOARD: "Copy",
LIST_REMAINING: (count) => `${count} more`,
LIST_REMAINING_USERS: (count) => `${count} ${pluralize.pluralize(count, "other")}`,
LIST_REMAINING_COMMENTS: (count) => `${count} more ${pluralize.pluralize(count, "comment")}`,
EMOJI_PICKER_SEARCH_PLACEHOLDER: "Search\u2026",
EMOJI_PICKER_EMPTY: "No emoji found.",
EMOJI_PICKER_ERROR: () => "There was an error while getting the list of emoji.",
EMOJI_PICKER_CHANGE_SKIN_TONE: "Change skin tone",
ATTACHMENT_TOO_LARGE: (maxSize) => maxSize ? `The file is larger than ${maxSize}` : "The file is too large",
ATTACHMENT_ERROR: () => "The file couldn\u2019t be uploaded.",
COMPOSER_INSERT_MENTION: "Mention someone",
COMPOSER_INSERT_EMOJI: "Add emoji",
COMPOSER_ATTACH_FILES: "Attach files",
COMPOSER_REMOVE_ATTACHMENT: "Remove attachment",
COMPOSER_PLACEHOLDER: "Write a comment\u2026",
COMPOSER_SEND: "Send",
COMPOSER_TOGGLE_MARK: (format) => {
switch (format) {
case "bold":
return "Bold";
case "italic":
return "Italic";
case "strikethrough":
return "Strikethrough";
case "code":
return "Inline code";
default:
return core.assertNever(format, "Unexpected mark");
}
},
COMMENT_EDITED: "(edited)",
COMMENT_DELETED: "This comment has been deleted.",
COMMENT_MORE: "More",
COMMENT_EDIT: "Edit comment",
COMMENT_EDIT_COMPOSER_PLACEHOLDER: "Edit comment\u2026",
COMMENT_EDIT_COMPOSER_CANCEL: "Cancel",
COMMENT_EDIT_COMPOSER_SAVE: "Save",
COMMENT_DELETE: "Delete comment",
COMMENT_DELETE_ATTACHMENT: "Delete attachment",
COMMENT_ADD_REACTION: "Add reaction",
COMMENT_REACTION_LIST: (list, emoji) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
list,
" reacted with ",
/* @__PURE__ */ jsxRuntime.jsx(Emoji.Emoji, {
emoji
})
]
}),
COMMENT_REACTION_DESCRIPTION: (emoji, count) => `${count} ${pluralize.pluralize(count, "reaction")}, react with ${emoji}`,
THREAD_RESOLVE: "Resolve thread",
THREAD_UNRESOLVE: "Re-open thread",
THREAD_SUBSCRIBE: "Subscribe to thread",
THREAD_UNSUBSCRIBE: "Unsubscribe from thread",
THREAD_NEW_INDICATOR: "New",
THREAD_NEW_INDICATOR_DESCRIPTION: "New comments",
THREAD_SHOW_MORE_COMMENTS: (count) => `Show ${count} more ${pluralize.pluralize(count, "reply", "replies")}`,
THREAD_COMPOSER_PLACEHOLDER: "Reply to thread\u2026",
THREAD_COMPOSER_SEND: "Reply",
INBOX_NOTIFICATION_MORE: "More",
INBOX_NOTIFICATION_MARK_AS_READ: "Mark as read",
INBOX_NOTIFICATION_DELETE: "Delete notification",
INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (list, room) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
list,
" commented",
room ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
" in ",
room
]
}) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
children: " in a thread"
})
]
}),
INBOX_NOTIFICATION_THREAD_MENTION: (user, room) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
user,
" mentioned you",
room ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
" in ",
room
]
}) : null
]
}),
INBOX_NOTIFICATION_TEXT_MENTION: (user, room) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
user,
" mentioned you",
room ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
" in ",
room
]
}) : null
]
}),
HISTORY_VERSION_PREVIEW_AUTHORS_LIST: (list) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
"Edits from ",
list
]
}),
HISTORY_VERSION_PREVIEW_RESTORE: "Restore",
HISTORY_VERSION_PREVIEW_EMPTY: "No content.",
HISTORY_VERSION_PREVIEW_ERROR: () => "There was an error while getting this version.",
AI_COMPOSER_PLACEHOLDER: "Ask anything\u2026",
AI_COMPOSER_SEND: "Send",
AI_COMPOSER_ABORT: "Abort response",
AI_CHAT_MESSAGE_DELETED: "This message has been deleted.",
AI_CHAT_MESSAGE_THINKING: "Thinking\u2026",
AI_CHAT_MESSAGE_REASONING: (isStreaming, part) => isStreaming ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
children: "Reasoning\u2026"
}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
"Reasoned",
isDurationVisible(part.startedAt, part.endedAt) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
" ",
"for",
" ",
/* @__PURE__ */ jsxRuntime.jsx(Duration.Duration, {
className: "lb-duration lb-ai-chat-message-reasoning-duration",
from: part.startedAt,
to: part.endedAt
})
]
}) : null
]
}),
AI_CHAT_MESSAGE_RETRIEVAL: (isStreaming, part) => isStreaming ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
"Searching",
" ",
/* @__PURE__ */ jsxRuntime.jsx("span", {
className: "lb-ai-chat-message-retrieval-query",
children: part.query
}),
"\u2026"
]
}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
"Searched",
" ",
/* @__PURE__ */ jsxRuntime.jsx("span", {
className: "lb-ai-chat-message-retrieval-query",
children: part.query
}),
isDurationVisible(part.startedAt, part.endedAt) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
" ",
"for",
" ",
/* @__PURE__ */ jsxRuntime.jsx(Duration.Duration, {
className: "lb-duration lb-ai-chat-message-retrieval-duration",
from: part.startedAt,
to: part.endedAt
})
]
}) : null
]
}),
AI_CHAT_MESSAGES_ERROR: () => "There was an error while getting the messages.",
AI_TOOL_CONFIRMATION_CONFIRM: "Confirm",
AI_TOOL_CONFIRMATION_CANCEL: "Cancel"
};
const OverridesContext = react.createContext(void 0);
function useOverrides(overrides) {
const contextOverrides = react.useContext(OverridesContext);
return react.useMemo(
() => ({
...defaultOverrides,
...contextOverrides,
...overrides
}),
[contextOverrides, overrides]
);
}
function OverridesProvider({
children,
overrides: providerOverrides
}) {
const contextOverrides = react.useContext(OverridesContext);
const overrides = react.useMemo(
() => ({
...defaultOverrides,
...contextOverrides,
...providerOverrides
}),
[contextOverrides, providerOverrides]
);
return /* @__PURE__ */ jsxRuntime.jsx(OverridesContext.Provider, {
value: overrides,
children
});
}
exports.OverridesContext = OverridesContext;
exports.OverridesProvider = OverridesProvider;
exports.defaultOverrides = defaultOverrides;
exports.useOverrides = useOverrides;
//# sourceMappingURL=overrides.cjs.map