@brainfish-ai/components 0.13.14 → 0.14.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.
Files changed (35) hide show
  1. package/dist/components/chat-search/PrimarySearch.d.ts +11 -5
  2. package/dist/components/chat-search/types.d.ts +8 -0
  3. package/dist/components/combobox/combobox.d.ts +9 -5
  4. package/dist/components/markdown/utils/urls.d.ts +6 -0
  5. package/dist/components/two-level-combobox/index.d.ts +1 -0
  6. package/dist/components/two-level-combobox/two-level-combobox.d.ts +15 -0
  7. package/dist/components/ui/div-button.d.ts +11 -0
  8. package/dist/esm/chunks/{ChatSearch.CicUAtwR.js → ChatSearch.DdKSJqhX.js} +121 -17
  9. package/dist/esm/chunks/ChatSearch.DdKSJqhX.js.map +1 -0
  10. package/dist/esm/chunks/{FormattedMessage.Cmv0Kl8o.js → FormattedMessage.C7CKFL5X.js} +50 -29
  11. package/dist/esm/chunks/FormattedMessage.C7CKFL5X.js.map +1 -0
  12. package/dist/esm/chunks/{combobox.B5aw7PrS.js → combobox.BRm6ZDEB.js} +18 -9
  13. package/dist/esm/chunks/combobox.BRm6ZDEB.js.map +1 -0
  14. package/dist/esm/chunks/index.tOGWkez1.js +123 -0
  15. package/dist/esm/chunks/index.tOGWkez1.js.map +1 -0
  16. package/dist/esm/chunks/two-level-combobox.DFonmrmc.js +132 -0
  17. package/dist/esm/chunks/two-level-combobox.DFonmrmc.js.map +1 -0
  18. package/dist/esm/components/chat-search.js +1 -1
  19. package/dist/esm/components/combobox.js +1 -1
  20. package/dist/esm/components/markdown.js +1 -1
  21. package/dist/esm/components/two-level-combobox.js +2 -0
  22. package/dist/esm/components/two-level-combobox.js.map +1 -0
  23. package/dist/esm/components/ui/button.js +1 -119
  24. package/dist/esm/components/ui/button.js.map +1 -1
  25. package/dist/esm/components/ui/div-button.js +59 -0
  26. package/dist/esm/components/ui/div-button.js.map +1 -0
  27. package/dist/esm/index.css +1 -1
  28. package/dist/esm/index.js +4 -3
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/stats.html +1 -1
  32. package/package.json +3 -1
  33. package/dist/esm/chunks/ChatSearch.CicUAtwR.js.map +0 -1
  34. package/dist/esm/chunks/FormattedMessage.Cmv0Kl8o.js.map +0 -1
  35. package/dist/esm/chunks/combobox.B5aw7PrS.js.map +0 -1
@@ -39173,6 +39173,7 @@ const parseTimeParams = (url) => {
39173
39173
  return {};
39174
39174
  }
39175
39175
  };
39176
+
39176
39177
  const NativeVideo = ({ attrs }) => {
39177
39178
  const { href } = attrs;
39178
39179
  const videoRef = React.useRef(null);
@@ -39180,25 +39181,42 @@ const NativeVideo = ({ attrs }) => {
39180
39181
  const [duration, setDuration] = React.useState(0);
39181
39182
  const [currentTime, setCurrentTime] = React.useState(0);
39182
39183
  const [isLoading, setIsLoading] = React.useState(true);
39183
- const handleLoadedMetadata = React.useCallback(() => {
39184
- if (videoRef.current) {
39185
- setDuration(videoRef.current.duration);
39184
+ const hasSetInitialTime = React.useRef(false);
39185
+ React.useEffect(() => {
39186
+ const video = videoRef.current;
39187
+ if (!video) {
39188
+ return;
39189
+ }
39190
+ const abortController = new AbortController();
39191
+ const { signal } = abortController;
39192
+ const handleLoadStart = () => {
39193
+ setCurrentTime(0);
39194
+ hasSetInitialTime.current = false;
39195
+ setIsLoading(true);
39196
+ };
39197
+ const handleLoadedMetadata = () => {
39198
+ setDuration(video.duration);
39199
+ };
39200
+ const handleCanPlay = () => {
39186
39201
  setIsLoading(false);
39187
- if (startTime !== void 0) {
39188
- videoRef.current.currentTime = startTime;
39202
+ if (startTime !== null && startTime !== void 0 && startTime >= 0 && !hasSetInitialTime.current) {
39203
+ hasSetInitialTime.current = true;
39204
+ video.currentTime = startTime;
39189
39205
  setCurrentTime(startTime);
39190
39206
  }
39191
- }
39192
- }, [startTime]);
39193
- const handleTimeUpdate = React.useCallback(() => {
39194
- if (videoRef.current) {
39195
- setCurrentTime(videoRef.current.currentTime);
39196
- if (endTime && videoRef.current.currentTime >= endTime) {
39197
- videoRef.current.pause();
39198
- }
39199
- }
39200
- }, [endTime]);
39201
- return /* @__PURE__ */ React.createElement("div", { className: "w-full relative" }, /* @__PURE__ */ React.createElement(
39207
+ };
39208
+ const handleTimeUpdate = () => {
39209
+ setCurrentTime(video.currentTime);
39210
+ };
39211
+ video.addEventListener("loadstart", handleLoadStart, { signal });
39212
+ video.addEventListener("loadedmetadata", handleLoadedMetadata, { signal });
39213
+ video.addEventListener("canplay", handleCanPlay, { signal });
39214
+ video.addEventListener("timeupdate", handleTimeUpdate, { signal });
39215
+ return () => {
39216
+ abortController.abort();
39217
+ };
39218
+ }, [startTime, endTime]);
39219
+ return /* @__PURE__ */ React.createElement("div", { className: "relative w-full" }, /* @__PURE__ */ React.createElement(
39202
39220
  "video",
39203
39221
  {
39204
39222
  ref: videoRef,
@@ -39208,21 +39226,24 @@ const NativeVideo = ({ attrs }) => {
39208
39226
  height: "auto",
39209
39227
  src: href,
39210
39228
  title: "Native Video",
39211
- className: "rounded-lg overflow-hidden",
39212
- controlsList: "nodownload",
39213
- onLoadedMetadata: handleLoadedMetadata,
39214
- onTimeUpdate: handleTimeUpdate
39229
+ className: "overflow-hidden rounded-lg",
39230
+ controlsList: "nodownload"
39215
39231
  },
39216
39232
  "Your browser does not support the video tag."
39217
- ), duration > 0 && !isLoading && (startTime !== void 0 || endTime !== void 0) && /* @__PURE__ */ React.createElement(
39218
- VideoTimeline,
39219
- {
39220
- duration,
39221
- currentTime,
39222
- startTime: startTime ?? null,
39223
- endTime: endTime ?? null
39233
+ ), React.useMemo(() => {
39234
+ if (duration > 0 && !isLoading && (startTime !== void 0 || endTime !== void 0)) {
39235
+ return /* @__PURE__ */ React.createElement(
39236
+ VideoTimeline,
39237
+ {
39238
+ duration,
39239
+ currentTime,
39240
+ startTime: startTime ?? null,
39241
+ endTime: endTime ?? null
39242
+ }
39243
+ );
39224
39244
  }
39225
- ));
39245
+ return null;
39246
+ }, [duration, isLoading, startTime, endTime, currentTime]));
39226
39247
  };
39227
39248
  NativeVideo.isMatch = (href) => {
39228
39249
  const [url] = href.split("?");
@@ -39729,4 +39750,4 @@ const FormattedMessage = memo(({ message, isStreaming, redirectRules = [], conte
39729
39750
  FormattedMessage.displayName = "FormattedMessage";
39730
39751
 
39731
39752
  export { CodeBlock as C, FormattedMessage as F, MemoizedReactMarkdown as M, ZoomableImage as Z, MermaidDiagram as a, addUtmParameters as b, addPopupWidgetUtm as c, getDefaultExportFromCjs as g };
39732
- //# sourceMappingURL=FormattedMessage.Cmv0Kl8o.js.map
39753
+ //# sourceMappingURL=FormattedMessage.C7CKFL5X.js.map