@box/metadata-view 0.23.1 → 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 (68) hide show
  1. package/dist/chunks/form-filter-chip.js +66 -0
  2. package/dist/esm/lib/components/action-bar/action-bar.js +35 -33
  3. package/dist/esm/lib/components/error-state/error-state.js +1 -1
  4. package/dist/esm/lib/components/filter-row/filter-row.js +40 -62
  5. package/dist/esm/lib/components/filter-row/form-filter-chip.js +11 -0
  6. package/dist/esm/lib/components/filter-row/initial-field-values.js +16 -11
  7. package/dist/esm/lib/components/filter-row/messages.js +4 -0
  8. package/dist/esm/lib/components/filter-row/metadata-filter-chip.js +50 -0
  9. package/dist/esm/lib/components/filter-row/select-filter-chip.js +54 -0
  10. package/dist/esm/lib/components/pagination/index.js +10 -0
  11. package/dist/esm/lib/components/pagination/marker-based-pagination.js +20 -0
  12. package/dist/esm/lib/components/pagination/messages.js +22 -0
  13. package/dist/esm/lib/components/pagination/offset-based-pagination.js +32 -0
  14. package/dist/esm/lib/components/pagination/pagination-controls.js +53 -0
  15. package/dist/esm/lib/components/pagination/pagination.js +34 -5
  16. package/dist/esm/lib/components/pagination/utils.js +7 -0
  17. package/dist/esm/lib/metadata-view.js +58 -49
  18. package/dist/i18n/bn-IN.js +6 -1
  19. package/dist/i18n/da-DK.js +6 -1
  20. package/dist/i18n/de-DE.js +6 -1
  21. package/dist/i18n/en-AU.js +6 -1
  22. package/dist/i18n/en-CA.js +6 -1
  23. package/dist/i18n/en-GB.js +6 -1
  24. package/dist/i18n/en-US.js +6 -1
  25. package/dist/i18n/en-US.properties +10 -0
  26. package/dist/i18n/en-x-pseudo.js +6 -1
  27. package/dist/i18n/es-419.js +6 -1
  28. package/dist/i18n/es-ES.js +6 -1
  29. package/dist/i18n/fi-FI.js +6 -1
  30. package/dist/i18n/fr-CA.js +6 -1
  31. package/dist/i18n/fr-FR.js +6 -1
  32. package/dist/i18n/hi-IN.js +6 -1
  33. package/dist/i18n/it-IT.js +6 -1
  34. package/dist/i18n/ja-JP.js +6 -1
  35. package/dist/i18n/json/src/lib/components/filter-row/messages.json +1 -1
  36. package/dist/i18n/json/src/lib/components/pagination/messages.json +1 -0
  37. package/dist/i18n/ko-KR.js +6 -1
  38. package/dist/i18n/nb-NO.js +6 -1
  39. package/dist/i18n/nl-NL.js +6 -1
  40. package/dist/i18n/pl-PL.js +6 -1
  41. package/dist/i18n/pt-BR.js +6 -1
  42. package/dist/i18n/ru-RU.js +6 -1
  43. package/dist/i18n/sv-SE.js +6 -1
  44. package/dist/i18n/tr-TR.js +6 -1
  45. package/dist/i18n/zh-CN.js +6 -1
  46. package/dist/i18n/zh-TW.js +6 -1
  47. package/dist/styles/action-bar.css +1 -1
  48. package/dist/styles/form-filter-chip.css +1 -0
  49. package/dist/styles/metadata-view.css +1 -0
  50. package/dist/styles/pagination-controls.css +1 -0
  51. package/dist/types/lib/components/filter-row/form-filter-chip.d.ts +10 -0
  52. package/dist/types/lib/components/filter-row/messages.d.ts +5 -0
  53. package/dist/types/lib/components/filter-row/metadata-filter-chip.d.ts +8 -0
  54. package/dist/types/lib/components/filter-row/select-filter-chip.d.ts +11 -0
  55. package/dist/types/lib/components/filter-row/types.d.ts +1 -0
  56. package/dist/types/lib/components/pagination/index.d.ts +8 -0
  57. package/dist/types/lib/components/pagination/marker-based-pagination.d.ts +7 -0
  58. package/dist/types/lib/components/pagination/messages.d.ts +23 -0
  59. package/dist/types/lib/components/pagination/offset-based-pagination.d.ts +8 -0
  60. package/dist/types/lib/components/pagination/pagination-controls.d.ts +12 -0
  61. package/dist/types/lib/components/pagination/pagination.d.ts +8 -1
  62. package/dist/types/lib/components/pagination/utils.d.ts +8 -0
  63. package/dist/types/lib/metadata-view.d.ts +5 -3
  64. package/dist/types/lib/test-utils/mock-data.d.ts +55 -0
  65. package/package.json +3 -3
  66. package/dist/esm/lib/components/filter-row/string-filter-chip.js +0 -67
  67. package/dist/styles/string-filter-chip.css +0 -1
  68. package/dist/types/lib/components/filter-row/string-filter-chip.d.ts +0 -2
@@ -0,0 +1,66 @@
1
+ import { useState as v } from "react";
2
+ import { useIntl as F } from "react-intl";
3
+ import { Popover as e, FilterChip as r, Button as l } from "@box/blueprint-web";
4
+ import { useFormikContext as g } from "formik";
5
+ import m from "../esm/lib/components/filter-row/messages.js";
6
+ import { jsx as o, jsxs as t } from "react/jsx-runtime";
7
+ import '../styles/form-filter-chip.css';const y = "_popoverFooter_6tqyh_1", _ = "_filterChipGroup_6tqyh_9", b = {
8
+ popoverFooter: y,
9
+ filterChipGroup: _
10
+ }, j = ({
11
+ children: c,
12
+ formRef: h,
13
+ icon: i,
14
+ id: n,
15
+ name: u,
16
+ selected: d
17
+ }) => {
18
+ const {
19
+ formatMessage: s
20
+ } = F(), [f, p] = v(!1), a = g(), C = () => {
21
+ a.handleSubmit(), p(!1);
22
+ };
23
+ return /* @__PURE__ */ o("div", {
24
+ children: /* @__PURE__ */ t(e.Root, {
25
+ onOpenChange: p,
26
+ open: f,
27
+ children: [/* @__PURE__ */ o(e.Trigger, {
28
+ children: /* @__PURE__ */ t(r.TriggerChip, {
29
+ selected: d,
30
+ value: n,
31
+ children: [i && /* @__PURE__ */ o(r.Icon, {
32
+ icon: i
33
+ }), /* @__PURE__ */ o(r.Label, {
34
+ children: u
35
+ }), /* @__PURE__ */ o(r.DropdownIndicator, {})]
36
+ }, n)
37
+ }), /* @__PURE__ */ t(e.ContentContainer, {
38
+ align: "start",
39
+ container: h.current,
40
+ children: [/* @__PURE__ */ o(e.MainContent, {
41
+ children: c
42
+ }), /* @__PURE__ */ t(e.Footer, {
43
+ className: b.popoverFooter,
44
+ children: [/* @__PURE__ */ o(l, {
45
+ onClick: () => {
46
+ a.setFieldValue(`metadata.fields.${n}.value.enum`, []);
47
+ },
48
+ size: "small",
49
+ variant: "secondary",
50
+ children: s(m.clearButton)
51
+ }), /* @__PURE__ */ o(l, {
52
+ onClick: C,
53
+ size: "small",
54
+ type: "submit",
55
+ variant: "primary",
56
+ children: s(m.applyButton)
57
+ })]
58
+ })]
59
+ })]
60
+ })
61
+ });
62
+ };
63
+ export {
64
+ j as F,
65
+ b as s
66
+ };
@@ -1,45 +1,47 @@
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";
1
+ import { Button as d } from "@box/blueprint-web";
2
+ import { Grid as f } from "@box/blueprint-web-assets/icons/Fill";
3
+ import { useIntl as p } from "react-intl";
4
+ import { V as s } from "../../../../chunks/types.js";
5
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
6
+ import { SortDropdown as w } from "./sort-dropdown.js";
7
+ import { jsxs as c, jsx as i } from "react/jsx-runtime";
8
+ import { FilterRow as _ } from "../filter-row/filter-row.js";
9
+ import '../../../../styles/action-bar.css';const R = "_actionBar_1jgp4_1", B = "_filterRow_1jgp4_8", g = "_additionalActions_1jgp4_13", o = {
10
+ actionBar: R,
11
+ filterRow: B,
12
+ additionalActions: g
13
+ }, y = ({
14
+ onViewModeClick: e,
15
+ viewMode: t,
16
+ sortableColumnNames: m,
17
+ sortDropdownProps: r,
18
+ ...l
18
19
  }) => {
19
20
  const {
20
21
  formatMessage: a
21
- } = f();
22
- return /* @__PURE__ */ s("div", {
23
- className: c.actionBar,
22
+ } = p();
23
+ return /* @__PURE__ */ c("div", {
24
+ className: o.actionBar,
24
25
  children: [/* @__PURE__ */ i("div", {
25
- children: /* @__PURE__ */ i(B, {
26
- ...d
26
+ className: o.filterRow,
27
+ children: /* @__PURE__ */ i(_, {
28
+ ...l
27
29
  })
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"
30
+ }), /* @__PURE__ */ c("div", {
31
+ className: o.additionalActions,
32
+ children: [r && /* @__PURE__ */ i(w, {
33
+ ...r,
34
+ sortableColumnNames: m
35
+ }), /* @__PURE__ */ i(d, {
36
+ "aria-label": t === s.GRID ? a(n.switchToListView) : a(n.switchToGridView),
37
+ icon: f,
38
+ onClick: e,
39
+ variant: t === s.GRID ? "primary" : "tertiary"
38
40
  })]
39
41
  })]
40
42
  });
41
43
  };
42
44
  export {
43
- I as ActionBar,
44
- I as default
45
+ y as ActionBar,
46
+ y as default
45
47
  };
@@ -1,5 +1,5 @@
1
1
  import { EmptyState as r, Text as a } from "@box/blueprint-web";
2
- import { Unplugged as s } from "@box/blueprint-web-assets/illustrations/Medium/";
2
+ import { Unplugged as s } from "@box/blueprint-web-assets/illustrations/Medium";
3
3
  import { useIntl as i } from "react-intl";
4
4
  import o from "./messages.js";
5
5
  import { jsx as t } from "react/jsx-runtime";
@@ -1,75 +1,53 @@
1
- import { FilterChip as n } from "@box/blueprint-web";
2
- import { Formik as C, Form as v } from "formik";
3
- import { useState as I, useRef as b } from "react";
4
- import w from "./all-filters-chip.js";
5
- import { getInitialFieldValues as R } from "./initial-field-values.js";
6
- import { StringFilterChip as j } from "./string-filter-chip.js";
7
- import { usePredefinedFilter as x } from "./use-predefined-filter.js";
8
- import { jsx as r, jsxs as p } from "react/jsx-runtime";
9
- const G = (e, a, m) => {
10
- const {
11
- icon: i
12
- } = e;
13
- switch (e.fieldType) {
14
- case "float":
15
- case "string":
16
- return /* @__PURE__ */ r(j, {
17
- formRef: m,
18
- icon: i,
19
- id: e.id,
20
- name: e.name,
21
- selected: a
22
- }, e.id);
23
- case "date":
24
- case "enum":
25
- case "multiSelect":
26
- return /* @__PURE__ */ p(n.Chip, {
27
- value: e.id,
28
- children: [i && /* @__PURE__ */ r(n.Icon, {
29
- icon: i
30
- }), /* @__PURE__ */ r(n.Label, {
31
- children: e.name
32
- })]
33
- }, e.id);
34
- default:
35
- return null;
36
- }
37
- }, _ = ({
38
- disabledPredefinedFilters: e = [],
1
+ import { useState as S, useRef as C } from "react";
2
+ import { Formik as v, Form as G } from "formik";
3
+ import { FilterChip as I } from "@box/blueprint-web";
4
+ import R from "./all-filters-chip.js";
5
+ import { getInitialFieldValues as b } from "./initial-field-values.js";
6
+ import { MetadataFilterChip as g } from "./metadata-filter-chip.js";
7
+ import { usePredefinedFilter as j } from "./use-predefined-filter.js";
8
+ import { s as w } from "../../../../chunks/form-filter-chip.js";
9
+ import { jsx as i, jsxs as x } from "react/jsx-runtime";
10
+ const z = ({
11
+ disabledPredefinedFilters: n = [],
39
12
  filterGroups: a,
40
- isAllFiltersDisabled: m,
41
- onFilterSubmit: i
13
+ isAllFiltersDisabled: d,
14
+ onFilterSubmit: p
42
15
  }) => {
43
- const [o, h] = I([]), f = x(e), F = ([t, l]) => {
44
- var s;
45
- return ((s = l.value) == null ? void 0 : s.enum) && l.value.enum.length > 0;
46
- }, S = ({
16
+ const [l, u] = S([]), c = j(n), f = ([e, t]) => {
17
+ var r;
18
+ return ((r = t.value) == null ? void 0 : r.enum) && t.value.enum.length > 0;
19
+ }, F = ({
47
20
  metadata: {
48
- fields: t
21
+ fields: e
49
22
  }
50
23
  }) => {
51
- const l = Object.entries(t).filter(F).map(([s]) => s);
52
- h(l), i(t);
53
- }, c = [...f, ...a], d = c.flatMap(({
54
- filters: t
55
- }) => t), g = R(d), u = b(null);
56
- return /* @__PURE__ */ r(C, {
57
- initialValues: g,
58
- onSubmit: S,
59
- children: /* @__PURE__ */ r(v, {
60
- ref: u,
61
- children: /* @__PURE__ */ p(n.Group, {
24
+ const t = Object.entries(e).filter(f).map(([r]) => r);
25
+ u(t), p(e);
26
+ }, s = [...c, ...a], o = s.flatMap(({
27
+ filters: e
28
+ }) => e), h = b(o), m = C(null);
29
+ return /* @__PURE__ */ i(v, {
30
+ initialValues: h,
31
+ onSubmit: F,
32
+ children: /* @__PURE__ */ i(G, {
33
+ ref: m,
34
+ children: /* @__PURE__ */ x(I.Group, {
35
+ className: w.filterChipGroup,
62
36
  name: "metadata-view-filters",
63
37
  type: "multiple",
64
- children: [m ? null : /* @__PURE__ */ r(w, {
65
- activeFilterCount: o.length,
66
- filterGroups: c
67
- }), d.filter((t) => t.shouldRenderChip).map((t) => G(t, o.includes(t.id), u))]
38
+ children: [d ? null : /* @__PURE__ */ i(R, {
39
+ activeFilterCount: l.length,
40
+ filterGroups: s
41
+ }), o.filter((e) => e.shouldRenderChip).map((e) => /* @__PURE__ */ i(g, {
42
+ filterOption: e,
43
+ formRef: m,
44
+ selected: l.includes(e.id)
45
+ }, e.id))]
68
46
  })
69
47
  })
70
48
  });
71
49
  };
72
50
  export {
73
- _ as FilterRow,
74
- _ as default
51
+ z as FilterRow,
52
+ z as default
75
53
  };
@@ -0,0 +1,11 @@
1
+ import "react";
2
+ import "react-intl";
3
+ import "@box/blueprint-web";
4
+ import "formik";
5
+ import { F as e, F as f } from "../../../../chunks/form-filter-chip.js";
6
+ import "./messages.js";
7
+ import "react/jsx-runtime";
8
+ export {
9
+ e as FormFilterChip,
10
+ f as default
11
+ };
@@ -1,21 +1,26 @@
1
- const u = (i) => ({
1
+ const s = (t) => ({
2
2
  metadata: {
3
- fields: i.reduce((a, l) => {
4
- let e;
5
- switch (l.fieldType) {
6
- case "string":
3
+ fields: t.reduce((l, e) => {
4
+ let a;
5
+ switch (e.fieldType) {
6
+ case "date":
7
7
  case "float":
8
- e = [""];
8
+ case "string":
9
+ a = [""];
10
+ break;
11
+ case "enum":
12
+ case "multiSelect":
13
+ e.options && (a = [...e.options]);
9
14
  break;
10
15
  default:
11
- e = null;
16
+ a = null;
12
17
  }
13
- return a[l.id] = {
14
- value: e
15
- }, a;
18
+ return l[e.id] = {
19
+ value: a
20
+ }, l;
16
21
  }, {})
17
22
  }
18
23
  });
19
24
  export {
20
- u as getInitialFieldValues
25
+ s as getInitialFieldValues
21
26
  };
@@ -19,6 +19,10 @@ const t = e({
19
19
  keywordSearchFilterPlaceholder: {
20
20
  id: "groupSharedFeatures.metadataView.filterRow.keywordSearchFilterPlaceholder",
21
21
  defaultMessage: "Enter keywords"
22
+ },
23
+ chipNameWithCount: {
24
+ id: "groupSharedFeatures.metadataView.filterRow.chipNameWithCount",
25
+ defaultMessage: "{name} ({count})"
22
26
  }
23
27
  });
24
28
  export {
@@ -0,0 +1,50 @@
1
+ import { MetadataStringField as m } from "@box/metadata-filter";
2
+ import { F as d } from "../../../../chunks/form-filter-chip.js";
3
+ import { SelectFilterChip as p } from "./select-filter-chip.js";
4
+ import { jsx as a } from "react/jsx-runtime";
5
+ const x = ({
6
+ filterOption: s,
7
+ formRef: i,
8
+ selected: n
9
+ }) => {
10
+ const {
11
+ fieldType: r,
12
+ icon: l,
13
+ id: e,
14
+ name: t,
15
+ options: c
16
+ } = s, o = `metadata.fields.${e}`;
17
+ switch (r) {
18
+ case "float":
19
+ case "string":
20
+ return /* @__PURE__ */ a(d, {
21
+ formRef: i,
22
+ icon: l,
23
+ id: e,
24
+ name: t,
25
+ selected: n,
26
+ children: /* @__PURE__ */ a(m, {
27
+ fieldNamePrefix: o,
28
+ label: t
29
+ })
30
+ }, e);
31
+ case "date":
32
+ case "enum":
33
+ case "multiSelect":
34
+ return /* @__PURE__ */ a(p, {
35
+ fieldNamePrefix: o,
36
+ formRef: i,
37
+ icon: l,
38
+ id: e,
39
+ name: t,
40
+ options: c,
41
+ type: r
42
+ });
43
+ default:
44
+ return null;
45
+ }
46
+ };
47
+ export {
48
+ x as MetadataFilterChip,
49
+ x as default
50
+ };
@@ -0,0 +1,54 @@
1
+ import { useState as a } from "react";
2
+ import { useFormikContext as O } from "formik";
3
+ import { DropdownMenu as c, FilterChip as o } from "@box/blueprint-web";
4
+ import { useIntl as S } from "react-intl";
5
+ import V from "./messages.js";
6
+ import { jsxs as u, jsx as t } from "react/jsx-runtime";
7
+ const T = ({
8
+ fieldNamePrefix: d,
9
+ formRef: C,
10
+ icon: h,
11
+ id: m,
12
+ name: s,
13
+ options: i,
14
+ type: f
15
+ }) => {
16
+ const {
17
+ formatMessage: g
18
+ } = S(), [b, k] = a(!1), [w, p] = a(s), [l, x] = a(/* @__PURE__ */ new Set()), {
19
+ setFieldValue: F,
20
+ submitForm: v
21
+ } = O(), I = async (r, n) => {
22
+ const e = new Set(l);
23
+ f === "enum" ? e.clear() : e.delete(n), r && e.add(n), x(e), e.size > 0 ? p(g(V.chipNameWithCount, {
24
+ name: s,
25
+ count: e.size
26
+ })) : p(s), F(`${d}.value.enum`, Array.from(e)), v();
27
+ };
28
+ return /* @__PURE__ */ u(c.Root, {
29
+ onOpenChange: k,
30
+ open: b,
31
+ children: [/* @__PURE__ */ t(c.Trigger, {
32
+ asChild: !0,
33
+ children: /* @__PURE__ */ u(o.TriggerChip, {
34
+ selected: l.size > 0,
35
+ value: m,
36
+ children: [h && /* @__PURE__ */ t(o.Icon, {
37
+ icon: h
38
+ }), /* @__PURE__ */ t(o.Label, {
39
+ children: w
40
+ }), /* @__PURE__ */ t(o.DropdownIndicator, {})]
41
+ }, m)
42
+ }), /* @__PURE__ */ t(c.Content, {
43
+ container: C.current,
44
+ children: i == null ? void 0 : i.map((r) => /* @__PURE__ */ t(c.CheckboxItem, {
45
+ checked: l.has(r),
46
+ onCheckedChange: (n) => I(n, r),
47
+ children: r
48
+ }, r))
49
+ })]
50
+ });
51
+ };
52
+ export {
53
+ T as SelectFilterChip
54
+ };
@@ -0,0 +1,10 @@
1
+ import { default as t } from "./pagination.js";
2
+ import { default as e } from "./pagination-controls.js";
3
+ import { OffsetBasedPagination as f } from "./offset-based-pagination.js";
4
+ import { MarkerBasedPagination as s } from "./marker-based-pagination.js";
5
+ export {
6
+ s as MarkerBasedPagination,
7
+ f as OffsetBasedPagination,
8
+ t as Pagination,
9
+ e as PaginationControls
10
+ };
@@ -0,0 +1,20 @@
1
+ import i from "./pagination-controls.js";
2
+ import { jsx as a } from "react/jsx-runtime";
3
+ const c = ({
4
+ hasNextMarker: t,
5
+ hasPrevMarker: e,
6
+ onMarkerBasedPageChange: o
7
+ }) => /* @__PURE__ */ a(i, {
8
+ handleNextClick: () => {
9
+ o(1);
10
+ },
11
+ handlePreviousClick: () => {
12
+ o(-1);
13
+ },
14
+ hasNextPage: t,
15
+ hasPreviousPage: e
16
+ });
17
+ export {
18
+ c as MarkerBasedPagination,
19
+ c as default
20
+ };
@@ -0,0 +1,22 @@
1
+ import { defineMessages as a } from "react-intl";
2
+ const t = a({
3
+ nextPageButton: {
4
+ id: "groupSharedFeatures.metadataView.pagination.nextPageButton",
5
+ defaultMessage: "Next"
6
+ },
7
+ pageEntryStatus: {
8
+ id: "groupSharedFeatures.metadataView.pagination.pageEntryStatus",
9
+ defaultMessage: "Showing {startEntryIndex} to {endEntryIndex} of {totalCount} entries"
10
+ },
11
+ paginationAriaLabel: {
12
+ id: "groupSharedFeatures.metadataView.pagination.paginationLabel",
13
+ defaultMessage: "Pagination navigation controls and current page information"
14
+ },
15
+ previousPageButton: {
16
+ id: "groupSharedFeatures.metadataView.pagination.previousPageButton",
17
+ defaultMessage: "Previous"
18
+ }
19
+ });
20
+ export {
21
+ t as default
22
+ };
@@ -0,0 +1,32 @@
1
+ import h from "./pagination-controls.js";
2
+ import { getOffsetForPage as c } from "./utils.js";
3
+ import { jsx as P } from "react/jsx-runtime";
4
+ const x = ({
5
+ offset: n,
6
+ onOffsetChange: o,
7
+ pageSize: t,
8
+ totalCount: r
9
+ }) => {
10
+ const e = Math.ceil(r / t);
11
+ if (e <= 1)
12
+ return null;
13
+ const a = Math.floor(n / t) + 1, s = a > 0 ? Math.min(e, a) : 1, i = s < e, l = s > 1;
14
+ return /* @__PURE__ */ P(h, {
15
+ handleNextClick: () => {
16
+ o(c(s + 1, t, r));
17
+ },
18
+ handlePreviousClick: () => {
19
+ o(c(s - 1, t, r));
20
+ },
21
+ hasNextPage: i,
22
+ hasPageEntryStatus: !0,
23
+ hasPreviousPage: l,
24
+ offset: n,
25
+ pageSize: t,
26
+ totalCount: r
27
+ });
28
+ };
29
+ export {
30
+ x as OffsetBasedPagination,
31
+ x as default
32
+ };
@@ -0,0 +1,53 @@
1
+ import { Button as r } from "@box/blueprint-web";
2
+ import { useIntl as x, FormattedMessage as B } from "react-intl";
3
+ import n from "./messages.js";
4
+ import { jsxs as s, jsx as a } from "react/jsx-runtime";
5
+ import '../../../../styles/pagination-controls.css';const h = "_pagination_1ozaq_1", y = "_paginationButtonContainer_1ozaq_9", i = {
6
+ pagination: h,
7
+ paginationButtonContainer: y
8
+ }, E = ({
9
+ handleNextClick: l,
10
+ handlePreviousClick: c,
11
+ hasNextPage: d,
12
+ hasPageEntryStatus: p,
13
+ hasPreviousPage: g,
14
+ offset: o = 0,
15
+ pageSize: m = 0,
16
+ totalCount: e = 0
17
+ }) => {
18
+ const {
19
+ formatMessage: t
20
+ } = x(), u = o + 1, v = Math.min(o + m, e);
21
+ return /* @__PURE__ */ s("div", {
22
+ "aria-label": t(n.paginationAriaLabel),
23
+ "aria-live": "polite",
24
+ className: i.pagination,
25
+ children: [p && /* @__PURE__ */ a("div", {
26
+ className: i.paginationText,
27
+ children: /* @__PURE__ */ a(B, {
28
+ ...n.pageEntryStatus,
29
+ values: {
30
+ startEntryIndex: u,
31
+ endEntryIndex: v,
32
+ totalCount: e
33
+ }
34
+ })
35
+ }), /* @__PURE__ */ s("div", {
36
+ className: i.paginationButtonContainer,
37
+ children: [/* @__PURE__ */ a(r, {
38
+ disabled: !g,
39
+ onClick: c,
40
+ variant: "secondary",
41
+ children: t(n.previousPageButton)
42
+ }), /* @__PURE__ */ a(r, {
43
+ disabled: !d,
44
+ onClick: l,
45
+ variant: "secondary",
46
+ children: t(n.nextPageButton)
47
+ })]
48
+ })]
49
+ });
50
+ };
51
+ export {
52
+ E as default
53
+ };
@@ -1,7 +1,36 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- const t = () => /* @__PURE__ */ i("div", {
3
- children: "Pagination"
4
- });
1
+ import { MarkerBasedPagination as g } from "./marker-based-pagination.js";
2
+ import { OffsetBasedPagination as p } from "./offset-based-pagination.js";
3
+ import { jsx as r } from "react/jsx-runtime";
4
+ import "./pagination-controls.js";
5
+ const u = ({
6
+ type: e,
7
+ ...a
8
+ }) => {
9
+ if (e === "marker") {
10
+ const {
11
+ hasNextMarker: s,
12
+ hasPrevMarker: f,
13
+ onMarkerBasedPageChange: m
14
+ } = a;
15
+ return /* @__PURE__ */ r(g, {
16
+ hasNextMarker: s,
17
+ hasPrevMarker: f,
18
+ onMarkerBasedPageChange: m
19
+ });
20
+ }
21
+ const {
22
+ offset: t,
23
+ onOffsetChange: o,
24
+ pageSize: n,
25
+ totalCount: i
26
+ } = a;
27
+ return /* @__PURE__ */ r(p, {
28
+ offset: t,
29
+ onOffsetChange: o,
30
+ pageSize: n,
31
+ totalCount: i
32
+ });
33
+ };
5
34
  export {
6
- t as default
35
+ u as default
7
36
  };
@@ -0,0 +1,7 @@
1
+ const n = (f, e, t) => {
2
+ const r = (f - 1) * e;
3
+ return r <= 0 ? 0 : r >= t ? Math.max(t - e, 0) : r;
4
+ };
5
+ export {
6
+ n as getOffsetForPage
7
+ };