@darajs/ui-components 1.0.0-a.1
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/LICENSE +201 -0
- package/dist/accordion/accordion-item.d.ts +25 -0
- package/dist/accordion/accordion-item.d.ts.map +1 -0
- package/dist/accordion/accordion-item.js +90 -0
- package/dist/accordion/accordion-item.js.map +1 -0
- package/dist/accordion/accordion.d.ts +33 -0
- package/dist/accordion/accordion.d.ts.map +1 -0
- package/dist/accordion/accordion.js +86 -0
- package/dist/accordion/accordion.js.map +1 -0
- package/dist/badge/badge.d.ts +21 -0
- package/dist/badge/badge.d.ts.map +1 -0
- package/dist/badge/badge.js +42 -0
- package/dist/badge/badge.js.map +1 -0
- package/dist/button/button.d.ts +35 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +169 -0
- package/dist/button/button.js.map +1 -0
- package/dist/button-bar/button-bar.d.ts +19 -0
- package/dist/button-bar/button-bar.d.ts.map +1 -0
- package/dist/button-bar/button-bar.js +123 -0
- package/dist/button-bar/button-bar.js.map +1 -0
- package/dist/carousel/carousel.d.ts +24 -0
- package/dist/carousel/carousel.d.ts.map +1 -0
- package/dist/carousel/carousel.js +175 -0
- package/dist/carousel/carousel.js.map +1 -0
- package/dist/checkbox/checkbox-group.d.ts +36 -0
- package/dist/checkbox/checkbox-group.d.ts.map +1 -0
- package/dist/checkbox/checkbox-group.js +116 -0
- package/dist/checkbox/checkbox-group.js.map +1 -0
- package/dist/checkbox/checkbox.d.ts +28 -0
- package/dist/checkbox/checkbox.d.ts.map +1 -0
- package/dist/checkbox/checkbox.js +162 -0
- package/dist/checkbox/checkbox.js.map +1 -0
- package/dist/checkbox/tri-state-checkbox.d.ts +23 -0
- package/dist/checkbox/tri-state-checkbox.d.ts.map +1 -0
- package/dist/checkbox/tri-state-checkbox.js +87 -0
- package/dist/checkbox/tri-state-checkbox.js.map +1 -0
- package/dist/combo-box/combo-box.d.ts +328 -0
- package/dist/combo-box/combo-box.d.ts.map +1 -0
- package/dist/combo-box/combo-box.js +213 -0
- package/dist/combo-box/combo-box.js.map +1 -0
- package/dist/component-select-list/component-select-list.d.ts +27 -0
- package/dist/component-select-list/component-select-list.d.ts.map +1 -0
- package/dist/component-select-list/component-select-list.js +129 -0
- package/dist/component-select-list/component-select-list.js.map +1 -0
- package/dist/constants.d.ts +33 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +47 -0
- package/dist/constants.js.map +1 -0
- package/dist/context-menu/context-menu.d.ts +24 -0
- package/dist/context-menu/context-menu.d.ts.map +1 -0
- package/dist/context-menu/context-menu.js +112 -0
- package/dist/context-menu/context-menu.js.map +1 -0
- package/dist/datepicker/datepicker-select.d.ts +50 -0
- package/dist/datepicker/datepicker-select.d.ts.map +1 -0
- package/dist/datepicker/datepicker-select.js +211 -0
- package/dist/datepicker/datepicker-select.js.map +1 -0
- package/dist/datepicker/datepicker.d.ts +57 -0
- package/dist/datepicker/datepicker.d.ts.map +1 -0
- package/dist/datepicker/datepicker.js +608 -0
- package/dist/datepicker/datepicker.js.map +1 -0
- package/dist/dropzone/dropzone.d.ts +20 -0
- package/dist/dropzone/dropzone.d.ts.map +1 -0
- package/dist/dropzone/dropzone.js +77 -0
- package/dist/dropzone/dropzone.js.map +1 -0
- package/dist/error-boundary/error-boundary.d.ts +33 -0
- package/dist/error-boundary/error-boundary.d.ts.map +1 -0
- package/dist/error-boundary/error-boundary.js +72 -0
- package/dist/error-boundary/error-boundary.js.map +1 -0
- package/dist/filter/categorical-filter.d.ts +27 -0
- package/dist/filter/categorical-filter.d.ts.map +1 -0
- package/dist/filter/categorical-filter.js +150 -0
- package/dist/filter/categorical-filter.js.map +1 -0
- package/dist/filter/datetime-filter.d.ts +29 -0
- package/dist/filter/datetime-filter.d.ts.map +1 -0
- package/dist/filter/datetime-filter.js +196 -0
- package/dist/filter/datetime-filter.js.map +1 -0
- package/dist/filter/numeric-filter.d.ts +25 -0
- package/dist/filter/numeric-filter.d.ts.map +1 -0
- package/dist/filter/numeric-filter.js +146 -0
- package/dist/filter/numeric-filter.js.map +1 -0
- package/dist/hierarchy-selector/hierarchy-selector.d.ts +31 -0
- package/dist/hierarchy-selector/hierarchy-selector.d.ts.map +1 -0
- package/dist/hierarchy-selector/hierarchy-selector.js +65 -0
- package/dist/hierarchy-selector/hierarchy-selector.js.map +1 -0
- package/dist/hierarchy-selector/node/branch.d.ts +47 -0
- package/dist/hierarchy-selector/node/branch.d.ts.map +1 -0
- package/dist/hierarchy-selector/node/branch.js +133 -0
- package/dist/hierarchy-selector/node/branch.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/input/input.d.ts +58 -0
- package/dist/input/input.d.ts.map +1 -0
- package/dist/input/input.js +102 -0
- package/dist/input/input.js.map +1 -0
- package/dist/jest-setup.d.ts +18 -0
- package/dist/jest-setup.d.ts.map +1 -0
- package/dist/jest-setup.js +18 -0
- package/dist/jest-setup.js.map +1 -0
- package/dist/modal/modal.d.ts +37 -0
- package/dist/modal/modal.d.ts.map +1 -0
- package/dist/modal/modal.js +120 -0
- package/dist/modal/modal.js.map +1 -0
- package/dist/multiselect/multiselect.d.ts +31 -0
- package/dist/multiselect/multiselect.d.ts.map +1 -0
- package/dist/multiselect/multiselect.js +282 -0
- package/dist/multiselect/multiselect.js.map +1 -0
- package/dist/numeric-input/input-stepper.d.ts +33 -0
- package/dist/numeric-input/input-stepper.d.ts.map +1 -0
- package/dist/numeric-input/input-stepper.js +54 -0
- package/dist/numeric-input/input-stepper.js.map +1 -0
- package/dist/numeric-input/numeric-input.d.ts +48 -0
- package/dist/numeric-input/numeric-input.d.ts.map +1 -0
- package/dist/numeric-input/numeric-input.js +199 -0
- package/dist/numeric-input/numeric-input.js.map +1 -0
- package/dist/progress-bar/progress-bar.d.ts +23 -0
- package/dist/progress-bar/progress-bar.d.ts.map +1 -0
- package/dist/progress-bar/progress-bar.js +88 -0
- package/dist/progress-bar/progress-bar.js.map +1 -0
- package/dist/radio/radio-group.d.ts +20 -0
- package/dist/radio/radio-group.d.ts.map +1 -0
- package/dist/radio/radio-group.js +158 -0
- package/dist/radio/radio-group.js.map +1 -0
- package/dist/search-bar/search-bar.d.ts +34 -0
- package/dist/search-bar/search-bar.d.ts.map +1 -0
- package/dist/search-bar/search-bar.js +39 -0
- package/dist/search-bar/search-bar.js.map +1 -0
- package/dist/sectioned-list/sectioned-list.d.ts +29 -0
- package/dist/sectioned-list/sectioned-list.d.ts.map +1 -0
- package/dist/sectioned-list/sectioned-list.js +208 -0
- package/dist/sectioned-list/sectioned-list.js.map +1 -0
- package/dist/select/select.d.ts +54 -0
- package/dist/select/select.d.ts.map +1 -0
- package/dist/select/select.js +159 -0
- package/dist/select/select.js.map +1 -0
- package/dist/slider/slider-inputs.d.ts +36 -0
- package/dist/slider/slider-inputs.d.ts.map +1 -0
- package/dist/slider/slider-inputs.js +85 -0
- package/dist/slider/slider-inputs.js.map +1 -0
- package/dist/slider/slider.d.ts +53 -0
- package/dist/slider/slider.d.ts.map +1 -0
- package/dist/slider/slider.js +267 -0
- package/dist/slider/slider.js.map +1 -0
- package/dist/spinner/spinner.d.ts +20 -0
- package/dist/spinner/spinner.d.ts.map +1 -0
- package/dist/spinner/spinner.js +132 -0
- package/dist/spinner/spinner.js.map +1 -0
- package/dist/switch/sun-icon.d.ts +3 -0
- package/dist/switch/sun-icon.d.ts.map +1 -0
- package/dist/switch/sun-icon.js +24 -0
- package/dist/switch/sun-icon.js.map +1 -0
- package/dist/switch/switch.d.ts +17 -0
- package/dist/switch/switch.d.ts.map +1 -0
- package/dist/switch/switch.js +92 -0
- package/dist/switch/switch.js.map +1 -0
- package/dist/table/cells/action-cell.d.ts +34 -0
- package/dist/table/cells/action-cell.d.ts.map +1 -0
- package/dist/table/cells/action-cell.js +68 -0
- package/dist/table/cells/action-cell.js.map +1 -0
- package/dist/table/cells/datetime-cell.d.ts +12 -0
- package/dist/table/cells/datetime-cell.d.ts.map +1 -0
- package/dist/table/cells/datetime-cell.js +36 -0
- package/dist/table/cells/datetime-cell.js.map +1 -0
- package/dist/table/cells/edit-cell-utils.d.ts +32 -0
- package/dist/table/cells/edit-cell-utils.d.ts.map +1 -0
- package/dist/table/cells/edit-cell-utils.js +2 -0
- package/dist/table/cells/edit-cell-utils.js.map +1 -0
- package/dist/table/cells/edit-input-cell.d.ts +10 -0
- package/dist/table/cells/edit-input-cell.d.ts.map +1 -0
- package/dist/table/cells/edit-input-cell.js +61 -0
- package/dist/table/cells/edit-input-cell.js.map +1 -0
- package/dist/table/cells/edit-select-cell.d.ts +12 -0
- package/dist/table/cells/edit-select-cell.d.ts.map +1 -0
- package/dist/table/cells/edit-select-cell.js +55 -0
- package/dist/table/cells/edit-select-cell.js.map +1 -0
- package/dist/table/filters.d.ts +46 -0
- package/dist/table/filters.d.ts.map +1 -0
- package/dist/table/filters.js +223 -0
- package/dist/table/filters.js.map +1 -0
- package/dist/table/headers/select-header.d.ts +14 -0
- package/dist/table/headers/select-header.d.ts.map +1 -0
- package/dist/table/headers/select-header.js +41 -0
- package/dist/table/headers/select-header.js.map +1 -0
- package/dist/table/options-menu.d.ts +25 -0
- package/dist/table/options-menu.d.ts.map +1 -0
- package/dist/table/options-menu.js +120 -0
- package/dist/table/options-menu.js.map +1 -0
- package/dist/table/table.d.ts +95 -0
- package/dist/table/table.d.ts.map +1 -0
- package/dist/table/table.js +524 -0
- package/dist/table/table.js.map +1 -0
- package/dist/table/types.d.ts +30 -0
- package/dist/table/types.d.ts.map +1 -0
- package/dist/table/types.js +2 -0
- package/dist/table/types.js.map +1 -0
- package/dist/tabs/tabs.d.ts +22 -0
- package/dist/tabs/tabs.d.ts.map +1 -0
- package/dist/tabs/tabs.js +88 -0
- package/dist/tabs/tabs.js.map +1 -0
- package/dist/textarea/textarea.d.ts +45 -0
- package/dist/textarea/textarea.d.ts.map +1 -0
- package/dist/textarea/textarea.js +77 -0
- package/dist/textarea/textarea.js.map +1 -0
- package/dist/tooltip/tooltip.d.ts +46 -0
- package/dist/tooltip/tooltip.d.ts.map +1 -0
- package/dist/tooltip/tooltip.js +116 -0
- package/dist/tooltip/tooltip.js.map +1 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/chevron.d.ts +34 -0
- package/dist/utils/chevron.d.ts.map +1 -0
- package/dist/utils/chevron.js +40 -0
- package/dist/utils/chevron.js.map +1 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/label.d.ts +3 -0
- package/dist/utils/label.d.ts.map +1 -0
- package/dist/utils/label.js +24 -0
- package/dist/utils/label.js.map +1 -0
- package/dist/utils/list-styles.d.ts +12 -0
- package/dist/utils/list-styles.d.ts.map +1 -0
- package/dist/utils/list-styles.js +58 -0
- package/dist/utils/list-styles.js.map +1 -0
- package/dist/utils/same-width-modifier.d.ts +23 -0
- package/dist/utils/same-width-modifier.d.ts.map +1 -0
- package/dist/utils/same-width-modifier.js +17 -0
- package/dist/utils/same-width-modifier.js.map +1 -0
- package/dist/utils/use-infinite-loader.d.ts +32 -0
- package/dist/utils/use-infinite-loader.d.ts.map +1 -0
- package/dist/utils/use-infinite-loader.js +114 -0
- package/dist/utils/use-infinite-loader.js.map +1 -0
- package/dist/utils/use-on-click-outside.d.ts +3 -0
- package/dist/utils/use-on-click-outside.d.ts.map +1 -0
- package/dist/utils/use-on-click-outside.js +36 -0
- package/dist/utils/use-on-click-outside.js.map +1 -0
- package/package.json +105 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@darajs/styled-components';
|
|
3
|
+
import { CheckSquare, Copy, Square, ToggleOff, ToggleOn, Trash } from '@darajs/ui-icons';
|
|
4
|
+
export var Action;
|
|
5
|
+
(function (Action) {
|
|
6
|
+
Action["COPY"] = "copy";
|
|
7
|
+
Action["DELETE"] = "delete";
|
|
8
|
+
Action["SELECT"] = "select";
|
|
9
|
+
Action["SELECT_ALL"] = "select_all";
|
|
10
|
+
Action["SWITCH"] = "switch";
|
|
11
|
+
Action["UNSELECT_ALL"] = "unselect_all";
|
|
12
|
+
})(Action || (Action = {}));
|
|
13
|
+
const SelectCheck = styled(CheckSquare) `
|
|
14
|
+
color: ${(props) => props.theme.colors.primary};
|
|
15
|
+
`;
|
|
16
|
+
function getSelectIcon(row) {
|
|
17
|
+
return row.selected ? SelectCheck : Square;
|
|
18
|
+
}
|
|
19
|
+
const SwitchOn = styled(ToggleOn) `
|
|
20
|
+
color: ${(props) => props.theme.colors.primary};
|
|
21
|
+
`;
|
|
22
|
+
function getSwitchIcon(row) {
|
|
23
|
+
return row.active ? SwitchOn : ToggleOff;
|
|
24
|
+
}
|
|
25
|
+
export const Actions = {
|
|
26
|
+
COPY: { icon: Copy, id: Action.COPY, label: 'Copy' },
|
|
27
|
+
DELETE: { icon: Trash, id: Action.DELETE, label: 'Delete' },
|
|
28
|
+
SELECT: { getIcon: getSelectIcon, id: Action.SELECT, label: 'Select Row' },
|
|
29
|
+
SELECT_ALL: { id: Action.SELECT_ALL, label: 'Select All Rows' },
|
|
30
|
+
SWITCH: { getIcon: getSwitchIcon, id: Action.SWITCH, label: 'Switch On/Off' },
|
|
31
|
+
UNSELECT_ALL: { id: Action.UNSELECT_ALL, label: 'Unselect All Rows' },
|
|
32
|
+
};
|
|
33
|
+
const ActionWrapper = styled.div `
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
|
|
38
|
+
width: 100%;
|
|
39
|
+
padding: 0 1rem;
|
|
40
|
+
|
|
41
|
+
svg:not(:last-of-type) {
|
|
42
|
+
margin-right: 0.7rem;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
/**
|
|
46
|
+
* The action cell is used by the action column to render row actions such as delete on each row of a table
|
|
47
|
+
*
|
|
48
|
+
* @param {ActionCellProps} props see interface for details
|
|
49
|
+
*/
|
|
50
|
+
export function ActionCell(props) {
|
|
51
|
+
if (!props.column.actions) {
|
|
52
|
+
throw new Error('Must pass an array of actions to the column def when using the ActionCell');
|
|
53
|
+
}
|
|
54
|
+
return (_jsx(ActionWrapper, { className: "table-action-cell", children: props.column.actions.map((action) => {
|
|
55
|
+
const Icon = action.getIcon ? action.getIcon(props.row.original) : action.icon;
|
|
56
|
+
if (Icon === undefined) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const label = action.getLabel ? action.getLabel(props.row.original) : action.label;
|
|
60
|
+
const onClick = (e) => {
|
|
61
|
+
var _a;
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
(_a = props.onAction) === null || _a === void 0 ? void 0 : _a.call(props, action.id, props.row.original);
|
|
64
|
+
};
|
|
65
|
+
return _jsx(Icon, { asButton: true, onClick: onClick, title: label }, action.label);
|
|
66
|
+
}) }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=action-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-cell.js","sourceRoot":"","sources":["../../../src/table/cells/action-cell.tsx"],"names":[],"mappings":";AAkBA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAa,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEpG,MAAM,CAAN,IAAY,MAOX;AAPD,WAAY,MAAM;IACd,uBAAa,CAAA;IACb,2BAAiB,CAAA;IACjB,2BAAiB,CAAA;IACjB,mCAAyB,CAAA;IACzB,2BAAiB,CAAA;IACjB,uCAA6B,CAAA;AACjC,CAAC,EAPW,MAAM,KAAN,MAAM,QAOjB;AAED,MAAM,WAAW,GAAG,MAAM,CA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
|
|
6
|
+
* A date formatting cell that will accept native JS date objects and render them according to a string format
|
|
7
|
+
*
|
|
8
|
+
* @param fmt the date format to render the Date as
|
|
9
|
+
*/
|
|
10
|
+
declare function DatetimeCell(fmt?: string): (props: DateCellProps) => string;
|
|
11
|
+
export default DatetimeCell;
|
|
12
|
+
//# sourceMappingURL=datetime-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime-cell.d.ts","sourceRoot":"","sources":["../../../src/table/cells/datetime-cell.tsx"],"names":[],"mappings":"AAkBA,0FAA0F;AAC1F,UAAU,aAAa;IACnB,KAAK,EAAE,GAAG,CAAC;CACd;AAED;;;;GAIG;AACH,iBAAS,YAAY,CAAC,GAAG,SAAqB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAahF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { format, parseISO } from 'date-fns';
|
|
18
|
+
/**
|
|
19
|
+
* A date formatting cell that will accept native JS date objects and render them according to a string format
|
|
20
|
+
*
|
|
21
|
+
* @param fmt the date format to render the Date as
|
|
22
|
+
*/
|
|
23
|
+
function DatetimeCell(fmt = 'yyyy-MM-dd HH:mm') {
|
|
24
|
+
return ({ value }) => {
|
|
25
|
+
if (!value) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
const parsed = parseISO(value);
|
|
29
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
return format(parsed, fmt);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export default DatetimeCell;
|
|
36
|
+
//# sourceMappingURL=datetime-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime-cell.js","sourceRoot":"","sources":["../../../src/table/cells/datetime-cell.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAO5C;;;;GAIG;AACH,SAAS,YAAY,CAAC,GAAG,GAAG,kBAAkB;IAC1C,OAAO,CAAC,EAAE,KAAK,EAAiB,EAAU,EAAE;QACxC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,EAAE,CAAC;SACb;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE;YAChC,OAAO,EAAE,CAAC;SACb;QAED,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as React from 'react';
|
|
18
|
+
/** Interface is very loose because react table basically lets anything go through here */
|
|
19
|
+
export interface EditCellProps<T> {
|
|
20
|
+
cell: any;
|
|
21
|
+
column: any;
|
|
22
|
+
currentEditCell?: [number, string | number];
|
|
23
|
+
data: any;
|
|
24
|
+
onAction: (actionId: string, row: any) => void | Promise<void>;
|
|
25
|
+
onChange: (value: T, rowIdx: number, colId: string) => void | Promise<void>;
|
|
26
|
+
onStartEdit: (e?: React.SyntheticEvent<HTMLSpanElement>) => void | Promise<void>;
|
|
27
|
+
onStopEdit: () => void | Promise<void>;
|
|
28
|
+
row: any;
|
|
29
|
+
rowIdx: number;
|
|
30
|
+
value: any;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=edit-cell-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-cell-utils.d.ts","sourceRoot":"","sources":["../../../src/table/cells/edit-cell-utils.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,0FAA0F;AAC1F,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,GAAG,CAAC;IACZ,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC5C,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-cell-utils.js","sourceRoot":"","sources":["../../../src/table/cells/edit-cell-utils.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditCellProps } from './edit-cell-utils';
|
|
2
|
+
/**
|
|
3
|
+
* The edit input cell can be used to make all the cells of a particular column editable with an input field. When using
|
|
4
|
+
* an editable cell then an onChange handler should be added to the main table component as well to listen for any
|
|
5
|
+
* updates. The onChange handler will be called with the value, row index and column id, but it will not update the data
|
|
6
|
+
* for you. You need to update the data and pass it back in to the component.
|
|
7
|
+
*/
|
|
8
|
+
declare function EditInputCell(): (props: EditCellProps<string>) => JSX.Element;
|
|
9
|
+
export default EditInputCell;
|
|
10
|
+
//# sourceMappingURL=edit-input-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-input-cell.d.ts","sourceRoot":"","sources":["../../../src/table/cells/edit-input-cell.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAelD;;;;;GAKG;AACH,iBAAS,aAAa,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,OAAO,CAuCtE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import isEqual from 'lodash/isEqual';
|
|
19
|
+
import { useEffect, useState } from 'react';
|
|
20
|
+
import styled from '@darajs/styled-components';
|
|
21
|
+
import Input from '../../input/input';
|
|
22
|
+
const InputWrapper = styled.div `
|
|
23
|
+
display: flex;
|
|
24
|
+
width: calc(100% + 22px);
|
|
25
|
+
margin: 0 -1rem;
|
|
26
|
+
`;
|
|
27
|
+
const ValueWrapper = styled.span `
|
|
28
|
+
display: flex;
|
|
29
|
+
flex: 1 1 auto;
|
|
30
|
+
align-items: center;
|
|
31
|
+
height: 100%;
|
|
32
|
+
`;
|
|
33
|
+
/**
|
|
34
|
+
* The edit input cell can be used to make all the cells of a particular column editable with an input field. When using
|
|
35
|
+
* an editable cell then an onChange handler should be added to the main table component as well to listen for any
|
|
36
|
+
* updates. The onChange handler will be called with the value, row index and column id, but it will not update the data
|
|
37
|
+
* for you. You need to update the data and pass it back in to the component.
|
|
38
|
+
*/
|
|
39
|
+
function EditInputCell() {
|
|
40
|
+
return function InputCell(props) {
|
|
41
|
+
const [value, setValue] = useState(props.value);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
setValue(props.value);
|
|
44
|
+
}, [props.value]);
|
|
45
|
+
if (isEqual(props.currentEditCell, [props.rowIdx, props.column.id])) {
|
|
46
|
+
const onComplete = () => {
|
|
47
|
+
if (props.onChange && value !== props.value) {
|
|
48
|
+
props.onChange(value, props.rowIdx, props.column.id);
|
|
49
|
+
}
|
|
50
|
+
props.onStopEdit();
|
|
51
|
+
};
|
|
52
|
+
const onChange = (val) => {
|
|
53
|
+
setValue(val);
|
|
54
|
+
};
|
|
55
|
+
return (_jsx(InputWrapper, { children: _jsx(Input, { autoFocus: true, initialValue: props.value, onBlur: onComplete, onChange: onChange, onComplete: onComplete, style: { maxWidth: '100%' } }) }));
|
|
56
|
+
}
|
|
57
|
+
return (_jsx(ValueWrapper, { "data-cell": [props.rowIdx, props.column.id], onClick: props.onStartEdit, children: props.value }));
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export default EditInputCell;
|
|
61
|
+
//# sourceMappingURL=edit-input-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-input-cell.js","sourceRoot":"","sources":["../../../src/table/cells/edit-input-cell.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAGtC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI9B,CAAC;AAEF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;CAK/B,CAAC;AAEF;;;;;GAKG;AACH,SAAS,aAAa;IAClB,OAAO,SAAS,SAAS,CAAC,KAA4B;QAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACh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/**
|
|
4
|
+
* The edit select cell can be used to make all the cells of a particular column editable with a select field to
|
|
5
|
+
* constrain the options you can choose from. When using an editable cell then an onChange handler should be added to
|
|
6
|
+
* the main table component as well to listen for any updates. The onChange handler will be called with the value, row
|
|
7
|
+
* index and column id, but it will not update the data for you. You need to update the data and pass it back in to the
|
|
8
|
+
* component.
|
|
9
|
+
*/
|
|
10
|
+
declare function EditSelectCell<T extends Item>(items: Array<T>): (props: EditCellProps<T>) => JSX.Element;
|
|
11
|
+
export default EditSelectCell;
|
|
12
|
+
//# sourceMappingURL=edit-select-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-select-cell.d.ts","sourceRoot":"","sources":["../../../src/table/cells/edit-select-cell.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAelD;;;;;;GAMG;AACH,iBAAS,cAAc,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CA+BjG;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import isEqual from 'lodash/isEqual';
|
|
19
|
+
import styled from '@darajs/styled-components';
|
|
20
|
+
import Select from '../../select/select';
|
|
21
|
+
const SelectWrapper = styled.div `
|
|
22
|
+
display: flex;
|
|
23
|
+
width: calc(100% + 22px);
|
|
24
|
+
margin: 0 -1rem;
|
|
25
|
+
`;
|
|
26
|
+
const ValueWrapper = styled.span `
|
|
27
|
+
display: flex;
|
|
28
|
+
flex: 1 1 auto;
|
|
29
|
+
align-items: center;
|
|
30
|
+
height: 100%;
|
|
31
|
+
`;
|
|
32
|
+
/**
|
|
33
|
+
* The edit select cell can be used to make all the cells of a particular column editable with a select field to
|
|
34
|
+
* constrain the options you can choose from. When using an editable cell then an onChange handler should be added to
|
|
35
|
+
* the main table component as well to listen for any updates. The onChange handler will be called with the value, row
|
|
36
|
+
* index and column id, but it will not update the data for you. You need to update the data and pass it back in to the
|
|
37
|
+
* component.
|
|
38
|
+
*/
|
|
39
|
+
function EditSelectCell(items) {
|
|
40
|
+
return function SelectCell(props) {
|
|
41
|
+
const selectedItem = items.find((item) => item.value === props.value);
|
|
42
|
+
if (isEqual(props.currentEditCell, [props.rowIdx, props.column.id])) {
|
|
43
|
+
const onSelect = (item) => {
|
|
44
|
+
if (props.onChange && item.value !== props.value) {
|
|
45
|
+
props.onChange(item.value, props.rowIdx, props.column.id);
|
|
46
|
+
}
|
|
47
|
+
props.onStopEdit();
|
|
48
|
+
};
|
|
49
|
+
return (_jsx(SelectWrapper, { children: _jsx(Select, { initialIsOpen: true, initialValue: selectedItem, items: items, onSelect: onSelect, style: { flex: '1 1 auto' } }) }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsx(ValueWrapper, { "data-cell": [props.rowIdx, props.column.id], onClick: props.onStartEdit, children: selectedItem ? selectedItem.label : '' }));
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export default EditSelectCell;
|
|
55
|
+
//# sourceMappingURL=edit-select-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-select-cell.js","sourceRoot":"","sources":["../../../src/table/cells/edit-select-cell.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAIzC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAC;AAEF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;CAK/B,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,cAAc,CAAiB,KAAe;IACnD,OAAO,SAAS,UAAU,CAAC,KAAuB;QAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC;QAEtE,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;YACjE,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAQ,EAAE;gBAClC,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE;oBAC9C,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;iBAC7D;gBACD,KAAK,CAAC,UAAU,EAAE,CAAC;YACvB,CAAC,CAAC;YAEF,OAAO,CACH,KAAC,aAAa,cACV,KAAC,MAAM,IACH,aAAa,QACb,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAC7B,GACU,CACnB,CAAC;SACL;QAED,OAAO,CACH,KAAC,YAAY,iBAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,WAAW,YAC/E,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAC5B,CAClB,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FilterProps, HeaderGroup, Row } from 'react-table';
|
|
2
|
+
import { FilterResults as DatetimeFilterResults } from '../filter/datetime-filter';
|
|
3
|
+
import { FilterResults as NumericFilterResults } from '../filter/numeric-filter';
|
|
4
|
+
import { Item } from '../types';
|
|
5
|
+
interface HeaderIconWrapperProp {
|
|
6
|
+
hasFilter?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const HeaderIconWrapper: import("styled-components").StyledComponent<"div", import("@darajs/styled-components").DefaultTheme, HeaderIconWrapperProp, never>;
|
|
9
|
+
/**
|
|
10
|
+
* Custom numeric filter function
|
|
11
|
+
*
|
|
12
|
+
* @param rows rows to filter
|
|
13
|
+
* @param columnIds IDs of columns
|
|
14
|
+
* @param filterValue filter value provided
|
|
15
|
+
*/
|
|
16
|
+
export declare function numeric(rows: Array<Row>, columnIds: Array<string>, filterValue: NumericFilterResults): Array<Row>;
|
|
17
|
+
/**
|
|
18
|
+
* Custom datetime filter function
|
|
19
|
+
*
|
|
20
|
+
* @param rows rows to filter
|
|
21
|
+
* @param columnIds IDs of columns
|
|
22
|
+
* @param filterValue filter value
|
|
23
|
+
*/
|
|
24
|
+
export declare function datetime(rows: Array<Row>, columnIds: Array<string>, filterValue: DatetimeFilterResults): Array<Row>;
|
|
25
|
+
/**
|
|
26
|
+
* Custom categorical filter function
|
|
27
|
+
*
|
|
28
|
+
* @param rows rows to filter
|
|
29
|
+
* @param columnIds IDs of columns
|
|
30
|
+
* @param filterItems filter value
|
|
31
|
+
*/
|
|
32
|
+
export declare function categorical(rows: Array<Row>, columnIds: Array<string>, filterItems: Item[]): Array<Row>;
|
|
33
|
+
/**
|
|
34
|
+
* Text Filter component
|
|
35
|
+
*/
|
|
36
|
+
export declare function TextFilter(props: FilterProps<any>): JSX.Element;
|
|
37
|
+
interface ColumnFilterProps extends HeaderGroup {
|
|
38
|
+
/** Optional prop passed to column defining uniqueItems that categorical filter should search for */
|
|
39
|
+
uniqueItems?: Array<string>;
|
|
40
|
+
}
|
|
41
|
+
export interface FilterContainerProps {
|
|
42
|
+
col: ColumnFilterProps;
|
|
43
|
+
}
|
|
44
|
+
export declare function FilterContainer(props: FilterContainerProps): JSX.Element;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/table/filters.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAK5D,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEjF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAOhC,UAAU,qBAAqB;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,iBAAiB,oIAoB7B,CAAC;AAyGF;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oBAAoB,GAAG,KAAK,CAAC,GAAG,CAAC,CAQjH;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,GAAG,KAAK,CAAC,GAAG,CAAC,CAQnH;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAUvG;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAU/D;AAED,UAAU,iBAAkB,SAAQ,WAAW;IAC3C,oGAAoG;IACpG,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,iBAAiB,CAAC;CAC1B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,GAAG,CAAC,OAAO,CA+CxE"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { faFilter } from '@fortawesome/free-solid-svg-icons';
|
|
19
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
20
|
+
import { isAfter, isBefore, isEqual, isWithinInterval, parseISO } from 'date-fns';
|
|
21
|
+
import { transparentize } from 'polished';
|
|
22
|
+
import { useMemo, useRef, useState } from 'react';
|
|
23
|
+
import styled from '@darajs/styled-components';
|
|
24
|
+
import { FilterWrapper, StyledSearchBar } from '../filter/categorical-filter';
|
|
25
|
+
import Tooltip from '../tooltip/tooltip';
|
|
26
|
+
const FilterIcon = styled(FontAwesomeIcon) `
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
color: ${(props) => (props.$hasFilter ? props.theme.colors.primary : props.theme.colors.grey3)};
|
|
29
|
+
`;
|
|
30
|
+
export const HeaderIconWrapper = styled.div `
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
|
|
35
|
+
width: 1.5rem;
|
|
36
|
+
height: 1.5rem;
|
|
37
|
+
|
|
38
|
+
border-radius: 0.25rem;
|
|
39
|
+
|
|
40
|
+
:hover {
|
|
41
|
+
background-color: ${(props) => transparentize(0.9, props.theme.colors.primaryHover)};
|
|
42
|
+
svg {
|
|
43
|
+
color: ${(props) => (props.hasFilter ? props.theme.colors.primary : props.theme.colors.grey3)};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:active {
|
|
48
|
+
background-color: ${(props) => transparentize(0.8, props.theme.colors.primaryDown)};
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
var NumericOperator;
|
|
52
|
+
(function (NumericOperator) {
|
|
53
|
+
NumericOperator["BT"] = "Between";
|
|
54
|
+
NumericOperator["EQ"] = "Equal to";
|
|
55
|
+
NumericOperator["GT"] = "Greater than";
|
|
56
|
+
NumericOperator["LT"] = "Less than";
|
|
57
|
+
NumericOperator["NE"] = "Not equal to";
|
|
58
|
+
})(NumericOperator || (NumericOperator = {}));
|
|
59
|
+
var DateOperator;
|
|
60
|
+
(function (DateOperator) {
|
|
61
|
+
DateOperator["BT"] = "Between";
|
|
62
|
+
DateOperator["EQ"] = "On date";
|
|
63
|
+
DateOperator["GT"] = "After";
|
|
64
|
+
DateOperator["LT"] = "Before";
|
|
65
|
+
})(DateOperator || (DateOperator = {}));
|
|
66
|
+
/**
|
|
67
|
+
* Check whether a given operator is supported
|
|
68
|
+
* @param op potential operator
|
|
69
|
+
*/
|
|
70
|
+
function isValidOperator(op) {
|
|
71
|
+
return Object.keys(NumericOperator)
|
|
72
|
+
.map((key) => NumericOperator[key])
|
|
73
|
+
.includes(op);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check whether a given operator is supported for datetime
|
|
77
|
+
* @param op potential operator
|
|
78
|
+
*/
|
|
79
|
+
function isValidDatetimeOperator(op) {
|
|
80
|
+
return Object.keys(DateOperator)
|
|
81
|
+
.map((key) => DateOperator[key])
|
|
82
|
+
.includes(op);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Apply an operator to a given numeric value.
|
|
86
|
+
*
|
|
87
|
+
* @param operator operator to apply
|
|
88
|
+
* @param value value to compare
|
|
89
|
+
* @param filterValue filter value to compare to
|
|
90
|
+
*/
|
|
91
|
+
function applyNumericOperator(operator, value, filterValue) {
|
|
92
|
+
switch (operator) {
|
|
93
|
+
case NumericOperator.EQ:
|
|
94
|
+
return value === filterValue;
|
|
95
|
+
case NumericOperator.GT:
|
|
96
|
+
if (Array.isArray(filterValue)) {
|
|
97
|
+
throw new Error('Cannot use array for GT operator');
|
|
98
|
+
}
|
|
99
|
+
return value > filterValue;
|
|
100
|
+
case NumericOperator.LT:
|
|
101
|
+
if (Array.isArray(filterValue)) {
|
|
102
|
+
throw new Error('Cannot use array for LT operator');
|
|
103
|
+
}
|
|
104
|
+
return value < filterValue;
|
|
105
|
+
case NumericOperator.NE:
|
|
106
|
+
return value !== filterValue;
|
|
107
|
+
case NumericOperator.BT:
|
|
108
|
+
if (Array.isArray(filterValue)) {
|
|
109
|
+
return value <= filterValue[1] && value >= filterValue[0];
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Apply an operator to a given datetime value.
|
|
118
|
+
*
|
|
119
|
+
* @param operator operator to apply
|
|
120
|
+
* @param value value to compare
|
|
121
|
+
* @param filterValue filter value to compare to
|
|
122
|
+
*/
|
|
123
|
+
function applyDatetimeOperator(operator, value, filterValue) {
|
|
124
|
+
const parsedValue = parseISO(value);
|
|
125
|
+
if (Array.isArray(filterValue)) {
|
|
126
|
+
if (operator === DateOperator.BT) {
|
|
127
|
+
return isWithinInterval(parsedValue, { end: filterValue[1], start: filterValue[0] });
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
switch (operator) {
|
|
132
|
+
case DateOperator.EQ:
|
|
133
|
+
return isEqual(parsedValue, filterValue);
|
|
134
|
+
case DateOperator.GT:
|
|
135
|
+
return isAfter(parsedValue, filterValue);
|
|
136
|
+
case DateOperator.LT:
|
|
137
|
+
return isBefore(parsedValue, filterValue);
|
|
138
|
+
default:
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Custom numeric filter function
|
|
144
|
+
*
|
|
145
|
+
* @param rows rows to filter
|
|
146
|
+
* @param columnIds IDs of columns
|
|
147
|
+
* @param filterValue filter value provided
|
|
148
|
+
*/
|
|
149
|
+
export function numeric(rows, columnIds, filterValue) {
|
|
150
|
+
const { selected, value } = filterValue;
|
|
151
|
+
const [colId] = columnIds;
|
|
152
|
+
// If operator not supported or there's no value to compare to, return all rows
|
|
153
|
+
if (!isValidOperator(selected) || (!value && value !== 0))
|
|
154
|
+
return rows;
|
|
155
|
+
return rows.filter((row) => applyNumericOperator(selected, row.values[colId], value));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Custom datetime filter function
|
|
159
|
+
*
|
|
160
|
+
* @param rows rows to filter
|
|
161
|
+
* @param columnIds IDs of columns
|
|
162
|
+
* @param filterValue filter value
|
|
163
|
+
*/
|
|
164
|
+
export function datetime(rows, columnIds, filterValue) {
|
|
165
|
+
const { selected, value } = filterValue;
|
|
166
|
+
const [colId] = columnIds;
|
|
167
|
+
// If operator not supported or there's no value to compare to, return all rows
|
|
168
|
+
if (!isValidDatetimeOperator(selected) || !value)
|
|
169
|
+
return rows;
|
|
170
|
+
return rows.filter((row) => applyDatetimeOperator(selected, row.values[colId], value));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Custom categorical filter function
|
|
174
|
+
*
|
|
175
|
+
* @param rows rows to filter
|
|
176
|
+
* @param columnIds IDs of columns
|
|
177
|
+
* @param filterItems filter value
|
|
178
|
+
*/
|
|
179
|
+
export function categorical(rows, columnIds, filterItems) {
|
|
180
|
+
const [colId] = columnIds;
|
|
181
|
+
const filteredItems = filterItems.map((item) => item.value);
|
|
182
|
+
// If no categories selected return everything
|
|
183
|
+
if (filteredItems.length === 0) {
|
|
184
|
+
return rows;
|
|
185
|
+
}
|
|
186
|
+
return rows.filter((row) => filteredItems.includes(row.values[colId]));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Text Filter component
|
|
190
|
+
*/
|
|
191
|
+
export function TextFilter(props) {
|
|
192
|
+
return (_jsx(FilterWrapper, { children: _jsx(StyledSearchBar, { onChange: (val) => props.column.setFilter(val || undefined), placeholder: "Rows containing value...", value: props.column.filterValue || '' }) }));
|
|
193
|
+
}
|
|
194
|
+
export function FilterContainer(props) {
|
|
195
|
+
var _a;
|
|
196
|
+
const [visible, setVisible] = useState(false);
|
|
197
|
+
const show = () => setVisible(true);
|
|
198
|
+
const hide = () => setVisible(false);
|
|
199
|
+
const hasFilter = !(props.col.filterValue === undefined ||
|
|
200
|
+
((_a = props.col.filterValue) === null || _a === void 0 ? void 0 : _a.selected) === 'None' ||
|
|
201
|
+
(Array.isArray(props.col.filterValue) && props.col.filterValue.length === 0));
|
|
202
|
+
const items = useMemo(() => {
|
|
203
|
+
var _a;
|
|
204
|
+
if ((_a = props.col) === null || _a === void 0 ? void 0 : _a.uniqueItems) {
|
|
205
|
+
return props.col.uniqueItems.map((item) => ({ label: item, value: item }));
|
|
206
|
+
}
|
|
207
|
+
}, [props.col]);
|
|
208
|
+
// because the select dropdown lives outside of the component we need to pass a ref so that we can check whether the user is clicking within it or outside
|
|
209
|
+
const portalsRef = useRef([]);
|
|
210
|
+
function onClickOutside(instance, event) {
|
|
211
|
+
const target = event.target;
|
|
212
|
+
// loop through refs if they contain the target then user is clicking within a dropdown
|
|
213
|
+
for (const portal of portalsRef.current) {
|
|
214
|
+
if (portal === null || portal === void 0 ? void 0 : portal.contains(target)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// user clicked outside so hide
|
|
219
|
+
hide();
|
|
220
|
+
}
|
|
221
|
+
return (_jsx(Tooltip, { content: props.col.render('Filter', { items, onChange: hide, portalsRef }), hidden: true, interactive: true, onClickOutside: onClickOutside, visible: visible, children: _jsx("span", { children: _jsx(HeaderIconWrapper, { hasFilter: hasFilter, children: _jsx(FilterIcon, { "$hasFilter": hasFilter, icon: faFilter, onClick: show }) }) }) }));
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/table/filters.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAA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G,MAAM,CAAqB,EAAE,CAAC,CAAC;IAElD,SAAS,cAAc,CAAC,QAAa,EAAE,KAAY;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,MAA0B,CAAC;QAEhD,uFAAuF;QACvF,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,OAAO,EAAE;YACrC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC1B,OAAO;aACV;SACJ;QACD,+BAA+B;QAC/B,IAAI,EAAE,CAAC;IACX,CAAC;IAED,OAAO,CACH,KAAC,OAAO,IACJ,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAC1E,MAAM,QACN,WAAW,QACX,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,YAEhB,yBACI,KAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS,YACnC,KAAC,UAAU,kBAAa,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAI,GACpD,GACjB,GACD,CACb,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface selectHeaderProps {
|
|
2
|
+
/** An action handler, will be called for selecting/unselecting all rows */
|
|
3
|
+
onAction: (actionId: string, input?: any) => void | Promise<void>;
|
|
4
|
+
/** The rows of the table, needed to keep track of them being selected or not */
|
|
5
|
+
rows: any;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A table header with a tri-state checkbox, for bulk selection actions
|
|
9
|
+
*
|
|
10
|
+
* @param {selectHeaderProps} props - the component props
|
|
11
|
+
*/
|
|
12
|
+
declare function SelectHeader(props: selectHeaderProps): JSX.Element;
|
|
13
|
+
export default SelectHeader;
|
|
14
|
+
//# sourceMappingURL=select-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-header.d.ts","sourceRoot":"","sources":["../../../src/table/headers/select-header.tsx"],"names":[],"mappings":"AAmBA,UAAU,iBAAiB;IACvB,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,gFAAgF;IAChF,IAAI,EAAE,GAAG,CAAC;CACb;AAED;;;;GAIG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAyB3D;AAED,eAAe,YAAY,CAAC"}
|