@madie/madie-design-system 1.0.32 → 1.0.34

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.
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
2
  import PropTypes from "prop-types";
3
+ import { visuallyHidden } from '@mui/utils';
4
+
3
5
  import {
4
6
  Pagination as PaginationComponent,
5
7
  PaginationItem,
@@ -57,13 +59,19 @@ const Pagination = ({
57
59
  return (
58
60
  <Container>
59
61
  <Row>
62
+ {/*this span is only for screen reader*/}
63
+ <span
64
+ id="items-per-page"
65
+ style={visuallyHidden}
66
+ >
67
+ Items per page {limit}.
68
+ </span>
60
69
  <Typography
61
70
  fontSize={14}
62
71
  fontFamily="Rubik"
63
72
  sx={{
64
73
  color: "#333333",
65
74
  }}
66
- id="items-per-page"
67
75
  >
68
76
  Items per page
69
77
  </Typography>
@@ -87,6 +95,7 @@ const Pagination = ({
87
95
  label={null}
88
96
  onChange={handleLimitChange}
89
97
  inputProps={{
98
+ "aria-labelledby":"items-per-page",
90
99
  "aria-describedby": "items-per-page offset-of-total-items",
91
100
  }}
92
101
  >
@@ -206,4 +215,4 @@ Pagination.propTypes = {
206
215
  type: PropTypes.string,
207
216
  };
208
217
 
209
- export { Pagination };
218
+ export { Pagination };
@@ -0,0 +1,55 @@
1
+ import React, { useState } from "react";
2
+ import Popover from "./index";
3
+ import { withKnobs } from "@storybook/addon-knobs";
4
+
5
+ export default {
6
+ title: "Popover",
7
+ component: Popover,
8
+ decorators: [withKnobs],
9
+ };
10
+
11
+ export const PopOver = () => {
12
+ const [anchorEl, setAnchorEl] = useState(null);
13
+ const [optionsOpen, setOptionsOpen] = useState(false);
14
+
15
+ const onClose = () => {
16
+ setOptionsOpen(false);
17
+ };
18
+
19
+ const handleOpen = (e) => {
20
+ setAnchorEl(e.currentTarget);
21
+ setOptionsOpen(true);
22
+ };
23
+
24
+ const viewEditredirect = () => {
25
+ setOptionsOpen(false);
26
+ };
27
+
28
+ const zipData = () => {
29
+ setOptionsOpen(false);
30
+ };
31
+
32
+ return (
33
+ <div className="qpp-u-padding--12">
34
+ <button className="qpp-c-button" onClick={(e) => handleOpen(e)}>
35
+ Open Popover
36
+ </button>
37
+ <Popover
38
+ optionsOpen={optionsOpen}
39
+ anchorEl={anchorEl}
40
+ onClose={onClose}
41
+ canEdit={true}
42
+ editViewSelectOptionProps={{
43
+ label: "View",
44
+ toImplementFunction: viewEditredirect,
45
+ dataTestId: `edit-measure-1`,
46
+ }}
47
+ otherSelectOptionProps={[{
48
+ label: "Export",
49
+ toImplementFunction: zipData,
50
+ dataTestId: `export-measure-1`,
51
+ }]}
52
+ />
53
+ </div>
54
+ );
55
+ };
@@ -0,0 +1,110 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import Popover from "@mui/material/Popover";
4
+
5
+ const MadiePopover = ({
6
+ optionsOpen,
7
+ anchorEl,
8
+ handleClose,
9
+ canEdit,
10
+ editViewSelectOptionProps,
11
+ otherSelectOptionProps,
12
+ }) => {
13
+ return (
14
+ <Popover
15
+ open={optionsOpen}
16
+ anchorEl={anchorEl}
17
+ onClose={handleClose}
18
+ anchorOrigin={{
19
+ vertical: "bottom",
20
+ horizontal: "right",
21
+ }}
22
+ transformOrigin={{
23
+ vertical: "top",
24
+ horizontal: "left",
25
+ }}
26
+ sx={{
27
+ ".MuiPopover-paper": {
28
+ boxShadow: "none",
29
+ overflow: "visible",
30
+ ".popover-content": {
31
+ border: "solid 1px #979797",
32
+ position: "relative",
33
+ marginTop: "16px",
34
+ marginLeft: "-70px",
35
+ borderRadius: "6px",
36
+ background: "#F7F7F7",
37
+ width: "115px",
38
+ "&::before": {
39
+ borderWidth: "thin",
40
+ position: "absolute",
41
+ top: "-8px",
42
+ left: "calc(50% - 8px)",
43
+ height: "16px",
44
+ width: "16px",
45
+ background: "#F7F7F7",
46
+ borderColor:
47
+ "#979797 transparent transparent #979797",
48
+ content: '""',
49
+ transform: "rotate(45deg)",
50
+ },
51
+ ".btn-container": {
52
+ display: "flex",
53
+ flexDirection: "column",
54
+ padding: "10px 0",
55
+ button: {
56
+ zIndex: 2,
57
+ fontSize: 14,
58
+ padding: "0px 12px",
59
+ textAlign: "left",
60
+ "&:hover": {
61
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
62
+ },
63
+ },
64
+ },
65
+ },
66
+ },
67
+ }}
68
+ >
69
+ <div className="popover-content" data-testid="popover-content">
70
+ <div className="btn-container">
71
+ <button
72
+ data-testid={editViewSelectOptionProps.dataTestId}
73
+ onClick={editViewSelectOptionProps.toImplementFunction}
74
+ >
75
+ {editViewSelectOptionProps.label}
76
+ </button>
77
+ {canEdit &&
78
+ otherSelectOptionProps.map((res) => {
79
+ return (
80
+ <button
81
+ key={res.dataTestId}
82
+ data-testid={res.dataTestId}
83
+ onClick={res.toImplementFunction}
84
+ >
85
+ {res.label}
86
+ </button>
87
+ );
88
+ })}
89
+ </div>
90
+ </div>
91
+ </Popover>
92
+ );
93
+ };
94
+
95
+ MadiePopover.propTypes = {
96
+ optionsOpen: PropTypes.bool,
97
+ anchorEl: PropTypes.any,
98
+ handleClose: PropTypes.func,
99
+ canEdit: PropTypes.bool,
100
+ editViewSelectOptionProps: PropTypes.object,
101
+ otherSelectOptionProps: PropTypes.arrayOf(
102
+ PropTypes.shape({
103
+ dataTestId: PropTypes.string,
104
+ label: PropTypes.string,
105
+ toImplementFunction: PropTypes.func,
106
+ })
107
+ ),
108
+ };
109
+
110
+ export default MadiePopover;
@@ -1,6 +1,6 @@
1
1
  import Accordion from "./Accordion";
2
2
  import Alert from "./Alert";
3
- import AutoComplete from "./AutoComplete/AutoComplete"
3
+ import AutoComplete from "./AutoComplete/AutoComplete";
4
4
  import Breadcrumb from "./Breadcrumb";
5
5
  import Button, { TextButton } from "./Button";
6
6
  import CalloutBox from "./CalloutBox";
@@ -15,6 +15,7 @@ import MadieDiscardDialog from "./MadieDiscardDialog";
15
15
  import MadieDeleteDialog from "./MadieDeleteDialog";
16
16
  import MadieSpinner from "./MadieSpinner";
17
17
  import Modal from "./Modal";
18
+ import Popover from "./Popover";
18
19
  import { Pagination } from "./Pagination";
19
20
  import ReadOnlyTextField from "./ReadOnlyTextField";
20
21
  import Select from "./Select";
@@ -132,6 +133,7 @@ export {
132
133
  MadieDeleteDialog,
133
134
  MadieSpinner,
134
135
  Pagination,
136
+ Popover,
135
137
  ReadOnlyTextField,
136
138
  Search,
137
139
  Select,