@canonical/react-components 0.59.0 → 0.60.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.
- package/dist/components/Accordion/Accordion.d.ts +5 -0
- package/dist/components/Accordion/Accordion.js +6 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +18 -0
- package/dist/components/Accordion/Accordion.stories.js +117 -0
- package/dist/components/ActionButton/ActionButton.d.ts +7 -0
- package/dist/components/ActionButton/ActionButton.js +7 -0
- package/dist/components/ActionButton/ActionButton.stories.d.ts +7 -0
- package/dist/components/ActionButton/ActionButton.stories.js +36 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.d.ts +3 -3
- package/dist/components/ApplicationLayout/ApplicationLayout.js +4 -4
- package/dist/components/ApplicationLayout/ApplicationLayout.stories.d.ts +5 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.stories.js +16 -2
- package/dist/components/ArticlePagination/ArticlePagination.d.ts +5 -0
- package/dist/components/ArticlePagination/ArticlePagination.js +5 -0
- package/dist/components/ArticlePagination/ArticlePagination.stories.d.ts +6 -0
- package/dist/components/ArticlePagination/ArticlePagination.stories.js +22 -0
- package/dist/components/Badge/Badge.d.ts +5 -0
- package/dist/components/Badge/Badge.js +6 -0
- package/dist/components/Badge/Badge.stories.d.ts +15 -0
- package/dist/components/Badge/Badge.stories.js +62 -0
- package/dist/components/Button/Button.d.ts +3 -1
- package/dist/components/Button/Button.js +3 -1
- package/dist/components/Button/Button.stories.d.ts +32 -0
- package/dist/components/Button/Button.stories.js +180 -0
- package/dist/components/Card/Card.stories.js +0 -1
- package/dist/components/CheckboxInput/CheckboxInput.d.ts +5 -0
- package/dist/components/CheckboxInput/CheckboxInput.js +5 -0
- package/dist/components/CheckboxInput/CheckboxInput.stories.d.ts +11 -0
- package/dist/components/CheckboxInput/CheckboxInput.stories.js +84 -0
- package/dist/components/Chip/Chip.d.ts +5 -0
- package/dist/components/Chip/Chip.js +5 -0
- package/dist/components/Chip/Chip.stories.d.ts +9 -0
- package/dist/components/Chip/Chip.stories.js +45 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +7 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +7 -0
- package/dist/components/CodeSnippet/CodeSnippet.stories.d.ts +45 -0
- package/dist/components/CodeSnippet/CodeSnippet.stories.js +279 -0
- package/dist/components/Col/Col.d.ts +5 -0
- package/dist/components/Col/Col.js +5 -0
- package/dist/components/Col/Col.stories.d.ts +11 -0
- package/dist/components/Col/Col.stories.js +154 -0
- package/dist/components/ConfirmationButton/ConfirmationButton.d.ts +3 -0
- package/dist/components/ConfirmationButton/ConfirmationButton.js +13 -1
- package/dist/components/ConfirmationButton/ConfirmationButton.stories.d.ts +9 -0
- package/dist/components/ConfirmationButton/ConfirmationButton.stories.js +108 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +16 -4
- package/dist/components/ConfirmationModal/ConfirmationModal.js +8 -3
- package/dist/components/ConfirmationModal/ConfirmationModal.stories.d.ts +18 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.stories.js +135 -0
- package/dist/components/ContextualMenu/ContextualMenu.d.ts +3 -20
- package/dist/components/ContextualMenu/ContextualMenu.js +3 -20
- package/dist/components/ContextualMenu/ContextualMenu.stories.d.ts +13 -0
- package/dist/components/ContextualMenu/ContextualMenu.stories.js +107 -0
- package/dist/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/components/EmptyState/EmptyState.js +3 -0
- package/dist/components/EmptyState/EmptyState.stories.d.ts +7 -0
- package/dist/components/EmptyState/EmptyState.stories.js +49 -0
- package/dist/components/Form/Form.d.ts +5 -0
- package/dist/components/Form/Form.js +5 -0
- package/dist/components/Form/Form.stories.d.ts +12 -0
- package/dist/components/Form/Form.stories.js +179 -0
- package/dist/components/FormikField/FormikField.stories.js +0 -1
- package/dist/components/Icon/Icon.d.ts +3 -1
- package/dist/components/Icon/Icon.js +3 -1
- package/dist/components/Icon/Icon.stories.d.ts +16 -0
- package/dist/components/Icon/Icon.stories.js +49 -0
- package/dist/components/Input/Input.d.ts +5 -0
- package/dist/components/Input/Input.js +5 -0
- package/dist/components/Input/Input.stories.d.ts +14 -0
- package/dist/components/Input/Input.stories.js +148 -0
- package/dist/components/Link/Link.d.ts +5 -0
- package/dist/components/Link/Link.js +5 -0
- package/dist/components/Link/Link.stories.d.ts +9 -0
- package/dist/components/Link/Link.stories.js +48 -0
- package/dist/components/List/List.d.ts +5 -0
- package/dist/components/List/List.js +6 -0
- package/dist/components/List/List.stories.d.ts +15 -0
- package/dist/components/List/List.stories.js +122 -0
- package/dist/components/LoginPageLayout/LoginPageLayout.d.ts +4 -0
- package/dist/components/LoginPageLayout/LoginPageLayout.js +4 -0
- package/dist/components/LoginPageLayout/LoginPageLayout.stories.d.ts +9 -0
- package/dist/components/LoginPageLayout/LoginPageLayout.stories.js +58 -0
- package/dist/components/MainTable/MainTable.d.ts +3 -0
- package/dist/components/MainTable/MainTable.js +4 -0
- package/dist/components/MainTable/MainTable.stories.d.ts +15 -0
- package/dist/components/MainTable/MainTable.stories.js +553 -0
- package/dist/components/Modal/Modal.d.ts +5 -0
- package/dist/components/Modal/Modal.js +5 -0
- package/dist/components/Modal/Modal.stories.d.ts +6 -0
- package/dist/components/Modal/Modal.stories.js +57 -0
- package/dist/components/ModularTable/ModularTable.d.ts +52 -0
- package/dist/components/ModularTable/ModularTable.js +53 -0
- package/dist/components/ModularTable/ModularTable.stories.d.ts +27 -0
- package/dist/components/ModularTable/ModularTable.stories.js +343 -0
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +5 -64
- package/dist/components/MultiSelect/MultiSelect.stories.js +0 -1
- package/dist/components/Navigation/Navigation.d.ts +8 -0
- package/dist/components/Navigation/Navigation.js +9 -0
- package/dist/components/Navigation/Navigation.stories.d.ts +43 -0
- package/dist/components/Navigation/Navigation.stories.js +232 -0
- package/dist/components/Notification/Notification.d.ts +25 -0
- package/dist/components/Notification/Notification.js +25 -0
- package/dist/components/Notification/Notification.stories.d.ts +45 -0
- package/dist/components/Notification/Notification.stories.js +201 -0
- package/dist/components/Pagination/Pagination.d.ts +12 -0
- package/dist/components/Pagination/Pagination.js +12 -0
- package/dist/components/Pagination/Pagination.stories.d.ts +14 -0
- package/dist/components/Pagination/Pagination.stories.js +94 -0
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +5 -0
- package/dist/components/PasswordToggle/PasswordToggle.js +5 -0
- package/dist/components/PasswordToggle/PasswordToggle.stories.d.ts +12 -0
- package/dist/components/PasswordToggle/PasswordToggle.stories.js +74 -0
- package/dist/components/RadioInput/RadioInput.d.ts +5 -0
- package/dist/components/RadioInput/RadioInput.js +5 -0
- package/dist/components/RadioInput/RadioInput.stories.d.ts +10 -0
- package/dist/components/RadioInput/RadioInput.stories.js +83 -0
- package/dist/components/Row/Row.d.ts +5 -0
- package/dist/components/Row/Row.js +5 -0
- package/dist/components/Row/Row.stories.d.ts +9 -0
- package/dist/components/Row/Row.stories.js +29 -0
- package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +3 -0
- package/dist/components/SearchAndFilter/SearchAndFilter.js +3 -0
- package/dist/components/SearchAndFilter/SearchAndFilter.stories.d.ts +8 -0
- package/dist/components/SearchAndFilter/SearchAndFilter.stories.js +218 -0
- package/dist/components/SearchBox/SearchBox.d.ts +5 -0
- package/dist/components/SearchBox/SearchBox.js +5 -0
- package/dist/components/SearchBox/SearchBox.stories.d.ts +14 -0
- package/dist/components/SearchBox/SearchBox.stories.js +106 -0
- package/dist/components/Select/Select.d.ts +5 -0
- package/dist/components/Select/Select.js +6 -0
- package/dist/components/Select/Select.stories.d.ts +7 -0
- package/dist/components/Select/Select.stories.js +97 -0
- package/dist/components/Slider/Slider.d.ts +6 -0
- package/dist/components/Slider/Slider.js +6 -0
- package/dist/components/Slider/Slider.stories.d.ts +10 -0
- package/dist/components/Slider/Slider.stories.js +74 -0
- package/dist/components/Spinner/Spinner.d.ts +3 -0
- package/dist/components/Spinner/Spinner.js +3 -0
- package/dist/components/Spinner/Spinner.stories.d.ts +8 -0
- package/dist/components/Spinner/Spinner.stories.js +28 -0
- package/dist/components/StatusLabel/StatusLabel.d.ts +3 -1
- package/dist/components/StatusLabel/StatusLabel.js +3 -1
- package/dist/components/StatusLabel/StatusLabel.stories.d.ts +10 -0
- package/dist/components/StatusLabel/StatusLabel.stories.js +61 -0
- package/dist/components/Strip/Strip.d.ts +5 -0
- package/dist/components/Strip/Strip.js +5 -0
- package/dist/components/Strip/Strip.stories.d.ts +12 -0
- package/dist/components/Strip/Strip.stories.js +130 -0
- package/dist/components/SummaryButton/SummaryButton.d.ts +3 -0
- package/dist/components/SummaryButton/SummaryButton.js +3 -0
- package/dist/components/SummaryButton/SummaryButton.stories.d.ts +18 -0
- package/dist/components/SummaryButton/SummaryButton.stories.js +59 -0
- package/dist/components/Switch/Switch.d.ts +3 -0
- package/dist/components/Switch/Switch.js +3 -0
- package/dist/components/Switch/Switch.stories.d.ts +7 -0
- package/dist/components/Switch/Switch.stories.js +26 -0
- package/dist/components/TablePagination/TablePagination.d.ts +21 -0
- package/dist/components/TablePagination/TablePagination.js +21 -0
- package/dist/components/TablePagination/TablePagination.stories.d.ts +10 -0
- package/dist/components/TablePagination/TablePagination.stories.js +302 -0
- package/dist/components/Tabs/Tabs.d.ts +5 -0
- package/dist/components/Tabs/Tabs.js +5 -0
- package/dist/components/Tabs/Tabs.stories.d.ts +11 -0
- package/dist/components/Tabs/Tabs.stories.js +56 -0
- package/dist/components/Textarea/Textarea.d.ts +5 -0
- package/dist/components/Textarea/Textarea.js +5 -0
- package/dist/components/Textarea/Textarea.stories.d.ts +7 -0
- package/dist/components/Textarea/Textarea.stories.js +62 -0
- package/dist/components/Tooltip/Tooltip.d.ts +7 -11
- package/dist/components/Tooltip/Tooltip.js +7 -11
- package/dist/components/Tooltip/Tooltip.stories.d.ts +12 -0
- package/dist/components/Tooltip/Tooltip.stories.js +71 -0
- package/package.json +14 -14
|
@@ -10,9 +10,13 @@ var _Modal = _interopRequireDefault(require("../Modal"));
|
|
|
10
10
|
var _ActionButton = _interopRequireDefault(require("../ActionButton"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
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); }
|
|
13
|
+
/**
|
|
14
|
+
* `ConfirmationModal` is a specialised version of the [Modal](?path=/docs/modal--default-story) component to prompt a confirmation from the user before executing an action.
|
|
15
|
+
*/
|
|
13
16
|
const ConfirmationModal = _ref => {
|
|
14
17
|
let {
|
|
15
18
|
cancelButtonLabel = "Cancel",
|
|
19
|
+
cancelButtonProps,
|
|
16
20
|
children,
|
|
17
21
|
confirmButtonAppearance = "negative",
|
|
18
22
|
confirmButtonLabel,
|
|
@@ -20,6 +24,7 @@ const ConfirmationModal = _ref => {
|
|
|
20
24
|
onConfirm,
|
|
21
25
|
confirmButtonLoading,
|
|
22
26
|
confirmButtonDisabled,
|
|
27
|
+
confirmButtonProps,
|
|
23
28
|
...props
|
|
24
29
|
} = _ref;
|
|
25
30
|
const handleClick = action => event => {
|
|
@@ -31,16 +36,16 @@ const ConfirmationModal = _ref => {
|
|
|
31
36
|
}
|
|
32
37
|
};
|
|
33
38
|
return /*#__PURE__*/_react.default.createElement(_Modal.default, _extends({
|
|
34
|
-
buttonRow: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, confirmExtra, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
39
|
+
buttonRow: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, confirmExtra, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({}, cancelButtonProps, {
|
|
35
40
|
className: "u-no-margin--bottom",
|
|
36
41
|
onClick: handleClick(props.close)
|
|
37
|
-
}, cancelButtonLabel), /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
42
|
+
}), cancelButtonLabel), /*#__PURE__*/_react.default.createElement(_ActionButton.default, _extends({}, confirmButtonProps, {
|
|
38
43
|
appearance: confirmButtonAppearance,
|
|
39
44
|
className: "u-no-margin--bottom",
|
|
40
45
|
onClick: handleClick(onConfirm),
|
|
41
46
|
loading: confirmButtonLoading,
|
|
42
47
|
disabled: confirmButtonDisabled
|
|
43
|
-
}, confirmButtonLabel))
|
|
48
|
+
}), confirmButtonLabel))
|
|
44
49
|
}, props), children);
|
|
45
50
|
};
|
|
46
51
|
exports.ConfirmationModal = ConfirmationModal;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import ConfirmationModal from "./ConfirmationModal";
|
|
3
|
+
declare const meta: Meta<typeof ConfirmationModal>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ConfirmationModal>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
/**
|
|
8
|
+
* The title is optional, and the content is fully customisable.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NoTitle: Story;
|
|
11
|
+
/**
|
|
12
|
+
* The appearance of the confirm button can be any of the `Button`'s appearance values.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Positive: Story;
|
|
15
|
+
/**
|
|
16
|
+
* Extra elements can be added to the button row.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Extra: Story;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Positive = exports.NoTitle = exports.Extra = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _ConfirmationModal = _interopRequireDefault(require("./ConfirmationModal"));
|
|
9
|
+
var _Input = _interopRequireDefault(require("../Input"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const doNothing = () => {};
|
|
14
|
+
const meta = {
|
|
15
|
+
component: _ConfirmationModal.default,
|
|
16
|
+
tags: ["autodocs"]
|
|
17
|
+
};
|
|
18
|
+
var _default = exports.default = meta;
|
|
19
|
+
const Default = exports.Default = {
|
|
20
|
+
render: () => {
|
|
21
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
22
|
+
const [modalOpen, setModalOpen] = (0, _react.useState)(false);
|
|
23
|
+
const closeHandler = () => setModalOpen(false);
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
25
|
+
onClick: () => setModalOpen(true)
|
|
26
|
+
}, "Open confirmation modal"), modalOpen ? /*#__PURE__*/_react.default.createElement(_ConfirmationModal.default, {
|
|
27
|
+
title: "Confirm delete",
|
|
28
|
+
confirmButtonLabel: "Delete",
|
|
29
|
+
onConfirm: doNothing,
|
|
30
|
+
close: closeHandler
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, "This will permanently delete the user \"Simon\".", /*#__PURE__*/_react.default.createElement("br", null), "You cannot undo this action.")) : null);
|
|
32
|
+
},
|
|
33
|
+
name: "Default"
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The title is optional, and the content is fully customisable.
|
|
38
|
+
*/
|
|
39
|
+
const NoTitle = exports.NoTitle = {
|
|
40
|
+
render: () => {
|
|
41
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
42
|
+
const [modalOpen, setModalOpen] = (0, _react.useState)(false);
|
|
43
|
+
const closeHandler = () => setModalOpen(false);
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
45
|
+
onClick: () => setModalOpen(true)
|
|
46
|
+
}, "Run"), modalOpen ? /*#__PURE__*/_react.default.createElement(_ConfirmationModal.default, {
|
|
47
|
+
close: closeHandler,
|
|
48
|
+
confirmButtonAppearance: "positive",
|
|
49
|
+
confirmButtonLabel: "Confirm",
|
|
50
|
+
onConfirm: doNothing
|
|
51
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
52
|
+
style: {
|
|
53
|
+
margin: "1rem 0"
|
|
54
|
+
}
|
|
55
|
+
}, "Run list-backups?"), /*#__PURE__*/_react.default.createElement("div", {
|
|
56
|
+
style: {
|
|
57
|
+
width: "480px",
|
|
58
|
+
marginBottom: "1rem"
|
|
59
|
+
}
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
61
|
+
className: "u-text--muted"
|
|
62
|
+
}, "UNIT COUNT"), /*#__PURE__*/_react.default.createElement("div", null, "1")), /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
+
style: {
|
|
64
|
+
marginBottom: "1.5rem"
|
|
65
|
+
}
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
67
|
+
className: "u-text--muted"
|
|
68
|
+
}, "UNIT NAME"), /*#__PURE__*/_react.default.createElement("div", null, "mysql/0"))) : null);
|
|
69
|
+
},
|
|
70
|
+
name: "No title"
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The appearance of the confirm button can be any of the `Button`'s appearance values.
|
|
75
|
+
*/
|
|
76
|
+
const Positive = exports.Positive = {
|
|
77
|
+
render: () => {
|
|
78
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
79
|
+
const [modalOpen, setModalOpen] = (0, _react.useState)(false);
|
|
80
|
+
const closeHandler = () => setModalOpen(false);
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
82
|
+
onClick: () => setModalOpen(true)
|
|
83
|
+
}, "Apply changes"), modalOpen ? /*#__PURE__*/_react.default.createElement(_ConfirmationModal.default, {
|
|
84
|
+
close: closeHandler,
|
|
85
|
+
confirmButtonAppearance: "positive",
|
|
86
|
+
confirmButtonLabel: "Yes, apply changes",
|
|
87
|
+
onConfirm: doNothing
|
|
88
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
89
|
+
style: {
|
|
90
|
+
margin: "1rem 0"
|
|
91
|
+
}
|
|
92
|
+
}, "Are you sure you wish to apply these changes?"), /*#__PURE__*/_react.default.createElement("p", null, "You have edited the following values to the mysql configuration:"), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h5", {
|
|
93
|
+
className: "u-no-margin--bottom"
|
|
94
|
+
}, "cluster-name"), /*#__PURE__*/_react.default.createElement("pre", {
|
|
95
|
+
className: "u-no-padding",
|
|
96
|
+
style: {
|
|
97
|
+
backgroundColor: "transparent"
|
|
98
|
+
}
|
|
99
|
+
}, "test")), /*#__PURE__*/_react.default.createElement("div", {
|
|
100
|
+
className: "p-text--small",
|
|
101
|
+
style: {
|
|
102
|
+
width: "480px"
|
|
103
|
+
}
|
|
104
|
+
}, "You can revert back to the applications default settings by clicking the \u201CReset all values\u201D button; or reset each edited field by clicking \u201CUse default\u201D.")) : null);
|
|
105
|
+
},
|
|
106
|
+
name: "Positive"
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Extra elements can be added to the button row.
|
|
111
|
+
*/
|
|
112
|
+
const Extra = exports.Extra = {
|
|
113
|
+
render: () => {
|
|
114
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
115
|
+
const [modalOpen, setModalOpen] = (0, _react.useState)(false);
|
|
116
|
+
const closeHandler = () => setModalOpen(false);
|
|
117
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
118
|
+
onClick: () => setModalOpen(true)
|
|
119
|
+
}, "Stop"), modalOpen ? /*#__PURE__*/_react.default.createElement(_ConfirmationModal.default, {
|
|
120
|
+
confirmExtra: /*#__PURE__*/_react.default.createElement("span", {
|
|
121
|
+
className: "u-float-left"
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
123
|
+
type: "checkbox",
|
|
124
|
+
id: "extraCheckbox",
|
|
125
|
+
label: "Force stop",
|
|
126
|
+
tabIndex: -1
|
|
127
|
+
})),
|
|
128
|
+
title: "Confirm stop",
|
|
129
|
+
confirmButtonLabel: "Stop",
|
|
130
|
+
onConfirm: doNothing,
|
|
131
|
+
close: closeHandler
|
|
132
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, "This will stop instance", /*#__PURE__*/_react.default.createElement("b", null, "whimsical-mouflon"), ".")) : null);
|
|
133
|
+
},
|
|
134
|
+
name: "Extra"
|
|
135
|
+
};
|
|
@@ -98,26 +98,9 @@ export type Props<L> = PropsWithSpread<{
|
|
|
98
98
|
visible?: boolean;
|
|
99
99
|
}, HTMLProps<HTMLSpanElement>>;
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @param children - The menu content (if the links prop is not supplied).
|
|
105
|
-
* @param className - An optional class to apply to the wrapping element.
|
|
106
|
-
* @param [closeOnEsc=true] - Whether the menu should close when the escape key is pressed.
|
|
107
|
-
* @param [closeOnOutsideClick=true] - Whether the menu should close when clicking outside the menu.
|
|
108
|
-
* @param constrainPanelWidth - Whether the menu's width should match the toggle's width.
|
|
109
|
-
* @param dropdownClassName - An optional class to apply to the dropdown.
|
|
110
|
-
* @param hasToggleIcon - Whether the toggle should display a chevron icon.
|
|
111
|
-
* @param links - A list of links to display in the menu (if the children prop is not supplied.)
|
|
112
|
-
* @param onToggleMenu - A function to call when the menu is toggled.
|
|
113
|
-
* @param [position="right"] - The position of the menu.
|
|
114
|
-
* @param positionNode - An element to make the menu relative to.
|
|
115
|
-
* @param toggleAppearance - The appearance of the toggle button.
|
|
116
|
-
* @param toggleClassName - An class to apply to the toggle button.
|
|
117
|
-
* @param toggleDisabled - Whether the toggle button should be disabled.
|
|
118
|
-
* @param toggleLabel - The toggle button's label.
|
|
119
|
-
* @param [toggleLabelFirst=true] - Whether the toggle lable or icon should appear first.
|
|
120
|
-
* @param [visible=false] - Whether the menu should be visible.
|
|
101
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Contextual menu](https://docs.vanillaframework.io/patterns//contextual-menu/).
|
|
102
|
+
*
|
|
103
|
+
* A contextual menu can be used in conjunction with any page element to provide a contextual menu.
|
|
121
104
|
*/
|
|
122
105
|
declare const ContextualMenu: <L>({ autoAdjust, children, className, closeOnEsc, closeOnOutsideClick, constrainPanelWidth, dropdownClassName, dropdownProps, hasToggleIcon, links, onToggleMenu, position, positionNode, scrollOverflow, toggleAppearance, toggleClassName, toggleDisabled, toggleLabel, toggleLabelFirst, toggleProps, visible, ...wrapperProps }: Props<L>) => JSX.Element;
|
|
123
106
|
export default ContextualMenu;
|
|
@@ -49,26 +49,9 @@ const getPositionNodeVisible = positionNode => {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @param children - The menu content (if the links prop is not supplied).
|
|
56
|
-
* @param className - An optional class to apply to the wrapping element.
|
|
57
|
-
* @param [closeOnEsc=true] - Whether the menu should close when the escape key is pressed.
|
|
58
|
-
* @param [closeOnOutsideClick=true] - Whether the menu should close when clicking outside the menu.
|
|
59
|
-
* @param constrainPanelWidth - Whether the menu's width should match the toggle's width.
|
|
60
|
-
* @param dropdownClassName - An optional class to apply to the dropdown.
|
|
61
|
-
* @param hasToggleIcon - Whether the toggle should display a chevron icon.
|
|
62
|
-
* @param links - A list of links to display in the menu (if the children prop is not supplied.)
|
|
63
|
-
* @param onToggleMenu - A function to call when the menu is toggled.
|
|
64
|
-
* @param [position="right"] - The position of the menu.
|
|
65
|
-
* @param positionNode - An element to make the menu relative to.
|
|
66
|
-
* @param toggleAppearance - The appearance of the toggle button.
|
|
67
|
-
* @param toggleClassName - An class to apply to the toggle button.
|
|
68
|
-
* @param toggleDisabled - Whether the toggle button should be disabled.
|
|
69
|
-
* @param toggleLabel - The toggle button's label.
|
|
70
|
-
* @param [toggleLabelFirst=true] - Whether the toggle lable or icon should appear first.
|
|
71
|
-
* @param [visible=false] - Whether the menu should be visible.
|
|
52
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Contextual menu](https://docs.vanillaframework.io/patterns//contextual-menu/).
|
|
53
|
+
*
|
|
54
|
+
* A contextual menu can be used in conjunction with any page element to provide a contextual menu.
|
|
72
55
|
*/
|
|
73
56
|
const ContextualMenu = _ref => {
|
|
74
57
|
let {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import ContextualMenu from "./ContextualMenu";
|
|
3
|
+
declare const meta: Meta<typeof ContextualMenu>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ContextualMenu>;
|
|
6
|
+
/**
|
|
7
|
+
* The contextual menu will provide a visual wrapper to any provided children. Visibility can be toggled via the `visible` prop.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Default: Story;
|
|
10
|
+
export declare const Toggle: Story;
|
|
11
|
+
export declare const OverflowingContainer: Story;
|
|
12
|
+
export declare const ChildFunction: Story;
|
|
13
|
+
export declare const ChildElement: Story;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Toggle = exports.OverflowingContainer = exports.Default = exports.ChildFunction = exports.ChildElement = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
9
|
+
var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const ScrollTemplate = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
12
|
+
style: {
|
|
13
|
+
maxWidth: "30rem",
|
|
14
|
+
maxHeight: "10rem",
|
|
15
|
+
overflow: "auto",
|
|
16
|
+
padding: "1rem"
|
|
17
|
+
}
|
|
18
|
+
}, /*#__PURE__*/_react.default.createElement(_ContextualMenu.default, args), Array(3).fill( /*#__PURE__*/_react.default.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur cum dicta beatae nostrum eligendi similique earum, dolorem fuga quis, sequi voluptates architecto ipsa dolorum eaque rem expedita inventore voluptas odit aspernatur alias molestias facere.")), /*#__PURE__*/_react.default.createElement(_ContextualMenu.default, args));
|
|
19
|
+
const Template = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
20
|
+
className: "u-align--center"
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement(_ContextualMenu.default, args));
|
|
22
|
+
const meta = {
|
|
23
|
+
component: _ContextualMenu.default,
|
|
24
|
+
render: Template,
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
argTypes: {
|
|
27
|
+
children: {
|
|
28
|
+
control: {
|
|
29
|
+
disable: true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
links: {
|
|
33
|
+
control: {
|
|
34
|
+
disable: true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var _default = exports.default = meta;
|
|
40
|
+
/**
|
|
41
|
+
* The contextual menu will provide a visual wrapper to any provided children. Visibility can be toggled via the `visible` prop.
|
|
42
|
+
*/
|
|
43
|
+
const Default = exports.Default = {
|
|
44
|
+
name: "Default",
|
|
45
|
+
args: {
|
|
46
|
+
children: /*#__PURE__*/_react.default.createElement("span", {
|
|
47
|
+
style: {
|
|
48
|
+
padding: "1rem"
|
|
49
|
+
}
|
|
50
|
+
}, "This is a menu."),
|
|
51
|
+
closeOnOutsideClick: false,
|
|
52
|
+
constrainPanelWidth: false,
|
|
53
|
+
position: "left",
|
|
54
|
+
visible: true
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const Toggle = exports.Toggle = {
|
|
58
|
+
name: "Toggle",
|
|
59
|
+
args: {
|
|
60
|
+
links: [{
|
|
61
|
+
children: "Link 1",
|
|
62
|
+
onClick: () => {}
|
|
63
|
+
}, {
|
|
64
|
+
children: "Link 2",
|
|
65
|
+
onClick: () => {}
|
|
66
|
+
}],
|
|
67
|
+
hasToggleIcon: true,
|
|
68
|
+
position: "right",
|
|
69
|
+
toggleLabel: "Click me!"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const OverflowingContainer = exports.OverflowingContainer = {
|
|
73
|
+
render: ScrollTemplate.bind({}),
|
|
74
|
+
name: "Overflowing container",
|
|
75
|
+
args: {
|
|
76
|
+
links: [{
|
|
77
|
+
children: "Link 1",
|
|
78
|
+
onClick: () => {}
|
|
79
|
+
}, {
|
|
80
|
+
children: "Long Link 2",
|
|
81
|
+
onClick: () => {}
|
|
82
|
+
}],
|
|
83
|
+
hasToggleIcon: true,
|
|
84
|
+
position: "right",
|
|
85
|
+
toggleLabel: "Click me!"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const ChildFunction = exports.ChildFunction = {
|
|
89
|
+
name: "Child function",
|
|
90
|
+
args: {
|
|
91
|
+
children: close => /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
92
|
+
onClick: close
|
|
93
|
+
}, "child function"),
|
|
94
|
+
hasToggleIcon: true,
|
|
95
|
+
position: "right",
|
|
96
|
+
toggleLabel: "Click me!"
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const ChildElement = exports.ChildElement = {
|
|
100
|
+
name: "Child element",
|
|
101
|
+
args: {
|
|
102
|
+
children: /*#__PURE__*/_react.default.createElement(_Button.default, null, "child element"),
|
|
103
|
+
hasToggleIcon: true,
|
|
104
|
+
position: "right",
|
|
105
|
+
toggleLabel: "Click me!"
|
|
106
|
+
}
|
|
107
|
+
};
|
|
@@ -18,5 +18,8 @@ export type Props = PropsWithSpread<{
|
|
|
18
18
|
*/
|
|
19
19
|
title: string;
|
|
20
20
|
}, HTMLProps<HTMLDivElement>>;
|
|
21
|
+
/**
|
|
22
|
+
* This is a [React](https://reactjs.org/) component to represent an empty state.
|
|
23
|
+
*/
|
|
21
24
|
export declare const EmptyState: ({ children, className, image, title, ...props }: Props) => ReactElement;
|
|
22
25
|
export default EmptyState;
|
|
@@ -8,6 +8,9 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
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); }
|
|
11
|
+
/**
|
|
12
|
+
* This is a [React](https://reactjs.org/) component to represent an empty state.
|
|
13
|
+
*/
|
|
11
14
|
const EmptyState = _ref => {
|
|
12
15
|
let {
|
|
13
16
|
children,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import EmptyState from "./EmptyState";
|
|
3
|
+
declare const meta: Meta<typeof EmptyState>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof EmptyState>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithContent: Story;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithContent = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _EmptyState = _interopRequireDefault(require("./EmptyState"));
|
|
9
|
+
var _Icon = _interopRequireWildcard(require("../Icon"));
|
|
10
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
const boxImage = /*#__PURE__*/_react.default.createElement("img", {
|
|
15
|
+
src: "https://assets.ubuntu.com/v1/c17e0d92-container.svg",
|
|
16
|
+
style: {
|
|
17
|
+
maxWidth: "10rem",
|
|
18
|
+
maxHeight: "10rem"
|
|
19
|
+
},
|
|
20
|
+
alt: "empty state"
|
|
21
|
+
});
|
|
22
|
+
const doNothing = () => {};
|
|
23
|
+
const meta = {
|
|
24
|
+
component: _EmptyState.default,
|
|
25
|
+
tags: ["autodocs"]
|
|
26
|
+
};
|
|
27
|
+
var _default = exports.default = meta;
|
|
28
|
+
const Default = exports.Default = {
|
|
29
|
+
render: () => /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
|
|
30
|
+
image: boxImage,
|
|
31
|
+
title: "This application doesn't have any configuration parameters"
|
|
32
|
+
}),
|
|
33
|
+
name: "Default"
|
|
34
|
+
};
|
|
35
|
+
const WithContent = exports.WithContent = {
|
|
36
|
+
render: () => /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
|
|
37
|
+
image: boxImage,
|
|
38
|
+
title: "No instances found"
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, "There are no instances in this project. Spin up your first instance!"), /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
40
|
+
href: "#todo",
|
|
41
|
+
target: "_blank"
|
|
42
|
+
}, "How to create instances", /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
43
|
+
name: _Icon.ICONS.externalLink
|
|
44
|
+
}))), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
45
|
+
appearance: "positive",
|
|
46
|
+
onClick: doNothing
|
|
47
|
+
}, "Create instance")),
|
|
48
|
+
name: "With content"
|
|
49
|
+
};
|
|
@@ -12,5 +12,10 @@ export type Props = PropsWithSpread<{
|
|
|
12
12
|
inline?: boolean;
|
|
13
13
|
stacked?: boolean;
|
|
14
14
|
}, HTMLProps<HTMLFormElement>>;
|
|
15
|
+
/**
|
|
16
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Form](https://docs.vanillaframework.io/base/forms).
|
|
17
|
+
*
|
|
18
|
+
* Form controls have global styling defined at the HTML element level. Labels and most input types are 100% width of the `<form>` parent element.
|
|
19
|
+
*/
|
|
15
20
|
declare const Form: ({ children, className, inline, stacked, ...props }: Props) => JSX.Element;
|
|
16
21
|
export default Form;
|
|
@@ -8,6 +8,11 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
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); }
|
|
11
|
+
/**
|
|
12
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Form](https://docs.vanillaframework.io/base/forms).
|
|
13
|
+
*
|
|
14
|
+
* Form controls have global styling defined at the HTML element level. Labels and most input types are 100% width of the `<form>` parent element.
|
|
15
|
+
*/
|
|
11
16
|
const Form = _ref => {
|
|
12
17
|
let {
|
|
13
18
|
children,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Form from "./Form";
|
|
3
|
+
declare const meta: Meta<typeof Form>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Form>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Fieldset: Story;
|
|
8
|
+
export declare const Inline: Story;
|
|
9
|
+
export declare const Stacked: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const Validation: Story;
|
|
12
|
+
export declare const Required: Story;
|