@canonical/react-components 2.2.4 → 2.3.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 (67) hide show
  1. package/dist/components/NotificationProvider/NotificationProvider.js +3 -2
  2. package/dist/components/NotificationProvider/messageBuilder.js +4 -4
  3. package/dist/components/NotificationProvider/types.d.ts +1 -1
  4. package/dist/components/{Notification → Notifications/Notification}/Notification.d.ts +1 -1
  5. package/dist/components/{Notification → Notifications/Notification}/Notification.js +2 -2
  6. package/dist/components/Notifications/ToastNotification/Animate.d.ts +11 -0
  7. package/dist/components/Notifications/ToastNotification/Animate.js +58 -0
  8. package/dist/components/Notifications/ToastNotification/Toast.scss +116 -0
  9. package/dist/components/Notifications/ToastNotification/ToastNotification.d.ts +10 -0
  10. package/dist/components/Notifications/ToastNotification/ToastNotification.js +63 -0
  11. package/dist/components/Notifications/ToastNotification/ToastNotification.stories.d.ts +6 -0
  12. package/dist/components/Notifications/ToastNotification/ToastNotification.stories.js +63 -0
  13. package/dist/components/Notifications/ToastNotification/ToastNotificationList.d.ts +21 -0
  14. package/dist/components/Notifications/ToastNotification/ToastNotificationList.js +215 -0
  15. package/dist/components/Notifications/ToastNotification/ToastNotificationProvider.d.ts +74 -0
  16. package/dist/components/Notifications/ToastNotification/ToastNotificationProvider.js +206 -0
  17. package/dist/components/Notifications/ToastNotification/index.d.ts +5 -0
  18. package/dist/components/Notifications/ToastNotification/index.js +35 -0
  19. package/dist/components/Notifications/index.d.ts +4 -0
  20. package/dist/components/Notifications/index.js +45 -0
  21. package/dist/esm/components/NotificationProvider/NotificationProvider.js +2 -1
  22. package/dist/esm/components/NotificationProvider/messageBuilder.js +1 -1
  23. package/dist/esm/components/NotificationProvider/types.d.ts +1 -1
  24. package/dist/esm/components/{Notification → Notifications/Notification}/Notification.d.ts +1 -1
  25. package/dist/esm/components/{Notification → Notifications/Notification}/Notification.js +2 -2
  26. package/dist/esm/components/Notifications/Notification/Notification.test.d.ts +1 -0
  27. package/dist/esm/components/Notifications/ToastNotification/Animate.d.ts +11 -0
  28. package/dist/esm/components/Notifications/ToastNotification/Animate.js +51 -0
  29. package/dist/esm/components/Notifications/ToastNotification/Toast.scss +116 -0
  30. package/dist/esm/components/Notifications/ToastNotification/ToastNotification.d.ts +10 -0
  31. package/dist/esm/components/Notifications/ToastNotification/ToastNotification.js +56 -0
  32. package/dist/esm/components/Notifications/ToastNotification/ToastNotification.stories.d.ts +6 -0
  33. package/dist/esm/components/Notifications/ToastNotification/ToastNotification.stories.js +54 -0
  34. package/dist/esm/components/Notifications/ToastNotification/ToastNotification.test.d.ts +1 -0
  35. package/dist/esm/components/Notifications/ToastNotification/ToastNotificationList.d.ts +21 -0
  36. package/dist/esm/components/Notifications/ToastNotification/ToastNotificationList.js +208 -0
  37. package/dist/esm/components/Notifications/ToastNotification/ToastNotificationProvider.d.ts +74 -0
  38. package/dist/esm/components/Notifications/ToastNotification/ToastNotificationProvider.js +201 -0
  39. package/dist/esm/components/Notifications/ToastNotification/index.d.ts +5 -0
  40. package/dist/esm/components/Notifications/ToastNotification/index.js +4 -0
  41. package/dist/esm/components/Notifications/index.d.ts +4 -0
  42. package/dist/esm/components/Notifications/index.js +2 -0
  43. package/dist/esm/hooks/index.d.ts +1 -0
  44. package/dist/esm/hooks/index.js +1 -0
  45. package/dist/esm/hooks/usePrefersReducedMotion.d.ts +6 -0
  46. package/dist/esm/hooks/usePrefersReducedMotion.js +23 -0
  47. package/dist/esm/hooks/usePrefersReducedMotion.test.d.ts +1 -0
  48. package/dist/esm/index.d.ts +5 -3
  49. package/dist/esm/index.js +3 -2
  50. package/dist/hooks/index.d.ts +1 -0
  51. package/dist/hooks/index.js +7 -0
  52. package/dist/hooks/usePrefersReducedMotion.d.ts +6 -0
  53. package/dist/hooks/usePrefersReducedMotion.js +30 -0
  54. package/dist/hooks/usePrefersReducedMotion.test.d.ts +1 -0
  55. package/dist/index.d.ts +5 -3
  56. package/dist/index.js +38 -3
  57. package/package.json +1 -1
  58. /package/dist/components/{Notification → Notifications/Notification}/Notification.stories.d.ts +0 -0
  59. /package/dist/components/{Notification → Notifications/Notification}/Notification.stories.js +0 -0
  60. /package/dist/components/{Notification → Notifications/Notification}/Notification.test.d.ts +0 -0
  61. /package/dist/components/{Notification → Notifications/Notification}/index.d.ts +0 -0
  62. /package/dist/components/{Notification → Notifications/Notification}/index.js +0 -0
  63. /package/dist/{esm/components/Notification/Notification.test.d.ts → components/Notifications/ToastNotification/ToastNotification.test.d.ts} +0 -0
  64. /package/dist/esm/components/{Notification → Notifications/Notification}/Notification.stories.d.ts +0 -0
  65. /package/dist/esm/components/{Notification → Notifications/Notification}/Notification.stories.js +0 -0
  66. /package/dist/esm/components/{Notification → Notifications/Notification}/index.d.ts +0 -0
  67. /package/dist/esm/components/{Notification → Notifications/Notification}/index.js +0 -0
@@ -35,7 +35,7 @@ export { default as ModularTable } from "./components/ModularTable";
35
35
  export { default as Navigation } from "./components/Navigation";
36
36
  export { default as Modal } from "./components/Modal";
37
37
  export * from "./components/MultiSelect";
38
- export { default as Notification, NotificationSeverity, } from "./components/Notification";
38
+ export { default as Notification, NotificationSeverity, } from "./components/Notifications";
39
39
  export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
40
40
  export { default as LoginPageLayout } from "./components/LoginPageLayout";
41
41
  export { default as Pagination } from "./components/Pagination";
@@ -64,6 +64,7 @@ export { default as TableHeader } from "./components/TableHeader";
64
64
  export { default as TableRow } from "./components/TableRow";
65
65
  export { default as Tabs } from "./components/Tabs";
66
66
  export { default as Textarea } from "./components/Textarea";
67
+ export { ToastNotification, ToastNotificationList, ToastNotificationProvider, useToastNotification, } from "./components/Notifications";
67
68
  export { default as Tooltip } from "./components/Tooltip";
68
69
  export { default as TablePagination } from "./components/TablePagination";
69
70
  export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
@@ -103,7 +104,7 @@ export type { MainTableProps } from "./components/MainTable";
103
104
  export type { ModularTableProps } from "./components/ModularTable";
104
105
  export type { ModalProps } from "./components/Modal";
105
106
  export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLinkAnchor, NavLinkBase, NavLinkButton, } from "./components/Navigation";
106
- export type { NotificationProps } from "./components/Notification";
107
+ export type { NotificationProps } from "./components/Notifications";
107
108
  export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
108
109
  export type { LoginPageLayoutProps } from "./components/LoginPageLayout";
109
110
  export type { PaginationProps } from "./components/Pagination";
@@ -130,10 +131,11 @@ export type { TableHeaderProps } from "./components/TableHeader";
130
131
  export type { TableRowProps } from "./components/TableRow";
131
132
  export type { TabsProps } from "./components/Tabs";
132
133
  export type { TextareaProps } from "./components/Textarea";
134
+ export type { ToastNotificationType } from "./components/Notifications";
133
135
  export type { TooltipProps } from "./components/Tooltip";
134
136
  export type { TablePaginationProps } from "./components/TablePagination";
135
137
  export type { CustomSelectProps, CustomSelectDropdownProps, CustomSelectOption, } from "./components/CustomSelect";
136
- export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, useThrottle, useWindowFitment, } from "./hooks";
138
+ export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, usePrefersReducedMotion, useThrottle, useWindowFitment, } from "./hooks";
137
139
  export type { WindowFitment } from "./hooks";
138
140
  export { isNavigationAnchor, isNavigationButton } from "./utils";
139
141
  export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, TSFixMe, ValueOf, } from "./types";
package/dist/esm/index.js CHANGED
@@ -35,7 +35,7 @@ export { default as ModularTable } from "./components/ModularTable";
35
35
  export { default as Navigation } from "./components/Navigation";
36
36
  export { default as Modal } from "./components/Modal";
37
37
  export * from "./components/MultiSelect";
38
- export { default as Notification, NotificationSeverity } from "./components/Notification";
38
+ export { default as Notification, NotificationSeverity } from "./components/Notifications";
39
39
  export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue } from "./components/NotificationProvider";
40
40
  export { default as LoginPageLayout } from "./components/LoginPageLayout";
41
41
  export { default as Pagination } from "./components/Pagination";
@@ -64,11 +64,12 @@ export { default as TableHeader } from "./components/TableHeader";
64
64
  export { default as TableRow } from "./components/TableRow";
65
65
  export { default as Tabs } from "./components/Tabs";
66
66
  export { default as Textarea } from "./components/Textarea";
67
+ export { ToastNotification, ToastNotificationList, ToastNotificationProvider, useToastNotification } from "./components/Notifications";
67
68
  export { default as Tooltip } from "./components/Tooltip";
68
69
  export { default as TablePagination } from "./components/TablePagination";
69
70
  export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
70
71
  export { default as CustomSelect } from "./components/CustomSelect";
71
- export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, useThrottle, useWindowFitment } from "./hooks";
72
+ export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, usePrefersReducedMotion, useThrottle, useWindowFitment } from "./hooks";
72
73
  export { isNavigationAnchor, isNavigationButton } from "./utils";
73
74
  export { Theme } from "./enums";
74
75
  export { usePortal } from "./external";
@@ -5,5 +5,6 @@ export { useOnEscapePressed } from "./useOnEscapePressed";
5
5
  export { usePrevious } from "./usePrevious";
6
6
  export { useThrottle } from "./useThrottle";
7
7
  export { usePagination } from "./usePagination";
8
+ export { usePrefersReducedMotion } from "./usePrefersReducedMotion";
8
9
  export { useWindowFitment } from "./useWindowFitment";
9
10
  export type { WindowFitment } from "./useWindowFitment";
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "usePagination", {
39
39
  return _usePagination.usePagination;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "usePrefersReducedMotion", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _usePrefersReducedMotion.usePrefersReducedMotion;
46
+ }
47
+ });
42
48
  Object.defineProperty(exports, "usePrevious", {
43
49
  enumerable: true,
44
50
  get: function () {
@@ -64,4 +70,5 @@ var _useOnEscapePressed = require("./useOnEscapePressed");
64
70
  var _usePrevious = require("./usePrevious");
65
71
  var _useThrottle = require("./useThrottle");
66
72
  var _usePagination = require("./usePagination");
73
+ var _usePrefersReducedMotion = require("./usePrefersReducedMotion");
67
74
  var _useWindowFitment = require("./useWindowFitment");
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns true if the user prefers reduced motion.
3
+ * It's useful for conditionally disabling animations for users who prefer reduced motion.
4
+ * @returns {boolean} - true if the user prefers reduced motion, false otherwise.
5
+ */
6
+ export declare const usePrefersReducedMotion: () => boolean;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.usePrefersReducedMotion = void 0;
7
+ var _react = require("react");
8
+ const QUERY = "(prefers-reduced-motion: reduce)";
9
+ const getInitialState = () => window.matchMedia(QUERY).matches;
10
+
11
+ /**
12
+ * Returns true if the user prefers reduced motion.
13
+ * It's useful for conditionally disabling animations for users who prefer reduced motion.
14
+ * @returns {boolean} - true if the user prefers reduced motion, false otherwise.
15
+ */
16
+ const usePrefersReducedMotion = () => {
17
+ const [prefersReducedMotion, setPrefersReducedMotion] = (0, _react.useState)(getInitialState);
18
+ (0, _react.useEffect)(() => {
19
+ const mediaQuery = window.matchMedia(QUERY);
20
+ const listener = event => {
21
+ setPrefersReducedMotion(event.matches);
22
+ };
23
+ mediaQuery.addEventListener("change", listener);
24
+ return () => {
25
+ mediaQuery.removeEventListener("change", listener);
26
+ };
27
+ }, []);
28
+ return prefersReducedMotion;
29
+ };
30
+ exports.usePrefersReducedMotion = usePrefersReducedMotion;
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export { default as ModularTable } from "./components/ModularTable";
35
35
  export { default as Navigation } from "./components/Navigation";
36
36
  export { default as Modal } from "./components/Modal";
37
37
  export * from "./components/MultiSelect";
38
- export { default as Notification, NotificationSeverity, } from "./components/Notification";
38
+ export { default as Notification, NotificationSeverity, } from "./components/Notifications";
39
39
  export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
40
40
  export { default as LoginPageLayout } from "./components/LoginPageLayout";
41
41
  export { default as Pagination } from "./components/Pagination";
@@ -64,6 +64,7 @@ export { default as TableHeader } from "./components/TableHeader";
64
64
  export { default as TableRow } from "./components/TableRow";
65
65
  export { default as Tabs } from "./components/Tabs";
66
66
  export { default as Textarea } from "./components/Textarea";
67
+ export { ToastNotification, ToastNotificationList, ToastNotificationProvider, useToastNotification, } from "./components/Notifications";
67
68
  export { default as Tooltip } from "./components/Tooltip";
68
69
  export { default as TablePagination } from "./components/TablePagination";
69
70
  export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
@@ -103,7 +104,7 @@ export type { MainTableProps } from "./components/MainTable";
103
104
  export type { ModularTableProps } from "./components/ModularTable";
104
105
  export type { ModalProps } from "./components/Modal";
105
106
  export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLinkAnchor, NavLinkBase, NavLinkButton, } from "./components/Navigation";
106
- export type { NotificationProps } from "./components/Notification";
107
+ export type { NotificationProps } from "./components/Notifications";
107
108
  export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
108
109
  export type { LoginPageLayoutProps } from "./components/LoginPageLayout";
109
110
  export type { PaginationProps } from "./components/Pagination";
@@ -130,10 +131,11 @@ export type { TableHeaderProps } from "./components/TableHeader";
130
131
  export type { TableRowProps } from "./components/TableRow";
131
132
  export type { TabsProps } from "./components/Tabs";
132
133
  export type { TextareaProps } from "./components/Textarea";
134
+ export type { ToastNotificationType } from "./components/Notifications";
133
135
  export type { TooltipProps } from "./components/Tooltip";
134
136
  export type { TablePaginationProps } from "./components/TablePagination";
135
137
  export type { CustomSelectProps, CustomSelectDropdownProps, CustomSelectOption, } from "./components/CustomSelect";
136
- export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, useThrottle, useWindowFitment, } from "./hooks";
138
+ export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, usePrefersReducedMotion, useThrottle, useWindowFitment, } from "./hooks";
137
139
  export type { WindowFitment } from "./hooks";
138
140
  export { isNavigationAnchor, isNavigationButton } from "./utils";
139
141
  export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, TSFixMe, ValueOf, } from "./types";
package/dist/index.js CHANGED
@@ -45,6 +45,10 @@ var _exportNames = {
45
45
  Modal: true,
46
46
  Notification: true,
47
47
  NotificationSeverity: true,
48
+ ToastNotification: true,
49
+ ToastNotificationList: true,
50
+ ToastNotificationProvider: true,
51
+ useToastNotification: true,
48
52
  NotificationConsumer: true,
49
53
  NotificationProvider: true,
50
54
  useNotify: true,
@@ -92,6 +96,7 @@ var _exportNames = {
92
96
  useOnEscapePressed: true,
93
97
  usePagination: true,
94
98
  usePrevious: true,
99
+ usePrefersReducedMotion: true,
95
100
  useThrottle: true,
96
101
  useWindowFitment: true,
97
102
  isNavigationAnchor: true,
@@ -348,7 +353,7 @@ Object.defineProperty(exports, "Navigation", {
348
353
  Object.defineProperty(exports, "Notification", {
349
354
  enumerable: true,
350
355
  get: function () {
351
- return _Notification.default;
356
+ return _Notifications.default;
352
357
  }
353
358
  });
354
359
  Object.defineProperty(exports, "NotificationConsumer", {
@@ -366,7 +371,7 @@ Object.defineProperty(exports, "NotificationProvider", {
366
371
  Object.defineProperty(exports, "NotificationSeverity", {
367
372
  enumerable: true,
368
373
  get: function () {
369
- return _Notification.NotificationSeverity;
374
+ return _Notifications.NotificationSeverity;
370
375
  }
371
376
  });
372
377
  Object.defineProperty(exports, "Pagination", {
@@ -555,6 +560,24 @@ Object.defineProperty(exports, "Theme", {
555
560
  return _enums.Theme;
556
561
  }
557
562
  });
563
+ Object.defineProperty(exports, "ToastNotification", {
564
+ enumerable: true,
565
+ get: function () {
566
+ return _Notifications.ToastNotification;
567
+ }
568
+ });
569
+ Object.defineProperty(exports, "ToastNotificationList", {
570
+ enumerable: true,
571
+ get: function () {
572
+ return _Notifications.ToastNotificationList;
573
+ }
574
+ });
575
+ Object.defineProperty(exports, "ToastNotificationProvider", {
576
+ enumerable: true,
577
+ get: function () {
578
+ return _Notifications.ToastNotificationProvider;
579
+ }
580
+ });
558
581
  Object.defineProperty(exports, "Tooltip", {
559
582
  enumerable: true,
560
583
  get: function () {
@@ -645,6 +668,12 @@ Object.defineProperty(exports, "usePortal", {
645
668
  return _external.usePortal;
646
669
  }
647
670
  });
671
+ Object.defineProperty(exports, "usePrefersReducedMotion", {
672
+ enumerable: true,
673
+ get: function () {
674
+ return _hooks.usePrefersReducedMotion;
675
+ }
676
+ });
648
677
  Object.defineProperty(exports, "usePrevious", {
649
678
  enumerable: true,
650
679
  get: function () {
@@ -657,6 +686,12 @@ Object.defineProperty(exports, "useThrottle", {
657
686
  return _hooks.useThrottle;
658
687
  }
659
688
  });
689
+ Object.defineProperty(exports, "useToastNotification", {
690
+ enumerable: true,
691
+ get: function () {
692
+ return _Notifications.useToastNotification;
693
+ }
694
+ });
660
695
  Object.defineProperty(exports, "useWindowFitment", {
661
696
  enumerable: true,
662
697
  get: function () {
@@ -711,7 +746,7 @@ Object.keys(_MultiSelect).forEach(function (key) {
711
746
  }
712
747
  });
713
748
  });
714
- var _Notification = _interopRequireWildcard(require("./components/Notification"));
749
+ var _Notifications = _interopRequireWildcard(require("./components/Notifications"));
715
750
  var _NotificationProvider = require("./components/NotificationProvider");
716
751
  var _LoginPageLayout = _interopRequireDefault(require("./components/LoginPageLayout"));
717
752
  var _Pagination = _interopRequireDefault(require("./components/Pagination"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "2.2.4",
3
+ "version": "2.3.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": {