@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.
- package/dist/esm/lib/components/filter-row/filter-row.js +42 -39
- package/dist/esm/lib/components/filter-row/string-filter-chip.js +25 -25
- package/dist/types/lib/components/filter-row/string-filter-chip.d.ts +1 -1
- package/dist/types/lib/components/filter-row/types.d.ts +2 -0
- package/dist/types/lib/test-utils/mock-data.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,83 +1,86 @@
|
|
|
1
|
-
import { FilterChip as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import b from "./
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const
|
|
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__ */
|
|
13
|
-
formRef:
|
|
14
|
+
return /* @__PURE__ */ r(b, {
|
|
15
|
+
formRef: n,
|
|
16
|
+
icon: i,
|
|
14
17
|
id: e.id,
|
|
15
18
|
name: e.name,
|
|
16
|
-
selected:
|
|
19
|
+
selected: c
|
|
17
20
|
}, e.id);
|
|
18
21
|
case "date":
|
|
19
22
|
case "enum":
|
|
20
23
|
case "multiSelect":
|
|
21
|
-
return /* @__PURE__ */ d(
|
|
24
|
+
return /* @__PURE__ */ d(s.Chip, {
|
|
22
25
|
value: e.id,
|
|
23
|
-
children: [/* @__PURE__ */
|
|
24
|
-
icon:
|
|
25
|
-
}), /* @__PURE__ */
|
|
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
|
-
},
|
|
35
|
+
}, T = ({
|
|
33
36
|
filterOptions: e,
|
|
34
|
-
isAllFiltersDisabled:
|
|
35
|
-
onFilterSubmit:
|
|
37
|
+
isAllFiltersDisabled: c,
|
|
38
|
+
onFilterSubmit: n
|
|
36
39
|
}) => {
|
|
37
|
-
const [
|
|
38
|
-
var
|
|
39
|
-
return ((
|
|
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
|
|
46
|
-
u(
|
|
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,
|
|
50
|
-
let
|
|
51
|
-
switch (
|
|
52
|
+
fields: e.reduce((t, a) => {
|
|
53
|
+
let l;
|
|
54
|
+
switch (a.fieldType) {
|
|
52
55
|
case "string":
|
|
53
56
|
case "float":
|
|
54
|
-
|
|
57
|
+
l = [""];
|
|
55
58
|
break;
|
|
56
59
|
default:
|
|
57
|
-
|
|
60
|
+
l = null;
|
|
58
61
|
}
|
|
59
|
-
return t[
|
|
60
|
-
value:
|
|
62
|
+
return t[a.id] = {
|
|
63
|
+
value: l
|
|
61
64
|
}, t;
|
|
62
65
|
}, {})
|
|
63
66
|
}
|
|
64
|
-
}, m =
|
|
65
|
-
return /* @__PURE__ */
|
|
67
|
+
}, m = g(null);
|
|
68
|
+
return /* @__PURE__ */ r(p, {
|
|
66
69
|
initialValues: F,
|
|
67
70
|
onSubmit: h,
|
|
68
|
-
children: /* @__PURE__ */
|
|
71
|
+
children: /* @__PURE__ */ r(f, {
|
|
69
72
|
ref: m,
|
|
70
|
-
children: /* @__PURE__ */ d(
|
|
73
|
+
children: /* @__PURE__ */ d(s.Group, {
|
|
71
74
|
name: "metadata-view-filters",
|
|
72
75
|
type: "multiple",
|
|
73
|
-
children: [
|
|
74
|
-
activeFilterCount:
|
|
75
|
-
}), e.map((t) =>
|
|
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
|
-
|
|
82
|
-
|
|
84
|
+
T as FilterRow,
|
|
85
|
+
T as default
|
|
83
86
|
};
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { Popover as o, FilterChip as t, Button as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
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:
|
|
10
|
+
}, P = ({
|
|
11
|
+
formRef: d,
|
|
13
12
|
id: r,
|
|
14
13
|
name: i,
|
|
15
|
-
selected:
|
|
14
|
+
selected: f,
|
|
15
|
+
icon: a
|
|
16
16
|
}) => {
|
|
17
17
|
const {
|
|
18
|
-
formatMessage:
|
|
19
|
-
} = F(), [
|
|
20
|
-
|
|
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:
|
|
25
|
-
open:
|
|
24
|
+
onOpenChange: s,
|
|
25
|
+
open: h,
|
|
26
26
|
children: [/* @__PURE__ */ e(o.Trigger, {
|
|
27
27
|
children: /* @__PURE__ */ n(t.TriggerChip, {
|
|
28
|
-
selected:
|
|
28
|
+
selected: f,
|
|
29
29
|
value: r,
|
|
30
|
-
children: [/* @__PURE__ */ e(t.Icon, {
|
|
31
|
-
icon:
|
|
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:
|
|
38
|
+
container: d.current,
|
|
39
39
|
children: [/* @__PURE__ */ e(o.MainContent, {
|
|
40
|
-
children: /* @__PURE__ */ e(
|
|
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(
|
|
46
|
+
children: [/* @__PURE__ */ e(m, {
|
|
47
47
|
onClick: () => {
|
|
48
|
-
|
|
48
|
+
p.setFieldValue(`metadata.fields.${r}.value.enum`, []);
|
|
49
49
|
},
|
|
50
50
|
size: "small",
|
|
51
51
|
variant: "secondary",
|
|
52
|
-
children:
|
|
53
|
-
}), /* @__PURE__ */ e(
|
|
54
|
-
onClick:
|
|
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:
|
|
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
|
-
|
|
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: {
|