@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
|
|
2
|
-
import { Filter as
|
|
3
|
-
import { Formik as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { StringFilterChip as
|
|
7
|
-
import
|
|
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
|
|
9
|
+
const x = (e, n, s) => {
|
|
10
10
|
switch (e.fieldType) {
|
|
11
11
|
case "float":
|
|
12
12
|
case "string":
|
|
13
|
-
return /* @__PURE__ */ i(
|
|
14
|
-
formRef:
|
|
13
|
+
return /* @__PURE__ */ i(j, {
|
|
14
|
+
formRef: s,
|
|
15
15
|
id: e.id,
|
|
16
16
|
name: e.name,
|
|
17
|
-
selected:
|
|
17
|
+
selected: n
|
|
18
18
|
}, e.id);
|
|
19
19
|
case "date":
|
|
20
20
|
case "enum":
|
|
21
21
|
case "multiSelect":
|
|
22
|
-
return /* @__PURE__ */ c(
|
|
22
|
+
return /* @__PURE__ */ c(a.Chip, {
|
|
23
23
|
value: e.id,
|
|
24
|
-
children: [/* @__PURE__ */ i(
|
|
25
|
-
icon:
|
|
26
|
-
}), /* @__PURE__ */ i(
|
|
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:
|
|
37
|
+
onFilterSubmit: d
|
|
37
38
|
}) => {
|
|
38
39
|
const {
|
|
39
|
-
formatMessage:
|
|
40
|
-
} =
|
|
41
|
-
var
|
|
42
|
-
return ((
|
|
43
|
-
},
|
|
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(
|
|
49
|
-
|
|
50
|
-
},
|
|
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
|
|
54
|
+
let l;
|
|
54
55
|
switch (r.fieldType) {
|
|
55
56
|
case "string":
|
|
56
57
|
case "float":
|
|
57
|
-
|
|
58
|
+
l = [""];
|
|
58
59
|
break;
|
|
59
60
|
default:
|
|
60
|
-
|
|
61
|
+
l = null;
|
|
61
62
|
}
|
|
62
63
|
return t[r.id] = {
|
|
63
|
-
value:
|
|
64
|
+
value: l
|
|
64
65
|
}, t;
|
|
65
66
|
}, {})
|
|
66
67
|
}
|
|
67
|
-
}, m =
|
|
68
|
-
return /* @__PURE__ */ i(
|
|
69
|
-
initialValues:
|
|
70
|
-
onSubmit:
|
|
71
|
-
children: /* @__PURE__ */ i(
|
|
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(
|
|
74
|
+
children: /* @__PURE__ */ c(a.Group, {
|
|
74
75
|
name: "metadata-view-filters",
|
|
75
76
|
type: "multiple",
|
|
76
|
-
children: [/* @__PURE__ */ c(
|
|
77
|
+
children: [n ? null : /* @__PURE__ */ c(a.ChipButton, {
|
|
77
78
|
onClick: s,
|
|
78
79
|
value: "all-filters-chip-btn",
|
|
79
|
-
children: [/* @__PURE__ */ i(
|
|
80
|
-
icon:
|
|
81
|
-
}), /* @__PURE__ */ i(
|
|
82
|
-
children:
|
|
83
|
-
}), e.length > 0 && /* @__PURE__ */ i(
|
|
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) =>
|
|
87
|
+
}), e.map((t) => x(t, o.includes(t.id), m))]
|
|
87
88
|
})
|
|
88
89
|
})
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
92
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
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.
|
|
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.
|
|
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"
|