aws-northstar
Version:
NorthStar Design System
71 lines (67 loc) • 2.51 kB
JavaScript
/** *******************************************************************************************************************
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. *
******************************************************************************************************************** */
import React from 'react';
import Select from '../../Select';
import { Button } from '../../index';
import { Inline } from '../../../layouts';
function SelectColumnFilter({ column: { filterValue, setFilter } }) {
const options = [
{
label: 'Order 11',
value: 'Order 11',
},
{
label: 'Order 12',
value: 'Order 12',
},
{
label: 'Order 13',
value: 'Order 13',
},
];
return (React.createElement(Inline, { spacing: "xs" },
React.createElement(Select, { options: options, selectedOption: options.find(({ value }) => value === filterValue), onChange: (e) => {
setFilter(e.target.value || undefined);
} }),
React.createElement(Button, { onClick: () => setFilter(undefined), size: "small" }, "Clear")));
}
const filterColumnDefinition = [
{
id: 'id',
width: 200,
Header: 'Id',
accessor: 'id',
},
{
id: 'name',
width: 200,
Header: 'Name',
Filter: SelectColumnFilter,
accessor: 'name',
},
{
id: 'createdDate',
width: 200,
Header: 'Created date',
accessor: 'createdDate',
},
{
id: 'accounts',
width: 200,
Header: '# Accounts',
disableFilters: true,
disableGlobalFilter: true,
accessor: (row) => { var _a; return (_a = row.accounts) === null || _a === void 0 ? void 0 : _a.length; },
},
];
export default filterColumnDefinition;