@hybridcore/ui 1.4.37 → 1.4.38

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.
@@ -1,40 +1,44 @@
1
- import { jsx as g } from "react/jsx-runtime";
2
- import { useMemo as s, useState as f } from "react";
1
+ import { jsx as x } from "react/jsx-runtime";
2
+ import { useMemo as p, useState as g } from "react";
3
3
  import { TreeViewFilter as h } from "../../../treeview-filter/index.js";
4
- import { getNestedChildrenFromMap as x } from "../../../../utils/ontology.js";
4
+ import { getNestedChildrenFromMap as y } from "../../../../utils/ontology.js";
5
5
  const O = ({
6
- templates: l,
7
- filters: n,
8
- onChange: r
6
+ templates: r,
7
+ filters: a,
8
+ defaultExpanded: d = [],
9
+ onChange: s
9
10
  }) => {
10
- const i = s(() => x(l), [l]), p = s(
11
- () => n.map((e) => e.templateKey),
12
- [n]
13
- ), [d, m] = f([]);
14
- return /* @__PURE__ */ g(
11
+ const m = p(() => y(r), [r]), f = p(
12
+ () => a.map((n) => n.templateKey),
13
+ [a]
14
+ ), [c, i] = g(d);
15
+ return /* @__PURE__ */ x(
15
16
  h,
16
17
  {
17
- data: i,
18
- onChange: (e, o) => {
19
- let t = [...n];
18
+ data: m,
19
+ onChange: (n, o) => {
20
+ let e = [...a];
20
21
  if (o)
21
- t.push({
22
- templateKey: e,
22
+ e.push({
23
+ templateKey: n,
23
24
  filterOperator: "AND",
24
25
  filters: [],
25
26
  exclusionTemplateKeys: []
26
27
  });
27
28
  else {
28
- const a = t.findIndex((c) => c.templateKey === e);
29
- a !== -1 && t.splice(a, 1);
29
+ const t = e.findIndex((l) => l.templateKey === n);
30
+ t !== -1 && e.splice(t, 1);
30
31
  }
31
- r && r(t);
32
+ s && s(e);
32
33
  },
33
34
  idKey: "templateKey",
34
- selected: p,
35
- expanded: d,
36
- onToggle: (e, o) => {
37
- m(o);
35
+ selected: f,
36
+ expanded: c,
37
+ onExpansionToggle: (n, o, e) => {
38
+ i(e ? (t) => [
39
+ ...t.filter((l) => l !== o),
40
+ o
41
+ ] : (t) => t.filter((l) => l !== o));
38
42
  }
39
43
  }
40
44
  );
@@ -1,70 +1,73 @@
1
- import { jsxs as p, Fragment as _, jsx as n } from "react/jsx-runtime";
2
- import f from "react";
3
- import { TreeViewFilter as b } from "../treeview-filter/index.js";
4
- import r from "lodash";
5
- import { flattenNestedTemplates as A } from "../../utils/ontology.js";
6
- import { F as E, I as M } from "../../InputLabel-ClDXuWBr.js";
1
+ import { jsxs as h, Fragment as W, jsx as o } from "react/jsx-runtime";
2
+ import u from "react";
3
+ import { TreeViewFilter as _ } from "../treeview-filter/index.js";
4
+ import s from "lodash";
5
+ import { flattenNestedTemplates as b } from "../../utils/ontology.js";
6
+ import { F as A, I as M } from "../../InputLabel-ClDXuWBr.js";
7
7
  import { S as j } from "../../Select-ush_fSWy.js";
8
8
  import { M as B } from "../../MenuItem-Lcjh1XlV.js";
9
9
  import { D as k, a as w, b as L } from "../../DialogContent-CtA2aNum.js";
10
10
  import { B as N } from "../../Button-jy67CcTH.js";
11
11
  const U = ({
12
12
  data: m,
13
- label: s,
14
- selected: o,
15
- disabled: C,
16
- idKey: l = "id",
17
- variant: h = "outlined",
18
- onChange: S
13
+ label: c,
14
+ selected: r,
15
+ disabled: S,
16
+ idKey: i = "id",
17
+ variant: g = "outlined",
18
+ onChange: D
19
19
  }) => {
20
- const [D, u] = f.useState(!1), [I, g] = f.useState([]), i = A(m), a = f.useMemo(() => r.isArray(o) ? o.map(
21
- (e) => i.find((t) => String(r.get(t, l)) === e)
22
- ) : [], [o, i]), v = (e, t) => {
23
- S(e, t);
24
- }, T = () => {
25
- u(!0), O();
26
- }, x = () => {
27
- u(!1);
28
- }, F = (e, t) => {
29
- g(t);
20
+ const [v, x] = u.useState(!1), [E, d] = u.useState([]), f = b(m), p = u.useMemo(() => s.isArray(r) ? r.map(
21
+ (n) => f.find((e) => String(s.get(e, i)) === n)
22
+ ) : [], [r, f]), T = (n, e) => {
23
+ D(n, e);
24
+ }, F = () => {
25
+ x(!0), O();
26
+ }, C = () => {
27
+ x(!1);
28
+ }, I = (n, e, l) => {
29
+ d(l ? (a) => [
30
+ ...a.filter((t) => t !== e),
31
+ e
32
+ ] : (a) => a.filter((t) => t !== e));
30
33
  }, O = () => {
31
- const e = [];
32
- a.length > 0 && a.forEach((t) => {
33
- const d = t == null ? void 0 : t.parentKeys, W = i.filter((c) => d == null ? void 0 : d.includes(c.templateKey)).map((c) => String(r.get(c, l)));
34
- e.push(...W);
35
- }), g(e);
34
+ const n = [];
35
+ p.length > 0 && p.forEach((e) => {
36
+ const l = e == null ? void 0 : e.parentKeys, a = f.filter((t) => l == null ? void 0 : l.includes(t.templateKey)).map((t) => String(s.get(t, i)));
37
+ n.push(...a);
38
+ }), d(n);
36
39
  };
37
- return /* @__PURE__ */ p(_, { children: [
38
- /* @__PURE__ */ p(E, { variant: h, fullWidth: !0, children: [
39
- s !== void 0 && /* @__PURE__ */ n(M, { id: "select-label", children: s }),
40
- /* @__PURE__ */ n(
40
+ return /* @__PURE__ */ h(W, { children: [
41
+ /* @__PURE__ */ h(A, { variant: g, fullWidth: !0, children: [
42
+ c !== void 0 && /* @__PURE__ */ o(M, { id: "select-label", children: c }),
43
+ /* @__PURE__ */ o(
41
44
  j,
42
45
  {
43
- label: s,
44
- variant: h,
46
+ label: c,
47
+ variant: g,
45
48
  id: "select",
46
49
  labelId: "select-label",
47
- value: o,
50
+ value: r,
48
51
  open: !1,
49
- onOpen: T,
50
- children: a.length > 0 && a.map((e, t) => /* @__PURE__ */ n(B, { value: r.get(e, l) ?? "", children: e == null ? void 0 : e.name }, t))
52
+ onOpen: F,
53
+ children: p.length > 0 && p.map((n, e) => /* @__PURE__ */ o(B, { value: s.get(n, i) ?? "", children: n == null ? void 0 : n.name }, e))
51
54
  }
52
55
  )
53
56
  ] }),
54
- /* @__PURE__ */ p(k, { open: D, onClose: x, fullWidth: !0, maxWidth: "sm", children: [
55
- /* @__PURE__ */ n(w, { sx: { p: 1, pt: 2 }, children: /* @__PURE__ */ n(
56
- b,
57
+ /* @__PURE__ */ h(k, { open: v, onClose: C, fullWidth: !0, maxWidth: "sm", children: [
58
+ /* @__PURE__ */ o(w, { sx: { p: 1, pt: 2 }, children: /* @__PURE__ */ o(
59
+ _,
57
60
  {
58
61
  data: m,
59
- selected: r.isArray(o) ? o : void 0,
60
- disabled: C,
61
- expanded: I,
62
- idKey: l,
63
- onToggle: F,
64
- onChange: v
62
+ selected: s.isArray(r) ? r : void 0,
63
+ disabled: S,
64
+ expanded: E,
65
+ idKey: i,
66
+ onExpansionToggle: I,
67
+ onChange: T
65
68
  }
66
69
  ) }),
67
- /* @__PURE__ */ n(L, { children: /* @__PURE__ */ n(N, { onClick: x, variant: "contained", fullWidth: !0, children: "OK" }) })
70
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(N, { onClick: C, variant: "contained", fullWidth: !0, children: "OK" }) })
68
71
  ] })
69
72
  ] });
70
73
  };
@@ -1,29 +1,31 @@
1
- import { jsxs as c, Fragment as m, jsx as t } from "react/jsx-runtime";
2
- import d from "react";
3
- import { SimpleTreeView as D } from "@mui/x-tree-view";
4
- import I from "./item/index.js";
5
- import p from "lodash";
6
- import { Box as C, Divider as F } from "@mui/material";
7
- import { SearchInput as L } from "../search-input/index.js";
8
- import { flattenNestedTemplates as _ } from "../../utils/ontology.js";
9
- const R = ({
10
- data: l,
11
- idKey: n = "id",
12
- selected: a,
13
- // expanded,
14
- disabled: s,
15
- disableSearch: u,
16
- onChange: f
1
+ import { jsxs as c, Fragment as d, jsx as t } from "react/jsx-runtime";
2
+ import p from "react";
3
+ import { SimpleTreeView as C } from "@mui/x-tree-view";
4
+ import F from "./item/index.js";
5
+ import u from "lodash";
6
+ import { Box as L, Divider as _ } from "@mui/material";
7
+ import { SearchInput as j } from "../search-input/index.js";
8
+ import { flattenNestedTemplates as z } from "../../utils/ontology.js";
9
+ import { ArrowDropDown as A, ArrowRight as B } from "@mui/icons-material";
10
+ const H = ({
11
+ data: r,
12
+ idKey: a = "id",
13
+ selected: s,
14
+ expanded: f,
15
+ disabled: m,
16
+ disableSearch: h,
17
+ onChange: S,
18
+ onExpansionToggle: x
17
19
  }) => {
18
- const [i, h] = d.useState(""), S = _(l), x = d.useMemo(() => i.length > 0 ? S.filter(
19
- (e) => e.name.toLowerCase().includes(i)
20
- ) : l, [i, l]);
21
- let o = null;
22
- const b = 500;
23
- return /* @__PURE__ */ c(m, { children: [
24
- !u && /* @__PURE__ */ c(m, { children: [
25
- /* @__PURE__ */ t(C, { px: 1, pt: 0.75, children: /* @__PURE__ */ t(
26
- L,
20
+ const [o, i] = p.useState(""), b = z(r), w = p.useMemo(() => o.length > 0 ? b.filter(
21
+ (e) => e.name.toLowerCase().includes(o)
22
+ ) : r, [o, r]);
23
+ let l = null;
24
+ const I = 500;
25
+ return /* @__PURE__ */ c(d, { children: [
26
+ !h && /* @__PURE__ */ c(d, { children: [
27
+ /* @__PURE__ */ t(L, { px: 1, pt: 0.75, children: /* @__PURE__ */ t(
28
+ j,
27
29
  {
28
30
  fullWidth: !0,
29
31
  disableLabel: !0,
@@ -36,33 +38,42 @@ const R = ({
36
38
  },
37
39
  iconSize: "small",
38
40
  onChange: (e) => {
39
- o && clearTimeout(o), o = setTimeout(() => h(e.toLowerCase()), b);
41
+ l && clearTimeout(l), l = setTimeout(() => i(e.toLowerCase()), I);
42
+ },
43
+ onSubmit: (e) => {
44
+ i(e || "");
40
45
  }
41
46
  }
42
47
  ) }),
43
- /* @__PURE__ */ t(F, { sx: { mt: 1.75 } })
48
+ /* @__PURE__ */ t(_, { sx: { mt: 1.75 } })
44
49
  ] }),
45
50
  /* @__PURE__ */ t(
46
- D,
51
+ C,
47
52
  {
48
53
  "aria-label": "tree view filter",
49
54
  disableSelection: !0,
50
- children: x.map((e, T) => {
51
- const r = String(e[n]), g = p.includes(a, r), w = p.includes(s, r);
52
- return console.log({ id: r }), /* @__PURE__ */ t(
53
- I,
55
+ defaultExpandedItems: f,
56
+ slots: {
57
+ collapseIcon: () => /* @__PURE__ */ t(A, {}),
58
+ expandIcon: () => /* @__PURE__ */ t(B, {})
59
+ },
60
+ onItemExpansionToggle: x,
61
+ children: w.map((e, g) => {
62
+ const n = String(e[a]), T = u.includes(s, n), D = u.includes(m, n);
63
+ return /* @__PURE__ */ t(
64
+ F,
54
65
  {
55
- id: r,
56
- idKey: n,
66
+ id: n,
67
+ idKey: a,
57
68
  name: e.name,
58
- checked: g,
59
- disabled: w,
60
- disabledIds: s,
69
+ checked: T,
70
+ disabled: D,
71
+ disabledIds: m,
61
72
  children: e.children,
62
- onChange: f,
63
- defaultSelected: a
73
+ onChange: S,
74
+ defaultSelected: s
64
75
  },
65
- T
76
+ g
66
77
  );
67
78
  })
68
79
  }
@@ -70,5 +81,5 @@ const R = ({
70
81
  ] });
71
82
  };
72
83
  export {
73
- R as TreeViewFilter
84
+ H as TreeViewFilter
74
85
  };
@@ -1,53 +1,49 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import g from "../item-label/index.js";
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import I from "../item-label/index.js";
3
3
  import a from "lodash";
4
- import { ArrowRight as I } from "@mui/icons-material";
5
4
  import { TreeItem as h } from "./styled.js";
6
5
  function x({
7
- id: i,
6
+ id: m,
8
7
  idKey: n,
9
- name: f,
10
- checked: e,
11
- disabled: l,
12
- disabledIds: c,
13
- onChange: s,
14
- children: r,
15
- defaultSelected: p
8
+ name: p,
9
+ checked: i,
10
+ disabled: d,
11
+ disabledIds: o,
12
+ onChange: c,
13
+ children: s,
14
+ defaultSelected: l
16
15
  }) {
17
- return /* @__PURE__ */ t(
16
+ return /* @__PURE__ */ e(
18
17
  h,
19
18
  {
20
- itemId: String(i),
21
- label: /* @__PURE__ */ t(
22
- g,
19
+ itemId: String(m),
20
+ label: /* @__PURE__ */ e(
21
+ I,
23
22
  {
24
- id: i,
25
- name: f,
26
- checked: e,
27
- disabled: l,
28
- onChange: s
23
+ id: m,
24
+ name: p,
25
+ checked: i,
26
+ disabled: d,
27
+ onChange: c
29
28
  }
30
29
  ),
31
- checked: e,
32
- ...r && r.length > 0 && {
33
- icon: /* @__PURE__ */ t(I, {})
34
- },
35
- children: r && r.map((o, u) => {
36
- const m = String(o[n]), b = a.includes(p, m), d = a.includes(c, m);
37
- return /* @__PURE__ */ t(
30
+ checked: i,
31
+ children: s && s.map((r, f) => {
32
+ const t = String(r[n]), u = a.includes(l, t), b = a.includes(o, t);
33
+ return /* @__PURE__ */ e(
38
34
  x,
39
35
  {
40
- id: m,
36
+ id: t,
41
37
  idKey: n,
42
- name: o.name,
43
- checked: b,
44
- disabled: d,
45
- disabledIds: c,
46
- children: o.children,
47
- onChange: s,
48
- defaultSelected: p
38
+ name: r.name,
39
+ checked: u,
40
+ disabled: b,
41
+ disabledIds: o,
42
+ children: r.children,
43
+ onChange: c,
44
+ defaultSelected: l
49
45
  },
50
- u
46
+ f
51
47
  );
52
48
  })
53
49
  }
@@ -1,13 +1,14 @@
1
- import { TreeItem as t } from "@mui/x-tree-view";
2
- import { styled as r, alpha as i } from "@mui/material";
3
- const m = r(t)(
4
- ({ theme: e, checked: o }) => ({
1
+ import { TreeItem as r } from "@mui/x-tree-view";
2
+ import { styled as t, alpha as i } from "@mui/material";
3
+ const l = t(r)(
4
+ ({ theme: o, checked: e }) => ({
5
5
  position: "relative",
6
6
  "& .MuiTreeItem-content": {
7
7
  flexDirection: "row-reverse",
8
8
  borderBottom: "1px solid",
9
- borderBottomColor: e.palette.divider,
10
- boxSizing: "border-box"
9
+ borderBottomColor: o.palette.divider,
10
+ boxSizing: "border-box",
11
+ borderRadius: 0
11
12
  },
12
13
  "& .MuiTreeItem-iconContainer": {
13
14
  transition: ".3s all",
@@ -15,10 +16,10 @@ const m = r(t)(
15
16
  fontSize: "20px !important"
16
17
  }
17
18
  },
18
- "& .MuiTreeItem-content.Mui-expanded .MuiTreeItem-iconContainer": {
19
- // transform: "rotate(90deg)",
20
- },
21
- ...o && {
19
+ // "& .MuiTreeItem-content.Mui-expanded .MuiTreeItem-iconContainer": {
20
+ // // transform: "rotate(90deg)",
21
+ // },
22
+ ...e && {
22
23
  "&:before": {
23
24
  content: '""',
24
25
  position: "absolute",
@@ -27,12 +28,12 @@ const m = r(t)(
27
28
  bottom: 0,
28
29
  right: 0,
29
30
  borderLeft: "1px solid",
30
- borderLeftColor: e.palette.primary.main,
31
- backgroundColor: i(e.palette.primary.main, 0.1)
31
+ borderLeftColor: o.palette.primary.main,
32
+ backgroundColor: i(o.palette.primary.main, 0.1)
32
33
  }
33
34
  }
34
35
  })
35
36
  );
36
37
  export {
37
- m as TreeItem
38
+ l as TreeItem
38
39
  };
@@ -9,7 +9,7 @@ function u({
9
9
  disabled: r,
10
10
  onChange: a
11
11
  }) {
12
- return /* @__PURE__ */ l(s, { display: "flex", alignItems: "center", py: 1, children: [
12
+ return /* @__PURE__ */ l(s, { display: "flex", alignItems: "center", children: [
13
13
  /* @__PURE__ */ e(
14
14
  p,
15
15
  {
package/dist/main.d.ts CHANGED
@@ -585,7 +585,11 @@ declare interface Props_11 {
585
585
  disabled?: string[];
586
586
  disableSearch?: boolean;
587
587
  onChange?(id: string, checked: boolean): void;
588
- onToggle?(event: React.SyntheticEvent, nodeIds: string[]): void;
588
+ onExpansionToggle?(
589
+ event: React.SyntheticEvent,
590
+ itemId: string,
591
+ isExpanded: boolean
592
+ ): void;
589
593
  }
590
594
 
591
595
  declare interface Props_2 {
@@ -815,6 +819,7 @@ declare interface TabItem {
815
819
  label: default_2.ReactNode;
816
820
  templates: Map<string | number, ONTOLOGY.TemplateType>;
817
821
  filters: FV.TemplateFilter[];
822
+ defaultExpanded?: string[];
818
823
  onChange: (filters: FV.TemplateFilter[]) => void;
819
824
  }
820
825
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridcore/ui",
3
3
  "description": "Hybrid Core UI Library",
4
- "version": "1.4.37",
4
+ "version": "1.4.38",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",