@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.
@@ -1,37 +1,45 @@
1
- import { Button as n } from "@box/blueprint-web";
2
- import { Grid as m } from "@box/blueprint-web-assets/icons/Fill";
3
- import { useIntl as c } from "react-intl";
4
- import { V as t } from "../../../../chunks/types.js";
5
- import a from "./messages.js";
6
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
7
- import { FilterRow as d } from "../filter-row/filter-row.js";
8
- import '../../../../styles/action-bar.css';const f = "_actionBar_17enr_1", p = {
9
- actionBar: f
10
- }, x = ({
11
- onViewModeClick: s,
12
- viewMode: i,
13
- ...e
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: o
17
- } = c();
18
- return /* @__PURE__ */ l("div", {
19
- className: p.actionBar,
20
- children: [/* @__PURE__ */ r("div", {
21
- children: /* @__PURE__ */ r(d, {
22
- ...e
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
- x as ActionBar,
36
- x as default
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 h } from "react";
2
- import M from "./components/error-state/error-state.js";
3
- import S from "./components/pagination/pagination.js";
4
- import { MetadataGrid as w } from "./components/metadata-grid/metadata-grid.js";
5
- import { V as t } from "../../chunks/types.js";
6
- import { SwitchCase as I, Case as e } from "./components/switch-case/switch-case.js";
7
- import { jsxs as m, jsx as o } from "react/jsx-runtime";
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 V from "./components/empty-state/empty-state.js";
10
- import C from "./components/metadata-table/metadata-table.js";
11
- import '../../styles/metadata-view.css';const L = {};
12
- function b({
13
- actionBarProps: d,
14
- tableProps: r,
15
- hasError: c,
16
- onRefresh: s,
17
- initialViewMode: l = t.LIST,
18
- ...n
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 [i, a] = h(l), p = () => {
21
- i === t.LIST ? a(t.GRID) : a(t.LIST);
22
- }, f = !r.isLoading && n.items.length === 0;
23
- return /* @__PURE__ */ m("div", {
24
- className: L.container,
25
- children: [/* @__PURE__ */ o(T, {
26
- ...d,
27
- onViewModeClick: p,
28
- viewMode: i
29
- }), /* @__PURE__ */ m(I, {
30
- children: [/* @__PURE__ */ o(e, {
31
- condition: c,
32
- children: /* @__PURE__ */ o(M, {
33
- onRefresh: s
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__ */ o(e, {
36
- condition: f,
37
- children: /* @__PURE__ */ o(V, {})
38
- }), /* @__PURE__ */ o(e, {
39
- condition: i === t.LIST,
40
- children: /* @__PURE__ */ o(C, {
41
- ...n,
42
- ...r
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__ */ o(e, {
45
- condition: i === t.GRID,
46
- children: /* @__PURE__ */ o(w, {
47
- ...n
46
+ }), /* @__PURE__ */ t(n, {
47
+ condition: e === o.GRID,
48
+ children: /* @__PURE__ */ t(C, {
49
+ ...r
48
50
  })
49
51
  })]
50
- }), /* @__PURE__ */ o(S, {})]
52
+ }), /* @__PURE__ */ t(V, {})]
51
53
  });
52
54
  }
53
55
  export {
54
- b as MetadataView,
55
- b as default
56
+ A as MetadataView,
57
+ A as default
56
58
  };
@@ -1 +1 @@
1
- ._actionBar_17enr_1{display:flex;justify-content:space-between}
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 { MetadataProps, ViewMode } from './types';
3
+ import { ViewMode, Column, MetadataProps } from './types';
4
4
  export interface MetadataViewProps extends MetadataProps {
5
- actionBarProps: Omit<ActionBarProps, 'onViewModeChange' | 'viewMode'>;
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 mockFilterRowArgs: {
12
- filterOptions: FilterOption[];
13
- onFilterSubmit: () => void;
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.21.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.0",
22
- "@box/metadata-filter": "^1.14.0",
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"