@box/metadata-view 0.38.0 → 0.39.1
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 +41 -34
- package/dist/esm/lib/components/filter-row/index.js +3 -2
- package/dist/esm/lib/components/filter-row/initial-field-values.js +16 -12
- package/dist/types/lib/components/filter-row/filter-row.d.ts +8 -4
- package/dist/types/lib/components/filter-row/initial-field-values.d.ts +3 -3
- package/dist/types/lib/components/filter-row/types.d.ts +4 -0
- package/dist/types/lib/test-utils/mock-data.d.ts +2 -1
- package/package.json +4 -4
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
import { FilterChip as
|
|
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
|
|
3
|
+
import { useState as g, useEffect as w, useRef as C } from "react";
|
|
4
|
+
import G from "./all-filters-chip.js";
|
|
5
|
+
import { getInitialFieldValues as R } from "./initial-field-values.js";
|
|
6
6
|
import { MetadataFilterChip as j } from "./metadata-filter-chip.js";
|
|
7
|
-
import { usePredefinedFilter as
|
|
8
|
-
import { s as
|
|
9
|
-
import { jsx as
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import { usePredefinedFilter as x } from "./predefinedFilters/use-predefined-filter.js";
|
|
8
|
+
import { s as V } from "../../../../chunks/form-filter-chip.js";
|
|
9
|
+
import { jsx as l, jsxs as b } from "react/jsx-runtime";
|
|
10
|
+
const p = (s) => Object.entries(s).filter(([r, t]) => {
|
|
11
|
+
var i;
|
|
12
|
+
return ((i = t.value) == null ? void 0 : i.enum) && t.value.enum.length > 0 && t.value.enum[0] !== "";
|
|
13
|
+
}).map(([r]) => r), z = ({
|
|
14
|
+
predefinedFilterOptions: s,
|
|
15
|
+
filterGroups: r = [],
|
|
16
|
+
initialFilterValues: t,
|
|
17
|
+
isAllFiltersDisabled: i,
|
|
18
|
+
onFilterSubmit: o
|
|
15
19
|
}) => {
|
|
16
|
-
const [
|
|
17
|
-
var r;
|
|
18
|
-
return ((r = t.value) == null ? void 0 : r.enum) && t.value.enum.length > 0;
|
|
19
|
-
}, h = ({
|
|
20
|
+
const [a, m] = g([]), f = x(s), F = ({
|
|
20
21
|
metadata: {
|
|
21
22
|
fields: e
|
|
22
23
|
}
|
|
23
24
|
}) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
},
|
|
25
|
+
const h = p(e);
|
|
26
|
+
m(h), o && o(e);
|
|
27
|
+
}, n = [...f, ...r], d = n.flatMap(({
|
|
27
28
|
filters: e
|
|
28
|
-
}) => e),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
}) => e), u = R(d, t);
|
|
30
|
+
w(() => {
|
|
31
|
+
const e = p(u.metadata.fields);
|
|
32
|
+
m(e);
|
|
33
|
+
}, []);
|
|
34
|
+
const c = C(null);
|
|
35
|
+
return /* @__PURE__ */ l(S, {
|
|
36
|
+
initialValues: u,
|
|
37
|
+
onSubmit: F,
|
|
38
|
+
children: /* @__PURE__ */ l(v, {
|
|
39
|
+
ref: c,
|
|
40
|
+
children: /* @__PURE__ */ b(I.Group, {
|
|
41
|
+
className: V.filterChipGroup,
|
|
36
42
|
name: "metadata-view-filters",
|
|
37
43
|
type: "multiple",
|
|
38
|
-
children: [
|
|
39
|
-
activeFilterCount:
|
|
40
|
-
filterGroups:
|
|
41
|
-
}),
|
|
44
|
+
children: [i ? null : /* @__PURE__ */ l(G, {
|
|
45
|
+
activeFilterCount: a.length,
|
|
46
|
+
filterGroups: n
|
|
47
|
+
}), d.filter((e) => e.shouldRenderChip).map((e) => /* @__PURE__ */ l(j, {
|
|
42
48
|
filterOption: e,
|
|
43
|
-
formRef:
|
|
44
|
-
selected:
|
|
49
|
+
formRef: c,
|
|
50
|
+
selected: a.includes(e.id)
|
|
45
51
|
}, e.id))]
|
|
46
52
|
})
|
|
47
53
|
})
|
|
@@ -49,5 +55,6 @@ const z = ({
|
|
|
49
55
|
};
|
|
50
56
|
export {
|
|
51
57
|
z as FilterRow,
|
|
52
|
-
z as default
|
|
58
|
+
z as default,
|
|
59
|
+
p as getSelectedFilterIds
|
|
53
60
|
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
const
|
|
2
|
-
key:
|
|
3
|
-
id:
|
|
4
|
-
}),
|
|
5
|
-
fieldType:
|
|
6
|
-
options:
|
|
7
|
-
}) => ["enum", "multiSelect"].includes(
|
|
1
|
+
const r = (t) => ({
|
|
2
|
+
key: t,
|
|
3
|
+
id: t
|
|
4
|
+
}), c = ({
|
|
5
|
+
fieldType: t,
|
|
6
|
+
options: e
|
|
7
|
+
}) => ["enum", "multiSelect"].includes(t) ? (e || []).map(r) : [], l = (t, e) => ({
|
|
8
8
|
metadata: {
|
|
9
|
-
fields:
|
|
10
|
-
|
|
9
|
+
fields: t.reduce((a, n) => {
|
|
10
|
+
var i;
|
|
11
|
+
const u = (i = e == null ? void 0 : e[n.id]) == null ? void 0 : i.value, o = {
|
|
11
12
|
enum: []
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
};
|
|
14
|
+
return a[n.id] = {
|
|
15
|
+
value: u || o,
|
|
16
|
+
options: c(n)
|
|
17
|
+
}, a;
|
|
18
|
+
}, {})
|
|
15
19
|
}
|
|
16
20
|
});
|
|
17
21
|
export {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { MetadataTemplateField } from '@box/metadata-filter';
|
|
2
|
-
import { FilterGroup } from './types';
|
|
3
1
|
import { PredefinedFilterOptions } from './predefinedFilters/types';
|
|
2
|
+
import { FilterGroup, FilterValues } from './types';
|
|
4
3
|
export interface FilterRowProps {
|
|
5
4
|
predefinedFilterOptions?: Partial<PredefinedFilterOptions>;
|
|
6
5
|
filterGroups?: Array<FilterGroup>;
|
|
6
|
+
initialFilterValues?: FilterValues;
|
|
7
7
|
isAllFiltersDisabled?: boolean;
|
|
8
|
-
onFilterSubmit?: (fields:
|
|
8
|
+
onFilterSubmit?: (fields: FilterValues) => void;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Extracts selected filter IDs from filter values
|
|
12
|
+
*/
|
|
13
|
+
export declare const getSelectedFilterIds: (fields: FilterValues) => string[];
|
|
14
|
+
export declare const FilterRow: ({ predefinedFilterOptions, filterGroups: customFilterGroups, initialFilterValues: customFilterValues, isAllFiltersDisabled, onFilterSubmit, }: FilterRowProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
15
|
export default FilterRow;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FilterOption } from './types';
|
|
3
|
-
export declare const getInitialFieldValues: (filterOptions: FilterOption[]) => {
|
|
1
|
+
import { MetadataFormFieldValue, MetadataTemplateFieldOption } from '@box/metadata-filter';
|
|
2
|
+
import { FilterOption, FilterValues } from './types';
|
|
3
|
+
export declare const getInitialFieldValues: (filterOptions: FilterOption[], customFieldValues?: FilterValues) => {
|
|
4
4
|
metadata: {
|
|
5
5
|
fields: Record<string, {
|
|
6
6
|
value: MetadataFormFieldValue;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MetadataFormFieldValue } from '@box/metadata-filter';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
3
|
import { FilterVariant, MetadataFieldType } from '../../types';
|
|
3
4
|
export interface FilterGroup {
|
|
@@ -26,3 +27,6 @@ export interface FilterChipProps {
|
|
|
26
27
|
name: string;
|
|
27
28
|
selected: boolean;
|
|
28
29
|
}
|
|
30
|
+
export type FilterValues = Record<string, {
|
|
31
|
+
value: MetadataFormFieldValue;
|
|
32
|
+
}>;
|
|
@@ -2,7 +2,7 @@ import { Item } from '@box/types';
|
|
|
2
2
|
import { SortDirection } from 'react-aria-components';
|
|
3
3
|
import { ActionBarProps } from '../components/action-bar/action-bar';
|
|
4
4
|
import { FilterRowProps } from '../components/filter-row/filter-row';
|
|
5
|
-
import { FilterGroup, FilterOption } from '../components/filter-row/types';
|
|
5
|
+
import { FilterGroup, FilterOption, FilterValues } from '../components/filter-row/types';
|
|
6
6
|
import { ItemActionMenuProps } from '../components/item-action-menu/item-action-menu';
|
|
7
7
|
import { MetadataTableProps } from '../components/metadata-table';
|
|
8
8
|
import { PaginationProps } from '../components/pagination/pagination';
|
|
@@ -92,3 +92,4 @@ export type SortArgs = {
|
|
|
92
92
|
direction: SortDirection;
|
|
93
93
|
};
|
|
94
94
|
export declare const defaultSortArgs: SortArgs;
|
|
95
|
+
export declare const mockInitialFilterValues: FilterValues;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.1",
|
|
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.8",
|
|
24
24
|
"@box/eslint-plugin-blueprint": "*",
|
|
25
|
-
"@box/item-icon": "^0.17.
|
|
26
|
-
"@box/metadata-filter": "^1.18.
|
|
25
|
+
"@box/item-icon": "^0.17.11",
|
|
26
|
+
"@box/metadata-filter": "^1.18.9",
|
|
27
27
|
"@box/storybook-utils": "0.13.18",
|
|
28
28
|
"@box/types": "0.2.1",
|
|
29
29
|
"@tanstack/react-virtual": "^3.10.8",
|