@box/metadata-view 0.18.1 → 0.19.0

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,83 +1,86 @@
1
- import { FilterChip as r } from "@box/blueprint-web";
2
- import { MetadataBadge as p } from "@box/blueprint-web-assets/icons/Line";
3
- import { Formik as f, Form as S } from "formik";
4
- import { useState as g, useRef as v } from "react";
5
- import b from "./all-filters-chip.js";
6
- import { StringFilterChip as w } from "./string-filter-chip.js";
7
- import { jsx as i, jsxs as d } from "react/jsx-runtime";
8
- const C = (e, s, c) => {
1
+ import { FilterChip as s } from "@box/blueprint-web";
2
+ import { Formik as p, Form as f } from "formik";
3
+ import { useState as S, useRef as g } from "react";
4
+ import v from "./all-filters-chip.js";
5
+ import { StringFilterChip as b } from "./string-filter-chip.js";
6
+ import { jsx as r, jsxs as d } from "react/jsx-runtime";
7
+ const w = (e, c, n) => {
8
+ const {
9
+ icon: i
10
+ } = e;
9
11
  switch (e.fieldType) {
10
12
  case "float":
11
13
  case "string":
12
- return /* @__PURE__ */ i(w, {
13
- formRef: c,
14
+ return /* @__PURE__ */ r(b, {
15
+ formRef: n,
16
+ icon: i,
14
17
  id: e.id,
15
18
  name: e.name,
16
- selected: s
19
+ selected: c
17
20
  }, e.id);
18
21
  case "date":
19
22
  case "enum":
20
23
  case "multiSelect":
21
- return /* @__PURE__ */ d(r.Chip, {
24
+ return /* @__PURE__ */ d(s.Chip, {
22
25
  value: e.id,
23
- children: [/* @__PURE__ */ i(r.Icon, {
24
- icon: p
25
- }), /* @__PURE__ */ i(r.Label, {
26
+ children: [i && /* @__PURE__ */ r(s.Icon, {
27
+ icon: i
28
+ }), /* @__PURE__ */ r(s.Label, {
26
29
  children: e.name
27
30
  })]
28
31
  }, e.id);
29
32
  default:
30
33
  return null;
31
34
  }
32
- }, G = ({
35
+ }, T = ({
33
36
  filterOptions: e,
34
- isAllFiltersDisabled: s,
35
- onFilterSubmit: c
37
+ isAllFiltersDisabled: c,
38
+ onFilterSubmit: n
36
39
  }) => {
37
- const [n, u] = g([]), o = ([t, l]) => {
38
- var a;
39
- return ((a = l.value) == null ? void 0 : a.enum) && l.value.enum.length > 0;
40
+ const [i, u] = S([]), o = ([t, a]) => {
41
+ var l;
42
+ return ((l = a.value) == null ? void 0 : l.enum) && a.value.enum.length > 0;
40
43
  }, h = ({
41
44
  metadata: {
42
45
  fields: t
43
46
  }
44
47
  }) => {
45
- const l = Object.entries(t).filter(o).map(([a]) => a);
46
- u(l), c(t);
48
+ const a = Object.entries(t).filter(o).map(([l]) => l);
49
+ u(a), n(t);
47
50
  }, F = {
48
51
  metadata: {
49
- fields: e.reduce((t, l) => {
50
- let a;
51
- switch (l.fieldType) {
52
+ fields: e.reduce((t, a) => {
53
+ let l;
54
+ switch (a.fieldType) {
52
55
  case "string":
53
56
  case "float":
54
- a = [""];
57
+ l = [""];
55
58
  break;
56
59
  default:
57
- a = null;
60
+ l = null;
58
61
  }
59
- return t[l.id] = {
60
- value: a
62
+ return t[a.id] = {
63
+ value: l
61
64
  }, t;
62
65
  }, {})
63
66
  }
64
- }, m = v(null);
65
- return /* @__PURE__ */ i(f, {
67
+ }, m = g(null);
68
+ return /* @__PURE__ */ r(p, {
66
69
  initialValues: F,
67
70
  onSubmit: h,
68
- children: /* @__PURE__ */ i(S, {
71
+ children: /* @__PURE__ */ r(f, {
69
72
  ref: m,
70
- children: /* @__PURE__ */ d(r.Group, {
73
+ children: /* @__PURE__ */ d(s.Group, {
71
74
  name: "metadata-view-filters",
72
75
  type: "multiple",
73
- children: [s ? null : /* @__PURE__ */ i(b, {
74
- activeFilterCount: n.length
75
- }), e.map((t) => C(t, n.includes(t.id), m))]
76
+ children: [c ? null : /* @__PURE__ */ r(v, {
77
+ activeFilterCount: i.length
78
+ }), e.map((t) => w(t, i.includes(t.id), m))]
76
79
  })
77
80
  })
78
81
  });
79
82
  };
80
83
  export {
81
- G as FilterRow,
82
- G as default
84
+ T as FilterRow,
85
+ T as default
83
86
  };
@@ -1,61 +1,61 @@
1
- import { Popover as o, FilterChip as t, Button as p } from "@box/blueprint-web";
2
- import { MetadataBadge as u } from "@box/blueprint-web-assets/icons/Line";
3
- import { MetadataStringField as g } from "@box/metadata-filter";
4
- import { useState as v } from "react";
1
+ import { Popover as o, FilterChip as t, Button as m } from "@box/blueprint-web";
2
+ import { MetadataStringField as v } from "@box/metadata-filter";
3
+ import { useState as g } from "react";
5
4
  import { useIntl as F } from "react-intl";
6
5
  import { useFormikContext as C } from "formik";
7
- import m from "./messages.js";
6
+ import c from "./messages.js";
8
7
  import { jsx as e, jsxs as n } from "react/jsx-runtime";
9
8
  import '../../../../styles/string-filter-chip.css';const b = "_popoverFooter_1tgko_1", k = {
10
9
  popoverFooter: b
11
- }, _ = ({
12
- formRef: c,
10
+ }, P = ({
11
+ formRef: d,
13
12
  id: r,
14
13
  name: i,
15
- selected: d
14
+ selected: f,
15
+ icon: a
16
16
  }) => {
17
17
  const {
18
- formatMessage: a
19
- } = F(), [f, l] = v(!1), s = C(), h = () => {
20
- s.handleSubmit(), l(!1);
18
+ formatMessage: l
19
+ } = F(), [h, s] = g(!1), p = C(), u = () => {
20
+ p.handleSubmit(), s(!1);
21
21
  };
22
22
  return /* @__PURE__ */ e("div", {
23
23
  children: /* @__PURE__ */ n(o.Root, {
24
- onOpenChange: l,
25
- open: f,
24
+ onOpenChange: s,
25
+ open: h,
26
26
  children: [/* @__PURE__ */ e(o.Trigger, {
27
27
  children: /* @__PURE__ */ n(t.TriggerChip, {
28
- selected: d,
28
+ selected: f,
29
29
  value: r,
30
- children: [/* @__PURE__ */ e(t.Icon, {
31
- icon: u
30
+ children: [a && /* @__PURE__ */ e(t.Icon, {
31
+ icon: a
32
32
  }), /* @__PURE__ */ e(t.Label, {
33
33
  children: i
34
34
  }), /* @__PURE__ */ e(t.DropdownIndicator, {})]
35
35
  }, r)
36
36
  }), /* @__PURE__ */ n(o.ContentContainer, {
37
37
  align: "start",
38
- container: c.current,
38
+ container: d.current,
39
39
  children: [/* @__PURE__ */ e(o.MainContent, {
40
- children: /* @__PURE__ */ e(g, {
40
+ children: /* @__PURE__ */ e(v, {
41
41
  fieldNamePrefix: `metadata.fields.${r}`,
42
42
  label: i
43
43
  })
44
44
  }), /* @__PURE__ */ n(o.Footer, {
45
45
  className: k.popoverFooter,
46
- children: [/* @__PURE__ */ e(p, {
46
+ children: [/* @__PURE__ */ e(m, {
47
47
  onClick: () => {
48
- s.setFieldValue(`metadata.fields.${r}.value.enum`, []);
48
+ p.setFieldValue(`metadata.fields.${r}.value.enum`, []);
49
49
  },
50
50
  size: "small",
51
51
  variant: "secondary",
52
- children: a(m.clearButton)
53
- }), /* @__PURE__ */ e(p, {
54
- onClick: h,
52
+ children: l(c.clearButton)
53
+ }), /* @__PURE__ */ e(m, {
54
+ onClick: u,
55
55
  size: "small",
56
56
  type: "submit",
57
57
  variant: "primary",
58
- children: a(m.applyButton)
58
+ children: l(c.applyButton)
59
59
  })]
60
60
  })]
61
61
  })]
@@ -63,5 +63,5 @@ import '../../../../styles/string-filter-chip.css';const b = "_popoverFooter_1tg
63
63
  });
64
64
  };
65
65
  export {
66
- _ as StringFilterChip
66
+ P as StringFilterChip
67
67
  };
@@ -1,2 +1,2 @@
1
1
  import { FilterChipProps } from './types';
2
- export declare const StringFilterChip: ({ formRef, id, name, selected }: FilterChipProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const StringFilterChip: ({ formRef, id, name, selected, icon }: FilterChipProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,10 +4,12 @@ export interface FilterOption {
4
4
  name: string;
5
5
  fieldType: MetadataFieldType;
6
6
  selected: boolean;
7
+ icon?: React.ForwardRefExoticComponent<Omit<React.SVGProps<SVGSVGElement>, 'ref'> & React.RefAttributes<SVGSVGElement>>;
7
8
  }
8
9
  export interface FilterChipProps {
9
10
  formRef: React.RefObject<HTMLFormElement>;
10
11
  id: string;
11
12
  name: string;
12
13
  selected: boolean;
14
+ icon?: React.ForwardRefExoticComponent<Omit<React.SVGProps<SVGSVGElement>, 'ref'> & React.RefAttributes<SVGSVGElement>>;
13
15
  }
@@ -5,6 +5,7 @@ export declare const mockActiveFilterIds: string[];
5
5
  export declare const mockColumnData: Column[];
6
6
  export declare const mockFilterOptions: FilterOption[];
7
7
  export declare const mockFilterOptionsNoSelection: FilterOption[];
8
+ export declare const mockFilterOptionsWithCustomFilterChips: FilterOption[];
8
9
  export declare const mockFilterOptionsWithInvalidType: FilterOption[];
9
10
  export declare const mockMetadata: Item[];
10
11
  export declare const mockFilterRowArgs: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^11.12.0",