@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,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 castArray from 'lodash/castArray';
|
|
19
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
20
|
+
import styled from '@darajs/styled-components';
|
|
21
|
+
import { CheckSquare } from '@darajs/ui-icons';
|
|
22
|
+
const Wrapper = styled.div `
|
|
23
|
+
overflow: auto;
|
|
24
|
+
display: grid;
|
|
25
|
+
grid-template-columns: repeat(${(props) => props.itemsPerRow}, 1fr);
|
|
26
|
+
|
|
27
|
+
max-height: 100%;
|
|
28
|
+
margin: 2rem;
|
|
29
|
+
padding: 1rem;
|
|
30
|
+
|
|
31
|
+
color: ${(props) => props.theme.colors.text};
|
|
32
|
+
|
|
33
|
+
background-color: ${(props) => props.theme.colors.grey1};
|
|
34
|
+
border-radius: 0.25rem;
|
|
35
|
+
`;
|
|
36
|
+
const Card = styled.div `
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
|
|
39
|
+
position: relative;
|
|
40
|
+
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
|
|
46
|
+
margin: 1rem;
|
|
47
|
+
padding: 1rem;
|
|
48
|
+
|
|
49
|
+
text-align: center;
|
|
50
|
+
|
|
51
|
+
background-color: ${(props) => props.theme.colors.blue1};
|
|
52
|
+
border: ${(props) => `2px solid ${props.selected ? props.theme.colors.primary : 'transparent'}`};
|
|
53
|
+
border-radius: 0.25rem;
|
|
54
|
+
|
|
55
|
+
:hover {
|
|
56
|
+
border: ${(props) => `2px solid ${props.selected ? props.theme.colors.primary : props.theme.colors.grey3}`};
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
const CardTitle = styled.h2 `
|
|
60
|
+
margin-top: 1rem;
|
|
61
|
+
`;
|
|
62
|
+
const CardSubtitle = styled.h4 `
|
|
63
|
+
margin-top: 1rem;
|
|
64
|
+
color: ${(props) => props.theme.colors.grey6};
|
|
65
|
+
`;
|
|
66
|
+
const StyledCheckSquare = styled(CheckSquare) `
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
|
|
69
|
+
position: absolute;
|
|
70
|
+
z-index: 3;
|
|
71
|
+
top: 10px;
|
|
72
|
+
right: 10px;
|
|
73
|
+
|
|
74
|
+
color: ${(props) => props.theme.colors.primary};
|
|
75
|
+
`;
|
|
76
|
+
const ComponentWrapper = styled.div `
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
display: flex;
|
|
79
|
+
width: 100%;
|
|
80
|
+
`;
|
|
81
|
+
/**
|
|
82
|
+
* Helper function to get the index of the selected item in the items array
|
|
83
|
+
*
|
|
84
|
+
* @param selectedItems the item that is selected
|
|
85
|
+
* @param item the array of items to find the index in
|
|
86
|
+
*/
|
|
87
|
+
function getSelectedIndex(selectedItems, item) {
|
|
88
|
+
return selectedItems.findIndex((selectedItem) => selectedItem === item.title);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Helper function for updating the selected items once a card is clicked
|
|
92
|
+
*
|
|
93
|
+
* @param prevSelections the previously selected card
|
|
94
|
+
* @param item the currently clicked card
|
|
95
|
+
* @param multiSelect flag for allowing multi selection
|
|
96
|
+
*/
|
|
97
|
+
function updateSelectedItems(prevSelections, item, multiSelect) {
|
|
98
|
+
const selectedIndex = getSelectedIndex(prevSelections, item);
|
|
99
|
+
// Remove from selections if item is already selected
|
|
100
|
+
if (selectedIndex > -1) {
|
|
101
|
+
return prevSelections.filter((_, index) => index !== selectedIndex);
|
|
102
|
+
}
|
|
103
|
+
// Add to selection if multi-select is allowed
|
|
104
|
+
if (multiSelect) {
|
|
105
|
+
return [...prevSelections, item.title];
|
|
106
|
+
}
|
|
107
|
+
return [item.title];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The ComponentSelectList component creates a list of card of selectable cards containing either images or plots.
|
|
111
|
+
* The plot should be passed as a JSX element.
|
|
112
|
+
*
|
|
113
|
+
* @param props the component props
|
|
114
|
+
*/
|
|
115
|
+
function ComponentSelectList(props) {
|
|
116
|
+
const [selectedCards, setSelectedCards] = useState(props.selectedItems ? castArray(props.selectedItems) : []);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
setSelectedCards(props.selectedItems ? castArray(props.selectedItems) : []);
|
|
119
|
+
}, [props.selectedItems]);
|
|
120
|
+
const onClick = useCallback((index) => {
|
|
121
|
+
var _a;
|
|
122
|
+
const updatedSelectedCards = updateSelectedItems(selectedCards, props.items[index], props.multiSelect);
|
|
123
|
+
setSelectedCards(updatedSelectedCards);
|
|
124
|
+
(_a = props.onSelect) === null || _a === void 0 ? void 0 : _a.call(props, updatedSelectedCards);
|
|
125
|
+
}, [props.items, props.multiSelect, selectedCards, setSelectedCards]);
|
|
126
|
+
return (_jsx(Wrapper, { className: props.className, itemsPerRow: props.itemsPerRow && props.itemsPerRow > 0 ? props.itemsPerRow : 3, style: props.style, children: props.items.map((item, index) => (_jsxs(Card, { onClick: () => onClick(index), selected: getSelectedIndex(selectedCards, item) > -1, children: [getSelectedIndex(selectedCards, item) > -1 && _jsx(StyledCheckSquare, { size: "2x" }), _jsx(ComponentWrapper, { children: item.component }), _jsx(CardTitle, { children: item.title }), item.subtitle && _jsx(CardSubtitle, { children: item.subtitle })] }, `${item.title}-${index}`))) }));
|
|
127
|
+
}
|
|
128
|
+
export default ComponentSelectList;
|
|
129
|
+
//# sourceMappingURL=component-select-list.js.map
|
|
@@ -0,0 +1 @@
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AAoB,EACrD,KAAC,SAAS,cAAE,IAAI,CAAC,KAAK,GAAa,EAClC,IAAI,CAAC,QAAQ,IAAI,KAAC,YAAY,cAAE,IAAI,CAAC,QAAQ,GAAgB,KAPzD,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,EAAE,CAQ1B,CACV,CAAC,GACI,CACb,CAAC;AACN,CAAC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
export declare enum Key {
|
|
18
|
+
BACKSPACE = "Backspace",
|
|
19
|
+
CTRL = "Control",
|
|
20
|
+
DOWN = "ArrowDown",
|
|
21
|
+
ENTER = "Enter",
|
|
22
|
+
ESCAPE = "Escape",
|
|
23
|
+
LEFT = "ArrowLeft",
|
|
24
|
+
META = "Meta",
|
|
25
|
+
MINUS = "-",
|
|
26
|
+
PERIOD = ".",
|
|
27
|
+
RIGHT = "ArrowRight",
|
|
28
|
+
SHIFT = "Shift",
|
|
29
|
+
TAB = "Tab",
|
|
30
|
+
UP = "ArrowUp"
|
|
31
|
+
}
|
|
32
|
+
export declare const CONTROL_KEYS: string[];
|
|
33
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,oBAAY,GAAG;IACX,SAAS,cAAc;IACvB,IAAI,YAAY;IAChB,IAAI,cAAc;IAClB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,IAAI,cAAc;IAClB,IAAI,SAAS;IACb,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,KAAK,eAAe;IACpB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,EAAE,YAAY;CACjB;AAGD,eAAO,MAAM,YAAY,EAAE,MAAM,EAYhC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
export var Key;
|
|
18
|
+
(function (Key) {
|
|
19
|
+
Key["BACKSPACE"] = "Backspace";
|
|
20
|
+
Key["CTRL"] = "Control";
|
|
21
|
+
Key["DOWN"] = "ArrowDown";
|
|
22
|
+
Key["ENTER"] = "Enter";
|
|
23
|
+
Key["ESCAPE"] = "Escape";
|
|
24
|
+
Key["LEFT"] = "ArrowLeft";
|
|
25
|
+
Key["META"] = "Meta";
|
|
26
|
+
Key["MINUS"] = "-";
|
|
27
|
+
Key["PERIOD"] = ".";
|
|
28
|
+
Key["RIGHT"] = "ArrowRight";
|
|
29
|
+
Key["SHIFT"] = "Shift";
|
|
30
|
+
Key["TAB"] = "Tab";
|
|
31
|
+
Key["UP"] = "ArrowUp";
|
|
32
|
+
})(Key || (Key = {}));
|
|
33
|
+
// A list of keys for the common controls / modifiers
|
|
34
|
+
export const CONTROL_KEYS = [
|
|
35
|
+
Key.ESCAPE,
|
|
36
|
+
Key.TAB,
|
|
37
|
+
Key.ENTER,
|
|
38
|
+
Key.BACKSPACE,
|
|
39
|
+
Key.CTRL,
|
|
40
|
+
Key.SHIFT,
|
|
41
|
+
Key.UP,
|
|
42
|
+
Key.DOWN,
|
|
43
|
+
Key.LEFT,
|
|
44
|
+
Key.RIGHT,
|
|
45
|
+
Key.META,
|
|
46
|
+
];
|
|
47
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAN,IAAY,GAcX;AAdD,WAAY,GAAG;IACX,8BAAuB,CAAA;IACvB,uBAAgB,CAAA;IAChB,yBAAkB,CAAA;IAClB,sBAAe,CAAA;IACf,wBAAiB,CAAA;IACjB,yBAAkB,CAAA;IAClB,oBAAa,CAAA;IACb,kBAAW,CAAA;IACX,mBAAY,CAAA;IACZ,2BAAoB,CAAA;IACpB,sBAAe,CAAA;IACf,kBAAW,CAAA;IACX,qBAAc,CAAA;AAClB,CAAC,EAdW,GAAG,KAAH,GAAG,QAcd;AAED,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAa;IAClC,GAAG,CAAC,MAAM;IACV,GAAG,CAAC,GAAG;IACP,GAAG,CAAC,KAAK;IACT,GAAG,CAAC,SAAS;IACb,GAAG,CAAC,IAAI;IACR,GAAG,CAAC,KAAK;IACT,GAAG,CAAC,EAAE;IACN,GAAG,CAAC,IAAI;IACR,GAAG,CAAC,IAAI;IACR,GAAG,CAAC,KAAK;IACT,GAAG,CAAC,IAAI;CACX,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface MenuAction {
|
|
3
|
+
action: () => void;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ContextMenuProps<T> {
|
|
7
|
+
/** An array of actions to show in the context menu */
|
|
8
|
+
actions: Array<MenuAction>;
|
|
9
|
+
/** Pass through children onto the root element */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** Pass through className onto the root element */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Any element props for the root element */
|
|
14
|
+
elementProps?: T;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The ContextMenu is a higher order component that wraps another react component and overrides its context menu to be a
|
|
18
|
+
* custom list of actions, defined by the actions prop.
|
|
19
|
+
*
|
|
20
|
+
* @param Component the component to wrap and draw as the root
|
|
21
|
+
*/
|
|
22
|
+
declare function ContextMenu<T>(Component: React.ComponentType<T> | string): (props: ContextMenuProps<T>) => JSX.Element;
|
|
23
|
+
export default ContextMenu;
|
|
24
|
+
//# sourceMappingURL=context-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../src/context-menu/context-menu.tsx"],"names":[],"mappings":";AAyBA,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACjB;AAOD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAC/B,sDAAsD;IACtD,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3B,kDAAkD;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,YAAY,CAAC,EAAE,CAAC,CAAC;CACpB;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAuH/G;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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 { useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import ReactDOM from 'react-dom';
|
|
20
|
+
import { usePopper } from 'react-popper';
|
|
21
|
+
import styled from '@darajs/styled-components';
|
|
22
|
+
import { Key } from '../constants';
|
|
23
|
+
import { List, ListItem } from '../utils';
|
|
24
|
+
const DropdownList = styled(List) `
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
box-shadow: ${(props) => props.theme.shadow.light};
|
|
27
|
+
`;
|
|
28
|
+
/**
|
|
29
|
+
* The ContextMenu is a higher order component that wraps another react component and overrides its context menu to be a
|
|
30
|
+
* custom list of actions, defined by the actions prop.
|
|
31
|
+
*
|
|
32
|
+
* @param Component the component to wrap and draw as the root
|
|
33
|
+
*/
|
|
34
|
+
function ContextMenu(Component) {
|
|
35
|
+
function WrappedContextMenu(props) {
|
|
36
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
37
|
+
const [showMenu, setShowMenu] = useState(false);
|
|
38
|
+
const [hoveredItem, setHoveredItem] = useState(-1);
|
|
39
|
+
// This ref is updated with the current mouse position each time the context menu is open, but as it's the same
|
|
40
|
+
// element, popper doesn't need to recreate everything.
|
|
41
|
+
const boundingRectRef = useRef({
|
|
42
|
+
bottom: 0,
|
|
43
|
+
height: 0,
|
|
44
|
+
left: 0,
|
|
45
|
+
right: 0,
|
|
46
|
+
top: 0,
|
|
47
|
+
width: 0,
|
|
48
|
+
});
|
|
49
|
+
const fakeElement = useMemo(() => ({
|
|
50
|
+
contextElement: document.body,
|
|
51
|
+
getBoundingClientRect: () => boundingRectRef.current,
|
|
52
|
+
}), []);
|
|
53
|
+
// Handle clicking outside the menu or hitting escape and make sure the menu closes.
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const keyHandler = (e) => {
|
|
56
|
+
if (e.key === Key.ESCAPE) {
|
|
57
|
+
setShowMenu(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const mouseHandler = () => {
|
|
61
|
+
setShowMenu(false);
|
|
62
|
+
};
|
|
63
|
+
if (showMenu) {
|
|
64
|
+
document.addEventListener('keydown', keyHandler);
|
|
65
|
+
document.addEventListener('click', mouseHandler);
|
|
66
|
+
document.addEventListener('contextmenu', mouseHandler);
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
document.removeEventListener('keydown', keyHandler);
|
|
70
|
+
document.removeEventListener('click', mouseHandler);
|
|
71
|
+
document.removeEventListener('contextmenu', mouseHandler);
|
|
72
|
+
};
|
|
73
|
+
}, [showMenu]);
|
|
74
|
+
// Set a timer on opening the dropdown before it can be closed, prevents first menu item being selected
|
|
75
|
+
// immediately, but lets user select action with the mouse up if they want to.
|
|
76
|
+
const [canClose, setCanClose] = useState(true);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (showMenu) {
|
|
79
|
+
setCanClose(false);
|
|
80
|
+
const timeout = setTimeout(() => {
|
|
81
|
+
setCanClose(true);
|
|
82
|
+
}, 300);
|
|
83
|
+
return () => {
|
|
84
|
+
setCanClose(true);
|
|
85
|
+
clearTimeout(timeout);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}, [showMenu]);
|
|
89
|
+
const { styles, attributes, update } = usePopper(fakeElement, popperElement, {
|
|
90
|
+
placement: 'bottom-start',
|
|
91
|
+
});
|
|
92
|
+
const onContextMenu = (e) => {
|
|
93
|
+
// dispatch event of a right click to close other context menu in the page
|
|
94
|
+
document.dispatchEvent(new Event('contextmenu'));
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
boundingRectRef.current = Object.assign(Object.assign({}, boundingRectRef.current), { left: e.clientX, top: e.clientY });
|
|
98
|
+
update();
|
|
99
|
+
setShowMenu(true);
|
|
100
|
+
};
|
|
101
|
+
const onAction = (action) => {
|
|
102
|
+
if (canClose) {
|
|
103
|
+
setShowMenu(false);
|
|
104
|
+
action.action();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return (_jsxs(_Fragment, { children: [_jsx(Component, Object.assign({}, props.elementProps, { className: props.className, onContextMenu: onContextMenu, children: props.children })), ReactDOM.createPortal(_jsx(DropdownList, Object.assign({}, attributes.popper, { isOpen: showMenu, ref: setPopperElement, style: Object.assign(Object.assign({}, styles.popper), { minWidth: 150, zIndex: 9999 }), children: props.actions.map((action, index) => (_jsx(ListItem, { hovered: hoveredItem === index, onMouseEnter: () => setHoveredItem(index), onMouseLeave: () => setHoveredItem(-1), onMouseUp: () => onAction(action), title: action.label, children: action.label }, `item-${index}`))) })), document.body)] }));
|
|
108
|
+
}
|
|
109
|
+
return WrappedContextMenu;
|
|
110
|
+
}
|
|
111
|
+
export default ContextMenu;
|
|
112
|
+
//# sourceMappingURL=context-menu.js.map
|
|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AM,KAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,eAErD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAClC,KAAC,QAAQ,IACL,OAAO,EAAE,WAAW,KAAK,KAAK,EAE9B,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EACzC,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACtC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,MAAM,CAAC,KAAK,YAElB,MAAM,CAAC,KAAK,IANR,QAAQ,KAAK,EAAE,CAOb,CACd,CAAC,IACS,EACf,QAAQ,CAAC,IAAI,CAChB,IACF,CACN,CAAC;IACN,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { Placement } from '@popperjs/core';
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { InteractiveComponentProps, Item } from '../types';
|
|
20
|
+
export interface SelectProps extends InteractiveComponentProps<Item> {
|
|
21
|
+
/** The left displacement from dropdown the items should show */
|
|
22
|
+
displacement?: number;
|
|
23
|
+
/** A function taking an element for the ref of the dropdown */
|
|
24
|
+
dropdownRef?: (element: any) => void;
|
|
25
|
+
/** className property to put on the select's items and the item wrapper */
|
|
26
|
+
itemClass?: string;
|
|
27
|
+
/** The items to pick from the list. Each should have a label and a value */
|
|
28
|
+
items: Array<Item>;
|
|
29
|
+
/** The maximum number of items to display, defaults to 5 */
|
|
30
|
+
maxItems?: number;
|
|
31
|
+
/** onClick event. */
|
|
32
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void | Promise<void>;
|
|
33
|
+
/** An optional onSelect handler for listening to changes in the selected item */
|
|
34
|
+
onSelect?: (item: Item) => void | Promise<void>;
|
|
35
|
+
/** Specify a specific placement for the list */
|
|
36
|
+
placement?: Placement;
|
|
37
|
+
/** Set the selected value to a specific value, will put the component in controlled mode */
|
|
38
|
+
selectedItem?: Item;
|
|
39
|
+
/** Font size in rem to show in the Select */
|
|
40
|
+
size?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A single select dropdown component that has no search capability, accepts a list of items to select from and an
|
|
44
|
+
* onSelect handler to listen for changes in the selection
|
|
45
|
+
*
|
|
46
|
+
* @param {SelectProps} props - the props of the component
|
|
47
|
+
*/
|
|
48
|
+
declare function DatepickerSelect(props: SelectProps): JSX.Element;
|
|
49
|
+
export default DatepickerSelect;
|
|
50
|
+
//# sourceMappingURL=datepicker-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datepicker-select.d.ts","sourceRoot":"","sources":["../../src/datepicker/datepicker-select.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,yBAAyB,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAgK3D,MAAM,WAAW,WAAY,SAAQ,yBAAyB,CAAC,IAAI,CAAC;IAChE,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,gDAAgD;IAChD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,4FAA4F;IAC5F,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,iBAAS,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAmIzD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { createElement as _createElement } from "react";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useSelect } from 'downshift';
|
|
15
|
+
import { useEffect, useRef, useState } from 'react';
|
|
16
|
+
import ReactDOM from 'react-dom';
|
|
17
|
+
import { usePopper } from 'react-popper';
|
|
18
|
+
import styled from '@darajs/styled-components';
|
|
19
|
+
import Tooltip from '../tooltip/tooltip';
|
|
20
|
+
import { Chevron, sameWidthModifier } from '../utils';
|
|
21
|
+
const { stateChangeTypes } = useSelect;
|
|
22
|
+
const SelectedItem = styled.div `
|
|
23
|
+
width: 100%;
|
|
24
|
+
font-size: ${(props) => (props.size ? `${props.size}rem` : props.theme.font.size)};
|
|
25
|
+
font-weight: 300;
|
|
26
|
+
`;
|
|
27
|
+
const Wrapper = styled.div `
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
width: 6.25rem;
|
|
30
|
+
height: 1.5rem;
|
|
31
|
+
border-radius: 0.25rem;
|
|
32
|
+
|
|
33
|
+
${(props) => {
|
|
34
|
+
if (props.isDisabled) {
|
|
35
|
+
return `
|
|
36
|
+
border: 1px solid ${props.theme.colors.grey1};
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
if (props.isErrored) {
|
|
41
|
+
return `border: 1px solid ${props.theme.colors.error};`;
|
|
42
|
+
}
|
|
43
|
+
return `
|
|
44
|
+
border: 1px solid ${props.theme.colors.grey1};
|
|
45
|
+
`;
|
|
46
|
+
}}
|
|
47
|
+
`;
|
|
48
|
+
const SelectButton = styled.button `
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
flex: 1 1 auto;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: space-between;
|
|
55
|
+
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
padding: 0 0.5rem 0rem 1rem;
|
|
59
|
+
|
|
60
|
+
font-size: ${(props) => props.theme.font.size};
|
|
61
|
+
|
|
62
|
+
border: none;
|
|
63
|
+
outline: 0;
|
|
64
|
+
|
|
65
|
+
:not(:enabled) {
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
const SelectButtonPrimary = styled(SelectButton) `
|
|
70
|
+
justify-content: start;
|
|
71
|
+
|
|
72
|
+
width: 100%;
|
|
73
|
+
padding: 0rem 0.25rem;
|
|
74
|
+
|
|
75
|
+
font-size: 0.875rem;
|
|
76
|
+
color: ${(props) => props.theme.colors.text};
|
|
77
|
+
|
|
78
|
+
background-color: ${(props) => props.theme.colors.grey1};
|
|
79
|
+
border-radius: 0.25rem;
|
|
80
|
+
|
|
81
|
+
:disabled {
|
|
82
|
+
color: ${(props) => props.theme.colors.grey2};
|
|
83
|
+
|
|
84
|
+
svg {
|
|
85
|
+
color: ${(props) => props.theme.colors.grey2};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:hover:enabled {
|
|
90
|
+
background-color: ${(props) => props.theme.colors.grey2};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
svg {
|
|
94
|
+
width: 1rem !important;
|
|
95
|
+
height: 0.8rem;
|
|
96
|
+
margin-left: 0.5rem !important;
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
const DatepickerListItem = styled.span `
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
user-select: none;
|
|
102
|
+
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
|
|
107
|
+
width: 100%;
|
|
108
|
+
min-height: 2rem;
|
|
109
|
+
padding: 0.25rem 1.5rem;
|
|
110
|
+
|
|
111
|
+
font-size: ${(props) => (props.size ? `${props.size}rem` : props.theme.font.size)};
|
|
112
|
+
font-weight: 300;
|
|
113
|
+
color: ${(props) => (props.isSelected ? '#FFF' : props.theme.colors.text)};
|
|
114
|
+
text-overflow: ellipsis;
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
|
|
117
|
+
background-color: ${(props) => {
|
|
118
|
+
if (props.isSelected) {
|
|
119
|
+
return props.theme.colors.primary;
|
|
120
|
+
}
|
|
121
|
+
if (props.hovered) {
|
|
122
|
+
return props.theme.colors.grey2;
|
|
123
|
+
}
|
|
124
|
+
return props.theme.colors.grey1;
|
|
125
|
+
}};
|
|
126
|
+
|
|
127
|
+
:active {
|
|
128
|
+
background-color: ${(props) => props.theme.colors.grey1};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&:last-child {
|
|
132
|
+
border-bottom: none;
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
const DropdownList = styled.div `
|
|
136
|
+
overflow-y: auto;
|
|
137
|
+
display: ${(props) => (props.isOpen ? 'flex' : 'none')};
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
gap: 0.125rem;
|
|
140
|
+
|
|
141
|
+
max-height: calc(${(props) => (props.maxItems || 5) * 2}em + 2px);
|
|
142
|
+
margin-left: ${(props) => props.displacement}rem;
|
|
143
|
+
|
|
144
|
+
background-color: ${(props) => props.theme.colors.grey1};
|
|
145
|
+
border: None;
|
|
146
|
+
outline: 0;
|
|
147
|
+
`;
|
|
148
|
+
/**
|
|
149
|
+
* A single select dropdown component that has no search capability, accepts a list of items to select from and an
|
|
150
|
+
* onSelect handler to listen for changes in the selection
|
|
151
|
+
*
|
|
152
|
+
* @param {SelectProps} props - the props of the component
|
|
153
|
+
*/
|
|
154
|
+
function DatepickerSelect(props) {
|
|
155
|
+
var _a, _b, _c;
|
|
156
|
+
const referenceElement = useRef(null);
|
|
157
|
+
const popperElement = useRef(null);
|
|
158
|
+
const { styles, attributes, update } = usePopper(referenceElement.current, popperElement.current, {
|
|
159
|
+
modifiers: [sameWidthModifier],
|
|
160
|
+
placement: props.placement || 'bottom-start',
|
|
161
|
+
});
|
|
162
|
+
const [pendingHighlight, setPendingHighlight] = useState(null);
|
|
163
|
+
const { isOpen, selectedItem, getToggleButtonProps, getMenuProps, highlightedIndex, getItemProps, setHighlightedIndex, } = useSelect(Object.assign({ initialSelectedItem: props.initialValue, itemToString: (item) => item.label, items: props.items, onSelectedItemChange: (changes) => {
|
|
164
|
+
const selected = changes.selectedItem;
|
|
165
|
+
if (props.onSelect) {
|
|
166
|
+
props.onSelect(selected);
|
|
167
|
+
}
|
|
168
|
+
}, stateReducer: (state, { changes, type }) => {
|
|
169
|
+
// hack to force highlight to update again in the next render
|
|
170
|
+
if (type === stateChangeTypes.ToggleButtonClick) {
|
|
171
|
+
setPendingHighlight(changes.selectedItem ? props.items.findIndex((i) => i.value === changes.selectedItem.value) : 0);
|
|
172
|
+
}
|
|
173
|
+
return changes;
|
|
174
|
+
} }, (props.selectedItem && { selectedItem: props.selectedItem })));
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (isOpen && pendingHighlight !== null) {
|
|
177
|
+
setHighlightedIndex(pendingHighlight);
|
|
178
|
+
setPendingHighlight(null);
|
|
179
|
+
}
|
|
180
|
+
}, [isOpen, pendingHighlight, setHighlightedIndex]);
|
|
181
|
+
// After the dropdown is opened, trigger an update of it's position, so it positions correctly.
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (isOpen && update) {
|
|
184
|
+
update();
|
|
185
|
+
}
|
|
186
|
+
}, [isOpen, update]);
|
|
187
|
+
// Both downshift and popper want a ref to the reference element and popper element, the following blocks combine
|
|
188
|
+
// these refs into a single function that can be applied to the elements
|
|
189
|
+
const buttonProps = getToggleButtonProps({ disabled: props.disabled });
|
|
190
|
+
const setButtonRef = buttonProps.ref;
|
|
191
|
+
delete buttonProps.ref;
|
|
192
|
+
const setButtonReference = (value) => {
|
|
193
|
+
setButtonRef(value);
|
|
194
|
+
referenceElement.current = value;
|
|
195
|
+
};
|
|
196
|
+
const menuProps = getMenuProps();
|
|
197
|
+
const setMenuRef = menuProps.ref;
|
|
198
|
+
delete menuProps.ref;
|
|
199
|
+
const setMenuReference = (value) => {
|
|
200
|
+
var _a;
|
|
201
|
+
setMenuRef(value);
|
|
202
|
+
popperElement.current = value;
|
|
203
|
+
(_a = props.dropdownRef) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
204
|
+
};
|
|
205
|
+
return (_jsx(Tooltip, { content: props.errorMsg, disabled: !props.errorMsg, styling: "error", children: _jsxs(Wrapper, { className: props.className, isDisabled: props.disabled, isErrored: !!props.errorMsg, onClick: props.onClick, style: props.style, children: [_jsxs(SelectButtonPrimary, Object.assign({ disabled: props.disabled }, buttonProps, { ref: setButtonReference, type: "button", children: [_jsx(SelectedItem, { size: props.size, children: selectedItem ? selectedItem.label : 'Select' }), _jsx(Chevron, { disabled: props.disabled, isOpen: isOpen })] })), ReactDOM.createPortal(_jsx(DropdownList, Object.assign({}, menuProps, attributes.popper, { className: `${(_a = menuProps === null || menuProps === void 0 ? void 0 : menuProps.className) !== null && _a !== void 0 ? _a : ''} ${(_c = (_b = attributes === null || attributes === void 0 ? void 0 : attributes.popper) === null || _b === void 0 ? void 0 : _b.className) !== null && _c !== void 0 ? _c : ''} ${props.itemClass}`, displacement: props.displacement, isOpen: isOpen, maxItems: 7, ref: setMenuReference, style: Object.assign(Object.assign({}, styles.popper), { marginTop: `0.8rem`, width: '16.25rem', zIndex: 9999 }), children: props.items.map((item, index) => {
|
|
206
|
+
const _a = getItemProps({ index, item }), { itemClassName } = _a, itemProps = __rest(_a, ["itemClassName"]);
|
|
207
|
+
return (_createElement(DatepickerListItem, Object.assign({}, itemProps, { "aria-selected": selectedItem.label === item.label, className: `${itemClassName} ${props.itemClass}`, hovered: index === highlightedIndex, isSelected: selectedItem.label === item.label, key: `item-${index}`, size: props.size, title: item.label }), item.label));
|
|
208
|
+
}) })), document.body)] }) }));
|
|
209
|
+
}
|
|
210
|
+
export default DatepickerSelect;
|
|
211
|
+
//# sourceMappingURL=datepicker-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datepicker-select.js","sourceRoot":"","sources":["../../src/datepicker/datepicker-select.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,EAAE,gBAAgB,EAAE,GAAG,SAAS,CAAC;AAMvC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAmB;;iBAEjC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;CAEpF,CAAC;AAOF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAc;;;;;;MAMlC,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,KAAK,CAAC,UAAU,EAAE;QAClB,OAAO;oCACiB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;;aAE/C,CAAC;KACL;IAED,IAAI,KAAK,CAAC,SAAS,EAAE;QACjB,OAAO,qBAAqB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;KAC3D;IAED,OAAO;gCACiB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;SAC/C,CAAC;AACN,CAAC;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