@payfit/unity-components 2.19.2 → 2.20.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 (33) hide show
  1. package/dist/esm/components/action-bar/ActionBar.d.ts +61 -120
  2. package/dist/esm/components/action-bar/ActionBar.js +48 -151
  3. package/dist/esm/components/action-bar/ActionBar.types.d.ts +116 -0
  4. package/dist/esm/components/action-bar/ActionBar.variants.d.ts +31 -0
  5. package/dist/esm/components/action-bar/ActionBar.variants.js +26 -0
  6. package/dist/esm/components/action-bar/hooks/use-action-bar-state.d.ts +19 -0
  7. package/dist/esm/components/action-bar/hooks/use-action-bar-state.js +22 -0
  8. package/dist/esm/components/action-bar/parts/ActionBarButton.d.ts +58 -0
  9. package/dist/esm/components/action-bar/parts/ActionBarButton.js +35 -0
  10. package/dist/esm/components/action-bar/parts/ActionBarIconButton.d.ts +61 -0
  11. package/dist/esm/components/action-bar/parts/ActionBarIconButton.js +41 -0
  12. package/dist/esm/components/action-bar/parts/ActionBarOverflowMenu.d.ts +10 -0
  13. package/dist/esm/components/action-bar/parts/ActionBarOverflowMenu.js +45 -0
  14. package/dist/esm/components/action-bar/parts/ActionBarPrefixArea.d.ts +11 -0
  15. package/dist/esm/components/action-bar/parts/ActionBarPrefixArea.js +35 -0
  16. package/dist/esm/components/action-bar/parts/ActionBarRoot.d.ts +23 -0
  17. package/dist/esm/components/action-bar/parts/ActionBarRoot.js +23 -13
  18. package/dist/esm/components/action-bar/utils/action-bar-helpers.d.ts +14 -0
  19. package/dist/esm/components/action-bar/utils/action-bar-helpers.js +29 -0
  20. package/dist/esm/components/data-table/parts/DataTableBulkActions.d.ts +16 -6
  21. package/dist/esm/components/data-table/parts/DataTableBulkActions.js +122 -37
  22. package/dist/esm/components/icon-button/IconButton.d.ts +4 -0
  23. package/dist/esm/components/icon-button/IconButton.js +40 -31
  24. package/dist/esm/components/menu/parts/RawMenuItem.d.ts +2 -1
  25. package/dist/esm/components/menu/parts/RawMenuItem.js +14 -12
  26. package/dist/esm/index.d.ts +2 -1
  27. package/dist/esm/index.js +545 -543
  28. package/i18n/en-GB.json +2 -0
  29. package/i18n/es-ES.json +2 -0
  30. package/i18n/fr-FR.json +2 -0
  31. package/package.json +8 -8
  32. package/dist/esm/components/action-bar/parts/ActionBarAction.d.ts +0 -44
  33. package/dist/esm/components/action-bar/parts/ActionBarAction.js +0 -45
@@ -1,65 +1,150 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import { useRef as i, useState as A, useCallback as R } from "react";
3
- import { useHotkeys as u } from "react-hotkeys-hook";
4
- import { ActionBar as S } from "../../action-bar/ActionBar.js";
5
- import { ActionBarAction as p } from "../../action-bar/parts/ActionBarAction.js";
6
- import { ActionBarRoot as B } from "../../action-bar/parts/ActionBarRoot.js";
7
- function b({
8
- table: e,
9
- actions: s
1
+ import { jsx as o, jsxs as m, Fragment as A } from "react/jsx-runtime";
2
+ import { useRef as d, useState as S, useCallback as k } from "react";
3
+ import { useHotkeys as f } from "react-hotkeys-hook";
4
+ import { useIntl as v, FormattedMessage as c } from "react-intl";
5
+ import { ActionBar as I } from "../../action-bar/ActionBar.js";
6
+ import { ActionBarButton as P } from "../../action-bar/parts/ActionBarButton.js";
7
+ import { ActionBarIconButton as R } from "../../action-bar/parts/ActionBarIconButton.js";
8
+ import { ActionBarRoot as w } from "../../action-bar/parts/ActionBarRoot.js";
9
+ import { Button as x } from "../../button/Button.js";
10
+ function F({
11
+ selectionCount: t,
12
+ onClearSelection: a,
13
+ renderSelectionText: r,
14
+ hasKeyshortcuts: s,
15
+ keyShortcuts: n
10
16
  }) {
11
- const n = i(null), r = i(null), [a, t] = A(!1);
12
- u(
13
- "f6",
17
+ return /* @__PURE__ */ m(A, { children: [
18
+ /* @__PURE__ */ m(
19
+ "div",
20
+ {
21
+ className: "uy:typography-body uy:whitespace-nowrap! uy:sr-only uy:md:not-sr-only",
22
+ role: "status",
23
+ "aria-live": "polite",
24
+ "aria-atomic": "true",
25
+ children: [
26
+ r ? r(t) : /* @__PURE__ */ o(
27
+ c,
28
+ {
29
+ id: "unity:component:action-bar:selection-count-text",
30
+ defaultMessage: "{selectionCount, plural, =0 {no items} one {item} other {items}} selected",
31
+ values: { selectionCount: t }
32
+ }
33
+ ),
34
+ s && /* @__PURE__ */ o("span", { className: "uy:sr-only", children: /* @__PURE__ */ o(
35
+ c,
36
+ {
37
+ id: "unity:component:action-bar:key-shortcuts-text",
38
+ defaultMessage: "Use {keyShortcuts} to focus the action bar",
39
+ values: {
40
+ keyShortcuts: n
41
+ }
42
+ }
43
+ ) })
44
+ ]
45
+ }
46
+ ),
47
+ /* @__PURE__ */ o(x, { color: "inverted", variant: "ghost", onPress: a, children: /* @__PURE__ */ o(
48
+ c,
49
+ {
50
+ id: "unity:component:action-bar:clear-selection-button",
51
+ defaultMessage: "Clear selection"
52
+ }
53
+ ) })
54
+ ] });
55
+ }
56
+ const C = (t) => t.type === "icon-button";
57
+ function M({
58
+ table: t,
59
+ actions: a,
60
+ renderSelectionText: r
61
+ }) {
62
+ const s = d(null), n = d(null), [g, i] = S(!1), p = v(), l = "f6";
63
+ f(
64
+ l,
14
65
  () => {
15
- if ((e.getIsAllPageRowsSelected() || e.getIsSomePageRowsSelected()) && s && n.current) {
16
- const l = n.current.querySelectorAll(
66
+ if ((t.getIsAllPageRowsSelected() || t.getIsSomePageRowsSelected()) && s.current) {
67
+ const u = s.current.querySelectorAll(
17
68
  'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
18
69
  );
19
- r.current = document.activeElement, l.length > 0 && (l[0].focus(), t(!0));
70
+ n.current = document.activeElement, u.length > 0 && (u[0].focus(), i(!0));
20
71
  }
21
72
  },
22
73
  {
23
74
  enableOnFormTags: !0
24
75
  }
25
- ), u(
76
+ ), f(
26
77
  "esc",
27
78
  () => {
28
- a && r.current && (r.current.focus(), t(!1));
79
+ g && n.current && (n.current.focus(), i(!1));
29
80
  },
30
81
  {
31
82
  enableOnFormTags: !0
32
83
  }
33
84
  );
34
- const f = e.getIsAllPageRowsSelected() || e.getIsSomePageRowsSelected(), m = e.getSelectedRowModel().rows.length, d = e.getPageCount() > 0, g = R(() => {
35
- e.resetRowSelection();
36
- }, [e]);
37
- return s ? /* @__PURE__ */ c(
38
- B,
85
+ const b = t.getIsAllPageRowsSelected() || t.getIsSomePageRowsSelected(), y = t.getSelectedRowModel().rows.length, h = t.getPageCount() > 0, B = k(() => {
86
+ t.resetRowSelection();
87
+ }, [t]);
88
+ return /* @__PURE__ */ o(
89
+ w,
39
90
  {
40
- isVisible: f,
41
- offsetBottom: d ? "$600" : 0,
42
- children: /* @__PURE__ */ c(
43
- S,
91
+ isVisible: b,
92
+ offsetBottom: h ? "$600" : 0,
93
+ children: /* @__PURE__ */ o(
94
+ I,
44
95
  {
45
- ref: n,
46
- actions: s,
47
- selectionCount: m,
48
- onClearSelection: g,
96
+ ref: s,
97
+ actions: a,
98
+ prefixContent: /* @__PURE__ */ o(
99
+ F,
100
+ {
101
+ selectionCount: y,
102
+ onClearSelection: B,
103
+ renderSelectionText: r,
104
+ hasKeyshortcuts: !0,
105
+ keyShortcuts: l
106
+ }
107
+ ),
49
108
  onFocus: () => {
50
- t(!0);
109
+ i(!0);
51
110
  },
52
111
  onBlur: () => {
53
- t(!1);
112
+ i(!1);
54
113
  },
55
- "aria-keyshortcuts": "f6",
56
- children: (o) => /* @__PURE__ */ c(p, { ...o, children: o.label }, o.id)
114
+ "aria-keyshortcuts": l,
115
+ "aria-label": p.formatMessage({
116
+ id: "unity:component:action-bar:toolbar-label",
117
+ defaultMessage: "Bulk actions toolbar"
118
+ }),
119
+ children: (e) => C(e) ? /* @__PURE__ */ o(
120
+ R,
121
+ {
122
+ icon: e.meta.icon,
123
+ label: e.label,
124
+ variant: e.variant,
125
+ onPress: e.meta.onPress,
126
+ isDisabled: e.meta.isDisabled,
127
+ isLoading: e.meta.isLoading
128
+ },
129
+ e.id
130
+ ) : /* @__PURE__ */ o(
131
+ P,
132
+ {
133
+ variant: e.variant,
134
+ onPress: e.meta?.onPress,
135
+ prefixIcon: e.meta?.prefixIcon,
136
+ isDisabled: e.meta?.isDisabled,
137
+ isLoading: e.meta?.isLoading,
138
+ children: e.label
139
+ },
140
+ e.id
141
+ )
57
142
  }
58
143
  )
59
144
  }
60
- ) : null;
145
+ );
61
146
  }
62
- b.displayName = "DataTableBulkActions";
147
+ M.displayName = "DataTableBulkActions";
63
148
  export {
64
- b as DataTableBulkActions
149
+ M as DataTableBulkActions
65
150
  };
@@ -1,5 +1,6 @@
1
1
  import { UnityIcon } from '@payfit/unity-icons';
2
2
  import { AriaRole, ButtonHTMLAttributes } from 'react';
3
+ import { ButtonProps as AriaButtonProps } from 'react-aria-components';
3
4
  import { IconButtonGhost, IconButtonPrimary, IconButtonSecondary } from './IconButton.variants.js';
4
5
  interface IconButtonBaseProps {
5
6
  /** Label used to describe the action of the button */
@@ -8,6 +9,8 @@ interface IconButtonBaseProps {
8
9
  icon: UnityIcon;
9
10
  /** The function to trigger when the button is clicked */
10
11
  onClick?: () => void;
12
+ /** The function to trigger when the button is clicked or pressed in touch devices */
13
+ onPress?: AriaButtonProps['onPress'];
11
14
  /** Override the icon role */
12
15
  iconRole?: AriaRole;
13
16
  /** className to add to the button */
@@ -22,5 +25,6 @@ interface IconButtonVariantsSecondaryProps extends IconButtonBaseProps, Omit<Ico
22
25
  }
23
26
  interface IconButtonVariantsGhostProps extends IconButtonBaseProps, Omit<IconButtonGhost, 'variant' | 'color'>, Required<Pick<IconButtonGhost, 'variant' | 'color'>> {
24
27
  }
28
+ export type IconButtonProps = IconButtonVariantsPrimaryProps | IconButtonVariantsSecondaryProps | IconButtonVariantsGhostProps;
25
29
  export declare const IconButton: import('react').ForwardRefExoticComponent<(IconButtonVariantsPrimaryProps | IconButtonVariantsSecondaryProps | IconButtonVariantsGhostProps) & import('react').RefAttributes<HTMLButtonElement>>;
26
30
  export {};
@@ -1,50 +1,59 @@
1
- import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
- import { forwardRef as y } from "react";
3
- import { Button as b } from "react-aria-components";
4
- import B from "../../hooks/use-id.js";
5
- import { Icon as h } from "../icon/Icon.js";
6
- import { Spinner as I } from "../spinner/Spinner.js";
7
- import { Tooltip as N } from "../tooltip/Tooltip.js";
8
- import { iconButtonPrimary as x, iconButtonSecondary as j, iconButtonGhost as w } from "./IconButton.variants.js";
1
+ import { jsx as e, jsxs as y } from "react/jsx-runtime";
2
+ import { forwardRef as b } from "react";
3
+ import { Button as B } from "react-aria-components";
4
+ import h from "../../hooks/use-id.js";
5
+ import { Icon as I } from "../icon/Icon.js";
6
+ import { Spinner as N } from "../spinner/Spinner.js";
7
+ import { Tooltip as x } from "../tooltip/Tooltip.js";
8
+ import { iconButtonPrimary as P, iconButtonSecondary as j, iconButtonGhost as w } from "./IconButton.variants.js";
9
9
  const C = ({
10
10
  variant: o,
11
11
  color: r,
12
- isLoading: t,
13
- isDisabled: n
14
- }) => o === "primary" ? x({
12
+ isLoading: n,
13
+ isDisabled: t
14
+ }) => o === "primary" ? P({
15
15
  variant: o,
16
16
  color: r,
17
- isDisabled: n,
18
- isLoading: t
17
+ isDisabled: t,
18
+ isLoading: n
19
19
  }) : o === "secondary" ? j({
20
20
  variant: o,
21
21
  color: r,
22
- isDisabled: n,
23
- isLoading: t
22
+ isDisabled: t,
23
+ isLoading: n
24
24
  }) : w({
25
25
  variant: o,
26
26
  color: r,
27
- isDisabled: n,
28
- isLoading: t
29
- }), P = y(
27
+ isDisabled: t,
28
+ isLoading: n
29
+ }), R = b(
30
30
  (o, r) => {
31
- const t = B(), { button: n, icon: s } = C(o), { onClick: a, icon: m, isLoading: l, label: i, isDisabled: d, iconRole: u, ...f } = o, c = `icon-button-label-${t}`;
32
- return /* @__PURE__ */ e(N, { title: i, children: /* @__PURE__ */ p(
33
- b,
31
+ const n = h(), { button: t, icon: s } = C(o), {
32
+ onClick: a,
33
+ onPress: m,
34
+ icon: d,
35
+ isLoading: l,
36
+ label: i,
37
+ isDisabled: u,
38
+ iconRole: f,
39
+ ...p
40
+ } = o, c = `icon-button-label-${n}`;
41
+ return /* @__PURE__ */ e(x, { title: i, children: /* @__PURE__ */ y(
42
+ B,
34
43
  {
35
44
  ref: r,
36
45
  "data-dd-privacy": "allow",
37
- ...f,
38
- className: n({ class: o.className }),
39
- onPress: a,
40
- isDisabled: d || l,
46
+ ...p,
47
+ className: t({ class: o.className }),
48
+ onPress: m ?? a,
49
+ isDisabled: u || l,
41
50
  "aria-label": i,
42
51
  children: [
43
- l ? /* @__PURE__ */ e(I, { size: "small", label: "Loading", color: "inherit" }) : /* @__PURE__ */ e(
44
- h,
52
+ l ? /* @__PURE__ */ e(N, { size: "small", label: "Loading", color: "inherit" }) : /* @__PURE__ */ e(
53
+ I,
45
54
  {
46
- role: u,
47
- src: m,
55
+ role: f,
56
+ src: d,
48
57
  className: s(),
49
58
  "aria-labelledby": c,
50
59
  color: "inherit"
@@ -56,7 +65,7 @@ const C = ({
56
65
  ) });
57
66
  }
58
67
  );
59
- P.displayName = "IconButton";
68
+ R.displayName = "IconButton";
60
69
  export {
61
- P as IconButton
70
+ R as IconButton
62
71
  };
@@ -5,10 +5,11 @@ export interface MenuItemProps extends DataAttributes {
5
5
  children?: MenuItemAriaComponentProps['children'];
6
6
  href?: MenuItemAriaComponentProps['href'];
7
7
  onAction?: MenuItemAriaComponentProps['onAction'];
8
+ isDisabled?: MenuItemAriaComponentProps['isDisabled'];
8
9
  prefix?: ReactNode;
9
10
  className?: string;
10
11
  }
11
- export declare function RawMenuItem({ prefix, children, href, onAction, className, ...dataAttributes }: PropsWithChildren<MenuItemProps>): import("react/jsx-runtime").JSX.Element;
12
+ export declare function RawMenuItem({ prefix, children, href, onAction, className, isDisabled, ...dataAttributes }: PropsWithChildren<MenuItemProps>): import("react/jsx-runtime").JSX.Element;
12
13
  export declare namespace RawMenuItem {
13
14
  var displayName: string;
14
15
  }
@@ -1,32 +1,34 @@
1
- import { jsxs as o, jsx as s } from "react/jsx-runtime";
2
- import { uyMerge as y } from "@payfit/unity-themes";
3
- import { MenuItem as i } from "react-aria-components";
4
- function l({
1
+ import { jsxs as s, jsx as y } from "react/jsx-runtime";
2
+ import { uyMerge as i } from "@payfit/unity-themes";
3
+ import { MenuItem as l } from "react-aria-components";
4
+ function c({
5
5
  prefix: e,
6
6
  children: u,
7
7
  href: t,
8
8
  onAction: r,
9
9
  className: a,
10
- ...n
10
+ isDisabled: n,
11
+ ...o
11
12
  }) {
12
- return /* @__PURE__ */ o(
13
- i,
13
+ return /* @__PURE__ */ s(
14
+ l,
14
15
  {
15
16
  href: t,
17
+ isDisabled: n,
16
18
  onAction: r,
17
- className: y(
19
+ className: i(
18
20
  "uy:cursor-pointer uy:flex uy:p-100 uy:items-start uy:gap-100 uy:rounded-25 uy:typography-body uy:text-content-neutral uy:hover:bg-surface-neutral-hover uy:data-[pressed]:bg-surface-neutral-pressed uy:focus-visible:outline-utility-focus-ring uy:active:bg-surface-neutral-active",
19
21
  a
20
22
  ),
21
- ...n,
23
+ ...o,
22
24
  children: [
23
- /* @__PURE__ */ s("div", { className: "uy:text-content-neutral-low", children: e || null }),
25
+ /* @__PURE__ */ y("div", { className: "uy:text-content-neutral-low", children: e || null }),
24
26
  u
25
27
  ]
26
28
  }
27
29
  );
28
30
  }
29
- l.displayName = "RawMenuItem";
31
+ c.displayName = "RawMenuItem";
30
32
  export {
31
- l as RawMenuItem
33
+ c as RawMenuItem
32
34
  };
@@ -1,6 +1,7 @@
1
1
  export * from './components/actionable/Actionable.js';
2
2
  export * from './components/action-bar/ActionBar.js';
3
- export * from './components/action-bar/parts/ActionBarAction.js';
3
+ export * from './components/action-bar/parts/ActionBarButton.js';
4
+ export * from './components/action-bar/parts/ActionBarIconButton.js';
4
5
  export * from './components/action-bar/parts/ActionBarRoot.js';
5
6
  export * from './components/alert/Alert.js';
6
7
  export * from './components/alert/parts/AlertActions.js';