@canonical/react-components 0.39.0 → 0.40.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.
@@ -90,6 +90,10 @@ export type Props = PropsWithSpread<{
90
90
  * A function to be used when sorting.
91
91
  */
92
92
  sortFunction?: (a: MainTableRow, b: MainTableRow, currentSortDirection: SortDirection, currentSortKey: MainTableHeader["sortKey"]) => -1 | 0 | 1;
93
+ /**
94
+ * A hidden caption to display on the table for screen readers
95
+ */
96
+ hiddenCaption?: string | null;
93
97
  }, TableProps>;
94
- declare const MainTable: ({ defaultSort, defaultSortDirection, emptyStateMsg, expanding, headers, onUpdateSort, paginate, rows, responsive, sortable, sortFunction, ...props }: Props) => JSX.Element;
98
+ declare const MainTable: ({ defaultSort, defaultSortDirection, emptyStateMsg, expanding, headers, onUpdateSort, paginate, rows, responsive, sortable, sortFunction, hiddenCaption, ...props }: Props) => JSX.Element;
95
99
  export default MainTable;
@@ -24,7 +24,7 @@ var _hooks = require("../../hooks");
24
24
  var _excluded = ["content", "sortKey"],
25
25
  _excluded2 = ["columns", "expanded", "expandedContent", "key", "sortData"],
26
26
  _excluded3 = ["content"],
27
- _excluded4 = ["defaultSort", "defaultSortDirection", "emptyStateMsg", "expanding", "headers", "onUpdateSort", "paginate", "rows", "responsive", "sortable", "sortFunction"];
27
+ _excluded4 = ["defaultSort", "defaultSortDirection", "emptyStateMsg", "expanding", "headers", "onUpdateSort", "paginate", "rows", "responsive", "sortable", "sortFunction", "hiddenCaption"];
28
28
 
29
29
  var _this = void 0;
30
30
 
@@ -200,6 +200,7 @@ var MainTable = function MainTable(_ref6) {
200
200
  responsive = _ref6.responsive,
201
201
  sortable = _ref6.sortable,
202
202
  sortFunction = _ref6.sortFunction,
203
+ hiddenCaption = _ref6.hiddenCaption,
203
204
  props = _objectWithoutProperties(_ref6, _excluded4);
204
205
 
205
206
  var _useState = (0, _react.useState)(defaultSort),
@@ -247,7 +248,17 @@ var MainTable = function MainTable(_ref6) {
247
248
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Table.default, _extends({
248
249
  expanding: expanding,
249
250
  responsive: responsive
250
- }, props), !!headers && generateHeaders(currentSortKey, currentSortDirection, expanding, headers, sortable, updateSort, setSortDirection), // If the table has no rows, return empty state message
251
+ }, props), hiddenCaption && /*#__PURE__*/_react.default.createElement("caption", {
252
+ "data-testid": "hidden-caption",
253
+ style: {
254
+ height: "1px",
255
+ left: "-1000px",
256
+ overflow: "hidden",
257
+ position: "absolute",
258
+ top: "auto",
259
+ width: "1px"
260
+ }
261
+ }, hiddenCaption), !!headers && generateHeaders(currentSortKey, currentSortDirection, expanding, headers, sortable, updateSort, setSortDirection), // If the table has no rows, return empty state message
251
262
  Object.entries(finalRows).length === 0 && emptyStateMsg ? /*#__PURE__*/_react.default.createElement("caption", null, emptyStateMsg) : /*#__PURE__*/_react.default.createElement("tbody", null, generateRows({
252
263
  rows: finalRows,
253
264
  headers: headers,
@@ -52,6 +52,10 @@ export type Props = {
52
52
  * An optional class to apply to the tooltip message element.
53
53
  */
54
54
  tooltipClassName?: string;
55
+ /**
56
+ * The z-index value of the tooltip message element.
57
+ */
58
+ zIndex?: number;
55
59
  };
56
60
  export declare const adjustForWindow: (position: Position, fitsWindow: WindowFitment) => Position;
57
61
  /**
@@ -64,6 +68,7 @@ export declare const adjustForWindow: (position: Position, fitsWindow: WindowFit
64
68
  * @param [position="top-left"] Position of the tooltip relative to the element.
65
69
  * @param positionElementClassName An optional class to apply to the element that wraps the children.
66
70
  * @param tooltipClassName An optional class to apply to the tooltip message element.
71
+ * @param zIndex The z-index value of the tooltip message element.
67
72
  */
68
- declare const Tooltip: ({ autoAdjust, children, className, followMouse, message, position, positionElementClassName, tooltipClassName, }: Props) => JSX.Element;
73
+ declare const Tooltip: ({ autoAdjust, children, className, followMouse, message, position, positionElementClassName, tooltipClassName, zIndex, }: Props) => JSX.Element;
69
74
  export default Tooltip;
@@ -157,6 +157,7 @@ var adjustForWindow = function adjustForWindow(position, fitsWindow) {
157
157
  * @param [position="top-left"] Position of the tooltip relative to the element.
158
158
  * @param positionElementClassName An optional class to apply to the element that wraps the children.
159
159
  * @param tooltipClassName An optional class to apply to the tooltip message element.
160
+ * @param zIndex The z-index value of the tooltip message element.
160
161
  */
161
162
 
162
163
 
@@ -173,7 +174,8 @@ var Tooltip = function Tooltip(_ref) {
173
174
  _ref$position = _ref.position,
174
175
  position = _ref$position === void 0 ? "top-left" : _ref$position,
175
176
  positionElementClassName = _ref.positionElementClassName,
176
- tooltipClassName = _ref.tooltipClassName;
177
+ tooltipClassName = _ref.tooltipClassName,
178
+ zIndex = _ref.zIndex;
177
179
  var wrapperRef = (0, _react.useRef)(null);
178
180
  var messageRef = (0, _react.useRef)(null);
179
181
 
@@ -292,7 +294,10 @@ var Tooltip = function Tooltip(_ref) {
292
294
  role: "tooltip",
293
295
  className: "p-tooltip__message",
294
296
  ref: messageRef,
295
- id: tooltipId
297
+ id: tooltipId,
298
+ style: {
299
+ zIndex: zIndex
300
+ }
296
301
  }, message)))) : /*#__PURE__*/_react.default.createElement("span", {
297
302
  className: className
298
303
  }, children));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "Huw Wilkins <huw.wilkins@canonical.com>",
@@ -35,7 +35,7 @@
35
35
  "@storybook/manager-webpack5": "6.5.16",
36
36
  "@storybook/react": "6.5.16",
37
37
  "@storybook/theming": "6.5.16",
38
- "@testing-library/cypress": "8.0.7",
38
+ "@testing-library/cypress": "9.0.0",
39
39
  "@testing-library/dom": "8.20.0",
40
40
  "@testing-library/jest-dom": "5.16.5",
41
41
  "@testing-library/react": "12.1.5",
@@ -49,7 +49,7 @@
49
49
  "babel-plugin-typescript-to-proptypes": "2.0.0",
50
50
  "concurrently": "7.6.0",
51
51
  "css-loader": "6.7.3",
52
- "cypress": "9.7.0",
52
+ "cypress": "12.7.0",
53
53
  "deepmerge": "4.3.0",
54
54
  "eslint": "8.33.0",
55
55
  "eslint-config-prettier": "8.6.0",
@@ -79,13 +79,13 @@
79
79
  "ts-jest": "27.1.5",
80
80
  "tsc-alias": "1.8.2",
81
81
  "typescript": "4.9.5",
82
- "vanilla-framework": "3.11.1",
82
+ "vanilla-framework": "3.12.1",
83
83
  "wait-on": "5.3.0",
84
84
  "webpack": "5.75.0"
85
85
  },
86
86
  "dependencies": {
87
87
  "@types/jest": "27.5.2",
88
- "@types/node": "16.18.12",
88
+ "@types/node": "18.14.2",
89
89
  "@types/react": "18.0.28",
90
90
  "@types/react-dom": "17.0.18",
91
91
  "@types/react-table": "7.7.14",
@@ -103,7 +103,7 @@
103
103
  "peerDependencies": {
104
104
  "react": "^17.0.2 || ^18.0.0",
105
105
  "react-dom": "^17.0.2 || ^18.0.0",
106
- "vanilla-framework": "3.11.1"
106
+ "vanilla-framework": "3.12.1"
107
107
  },
108
108
  "scripts": {
109
109
  "build": "rm -rf dist && yarn build-local; yarn build-declaration",
@@ -127,7 +127,11 @@
127
127
  "unlink-packages": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink",
128
128
  "cypress:test": "wait-on http://localhost:${PORT:-9009} && cypress run --env port=${PORT:-9009}",
129
129
  "cypress:run": "cypress run --env port=${PORT:-9009}",
130
- "cypress:open": "cypress open --env port=${PORT:-9009}"
130
+ "cypress:open": "cypress open --env port=${PORT:-9009}",
131
+ "prepare-release:major": "./prepare-release major",
132
+ "prepare-release:minor": "./prepare-release minor",
133
+ "prepare-release:patch": "./prepare-release patch",
134
+ "prepare-release": "yarn run prepare-release:minor"
131
135
  },
132
136
  "eslintConfig": {
133
137
  "extends": "react-app"