@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,24 @@
|
|
|
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 styled from '@darajs/styled-components';
|
|
18
|
+
const SubtleLabel = styled.label `
|
|
19
|
+
margin-bottom: 0px;
|
|
20
|
+
font-size: 11px;
|
|
21
|
+
color: ${(props) => props.theme.colors.grey6};
|
|
22
|
+
`;
|
|
23
|
+
export default SubtleLabel;
|
|
24
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/utils/label.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;;;aAGnB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;CAC/C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface ListProps {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
maxItems?: number;
|
|
4
|
+
}
|
|
5
|
+
declare const List: import("styled-components").StyledComponent<"div", import("@darajs/styled-components").DefaultTheme, ListProps, never>;
|
|
6
|
+
interface ListItemProps {
|
|
7
|
+
hovered?: boolean;
|
|
8
|
+
size?: number;
|
|
9
|
+
}
|
|
10
|
+
declare const ListItem: import("styled-components").StyledComponent<"span", import("@darajs/styled-components").DefaultTheme, ListItemProps, never>;
|
|
11
|
+
export { List, ListItem };
|
|
12
|
+
//# sourceMappingURL=list-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-styles.d.ts","sourceRoot":"","sources":["../../src/utils/list-styles.tsx"],"names":[],"mappings":"AAkBA,UAAU,SAAS;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,QAAA,MAAM,IAAI,wHAUT,CAAC;AAEF,UAAU,aAAa;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,QAAQ,6HA2Bb,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 styled from '@darajs/styled-components';
|
|
18
|
+
const List = styled.div `
|
|
19
|
+
z-index: 5000;
|
|
20
|
+
|
|
21
|
+
overflow-y: auto;
|
|
22
|
+
display: ${(props) => (props.isOpen ? 'flex' : 'none')};
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
|
|
25
|
+
max-height: calc(${(props) => (props.maxItems || 5) * 2}em + 2px);
|
|
26
|
+
|
|
27
|
+
border: 1px solid ${(props) => props.theme.colors.grey3};
|
|
28
|
+
`;
|
|
29
|
+
const ListItem = styled.span `
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
user-select: none;
|
|
32
|
+
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
|
|
35
|
+
width: 100%;
|
|
36
|
+
min-height: 2rem;
|
|
37
|
+
padding: 0.25rem 1rem;
|
|
38
|
+
|
|
39
|
+
font-size: ${(props) => (props.size ? `${props.size}rem` : '1rem')};
|
|
40
|
+
font-weight: 300;
|
|
41
|
+
color: ${(props) => props.theme.colors.text};
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
|
|
45
|
+
background-color: ${(props) => (props.hovered ? props.theme.colors.grey2 : props.theme.colors.blue1)};
|
|
46
|
+
border-bottom: 1px solid ${(props) => props.theme.colors.grey3};
|
|
47
|
+
|
|
48
|
+
:active {
|
|
49
|
+
color: ${(props) => props.theme.colors.blue1};
|
|
50
|
+
background-color: ${(props) => props.theme.colors.primary};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:last-child {
|
|
54
|
+
border-bottom: none;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
export { List, ListItem };
|
|
58
|
+
//# sourceMappingURL=list-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-styles.js","sourceRoot":"","sources":["../../src/utils/list-styles.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAO/C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAW;;;;eAInB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;;;uBAGnC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC;;wBAEnC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;CAC1D,CAAC;AAOF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAe;;;;;;;;;;iBAU1B,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;;aAEzD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI;;;;wBAIvB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;+BACzE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;;;iBAGjD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;4BACxB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;;;;;;CAMhE,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { Modifier, Options } from '@popperjs/core';
|
|
18
|
+
/**
|
|
19
|
+
* A modifier for popper js that auto sizes the content of the popper to be the same as the reference element.
|
|
20
|
+
*/
|
|
21
|
+
declare const sameWidthModifier: Modifier<string, Options>;
|
|
22
|
+
export default sameWidthModifier;
|
|
23
|
+
//# sourceMappingURL=same-width-modifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"same-width-modifier.d.ts","sourceRoot":"","sources":["../../src/utils/same-width-modifier.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAqB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;GAEG;AACH,QAAA,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAahD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A modifier for popper js that auto sizes the content of the popper to be the same as the reference element.
|
|
3
|
+
*/
|
|
4
|
+
const sameWidthModifier = {
|
|
5
|
+
effect: ({ state }) => () => {
|
|
6
|
+
state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`;
|
|
7
|
+
},
|
|
8
|
+
enabled: true,
|
|
9
|
+
fn: ({ state }) => {
|
|
10
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
11
|
+
},
|
|
12
|
+
name: 'sameWidth',
|
|
13
|
+
phase: 'beforeWrite',
|
|
14
|
+
requires: ['computeStyles'],
|
|
15
|
+
};
|
|
16
|
+
export default sameWidthModifier;
|
|
17
|
+
//# sourceMappingURL=same-width-modifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"same-width-modifier.js","sourceRoot":"","sources":["../../src/utils/same-width-modifier.tsx"],"names":[],"mappings":"AAkBA;;GAEG;AACH,MAAM,iBAAiB,GAA8B;IACjD,MAAM,EACF,CAAC,EAAE,KAAK,EAAO,EAAE,EAAE,CACnB,GAAG,EAAE;QACD,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAqB,IAAI,CAAC;IAC9F,CAAC;IACL,OAAO,EAAE,IAAI;IACb,EAAE,EAAE,CAAC,EAAE,KAAK,EAA8B,EAAE,EAAE;QAC1C,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACnE,CAAC;IACD,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,eAAe,CAAC;CAC9B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface LoadReturn<T> {
|
|
2
|
+
data: Array<T>;
|
|
3
|
+
totalCount: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ItemsRenderedPayload {
|
|
6
|
+
overscanStartIndex: number;
|
|
7
|
+
overscanStopIndex: number;
|
|
8
|
+
}
|
|
9
|
+
export interface InfiniteLoader<T> {
|
|
10
|
+
/** A function to get the actual value of an item, based on it's absolute index in the list */
|
|
11
|
+
getItem: (index: number) => T;
|
|
12
|
+
/** The total count of items in the list */
|
|
13
|
+
itemCount: number;
|
|
14
|
+
/** A handler for the onItemsRendered function exposed by the react-window components */
|
|
15
|
+
onItemsRendered: (payload: ItemsRenderedPayload) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* A function to force a refresh of the data, will trigger a refetch of the current window and discard anything
|
|
18
|
+
* outside that window
|
|
19
|
+
*/
|
|
20
|
+
refresh: () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This is a helper hook that plugs into the react-window components and allows them to load data infinitely by simply
|
|
24
|
+
* passing a load data function to the constructor and passing the returned props into the virtualized list components.
|
|
25
|
+
* The key difference between this and the infinite loader library is that this hook allows for polling, simply by
|
|
26
|
+
* calling the refresh function that it exposes in a useEffect hook.
|
|
27
|
+
*
|
|
28
|
+
* @param onLoadData a function that should load the data between startIndex and stopIndex
|
|
29
|
+
*/
|
|
30
|
+
declare function useInfiniteLoader<T>(onLoadData: (startIndex: number, stopIndex: number) => Promise<LoadReturn<T>>, onError?: (err: Error) => void | Promise<void>, batchSize?: number): InfiniteLoader<T>;
|
|
31
|
+
export default useInfiniteLoader;
|
|
32
|
+
//# sourceMappingURL=use-infinite-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-infinite-loader.d.ts","sourceRoot":"","sources":["../../src/utils/use-infinite-loader.tsx"],"names":[],"mappings":"AAoBA,UAAU,UAAU,CAAC,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B,8FAA8F;IAC9F,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,eAAe,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE;;;OAGG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CAAC,CAAC,EACxB,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC7E,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC9C,SAAS,SAAK,GACf,cAAc,CAAC,CAAC,CAAC,CAyFnB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
* you may not use this file except in compliance with the License.
|
|
16
|
+
* You may obtain a copy of the License at
|
|
17
|
+
*
|
|
18
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
+
* See the License for the specific language governing permissions and
|
|
24
|
+
* limitations under the License.
|
|
25
|
+
*/
|
|
26
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
27
|
+
import { useDeepCompare } from '@darajs/ui-utils';
|
|
28
|
+
/**
|
|
29
|
+
* This is a helper hook that plugs into the react-window components and allows them to load data infinitely by simply
|
|
30
|
+
* passing a load data function to the constructor and passing the returned props into the virtualized list components.
|
|
31
|
+
* The key difference between this and the infinite loader library is that this hook allows for polling, simply by
|
|
32
|
+
* calling the refresh function that it exposes in a useEffect hook.
|
|
33
|
+
*
|
|
34
|
+
* @param onLoadData a function that should load the data between startIndex and stopIndex
|
|
35
|
+
*/
|
|
36
|
+
function useInfiniteLoader(onLoadData, onError, batchSize = 50) {
|
|
37
|
+
// Use a ref on the onLoadData function to get the updated version into the onItemsRendered function as only the
|
|
38
|
+
// first instance passed is ever called by react-window
|
|
39
|
+
const onLoadRef = useRef(onLoadData);
|
|
40
|
+
const [internalData, setInternalData] = useState([]);
|
|
41
|
+
const [itemCount, setItemCount] = useState(0);
|
|
42
|
+
const [currentStartIdx, setStartIdx] = useState(0);
|
|
43
|
+
const [currentStopIdx, setStopIdx] = useState(0);
|
|
44
|
+
const [currentRange, setCurrentRange] = useState({
|
|
45
|
+
overscanStartIndex: 0,
|
|
46
|
+
overscanStopIndex: 50,
|
|
47
|
+
});
|
|
48
|
+
const getItem = useCallback((index) => {
|
|
49
|
+
const adjustedIndex = index - currentStartIdx;
|
|
50
|
+
if (adjustedIndex < 0 || adjustedIndex > internalData.length) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
return internalData[adjustedIndex];
|
|
54
|
+
}, useDeepCompare([currentStartIdx, internalData]));
|
|
55
|
+
const onItemsRendered = useCallback(({ overscanStartIndex, overscanStopIndex }, forceRefresh) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
try {
|
|
57
|
+
const isFirstItemLoaded = overscanStartIndex >= currentStartIdx && overscanStartIndex <= currentStopIdx;
|
|
58
|
+
const isLastItemLoaded = overscanStopIndex >= currentStartIdx && overscanStopIndex <= currentStopIdx;
|
|
59
|
+
setCurrentRange({ overscanStartIndex, overscanStopIndex });
|
|
60
|
+
// Nothing to do if everything is loaded and it's not a forced refresh
|
|
61
|
+
if (isFirstItemLoaded && isLastItemLoaded && !forceRefresh) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// If both are loaded then forceRefresh is true or both are not loaded and we're starting from nothing. In
|
|
65
|
+
// either case we need to calculate the window to fetch from the backend.
|
|
66
|
+
if (isFirstItemLoaded === isLastItemLoaded) {
|
|
67
|
+
const mid = Math.floor((overscanStopIndex - overscanStartIndex) / 2 + overscanStartIndex);
|
|
68
|
+
const start = Math.max(mid - batchSize / 2, 0);
|
|
69
|
+
const end = mid + batchSize / 2;
|
|
70
|
+
setStartIdx(start);
|
|
71
|
+
setStopIdx(end);
|
|
72
|
+
const { data, totalCount } = yield onLoadRef.current(start, end);
|
|
73
|
+
setInternalData(data);
|
|
74
|
+
setItemCount(totalCount);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// This branch covers scrolling up from the bottom of the list and loading as it goes
|
|
78
|
+
if (!isFirstItemLoaded) {
|
|
79
|
+
const start = Math.max(currentStartIdx - batchSize, 0);
|
|
80
|
+
const res = onLoadRef.current(start, currentStartIdx);
|
|
81
|
+
setStartIdx(start);
|
|
82
|
+
const { data, totalCount } = yield res;
|
|
83
|
+
setInternalData((current) => [...data, ...current]);
|
|
84
|
+
setItemCount(totalCount);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// This branch covers scrolling down from the top and loading as it goes
|
|
88
|
+
const end = currentStopIdx + batchSize;
|
|
89
|
+
const res = onLoadRef.current(currentStopIdx, end);
|
|
90
|
+
setStopIdx(end);
|
|
91
|
+
const { data, totalCount } = yield res;
|
|
92
|
+
setInternalData((current) => [...current, ...data]);
|
|
93
|
+
setItemCount(totalCount);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
97
|
+
}
|
|
98
|
+
}), [currentStartIdx, currentStopIdx]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
onLoadRef.current = onLoadData;
|
|
101
|
+
onItemsRendered(currentRange, true);
|
|
102
|
+
}, [onLoadData]);
|
|
103
|
+
const refresh = useCallback(() => {
|
|
104
|
+
onItemsRendered(currentRange, true);
|
|
105
|
+
}, useDeepCompare([currentRange]));
|
|
106
|
+
return {
|
|
107
|
+
getItem,
|
|
108
|
+
itemCount,
|
|
109
|
+
onItemsRendered,
|
|
110
|
+
refresh,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export default useInfiniteLoader;
|
|
114
|
+
//# sourceMappingURL=use-infinite-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-infinite-loader.js","sourceRoot":"","sources":["../../src/utils/use-infinite-loader.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-on-click-outside.d.ts","sourceRoot":"","sources":["../../src/utils/use-on-click-outside.tsx"],"names":[],"mappings":"AAkBA,iBAAS,iBAAiB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAgBlE;AAED,eAAe,iBAAiB,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 { useEffect } from 'react';
|
|
18
|
+
function useOnClickOutside(element, handler) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const listener = (event) => {
|
|
21
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
22
|
+
if (!element || element.contains(event.target)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
handler();
|
|
26
|
+
};
|
|
27
|
+
document.addEventListener('mousedown', listener);
|
|
28
|
+
document.addEventListener('touchstart', listener);
|
|
29
|
+
return () => {
|
|
30
|
+
document.removeEventListener('mousedown', listener);
|
|
31
|
+
document.removeEventListener('touchstart', listener);
|
|
32
|
+
};
|
|
33
|
+
}, [element, handler]);
|
|
34
|
+
}
|
|
35
|
+
export default useOnClickOutside;
|
|
36
|
+
//# sourceMappingURL=use-on-click-outside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-on-click-outside.js","sourceRoot":"","sources":["../../src/utils/use-on-click-outside.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,SAAS,iBAAiB,CAAC,OAAY,EAAE,OAAmB;IACxD,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,QAAQ,GAAG,CAAC,KAAiB,EAAQ,EAAE;YACzC,8DAA8D;YAC9D,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;gBAC5C,OAAO;aACV;YACD,OAAO,EAAE,CAAC;QACd,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACjD,QAAQ,CAAC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAClD,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YACpD,QAAQ,CAAC,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@darajs/ui-components",
|
|
3
|
+
"version": "1.0.0-a.1",
|
|
4
|
+
"description": "The core React UI kit for Dara",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"jsnext:main": "dist/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rimraf dist && tsc",
|
|
10
|
+
"lint": "eslint src --ext .tsx --max-warnings 0 && stylelint './src/**/*.tsx'",
|
|
11
|
+
"lint:fix": "eslint src --ext .tsx --max-warnings 0 --fix",
|
|
12
|
+
"package": "yarn build && yarn publish --no-git-tag-version",
|
|
13
|
+
"test-watch": "jest --watch",
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"storybook": "start-storybook -p 6006",
|
|
16
|
+
"build-storybook": "build-storybook"
|
|
17
|
+
},
|
|
18
|
+
"author": "Krzysztof Bielikowicz <krzysztof@causalens.com>",
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"prettier": "@darajs/prettier-config",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@babel/core": "^7.15.5",
|
|
23
|
+
"@babel/preset-env": "^7.15.6",
|
|
24
|
+
"@babel/preset-react": "^7.14.5",
|
|
25
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
26
|
+
"@darajs/eslint-config": "1.0.0-a.1",
|
|
27
|
+
"@darajs/prettier-config": "1.0.0-a.1",
|
|
28
|
+
"@darajs/stylelint-config": "1.0.0-a.1",
|
|
29
|
+
"@storybook/addon-a11y": "^6.5.16",
|
|
30
|
+
"@storybook/addon-actions": "^6.5.16",
|
|
31
|
+
"@storybook/addon-essentials": "^6.5.16",
|
|
32
|
+
"@storybook/addon-links": "^6.5.16",
|
|
33
|
+
"@storybook/addon-styling": "^0.3.2",
|
|
34
|
+
"@storybook/builder-webpack5": "^6.5.16",
|
|
35
|
+
"@storybook/manager-webpack5": "^6.5.16",
|
|
36
|
+
"@storybook/react": "^6.5.16",
|
|
37
|
+
"@storybook/theming": "^6.5.16",
|
|
38
|
+
"@testing-library/dom": "^9.3.0",
|
|
39
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
40
|
+
"@testing-library/react": "^14.0.0",
|
|
41
|
+
"@testing-library/user-event": "^13.2.1",
|
|
42
|
+
"@types/jest": "^27.0.0",
|
|
43
|
+
"@types/lodash": "^4.14.155",
|
|
44
|
+
"@types/react": "^18.0",
|
|
45
|
+
"@types/react-collapse": "^5.0.1",
|
|
46
|
+
"@types/react-datepicker": "^4.0.0",
|
|
47
|
+
"@types/react-dom": "^18.0",
|
|
48
|
+
"@types/react-table": "^7.0.19",
|
|
49
|
+
"@types/react-virtualized-auto-sizer": "^1.0.0",
|
|
50
|
+
"@types/react-window": "^1.8.2",
|
|
51
|
+
"@types/react-window-infinite-loader": "^1.0.3",
|
|
52
|
+
"@types/shortid": "0.0.29",
|
|
53
|
+
"@types/styled-components": "^5.1.26",
|
|
54
|
+
"babel-jest": "^29.5.0",
|
|
55
|
+
"babel-loader": "^8.2.2",
|
|
56
|
+
"babel-plugin-styled-components": "^1.13.2",
|
|
57
|
+
"eslint": "^7.2.0",
|
|
58
|
+
"eslint-plugin-jest": "^26.1.1",
|
|
59
|
+
"jest": "^29.5.0",
|
|
60
|
+
"jest-css-modules": "^2.1.0",
|
|
61
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
62
|
+
"prettier": "2.4.1",
|
|
63
|
+
"react-docgen-typescript-plugin": "^1.0.5",
|
|
64
|
+
"react-test-renderer": "^17.0",
|
|
65
|
+
"rimraf": "^3.0.2",
|
|
66
|
+
"storybook-dark-mode": "^2.1.1",
|
|
67
|
+
"stylelint": "^13.5.0",
|
|
68
|
+
"typescript": "^5.0.4"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@darajs/styled-components": "1.0.0-a.1",
|
|
72
|
+
"@darajs/ui-icons": "1.0.0-a.1",
|
|
73
|
+
"@darajs/ui-utils": "1.0.0-a.1",
|
|
74
|
+
"@fortawesome/free-regular-svg-icons": "^6.3.0",
|
|
75
|
+
"@fortawesome/free-solid-svg-icons": "^6.3.0",
|
|
76
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
77
|
+
"@popperjs/core": "2.4.0",
|
|
78
|
+
"@tippyjs/react": "4.1.0",
|
|
79
|
+
"date-fns": "2.9.0",
|
|
80
|
+
"downshift": "^7.0.0",
|
|
81
|
+
"lodash": "4.17.21",
|
|
82
|
+
"nanoid": "^3.3.0",
|
|
83
|
+
"polished": "3.6.4",
|
|
84
|
+
"react": "^18.0",
|
|
85
|
+
"react-collapse": "^5.1.1",
|
|
86
|
+
"react-compound-slider": "3.3.0",
|
|
87
|
+
"react-datepicker": "4.8.0",
|
|
88
|
+
"react-dom": "^18.0",
|
|
89
|
+
"react-dropzone": "11.0.1",
|
|
90
|
+
"react-popper": "2.2.5",
|
|
91
|
+
"react-table": "7.7.0",
|
|
92
|
+
"react-table-sticky": "^1.1.3",
|
|
93
|
+
"react-virtualized-auto-sizer": "1.0.6",
|
|
94
|
+
"react-window": "1.8.6",
|
|
95
|
+
"shortid": "2.2.15",
|
|
96
|
+
"tippy.js": "6.2.6"
|
|
97
|
+
},
|
|
98
|
+
"files": [
|
|
99
|
+
"dist"
|
|
100
|
+
],
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
103
|
+
},
|
|
104
|
+
"gitHead": "6280e44892919b09c7271a49919079baf250dc8f"
|
|
105
|
+
}
|