@box/metadata-view 0.23.2 → 0.24.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.
Files changed (64) hide show
  1. package/dist/chunks/form-filter-chip.js +66 -0
  2. package/dist/esm/lib/components/error-state/error-state.js +1 -1
  3. package/dist/esm/lib/components/filter-row/filter-row.js +41 -64
  4. package/dist/esm/lib/components/filter-row/{string-filter-chip.js → form-filter-chip.js} +4 -4
  5. package/dist/esm/lib/components/filter-row/initial-field-values.js +16 -11
  6. package/dist/esm/lib/components/filter-row/messages.js +4 -0
  7. package/dist/esm/lib/components/filter-row/metadata-filter-chip.js +50 -0
  8. package/dist/esm/lib/components/filter-row/select-filter-chip.js +54 -0
  9. package/dist/esm/lib/components/pagination/index.js +10 -0
  10. package/dist/esm/lib/components/pagination/marker-based-pagination.js +20 -0
  11. package/dist/esm/lib/components/pagination/messages.js +22 -0
  12. package/dist/esm/lib/components/pagination/offset-based-pagination.js +32 -0
  13. package/dist/esm/lib/components/pagination/pagination-controls.js +53 -0
  14. package/dist/esm/lib/components/pagination/pagination.js +34 -5
  15. package/dist/esm/lib/components/pagination/utils.js +7 -0
  16. package/dist/esm/lib/metadata-view.js +42 -38
  17. package/dist/i18n/bn-IN.js +6 -1
  18. package/dist/i18n/da-DK.js +6 -1
  19. package/dist/i18n/de-DE.js +6 -1
  20. package/dist/i18n/en-AU.js +6 -1
  21. package/dist/i18n/en-CA.js +6 -1
  22. package/dist/i18n/en-GB.js +6 -1
  23. package/dist/i18n/en-US.js +6 -1
  24. package/dist/i18n/en-US.properties +10 -0
  25. package/dist/i18n/en-x-pseudo.js +6 -1
  26. package/dist/i18n/es-419.js +6 -1
  27. package/dist/i18n/es-ES.js +6 -1
  28. package/dist/i18n/fi-FI.js +6 -1
  29. package/dist/i18n/fr-CA.js +6 -1
  30. package/dist/i18n/fr-FR.js +6 -1
  31. package/dist/i18n/hi-IN.js +6 -1
  32. package/dist/i18n/it-IT.js +6 -1
  33. package/dist/i18n/ja-JP.js +6 -1
  34. package/dist/i18n/json/src/lib/components/filter-row/messages.json +1 -1
  35. package/dist/i18n/json/src/lib/components/pagination/messages.json +1 -0
  36. package/dist/i18n/ko-KR.js +6 -1
  37. package/dist/i18n/nb-NO.js +6 -1
  38. package/dist/i18n/nl-NL.js +6 -1
  39. package/dist/i18n/pl-PL.js +6 -1
  40. package/dist/i18n/pt-BR.js +6 -1
  41. package/dist/i18n/ru-RU.js +6 -1
  42. package/dist/i18n/sv-SE.js +6 -1
  43. package/dist/i18n/tr-TR.js +6 -1
  44. package/dist/i18n/zh-CN.js +6 -1
  45. package/dist/i18n/zh-TW.js +6 -1
  46. package/dist/styles/pagination-controls.css +1 -0
  47. package/dist/types/lib/components/filter-row/form-filter-chip.d.ts +10 -0
  48. package/dist/types/lib/components/filter-row/messages.d.ts +5 -0
  49. package/dist/types/lib/components/filter-row/metadata-filter-chip.d.ts +8 -0
  50. package/dist/types/lib/components/filter-row/select-filter-chip.d.ts +11 -0
  51. package/dist/types/lib/components/filter-row/types.d.ts +1 -0
  52. package/dist/types/lib/components/pagination/index.d.ts +8 -0
  53. package/dist/types/lib/components/pagination/marker-based-pagination.d.ts +7 -0
  54. package/dist/types/lib/components/pagination/messages.d.ts +23 -0
  55. package/dist/types/lib/components/pagination/offset-based-pagination.d.ts +8 -0
  56. package/dist/types/lib/components/pagination/pagination-controls.d.ts +12 -0
  57. package/dist/types/lib/components/pagination/pagination.d.ts +8 -1
  58. package/dist/types/lib/components/pagination/utils.d.ts +8 -0
  59. package/dist/types/lib/metadata-view.d.ts +5 -3
  60. package/dist/types/lib/test-utils/mock-data.d.ts +55 -0
  61. package/package.json +2 -2
  62. package/dist/chunks/string-filter-chip.js +0 -69
  63. package/dist/types/lib/components/filter-row/string-filter-chip.d.ts +0 -2
  64. /package/dist/styles/{string-filter-chip.css → form-filter-chip.css} +0 -0
@@ -0,0 +1,11 @@
1
+ import { MetadataFieldType } from '@box/metadata-view';
2
+ export interface SelectFilterChipProps {
3
+ fieldNamePrefix: string;
4
+ formRef: React.RefObject<HTMLFormElement>;
5
+ icon?: React.ForwardRefExoticComponent<Omit<React.SVGProps<SVGSVGElement>, 'ref'> & React.RefAttributes<SVGSVGElement>>;
6
+ id: string;
7
+ name: string;
8
+ options?: string[];
9
+ type: MetadataFieldType;
10
+ }
11
+ export declare const SelectFilterChip: ({ fieldNamePrefix, formRef, icon, id, name, options, type, }: SelectFilterChipProps) => import("react/jsx-runtime").JSX.Element;
@@ -10,6 +10,7 @@ export interface FilterOption {
10
10
  icon?: React.ForwardRefExoticComponent<Omit<React.SVGProps<SVGSVGElement>, 'ref'> & React.RefAttributes<SVGSVGElement>>;
11
11
  id: string;
12
12
  name?: string;
13
+ options?: string[];
13
14
  placeholder?: string;
14
15
  selected: boolean;
15
16
  shouldRenderChip?: boolean;
@@ -0,0 +1,8 @@
1
+ export { default as Pagination } from './pagination';
2
+ export type { PaginationProps } from './pagination';
3
+ export { default as PaginationControls } from './pagination-controls';
4
+ export type { PaginationControlsProps } from './pagination-controls';
5
+ export { default as OffsetBasedPagination } from './offset-based-pagination';
6
+ export type { OffsetBasedPaginationProps } from './offset-based-pagination';
7
+ export { default as MarkerBasedPagination } from './marker-based-pagination';
8
+ export type { MarkerBasedPaginationProps } from './marker-based-pagination';
@@ -0,0 +1,7 @@
1
+ export interface MarkerBasedPaginationProps {
2
+ hasNextMarker?: boolean;
3
+ hasPrevMarker?: boolean;
4
+ onMarkerBasedPageChange: (pageDirection: number) => void;
5
+ }
6
+ export declare const MarkerBasedPagination: ({ hasNextMarker, hasPrevMarker, onMarkerBasedPageChange, }: MarkerBasedPaginationProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default MarkerBasedPagination;
@@ -0,0 +1,23 @@
1
+ declare const messages: {
2
+ nextPageButton: {
3
+ defaultMessage: string;
4
+ description: string;
5
+ id: string;
6
+ };
7
+ pageEntryStatus: {
8
+ defaultMessage: string;
9
+ description: string;
10
+ id: string;
11
+ };
12
+ paginationAriaLabel: {
13
+ defaultMessage: string;
14
+ description: string;
15
+ id: string;
16
+ };
17
+ previousPageButton: {
18
+ defaultMessage: string;
19
+ description: string;
20
+ id: string;
21
+ };
22
+ };
23
+ export default messages;
@@ -0,0 +1,8 @@
1
+ export interface OffsetBasedPaginationProps {
2
+ offset: number;
3
+ onOffsetChange?: (offset: number) => void;
4
+ pageSize: number;
5
+ totalCount: number;
6
+ }
7
+ export declare const OffsetBasedPagination: ({ offset, onOffsetChange, pageSize, totalCount }: OffsetBasedPaginationProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default OffsetBasedPagination;
@@ -0,0 +1,12 @@
1
+ export interface PaginationControlsProps {
2
+ handleNextClick: () => void;
3
+ handlePreviousClick: () => void;
4
+ hasNextPage: boolean;
5
+ hasPageEntryStatus?: boolean;
6
+ hasPreviousPage: boolean;
7
+ offset?: number;
8
+ pageSize?: number;
9
+ totalCount?: number;
10
+ }
11
+ declare const PaginationControls: ({ handleNextClick, handlePreviousClick, hasNextPage, hasPageEntryStatus, hasPreviousPage, offset, pageSize, totalCount, }: PaginationControlsProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default PaginationControls;
@@ -1,2 +1,9 @@
1
- declare const Pagination: () => import("react/jsx-runtime").JSX.Element;
1
+ import { MarkerBasedPaginationProps } from './marker-based-pagination';
2
+ import { OffsetBasedPaginationProps } from './offset-based-pagination';
3
+ export type PaginationProps = ({
4
+ type: 'marker';
5
+ } & MarkerBasedPaginationProps) | ({
6
+ type: 'offset';
7
+ } & OffsetBasedPaginationProps);
8
+ declare const Pagination: ({ type, ...rest }: PaginationProps) => import("react/jsx-runtime").JSX.Element;
2
9
  export default Pagination;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the offset for the given page number, page size, and total count
3
+ * @param newPageNumber - The page number to get the offset for
4
+ * @param pageSize - The size of the page
5
+ * @param totalCount - The total number of items
6
+ * @returns The offset for the given page number
7
+ */
8
+ export declare const getOffsetForPage: (newPageNumber: number, pageSize: number, totalCount: number) => number;
@@ -1,13 +1,15 @@
1
1
  import { MetadataTableProps } from './components/metadata-table';
2
+ import { PaginationProps } from './components/pagination/pagination';
2
3
  import { ActionBarProps } from './components/action-bar';
3
4
  import { ViewMode, Column, MetadataProps } from './types';
4
5
  export interface MetadataViewProps extends MetadataProps {
5
6
  columns: Column[];
6
- actionBarProps: Omit<ActionBarProps, 'onViewModeChange' | 'viewMode' | 'sortableColumnNames'>;
7
+ actionBarProps?: Omit<ActionBarProps, 'onViewModeClick' | 'viewMode' | 'sortableColumnNames'>;
7
8
  hasError?: boolean;
8
9
  initialViewMode?: ViewMode;
9
10
  onRefresh?: () => void;
10
- tableProps: Omit<MetadataTableProps, 'items' | 'itemActionMenuProps'>;
11
+ tableProps: Omit<MetadataTableProps, 'columns' | 'items' | 'itemActionMenuProps'>;
12
+ paginationProps?: PaginationProps;
11
13
  }
12
- export declare function MetadataView({ actionBarProps, columns, tableProps, hasError, onRefresh, initialViewMode, ...rest }: MetadataViewProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function MetadataView({ actionBarProps, columns, tableProps, hasError, onRefresh, initialViewMode, paginationProps, ...rest }: MetadataViewProps): import("react/jsx-runtime").JSX.Element;
13
15
  export default MetadataView;
@@ -5,6 +5,7 @@ import { SortDropdownProps } from '../components/action-bar/sort-dropdown';
5
5
  import { FilterRowProps } from '../components/filter-row/filter-row';
6
6
  import { FilterGroup, FilterOption } from '../components/filter-row/types';
7
7
  import { MetadataTableProps } from '../components/metadata-table';
8
+ import { PaginationProps } from '../components/pagination/pagination';
8
9
  import { MetadataViewProps } from '../metadata-view';
9
10
  import { Column } from '../types';
10
11
  export declare const getMockFilterGroups: (filters: FilterOption[]) => {
@@ -29,6 +30,60 @@ export declare const mockFilterGroups: {
29
30
  togglable: boolean;
30
31
  filters: FilterOption[];
31
32
  }[];
33
+ export declare const mockTypedPaginationPropsMarker: PaginationProps;
34
+ export declare const mockTypedPaginationPropsOffset: PaginationProps;
35
+ export declare const mockPaginationPropsOffsetWithNoAdditionalPages: {
36
+ offset: number;
37
+ onOffsetChange: (...args: any[]) => void;
38
+ pageSize: number;
39
+ totalCount: number;
40
+ type: "offset";
41
+ };
42
+ export declare const mockPaginationPropsOffsetWithPageAtZero: {
43
+ totalCount: number;
44
+ offset: number;
45
+ onOffsetChange: (...args: any[]) => void;
46
+ pageSize: number;
47
+ type: "offset";
48
+ };
49
+ export declare const mockPaginationPropsOffsetWithPageInMiddleOfData: {
50
+ offset: number;
51
+ totalCount: number;
52
+ onOffsetChange: (...args: any[]) => void;
53
+ pageSize: number;
54
+ type: "offset";
55
+ };
56
+ export declare const mockPaginationPropsOffsetWithPageAtEndOfData: {
57
+ offset: number;
58
+ totalCount: number;
59
+ onOffsetChange: (...args: any[]) => void;
60
+ pageSize: number;
61
+ type: "offset";
62
+ };
63
+ export declare const mockPaginationPropsMarkerWithNoMarkers: {
64
+ hasNextMarker: boolean;
65
+ hasPrevMarker: boolean;
66
+ type: "marker";
67
+ onMarkerBasedPageChange: (pageDirection: number) => void;
68
+ };
69
+ export declare const mockPaginationPropsMarkerWithNextMarker: {
70
+ hasNextMarker: boolean;
71
+ hasPrevMarker: boolean;
72
+ type: "marker";
73
+ onMarkerBasedPageChange: (pageDirection: number) => void;
74
+ };
75
+ export declare const mockPaginationPropsMarkerWithPrevMarker: {
76
+ hasPrevMarker: boolean;
77
+ hasNextMarker: boolean;
78
+ type: "marker";
79
+ onMarkerBasedPageChange: (pageDirection: number) => void;
80
+ };
81
+ export declare const mockPaginationPropsMarkerWithNextAndPrevMarkers: {
82
+ hasNextMarker: boolean;
83
+ hasPrevMarker: boolean;
84
+ type: "marker";
85
+ onMarkerBasedPageChange: (pageDirection: number) => void;
86
+ };
32
87
  export declare const mockFilterRowArgs: FilterRowProps;
33
88
  export declare const mockActionBarProps: ActionBarProps;
34
89
  export declare const mockTableProps: MetadataTableProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "0.23.2",
3
+ "version": "0.24.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^11.12.0",
@@ -20,7 +20,7 @@
20
20
  "@box/blueprint-web-assets": "^4.57.0",
21
21
  "@box/eslint-plugin-blueprint": "*",
22
22
  "@box/item-icon": "^0.13.5",
23
- "@box/metadata-filter": "^1.14.5",
23
+ "@box/metadata-filter": "^1.15.0",
24
24
  "@box/storybook-utils": "0.13.11",
25
25
  "@box/types": "0.2.0",
26
26
  "react-intl": "^6.4.2"
@@ -1,69 +0,0 @@
1
- import { Popover as o, FilterChip as t, Button as m } from "@box/blueprint-web";
2
- import { MetadataStringField as C } from "@box/metadata-filter";
3
- import { useState as v } from "react";
4
- import { useIntl as F } from "react-intl";
5
- import { useFormikContext as g } from "formik";
6
- import c from "../esm/lib/components/filter-row/messages.js";
7
- import { jsx as e, jsxs as i } from "react/jsx-runtime";
8
- import '../styles/string-filter-chip.css';const y = "_popoverFooter_6tqyh_1", _ = "_filterChipGroup_6tqyh_9", b = {
9
- popoverFooter: y,
10
- filterChipGroup: _
11
- }, O = ({
12
- formRef: d,
13
- id: r,
14
- name: n,
15
- selected: h,
16
- icon: a
17
- }) => {
18
- const {
19
- formatMessage: l
20
- } = F(), [f, s] = v(!1), p = g(), u = () => {
21
- p.handleSubmit(), s(!1);
22
- };
23
- return /* @__PURE__ */ e("div", {
24
- children: /* @__PURE__ */ i(o.Root, {
25
- onOpenChange: s,
26
- open: f,
27
- children: [/* @__PURE__ */ e(o.Trigger, {
28
- children: /* @__PURE__ */ i(t.TriggerChip, {
29
- selected: h,
30
- value: r,
31
- children: [a && /* @__PURE__ */ e(t.Icon, {
32
- icon: a
33
- }), /* @__PURE__ */ e(t.Label, {
34
- children: n
35
- }), /* @__PURE__ */ e(t.DropdownIndicator, {})]
36
- }, r)
37
- }), /* @__PURE__ */ i(o.ContentContainer, {
38
- align: "start",
39
- container: d.current,
40
- children: [/* @__PURE__ */ e(o.MainContent, {
41
- children: /* @__PURE__ */ e(C, {
42
- fieldNamePrefix: `metadata.fields.${r}`,
43
- label: n
44
- })
45
- }), /* @__PURE__ */ i(o.Footer, {
46
- className: b.popoverFooter,
47
- children: [/* @__PURE__ */ e(m, {
48
- onClick: () => {
49
- p.setFieldValue(`metadata.fields.${r}.value.enum`, []);
50
- },
51
- size: "small",
52
- variant: "secondary",
53
- children: l(c.clearButton)
54
- }), /* @__PURE__ */ e(m, {
55
- onClick: u,
56
- size: "small",
57
- type: "submit",
58
- variant: "primary",
59
- children: l(c.applyButton)
60
- })]
61
- })]
62
- })]
63
- })
64
- });
65
- };
66
- export {
67
- O as S,
68
- b as s
69
- };
@@ -1,2 +0,0 @@
1
- import { FilterChipProps } from './types';
2
- export declare const StringFilterChip: ({ formRef, id, name, selected, icon }: FilterChipProps) => import("react/jsx-runtime").JSX.Element;