@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
|
@@ -44,6 +44,59 @@ const generateRows = (rows, prepareRow, getRowProps, getCellProps) => {
|
|
|
44
44
|
});
|
|
45
45
|
return tableRows;
|
|
46
46
|
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
This is a [React](https://reactjs.org/) component to support many table use cases.
|
|
50
|
+
|
|
51
|
+
ModularTable components accepts `columns` and `data` arguments in the same format as [`useTable`](https://react-table.tanstack.com/docs/api/useTable) hook of the ReactTable library.
|
|
52
|
+
|
|
53
|
+
`columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
|
|
54
|
+
`data` - The data array that you want to display on the table.
|
|
55
|
+
### Important note!
|
|
56
|
+
Values passed to both of these params have to me memoized (for example via{" "}
|
|
57
|
+
<code>React.useMemo</code>). Memoization ensures that our data isn't recreated
|
|
58
|
+
on every render. If we didn't use <code>React.useMemo</code>, the table would
|
|
59
|
+
think it was receiving new data on every render and attempt to recalulate a
|
|
60
|
+
lot of logic every single time.
|
|
61
|
+
|
|
62
|
+
#### Custom column options
|
|
63
|
+
|
|
64
|
+
In addition to standard column propeties from [`useTable`](https://react-table.tanstack.com/docs/api/useTable) `ModularTable` accepts some custom properties.
|
|
65
|
+
|
|
66
|
+
##### Class names
|
|
67
|
+
|
|
68
|
+
Custom `className` can be used to provide a specific CSS class name that will be added to all cells in given column.
|
|
69
|
+
You can also provide `getHeaderProps`, `getRowProps` and `getCellProps` to resolve additional custom props for a specific element. More on this in [`useTable - cell properties`](https://react-table.tanstack.com/docs/api/useTable#cell-properties).
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
getCellProps={({ value, column }) => ({
|
|
73
|
+
className: `table__cell--${column.id} ${value === "1 minute" ? "p-heading--5" : ""}`,
|
|
74
|
+
})}
|
|
75
|
+
columns = {
|
|
76
|
+
Header: "Hidden on mobile",
|
|
77
|
+
accessor: "example",
|
|
78
|
+
className: "u-hide--small"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
##### Icons
|
|
83
|
+
|
|
84
|
+
To show an icon in the cells of a column `getCellIcon` function should be defined. The function takes a cell data as an argument and should return one of built in icons (from the `ICONS` const), a string with a custom icon name, or `false` if no icon should be shown.
|
|
85
|
+
|
|
86
|
+
The `ICONS` const contains all [the Vanilla built in icons](https://vanillaframework.io/docs/patterns/icons) such as "plus", "minus", "success", "error", etc.
|
|
87
|
+
|
|
88
|
+
Product specific icons can be used as well, assuming that the product provides the necessary CSS styling and the icon follows the Vanilla naming convention `p-icon--{name}`.
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
columns = {
|
|
92
|
+
Header: "With icons",
|
|
93
|
+
accessor: "status",
|
|
94
|
+
getCellIcon: ({ value }) => {
|
|
95
|
+
return value === "released" ? ICONS.success : false;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
*/
|
|
47
100
|
function ModularTable(_ref) {
|
|
48
101
|
let {
|
|
49
102
|
data,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import ModularTable from "./ModularTable";
|
|
3
|
+
declare const meta: Meta<typeof ModularTable>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ModularTable>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Empty: Story;
|
|
8
|
+
export declare const Sortable: Story;
|
|
9
|
+
/**
|
|
10
|
+
* Subrows can be used to group table rows under a heading that needs to appear
|
|
11
|
+
at the start of the group. In the following example sorting the columns will
|
|
12
|
+
sort the group rows, then sort the sub-rows, but the group header always comes first.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Subrows: Story;
|
|
15
|
+
/**
|
|
16
|
+
Example below shows a basic `ModularTable` with `SummaryButton` component in the footer.
|
|
17
|
+
```
|
|
18
|
+
export const getSampleData = (i = 0) => [
|
|
19
|
+
{ data: ++i * 100 + i },
|
|
20
|
+
{ data: ++i * 100 + i },
|
|
21
|
+
{ data: ++i * 100 + i },
|
|
22
|
+
{ data: ++i * 100 + i },
|
|
23
|
+
{ data: ++i * 100 + i },
|
|
24
|
+
];
|
|
25
|
+
```
|
|
26
|
+
*/
|
|
27
|
+
export declare const LoadMore: Story;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Subrows = exports.Sortable = exports.LoadMore = exports.Empty = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _SummaryButton = _interopRequireDefault(require("../SummaryButton"));
|
|
9
|
+
var _ModularTable = _interopRequireDefault(require("./ModularTable"));
|
|
10
|
+
var _Icon = require("../Icon");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
const getSampleData = function () {
|
|
15
|
+
let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
16
|
+
return [{
|
|
17
|
+
data: ++i * 100 + i
|
|
18
|
+
}, {
|
|
19
|
+
data: ++i * 100 + i
|
|
20
|
+
}, {
|
|
21
|
+
data: ++i * 100 + i
|
|
22
|
+
}, {
|
|
23
|
+
data: ++i * 100 + i
|
|
24
|
+
}, {
|
|
25
|
+
data: ++i * 100 + i
|
|
26
|
+
}];
|
|
27
|
+
};
|
|
28
|
+
const meta = {
|
|
29
|
+
component: _ModularTable.default,
|
|
30
|
+
tags: ["autodocs"]
|
|
31
|
+
};
|
|
32
|
+
var _default = exports.default = meta;
|
|
33
|
+
const Default = exports.Default = {
|
|
34
|
+
render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
|
|
35
|
+
getCellProps: _ref => {
|
|
36
|
+
let {
|
|
37
|
+
value
|
|
38
|
+
} = _ref;
|
|
39
|
+
return {
|
|
40
|
+
className: value === "1 minute" ? "p-heading--5" : ""
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
44
|
+
,
|
|
45
|
+
columns: _react.default.useMemo(() => [{
|
|
46
|
+
Header: "ID",
|
|
47
|
+
accessor: "buildId",
|
|
48
|
+
Cell: _ref2 => {
|
|
49
|
+
let {
|
|
50
|
+
value
|
|
51
|
+
} = _ref2;
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
53
|
+
href: "#test"
|
|
54
|
+
}, "#", value);
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
Header: "Architecture",
|
|
58
|
+
accessor: "arch"
|
|
59
|
+
}, {
|
|
60
|
+
Header: "Build Duration",
|
|
61
|
+
accessor: "duration",
|
|
62
|
+
className: "u-hide--small"
|
|
63
|
+
}, {
|
|
64
|
+
Header: "Result",
|
|
65
|
+
accessor: "result",
|
|
66
|
+
Cell: _ref3 => {
|
|
67
|
+
let {
|
|
68
|
+
value
|
|
69
|
+
} = _ref3;
|
|
70
|
+
switch (value) {
|
|
71
|
+
case "released":
|
|
72
|
+
return "Released";
|
|
73
|
+
case "failed":
|
|
74
|
+
return "Failed";
|
|
75
|
+
default:
|
|
76
|
+
return "Unknown";
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
getCellIcon: _ref4 => {
|
|
80
|
+
let {
|
|
81
|
+
value
|
|
82
|
+
} = _ref4;
|
|
83
|
+
switch (value) {
|
|
84
|
+
case "released":
|
|
85
|
+
return _Icon.ICONS.success;
|
|
86
|
+
case "failed":
|
|
87
|
+
return _Icon.ICONS.error;
|
|
88
|
+
default:
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
Header: "Build Finished",
|
|
94
|
+
accessor: "finished",
|
|
95
|
+
className: "u-align-text--right"
|
|
96
|
+
}], [])
|
|
97
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
98
|
+
,
|
|
99
|
+
data: _react.default.useMemo(() => [{
|
|
100
|
+
buildId: "5432",
|
|
101
|
+
arch: "arm64",
|
|
102
|
+
duration: "5 minutes",
|
|
103
|
+
result: "released",
|
|
104
|
+
finished: "10 minutes ago"
|
|
105
|
+
}, {
|
|
106
|
+
buildId: "1234",
|
|
107
|
+
arch: "armhf",
|
|
108
|
+
duration: "5 minutes",
|
|
109
|
+
result: "failed",
|
|
110
|
+
finished: "over 1 year ago"
|
|
111
|
+
}, {
|
|
112
|
+
buildId: "1111",
|
|
113
|
+
arch: "test64",
|
|
114
|
+
duration: "1 minute",
|
|
115
|
+
result: "other",
|
|
116
|
+
finished: "ages ago"
|
|
117
|
+
}], [])
|
|
118
|
+
}),
|
|
119
|
+
name: "Default"
|
|
120
|
+
};
|
|
121
|
+
const Empty = exports.Empty = {
|
|
122
|
+
render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
|
|
123
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
124
|
+
columns: _react.default.useMemo(() => [{
|
|
125
|
+
Header: "ID",
|
|
126
|
+
accessor: "buildId"
|
|
127
|
+
}, {
|
|
128
|
+
Header: "Architecture",
|
|
129
|
+
accessor: "arch"
|
|
130
|
+
}, {
|
|
131
|
+
Header: "Build Duration",
|
|
132
|
+
accessor: "duration",
|
|
133
|
+
className: "u-hide--small"
|
|
134
|
+
}, {
|
|
135
|
+
Header: "Result",
|
|
136
|
+
accessor: "result"
|
|
137
|
+
}, {
|
|
138
|
+
Header: "Build Finished",
|
|
139
|
+
accessor: "finished",
|
|
140
|
+
className: "u-align-text--right"
|
|
141
|
+
}], []),
|
|
142
|
+
data: [],
|
|
143
|
+
emptyMsg: "Waiting for data..."
|
|
144
|
+
}),
|
|
145
|
+
name: "Empty"
|
|
146
|
+
};
|
|
147
|
+
const Sortable = exports.Sortable = {
|
|
148
|
+
render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
|
|
149
|
+
sortable: true,
|
|
150
|
+
initialSortColumn: "duration",
|
|
151
|
+
initialSortDirection: "ascending",
|
|
152
|
+
getCellProps: _ref5 => {
|
|
153
|
+
let {
|
|
154
|
+
value
|
|
155
|
+
} = _ref5;
|
|
156
|
+
return {
|
|
157
|
+
className: value === "1 minute" ? "p-heading--5" : ""
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
161
|
+
,
|
|
162
|
+
columns: _react.default.useMemo(() => [{
|
|
163
|
+
Header: "ID",
|
|
164
|
+
accessor: "buildId",
|
|
165
|
+
sortType: "basic",
|
|
166
|
+
Cell: _ref6 => {
|
|
167
|
+
let {
|
|
168
|
+
value
|
|
169
|
+
} = _ref6;
|
|
170
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
171
|
+
href: "#test"
|
|
172
|
+
}, "#", value);
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
Header: "Architecture",
|
|
176
|
+
accessor: "arch",
|
|
177
|
+
sortType: "basic"
|
|
178
|
+
}, {
|
|
179
|
+
Header: "Build Duration",
|
|
180
|
+
accessor: "duration",
|
|
181
|
+
className: "u-hide--small",
|
|
182
|
+
sortType: "basic"
|
|
183
|
+
}, {
|
|
184
|
+
Header: "Result",
|
|
185
|
+
accessor: "result",
|
|
186
|
+
sortType: "basic",
|
|
187
|
+
Cell: _ref7 => {
|
|
188
|
+
let {
|
|
189
|
+
value
|
|
190
|
+
} = _ref7;
|
|
191
|
+
switch (value) {
|
|
192
|
+
case "released":
|
|
193
|
+
return "Released";
|
|
194
|
+
case "failed":
|
|
195
|
+
return "Failed";
|
|
196
|
+
default:
|
|
197
|
+
return "Unknown";
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
getCellIcon: _ref8 => {
|
|
201
|
+
let {
|
|
202
|
+
value
|
|
203
|
+
} = _ref8;
|
|
204
|
+
switch (value) {
|
|
205
|
+
case "released":
|
|
206
|
+
return _Icon.ICONS.success;
|
|
207
|
+
case "failed":
|
|
208
|
+
return _Icon.ICONS.error;
|
|
209
|
+
default:
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
Header: "Build Finished",
|
|
215
|
+
accessor: "finished",
|
|
216
|
+
className: "u-align-text--right",
|
|
217
|
+
sortType: "basic"
|
|
218
|
+
}], [])
|
|
219
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
220
|
+
,
|
|
221
|
+
data: _react.default.useMemo(() => [{
|
|
222
|
+
buildId: "5432",
|
|
223
|
+
arch: "arm64",
|
|
224
|
+
duration: "5 minutes",
|
|
225
|
+
result: "released",
|
|
226
|
+
finished: "10 minutes ago"
|
|
227
|
+
}, {
|
|
228
|
+
buildId: "1234",
|
|
229
|
+
arch: "armhf",
|
|
230
|
+
duration: "5 minutes",
|
|
231
|
+
result: "failed",
|
|
232
|
+
finished: "over 1 year ago"
|
|
233
|
+
}, {
|
|
234
|
+
buildId: "1111",
|
|
235
|
+
arch: "test64",
|
|
236
|
+
duration: "1 minute",
|
|
237
|
+
result: "other",
|
|
238
|
+
finished: "ages ago"
|
|
239
|
+
}], [])
|
|
240
|
+
}),
|
|
241
|
+
name: "Sortable"
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Subrows can be used to group table rows under a heading that needs to appear
|
|
246
|
+
at the start of the group. In the following example sorting the columns will
|
|
247
|
+
sort the group rows, then sort the sub-rows, but the group header always comes first.
|
|
248
|
+
*/
|
|
249
|
+
const Subrows = exports.Subrows = {
|
|
250
|
+
render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
|
|
251
|
+
sortable: true
|
|
252
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
253
|
+
,
|
|
254
|
+
columns: _react.default.useMemo(() => [{
|
|
255
|
+
Header: "Flavour",
|
|
256
|
+
accessor: "flavour",
|
|
257
|
+
sortType: "basic",
|
|
258
|
+
Cell: props => props.row.depth === 0 ? /*#__PURE__*/_react.default.createElement("strong", null, props.value) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", {
|
|
259
|
+
type: "checkbox"
|
|
260
|
+
}), " ", props.value)
|
|
261
|
+
}, {
|
|
262
|
+
Header: "Scoops",
|
|
263
|
+
accessor: "scoops",
|
|
264
|
+
sortType: "basic",
|
|
265
|
+
Cell: props => props.row.depth === 0 ? /*#__PURE__*/_react.default.createElement("span", {
|
|
266
|
+
className: "u-text--muted"
|
|
267
|
+
}, props.value) : props.value
|
|
268
|
+
}], [])
|
|
269
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
270
|
+
,
|
|
271
|
+
data: _react.default.useMemo(() => [{
|
|
272
|
+
flavour: "Sorbet",
|
|
273
|
+
scoops: "1-2",
|
|
274
|
+
subRows: [{
|
|
275
|
+
flavour: "Lemon",
|
|
276
|
+
scoops: 2
|
|
277
|
+
}, {
|
|
278
|
+
flavour: "Mango",
|
|
279
|
+
scoops: 1
|
|
280
|
+
}, {
|
|
281
|
+
flavour: "Raspberry",
|
|
282
|
+
scoops: 2
|
|
283
|
+
}]
|
|
284
|
+
}, {
|
|
285
|
+
flavour: "Ice-cream",
|
|
286
|
+
scoops: "1-3",
|
|
287
|
+
subRows: [{
|
|
288
|
+
flavour: "Chocolate",
|
|
289
|
+
scoops: 1
|
|
290
|
+
}, {
|
|
291
|
+
flavour: "Vanilla",
|
|
292
|
+
scoops: 3
|
|
293
|
+
}, {
|
|
294
|
+
flavour: "Caramel",
|
|
295
|
+
scoops: 2
|
|
296
|
+
}]
|
|
297
|
+
}], [])
|
|
298
|
+
}),
|
|
299
|
+
name: "Subrows"
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
Example below shows a basic `ModularTable` with `SummaryButton` component in the footer.
|
|
304
|
+
```
|
|
305
|
+
export const getSampleData = (i = 0) => [
|
|
306
|
+
{ data: ++i * 100 + i },
|
|
307
|
+
{ data: ++i * 100 + i },
|
|
308
|
+
{ data: ++i * 100 + i },
|
|
309
|
+
{ data: ++i * 100 + i },
|
|
310
|
+
{ data: ++i * 100 + i },
|
|
311
|
+
];
|
|
312
|
+
```
|
|
313
|
+
*/
|
|
314
|
+
const LoadMore = exports.LoadMore = {
|
|
315
|
+
render: () => {
|
|
316
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
317
|
+
const [data, setData] = (0, _react.useState)(getSampleData());
|
|
318
|
+
const hasMore = data.length < 20;
|
|
319
|
+
const loadMore = () => {
|
|
320
|
+
setData(data.concat(getSampleData(data.length)));
|
|
321
|
+
};
|
|
322
|
+
const columns = [{
|
|
323
|
+
Header: "Id",
|
|
324
|
+
accessor: (_d, i) => i
|
|
325
|
+
}, {
|
|
326
|
+
Header: "Data",
|
|
327
|
+
accessor: "data"
|
|
328
|
+
}];
|
|
329
|
+
const footer = hasMore ? /*#__PURE__*/_react.default.createElement("div", {
|
|
330
|
+
className: "u-align--right"
|
|
331
|
+
}, /*#__PURE__*/_react.default.createElement(_SummaryButton.default, {
|
|
332
|
+
summary: "Showing ".concat(data.length, " of 20 items."),
|
|
333
|
+
label: "Show 5 more",
|
|
334
|
+
onClick: loadMore
|
|
335
|
+
})) : null;
|
|
336
|
+
return /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
|
|
337
|
+
data: data,
|
|
338
|
+
columns: columns,
|
|
339
|
+
footer: footer
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
name: "Load more"
|
|
343
|
+
};
|
|
@@ -1,67 +1,8 @@
|
|
|
1
|
-
import { Meta } from "@storybook/react";
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { MultiSelect } from "./MultiSelect";
|
|
3
3
|
declare const meta: Meta<typeof MultiSelect>;
|
|
4
4
|
export default meta;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
value: string;
|
|
10
|
-
} | {
|
|
11
|
-
label: string;
|
|
12
|
-
value: number;
|
|
13
|
-
})[];
|
|
14
|
-
selectedItems: ({
|
|
15
|
-
label: string;
|
|
16
|
-
value: string;
|
|
17
|
-
} | {
|
|
18
|
-
label: string;
|
|
19
|
-
value: number;
|
|
20
|
-
})[];
|
|
21
|
-
variant: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export declare const SearchExample: {
|
|
25
|
-
args: {
|
|
26
|
-
variant: string;
|
|
27
|
-
items: ({
|
|
28
|
-
group: string;
|
|
29
|
-
label: string;
|
|
30
|
-
value: string;
|
|
31
|
-
} | {
|
|
32
|
-
group: string;
|
|
33
|
-
label: string;
|
|
34
|
-
value: number;
|
|
35
|
-
})[];
|
|
36
|
-
selectedItems: ({
|
|
37
|
-
label: string;
|
|
38
|
-
value: string;
|
|
39
|
-
} | {
|
|
40
|
-
label: string;
|
|
41
|
-
value: number;
|
|
42
|
-
})[];
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
export declare const WithDisabledItems: {
|
|
46
|
-
args: {
|
|
47
|
-
disabledItems: {
|
|
48
|
-
label: string;
|
|
49
|
-
value: number;
|
|
50
|
-
}[];
|
|
51
|
-
items: ({
|
|
52
|
-
label: string;
|
|
53
|
-
value: string;
|
|
54
|
-
} | {
|
|
55
|
-
label: string;
|
|
56
|
-
value: number;
|
|
57
|
-
})[];
|
|
58
|
-
selectedItems: ({
|
|
59
|
-
label: string;
|
|
60
|
-
value: string;
|
|
61
|
-
} | {
|
|
62
|
-
label: string;
|
|
63
|
-
value: number;
|
|
64
|
-
})[];
|
|
65
|
-
variant: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
5
|
+
type Story = StoryObj<typeof MultiSelect>;
|
|
6
|
+
export declare const CondensedExample: Story;
|
|
7
|
+
export declare const SearchExample: Story;
|
|
8
|
+
export declare const WithDisabledItems: Story;
|
|
@@ -54,5 +54,13 @@ export type Props = PropsWithSpread<{
|
|
|
54
54
|
*/
|
|
55
55
|
theme?: Theme | null;
|
|
56
56
|
}, HTMLProps<HTMLElement>>;
|
|
57
|
+
/**
|
|
58
|
+
This is the [React](https://reactjs.org/) component for the Vanilla
|
|
59
|
+
[Navigation](https://vanillaframework.io/docs/patterns/navigation) pattern. It
|
|
60
|
+
is a simple navigation bar that you can add to the top of your site or app.
|
|
61
|
+
|
|
62
|
+
The navigation items are collapsed behind a "Menu" link in small screens and
|
|
63
|
+
displayed horizontally on larger screens.
|
|
64
|
+
*/
|
|
57
65
|
declare const Navigation: ({ fullWidth, generateLink, items, itemsRight, leftNavProps, logo, navProps, rightNavProps, searchProps, theme, ...headerProps }: Props) => JSX.Element;
|
|
58
66
|
export default Navigation;
|
|
@@ -95,6 +95,15 @@ const generateItems = (items, closeMobileMenu, generateLink) => items.map((item,
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
})));
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
This is the [React](https://reactjs.org/) component for the Vanilla
|
|
101
|
+
[Navigation](https://vanillaframework.io/docs/patterns/navigation) pattern. It
|
|
102
|
+
is a simple navigation bar that you can add to the top of your site or app.
|
|
103
|
+
|
|
104
|
+
The navigation items are collapsed behind a "Menu" link in small screens and
|
|
105
|
+
displayed horizontally on larger screens.
|
|
106
|
+
*/
|
|
98
107
|
const Navigation = _ref => {
|
|
99
108
|
let {
|
|
100
109
|
fullWidth,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Navigation from "./Navigation";
|
|
3
|
+
declare const meta: Meta<typeof Navigation>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Navigation>;
|
|
6
|
+
/**
|
|
7
|
+
* The default navigation is constrained to the max width of the Vanilla grid and
|
|
8
|
+
uses the light theme.
|
|
9
|
+
*/
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
/**
|
|
12
|
+
* You can switch to a dark themed Navigation by using the `dark` prop. This will
|
|
13
|
+
automatically update the Navigation items to use lighter text and hover state
|
|
14
|
+
colours.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Dark: Story;
|
|
17
|
+
/**
|
|
18
|
+
* Sub-navigation dropdown menus can be added to Navigation by adding an `items`
|
|
19
|
+
array instead of a URL. By default, the dropdown items will align to the left of the
|
|
20
|
+
parent item. This can be changed by adding `alignRight` to the subnav
|
|
21
|
+
object.
|
|
22
|
+
*/
|
|
23
|
+
export declare const Dropdown: Story;
|
|
24
|
+
/**
|
|
25
|
+
* Expanding search can be enabled by providing props to the underlying [`SearchBox`](/?path=/docs/searchbox--default-story)
|
|
26
|
+
component. Elements to toggle the Searchbox will be included automatically if
|
|
27
|
+
the SearchBox props are provided.
|
|
28
|
+
*/
|
|
29
|
+
export declare const Search: Story;
|
|
30
|
+
/**
|
|
31
|
+
* Logos can be displayed using the new tag design. In cases where another logo
|
|
32
|
+
style is required then an element can be provided to the `logo` prop.
|
|
33
|
+
*/
|
|
34
|
+
export declare const OverridingTheLogo: Story;
|
|
35
|
+
/**
|
|
36
|
+
* In some cases such as when using [React Router](https://reactrouter.com/) it is
|
|
37
|
+
necessary to use custom components for links. When this is required then a
|
|
38
|
+
function can be passed to `generateLink` which should return your component.
|
|
39
|
+
Bear in mind that some props like classes and on-click events might be passed to
|
|
40
|
+
this function so take care in overriding any link props.
|
|
41
|
+
*/
|
|
42
|
+
export declare const OverridingTheLinkComponent: Story;
|
|
43
|
+
export declare const NoMenuItems: Story;
|