@blocklet/discuss-kit-ux 2.1.199 → 2.1.201

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.
@@ -3,3 +3,4 @@ export { useChanged } from './changed';
3
3
  export { useNow } from './now';
4
4
  export { useInterval } from './interval';
5
5
  export { useDownBreakpoint, useUpBreakpoint } from './responsive';
6
+ export { useEventCallback } from './use-event-callback';
@@ -0,0 +1 @@
1
+ export declare function useEventCallback<I extends unknown[], O>(fn: (...args: I) => O): (...args: I) => O;
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
4
4
  import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
5
5
  import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
6
6
  import { lazyRetry } from "@arcblock/ux/lib/Util";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-D051_TWT.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-B7y6yLro.mjs";
8
8
  const BlockletEditor = lazyRetry(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -6,7 +6,7 @@ import { Labels2, LabelPicker } from "@blocklet/labels";
6
6
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
7
7
  import { useTheme, ThemeProvider, styled as styled$2 } from "@mui/material/styles";
8
8
  import { create as create$1, styled } from "@arcblock/ux/lib/Theme";
9
- import { useEffect, useRef, useState, createElement, useContext, useMemo, useCallback, isValidElement, Suspense, createContext, Fragment as Fragment$1, forwardRef, useImperativeHandle } from "react";
9
+ import { useEffect, useRef, useState, createElement, useContext, useMemo, useLayoutEffect, useCallback, isValidElement, Suspense, createContext, Fragment as Fragment$1, forwardRef, useImperativeHandle } from "react";
10
10
  import { Box, useTheme as useTheme$1, useMediaQuery, styled as styled$1, Button as Button$1, Stack as Stack$1, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Divider, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, CircularProgress, Backdrop, Autocomplete, Typography as Typography$1, TextField, InputAdornment, SwipeableDrawer, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
11
11
  import isNil from "lodash/isNil";
12
12
  import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/config";
@@ -1125,6 +1125,19 @@ const useResponsiveValue = (values2) => {
1125
1125
  const r = useResponsive();
1126
1126
  return r(values2);
1127
1127
  };
1128
+ function useEventCallback(fn) {
1129
+ const ref = useRef();
1130
+ useLayoutEffect(() => {
1131
+ ref.current = fn;
1132
+ });
1133
+ return useCallback((...args) => {
1134
+ const { current } = ref;
1135
+ if (current == null) {
1136
+ throw new Error("callback created in useEventCallback can only be called from event handlers");
1137
+ }
1138
+ return current(...args);
1139
+ }, []);
1140
+ }
1128
1141
  const useChatInWallet = () => {
1129
1142
  var _a2;
1130
1143
  const navigate = useNavigate();
@@ -4906,7 +4919,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4906
4919
  }
4907
4920
  const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
4908
4921
  const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
4909
- const Editor = lazyRetry(() => import("./editor-MevHKU1_.mjs"));
4922
+ const Editor = lazyRetry(() => import("./editor-D5FK3BKr.mjs"));
4910
4923
  function LazyEditor(props) {
4911
4924
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4912
4925
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -12421,94 +12434,95 @@ function SegmentedControl({ value, options, onChange, sx, ...rest }) {
12421
12434
  ) });
12422
12435
  }
12423
12436
  export {
12424
- ChatHeaderAddon as $,
12437
+ ChatListInWallet as $,
12425
12438
  Avatar as A,
12426
12439
  Badge as B,
12427
12440
  CommentInput as C,
12428
12441
  DefaultEditorConfigProvider as D,
12429
- CommentsProvider as E,
12430
- BinaryThumb as F,
12431
- GithubReaction as G,
12432
- EmptyStatus as H,
12442
+ useCommentsContext as E,
12443
+ CommentsProvider as F,
12444
+ BinaryThumb as G,
12445
+ GithubReaction as H,
12433
12446
  ImagePathFixerPlugin as I,
12434
- BlogListWrapper as J,
12435
- BlogCard as K,
12436
- BlogPermaLink as L,
12447
+ EmptyStatus as J,
12448
+ BlogListWrapper as K,
12449
+ BlogCard as L,
12437
12450
  Menu as M,
12438
- getBlogLink as N,
12439
- CoverImage as O,
12451
+ BlogPermaLink as N,
12452
+ getBlogLink as O,
12440
12453
  Pagination as P,
12441
- CoverImageUpload as Q,
12454
+ CoverImage as Q,
12442
12455
  RelativeTime as R,
12443
12456
  ScrollableEditorWrapper as S,
12444
- AccessControl as T,
12445
- useAuthzContext as U,
12457
+ CoverImageUpload as T,
12458
+ AccessControl as U,
12446
12459
  VideoPathFixerPlugin as V,
12447
- AuthzProvider as W,
12448
- ChatClient as X,
12449
- Chat as Y,
12450
- ChatInWallet as Z,
12451
- ChatListInWallet as _,
12460
+ useAuthzContext as W,
12461
+ AuthzProvider as X,
12462
+ ChatClient as Y,
12463
+ Chat as Z,
12464
+ ChatInWallet as _,
12452
12465
  isEmptyContent as a,
12453
- useChatContext as a0,
12454
- ChatProvider as a1,
12455
- UnreadNotificationContext as a2,
12456
- useUnreadNotification as a3,
12457
- UnreadNotificationProvider as a4,
12458
- Confirm as a5,
12459
- ConfirmContext as a6,
12460
- useConfirm as a7,
12461
- ConfirmProvider as a8,
12462
- SecureLabelPicker as a9,
12463
- useApiErrorHandler as aa,
12464
- useDefaultApiErrorHandler as ab,
12465
- DefaultApiErrorHandler as ac,
12466
- Back as ad,
12467
- LazyEditor as ae,
12468
- EditorPreview as af,
12469
- DirtyPromptContainer as ag,
12470
- ConfirmNavigation as ah,
12471
- UploaderContext as ai,
12472
- useUploader as aj,
12473
- UploaderTrigger as ak,
12474
- UploaderProvider as al,
12475
- getUploadedImageUrl as am,
12476
- usePointUpContext as an,
12477
- PointUpProvider as ao,
12478
- ButtonGroup as ap,
12479
- SegmentedControl as aq,
12480
- create as ar,
12481
- getWsClient as as,
12482
- useSubscription as at,
12483
- toast as au,
12484
- isInArcSphere$1 as av,
12485
- isInArcSphereDialog as aw,
12486
- openArcSphereDialog as ax,
12487
- closeArcSphereDialog as ay,
12488
- useArcSphereDialog as az,
12466
+ ChatHeaderAddon as a0,
12467
+ useChatContext as a1,
12468
+ ChatProvider as a2,
12469
+ UnreadNotificationContext as a3,
12470
+ useUnreadNotification as a4,
12471
+ UnreadNotificationProvider as a5,
12472
+ Confirm as a6,
12473
+ ConfirmContext as a7,
12474
+ useConfirm as a8,
12475
+ ConfirmProvider as a9,
12476
+ useArcSphereDialog as aA,
12477
+ SecureLabelPicker as aa,
12478
+ useApiErrorHandler as ab,
12479
+ useDefaultApiErrorHandler as ac,
12480
+ DefaultApiErrorHandler as ad,
12481
+ Back as ae,
12482
+ LazyEditor as af,
12483
+ EditorPreview as ag,
12484
+ DirtyPromptContainer as ah,
12485
+ ConfirmNavigation as ai,
12486
+ UploaderContext as aj,
12487
+ useUploader as ak,
12488
+ UploaderTrigger as al,
12489
+ UploaderProvider as am,
12490
+ getUploadedImageUrl as an,
12491
+ usePointUpContext as ao,
12492
+ PointUpProvider as ap,
12493
+ ButtonGroup as aq,
12494
+ SegmentedControl as ar,
12495
+ create as as,
12496
+ getWsClient as at,
12497
+ useSubscription as au,
12498
+ toast as av,
12499
+ isInArcSphere$1 as aw,
12500
+ isInArcSphereDialog as ax,
12501
+ openArcSphereDialog as ay,
12502
+ closeArcSphereDialog as az,
12489
12503
  Input as b,
12490
12504
  useChanged as c,
12491
12505
  useSessionContext as d,
12492
- utils as e,
12493
- preferences as f,
12506
+ useEventCallback as e,
12507
+ utils as f,
12494
12508
  getExcerptSync as g,
12495
- typography as h,
12509
+ preferences as h,
12496
12510
  inferInitialEditorState as i,
12497
- themeOverrides as j,
12498
- InternalThemeProvider as k,
12511
+ typography as j,
12512
+ themeOverrides as k,
12499
12513
  lexical as l,
12500
- Avatars as m,
12501
- AuthorInfo as n,
12502
- SystemUser as o,
12514
+ InternalThemeProvider as m,
12515
+ Avatars as n,
12516
+ AuthorInfo as o,
12503
12517
  preloadInput as p,
12504
- PostContent as q,
12518
+ SystemUser as q,
12505
12519
  routes as r,
12506
12520
  stringify as s,
12507
12521
  translations as t,
12508
12522
  useNow as u,
12509
- PostComponent as v,
12510
- Comment as w,
12511
- CommentList as x,
12512
- CommentsContext as y,
12513
- useCommentsContext as z
12523
+ PostContent as v,
12524
+ PostComponent as w,
12525
+ Comment as x,
12526
+ CommentList as y,
12527
+ CommentsContext as z
12514
12528
  };
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export * from './components/editor';
18
18
  export * as lexicalUtils from './components/lexical';
19
19
  export * from './components/dirty-prompt';
20
20
  export { translations } from './components/locale';
21
- export { useNow, useChanged, useSessionContext } from './components/hooks';
21
+ export { useNow, useChanged, useSessionContext, useEventCallback } from './components/hooks';
22
22
  export * as utils from './components/utils';
23
23
  export * as routes from './components/routes';
24
24
  export { default as preferences } from './preferences';
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, ay, ar, N, am, as, av, aw, l, ax, f, p, r, j, au, t, h, aa, az, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-D051_TWT.mjs";
2
+ import { U, o, X, A, n, ae, B, G, L, K, N, aq, Z, Y, a0, _, $, a2, x, C, y, z, F, a6, a7, ai, a9, Q, T, ad, D, ah, ag, J, H, b, m, af, M, P, ap, w, v, R, S, aa, ar, q, a3, a5, aj, am, al, az, as, O, an, at, aw, ax, l, ay, h, p, r, k, av, t, j, ab, aA, W, c, a1, E, a8, ac, e, u, ao, d, au, a4, ak, f } from "./index-B7y6yLro.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -9,88 +9,89 @@ import "@mui/icons-material";
9
9
  import "@arcblock/ux/lib/Locale/context";
10
10
  import "@mui/material";
11
11
  export {
12
- T as AccessControl,
13
- n as AuthorInfo,
14
- W as AuthzProvider,
12
+ U as AccessControl,
13
+ o as AuthorInfo,
14
+ X as AuthzProvider,
15
15
  A as Avatar,
16
- m as Avatars,
17
- ad as Back,
16
+ n as Avatars,
17
+ ae as Back,
18
18
  B as Badge,
19
- F as BinaryThumb,
20
- K as BlogCard,
21
- J as BlogList,
22
- L as BlogPermaLink,
23
- ap as ButtonGroup,
24
- Y as Chat,
25
- X as ChatClient,
26
- $ as ChatHeaderAddon,
27
- Z as ChatInWallet,
28
- _ as ChatListInWallet,
29
- a1 as ChatProvider,
30
- w as Comment,
19
+ G as BinaryThumb,
20
+ L as BlogCard,
21
+ K as BlogList,
22
+ N as BlogPermaLink,
23
+ aq as ButtonGroup,
24
+ Z as Chat,
25
+ Y as ChatClient,
26
+ a0 as ChatHeaderAddon,
27
+ _ as ChatInWallet,
28
+ $ as ChatListInWallet,
29
+ a2 as ChatProvider,
30
+ x as Comment,
31
31
  C as CommentInput,
32
- x as CommentList,
33
- y as CommentsContext,
34
- E as CommentsProvider,
35
- a5 as Confirm,
36
- a6 as ConfirmContext,
37
- ah as ConfirmNavigation,
38
- a8 as ConfirmProvider,
39
- O as CoverImage,
40
- Q as CoverImageUpload,
41
- ac as DefaultApiErrorHandler,
32
+ y as CommentList,
33
+ z as CommentsContext,
34
+ F as CommentsProvider,
35
+ a6 as Confirm,
36
+ a7 as ConfirmContext,
37
+ ai as ConfirmNavigation,
38
+ a9 as ConfirmProvider,
39
+ Q as CoverImage,
40
+ T as CoverImageUpload,
41
+ ad as DefaultApiErrorHandler,
42
42
  D as DefaultEditorConfigProvider,
43
- ag as DirtyPromptContainer,
44
- af as EditorPreview,
45
- H as EmptyStatus,
46
- G as GithubReaction,
43
+ ah as DirtyPromptContainer,
44
+ ag as EditorPreview,
45
+ J as EmptyStatus,
46
+ H as GithubReaction,
47
47
  b as Input,
48
- k as InternalThemeProvider,
49
- ae as LazyEditor,
48
+ m as InternalThemeProvider,
49
+ af as LazyEditor,
50
50
  M as Menu,
51
51
  P as Pagination,
52
- ao as PointUpProvider,
53
- v as Post,
54
- q as PostContent,
52
+ ap as PointUpProvider,
53
+ w as Post,
54
+ v as PostContent,
55
55
  R as RelativeTime,
56
56
  S as ScrollableEditorWrapper,
57
- a9 as SecureLabelPicker,
58
- aq as SegmentedControl,
59
- o as SystemUser,
60
- a2 as UnreadNotificationContext,
61
- a4 as UnreadNotificationProvider,
62
- ai as UploaderContext,
63
- al as UploaderProvider,
64
- ak as UploaderTrigger,
65
- ay as closeArcSphereDialog,
66
- ar as create,
67
- N as getBlogLink,
68
- am as getUploadedImageUrl,
69
- as as getWsClient,
70
- av as isInArcSphere,
71
- aw as isInArcSphereDialog,
57
+ aa as SecureLabelPicker,
58
+ ar as SegmentedControl,
59
+ q as SystemUser,
60
+ a3 as UnreadNotificationContext,
61
+ a5 as UnreadNotificationProvider,
62
+ aj as UploaderContext,
63
+ am as UploaderProvider,
64
+ al as UploaderTrigger,
65
+ az as closeArcSphereDialog,
66
+ as as create,
67
+ O as getBlogLink,
68
+ an as getUploadedImageUrl,
69
+ at as getWsClient,
70
+ aw as isInArcSphere,
71
+ ax as isInArcSphereDialog,
72
72
  l as lexicalUtils,
73
- ax as openArcSphereDialog,
74
- f as preferences,
73
+ ay as openArcSphereDialog,
74
+ h as preferences,
75
75
  p as preloadInput,
76
76
  r as routes,
77
- j as themeOverrides,
78
- au as toast,
77
+ k as themeOverrides,
78
+ av as toast,
79
79
  t as translations,
80
- h as typography,
81
- aa as useApiErrorHandler,
82
- az as useArcSphereDialog,
83
- U as useAuthzContext,
80
+ j as typography,
81
+ ab as useApiErrorHandler,
82
+ aA as useArcSphereDialog,
83
+ W as useAuthzContext,
84
84
  c as useChanged,
85
- a0 as useChatContext,
86
- z as useCommentsContext,
87
- a7 as useConfirm,
88
- ab as useDefaultApiErrorHandler,
85
+ a1 as useChatContext,
86
+ E as useCommentsContext,
87
+ a8 as useConfirm,
88
+ ac as useDefaultApiErrorHandler,
89
+ e as useEventCallback,
89
90
  u as useNow,
90
- an as usePointUpContext,
91
+ ao as usePointUpContext,
91
92
  d as useSessionContext,
92
- at as useSubscription,
93
- a3 as useUnreadNotification,
94
- aj as useUploader,
95
- e as utils
93
+ au as useSubscription,
94
+ a4 as useUnreadNotification,
95
+ ak as useUploader,
96
+ f as utils
96
97
  };
package/dist/index.umd.js CHANGED
@@ -1049,6 +1049,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1049
1049
  const r = useResponsive();
1050
1050
  return r(values2);
1051
1051
  };
1052
+ function useEventCallback(fn) {
1053
+ const ref = react.useRef();
1054
+ react.useLayoutEffect(() => {
1055
+ ref.current = fn;
1056
+ });
1057
+ return react.useCallback((...args) => {
1058
+ const { current } = ref;
1059
+ if (current == null) {
1060
+ throw new Error("callback created in useEventCallback can only be called from event handlers");
1061
+ }
1062
+ return current(...args);
1063
+ }, []);
1064
+ }
1052
1065
  const useChatInWallet = () => {
1053
1066
  var _a2;
1054
1067
  const navigate = reactRouterDom.useNavigate();
@@ -12459,6 +12472,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12459
12472
  exports2.useCommentsContext = useCommentsContext;
12460
12473
  exports2.useConfirm = useConfirm;
12461
12474
  exports2.useDefaultApiErrorHandler = useDefaultApiErrorHandler;
12475
+ exports2.useEventCallback = useEventCallback;
12462
12476
  exports2.useNow = useNow;
12463
12477
  exports2.usePointUpContext = usePointUpContext;
12464
12478
  exports2.useSessionContext = useSessionContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.1.199",
3
+ "version": "2.1.201",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -45,8 +45,8 @@
45
45
  "ufo": "^1.5.4",
46
46
  "unstated-next": "^1.1.0",
47
47
  "url-join": "^4.0.1",
48
- "@blocklet/editor": "^2.1.199",
49
- "@blocklet/labels": "^2.1.199"
48
+ "@blocklet/editor": "^2.1.201",
49
+ "@blocklet/labels": "^2.1.201"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@arcblock/did-connect": "^2.10.36",