@canonical/react-components 0.36.0 → 0.37.2

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 (74) hide show
  1. package/dist/components/Accordion/Accordion.js +1 -1
  2. package/dist/components/ActionButton/ActionButton.js +1 -1
  3. package/dist/components/ArticlePagination/ArticlePagination.js +1 -1
  4. package/dist/components/Button/Button.d.ts +1 -0
  5. package/dist/components/Button/Button.js +2 -1
  6. package/dist/components/Card/Card.js +1 -1
  7. package/dist/components/CheckableInput/CheckableInput.js +1 -1
  8. package/dist/components/CheckboxInput/CheckboxInput.js +1 -1
  9. package/dist/components/Chip/Chip.js +1 -1
  10. package/dist/components/Code/Code.js +1 -1
  11. package/dist/components/CodeSnippet/CodeSnippet.js +1 -1
  12. package/dist/components/CodeSnippet/CodeSnippetBlock.js +1 -1
  13. package/dist/components/CodeSnippet/CodeSnippetDropdown.js +1 -1
  14. package/dist/components/Col/Col.js +1 -1
  15. package/dist/components/ContextualMenu/ContextualMenu.js +1 -2
  16. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +1 -1
  17. package/dist/components/Form/Form.js +1 -1
  18. package/dist/components/Icon/Icon.js +1 -1
  19. package/dist/components/Input/Input.js +1 -1
  20. package/dist/components/Label/Label.js +1 -1
  21. package/dist/components/Link/Link.js +1 -1
  22. package/dist/components/List/List.js +28 -17
  23. package/dist/components/MainTable/MainTable.js +2 -2
  24. package/dist/components/Modal/Modal.js +1 -1
  25. package/dist/components/ModularTable/ModularTable.js +1 -1
  26. package/dist/components/Navigation/Navigation.d.ts +58 -0
  27. package/dist/components/Navigation/Navigation.js +276 -0
  28. package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +10 -0
  29. package/dist/components/Navigation/NavigationLink/NavigationLink.js +74 -0
  30. package/dist/components/Navigation/NavigationLink/index.d.ts +1 -0
  31. package/dist/components/Navigation/NavigationLink/index.js +15 -0
  32. package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
  33. package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +105 -0
  34. package/dist/components/Navigation/NavigationMenu/index.d.ts +1 -0
  35. package/dist/components/Navigation/NavigationMenu/index.js +15 -0
  36. package/dist/components/Navigation/index.d.ts +3 -0
  37. package/dist/components/Navigation/index.js +15 -0
  38. package/dist/components/Navigation/types.d.ts +64 -0
  39. package/dist/components/Navigation/types.js +5 -0
  40. package/dist/components/Notification/Notification.js +1 -1
  41. package/dist/components/PasswordToggle/PasswordToggle.js +1 -1
  42. package/dist/components/RadioInput/RadioInput.js +1 -1
  43. package/dist/components/Row/Row.js +1 -1
  44. package/dist/components/SearchAndFilter/SearchAndFilter.js +12 -16
  45. package/dist/components/SearchBox/SearchBox.d.ts +6 -5
  46. package/dist/components/SearchBox/SearchBox.js +22 -8
  47. package/dist/components/Select/Select.js +1 -1
  48. package/dist/components/Slider/Slider.js +1 -1
  49. package/dist/components/Spinner/Spinner.js +1 -1
  50. package/dist/components/StatusLabel/StatusLabel.d.ts +31 -0
  51. package/dist/components/StatusLabel/StatusLabel.js +51 -0
  52. package/dist/components/StatusLabel/index.d.ts +2 -0
  53. package/dist/components/StatusLabel/index.js +25 -0
  54. package/dist/components/Strip/Strip.js +1 -1
  55. package/dist/components/Switch/Switch.js +1 -1
  56. package/dist/components/Table/Table.js +1 -1
  57. package/dist/components/TableCell/TableCell.js +1 -1
  58. package/dist/components/TableHeader/TableHeader.js +1 -1
  59. package/dist/components/TableRow/TableRow.js +1 -1
  60. package/dist/components/Tabs/Tabs.js +1 -1
  61. package/dist/components/Textarea/Textarea.js +1 -1
  62. package/dist/enums.d.ts +13 -0
  63. package/dist/enums.js +17 -0
  64. package/dist/hooks/index.d.ts +4 -2
  65. package/dist/hooks/index.js +19 -3
  66. package/dist/hooks/useClickOutside.d.ts +7 -0
  67. package/dist/hooks/useClickOutside.js +41 -0
  68. package/dist/hooks/useOnEscapePressed.d.ts +4 -0
  69. package/dist/hooks/useOnEscapePressed.js +27 -0
  70. package/dist/index.d.ts +7 -1
  71. package/dist/index.js +56 -0
  72. package/dist/utils.d.ts +11 -0
  73. package/dist/utils.js +24 -2
  74. package/package.json +42 -40
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export { default as List } from "./components/List";
19
19
  export { default as Loader } from "./components/Loader";
20
20
  export { default as MainTable } from "./components/MainTable";
21
21
  export { default as ModularTable } from "./components/ModularTable";
22
+ export { default as Navigation } from "./components/Navigation";
22
23
  export { default as Modal } from "./components/Modal";
23
24
  export { default as Notification, NotificationSeverity, } from "./components/Notification";
24
25
  export { default as Pagination } from "./components/Pagination";
@@ -31,6 +32,7 @@ export { default as Select } from "./components/Select";
31
32
  export { default as Slider } from "./components/Slider";
32
33
  export { default as Switch } from "./components/Switch";
33
34
  export { default as Spinner } from "./components/Spinner";
35
+ export { default as StatusLabel, StatusLabelAppearance, } from "./components/StatusLabel";
34
36
  export { default as Strip } from "./components/Strip";
35
37
  export { default as SummaryButton } from "./components/SummaryButton";
36
38
  export { default as Table } from "./components/Table";
@@ -63,6 +65,7 @@ export type { ListProps } from "./components/List";
63
65
  export type { MainTableProps } from "./components/MainTable";
64
66
  export type { ModularTableProps } from "./components/ModularTable";
65
67
  export type { ModalProps } from "./components/Modal";
68
+ export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLinkAnchor, NavLinkBase, NavLinkButton, } from "./components/Navigation";
66
69
  export type { NotificationProps } from "./components/Notification";
67
70
  export type { PaginationProps } from "./components/Pagination";
68
71
  export type { RadioInputProps } from "./components/RadioInput";
@@ -72,6 +75,7 @@ export type { SearchBoxProps } from "./components/SearchBox";
72
75
  export type { SelectProps } from "./components/Select";
73
76
  export type { SliderProps } from "./components/Slider";
74
77
  export type { SpinnerProps } from "./components/Spinner";
78
+ export type { StatusLabelProps } from "./components/StatusLabel";
75
79
  export type { StripProps } from "./components/Strip";
76
80
  export type { SummaryButtonProps } from "./components/SummaryButton";
77
81
  export type { TableProps } from "./components/Table";
@@ -81,6 +85,8 @@ export type { TableRowProps } from "./components/TableRow";
81
85
  export type { TabsProps } from "./components/Tabs";
82
86
  export type { TextareaProps } from "./components/Textarea";
83
87
  export type { TooltipProps } from "./components/Tooltip";
84
- export { useWindowFitment, useListener, usePrevious, useThrottle, useId, } from "./hooks";
88
+ export { useClickOutside, useId, useListener, useOnEscapePressed, usePrevious, useThrottle, useWindowFitment, } from "./hooks";
85
89
  export type { WindowFitment } from "./hooks";
90
+ export { isNavigationAnchor, isNavigationButton } from "./utils";
86
91
  export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, TSFixMe, ValueOf, } from "./types";
92
+ export { Theme } from "./enums";
package/dist/index.js CHANGED
@@ -155,6 +155,12 @@ Object.defineProperty(exports, "ModularTable", {
155
155
  return _ModularTable.default;
156
156
  }
157
157
  });
158
+ Object.defineProperty(exports, "Navigation", {
159
+ enumerable: true,
160
+ get: function get() {
161
+ return _Navigation.default;
162
+ }
163
+ });
158
164
  Object.defineProperty(exports, "Notification", {
159
165
  enumerable: true,
160
166
  get: function get() {
@@ -221,6 +227,18 @@ Object.defineProperty(exports, "Spinner", {
221
227
  return _Spinner.default;
222
228
  }
223
229
  });
230
+ Object.defineProperty(exports, "StatusLabel", {
231
+ enumerable: true,
232
+ get: function get() {
233
+ return _StatusLabel.default;
234
+ }
235
+ });
236
+ Object.defineProperty(exports, "StatusLabelAppearance", {
237
+ enumerable: true,
238
+ get: function get() {
239
+ return _StatusLabel.StatusLabelAppearance;
240
+ }
241
+ });
224
242
  Object.defineProperty(exports, "Strip", {
225
243
  enumerable: true,
226
244
  get: function get() {
@@ -275,12 +293,36 @@ Object.defineProperty(exports, "Textarea", {
275
293
  return _Textarea.default;
276
294
  }
277
295
  });
296
+ Object.defineProperty(exports, "Theme", {
297
+ enumerable: true,
298
+ get: function get() {
299
+ return _enums.Theme;
300
+ }
301
+ });
278
302
  Object.defineProperty(exports, "Tooltip", {
279
303
  enumerable: true,
280
304
  get: function get() {
281
305
  return _Tooltip.default;
282
306
  }
283
307
  });
308
+ Object.defineProperty(exports, "isNavigationAnchor", {
309
+ enumerable: true,
310
+ get: function get() {
311
+ return _utils.isNavigationAnchor;
312
+ }
313
+ });
314
+ Object.defineProperty(exports, "isNavigationButton", {
315
+ enumerable: true,
316
+ get: function get() {
317
+ return _utils.isNavigationButton;
318
+ }
319
+ });
320
+ Object.defineProperty(exports, "useClickOutside", {
321
+ enumerable: true,
322
+ get: function get() {
323
+ return _hooks.useClickOutside;
324
+ }
325
+ });
284
326
  Object.defineProperty(exports, "useId", {
285
327
  enumerable: true,
286
328
  get: function get() {
@@ -293,6 +335,12 @@ Object.defineProperty(exports, "useListener", {
293
335
  return _hooks.useListener;
294
336
  }
295
337
  });
338
+ Object.defineProperty(exports, "useOnEscapePressed", {
339
+ enumerable: true,
340
+ get: function get() {
341
+ return _hooks.useOnEscapePressed;
342
+ }
343
+ });
296
344
  Object.defineProperty(exports, "usePrevious", {
297
345
  enumerable: true,
298
346
  get: function get() {
@@ -354,6 +402,8 @@ var _MainTable = _interopRequireDefault(require("./components/MainTable"));
354
402
 
355
403
  var _ModularTable = _interopRequireDefault(require("./components/ModularTable"));
356
404
 
405
+ var _Navigation = _interopRequireDefault(require("./components/Navigation"));
406
+
357
407
  var _Modal = _interopRequireDefault(require("./components/Modal"));
358
408
 
359
409
  var _Notification = _interopRequireWildcard(require("./components/Notification"));
@@ -378,6 +428,8 @@ var _Switch = _interopRequireDefault(require("./components/Switch"));
378
428
 
379
429
  var _Spinner = _interopRequireDefault(require("./components/Spinner"));
380
430
 
431
+ var _StatusLabel = _interopRequireWildcard(require("./components/StatusLabel"));
432
+
381
433
  var _Strip = _interopRequireDefault(require("./components/Strip"));
382
434
 
383
435
  var _SummaryButton = _interopRequireDefault(require("./components/SummaryButton"));
@@ -398,6 +450,10 @@ var _Tooltip = _interopRequireDefault(require("./components/Tooltip"));
398
450
 
399
451
  var _hooks = require("./hooks");
400
452
 
453
+ var _utils = require("./utils");
454
+
455
+ var _enums = require("./enums");
456
+
401
457
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
402
458
 
403
459
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { NavLink, NavLinkAnchor, NavLinkButton } from "./components/Navigation";
1
2
  export declare const IS_DEV: boolean;
2
3
  /**
3
4
  * Find substring and wrap in <strong /> tag
@@ -9,3 +10,13 @@ export declare const highlightSubString: (str?: string, subString?: string) => {
9
10
  text: string;
10
11
  match: boolean;
11
12
  };
13
+ /**
14
+ * Whether a navigation item is an anchor.
15
+ * @param link - The navigation item.
16
+ */
17
+ export declare const isNavigationAnchor: (link: NavLink) => link is NavLinkAnchor;
18
+ /**
19
+ * Whether a navigation item is a button.
20
+ * @param link - The navigation item.
21
+ */
22
+ export declare const isNavigationButton: (link: NavLink) => link is NavLinkButton;
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.highlightSubString = exports.IS_DEV = void 0;
6
+ exports.isNavigationButton = exports.isNavigationAnchor = exports.highlightSubString = exports.IS_DEV = void 0;
7
7
  var IS_DEV = process.env.NODE_ENV === "development";
8
8
  /**
9
9
  * Find substring and wrap in <strong /> tag
@@ -31,5 +31,27 @@ var highlightSubString = function highlightSubString(str, subString) {
31
31
  match: newStr !== str
32
32
  };
33
33
  };
34
+ /**
35
+ * Whether a navigation item is an anchor.
36
+ * @param link - The navigation item.
37
+ */
38
+
39
+
40
+ exports.highlightSubString = highlightSubString;
41
+
42
+ var isNavigationAnchor = function isNavigationAnchor(link) {
43
+ return !!link.url;
44
+ };
45
+ /**
46
+ * Whether a navigation item is a button.
47
+ * @param link - The navigation item.
48
+ */
49
+
50
+
51
+ exports.isNavigationAnchor = isNavigationAnchor;
52
+
53
+ var isNavigationButton = function isNavigationButton(link) {
54
+ return !link.url;
55
+ };
34
56
 
35
- exports.highlightSubString = highlightSubString;
57
+ exports.isNavigationButton = isNavigationButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "0.36.0",
3
+ "version": "0.37.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "Huw Wilkins <huw.wilkins@canonical.com>",
@@ -22,87 +22,89 @@
22
22
  },
23
23
  "homepage": "/react-components/",
24
24
  "devDependencies": {
25
- "@babel/cli": "7.17.6",
26
- "@babel/eslint-parser": "7.17.0",
27
- "@babel/preset-typescript": "7.16.7",
28
- "@percy/cli": "1.0.5",
29
- "@percy/storybook": "4.2.0",
30
- "@storybook/addon-a11y": "6.4.20",
31
- "@storybook/addon-controls": "6.4.20",
32
- "@storybook/addon-docs": "6.4.20",
33
- "@storybook/addons": "6.4.20",
34
- "@storybook/react": "6.4.20",
35
- "@storybook/theming": "6.4.20",
25
+ "@babel/cli": "7.17.10",
26
+ "@babel/eslint-parser": "7.18.2",
27
+ "@babel/preset-typescript": "7.17.12",
28
+ "@percy/cli": "1.2.1",
29
+ "@percy/storybook": "4.2.1",
30
+ "@storybook/addon-a11y": "6.4.22",
31
+ "@storybook/addon-controls": "6.4.22",
32
+ "@storybook/addon-docs": "6.4.22",
33
+ "@storybook/addons": "6.4.22",
34
+ "@storybook/react": "6.4.22",
35
+ "@storybook/theming": "6.4.22",
36
36
  "@testing-library/cypress": "8.0.2",
37
- "@testing-library/dom": "8.12.0",
38
- "@testing-library/jest-dom": "5.16.3",
39
- "@testing-library/react": "12.1.4",
37
+ "@testing-library/dom": "8.14.0",
38
+ "@testing-library/jest-dom": "5.16.4",
39
+ "@testing-library/react": "12.1.5",
40
40
  "@testing-library/react-hooks": "7.0.2",
41
41
  "@testing-library/user-event": "13.5.0",
42
- "@typescript-eslint/eslint-plugin": "5.18.0",
43
- "@typescript-eslint/parser": "5.18.0",
42
+ "@typescript-eslint/eslint-plugin": "5.29.0",
43
+ "@typescript-eslint/parser": "5.29.0",
44
44
  "@wojtekmaj/enzyme-adapter-react-17": "0.6.7",
45
45
  "babel-jest": "27.5.1",
46
- "babel-loader": "8.2.4",
46
+ "babel-loader": "8.2.5",
47
47
  "babel-plugin-module-resolver": "4.1.0",
48
48
  "babel-plugin-typescript-to-proptypes": "2.0.0",
49
- "concurrently": "7.1.0",
49
+ "concurrently": "7.2.1",
50
50
  "css-loader": "5.2.7",
51
- "cypress": "9.5.3",
51
+ "cypress": "9.7.0",
52
52
  "deepmerge": "4.2.2",
53
53
  "enzyme": "3.11.0",
54
54
  "enzyme-adapter-react-16": "1.15.6",
55
55
  "enzyme-to-json": "3.6.2",
56
- "eslint": "8.12.0",
56
+ "eslint": "8.16.0",
57
57
  "eslint-config-prettier": "8.5.0",
58
- "eslint-config-react-app": "7.0.0",
58
+ "eslint-config-react-app": "7.0.1",
59
59
  "eslint-plugin-cypress": "2.12.1",
60
60
  "eslint-plugin-flowtype": "8.0.3",
61
- "eslint-plugin-import": "2.25.4",
61
+ "eslint-plugin-import": "2.26.0",
62
62
  "eslint-plugin-jsx-a11y": "6.5.1",
63
63
  "eslint-plugin-prettier": "4.0.0",
64
- "eslint-plugin-react": "7.29.4",
65
- "eslint-plugin-react-hooks": "4.4.0",
66
- "eslint-plugin-testing-library": "5.2.1",
64
+ "eslint-plugin-react": "7.30.0",
65
+ "eslint-plugin-react-hooks": "4.5.0",
66
+ "eslint-plugin-testing-library": "5.5.1",
67
67
  "jest": "27.5.1",
68
68
  "npm-package-json-lint": "5.4.2",
69
69
  "prettier": "2.6.2",
70
70
  "react": "17.0.2",
71
71
  "react-docgen-typescript-loader": "3.7.2",
72
72
  "react-dom": "17.0.2",
73
- "sass": "1.49.11",
73
+ "sass": "1.52.2",
74
74
  "sass-loader": "10.2.1",
75
75
  "style-loader": "2.0.0",
76
- "stylelint": "14.6.1",
76
+ "stylelint": "14.8.5",
77
77
  "stylelint-config-prettier": "9.0.3",
78
78
  "stylelint-config-recommended-scss": "5.0.2",
79
79
  "stylelint-order": "5.0.0",
80
80
  "stylelint-prettier": "2.0.0",
81
- "ts-jest": "27.1.4",
82
- "tsc-alias": "1.6.5",
83
- "typescript": "4.6.3",
84
- "vanilla-framework": "3.3.0",
81
+ "ts-jest": "27.1.5",
82
+ "tsc-alias": "1.6.8",
83
+ "typescript": "4.7.2",
84
+ "vanilla-framework": "3.6.0",
85
85
  "wait-on": "5.3.0"
86
86
  },
87
87
  "dependencies": {
88
- "@types/jest": "27.4.1",
89
- "@types/node": "16.11.26",
90
- "@types/react": "17.0.43",
91
- "@types/react-dom": "17.0.14",
92
- "@types/react-table": "7.7.10",
88
+ "@types/jest": "27.5.2",
89
+ "@types/node": "16.11.38",
90
+ "@types/react": "17.0.45",
91
+ "@types/react-dom": "17.0.17",
92
+ "@types/react-table": "7.7.12",
93
93
  "classnames": "2.3.1",
94
- "nanoid": "3.3.2",
94
+ "nanoid": "3.3.4",
95
95
  "prop-types": "15.8.1",
96
- "react-table": "7.7.0",
96
+ "react-table": "7.8.0",
97
97
  "react-useportal": "1.0.16"
98
98
  },
99
99
  "resolutions": {
100
+ "@types/react": "17.0.45",
101
+ "@types/react-dom": "17.0.17",
100
102
  "postcss": "^8.3.11"
101
103
  },
102
104
  "peerDependencies": {
103
105
  "react": "17.0.2",
104
106
  "react-dom": "17.0.2",
105
- "vanilla-framework": "3.3.0"
107
+ "vanilla-framework": "3.6.0"
106
108
  },
107
109
  "scripts": {
108
110
  "build": "rm -rf dist && yarn build-local; yarn build-declaration",