@box/metadata-view 1.6.2 → 1.7.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/metadata-filter-chip.js +28 -26
- package/dist/esm/lib/components/filter-row/select-filter-chip.js +43 -38
- package/dist/types/lib/components/filter-row/select-filter-chip.d.ts +2 -1
- package/dist/types/lib/test-utils/mock-data.d.ts +1 -0
- package/package.json +5 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { MetadataStringField as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import { MetadataFileChip as
|
|
1
|
+
import { MetadataStringField as f, MetadataFloatField as h, MetadataDateField as M } from "@box/metadata-filter";
|
|
2
|
+
import { useIntl as C } from "react-intl";
|
|
3
|
+
import { MetadataFileChip as b } from "../metadata-value/metadata-file-chip.js";
|
|
4
4
|
import { FormFilterChip as n } from "./form-filter-chip.js";
|
|
5
|
-
import { SelectFilterChip as
|
|
5
|
+
import { SelectFilterChip as v } from "./select-filter-chip.js";
|
|
6
6
|
import { jsx as t } from "react/jsx-runtime";
|
|
7
|
-
const
|
|
7
|
+
const w = ({
|
|
8
8
|
filterOption: c,
|
|
9
9
|
formRef: i
|
|
10
10
|
}) => {
|
|
@@ -12,65 +12,67 @@ const j = ({
|
|
|
12
12
|
canUseRelativeDates: d,
|
|
13
13
|
customDateFilterOptions: s,
|
|
14
14
|
fieldType: o,
|
|
15
|
-
icon:
|
|
15
|
+
icon: l,
|
|
16
16
|
id: e,
|
|
17
17
|
name: a,
|
|
18
18
|
options: m,
|
|
19
|
-
|
|
19
|
+
placeholder: p,
|
|
20
|
+
variant: u
|
|
20
21
|
} = c, {
|
|
21
|
-
locale:
|
|
22
|
-
} =
|
|
22
|
+
locale: F
|
|
23
|
+
} = C(), r = `metadata.fields.${e}`;
|
|
23
24
|
switch (o) {
|
|
24
25
|
case "date":
|
|
25
26
|
return /* @__PURE__ */ t(n, {
|
|
26
27
|
formRef: i,
|
|
27
|
-
icon:
|
|
28
|
+
icon: l,
|
|
28
29
|
id: e,
|
|
29
30
|
name: a,
|
|
30
|
-
children: /* @__PURE__ */ t(
|
|
31
|
+
children: /* @__PURE__ */ t(M, {
|
|
31
32
|
canUseRelativeDates: d,
|
|
32
33
|
customDateFilterOptions: s,
|
|
33
34
|
direction: "vertical",
|
|
34
|
-
fieldNamePrefix:
|
|
35
|
+
fieldNamePrefix: r,
|
|
35
36
|
label: a,
|
|
36
|
-
locale:
|
|
37
|
+
locale: F
|
|
37
38
|
})
|
|
38
39
|
}, e);
|
|
39
40
|
case "float":
|
|
40
41
|
return /* @__PURE__ */ t(n, {
|
|
41
42
|
formRef: i,
|
|
42
|
-
icon:
|
|
43
|
+
icon: l,
|
|
43
44
|
id: e,
|
|
44
45
|
name: a,
|
|
45
|
-
children: /* @__PURE__ */ t(
|
|
46
|
-
fieldNamePrefix:
|
|
46
|
+
children: /* @__PURE__ */ t(h, {
|
|
47
|
+
fieldNamePrefix: r,
|
|
47
48
|
label: a
|
|
48
49
|
})
|
|
49
50
|
}, e);
|
|
50
51
|
case "string":
|
|
51
52
|
return /* @__PURE__ */ t(n, {
|
|
52
53
|
formRef: i,
|
|
53
|
-
icon:
|
|
54
|
+
icon: l,
|
|
54
55
|
id: e,
|
|
55
56
|
name: a,
|
|
56
|
-
children: /* @__PURE__ */ t(
|
|
57
|
-
fieldNamePrefix:
|
|
57
|
+
children: /* @__PURE__ */ t(f, {
|
|
58
|
+
fieldNamePrefix: r,
|
|
58
59
|
label: a
|
|
59
60
|
})
|
|
60
61
|
}, e);
|
|
61
62
|
case "multiSelect":
|
|
62
|
-
if (
|
|
63
|
-
return /* @__PURE__ */ t(
|
|
63
|
+
if (u === "file")
|
|
64
|
+
return /* @__PURE__ */ t(b, {
|
|
64
65
|
id: e
|
|
65
66
|
});
|
|
66
67
|
case "enum":
|
|
67
|
-
return /* @__PURE__ */ t(
|
|
68
|
-
fieldNamePrefix:
|
|
68
|
+
return /* @__PURE__ */ t(v, {
|
|
69
|
+
fieldNamePrefix: r,
|
|
69
70
|
formRef: i,
|
|
70
|
-
icon:
|
|
71
|
+
icon: l,
|
|
71
72
|
id: e,
|
|
72
73
|
name: a,
|
|
73
74
|
options: m,
|
|
75
|
+
placeholder: p,
|
|
74
76
|
type: o
|
|
75
77
|
});
|
|
76
78
|
default:
|
|
@@ -78,6 +80,6 @@ const j = ({
|
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
82
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
w as MetadataFilterChip,
|
|
84
|
+
w as default
|
|
83
85
|
};
|
|
@@ -1,55 +1,60 @@
|
|
|
1
|
-
import { DropdownMenu as
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import
|
|
6
|
-
import { jsxs as
|
|
7
|
-
const
|
|
8
|
-
fieldNamePrefix:
|
|
9
|
-
formRef:
|
|
10
|
-
icon:
|
|
11
|
-
id:
|
|
1
|
+
import { DropdownMenu as s, FilterChip as a } from "@box/blueprint-web";
|
|
2
|
+
import { useFormikContext as V } from "formik";
|
|
3
|
+
import { useState as j } from "react";
|
|
4
|
+
import { useIntl as D } from "react-intl";
|
|
5
|
+
import L from "./messages.js";
|
|
6
|
+
import { jsxs as m, jsx as t } from "react/jsx-runtime";
|
|
7
|
+
const W = ({
|
|
8
|
+
fieldNamePrefix: v,
|
|
9
|
+
formRef: x,
|
|
10
|
+
icon: h,
|
|
11
|
+
id: i,
|
|
12
12
|
name: l,
|
|
13
13
|
options: o,
|
|
14
|
-
type:
|
|
14
|
+
type: u,
|
|
15
|
+
placeholder: n
|
|
15
16
|
}) => {
|
|
16
|
-
var
|
|
17
|
+
var f, p, g, k;
|
|
17
18
|
const {
|
|
18
|
-
formatMessage:
|
|
19
|
-
} =
|
|
20
|
-
values:
|
|
21
|
-
setFieldValue:
|
|
22
|
-
submitForm:
|
|
23
|
-
} =
|
|
19
|
+
formatMessage: b
|
|
20
|
+
} = D(), [w, F] = j(!1), {
|
|
21
|
+
values: I,
|
|
22
|
+
setFieldValue: y,
|
|
23
|
+
submitForm: z
|
|
24
|
+
} = V(), d = (k = (g = (p = (f = I.metadata) == null ? void 0 : f.fields) == null ? void 0 : p[i]) == null ? void 0 : g.value) == null ? void 0 : k.enum, A = Array.isArray(d) ? d : [], e = new Set(A), O = e.size > 0 ? b(L.chipNameWithCount, {
|
|
24
25
|
name: l,
|
|
25
26
|
count: e.size
|
|
26
|
-
}) : l,
|
|
27
|
-
|
|
27
|
+
}) : l, S = !!n && u !== "multiSelect", C = async (r, c) => {
|
|
28
|
+
u === "enum" ? e.clear() : e.delete(c), r && c !== n && e.add(c), await y(`${v}.value.enum`, Array.from(e)), z();
|
|
28
29
|
};
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
onOpenChange:
|
|
30
|
+
return /* @__PURE__ */ m(s.Root, {
|
|
31
|
+
onOpenChange: F,
|
|
31
32
|
open: w,
|
|
32
|
-
children: [/* @__PURE__ */ t(
|
|
33
|
+
children: [/* @__PURE__ */ t(s.Trigger, {
|
|
33
34
|
asChild: !0,
|
|
34
|
-
children: /* @__PURE__ */
|
|
35
|
+
children: /* @__PURE__ */ m(a.TriggerChip, {
|
|
35
36
|
selected: e.size > 0,
|
|
36
|
-
value:
|
|
37
|
-
children: [
|
|
38
|
-
icon:
|
|
39
|
-
}), /* @__PURE__ */ t(
|
|
40
|
-
children:
|
|
41
|
-
}), /* @__PURE__ */ t(
|
|
42
|
-
},
|
|
43
|
-
}), /* @__PURE__ */
|
|
44
|
-
container:
|
|
45
|
-
children:
|
|
37
|
+
value: i,
|
|
38
|
+
children: [h && /* @__PURE__ */ t(a.Icon, {
|
|
39
|
+
icon: h
|
|
40
|
+
}), /* @__PURE__ */ t(a.Label, {
|
|
41
|
+
children: O
|
|
42
|
+
}), /* @__PURE__ */ t(a.DropdownIndicator, {})]
|
|
43
|
+
}, i)
|
|
44
|
+
}), /* @__PURE__ */ m(s.Content, {
|
|
45
|
+
container: x.current,
|
|
46
|
+
children: [S && /* @__PURE__ */ t(s.CheckboxItem, {
|
|
47
|
+
checked: e.size === 0,
|
|
48
|
+
onCheckedChange: (r) => C(r, n),
|
|
49
|
+
children: n
|
|
50
|
+
}, n), o == null ? void 0 : o.map((r) => /* @__PURE__ */ t(s.CheckboxItem, {
|
|
46
51
|
checked: e.has(r),
|
|
47
|
-
onCheckedChange: (
|
|
52
|
+
onCheckedChange: (c) => C(c, r),
|
|
48
53
|
children: r
|
|
49
|
-
}, r))
|
|
54
|
+
}, r))]
|
|
50
55
|
})]
|
|
51
56
|
});
|
|
52
57
|
};
|
|
53
58
|
export {
|
|
54
|
-
|
|
59
|
+
W as SelectFilterChip
|
|
55
60
|
};
|
|
@@ -6,6 +6,7 @@ export interface SelectFilterChipProps {
|
|
|
6
6
|
id: string;
|
|
7
7
|
name: string;
|
|
8
8
|
options?: string[];
|
|
9
|
+
placeholder?: string;
|
|
9
10
|
type: MetadataFieldType;
|
|
10
11
|
}
|
|
11
|
-
export declare const SelectFilterChip: ({ fieldNamePrefix, formRef, icon, id, name, options, type, }: SelectFilterChipProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const SelectFilterChip: ({ fieldNamePrefix, formRef, icon, id, name, options, type, placeholder, }: SelectFilterChipProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,6 +22,7 @@ export declare const mockFilterOptionsWithoutName: FilterOption[];
|
|
|
22
22
|
export declare const mockFilterGroupsWithoutName: FilterGroup[];
|
|
23
23
|
export declare const mockFilterOptionsWithInvalidType: FilterOption[];
|
|
24
24
|
export declare const mockFilterOptionsWithSomeChipsHidden: FilterOption[];
|
|
25
|
+
export declare const mockFilterOptionsWithEnumPlaceholder: FilterOption[];
|
|
25
26
|
export declare const mockMetadata: Item[];
|
|
26
27
|
export declare const mockMetadataWithThumbnail: Item[];
|
|
27
28
|
export declare const mockSortableColumns: Column[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-view",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@box/blueprint-web": "^12.76.2",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"react-intl": "^6.4.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@box/blueprint-web": "^12.89.
|
|
21
|
+
"@box/blueprint-web": "^12.89.2",
|
|
22
22
|
"@box/blueprint-web-assets": "^4.75.0",
|
|
23
|
-
"@box/box-item-type-selector": "^1.2.
|
|
23
|
+
"@box/box-item-type-selector": "^1.2.6",
|
|
24
24
|
"@box/eslint-plugin-blueprint": "1.0.5",
|
|
25
|
-
"@box/item-icon": "^1.3.
|
|
26
|
-
"@box/metadata-filter": "^1.39.
|
|
25
|
+
"@box/item-icon": "^1.3.6",
|
|
26
|
+
"@box/metadata-filter": "^1.39.6",
|
|
27
27
|
"@box/storybook-utils": "0.14.11",
|
|
28
28
|
"@box/types": "1.0.0",
|
|
29
29
|
"@tanstack/react-virtual": "^3.10.8",
|