@blocklet/discuss-kit-ux 1.6.160 → 1.6.162

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.
@@ -6,11 +6,11 @@ interface ButtonItem {
6
6
  interface Props {
7
7
  data: ButtonItem[];
8
8
  theme: string;
9
- selected: string[];
10
9
  urlName: string;
11
10
  defaultButton: ButtonItem;
12
11
  onSelectTab: (selectTab: string[]) => void;
13
12
  type: string;
13
+ urlParams: boolean;
14
14
  }
15
- export default function ButtonGroup({ data, theme, selected, urlName, defaultButton, onSelectTab, type, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
15
+ export default function ButtonGroup({ data, theme, urlName, defaultButton, urlParams, onSelectTab, type, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
16
16
  export {};
@@ -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 { lazy } from "react";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-bzFgbBTK.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-G56xwIdk.mjs";
8
8
  import "@blocklet/labels";
9
9
  import "@mui/material/styles";
10
10
  import "@mui/material/Box";
@@ -30,7 +30,7 @@ import DidAvatar from "@arcblock/did-connect/lib/Avatar";
30
30
  import useMediaQuery$1 from "@mui/material/useMediaQuery";
31
31
  import DID from "@arcblock/ux/lib/DID";
32
32
  import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
33
- import { useNavigate, Link, useLocation, useSearchParams, unstable_useBlocker } from "react-router-dom";
33
+ import { useNavigate, Link, useLocation, useSearchParams, unstable_useBlocker, useParams } from "react-router-dom";
34
34
  import UxRelativeTime from "@arcblock/ux/lib/RelativeTime";
35
35
  import Chip from "@mui/material/Chip";
36
36
  import Stack from "@mui/material/Stack";
@@ -4563,7 +4563,7 @@ function Pagination({ page, size = 20, total, onChange, routerMode = true, ...re
4563
4563
  }
4564
4564
  );
4565
4565
  }
4566
- const Editor = lazy(() => import("./editor-DQIO9RKL.mjs"));
4566
+ const Editor = lazy(() => import("./editor-zkz1ucq8.mjs"));
4567
4567
  function LazyEditor(props) {
4568
4568
  const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
4569
4569
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -10425,25 +10425,31 @@ function PointUpProvider({ children }) {
10425
10425
  function ButtonGroup({
10426
10426
  data,
10427
10427
  theme = "dark",
10428
- selected,
10429
10428
  urlName,
10430
10429
  defaultButton,
10430
+ urlParams = true,
10431
10431
  onSelectTab,
10432
10432
  type,
10433
10433
  ...rest
10434
10434
  }) {
10435
10435
  const downSm = useMediaQuery$1((mainTheme) => mainTheme.breakpoints.down("sm"));
10436
+ const navigate = useNavigate();
10436
10437
  const [searchParams, setSearchParams] = useSearchParams();
10438
+ const { boardId } = useParams();
10437
10439
  const selectedString = searchParams.get(urlName);
10438
- const dataWithDefault = defaultButton ? [defaultButton, ...data] : data;
10439
- const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault.map((item) => item.id);
10440
- const [selectTab, setSelectTab] = useState(selectedArray);
10440
+ const dataWithDefault = defaultButton && (data == null ? void 0 : data.length) > 0 ? [defaultButton, ...data] : data;
10441
+ const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id);
10442
+ const [selectTab, setSelectTab] = useState(urlParams ? selectedArray : [boardId]);
10441
10443
  const [selectAll, setSelectAll] = useState(false);
10442
10444
  const updateUrl = (url, newSelectTab) => {
10443
- setSearchParams({
10444
- ...searchParams,
10445
- [url]: newSelectTab.join(",")
10446
- });
10445
+ if (urlParams) {
10446
+ setSearchParams({
10447
+ ...searchParams,
10448
+ [url]: newSelectTab.join(",")
10449
+ });
10450
+ } else {
10451
+ navigate(`/${type}/boards/${newSelectTab.join(",")}`);
10452
+ }
10447
10453
  };
10448
10454
  const handleClick = (item) => {
10449
10455
  setSelectTab([item.id]);
@@ -10454,26 +10460,42 @@ function ButtonGroup({
10454
10460
  const newSelectAll = !prevSelectAll;
10455
10461
  const newSelectTab = newSelectAll ? dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id) : [];
10456
10462
  setSelectTab(newSelectTab);
10457
- updateUrl(urlName, newSelectTab);
10463
+ updateUrl(urlName, [""]);
10458
10464
  return newSelectAll;
10459
10465
  });
10460
10466
  };
10461
10467
  useEffect(() => {
10462
10468
  if (JSON.stringify(selectedArray) !== JSON.stringify(selectTab)) {
10463
- setSelectTab((selectedArray == null ? void 0 : selectedArray.length) > 0 ? selectedArray : []);
10469
+ if (urlParams) {
10470
+ setSelectTab(selectedArray || []);
10471
+ } else if (boardId) {
10472
+ if ((data == null ? void 0 : data.find((item) => item.id === boardId)) || boardId === "default") {
10473
+ setSelectTab([boardId]);
10474
+ } else {
10475
+ navigate(`/${type}/`);
10476
+ }
10477
+ } else {
10478
+ setSelectTab(dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id));
10479
+ }
10464
10480
  }
10465
- }, [data]);
10481
+ }, [data, boardId]);
10466
10482
  useEffect(() => {
10467
- if (selectedString === null || selectedString === "") {
10468
- setSelectAll(true);
10469
- } else if ((selectTab == null ? void 0 : selectTab.length) === (dataWithDefault == null ? void 0 : dataWithDefault.length)) {
10470
- setSelectAll(true);
10471
- } else {
10483
+ if (urlParams) {
10484
+ if (selectedString === null || selectedString === "") {
10485
+ setSelectAll(true);
10486
+ } else if ((selectTab == null ? void 0 : selectTab.length) === (dataWithDefault == null ? void 0 : dataWithDefault.length)) {
10487
+ setSelectAll(true);
10488
+ } else {
10489
+ setSelectAll(false);
10490
+ }
10491
+ } else if (boardId) {
10472
10492
  setSelectAll(false);
10493
+ } else {
10494
+ setSelectAll(true);
10473
10495
  }
10474
10496
  if (onSelectTab)
10475
10497
  onSelectTab(selectTab);
10476
- }, [selectTab, selectedArray]);
10498
+ }, [selectTab, selectedArray, boardId]);
10477
10499
  return /* @__PURE__ */ jsxs(Box$1, { className: Group, children: [
10478
10500
  /* @__PURE__ */ jsxs(
10479
10501
  Box$1,
@@ -10486,7 +10508,8 @@ function ButtonGroup({
10486
10508
  borderTopRightRadius: downSm ? 0 : "99999px",
10487
10509
  borderBottomRightRadius: downSm ? 0 : "99999px",
10488
10510
  overflow: "scroll",
10489
- whiteSpace: "nowrap"
10511
+ whiteSpace: "nowrap",
10512
+ mr: 2
10490
10513
  },
10491
10514
  children: [
10492
10515
  /* @__PURE__ */ jsx(
@@ -10503,7 +10526,7 @@ function ButtonGroup({
10503
10526
  }
10504
10527
  ),
10505
10528
  dataWithDefault == null ? void 0 : dataWithDefault.map((item, index) => {
10506
- const isActive = !selectAll && (selectTab == null ? void 0 : selectTab.includes(item.id));
10529
+ const isActive = urlParams ? !selectAll && (selectTab == null ? void 0 : selectTab.includes(item.id)) : boardId === item.id;
10507
10530
  return /* @__PURE__ */ jsx(
10508
10531
  Button$1,
10509
10532
  {
@@ -10534,7 +10557,7 @@ function ButtonGroup({
10534
10557
  component: Link,
10535
10558
  color: "inherit",
10536
10559
  size: "small",
10537
- to: `/discussions/boards?type=${type}`,
10560
+ to: `/boards?type=${type}`,
10538
10561
  sx: { color: "grey.500" },
10539
10562
  children: /* @__PURE__ */ jsx(BorderColorOutlined, { sx: { fontSize: 16 } })
10540
10563
  }
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { N, j, Q, A, h, a8, B, y, F, z, H, ak, U, T, W, Y, o, C, q, v, x, a0, a1, ac, a3, K, L, D, ab, aa, E, G, c, b, a9, M, P, aj, n, m, a7, R, S, a4, k, Z, $, ad, ag, af, ah, al, J, am, l, p, r, t, d, a5, O, e, X, w, a2, a6, u, ai, an, _, ae, f } from "./index-bzFgbBTK.mjs";
2
+ import { N, j, Q, A, h, a8, B, y, F, z, H, ak, U, T, W, Y, o, C, q, v, x, a0, a1, ac, a3, K, L, D, ab, aa, E, G, c, b, a9, M, P, aj, n, m, a7, R, S, a4, k, Z, $, ad, ag, af, ah, al, J, am, l, p, r, t, d, a5, O, e, X, w, a2, a6, u, ai, an, _, ae, f } from "./index-G56xwIdk.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -10362,25 +10362,31 @@ var __publicField = (obj, key, value) => {
10362
10362
  function ButtonGroup({
10363
10363
  data,
10364
10364
  theme = "dark",
10365
- selected,
10366
10365
  urlName,
10367
10366
  defaultButton,
10367
+ urlParams = true,
10368
10368
  onSelectTab,
10369
10369
  type,
10370
10370
  ...rest
10371
10371
  }) {
10372
10372
  const downSm = useMediaQuery((mainTheme) => mainTheme.breakpoints.down("sm"));
10373
+ const navigate = reactRouterDom.useNavigate();
10373
10374
  const [searchParams, setSearchParams] = reactRouterDom.useSearchParams();
10375
+ const { boardId } = reactRouterDom.useParams();
10374
10376
  const selectedString = searchParams.get(urlName);
10375
- const dataWithDefault = defaultButton ? [defaultButton, ...data] : data;
10376
- const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault.map((item) => item.id);
10377
- const [selectTab, setSelectTab] = react.useState(selectedArray);
10377
+ const dataWithDefault = defaultButton && (data == null ? void 0 : data.length) > 0 ? [defaultButton, ...data] : data;
10378
+ const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id);
10379
+ const [selectTab, setSelectTab] = react.useState(urlParams ? selectedArray : [boardId]);
10378
10380
  const [selectAll, setSelectAll] = react.useState(false);
10379
10381
  const updateUrl = (url, newSelectTab) => {
10380
- setSearchParams({
10381
- ...searchParams,
10382
- [url]: newSelectTab.join(",")
10383
- });
10382
+ if (urlParams) {
10383
+ setSearchParams({
10384
+ ...searchParams,
10385
+ [url]: newSelectTab.join(",")
10386
+ });
10387
+ } else {
10388
+ navigate(`/${type}/boards/${newSelectTab.join(",")}`);
10389
+ }
10384
10390
  };
10385
10391
  const handleClick = (item) => {
10386
10392
  setSelectTab([item.id]);
@@ -10391,26 +10397,42 @@ var __publicField = (obj, key, value) => {
10391
10397
  const newSelectAll = !prevSelectAll;
10392
10398
  const newSelectTab = newSelectAll ? dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id) : [];
10393
10399
  setSelectTab(newSelectTab);
10394
- updateUrl(urlName, newSelectTab);
10400
+ updateUrl(urlName, [""]);
10395
10401
  return newSelectAll;
10396
10402
  });
10397
10403
  };
10398
10404
  react.useEffect(() => {
10399
10405
  if (JSON.stringify(selectedArray) !== JSON.stringify(selectTab)) {
10400
- setSelectTab((selectedArray == null ? void 0 : selectedArray.length) > 0 ? selectedArray : []);
10406
+ if (urlParams) {
10407
+ setSelectTab(selectedArray || []);
10408
+ } else if (boardId) {
10409
+ if ((data == null ? void 0 : data.find((item) => item.id === boardId)) || boardId === "default") {
10410
+ setSelectTab([boardId]);
10411
+ } else {
10412
+ navigate(`/${type}/`);
10413
+ }
10414
+ } else {
10415
+ setSelectTab(dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id));
10416
+ }
10401
10417
  }
10402
- }, [data]);
10418
+ }, [data, boardId]);
10403
10419
  react.useEffect(() => {
10404
- if (selectedString === null || selectedString === "") {
10405
- setSelectAll(true);
10406
- } else if ((selectTab == null ? void 0 : selectTab.length) === (dataWithDefault == null ? void 0 : dataWithDefault.length)) {
10407
- setSelectAll(true);
10408
- } else {
10420
+ if (urlParams) {
10421
+ if (selectedString === null || selectedString === "") {
10422
+ setSelectAll(true);
10423
+ } else if ((selectTab == null ? void 0 : selectTab.length) === (dataWithDefault == null ? void 0 : dataWithDefault.length)) {
10424
+ setSelectAll(true);
10425
+ } else {
10426
+ setSelectAll(false);
10427
+ }
10428
+ } else if (boardId) {
10409
10429
  setSelectAll(false);
10430
+ } else {
10431
+ setSelectAll(true);
10410
10432
  }
10411
10433
  if (onSelectTab)
10412
10434
  onSelectTab(selectTab);
10413
- }, [selectTab, selectedArray]);
10435
+ }, [selectTab, selectedArray, boardId]);
10414
10436
  return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { className: Group, children: [
10415
10437
  /* @__PURE__ */ jsxRuntime.jsxs(
10416
10438
  material.Box,
@@ -10423,7 +10445,8 @@ var __publicField = (obj, key, value) => {
10423
10445
  borderTopRightRadius: downSm ? 0 : "99999px",
10424
10446
  borderBottomRightRadius: downSm ? 0 : "99999px",
10425
10447
  overflow: "scroll",
10426
- whiteSpace: "nowrap"
10448
+ whiteSpace: "nowrap",
10449
+ mr: 2
10427
10450
  },
10428
10451
  children: [
10429
10452
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -10440,7 +10463,7 @@ var __publicField = (obj, key, value) => {
10440
10463
  }
10441
10464
  ),
10442
10465
  dataWithDefault == null ? void 0 : dataWithDefault.map((item, index) => {
10443
- const isActive = !selectAll && (selectTab == null ? void 0 : selectTab.includes(item.id));
10466
+ const isActive = urlParams ? !selectAll && (selectTab == null ? void 0 : selectTab.includes(item.id)) : boardId === item.id;
10444
10467
  return /* @__PURE__ */ jsxRuntime.jsx(
10445
10468
  material.Button,
10446
10469
  {
@@ -10471,7 +10494,7 @@ var __publicField = (obj, key, value) => {
10471
10494
  component: reactRouterDom.Link,
10472
10495
  color: "inherit",
10473
10496
  size: "small",
10474
- to: `/discussions/boards?type=${type}`,
10497
+ to: `/boards?type=${type}`,
10475
10498
  sx: { color: "grey.500" },
10476
10499
  children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.BorderColorOutlined, { sx: { fontSize: 16 } })
10477
10500
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "1.6.160",
3
+ "version": "1.6.162",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@arcblock/ws": "^1.18.110",
32
- "@blocklet/editor": "1.6.160",
33
- "@blocklet/labels": "1.6.160",
32
+ "@blocklet/editor": "1.6.162",
33
+ "@blocklet/labels": "1.6.162",
34
34
  "@blocklet/uploader": "^0.0.73",
35
35
  "@emotion/css": "^11.10.5",
36
36
  "@emotion/react": "^11.10.5",
@@ -45,6 +45,7 @@
45
45
  "lexical": "0.13.1",
46
46
  "lottie-react": "^2.4.0",
47
47
  "mitt": "^3.0.0",
48
+ "react-flip-toolkit": "^7.1.0",
48
49
  "react-helmet": "^6.1.0",
49
50
  "react-select": "^5.6.0",
50
51
  "unstated-next": "^1.1.0",
@@ -83,7 +84,6 @@
83
84
  "babel-loader": "^8.3.0",
84
85
  "react": "^18.2.0",
85
86
  "react-dom": "^18.2.0",
86
- "react-flip-toolkit": "^7.1.0",
87
87
  "rollup-plugin-node-externals": "^5.1.3",
88
88
  "typescript": "^4.6.4",
89
89
  "unplugin-icons": "^0.14.14",
@@ -94,5 +94,5 @@
94
94
  "resolutions": {
95
95
  "react": "^18.2.0"
96
96
  },
97
- "gitHead": "e7de80eaeedb0621b5fa05110313615e93436d08"
97
+ "gitHead": "45ef63a2305bb38d8f278dc8e23667d71db5d187"
98
98
  }