@box/metadata-view 0.13.1 → 0.14.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,94 +1,95 @@
1
- import { FilterChip as l } from "@box/blueprint-web";
2
- import { Filter as g, MetadataBadge as p } from "@box/blueprint-web-assets/icons/Line";
3
- import { Formik as S, Form as b } from "formik";
4
- import { useState as v, useRef as w } from "react";
5
- import { useIntl as C } from "react-intl";
6
- import { StringFilterChip as I } from "./string-filter-chip.js";
7
- import j from "./messages.js";
1
+ import { FilterChip as a } from "@box/blueprint-web";
2
+ import { Filter as p, MetadataBadge as S } from "@box/blueprint-web-assets/icons/Line";
3
+ import { Formik as b, Form as v } from "formik";
4
+ import { useState as w, useRef as C } from "react";
5
+ import { useIntl as I } from "react-intl";
6
+ import { StringFilterChip as j } from "./string-filter-chip.js";
7
+ import k from "./messages.js";
8
8
  import { jsx as i, jsxs as c } from "react/jsx-runtime";
9
- const k = (e, s, n) => {
9
+ const x = (e, n, s) => {
10
10
  switch (e.fieldType) {
11
11
  case "float":
12
12
  case "string":
13
- return /* @__PURE__ */ i(I, {
14
- formRef: n,
13
+ return /* @__PURE__ */ i(j, {
14
+ formRef: s,
15
15
  id: e.id,
16
16
  name: e.name,
17
- selected: s
17
+ selected: n
18
18
  }, e.id);
19
19
  case "date":
20
20
  case "enum":
21
21
  case "multiSelect":
22
- return /* @__PURE__ */ c(l.Chip, {
22
+ return /* @__PURE__ */ c(a.Chip, {
23
23
  value: e.id,
24
- children: [/* @__PURE__ */ i(l.Icon, {
25
- icon: p
26
- }), /* @__PURE__ */ i(l.Label, {
24
+ children: [/* @__PURE__ */ i(a.Icon, {
25
+ icon: S
26
+ }), /* @__PURE__ */ i(a.Label, {
27
27
  children: e.name
28
28
  })]
29
29
  }, e.id);
30
30
  default:
31
31
  return null;
32
32
  }
33
- }, _ = ({
33
+ }, q = ({
34
34
  filterOptions: e,
35
+ isAllFiltersDisabled: n,
35
36
  onAllFiltersClick: s,
36
- onFilterSubmit: n
37
+ onFilterSubmit: d
37
38
  }) => {
38
39
  const {
39
- formatMessage: d
40
- } = C(), [u, o] = v([]), h = ([t, r]) => {
41
- var a;
42
- return ((a = r.value) == null ? void 0 : a.enum) && r.value.enum.length > 0;
43
- }, F = ({
40
+ formatMessage: u
41
+ } = I(), [o, h] = w([]), F = ([t, r]) => {
42
+ var l;
43
+ return ((l = r.value) == null ? void 0 : l.enum) && r.value.enum.length > 0;
44
+ }, f = ({
44
45
  metadata: {
45
46
  fields: t
46
47
  }
47
48
  }) => {
48
- const r = Object.entries(t).filter(h).map(([a]) => a);
49
- o(r), n(t);
50
- }, f = {
49
+ const r = Object.entries(t).filter(F).map(([l]) => l);
50
+ h(r), d(t);
51
+ }, g = {
51
52
  metadata: {
52
53
  fields: e.reduce((t, r) => {
53
- let a;
54
+ let l;
54
55
  switch (r.fieldType) {
55
56
  case "string":
56
57
  case "float":
57
- a = [""];
58
+ l = [""];
58
59
  break;
59
60
  default:
60
- a = null;
61
+ l = null;
61
62
  }
62
63
  return t[r.id] = {
63
- value: a
64
+ value: l
64
65
  }, t;
65
66
  }, {})
66
67
  }
67
- }, m = w(null);
68
- return /* @__PURE__ */ i(S, {
69
- initialValues: f,
70
- onSubmit: F,
71
- children: /* @__PURE__ */ i(b, {
68
+ }, m = C(null);
69
+ return /* @__PURE__ */ i(b, {
70
+ initialValues: g,
71
+ onSubmit: f,
72
+ children: /* @__PURE__ */ i(v, {
72
73
  ref: m,
73
- children: /* @__PURE__ */ c(l.Group, {
74
+ children: /* @__PURE__ */ c(a.Group, {
74
75
  name: "metadata-view-filters",
75
76
  type: "multiple",
76
- children: [/* @__PURE__ */ c(l.ChipButton, {
77
+ children: [n ? null : /* @__PURE__ */ c(a.ChipButton, {
77
78
  onClick: s,
78
79
  value: "all-filters-chip-btn",
79
- children: [/* @__PURE__ */ i(l.Icon, {
80
- icon: g
81
- }), /* @__PURE__ */ i(l.Label, {
82
- children: d(j.allFilters)
83
- }), e.length > 0 && /* @__PURE__ */ i(l.Status, {
80
+ children: [/* @__PURE__ */ i(a.Icon, {
81
+ icon: p
82
+ }), /* @__PURE__ */ i(a.Label, {
83
+ children: u(k.allFilters)
84
+ }), e.length > 0 && /* @__PURE__ */ i(a.Status, {
84
85
  children: e.length.toString()
85
86
  })]
86
- }), e.map((t) => k(t, u.includes(t.id), m))]
87
+ }), e.map((t) => x(t, o.includes(t.id), m))]
87
88
  })
88
89
  })
89
90
  });
90
91
  };
91
92
  export {
92
- _ as FilterRow,
93
- _ as default
93
+ q as FilterRow,
94
+ q as default
94
95
  };
@@ -2,8 +2,9 @@ import { MetadataTemplateField } from '@box/metadata-filter';
2
2
  import { FilterOption } from './types';
3
3
  export interface FilterRowProps {
4
4
  filterOptions: FilterOption[];
5
+ isAllFiltersDisabled?: boolean;
5
6
  onAllFiltersClick?: () => void;
6
7
  onFilterSubmit: (fields: MetadataTemplateField[]) => void;
7
8
  }
8
- export declare const FilterRow: ({ filterOptions, onAllFiltersClick, onFilterSubmit }: FilterRowProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const FilterRow: ({ filterOptions, isAllFiltersDisabled, onAllFiltersClick, onFilterSubmit, }: FilterRowProps) => import("react/jsx-runtime").JSX.Element;
9
10
  export default FilterRow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^11.12.0",
@@ -19,7 +19,7 @@
19
19
  "@box/blueprint-web-assets": "^4.55.0",
20
20
  "@box/eslint-plugin-blueprint": "*",
21
21
  "@box/item-icon": "^0.10.1",
22
- "@box/metadata-filter": "^1.10.1",
22
+ "@box/metadata-filter": "^1.11.0",
23
23
  "@box/storybook-utils": "0.13.8",
24
24
  "@box/types": "0.2.0",
25
25
  "react-intl": "^6.4.2"