@canonical/react-components 2.9.0 → 2.10.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.
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import type { HTMLProps, ReactNode } from "react";
3
+ export type Props = {
4
+ /**
5
+ * This prop can be used to replace the header area of the panel when the default implementation is not sufficient.
6
+ */
7
+ header?: ReactNode;
8
+ /**
9
+ * The main content.
10
+ */
11
+ children: ReactNode;
12
+ /**
13
+ * Classes to apply to the main content.
14
+ */
15
+ mainClassName?: string;
16
+ /**
17
+ * Classes to apply to the main area.
18
+ */
19
+ contentClassName?: string;
20
+ } & HTMLProps<HTMLDivElement>;
21
+ declare const CustomLayout: ({ header, children, mainClassName, contentClassName, }: Props) => React.JSX.Element;
22
+ export default CustomLayout;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _ApplicationLayout = require("../ApplicationLayout");
9
+ var _Panel = _interopRequireDefault(require("../Panel"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const CustomLayout = _ref => {
12
+ let {
13
+ header,
14
+ children,
15
+ mainClassName,
16
+ contentClassName
17
+ } = _ref;
18
+ return /*#__PURE__*/_react.default.createElement(_ApplicationLayout.AppMain, {
19
+ className: mainClassName,
20
+ id: "main-content"
21
+ }, /*#__PURE__*/_react.default.createElement(_Panel.default, {
22
+ contentClassName: contentClassName,
23
+ header: header
24
+ }, children));
25
+ };
26
+ var _default = exports.default = CustomLayout;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import CustomLayout from "./CustomLayout";
3
+ declare const meta: Meta<typeof CustomLayout>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CustomLayout>;
6
+ export declare const Default: Story;
7
+ export declare const Content: Story;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Default = exports.Content = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _Panel = _interopRequireDefault(require("../Panel"));
9
+ var _CustomLayout = _interopRequireDefault(require("./CustomLayout"));
10
+ var _AppMain = _interopRequireDefault(require("../ApplicationLayout/AppMain"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const meta = {
13
+ component: _CustomLayout.default,
14
+ tags: ["autodocs"]
15
+ };
16
+ var _default = exports.default = meta;
17
+ const Default = exports.Default = {
18
+ args: {
19
+ children: "CustomLayout"
20
+ }
21
+ };
22
+ const Content = exports.Content = {
23
+ render: () => {
24
+ return /*#__PURE__*/_react.default.createElement(_AppMain.default, {
25
+ id: "main-content"
26
+ }, /*#__PURE__*/_react.default.createElement(_Panel.default, null, "test"));
27
+ }
28
+ };
@@ -0,0 +1,2 @@
1
+ export { default } from "./CustomLayout";
2
+ export type { Props as CustomLayoutProps } from "./CustomLayout";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _CustomLayout.default;
10
+ }
11
+ });
12
+ var _CustomLayout = _interopRequireDefault(require("./CustomLayout"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -21,9 +21,15 @@ export type Props = {
21
21
  * The politeness setting of the spinner alert.
22
22
  */
23
23
  ariaLive?: "assertive" | "off" | "polite";
24
+ /**
25
+ * Whether the Loader is replacing the main component in the application layout.
26
+ * In that case, the loader has to be wrapped with a main panel of the application
27
+ * layout. This is important for the mobile view. This prop enables the wrapping.
28
+ */
29
+ isMainComponent?: boolean;
24
30
  } & HTMLProps<HTMLSpanElement>;
25
31
  /**
26
32
  * This is a [React](https://reactjs.org/) component for the Vanilla [Spin](https://docs.vanillaframework.io/settings/animation-settings/#spin) animation.
27
33
  */
28
- declare const Spinner: ({ className, text, isLight, ariaLive, role, ...props }: Props) => React.JSX.Element;
34
+ declare const Spinner: ({ className, text, isLight, ariaLive, role, isMainComponent, ...props }: Props) => React.JSX.Element;
29
35
  export default Spinner;
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _CustomLayout = _interopRequireDefault(require("../CustomLayout"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
13
  /**
@@ -19,9 +20,10 @@ const Spinner = _ref => {
19
20
  isLight = false,
20
21
  ariaLive = "polite",
21
22
  role = "alert",
23
+ isMainComponent = false,
22
24
  ...props
23
25
  } = _ref;
24
- return /*#__PURE__*/_react.default.createElement("span", _extends({}, props, {
26
+ const loader = /*#__PURE__*/_react.default.createElement("span", _extends({}, props, {
25
27
  className: (0, _classnames.default)(className, "p-text--default"),
26
28
  role: role,
27
29
  "aria-live": ariaLive
@@ -30,11 +32,13 @@ const Spinner = _ref => {
30
32
  "is-light": isLight
31
33
  })
32
34
  }, text ? "" : "Loading"), text && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "\u2002", /*#__PURE__*/_react.default.createElement("span", null, text)));
35
+ return isMainComponent ? /*#__PURE__*/_react.default.createElement(_CustomLayout.default, null, loader) : loader;
33
36
  };
34
37
  Spinner.propTypes = {
35
38
  isLight: _propTypes.default.bool,
36
39
  text: _propTypes.default.string,
37
40
  role: _propTypes.default.string,
38
- ariaLive: _propTypes.default.oneOf(["assertive", "off", "polite"])
41
+ ariaLive: _propTypes.default.oneOf(["assertive", "off", "polite"]),
42
+ isMainComponent: _propTypes.default.bool
39
43
  };
40
44
  var _default = exports.default = Spinner;
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import type { HTMLProps, ReactNode } from "react";
3
+ export type Props = {
4
+ /**
5
+ * This prop can be used to replace the header area of the panel when the default implementation is not sufficient.
6
+ */
7
+ header?: ReactNode;
8
+ /**
9
+ * The main content.
10
+ */
11
+ children: ReactNode;
12
+ /**
13
+ * Classes to apply to the main content.
14
+ */
15
+ mainClassName?: string;
16
+ /**
17
+ * Classes to apply to the main area.
18
+ */
19
+ contentClassName?: string;
20
+ } & HTMLProps<HTMLDivElement>;
21
+ declare const CustomLayout: ({ header, children, mainClassName, contentClassName, }: Props) => React.JSX.Element;
22
+ export default CustomLayout;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { AppMain } from "../ApplicationLayout";
3
+ import Panel from "../Panel";
4
+ var CustomLayout = _ref => {
5
+ var {
6
+ header,
7
+ children,
8
+ mainClassName,
9
+ contentClassName
10
+ } = _ref;
11
+ return /*#__PURE__*/React.createElement(AppMain, {
12
+ className: mainClassName,
13
+ id: "main-content"
14
+ }, /*#__PURE__*/React.createElement(Panel, {
15
+ contentClassName: contentClassName,
16
+ header: header
17
+ }, children));
18
+ };
19
+ export default CustomLayout;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import CustomLayout from "./CustomLayout";
3
+ declare const meta: Meta<typeof CustomLayout>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CustomLayout>;
6
+ export declare const Default: Story;
7
+ export declare const Content: Story;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import Panel from "../Panel";
3
+ import CustomLayout from "./CustomLayout";
4
+ import AppMain from "../ApplicationLayout/AppMain";
5
+ var meta = {
6
+ component: CustomLayout,
7
+ tags: ["autodocs"]
8
+ };
9
+ export default meta;
10
+ export var Default = {
11
+ args: {
12
+ children: "CustomLayout"
13
+ }
14
+ };
15
+ export var Content = {
16
+ render: () => {
17
+ return /*#__PURE__*/React.createElement(AppMain, {
18
+ id: "main-content"
19
+ }, /*#__PURE__*/React.createElement(Panel, null, "test"));
20
+ }
21
+ };
@@ -0,0 +1,2 @@
1
+ export { default } from "./CustomLayout";
2
+ export type { Props as CustomLayoutProps } from "./CustomLayout";
@@ -0,0 +1 @@
1
+ export { default } from "./CustomLayout";
@@ -21,9 +21,15 @@ export type Props = {
21
21
  * The politeness setting of the spinner alert.
22
22
  */
23
23
  ariaLive?: "assertive" | "off" | "polite";
24
+ /**
25
+ * Whether the Loader is replacing the main component in the application layout.
26
+ * In that case, the loader has to be wrapped with a main panel of the application
27
+ * layout. This is important for the mobile view. This prop enables the wrapping.
28
+ */
29
+ isMainComponent?: boolean;
24
30
  } & HTMLProps<HTMLSpanElement>;
25
31
  /**
26
32
  * This is a [React](https://reactjs.org/) component for the Vanilla [Spin](https://docs.vanillaframework.io/settings/animation-settings/#spin) animation.
27
33
  */
28
- declare const Spinner: ({ className, text, isLight, ariaLive, role, ...props }: Props) => React.JSX.Element;
34
+ declare const Spinner: ({ className, text, isLight, ariaLive, role, isMainComponent, ...props }: Props) => React.JSX.Element;
29
35
  export default Spinner;
@@ -1,10 +1,11 @@
1
1
  import _pt from "prop-types";
2
- var _excluded = ["className", "text", "isLight", "ariaLive", "role"];
2
+ var _excluded = ["className", "text", "isLight", "ariaLive", "role", "isMainComponent"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
  import React from "react";
7
7
  import classNames from "classnames";
8
+ import CustomLayout from "../CustomLayout";
8
9
  /**
9
10
  * This is a [React](https://reactjs.org/) component for the Vanilla [Spin](https://docs.vanillaframework.io/settings/animation-settings/#spin) animation.
10
11
  */
@@ -14,10 +15,11 @@ var Spinner = _ref => {
14
15
  text,
15
16
  isLight = false,
16
17
  ariaLive = "polite",
17
- role = "alert"
18
+ role = "alert",
19
+ isMainComponent = false
18
20
  } = _ref,
19
21
  props = _objectWithoutProperties(_ref, _excluded);
20
- return /*#__PURE__*/React.createElement("span", _extends({}, props, {
22
+ var loader = /*#__PURE__*/React.createElement("span", _extends({}, props, {
21
23
  className: classNames(className, "p-text--default"),
22
24
  role: role,
23
25
  "aria-live": ariaLive
@@ -26,11 +28,13 @@ var Spinner = _ref => {
26
28
  "is-light": isLight
27
29
  })
28
30
  }, text ? "" : "Loading"), text && /*#__PURE__*/React.createElement(React.Fragment, null, "\u2002", /*#__PURE__*/React.createElement("span", null, text)));
31
+ return isMainComponent ? /*#__PURE__*/React.createElement(CustomLayout, null, loader) : loader;
29
32
  };
30
33
  Spinner.propTypes = {
31
34
  isLight: _pt.bool,
32
35
  text: _pt.string,
33
36
  role: _pt.string,
34
- ariaLive: _pt.oneOf(["assertive", "off", "polite"])
37
+ ariaLive: _pt.oneOf(["assertive", "off", "polite"]),
38
+ isMainComponent: _pt.bool
35
39
  };
36
40
  export default Spinner;
@@ -71,6 +71,7 @@ export { ToastNotification, ToastNotificationList, ToastNotificationProvider, us
71
71
  export { default as Tooltip } from "./components/Tooltip";
72
72
  export { default as TablePagination } from "./components/TablePagination";
73
73
  export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
74
+ export { default as CustomLayout } from "./components/CustomLayout";
74
75
  export { default as CustomSelect } from "./components/CustomSelect";
75
76
  export type { AccordionProps } from "./components/Accordion";
76
77
  export type { ActionButtonProps } from "./components/ActionButton";
package/dist/esm/index.js CHANGED
@@ -71,6 +71,7 @@ export { ToastNotification, ToastNotificationList, ToastNotificationProvider, us
71
71
  export { default as Tooltip } from "./components/Tooltip";
72
72
  export { default as TablePagination } from "./components/TablePagination";
73
73
  export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
74
+ export { default as CustomLayout } from "./components/CustomLayout";
74
75
  export { default as CustomSelect } from "./components/CustomSelect";
75
76
  export { useOnClickOutside, useClickOutside, useId, useListener, useOnEscapePressed, usePagination, usePrevious, usePrefersReducedMotion, useThrottle, useWindowFitment } from "./hooks";
76
77
  export { isNavigationAnchor, isNavigationButton } from "./utils";
package/dist/index.d.ts CHANGED
@@ -71,6 +71,7 @@ export { ToastNotification, ToastNotificationList, ToastNotificationProvider, us
71
71
  export { default as Tooltip } from "./components/Tooltip";
72
72
  export { default as TablePagination } from "./components/TablePagination";
73
73
  export { default as TablePaginationControls } from "./components/TablePagination/TablePaginationControls";
74
+ export { default as CustomLayout } from "./components/CustomLayout";
74
75
  export { default as CustomSelect } from "./components/CustomSelect";
75
76
  export type { AccordionProps } from "./components/Accordion";
76
77
  export type { ActionButtonProps } from "./components/ActionButton";
package/dist/index.js CHANGED
@@ -94,6 +94,7 @@ var _exportNames = {
94
94
  Tooltip: true,
95
95
  TablePagination: true,
96
96
  TablePaginationControls: true,
97
+ CustomLayout: true,
97
98
  CustomSelect: true,
98
99
  useOnClickOutside: true,
99
100
  useClickOutside: true,
@@ -248,6 +249,12 @@ Object.defineProperty(exports, "ContextualMenu", {
248
249
  return _ContextualMenu.default;
249
250
  }
250
251
  });
252
+ Object.defineProperty(exports, "CustomLayout", {
253
+ enumerable: true,
254
+ get: function () {
255
+ return _CustomLayout.default;
256
+ }
257
+ });
251
258
  Object.defineProperty(exports, "CustomSelect", {
252
259
  enumerable: true,
253
260
  get: function () {
@@ -823,6 +830,7 @@ var _ThemeSwitcher = _interopRequireWildcard(require("./components/ThemeSwitcher
823
830
  var _Tooltip = _interopRequireDefault(require("./components/Tooltip"));
824
831
  var _TablePagination = _interopRequireDefault(require("./components/TablePagination"));
825
832
  var _TablePaginationControls = _interopRequireDefault(require("./components/TablePagination/TablePaginationControls"));
833
+ var _CustomLayout = _interopRequireDefault(require("./components/CustomLayout"));
826
834
  var _CustomSelect = _interopRequireDefault(require("./components/CustomSelect"));
827
835
  var _hooks = require("./hooks");
828
836
  var _utils = require("./utils");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": {
@@ -93,7 +93,7 @@
93
93
  "tsc-alias": "1.8.10",
94
94
  "typescript": "5.7.3",
95
95
  "typescript-eslint": "8.24.1",
96
- "vanilla-framework": "4.26.0",
96
+ "vanilla-framework": "4.26.1",
97
97
  "wait-on": "8.0.2",
98
98
  "webpack": "5.98.0"
99
99
  },