@saleor/macaw-ui 0.4.0 → 0.5.2
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/dist/ActionBar/ActionBar.d.ts +8 -0
- package/dist/ActionBar/ActionBar.stories.d.ts +4 -0
- package/dist/ActionBar/context.d.ts +9 -0
- package/dist/ActionBar/index.d.ts +2 -0
- package/dist/ActionBar/styles.d.ts +2 -0
- package/dist/Alert/Alert.d.ts +8 -0
- package/dist/Alert/Alert.stories.d.ts +12 -0
- package/dist/Alert/AlertBase.d.ts +8 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/styles.d.ts +2 -0
- package/dist/Backlink/Backlink.d.ts +8 -0
- package/dist/Backlink/Backlink.stories.d.ts +5 -0
- package/dist/Backlink/context.d.ts +5 -0
- package/dist/Backlink/index.d.ts +2 -0
- package/dist/Backlink/styles.d.ts +2 -0
- package/dist/BaseList/BaseList.d.ts +26 -0
- package/dist/BaseList/context.d.ts +7 -0
- package/dist/BaseList/index.d.ts +1 -0
- package/dist/BaseList/styles.d.ts +5 -0
- package/dist/Button/Button.d.ts +16 -0
- package/dist/Button/index.d.ts +1 -0
- package/dist/Button/styles.d.ts +2 -0
- package/dist/ConfirmButton/ConfirmButton.d.ts +11 -0
- package/dist/ConfirmButton/ConfirmButton.stories.d.ts +8 -0
- package/dist/ConfirmButton/index.d.ts +1 -0
- package/dist/ConfirmButton/styles.d.ts +2 -0
- package/dist/DialogHeader/DialogHeader.d.ts +6 -0
- package/dist/DialogHeader/index.d.ts +1 -0
- package/dist/DialogHeader/styles.d.ts +1 -0
- package/dist/DialogTable/DialogTable.d.ts +6 -0
- package/dist/DialogTable/index.d.ts +1 -0
- package/dist/DialogTable/styles.d.ts +1 -0
- package/dist/Filter/Filter.d.ts +10 -0
- package/dist/Filter/Filter.stories.d.ts +5 -0
- package/dist/Filter/FilterBar.d.ts +11 -0
- package/dist/Filter/FilterContent.d.ts +7 -0
- package/dist/Filter/FilterField/MultipleSelectFilterField.d.ts +6 -0
- package/dist/Filter/FilterField/RangeFilterField.d.ts +7 -0
- package/dist/Filter/FilterField/SelectFilterField.d.ts +6 -0
- package/dist/Filter/FilterField/TextFilterField.d.ts +6 -0
- package/dist/Filter/FilterMenu.d.ts +9 -0
- package/dist/Filter/context.d.ts +4 -0
- package/dist/Filter/index.d.ts +4 -0
- package/dist/Filter/styles.d.ts +2 -0
- package/dist/Filter/types.d.ts +49 -0
- package/dist/Filter/utils.d.ts +8 -0
- package/dist/IconButton/IconButton.d.ts +8 -0
- package/dist/IconButton/index.d.ts +1 -0
- package/dist/IconButton/partials.d.ts +14 -0
- package/dist/IconButton/styles.d.ts +2 -0
- package/dist/LayoutButton/LayoutButton.d.ts +7 -0
- package/dist/LayoutButton/index.d.ts +1 -0
- package/dist/LayoutButton/styles.d.ts +2 -0
- package/dist/List/List.d.ts +13 -0
- package/dist/List/List.stories.d.ts +5 -0
- package/dist/List/context.d.ts +8 -0
- package/dist/List/index.d.ts +1 -0
- package/dist/List/styles.d.ts +1 -0
- package/dist/Notification/Notification.d.ts +3 -0
- package/dist/Notification/Notification.stories.d.ts +10 -0
- package/dist/Notification/index.d.ts +2 -0
- package/dist/Notification/styles.d.ts +2 -0
- package/dist/Notification/types.d.ts +16 -0
- package/dist/OffsettedList/OffsettedList.d.ts +12 -0
- package/dist/OffsettedList/OffsettedList.stories.d.ts +5 -0
- package/dist/OffsettedList/index.d.ts +1 -0
- package/dist/OffsettedList/styles.d.ts +2 -0
- package/dist/PageTabs/PageTab.d.ts +3 -0
- package/dist/PageTabs/PageTab.stories.d.ts +4 -0
- package/dist/PageTabs/PageTabPanel.d.ts +4 -0
- package/dist/PageTabs/PageTabs.d.ts +5 -0
- package/dist/PageTabs/index.d.ts +3 -0
- package/dist/PageTabs/styles.d.ts +2 -0
- package/dist/Pagination/Pagination.d.ts +10 -0
- package/dist/Pagination/PaginationActions.d.ts +11 -0
- package/dist/Pagination/PaginationRowNumberSelect.d.ts +11 -0
- package/dist/Pagination/TablePagination.d.ts +6 -0
- package/dist/Pagination/index.d.ts +4 -0
- package/dist/Pagination/styles.d.ts +2 -0
- package/dist/PillLink/PillLink.d.ts +15 -0
- package/dist/PillLink/index.d.ts +1 -0
- package/dist/PillLink/styles.d.ts +2 -0
- package/dist/ResponsiveTable/ResponsiveTable.d.ts +8 -0
- package/dist/ResponsiveTable/index.d.ts +1 -0
- package/dist/ResponsiveTable/styles.d.ts +2 -0
- package/dist/Savebar/ButtonTooltipDecorator.d.ts +6 -0
- package/dist/Savebar/Savebar.d.ts +14 -0
- package/dist/Savebar/Savebar.stories.d.ts +6 -0
- package/dist/Savebar/index.d.ts +1 -0
- package/dist/Savebar/styles.d.ts +2 -0
- package/dist/ScrollShadow/ScrollShadow.d.ts +6 -0
- package/dist/ScrollShadow/index.d.ts +1 -0
- package/dist/ScrollShadow/styles.d.ts +1 -0
- package/dist/Sidebar/ExpandButton.d.ts +6 -0
- package/dist/Sidebar/MenuItem.d.ts +11 -0
- package/dist/Sidebar/Sidebar.d.ts +6 -0
- package/dist/Sidebar/Sidebar.stories.d.ts +6 -0
- package/dist/Sidebar/fixtures.d.ts +2 -0
- package/dist/Sidebar/index.d.ts +4 -0
- package/dist/Sidebar/types.d.ts +16 -0
- package/dist/SidebarDrawer/MenuItemBtn.d.ts +7 -0
- package/dist/SidebarDrawer/SidebarDrawer.d.ts +4 -0
- package/dist/SidebarDrawer/SidebarDrawer.stories.d.ts +4 -0
- package/dist/SidebarDrawer/index.d.ts +2 -0
- package/dist/SidebarDrawer/styles.d.ts +2 -0
- package/dist/SquareButton/SquareButton.d.ts +3 -0
- package/dist/SquareButton/SquareButton.stories.d.ts +5 -0
- package/dist/SquareButton/index.d.ts +1 -0
- package/dist/StatusChip/StatusChip.d.ts +3 -0
- package/dist/StatusChip/StatusChip.stories.d.ts +8 -0
- package/dist/StatusChip/index.d.ts +2 -0
- package/dist/StatusChip/styles.d.ts +3 -0
- package/dist/StatusChip/types.d.ts +8 -0
- package/dist/Tooltip/Tooltip.d.ts +6 -0
- package/dist/Tooltip/Tooltip.stories.d.ts +7 -0
- package/dist/Tooltip/index.d.ts +1 -0
- package/dist/Tooltip/styles.d.ts +3 -0
- package/dist/UserChipMenu/UserChipMenu.d.ts +9 -0
- package/dist/UserChipMenu/UserChipMenu.stories.d.ts +6 -0
- package/dist/UserChipMenu/UserChipMenuItem.d.ts +6 -0
- package/dist/UserChipMenu/context.d.ts +4 -0
- package/dist/UserChipMenu/index.d.ts +2 -0
- package/dist/UserChipMenu/styles.d.ts +2 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +3 -3
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/sendMessage.d.ts +3 -0
- package/dist/extensions/types.d.ts +22 -0
- package/dist/extensions/useExtensionMessage.d.ts +2 -0
- package/dist/icons/ArrowDropdownIcon.d.ts +2 -0
- package/dist/icons/ArrowRightIcon.d.ts +1 -0
- package/dist/icons/CheckboxCheckedIcon.d.ts +1 -0
- package/dist/icons/CheckboxIcon.d.ts +1 -0
- package/dist/icons/CheckboxIndeterminateIcon.d.ts +1 -0
- package/dist/icons/CloseIcon.d.ts +1 -0
- package/dist/icons/CompleteIcon.d.ts +2 -0
- package/dist/icons/DeleteIcon.d.ts +1 -0
- package/dist/icons/EditIcon.d.ts +1 -0
- package/dist/icons/FilteringIcon.d.ts +1 -0
- package/dist/icons/ImageIcon.d.ts +1 -0
- package/dist/icons/InfoIcon.d.ts +2 -0
- package/dist/icons/Logo.d.ts +2 -0
- package/dist/icons/LogoLight.d.ts +2 -0
- package/dist/icons/MoreIcon.d.ts +1 -0
- package/dist/icons/NavigatorIcon.d.ts +1 -0
- package/dist/icons/NotAllowedIcon.d.ts +2 -0
- package/dist/icons/NotAllowedInvertedIcon.d.ts +2 -0
- package/dist/icons/PlusIcon.d.ts +1 -0
- package/dist/icons/RadioCheckedIcon.d.ts +1 -0
- package/dist/icons/RadioIcon.d.ts +1 -0
- package/dist/icons/SearchIcon.d.ts +1 -0
- package/dist/icons/WarningIcon.d.ts +2 -0
- package/dist/icons/index.d.ts +18 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/localStorageKeys.d.ts +4 -0
- package/dist/mjs/index.js +5 -0
- package/dist/mjs/index.js.map +7 -0
- package/dist/theme/Baseline.d.ts +2 -0
- package/dist/theme/ThemeProvider.d.ts +17 -0
- package/dist/theme/context.d.ts +3 -0
- package/dist/theme/createSaleorTheme/createSaleorTheme.d.ts +3 -0
- package/dist/theme/createSaleorTheme/index.d.ts +2 -0
- package/dist/theme/createSaleorTheme/overrides/buttons.d.ts +3 -0
- package/dist/theme/createSaleorTheme/overrides/controls.d.ts +3 -0
- package/dist/theme/createSaleorTheme/overrides/index.d.ts +3 -0
- package/dist/theme/createSaleorTheme/overrides/inputs.d.ts +3 -0
- package/dist/theme/createSaleorTheme/overrides/tables.d.ts +3 -0
- package/dist/theme/createSaleorTheme/palette.d.ts +2 -0
- package/dist/theme/createSaleorTheme/shadows.d.ts +2 -0
- package/dist/theme/createSaleorTheme/types.d.ts +51 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/styles.d.ts +5 -0
- package/dist/theme/themes.d.ts +3 -0
- package/dist/theme/types.d.ts +6 -0
- package/dist/theme/utils.d.ts +1 -0
- package/dist/theme/utils.test.d.ts +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/useElementScroll.d.ts +12 -0
- package/dist/tools/useLocalStorage.d.ts +5 -0
- package/dist/tools/useWindowScroll.d.ts +4 -0
- package/dist/types/Autocomplete/Autocomplete.d.ts +23 -0
- package/dist/types/Autocomplete/Autocomplete.stories.d.ts +5 -0
- package/dist/types/Autocomplete/fixtures.d.ts +4 -0
- package/dist/types/Autocomplete/index.d.ts +1 -0
- package/dist/types/Autocomplete/styles.d.ts +2 -0
- package/dist/types/Backlink/Backlink.d.ts +6 -4
- package/dist/types/Filter/FilterField/AutocompleteFilterField.d.ts +6 -0
- package/dist/types/Filter/FilterField/MultipleValueAutocompleteFilterField.d.ts +6 -0
- package/dist/types/Filter/stories/Filter.stories.d.ts +5 -0
- package/dist/types/Filter/stories/FilterInteractive.stories.d.ts +4 -0
- package/dist/types/Filter/stories/labels.d.ts +8 -0
- package/dist/types/Filter/styles.d.ts +1 -1
- package/dist/types/Filter/types.d.ts +8 -2
- package/dist/types/Filter/utils.d.ts +4 -1
- package/dist/types/IconButton/IconButton.d.ts +44 -2
- package/dist/types/LayoutButton/LayoutButton.d.ts +29 -2
- package/dist/types/MultipleValueAutocomplete/MultipleValueAutocomplete.d.ts +26 -0
- package/dist/types/MultipleValueAutocomplete/MultipleValueAutocomplete.stories.d.ts +6 -0
- package/dist/types/MultipleValueAutocomplete/fixtures.d.ts +4 -0
- package/dist/types/MultipleValueAutocomplete/index.d.ts +1 -0
- package/dist/types/MultipleValueAutocomplete/styles.d.ts +2 -0
- package/dist/types/MultipleValueAutocomplete/useMultipleValueAutocomplete.d.ts +32 -0
- package/dist/types/StatusChip/styles.d.ts +3 -0
- package/dist/types/SwitchSelector/SwitchSelector.d.ts +2 -0
- package/dist/types/SwitchSelector/SwitchSelector.stories.d.ts +4 -0
- package/dist/types/SwitchSelector/SwitchSelectorButton.d.ts +8 -0
- package/dist/types/SwitchSelector/index.d.ts +2 -0
- package/dist/types/consts.d.ts +4 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/tools/useTextWidth.d.ts +2 -0
- package/dist/types/utils/mergeRefs.d.ts +2 -0
- package/dist/types/utils/useMockAutocomplete.d.ts +10 -0
- package/dist/utils/Decorator.d.ts +4 -0
- package/dist/utils/useListStory.d.ts +21 -0
- package/package.json +10 -6
- package/src/Autocomplete/Autocomplete.stories.tsx +43 -0
- package/src/Autocomplete/Autocomplete.tsx +188 -0
- package/src/Autocomplete/fixtures.ts +122 -0
- package/src/Autocomplete/index.ts +1 -0
- package/src/Autocomplete/styles.ts +22 -0
- package/src/Backlink/Backlink.tsx +7 -7
- package/src/Backlink/styles.ts +1 -1
- package/src/Chip/styles.ts +2 -1
- package/src/Filter/Filter.tsx +88 -44
- package/src/Filter/FilterBar.tsx +15 -9
- package/src/Filter/FilterContent.tsx +8 -1
- package/src/Filter/FilterField/AutocompleteFilterField.tsx +61 -0
- package/src/Filter/FilterField/MultipleSelectFilterField.tsx +6 -2
- package/src/Filter/FilterField/MultipleValueAutocompleteFilterField.tsx +60 -0
- package/src/Filter/context.tsx +1 -1
- package/src/Filter/{Filter.stories.tsx → stories/Filter.stories.tsx} +47 -13
- package/src/Filter/stories/FilterInteractive.stories.tsx +97 -0
- package/src/Filter/stories/labels.ts +8 -0
- package/src/Filter/styles.ts +37 -6
- package/src/Filter/types.ts +8 -1
- package/src/Filter/utils.ts +71 -5
- package/src/IconButton/IconButton.tsx +29 -7
- package/src/LayoutButton/LayoutButton.tsx +39 -23
- package/src/MultipleValueAutocomplete/MultipleValueAutocomplete.stories.tsx +76 -0
- package/src/MultipleValueAutocomplete/MultipleValueAutocomplete.tsx +185 -0
- package/src/MultipleValueAutocomplete/fixtures.ts +122 -0
- package/src/MultipleValueAutocomplete/index.ts +1 -0
- package/src/MultipleValueAutocomplete/styles.ts +41 -0
- package/src/MultipleValueAutocomplete/useMultipleValueAutocomplete.ts +172 -0
- package/src/SwitchSelector/SwitchSelector.stories.tsx +63 -0
- package/src/SwitchSelector/SwitchSelector.tsx +20 -0
- package/src/SwitchSelector/SwitchSelectorButton.tsx +60 -0
- package/src/SwitchSelector/index.ts +2 -0
- package/src/consts.ts +4 -0
- package/src/index.tsx +3 -0
- package/src/theme/createSaleorTheme/createSaleorTheme.tsx +1 -1
- package/src/tools/useTextWidth.ts +20 -0
- package/src/utils/mergeRefs.ts +14 -0
- package/src/utils/useMockAutocomplete.ts +37 -0
- package/dist/types/Chip/ColorSwatch.d.ts +0 -6
- package/dist/types/Chip/common/ChipMovable.d.ts +0 -5
- package/dist/types/Chip/common/ChipRemovable.d.ts +0 -6
- package/dist/types/Chip/common/ChipSwatch.d.ts +0 -7
- package/dist/types/Chip/common/index.d.ts +0 -3
- package/src/Chip/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.5.2",
|
|
3
3
|
"license": "CC-BY-4.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -86,11 +86,12 @@
|
|
|
86
86
|
"@material-ui/icons": "^4.11.2",
|
|
87
87
|
"@material-ui/lab": "^4.0.0-alpha.58",
|
|
88
88
|
"@size-limit/preset-small-lib": "^4.10.2",
|
|
89
|
-
"@storybook/addon-essentials": "^6.
|
|
89
|
+
"@storybook/addon-essentials": "^6.4.22",
|
|
90
90
|
"@storybook/addon-info": "^5.3.21",
|
|
91
|
-
"@storybook/addon-links": "^6.
|
|
92
|
-
"@storybook/addons": "^6.
|
|
93
|
-
"@storybook/react": "^6.
|
|
91
|
+
"@storybook/addon-links": "^6.4.22",
|
|
92
|
+
"@storybook/addons": "^6.4.22",
|
|
93
|
+
"@storybook/react": "^6.4.22",
|
|
94
|
+
"@types/fuzzaldrin": "^2.1.4",
|
|
94
95
|
"@types/jest": "^27.0.2",
|
|
95
96
|
"@types/lodash": "^4.14.170",
|
|
96
97
|
"@types/lodash-es": "^4.17.5",
|
|
@@ -106,8 +107,10 @@
|
|
|
106
107
|
"esbuild-jest": "^0.5.0",
|
|
107
108
|
"eslint": "^7.32.0",
|
|
108
109
|
"eslint-plugin-simple-import-sort": "^5.0.3",
|
|
110
|
+
"eslint-plugin-storybook": "^0.5.10",
|
|
109
111
|
"faker": "^5.5.3",
|
|
110
112
|
"husky": "^7.0.0",
|
|
113
|
+
"fuzzaldrin": "^2.1.0",
|
|
111
114
|
"hygen": "^6.1.0",
|
|
112
115
|
"jest": "^27.2.4",
|
|
113
116
|
"jest-file": "^1.0.0",
|
|
@@ -117,13 +120,14 @@
|
|
|
117
120
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
118
121
|
"react-is": "^17.0.2",
|
|
119
122
|
"size-limit": "^4.10.2",
|
|
120
|
-
"storybook-dark-mode": "^1.0.
|
|
123
|
+
"storybook-dark-mode": "^1.0.9",
|
|
121
124
|
"tslib": "^2.3.1",
|
|
122
125
|
"typescript": "^4.2.4",
|
|
123
126
|
"yargs": "^17.2.1"
|
|
124
127
|
},
|
|
125
128
|
"dependencies": {
|
|
126
129
|
"clsx": "^1.1.1",
|
|
130
|
+
"downshift": "^6.1.7",
|
|
127
131
|
"lodash": "^4.17.21",
|
|
128
132
|
"lodash-es": "^4.17.21",
|
|
129
133
|
"react-inlinesvg": "^2.3.0"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MenuItem } from "@material-ui/core";
|
|
2
|
+
import { Meta, Story } from "@storybook/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
import { Decorator, GuideDecorator } from "../utils/Decorator";
|
|
6
|
+
import { useMockAutocomplete } from "../utils/useMockAutocomplete";
|
|
7
|
+
import { Autocomplete } from "./Autocomplete";
|
|
8
|
+
import { choices } from "./fixtures";
|
|
9
|
+
|
|
10
|
+
export const Default: Story = () => {
|
|
11
|
+
const { results, search } = useMockAutocomplete(choices);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Autocomplete
|
|
15
|
+
choices={results}
|
|
16
|
+
fullWidth
|
|
17
|
+
label="Employee of the month"
|
|
18
|
+
onInputChange={search}
|
|
19
|
+
>
|
|
20
|
+
{({ highlightedIndex, getItemProps }) =>
|
|
21
|
+
results.map((choice, choiceIndex) => (
|
|
22
|
+
<MenuItem
|
|
23
|
+
selected={highlightedIndex === choiceIndex}
|
|
24
|
+
{...getItemProps({ item: choice, index: choiceIndex })}
|
|
25
|
+
>
|
|
26
|
+
{choice.label}
|
|
27
|
+
</MenuItem>
|
|
28
|
+
))
|
|
29
|
+
}
|
|
30
|
+
</Autocomplete>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Loading: Story = () => (
|
|
35
|
+
<Autocomplete fullWidth choices={[]} label="Employee of the month" loading>
|
|
36
|
+
{() => null}
|
|
37
|
+
</Autocomplete>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export default {
|
|
41
|
+
decorators: [Decorator, GuideDecorator],
|
|
42
|
+
title: "Autocomplete / Single choice",
|
|
43
|
+
} as Meta;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import CircularProgress from "@material-ui/core/CircularProgress";
|
|
2
|
+
import Grow from "@material-ui/core/Grow";
|
|
3
|
+
import Paper from "@material-ui/core/Paper";
|
|
4
|
+
import Popper, { PopperPlacementType } from "@material-ui/core/Popper";
|
|
5
|
+
import TextField, { StandardTextFieldProps } from "@material-ui/core/TextField";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { useCombobox, UseComboboxGetItemPropsOptions } from "downshift";
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import { SyntheticChangeEvent } from "../../types/utils";
|
|
11
|
+
import { Choice } from "../Filter";
|
|
12
|
+
import { ChevronIcon } from "../icons";
|
|
13
|
+
import { isScrolledToBottom, useElementScroll } from "../tools";
|
|
14
|
+
import { mergeRefs } from "../utils/mergeRefs";
|
|
15
|
+
import useStyles from "./styles";
|
|
16
|
+
|
|
17
|
+
export interface AutocompleteProps extends StandardTextFieldProps {
|
|
18
|
+
children: (data: {
|
|
19
|
+
getItemProps: (opts: UseComboboxGetItemPropsOptions<Choice>) => any;
|
|
20
|
+
highlightedIndex: number;
|
|
21
|
+
inputValue: string;
|
|
22
|
+
}) => React.ReactNode | React.ReactNodeArray;
|
|
23
|
+
className?: string;
|
|
24
|
+
styles?: React.CSSProperties;
|
|
25
|
+
choices: Choice[];
|
|
26
|
+
label?: string;
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
popperPlacement?: PopperPlacementType;
|
|
29
|
+
onChange?: (event: SyntheticChangeEvent) => void;
|
|
30
|
+
onInputChange?: (value: string) => void;
|
|
31
|
+
onScrollToBottom?: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
35
|
+
choices,
|
|
36
|
+
children,
|
|
37
|
+
loading,
|
|
38
|
+
name,
|
|
39
|
+
InputProps,
|
|
40
|
+
popperPlacement = "bottom-start",
|
|
41
|
+
onChange,
|
|
42
|
+
onInputChange,
|
|
43
|
+
onScrollToBottom,
|
|
44
|
+
...rest
|
|
45
|
+
}) => {
|
|
46
|
+
const classes = useStyles();
|
|
47
|
+
const anchor = React.useRef<HTMLDivElement>();
|
|
48
|
+
const input = React.useRef<HTMLInputElement>();
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
closeMenu,
|
|
52
|
+
isOpen,
|
|
53
|
+
getToggleButtonProps,
|
|
54
|
+
getLabelProps,
|
|
55
|
+
getMenuProps,
|
|
56
|
+
getInputProps,
|
|
57
|
+
getComboboxProps,
|
|
58
|
+
highlightedIndex,
|
|
59
|
+
getItemProps,
|
|
60
|
+
openMenu,
|
|
61
|
+
inputValue,
|
|
62
|
+
setInputValue,
|
|
63
|
+
} = useCombobox({
|
|
64
|
+
circularNavigation: false,
|
|
65
|
+
defaultHighlightedIndex: 0,
|
|
66
|
+
items: choices,
|
|
67
|
+
onInputValueChange: ({ inputValue }) => {
|
|
68
|
+
if (onInputChange) {
|
|
69
|
+
onInputChange(inputValue ?? "");
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
onSelectedItemChange: ({ selectedItem }) => {
|
|
73
|
+
closeMenu();
|
|
74
|
+
if (onChange) {
|
|
75
|
+
onChange({
|
|
76
|
+
target: {
|
|
77
|
+
name: name ?? "",
|
|
78
|
+
value: selectedItem?.value ?? "",
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
itemToString: (choice) => choice?.label ?? "",
|
|
84
|
+
onIsOpenChange: ({ selectedItem, inputValue, isOpen }) => {
|
|
85
|
+
if (!isOpen && selectedItem && selectedItem?.label !== inputValue) {
|
|
86
|
+
setInputValue(selectedItem!.label);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const { anchor: dropdownRef, position, setAnchor } = useElementScroll();
|
|
92
|
+
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
if (
|
|
95
|
+
isOpen &&
|
|
96
|
+
onScrollToBottom &&
|
|
97
|
+
dropdownRef &&
|
|
98
|
+
isScrolledToBottom(dropdownRef, position!, 5)
|
|
99
|
+
) {
|
|
100
|
+
onScrollToBottom();
|
|
101
|
+
}
|
|
102
|
+
}, [position?.y, dropdownRef]);
|
|
103
|
+
|
|
104
|
+
const labelProps = getLabelProps();
|
|
105
|
+
const { ref: comboboxDownshiftRef, ...comboboxProps } = getComboboxProps();
|
|
106
|
+
const { ref: downshiftRef, ...inputProps } = getInputProps({
|
|
107
|
+
onFocus: () => {
|
|
108
|
+
if (!isOpen) {
|
|
109
|
+
input.current?.select();
|
|
110
|
+
openMenu();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
const menuProps = getMenuProps({}, { suppressRefError: true });
|
|
115
|
+
|
|
116
|
+
React.useEffect(() => {
|
|
117
|
+
if (
|
|
118
|
+
isOpen &&
|
|
119
|
+
onScrollToBottom &&
|
|
120
|
+
dropdownRef &&
|
|
121
|
+
isScrolledToBottom(dropdownRef, position!, 5)
|
|
122
|
+
) {
|
|
123
|
+
onScrollToBottom();
|
|
124
|
+
}
|
|
125
|
+
}, [position?.y, dropdownRef]);
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
<TextField
|
|
130
|
+
{...rest}
|
|
131
|
+
{...comboboxProps}
|
|
132
|
+
name={name}
|
|
133
|
+
InputLabelProps={labelProps}
|
|
134
|
+
ref={mergeRefs(comboboxDownshiftRef, anchor)}
|
|
135
|
+
InputProps={{
|
|
136
|
+
...InputProps,
|
|
137
|
+
...inputProps,
|
|
138
|
+
endAdornment: (
|
|
139
|
+
<>
|
|
140
|
+
{loading && (
|
|
141
|
+
<div className={classes.loader}>
|
|
142
|
+
<CircularProgress size={24} />
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
<ChevronIcon
|
|
146
|
+
{...getToggleButtonProps()}
|
|
147
|
+
type="button"
|
|
148
|
+
aria-label="toggle menu"
|
|
149
|
+
/>
|
|
150
|
+
</>
|
|
151
|
+
),
|
|
152
|
+
}}
|
|
153
|
+
inputProps={{ ref: mergeRefs(downshiftRef, input) }}
|
|
154
|
+
/>
|
|
155
|
+
<Popper
|
|
156
|
+
className={clsx(classes.popper, menuProps.className)}
|
|
157
|
+
open={isOpen}
|
|
158
|
+
anchorEl={input.current}
|
|
159
|
+
transition
|
|
160
|
+
placement={popperPlacement}
|
|
161
|
+
>
|
|
162
|
+
{({ TransitionProps, placement }) => (
|
|
163
|
+
<Grow
|
|
164
|
+
{...TransitionProps}
|
|
165
|
+
style={{
|
|
166
|
+
transformOrigin:
|
|
167
|
+
placement === "bottom" ? "left top" : "left bottom",
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<Paper
|
|
171
|
+
className={classes.dropdown}
|
|
172
|
+
elevation={8}
|
|
173
|
+
style={{ width: anchor.current?.clientWidth }}
|
|
174
|
+
{...menuProps}
|
|
175
|
+
ref={mergeRefs(setAnchor, menuProps.ref)}
|
|
176
|
+
>
|
|
177
|
+
{children({
|
|
178
|
+
highlightedIndex,
|
|
179
|
+
getItemProps,
|
|
180
|
+
inputValue,
|
|
181
|
+
})}
|
|
182
|
+
</Paper>
|
|
183
|
+
</Grow>
|
|
184
|
+
)}
|
|
185
|
+
</Popper>
|
|
186
|
+
</>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const choices = [
|
|
2
|
+
{
|
|
3
|
+
label: "Hazel, Direct Integration Producer",
|
|
4
|
+
value: "hazel, direct integration producer",
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
label: "Audra, District Functionality Facilitator",
|
|
8
|
+
value: "audra, district functionality facilitator",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: "Emilie, Product Integration Assistant",
|
|
12
|
+
value: "emilie, product integration assistant",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Kyla, Central Interactions Director",
|
|
16
|
+
value: "kyla, central interactions director",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Vida, Senior Usability Producer",
|
|
20
|
+
value: "vida, senior usability producer",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "Lonie, Chief Infrastructure Director",
|
|
24
|
+
value: "lonie, chief infrastructure director",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Zola, Lead Operations Producer",
|
|
28
|
+
value: "zola, lead operations producer",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "Angel, District Operations Orchestrator",
|
|
32
|
+
value: "angel, district operations orchestrator",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Glenda, Lead Accountability Technician",
|
|
36
|
+
value: "glenda, lead accountability technician",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Kayley, National Web Facilitator",
|
|
40
|
+
value: "kayley, national web facilitator",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "Kali, National Configuration Planner",
|
|
44
|
+
value: "kali, national configuration planner",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "Lilian, Internal Branding Planner",
|
|
48
|
+
value: "lilian, internal branding planner",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "Lamar, Dynamic Integration Executive",
|
|
52
|
+
value: "lamar, dynamic integration executive",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "Leonel, Central Brand Strategist",
|
|
56
|
+
value: "leonel, central brand strategist",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: "Broderick, Chief Division Liaison",
|
|
60
|
+
value: "broderick, chief division liaison",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: "Kavon, Future Marketing Representative",
|
|
64
|
+
value: "kavon, future marketing representative",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: "Sydnee, Corporate Marketing Liaison",
|
|
68
|
+
value: "sydnee, corporate marketing liaison",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: "Jett, Future Data Specialist",
|
|
72
|
+
value: "jett, future data specialist",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: "Theresia, International Tactics Assistant",
|
|
76
|
+
value: "theresia, international tactics assistant",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "Cesar, Direct Mobility Director",
|
|
80
|
+
value: "cesar, direct mobility director",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "Madonna, Investor Assurance Executive",
|
|
84
|
+
value: "madonna, investor assurance executive",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: "Ima, Internal Research Facilitator",
|
|
88
|
+
value: "ima, internal research facilitator",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: "Joanne, Investor Identity Coordinator",
|
|
92
|
+
value: "joanne, investor identity coordinator",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: "Gavin, Future Web Assistant",
|
|
96
|
+
value: "gavin, future web assistant",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
label: "Maverick, Internal Optimization Assistant",
|
|
100
|
+
value: "maverick, internal optimization assistant",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: "Hudson, Regional Branding Representative",
|
|
104
|
+
value: "hudson, regional branding representative",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: "Brooklyn, Human Paradigm Producer",
|
|
108
|
+
value: "brooklyn, human paradigm producer",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: "Gussie, Future Configuration Supervisor",
|
|
112
|
+
value: "gussie, future configuration supervisor",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: "Michel, Corporate Tactics Orchestrator",
|
|
116
|
+
value: "michel, corporate tactics orchestrator",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Maxime, Customer Mobility Analyst",
|
|
120
|
+
value: "maxime, customer mobility analyst",
|
|
121
|
+
},
|
|
122
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Autocomplete";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { zIndex } from "../consts";
|
|
2
|
+
import { makeStyles } from "../theme";
|
|
3
|
+
|
|
4
|
+
const useStyles = makeStyles(
|
|
5
|
+
(theme) => ({
|
|
6
|
+
dropdown: {
|
|
7
|
+
maxHeight: 220,
|
|
8
|
+
overflow: "scroll",
|
|
9
|
+
},
|
|
10
|
+
loader: {
|
|
11
|
+
marginRight: theme.spacing(1),
|
|
12
|
+
},
|
|
13
|
+
popper: {
|
|
14
|
+
marginTop: theme.spacing(1),
|
|
15
|
+
// Places popper above dialogs
|
|
16
|
+
zIndex: zIndex.popper,
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
{ name: "Autocomplete" }
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default useStyles;
|
|
@@ -8,18 +8,18 @@ import { useTheme } from "../theme";
|
|
|
8
8
|
import { useBacklink } from "./context";
|
|
9
9
|
import useStyles from "./styles";
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
11
|
+
export type BacklinkProps<T extends React.ElementType> =
|
|
12
|
+
LayoutButtonProps<T> & {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
export const Backlink
|
|
17
|
+
export const Backlink = <T extends React.ElementType>({
|
|
18
18
|
children,
|
|
19
19
|
disabled,
|
|
20
20
|
onClick,
|
|
21
21
|
...props
|
|
22
|
-
}) => {
|
|
22
|
+
}: BacklinkProps<T>) => {
|
|
23
23
|
const { ssr } = useTheme();
|
|
24
24
|
const classes = useStyles();
|
|
25
25
|
const anchor = useBacklink();
|
package/src/Backlink/styles.ts
CHANGED
package/src/Chip/styles.ts
CHANGED
|
@@ -3,12 +3,13 @@ import { makeStyles } from "../theme";
|
|
|
3
3
|
const useStyles = makeStyles(
|
|
4
4
|
(theme) => ({
|
|
5
5
|
chip: {
|
|
6
|
+
...theme.typography.body2,
|
|
6
7
|
background: theme.palette.saleor.active[1],
|
|
7
8
|
color: theme.palette.primary.contrastText,
|
|
8
9
|
borderRadius: "8px",
|
|
9
10
|
display: "flex",
|
|
10
11
|
alignItems: "center",
|
|
11
|
-
padding:
|
|
12
|
+
padding: theme.spacing(0, 2),
|
|
12
13
|
gap: "4px",
|
|
13
14
|
lineHeight: 1,
|
|
14
15
|
minHeight: theme.spacing(4),
|
package/src/Filter/Filter.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import IconButton from "@material-ui/core/IconButton";
|
|
2
1
|
import MenuItem from "@material-ui/core/MenuItem";
|
|
3
|
-
import Select from "@material-ui/core/Select";
|
|
2
|
+
import Select, { SelectProps } from "@material-ui/core/Select";
|
|
4
3
|
import Typography from "@material-ui/core/Typography";
|
|
5
|
-
import { difference } from "lodash";
|
|
4
|
+
import { difference, uniqBy } from "lodash";
|
|
6
5
|
import React from "react";
|
|
7
6
|
|
|
7
|
+
import { IconButton } from "../IconButton";
|
|
8
8
|
import { DeleteIcon } from "../icons";
|
|
9
9
|
import { useFilters } from "./context";
|
|
10
10
|
import { FilterContent } from "./FilterContent";
|
|
@@ -19,9 +19,16 @@ import {
|
|
|
19
19
|
import * as utils from "./utils";
|
|
20
20
|
|
|
21
21
|
export type FilterProps = FilterOptions & FilterDetailedOptions;
|
|
22
|
-
export const Filter: React.FC<FilterProps> = ({
|
|
23
|
-
|
|
22
|
+
export const Filter: React.FC<FilterProps> = ({
|
|
23
|
+
name: nameProp,
|
|
24
|
+
label,
|
|
25
|
+
...options
|
|
26
|
+
}) => {
|
|
27
|
+
const name = utils.getFilterName(nameProp, options);
|
|
28
|
+
const { filters, register, set, unregister } = useFilters();
|
|
24
29
|
const registered = React.useRef(false);
|
|
30
|
+
const filter = filters.find((fd) => fd.name === name);
|
|
31
|
+
|
|
25
32
|
React.useEffect(() => {
|
|
26
33
|
register(name, label, options);
|
|
27
34
|
registered.current = true;
|
|
@@ -33,7 +40,8 @@ export const Filter: React.FC<FilterProps> = ({ name, label, ...options }) => {
|
|
|
33
40
|
if (
|
|
34
41
|
registered.current &&
|
|
35
42
|
options.choices !== undefined &&
|
|
36
|
-
|
|
43
|
+
filter &&
|
|
44
|
+
difference(options.choices, filter!.options.choices!).length
|
|
37
45
|
) {
|
|
38
46
|
set(name, {
|
|
39
47
|
options: {
|
|
@@ -58,7 +66,7 @@ export const FilterRow: React.FC<FilterRowProps> = ({
|
|
|
58
66
|
labels,
|
|
59
67
|
}) => {
|
|
60
68
|
const classes = useStyles();
|
|
61
|
-
const { filters, toggle, toggleRange } = useFilters();
|
|
69
|
+
const { filters, toggle, toggleRange, swap } = useFilters();
|
|
62
70
|
|
|
63
71
|
const filter = filters.find((filter) => filter.name === name);
|
|
64
72
|
|
|
@@ -67,50 +75,86 @@ export const FilterRow: React.FC<FilterRowProps> = ({
|
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
const availableFilters = utils.getAvailableFilters(filters);
|
|
70
|
-
const options =
|
|
78
|
+
const options = uniqBy(
|
|
79
|
+
[filter.options.group ?? filter, ...availableFilters],
|
|
80
|
+
"name"
|
|
81
|
+
);
|
|
82
|
+
const groupOptions = [
|
|
83
|
+
filter,
|
|
84
|
+
...filters.filter(
|
|
85
|
+
(f) =>
|
|
86
|
+
f.name !== filter.name &&
|
|
87
|
+
f.options.group?.name === filter.options.group?.name &&
|
|
88
|
+
!f.active
|
|
89
|
+
),
|
|
90
|
+
];
|
|
71
91
|
|
|
72
92
|
const change = (event: React.ChangeEvent<EventTarget<unknown>>) => {
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
const targetFilterName = event.target.value as string;
|
|
94
|
+
|
|
95
|
+
swap(name, targetFilterName);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const selectProps: SelectProps = {
|
|
99
|
+
classes: {
|
|
100
|
+
selectMenu: classes.filterInputInner,
|
|
101
|
+
},
|
|
102
|
+
variant: "outlined",
|
|
75
103
|
};
|
|
76
104
|
|
|
77
105
|
return (
|
|
78
106
|
<div className={classes.filter}>
|
|
79
|
-
<
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
<div className={classes.filterOptions}>
|
|
108
|
+
<Typography className={classes.filterConjunction}>
|
|
109
|
+
{first ? labels.where : labels.and}
|
|
110
|
+
</Typography>
|
|
111
|
+
<Select
|
|
112
|
+
{...selectProps}
|
|
113
|
+
className={classes.filterName}
|
|
114
|
+
onChange={change}
|
|
115
|
+
value={filter.options.group?.name ?? filter.name}
|
|
116
|
+
>
|
|
117
|
+
{options.map((option) => (
|
|
118
|
+
<MenuItem key={option.name} value={option.name}>
|
|
119
|
+
{option.label}
|
|
120
|
+
</MenuItem>
|
|
121
|
+
))}
|
|
122
|
+
</Select>
|
|
123
|
+
{!!filter.options.group && (
|
|
124
|
+
<Select
|
|
125
|
+
{...selectProps}
|
|
126
|
+
className={classes.filterName}
|
|
127
|
+
onChange={change}
|
|
128
|
+
value={filter.name}
|
|
129
|
+
>
|
|
130
|
+
{groupOptions.map((option) => (
|
|
131
|
+
<MenuItem key={option.name} value={option.name}>
|
|
132
|
+
{option.label}
|
|
133
|
+
</MenuItem>
|
|
134
|
+
))}
|
|
135
|
+
</Select>
|
|
136
|
+
)}
|
|
137
|
+
<Select
|
|
138
|
+
{...selectProps}
|
|
139
|
+
disabled={filter.options.type !== FilterType.Range}
|
|
140
|
+
className={classes.filterRange}
|
|
141
|
+
value={filter.range.toString()}
|
|
142
|
+
onChange={() => toggleRange(name)}
|
|
143
|
+
>
|
|
144
|
+
<MenuItem value="false">{labels.is}</MenuItem>
|
|
145
|
+
<MenuItem value="true">{labels.range}</MenuItem>
|
|
146
|
+
</Select>
|
|
147
|
+
</div>
|
|
110
148
|
<FilterContent filter={filter} labels={labels} />
|
|
111
|
-
<
|
|
112
|
-
<
|
|
113
|
-
|
|
149
|
+
<div className={classes.filterDeleteContainer}>
|
|
150
|
+
<IconButton
|
|
151
|
+
variant="secondary"
|
|
152
|
+
className={classes.filterDelete}
|
|
153
|
+
onClick={() => toggle(name)}
|
|
154
|
+
>
|
|
155
|
+
<DeleteIcon />
|
|
156
|
+
</IconButton>
|
|
157
|
+
</div>
|
|
114
158
|
</div>
|
|
115
159
|
);
|
|
116
160
|
};
|