@box/metadata-view 0.39.2 → 0.39.4
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,50 +1,51 @@
|
|
|
1
1
|
import { FilterChip as I } from "@box/blueprint-web";
|
|
2
2
|
import { Formik as S, Form as v } from "formik";
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
5
|
-
import { getInitialFieldValues as
|
|
6
|
-
import { MetadataFilterChip as
|
|
7
|
-
import { usePredefinedFilter as
|
|
8
|
-
import { s as
|
|
9
|
-
import { jsx as l, jsxs as
|
|
3
|
+
import { useState as R, useEffect as g, useRef as w } from "react";
|
|
4
|
+
import C from "./all-filters-chip.js";
|
|
5
|
+
import { getInitialFieldValues as G } from "./initial-field-values.js";
|
|
6
|
+
import { MetadataFilterChip as b } from "./metadata-filter-chip.js";
|
|
7
|
+
import { usePredefinedFilter as j } from "./predefinedFilters/use-predefined-filter.js";
|
|
8
|
+
import { s as x } from "../../../../chunks/form-filter-chip.js";
|
|
9
|
+
import { jsx as l, jsxs as V } from "react/jsx-runtime";
|
|
10
10
|
const p = (s) => Object.entries(s).filter(([r, t]) => {
|
|
11
11
|
var i;
|
|
12
12
|
return ((i = t.value) == null ? void 0 : i.enum) && t.value.enum.length > 0 && t.value.enum[0] !== "";
|
|
13
|
-
}).map(([r]) => r),
|
|
13
|
+
}).map(([r]) => r), q = ({
|
|
14
14
|
predefinedFilterOptions: s,
|
|
15
15
|
filterGroups: r = [],
|
|
16
16
|
initialFilterValues: t,
|
|
17
17
|
isAllFiltersDisabled: i,
|
|
18
18
|
onFilterSubmit: o
|
|
19
19
|
}) => {
|
|
20
|
-
const [a,
|
|
20
|
+
const [a, n] = R([]), f = j(s), F = ({
|
|
21
21
|
metadata: {
|
|
22
22
|
fields: e
|
|
23
23
|
}
|
|
24
24
|
}) => {
|
|
25
25
|
const h = p(e);
|
|
26
|
-
|
|
27
|
-
},
|
|
26
|
+
n(h), o && o(e);
|
|
27
|
+
}, m = [...f, ...r], u = m.flatMap(({
|
|
28
28
|
filters: e
|
|
29
|
-
}) => e),
|
|
30
|
-
|
|
31
|
-
const e = p(
|
|
32
|
-
|
|
29
|
+
}) => e), d = G(u, t);
|
|
30
|
+
g(() => {
|
|
31
|
+
const e = p(d.metadata.fields);
|
|
32
|
+
n(e);
|
|
33
33
|
}, []);
|
|
34
|
-
const c =
|
|
34
|
+
const c = w(null);
|
|
35
35
|
return /* @__PURE__ */ l(S, {
|
|
36
|
-
|
|
36
|
+
enableReinitialize: !0,
|
|
37
|
+
initialValues: d,
|
|
37
38
|
onSubmit: F,
|
|
38
39
|
children: /* @__PURE__ */ l(v, {
|
|
39
40
|
ref: c,
|
|
40
|
-
children: /* @__PURE__ */
|
|
41
|
-
className:
|
|
41
|
+
children: /* @__PURE__ */ V(I.Group, {
|
|
42
|
+
className: x.filterChipGroup,
|
|
42
43
|
name: "metadata-view-filters",
|
|
43
44
|
type: "multiple",
|
|
44
|
-
children: [i ? null : /* @__PURE__ */ l(
|
|
45
|
+
children: [i ? null : /* @__PURE__ */ l(C, {
|
|
45
46
|
activeFilterCount: a.length,
|
|
46
|
-
filterGroups:
|
|
47
|
-
}),
|
|
47
|
+
filterGroups: m
|
|
48
|
+
}), u.filter((e) => e.shouldRenderChip).map((e) => /* @__PURE__ */ l(b, {
|
|
48
49
|
filterOption: e,
|
|
49
50
|
formRef: c,
|
|
50
51
|
selected: a.includes(e.id)
|
|
@@ -54,7 +55,7 @@ const p = (s) => Object.entries(s).filter(([r, t]) => {
|
|
|
54
55
|
});
|
|
55
56
|
};
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
q as FilterRow,
|
|
59
|
+
q as default,
|
|
59
60
|
p as getSelectedFilterIds
|
|
60
61
|
};
|
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
import { useState as w } from "react";
|
|
2
|
-
import { useFormikContext as I } from "formik";
|
|
3
1
|
import { DropdownMenu as a, FilterChip as c } from "@box/blueprint-web";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { useFormikContext as z } from "formik";
|
|
3
|
+
import { useState as S } from "react";
|
|
4
|
+
import { useIntl as V } from "react-intl";
|
|
5
|
+
import j from "./messages.js";
|
|
6
|
+
import { jsxs as f, jsx as t } from "react/jsx-runtime";
|
|
7
|
+
const P = ({
|
|
8
|
+
fieldNamePrefix: C,
|
|
9
|
+
formRef: g,
|
|
10
|
+
icon: i,
|
|
11
|
+
id: s,
|
|
12
|
+
name: l,
|
|
13
|
+
options: o,
|
|
14
|
+
type: v
|
|
15
15
|
}) => {
|
|
16
|
+
var h, u, d, p;
|
|
16
17
|
const {
|
|
17
|
-
formatMessage:
|
|
18
|
-
} =
|
|
19
|
-
values:
|
|
20
|
-
setFieldValue:
|
|
21
|
-
submitForm:
|
|
22
|
-
} =
|
|
23
|
-
name:
|
|
18
|
+
formatMessage: k
|
|
19
|
+
} = V(), [w, x] = S(!1), {
|
|
20
|
+
values: y,
|
|
21
|
+
setFieldValue: F,
|
|
22
|
+
submitForm: b
|
|
23
|
+
} = z(), m = (p = (d = (u = (h = y.metadata) == null ? void 0 : h.fields) == null ? void 0 : u[s]) == null ? void 0 : d.value) == null ? void 0 : p.enum, A = Array.isArray(m) ? m : [], e = new Set(A), I = e.size > 0 ? k(j.chipNameWithCount, {
|
|
24
|
+
name: l,
|
|
24
25
|
count: e.size
|
|
25
|
-
}) :
|
|
26
|
-
|
|
26
|
+
}) : l, O = async (r, n) => {
|
|
27
|
+
v === "enum" ? e.clear() : e.delete(n), r && e.add(n), await F(`${C}.value.enum`, Array.from(e)), b();
|
|
27
28
|
};
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
onOpenChange:
|
|
30
|
-
open:
|
|
29
|
+
return /* @__PURE__ */ f(a.Root, {
|
|
30
|
+
onOpenChange: x,
|
|
31
|
+
open: w,
|
|
31
32
|
children: [/* @__PURE__ */ t(a.Trigger, {
|
|
32
33
|
asChild: !0,
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
+
children: /* @__PURE__ */ f(c.TriggerChip, {
|
|
34
35
|
selected: e.size > 0,
|
|
35
|
-
value:
|
|
36
|
-
children: [
|
|
37
|
-
icon:
|
|
36
|
+
value: s,
|
|
37
|
+
children: [i && /* @__PURE__ */ t(c.Icon, {
|
|
38
|
+
icon: i
|
|
38
39
|
}), /* @__PURE__ */ t(c.Label, {
|
|
39
|
-
children:
|
|
40
|
+
children: I
|
|
40
41
|
}), /* @__PURE__ */ t(c.DropdownIndicator, {})]
|
|
41
|
-
},
|
|
42
|
+
}, s)
|
|
42
43
|
}), /* @__PURE__ */ t(a.Content, {
|
|
43
|
-
container:
|
|
44
|
-
children:
|
|
44
|
+
container: g.current,
|
|
45
|
+
children: o == null ? void 0 : o.map((r) => /* @__PURE__ */ t(a.CheckboxItem, {
|
|
45
46
|
checked: e.has(r),
|
|
46
|
-
onCheckedChange: (n) =>
|
|
47
|
+
onCheckedChange: (n) => O(n, r),
|
|
47
48
|
children: r
|
|
48
49
|
}, r))
|
|
49
50
|
})]
|
|
50
51
|
});
|
|
51
52
|
};
|
|
52
53
|
export {
|
|
53
|
-
|
|
54
|
+
P as SelectFilterChip
|
|
54
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-view",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@box/blueprint-web": "^11.12.0",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@box/blueprint-web": "^11.12.0",
|
|
22
22
|
"@box/blueprint-web-assets": "^4.63.0",
|
|
23
|
-
"@box/box-item-type-selector": "^0.63.
|
|
23
|
+
"@box/box-item-type-selector": "^0.63.10",
|
|
24
24
|
"@box/eslint-plugin-blueprint": "*",
|
|
25
|
-
"@box/item-icon": "^0.17.
|
|
26
|
-
"@box/metadata-filter": "^1.18.
|
|
25
|
+
"@box/item-icon": "^0.17.13",
|
|
26
|
+
"@box/metadata-filter": "^1.18.11",
|
|
27
27
|
"@box/storybook-utils": "0.13.18",
|
|
28
28
|
"@box/types": "0.2.1",
|
|
29
29
|
"@tanstack/react-virtual": "^3.10.8",
|