@box/metadata-view 0.21.0 → 0.22.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/action-bar/action-bar.js +37 -29
- package/dist/esm/lib/components/action-bar/sort-dropdown.js +33 -0
- package/dist/esm/lib/metadata-view.js +48 -46
- package/dist/styles/action-bar.css +1 -1
- package/dist/types/lib/components/action-bar/action-bar.d.ts +4 -1
- package/dist/types/lib/components/action-bar/sort-dropdown.d.ts +8 -0
- package/dist/types/lib/metadata-view.d.ts +4 -3
- package/dist/types/lib/test-utils/mock-data.d.ts +17 -3
- package/package.json +4 -3
|
@@ -1,37 +1,45 @@
|
|
|
1
|
-
import { Button as
|
|
2
|
-
import { Grid as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import { V as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Button as l } from "@box/blueprint-web";
|
|
2
|
+
import { Grid as p } from "@box/blueprint-web-assets/icons/Fill";
|
|
3
|
+
import { useIntl as f } from "react-intl";
|
|
4
|
+
import { V as r } from "../../../../chunks/types.js";
|
|
5
|
+
import n from "./messages.js";
|
|
6
|
+
import { SortDropdown as h } from "./sort-dropdown.js";
|
|
7
|
+
import { jsxs as s, jsx as i } from "react/jsx-runtime";
|
|
8
|
+
import { FilterRow as B } from "../filter-row/filter-row.js";
|
|
9
|
+
import '../../../../styles/action-bar.css';const _ = "_actionBar_1bpah_1", w = "_additionalActions_1bpah_6", c = {
|
|
10
|
+
actionBar: _,
|
|
11
|
+
additionalActions: w
|
|
12
|
+
}, I = ({
|
|
13
|
+
onViewModeClick: m,
|
|
14
|
+
viewMode: o,
|
|
15
|
+
sortableColumnNames: e,
|
|
16
|
+
sortDropdownProps: t,
|
|
17
|
+
...d
|
|
14
18
|
}) => {
|
|
15
19
|
const {
|
|
16
|
-
formatMessage:
|
|
17
|
-
} =
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
className:
|
|
20
|
-
children: [/* @__PURE__ */
|
|
21
|
-
children: /* @__PURE__ */
|
|
22
|
-
...
|
|
23
|
-
})
|
|
24
|
-
}), /* @__PURE__ */ r("div", {
|
|
25
|
-
children: /* @__PURE__ */ r(n, {
|
|
26
|
-
"aria-label": i === t.GRID ? o(a.switchToListView) : o(a.switchToGridView),
|
|
27
|
-
icon: m,
|
|
28
|
-
onClick: s,
|
|
29
|
-
variant: i === t.GRID ? "primary" : "tertiary"
|
|
20
|
+
formatMessage: a
|
|
21
|
+
} = f();
|
|
22
|
+
return /* @__PURE__ */ s("div", {
|
|
23
|
+
className: c.actionBar,
|
|
24
|
+
children: [/* @__PURE__ */ i("div", {
|
|
25
|
+
children: /* @__PURE__ */ i(B, {
|
|
26
|
+
...d
|
|
30
27
|
})
|
|
28
|
+
}), /* @__PURE__ */ s("div", {
|
|
29
|
+
className: c.additionalActions,
|
|
30
|
+
children: [t && /* @__PURE__ */ i(h, {
|
|
31
|
+
...t,
|
|
32
|
+
sortableColumnNames: e
|
|
33
|
+
}), /* @__PURE__ */ i(l, {
|
|
34
|
+
"aria-label": o === r.GRID ? a(n.switchToListView) : a(n.switchToGridView),
|
|
35
|
+
icon: p,
|
|
36
|
+
onClick: m,
|
|
37
|
+
variant: o === r.GRID ? "primary" : "tertiary"
|
|
38
|
+
})]
|
|
31
39
|
})]
|
|
32
40
|
});
|
|
33
41
|
};
|
|
34
42
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
I as ActionBar,
|
|
44
|
+
I as default
|
|
37
45
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DropdownMenu as r, TriggerButton as p } from "@box/blueprint-web";
|
|
2
|
+
import { ArrowUp as c, ArrowDown as l } from "@box/blueprint-web-assets/icons/Fill";
|
|
3
|
+
import { jsxs as s, jsx as o } from "react/jsx-runtime";
|
|
4
|
+
const w = ({
|
|
5
|
+
onSortChange: i,
|
|
6
|
+
sortableColumnNames: a,
|
|
7
|
+
sortByColumn: e,
|
|
8
|
+
sortDirection: d
|
|
9
|
+
}) => {
|
|
10
|
+
const n = d === "ascending" ? "up" : "down";
|
|
11
|
+
return /* @__PURE__ */ s(r.Root, {
|
|
12
|
+
children: [/* @__PURE__ */ o(r.Trigger, {
|
|
13
|
+
children: /* @__PURE__ */ o(p, {
|
|
14
|
+
caretDirection: n,
|
|
15
|
+
label: e,
|
|
16
|
+
startIcon: n === "up" ? c : l,
|
|
17
|
+
variant: "tertiary"
|
|
18
|
+
})
|
|
19
|
+
}), /* @__PURE__ */ o(r.Content, {
|
|
20
|
+
children: /* @__PURE__ */ o(r.RadioGroup, {
|
|
21
|
+
onValueChange: i,
|
|
22
|
+
value: e,
|
|
23
|
+
children: a.map((t) => /* @__PURE__ */ o(r.RadioSelectItem, {
|
|
24
|
+
value: t,
|
|
25
|
+
children: t
|
|
26
|
+
}, t))
|
|
27
|
+
})
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
w as SortDropdown
|
|
33
|
+
};
|
|
@@ -1,56 +1,58 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { MetadataGrid as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { jsxs as
|
|
1
|
+
import { useState as w } from "react";
|
|
2
|
+
import u from "./components/error-state/error-state.js";
|
|
3
|
+
import V from "./components/pagination/pagination.js";
|
|
4
|
+
import { MetadataGrid as C } from "./components/metadata-grid/metadata-grid.js";
|
|
5
|
+
import { SwitchCase as I, Case as n } from "./components/switch-case/switch-case.js";
|
|
6
|
+
import { V as o } from "../../chunks/types.js";
|
|
7
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
8
8
|
import { ActionBar as T } from "./components/action-bar/action-bar.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import '../../styles/metadata-view.css';const
|
|
12
|
-
function
|
|
13
|
-
actionBarProps:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
import y from "./components/empty-state/empty-state.js";
|
|
10
|
+
import L from "./components/metadata-table/metadata-table.js";
|
|
11
|
+
import '../../styles/metadata-view.css';const g = {};
|
|
12
|
+
function A({
|
|
13
|
+
actionBarProps: a,
|
|
14
|
+
columns: c,
|
|
15
|
+
tableProps: m,
|
|
16
|
+
hasError: l,
|
|
17
|
+
onRefresh: p,
|
|
18
|
+
initialViewMode: f = o.LIST,
|
|
19
|
+
...r
|
|
19
20
|
}) {
|
|
20
|
-
const [
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
className:
|
|
25
|
-
children: [/* @__PURE__ */
|
|
26
|
-
...
|
|
27
|
-
onViewModeClick:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
const [e, d] = w(f), h = () => {
|
|
22
|
+
e === o.LIST ? d(o.GRID) : d(o.LIST);
|
|
23
|
+
}, M = !m.isLoading && r.items.length === 0, S = a.sortDropdownProps && c.filter((i) => i.type !== "multiSelect" && i.type !== "enum").map((i) => i.textValue);
|
|
24
|
+
return /* @__PURE__ */ s("div", {
|
|
25
|
+
className: g.container,
|
|
26
|
+
children: [/* @__PURE__ */ t(T, {
|
|
27
|
+
...a,
|
|
28
|
+
onViewModeClick: h,
|
|
29
|
+
sortableColumnNames: S,
|
|
30
|
+
viewMode: e
|
|
31
|
+
}), /* @__PURE__ */ s(I, {
|
|
32
|
+
children: [/* @__PURE__ */ t(n, {
|
|
33
|
+
condition: l,
|
|
34
|
+
children: /* @__PURE__ */ t(u, {
|
|
35
|
+
onRefresh: p
|
|
34
36
|
})
|
|
35
|
-
}), /* @__PURE__ */
|
|
36
|
-
condition:
|
|
37
|
-
children: /* @__PURE__ */
|
|
38
|
-
}), /* @__PURE__ */
|
|
39
|
-
condition:
|
|
40
|
-
children: /* @__PURE__ */
|
|
41
|
-
...
|
|
42
|
-
...
|
|
37
|
+
}), /* @__PURE__ */ t(n, {
|
|
38
|
+
condition: M,
|
|
39
|
+
children: /* @__PURE__ */ t(y, {})
|
|
40
|
+
}), /* @__PURE__ */ t(n, {
|
|
41
|
+
condition: e === o.LIST,
|
|
42
|
+
children: /* @__PURE__ */ t(L, {
|
|
43
|
+
...r,
|
|
44
|
+
...m
|
|
43
45
|
})
|
|
44
|
-
}), /* @__PURE__ */
|
|
45
|
-
condition:
|
|
46
|
-
children: /* @__PURE__ */
|
|
47
|
-
...
|
|
46
|
+
}), /* @__PURE__ */ t(n, {
|
|
47
|
+
condition: e === o.GRID,
|
|
48
|
+
children: /* @__PURE__ */ t(C, {
|
|
49
|
+
...r
|
|
48
50
|
})
|
|
49
51
|
})]
|
|
50
|
-
}), /* @__PURE__ */
|
|
52
|
+
}), /* @__PURE__ */ t(V, {})]
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
A as MetadataView,
|
|
57
|
+
A as default
|
|
56
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._actionBar_1bpah_1{display:flex;justify-content:space-between}._additionalActions_1bpah_6{display:flex}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { FilterRowProps } from '../filter-row';
|
|
2
2
|
import { ViewMode } from '../../types';
|
|
3
|
+
import { SortDropdownProps } from './sort-dropdown';
|
|
3
4
|
export interface ActionBarProps extends FilterRowProps {
|
|
4
5
|
onViewModeClick?: () => void;
|
|
5
6
|
viewMode?: ViewMode;
|
|
7
|
+
sortableColumnNames: string[];
|
|
8
|
+
sortDropdownProps?: SortDropdownProps;
|
|
6
9
|
}
|
|
7
|
-
export declare const ActionBar: ({ onViewModeClick, viewMode, ...rest }: ActionBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const ActionBar: ({ onViewModeClick, viewMode, sortableColumnNames, sortDropdownProps, ...rest }: ActionBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
11
|
export default ActionBar;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SortDirection } from 'react-aria-components';
|
|
2
|
+
export interface SortDropdownProps {
|
|
3
|
+
onSortChange: (sortByColumn: string) => void;
|
|
4
|
+
sortableColumnNames: string[];
|
|
5
|
+
sortByColumn: string;
|
|
6
|
+
sortDirection: SortDirection;
|
|
7
|
+
}
|
|
8
|
+
export declare const SortDropdown: ({ onSortChange, sortableColumnNames, sortByColumn, sortDirection }: SortDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { MetadataTableProps } from './components/metadata-table';
|
|
2
2
|
import { ActionBarProps } from './components/action-bar';
|
|
3
|
-
import {
|
|
3
|
+
import { ViewMode, Column, MetadataProps } from './types';
|
|
4
4
|
export interface MetadataViewProps extends MetadataProps {
|
|
5
|
-
|
|
5
|
+
columns: Column[];
|
|
6
|
+
actionBarProps: Omit<ActionBarProps, 'onViewModeChange' | 'viewMode' | 'sortableColumnNames'>;
|
|
6
7
|
hasError?: boolean;
|
|
7
8
|
initialViewMode?: ViewMode;
|
|
8
9
|
onRefresh?: () => void;
|
|
9
10
|
tableProps: Omit<MetadataTableProps, 'items' | 'itemActionMenuProps'>;
|
|
10
11
|
}
|
|
11
|
-
export declare function MetadataView({ actionBarProps, tableProps, hasError, onRefresh, initialViewMode, ...rest }: MetadataViewProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function MetadataView({ actionBarProps, columns, tableProps, hasError, onRefresh, initialViewMode, ...rest }: MetadataViewProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export default MetadataView;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { Item } from '@box/types';
|
|
2
|
+
import { SortDirection } from 'react-aria-components';
|
|
3
|
+
import { ActionBarProps } from '../components/action-bar/action-bar';
|
|
4
|
+
import { SortDropdownProps } from '../components/action-bar/sort-dropdown';
|
|
5
|
+
import { FilterRowProps } from '../components/filter-row/filter-row';
|
|
2
6
|
import { FilterOption } from '../components/filter-row/types';
|
|
7
|
+
import { MetadataTableProps } from '../components/metadata-table';
|
|
8
|
+
import { MetadataViewProps } from '../metadata-view';
|
|
3
9
|
import { Column } from '../types';
|
|
4
10
|
export declare const mockActiveFilterIds: string[];
|
|
5
11
|
export declare const mockColumnData: Column[];
|
|
6
12
|
export declare const mockFilterOptions: FilterOption[];
|
|
7
13
|
export declare const mockFilterOptionsNoSelection: FilterOption[];
|
|
8
14
|
export declare const mockFilterOptionsWithCustomFilterChips: FilterOption[];
|
|
15
|
+
export declare const mockFilterOptionsWithoutAlias: FilterOption[];
|
|
9
16
|
export declare const mockFilterOptionsWithInvalidType: FilterOption[];
|
|
10
17
|
export declare const mockMetadata: Item[];
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
export declare const mockSortableColumnNames: string[];
|
|
19
|
+
export declare const mockSortDropdownProps: SortDropdownProps;
|
|
20
|
+
export declare const mockFilterRowArgs: FilterRowProps;
|
|
21
|
+
export declare const mockActionBarProps: ActionBarProps;
|
|
22
|
+
export declare const mockTableProps: MetadataTableProps;
|
|
23
|
+
export declare const mockMetadataViewProps: MetadataViewProps;
|
|
24
|
+
export type SortArgs = {
|
|
25
|
+
column: string;
|
|
26
|
+
direction: SortDirection;
|
|
14
27
|
};
|
|
28
|
+
export declare const defaultSortArgs: SortArgs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@box/blueprint-web": "^11.12.0",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"formik": "^2.4.5",
|
|
12
12
|
"lodash": "^4.17.15",
|
|
13
13
|
"react": "^18.0.0",
|
|
14
|
+
"react-aria-components": "^1.7.1",
|
|
14
15
|
"react-dom": "^18.0.0",
|
|
15
16
|
"react-intl": "^6.4.2"
|
|
16
17
|
},
|
|
@@ -18,8 +19,8 @@
|
|
|
18
19
|
"@box/blueprint-web": "^11.12.0",
|
|
19
20
|
"@box/blueprint-web-assets": "^4.57.0",
|
|
20
21
|
"@box/eslint-plugin-blueprint": "*",
|
|
21
|
-
"@box/item-icon": "^0.13.
|
|
22
|
-
"@box/metadata-filter": "^1.14.
|
|
22
|
+
"@box/item-icon": "^0.13.2",
|
|
23
|
+
"@box/metadata-filter": "^1.14.2",
|
|
23
24
|
"@box/storybook-utils": "0.13.11",
|
|
24
25
|
"@box/types": "0.2.0",
|
|
25
26
|
"react-intl": "^6.4.2"
|