aws-northstar
Version:
NorthStar Design System
154 lines (150 loc) • 6.82 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/** *******************************************************************************************************************
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. *
******************************************************************************************************************** */
const react_1 = __importStar(require("react"));
const PivotTableUI_1 = __importDefault(require("react-pivottable/PivotTableUI"));
const TableRenderers_1 = __importDefault(require("react-pivottable/TableRenderers"));
require("react-pivottable/pivottable.css");
const react_plotly_js_1 = __importDefault(require("react-plotly.js"));
const PlotlyRenderers_1 = __importDefault(require("react-pivottable/PlotlyRenderers"));
const styles_1 = require("@material-ui/core/styles");
const PlotlyRenderers = (0, PlotlyRenderers_1.default)(react_plotly_js_1.default);
const useStyles = (0, styles_1.makeStyles)((theme) => ({
root: {
// Main control
'& .pvtUi': {
fontFamily: theme.typography.fontFamily,
},
// Table content
'& table.pvtTable': {
fontFamily: theme.typography.fontFamily,
fontSize: theme.typography.subtitle1.fontSize,
},
'& .pvtAxisContainer, & .pvtVals': {
border: `1px solid ${theme.palette.grey['200']}`,
backgroundColor: theme.palette.grey['100'],
},
'& table.pvtTable thead tr th, & table.pvtTable tbody tr th': {
border: `1px solid ${theme.palette.grey['200']}`,
backgroundColor: theme.palette.grey['100'],
fontSize: theme.typography.subtitle1.fontSize,
},
'& table.pvtTable tbody tr td': {
border: `1px solid ${theme.palette.grey['200']}`,
color: theme.palette.grey['900'],
padding: '9px 12px',
},
// Dropdown control
'& .pvtDropdownMenu': {
border: `1px solid ${theme.palette.grey['400']}`,
borderTop: `1px solid ${theme.palette.grey['200']}`,
},
'& .pvtDropdownCurrent': {
border: `1px solid ${theme.palette.grey['400']}`,
},
'& .pvtDropdownValue': {
cursor: 'pointer',
padding: '4px 10px',
},
'& .pvtDropdownValue:not(.pvtDropdownCurrent)': {
border: '1px solid transparent',
},
'& .pvtDropdownValue:not(.pvtDropdownCurrent):not(.pvtDropdownActiveValue):hover': {
background: theme.palette.grey['100'],
border: `1px solid ${theme.palette.grey['500']}`,
},
'& .pvtDropdownValue.pvtDropdownActiveValue': {
background: theme.palette.info.light,
border: `1px solid ${theme.palette.info.dark}`,
},
// Data attributes (drag and drop control)
'& .pvtTriangle': {
color: theme.palette.info.contrastText,
},
'& .pvtAxisContainer li span.pvtAttr': {
background: theme.palette.info.dark,
color: theme.palette.info.contrastText,
border: 'none',
padding: '2px 7px',
borderRadius: '16px',
},
// Data attribute's popover
'& .pvtCheckContainer': {
borderTop: `1px solid ${theme.palette.grey['200']}`,
marginTop: '20px',
},
'& .pvtCheckContainer p.selected': {
cursor: 'pointer',
background: theme.palette.info.light,
},
'& .pvtFilterBox input[type="text"]': {
width: '240px',
border: `1px solid ${theme.palette.grey['400']}`,
padding: '4px 10px',
borderRadius: '2px',
marginBottom: theme.spacing(1),
},
'& .pvtButton': {
cursor: 'pointer',
padding: '4px 20px',
borderRadius: '2px',
background: theme.palette.background.paper,
letterSpacing: '.25px',
fontWeight: 'bold',
border: `1px solid ${theme.palette.grey['600']}`,
color: theme.palette.grey['600'],
},
'& .pvtButton:hover': {
border: `1px solid ${theme.palette.grey['900']}`,
color: theme.palette.grey['900'],
background: theme.palette.grey['100'],
},
},
}));
/**
* A pivot table with drag'n'drop functionality to enable data exploration and analysis by summarizing a data set into different presentational views such as a table or charts.
*/
const PivotTable = (props) => {
const classes = useStyles();
const [state, setState] = (0, react_1.useState)(props);
return (react_1.default.createElement("div", { className: classes.root },
react_1.default.createElement(PivotTableUI_1.default, Object.assign({ onChange: (s) => setState(s), renderers: Object.assign(Object.assign({}, TableRenderers_1.default), PlotlyRenderers) }, state))));
};
exports.default = PivotTable;