@via-profit/ui-kit 0.1.8 → 0.2.1-alpha.3
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/Accordion/index.d.ts +4 -4
- package/Autocomplete/AutocompleteContainer.d.ts +34 -7
- package/Autocomplete/AutocompleteContainer.js +28 -24
- package/Autocomplete/AutocompleteItem.d.ts +1 -1
- package/Autocomplete/AutocompleteTextField.d.ts +3 -0
- package/Autocomplete/AutocompleteTextField.js +63 -1
- package/Autocomplete/OverrideMenuList.d.ts +4 -0
- package/Autocomplete/OverrideMenuList.js +39 -0
- package/Autocomplete/context.d.ts +9 -1
- package/Autocomplete/context.js +15 -1
- package/Autocomplete/index.js +9 -10
- package/Autocomplete2/Autocomplete2.d.ts +12 -0
- package/Autocomplete2/Autocomplete2.js +83 -0
- package/Autocomplete2/Autocomplete2TextField.d.ts +7 -0
- package/Autocomplete2/Autocomplete2TextField.js +39 -0
- package/Autocomplete2/index.d.ts +2 -0
- package/Autocomplete2/index.js +7 -0
- package/Avatar/AvatarBase.d.ts +4 -4
- package/Avatar/index.js +1 -1
- package/Badge/BadgeBase.d.ts +4 -4
- package/Badge/BadgeDeleteButton.js +6 -6
- package/Badge/BadgeOutlined.js +2 -2
- package/Badge/BadgeStandard.js +1 -1
- package/Button/ButtonBase.d.ts +3 -3
- package/Button/ButtonOutlined.js +1 -1
- package/Button/ButtonPlain.js +1 -1
- package/Button/ButtonStandard.js +4 -11
- package/Calendar/CalendarCell.js +22 -4
- package/Calendar/CalendarComponent.d.ts +226 -0
- package/Calendar/CalendarComponent.js +572 -0
- package/Calendar/CalendarControlButton.js +16 -9
- package/Calendar/CalendarDayBadge.js +1 -1
- package/Calendar/CalendarEmptyCell.d.ts +2 -2
- package/Calendar/CalendarEmptyCell.js +8 -3
- package/Calendar/CalendarHeading.js +2 -1
- package/Calendar/CalendarMonthCell.js +0 -5
- package/Calendar/CalendarSubheading.js +3 -2
- package/Calendar/CalendarWeekDayCell.d.ts +10 -0
- package/Calendar/CalendarWeekDayCell.js +32 -0
- package/Calendar/CalendarWeekDayWeekNumber.d.ts +7 -0
- package/Calendar/CalendarWeekDayWeekNumber.js +38 -0
- package/Calendar/CalendarWeekRow.d.ts +2 -2
- package/Calendar/CalendarWeekRow.js +2 -1
- package/Calendar/CalendarWeekRowButton.d.ts +13 -0
- package/Calendar/CalendarWeekRowButton.js +31 -0
- package/Calendar/CalendarYearCell.js +5 -5
- package/Calendar/CalendarYearsSelector.d.ts +39 -1
- package/Calendar/CalendarYearsSelector.js +52 -16
- package/Calendar/IconChevronDown.d.ts +3 -0
- package/Calendar/IconChevronDown.js +31 -0
- package/Calendar/index.d.ts +7 -220
- package/Calendar/index.js +19 -274
- package/Calendar/use-calendar.d.ts +1 -1
- package/Calendar/use-calendar.js +102 -155
- package/Color/Color.d.ts +138 -0
- package/Color/Color.js +324 -0
- package/Color/ColorGenerator.d.ts +29 -0
- package/Color/ColorGenerator.js +141 -0
- package/Color/ColorParser.d.ts +20 -0
- package/Color/ColorParser.js +284 -0
- package/Color/index.d.ts +4 -122
- package/Color/index.js +18 -473
- package/DatePicker/index.d.ts +2 -17
- package/DatePicker/index.js +47 -61
- package/DatePicker/useDatePickerFormat.js +5 -5
- package/ErrorBoundary/Fallback.d.ts +3 -0
- package/ErrorBoundary/Fallback.js +51 -0
- package/ErrorBoundary/RenderError.d.ts +6 -0
- package/ErrorBoundary/RenderError.js +80 -0
- package/ErrorBoundary/index.d.ts +7 -11
- package/ErrorBoundary/index.js +4 -51
- package/Highlighted/index.d.ts +3 -3
- package/LoadingIndicator/Spinner.d.ts +5 -3
- package/LoadingIndicator/Spinner.js +61 -32
- package/LoadingIndicator/index.d.ts +3 -3
- package/LoadingIndicator/index.js +15 -2
- package/MaskedField/index.d.ts +1 -1
- package/MaskedField/index.js +11 -10
- package/Menu/AutoHeightWrapper.d.ts +6 -0
- package/Menu/AutoHeightWrapper.js +43 -0
- package/Menu/MeasuredItem.d.ts +10 -0
- package/Menu/MeasuredItem.js +51 -0
- package/Menu/MenuContainer.d.ts +53 -20
- package/Menu/MenuContainer.js +18 -11
- package/Menu/MenuItem.d.ts +24 -7
- package/Menu/MenuItem.js +13 -6
- package/Menu/MenuList.d.ts +4 -2
- package/Menu/MenuList.js +26 -6
- package/Menu/VirtualizedItem.d.ts +22 -0
- package/Menu/VirtualizedItem.js +69 -0
- package/Menu/VirtualizedList.d.ts +18 -0
- package/Menu/VirtualizedList.js +28 -0
- package/Menu/VirtualizedListComponent.d.ts +20 -0
- package/Menu/VirtualizedListComponent.js +305 -0
- package/Menu/index.d.ts +3 -1
- package/Menu/index.js +4 -7
- package/Modal/BaseModal/RenderModal.d.ts +3 -3
- package/Modal/BaseModal/index.d.ts +3 -3
- package/Modal/ConfirmBox/index.d.ts +5 -5
- package/Modal/Drawer/index.d.ts +5 -5
- package/Modal/MessageBox/index.d.ts +5 -5
- package/Popper/Popper.d.ts +148 -0
- package/Popper/Popper.js +113 -0
- package/Popper/PopperContainer.d.ts +2 -0
- package/Popper/PopperContainer.js +3 -6
- package/Popper/index.d.ts +5 -22
- package/Popper/index.js +18 -264
- package/Popper/usePopprer.d.ts +110 -0
- package/Popper/usePopprer.js +505 -0
- package/Selectbox/SelectboxButton.d.ts +5 -0
- package/Selectbox/SelectboxButton.js +48 -8
- package/Selectbox/SelectboxButtonWrapper.d.ts +2 -0
- package/Selectbox/SelectboxButtonWrapper.js +1 -17
- package/Selectbox/SelectboxMenu.d.ts +12 -0
- package/Selectbox/SelectboxMenu.js +50 -0
- package/Selectbox/index.d.ts +13 -13
- package/Selectbox/index.js +115 -97
- package/Surface/index.d.ts +5 -5
- package/Surface/index.js +1 -1
- package/Swiper/Swiper.d.ts +44 -0
- package/Swiper/Swiper.js +139 -0
- package/Swiper/SwiperContainer.d.ts +7 -0
- package/Swiper/SwiperContainer.js +14 -0
- package/Swiper/SwiperSlide.d.ts +7 -0
- package/Swiper/SwiperSlide.js +55 -0
- package/Swiper/SwiperTrack.d.ts +14 -0
- package/Swiper/SwiperTrack.js +58 -0
- package/Swiper/SwiperWrapper.d.ts +14 -0
- package/Swiper/SwiperWrapper.js +60 -0
- package/Swiper/index.d.ts +7 -0
- package/Swiper/index.js +26 -0
- package/Switch/SwitchDot.js +1 -1
- package/Switch/SwitchTrack.js +1 -1
- package/Switch/index.d.ts +8 -8
- package/TextArea/index.d.ts +7 -7
- package/TextField/TextFieldContainer.d.ts +2 -2
- package/TextField/TextFieldContainer.js +5 -3
- package/TextField/TextFieldErrorText.d.ts +2 -2
- package/TextField/TextFieldErrorText.js +5 -4
- package/TextField/TextFieldIconWrapper.d.ts +3 -3
- package/TextField/TextFieldIconWrapper.js +5 -3
- package/TextField/TextFieldInput.d.ts +2 -2
- package/TextField/TextFieldInput.js +6 -4
- package/TextField/TextFieldInputWrapper.d.ts +2 -2
- package/TextField/TextFieldInputWrapper.js +5 -3
- package/TextField/TextFieldLabel.d.ts +2 -2
- package/TextField/TextFieldLabel.js +5 -3
- package/TextField/TextFieldLabelAsterisk.d.ts +2 -2
- package/TextField/TextFieldLabelAsterisk.js +5 -3
- package/TextField/index.d.ts +15 -8
- package/TextField/index.js +49 -22
- package/ThemeProvider/createTheme.js +2 -2
- package/package.json +1 -1
- package/Calendar/reducer.d.ts +0 -14
- package/Calendar/reducer.js +0 -26
- /package/Calendar/{IconChevronRight.d.ts → CalendarIconNext.d.ts} +0 -0
- /package/Calendar/{IconChevronRight.js → CalendarIconNext.js} +0 -0
package/Menu/MenuContainer.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MenuListProps } from './MenuList';
|
|
3
|
-
import { AnchorPos, PopperProps } from '../Popper';
|
|
4
|
-
import type {
|
|
3
|
+
import { AnchorPos, PopperProps, PositionStrategy } from '../Popper';
|
|
4
|
+
import type { MenuItemProps } from './MenuItem';
|
|
5
5
|
export type AnchorElement<E extends HTMLElement = HTMLElement> = E;
|
|
6
6
|
export type Children<T> = (data: {
|
|
7
7
|
item: T;
|
|
8
8
|
index: number;
|
|
9
|
-
}, itemProps:
|
|
9
|
+
}, itemProps: MenuItemProps) => React.ReactNode;
|
|
10
10
|
export interface MenuProps<T, Multiple extends boolean | undefined = undefined> {
|
|
11
11
|
/**
|
|
12
12
|
* List of items
|
|
@@ -46,9 +46,9 @@ export interface MenuProps<T, Multiple extends boolean | undefined = undefined>
|
|
|
46
46
|
/**
|
|
47
47
|
* An HTML element. It's used to set the position of the menu.
|
|
48
48
|
* \
|
|
49
|
-
* **Default**: `
|
|
49
|
+
* **Default**: `null`
|
|
50
50
|
*/
|
|
51
|
-
readonly anchorElement
|
|
51
|
+
readonly anchorElement: AnchorElement | null;
|
|
52
52
|
/**
|
|
53
53
|
* A function that extract key for each item\
|
|
54
54
|
* (for details: [React List and keys](https://react.dev/learn/rendering-lists))\
|
|
@@ -66,7 +66,7 @@ export interface MenuProps<T, Multiple extends boolean | undefined = undefined>
|
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
68
|
/**
|
|
69
|
-
* Close list if click outside
|
|
69
|
+
* Close list if click outside the list and anchor element\
|
|
70
70
|
* \
|
|
71
71
|
* **Default**: `true`
|
|
72
72
|
*/
|
|
@@ -87,20 +87,52 @@ export interface MenuProps<T, Multiple extends boolean | undefined = undefined>
|
|
|
87
87
|
/**
|
|
88
88
|
* Anchor position\
|
|
89
89
|
* \
|
|
90
|
-
* Default: `
|
|
90
|
+
* Default: `bottom`
|
|
91
91
|
*/
|
|
92
92
|
readonly anchorPos?: AnchorPos;
|
|
93
|
+
readonly onAnchorPosChanged?: (anchorPos: AnchorPos) => void;
|
|
94
|
+
/**
|
|
95
|
+
* When enabled, the popper will automatically try to find the best placement
|
|
96
|
+
* if the preferred placement doesn't fit in the viewport.
|
|
97
|
+
* The component will iterate through possible placements until it finds one that fits.
|
|
98
|
+
*
|
|
99
|
+
* **Default**: `true`
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
readonly autoFlip?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Additional offset (in pixels) from the anchor element.
|
|
105
|
+
* Positive values move the popper away from the anchor, negative values move it closer.
|
|
106
|
+
*
|
|
107
|
+
* @default `0`
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
readonly offset?: number;
|
|
111
|
+
/**
|
|
112
|
+
* The positioning strategy to use.
|
|
113
|
+
* - `'fixed'`: Positions relative to the viewport. Works reliably in all cases.
|
|
114
|
+
* - `'absolute'`: Positions relative to the nearest positioned ancestor.
|
|
115
|
+
* When using 'absolute', make sure a parent element has `position: relative`.
|
|
116
|
+
*
|
|
117
|
+
* **Default**: `'`absolute`'`
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
readonly positionStrategy?: PositionStrategy;
|
|
121
|
+
/**
|
|
122
|
+
* Minimum distance (in pixels) that the popper must maintain from the viewport edges.
|
|
123
|
+
* Used to prevent the popper from being positioned too close to the screen boundaries.
|
|
124
|
+
* The popper will try to flip to another placement if it cannot maintain this margin.
|
|
125
|
+
*
|
|
126
|
+
* **Default**: `8`
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
readonly viewportMargin?: number;
|
|
93
130
|
/**
|
|
94
131
|
* Should menu will be closed when item selected\
|
|
95
132
|
* \
|
|
96
133
|
* **Default**: if **multiple** is true then `false` otherwise - `true`
|
|
97
134
|
*/
|
|
98
135
|
readonly closeOnSelect?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Do not use react portal\
|
|
101
|
-
* \
|
|
102
|
-
* **Default**: `false`
|
|
103
|
-
*/
|
|
104
136
|
/**
|
|
105
137
|
* Popper z-index\
|
|
106
138
|
* \
|
|
@@ -137,11 +169,11 @@ export interface MenuOverrides {
|
|
|
137
169
|
/**
|
|
138
170
|
* Element wrapper
|
|
139
171
|
*/
|
|
140
|
-
readonly List?: React.
|
|
172
|
+
readonly List?: React.ComponentType<MenuListProps & React.RefAttributes<HTMLDivElement>>;
|
|
141
173
|
/**
|
|
142
174
|
* Popper wrapper
|
|
143
175
|
*/
|
|
144
|
-
readonly Popper?: React.
|
|
176
|
+
readonly Popper?: React.ComponentType<PopperProps & React.RefAttributes<HTMLDivElement>>;
|
|
145
177
|
}
|
|
146
178
|
export type MenuRef = {
|
|
147
179
|
/**
|
|
@@ -161,33 +193,34 @@ export type MenuRef = {
|
|
|
161
193
|
*/
|
|
162
194
|
selectItem: (index: number) => void;
|
|
163
195
|
/**
|
|
164
|
-
*
|
|
196
|
+
* Highlight specified item by index
|
|
165
197
|
*/
|
|
166
198
|
highlightIndex: (index: number) => void;
|
|
167
199
|
/**
|
|
168
200
|
* Highlight the previous item relative to the currently highlighted one
|
|
169
201
|
*/
|
|
170
|
-
|
|
202
|
+
highlightPrevItem: () => void;
|
|
171
203
|
/**
|
|
172
204
|
* Highlight the next item relative to the currently highlighted one
|
|
173
205
|
*/
|
|
174
|
-
|
|
206
|
+
highlightNextItem: () => void;
|
|
175
207
|
/**
|
|
176
208
|
* Highlight the first item in list
|
|
177
209
|
*/
|
|
178
|
-
|
|
210
|
+
highlightFirstItem: () => void;
|
|
179
211
|
/**
|
|
180
212
|
* Highlight the last item in list
|
|
181
213
|
*/
|
|
182
|
-
|
|
214
|
+
highlightLastItem: () => void;
|
|
183
215
|
/**
|
|
184
216
|
* Select highlighted item in list
|
|
185
217
|
*/
|
|
186
|
-
|
|
218
|
+
selectHighlightedItem: () => void;
|
|
187
219
|
/**
|
|
188
220
|
* Returns the list HTML container
|
|
189
221
|
*/
|
|
190
222
|
getListElement: () => HTMLDivElement | null;
|
|
223
|
+
setActualPlacement: (placement: AnchorPos) => void;
|
|
191
224
|
};
|
|
192
225
|
export type Value<T, Multiple> = Multiple extends undefined | undefined ? T | null : readonly T[];
|
|
193
226
|
export type GetOptionSelected<T> = (payload: {
|
package/Menu/MenuContainer.js
CHANGED
|
@@ -33,7 +33,8 @@ const Popper_1 = __importDefault(require("../Popper"));
|
|
|
33
33
|
const ClickOutside_1 = __importDefault(require("../ClickOutside"));
|
|
34
34
|
const onRequestCloseDefault = () => undefined;
|
|
35
35
|
const MenuContainer = react_1.default.forwardRef((props, ref) => {
|
|
36
|
-
const { items, value, anchorElement, overrides, children, closeOutsideClick = true, isOpen =
|
|
36
|
+
const { items, value, anchorElement = null, overrides, children, closeOutsideClick = true, isOpen = false, anchorPos = 'bottom', positionStrategy, autoFlip, viewportMargin, offset, multiple = false, autofocus = true, closeOnSelect = !multiple, onRequestClose = onRequestCloseDefault, onAnchorPosChanged, zIndex, onSelectItem, getOptionSelected, } = props;
|
|
37
|
+
const [actualPlacement, setActualPlacement] = react_1.default.useState(anchorPos);
|
|
37
38
|
const overridesMap = react_1.default.useMemo(() => ({
|
|
38
39
|
List: (overrides === null || overrides === void 0 ? void 0 : overrides.List) || MenuList_1.default,
|
|
39
40
|
Popper: (overrides === null || overrides === void 0 ? void 0 : overrides.Popper) || Popper_1.default,
|
|
@@ -187,14 +188,15 @@ const MenuContainer = react_1.default.forwardRef((props, ref) => {
|
|
|
187
188
|
focus: () => { var _a; return (_a = menuListRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
188
189
|
scrollToIndex: (idx) => scrollToIndex(idx),
|
|
189
190
|
highlightIndex: (idx) => highlightIndex(idx),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
highlightPrevItem: () => hightlightPrevItem(),
|
|
192
|
+
highlightNextItem: () => hightlightNextItem(),
|
|
193
|
+
highlightFirstItem: () => hightlightFirstItem(),
|
|
194
|
+
highlightLastItem: () => hightlightLastItem(),
|
|
194
195
|
scrollToFirstSelected: () => scrollToFirstSelected(),
|
|
195
|
-
|
|
196
|
+
selectHighlightedItem: () => selectHightlightedItem(),
|
|
196
197
|
selectItem: (idx) => selectItem(idx),
|
|
197
198
|
getListElement: () => menuListRef.current,
|
|
199
|
+
setActualPlacement: placement => setActualPlacement(placement),
|
|
198
200
|
}), [
|
|
199
201
|
scrollToIndex,
|
|
200
202
|
highlightIndex,
|
|
@@ -324,9 +326,9 @@ const MenuContainer = react_1.default.forwardRef((props, ref) => {
|
|
|
324
326
|
*/
|
|
325
327
|
react_1.default.useEffect(() => {
|
|
326
328
|
const indexes = getSelectedIndexes();
|
|
327
|
-
// If elements in selectedIndexesRef and indexes are not
|
|
328
|
-
if ((selectedIndexesRef.current.length === indexes.length &&
|
|
329
|
-
selectedIndexesRef.current.every(value => indexes.includes(value)))
|
|
329
|
+
// If elements in selectedIndexesRef and indexes are not equal
|
|
330
|
+
if (!(selectedIndexesRef.current.length === indexes.length &&
|
|
331
|
+
selectedIndexesRef.current.every(value => indexes.includes(value)))) {
|
|
330
332
|
selectedIndexesRef.current = indexes;
|
|
331
333
|
dispatch({
|
|
332
334
|
type: 'setMenuState',
|
|
@@ -356,8 +358,13 @@ const MenuContainer = react_1.default.forwardRef((props, ref) => {
|
|
|
356
358
|
}
|
|
357
359
|
}, [dispatch]);
|
|
358
360
|
return (react_1.default.createElement(ClickOutside_1.default, { onOutsideClick: onRequestClose, mouseEvent: closeOutsideClick ? 'onMouseDown' : false },
|
|
359
|
-
react_1.default.createElement(overridesMap.Popper, { isOpen: Boolean(isOpen), ref: menuPopperRef,
|
|
360
|
-
|
|
361
|
+
react_1.default.createElement(overridesMap.Popper, { isOpen: Boolean(isOpen), ref: menuPopperRef, zIndex: zIndex, anchorPos: actualPlacement, anchorElement: anchorElement, onAnchorPosChanged: newPlacement => {
|
|
362
|
+
setActualPlacement(newPlacement);
|
|
363
|
+
if (typeof onAnchorPosChanged === 'function') {
|
|
364
|
+
onAnchorPosChanged(newPlacement);
|
|
365
|
+
}
|
|
366
|
+
}, positionStrategy: positionStrategy, autoFlip: autoFlip, viewportMargin: viewportMargin, offset: offset },
|
|
367
|
+
react_1.default.createElement(overridesMap.List, { anchorPos: actualPlacement, isOpen: Boolean(isOpen), ref: menuListRef, onKeyDown: listKeydownEvent }, items.map((item, index) => children({
|
|
361
368
|
item,
|
|
362
369
|
index,
|
|
363
370
|
}, {
|
package/Menu/MenuItem.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export type MenuItemProps = React.HTMLAttributes<HTMLDivElement> &
|
|
3
|
-
export type MenuItemCommonProps = {
|
|
2
|
+
export type MenuItemProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
4
3
|
/**
|
|
5
4
|
* Selected flag
|
|
6
5
|
*/
|
|
@@ -13,13 +12,31 @@ export type MenuItemCommonProps = {
|
|
|
13
12
|
* React key
|
|
14
13
|
*/
|
|
15
14
|
readonly key: React.Key;
|
|
16
|
-
readonly onMouseEnter: React.MouseEventHandler<HTMLDivElement>;
|
|
17
|
-
readonly onMouseLeave: React.MouseEventHandler<HTMLDivElement>;
|
|
18
|
-
readonly onClick: React.MouseEventHandler<HTMLDivElement>;
|
|
19
15
|
/**
|
|
20
16
|
* Icon or another JSX element placed before button label
|
|
21
17
|
*/
|
|
22
|
-
readonly startIcon?:
|
|
18
|
+
readonly startIcon?: React.ReactNode;
|
|
23
19
|
};
|
|
24
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `MenuItemProps` instead
|
|
22
|
+
*/
|
|
23
|
+
export type MenuItemCommonProps = MenuItemProps;
|
|
24
|
+
export declare const MenuItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
25
|
+
/**
|
|
26
|
+
* Selected flag
|
|
27
|
+
*/
|
|
28
|
+
readonly selected: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Hovered flag
|
|
31
|
+
*/
|
|
32
|
+
readonly hovered: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* React key
|
|
35
|
+
*/
|
|
36
|
+
readonly key: React.Key;
|
|
37
|
+
/**
|
|
38
|
+
* Icon or another JSX element placed before button label
|
|
39
|
+
*/
|
|
40
|
+
readonly startIcon?: React.ReactNode;
|
|
41
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
42
|
export default MenuItem;
|
package/Menu/MenuItem.js
CHANGED
|
@@ -14,10 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MenuItem = void 0;
|
|
17
18
|
const react_1 = __importDefault(require("react"));
|
|
18
19
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
20
|
const react_2 = require("@emotion/react");
|
|
20
|
-
const
|
|
21
|
+
const StyledMenuItem = styled_1.default.div `
|
|
21
22
|
cursor: pointer;
|
|
22
23
|
user-select: none;
|
|
23
24
|
display: flex;
|
|
@@ -53,11 +54,17 @@ const InnerContainer = styled_1.default.div `
|
|
|
53
54
|
const ItemIconWrapper = styled_1.default.span `
|
|
54
55
|
margin-right: 0.5em;
|
|
55
56
|
`;
|
|
56
|
-
|
|
57
|
+
exports.MenuItem = react_1.default.forwardRef((props, ref) => {
|
|
57
58
|
const { children, selected, hovered, onMouseEnter, onMouseLeave, onClick, startIcon } = props, nativeProps = __rest(props, ["children", "selected", "hovered", "onMouseEnter", "onMouseLeave", "onClick", "startIcon"]);
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const renderStartIcon = react_1.default.useCallback(() => {
|
|
60
|
+
if (!startIcon) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return react_1.default.createElement(ItemIconWrapper, null, startIcon);
|
|
64
|
+
}, [startIcon]);
|
|
65
|
+
return (react_1.default.createElement(StyledMenuItem, Object.assign({}, nativeProps, { ref: ref, onMouseLeave: onMouseLeave, onMouseEnter: onMouseEnter, onClick: onClick, selected: selected, hovered: hovered }),
|
|
66
|
+
renderStartIcon(),
|
|
60
67
|
children));
|
|
61
68
|
});
|
|
62
|
-
MenuItem.displayName = 'MenuItem';
|
|
63
|
-
exports.default = MenuItem;
|
|
69
|
+
exports.MenuItem.displayName = 'MenuItem';
|
|
70
|
+
exports.default = exports.MenuItem;
|
package/Menu/MenuList.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AnchorPos } from '../Popper';
|
|
2
3
|
export interface MenuListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
readonly isOpen: boolean;
|
|
5
|
+
readonly anchorPos: AnchorPos;
|
|
4
6
|
}
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
7
|
+
export declare const MenuList: React.ForwardRefExoticComponent<MenuListProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export default MenuList;
|
package/Menu/MenuList.js
CHANGED
|
@@ -14,8 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MenuList = void 0;
|
|
17
18
|
const react_1 = __importDefault(require("react"));
|
|
18
19
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
20
|
+
const react_2 = require("@emotion/react");
|
|
19
21
|
const StyledMenuList = styled_1.default.div `
|
|
20
22
|
display: flex;
|
|
21
23
|
flex-direction: column;
|
|
@@ -23,12 +25,14 @@ const StyledMenuList = styled_1.default.div `
|
|
|
23
25
|
opacity: ${props => (props.$isOpen ? 1 : 0)};
|
|
24
26
|
background-color: ${({ theme }) => theme.color.surface.toString()};
|
|
25
27
|
border-radius: ${({ theme }) => theme.shape.radiusFactor * 2}em;
|
|
26
|
-
box-shadow: 0
|
|
28
|
+
box-shadow: 0 0.5em 1.5em ${({ theme }) => theme.color.surface.darken(50).alpha(0.6).toString()};
|
|
29
|
+
|
|
27
30
|
&:focus {
|
|
28
31
|
outline-style: solid;
|
|
29
32
|
outline-width: 0.14em;
|
|
30
33
|
outline-color: ${({ theme }) => theme.color.accentPrimary.toString()};
|
|
31
34
|
}
|
|
35
|
+
|
|
32
36
|
& ::-webkit-scrollbar {
|
|
33
37
|
width: 0.6rem;
|
|
34
38
|
height: 0.6rem;
|
|
@@ -55,13 +59,29 @@ const StyledMenuList = styled_1.default.div `
|
|
|
55
59
|
& ::-webkit-scrollbar-thumb:vertical:hover {
|
|
56
60
|
background: ${({ theme }) => theme.color.accentPrimary.toString()};
|
|
57
61
|
}
|
|
62
|
+
|
|
58
63
|
box-sizing: border-box;
|
|
59
64
|
overflow-y: auto;
|
|
60
65
|
padding: 0.4em;
|
|
61
66
|
max-height: 18em;
|
|
67
|
+
min-width: 10em;
|
|
68
|
+
|
|
69
|
+
max-width: 100%;
|
|
70
|
+
|
|
71
|
+
${({ $fixedWidth }) => $fixedWidth &&
|
|
72
|
+
(0, react_2.css) `
|
|
73
|
+
min-width: 10em;
|
|
74
|
+
max-width: 16em;
|
|
75
|
+
`}
|
|
76
|
+
|
|
77
|
+
${({ $anchorPos, theme }) => $anchorPos === 'top-fill' &&
|
|
78
|
+
(0, react_2.css) `
|
|
79
|
+
box-shadow: 0 -0.5em 1.5em ${theme.color.surface.darken(50).alpha(0.6).toString()};
|
|
80
|
+
`};
|
|
62
81
|
`;
|
|
63
|
-
|
|
64
|
-
const { isOpen, children } = props, nativeProps = __rest(props, ["isOpen", "children"]);
|
|
65
|
-
return (react_1.default.createElement(StyledMenuList, Object.assign({ tabIndex: -1, "$isOpen": isOpen }, nativeProps, { ref: ref }), children));
|
|
66
|
-
};
|
|
67
|
-
exports.
|
|
82
|
+
exports.MenuList = react_1.default.forwardRef((props, ref) => {
|
|
83
|
+
const { isOpen, anchorPos, children } = props, nativeProps = __rest(props, ["isOpen", "anchorPos", "children"]);
|
|
84
|
+
return (react_1.default.createElement(StyledMenuList, Object.assign({ tabIndex: -1, "$isOpen": isOpen, "$anchorPos": anchorPos, "$fixedWidth": !['bottom-fill', 'top-fill'].includes(anchorPos) }, nativeProps, { ref: ref }), children));
|
|
85
|
+
});
|
|
86
|
+
exports.MenuList.displayName = 'MenuList';
|
|
87
|
+
exports.default = exports.MenuList;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type VirtualizedItemProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly index: number;
|
|
5
|
+
readonly style: React.CSSProperties;
|
|
6
|
+
readonly setItemHeight: (index: number, height: number) => void;
|
|
7
|
+
readonly isActiveOnScroll: boolean;
|
|
8
|
+
readonly children: VirtualizedItemChildren;
|
|
9
|
+
};
|
|
10
|
+
export type VirtualizedItemChildren = (params: {
|
|
11
|
+
readonly index: number;
|
|
12
|
+
readonly isActiveOnScroll: boolean;
|
|
13
|
+
}) => React.ReactNode;
|
|
14
|
+
export declare const VirtualizedItem: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
15
|
+
readonly key: string;
|
|
16
|
+
readonly index: number;
|
|
17
|
+
readonly style: React.CSSProperties;
|
|
18
|
+
readonly setItemHeight: (index: number, height: number) => void;
|
|
19
|
+
readonly isActiveOnScroll: boolean;
|
|
20
|
+
readonly children: VirtualizedItemChildren;
|
|
21
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export default VirtualizedItem;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.VirtualizedItem = void 0;
|
|
41
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
42
|
+
const React = __importStar(require("react"));
|
|
43
|
+
const StyledVirtualizedItem = styled_1.default.div `
|
|
44
|
+
position: absolute;
|
|
45
|
+
width: 100%;
|
|
46
|
+
`;
|
|
47
|
+
exports.VirtualizedItem = React.forwardRef((props, ref) => {
|
|
48
|
+
const { children, style, index, setItemHeight, isActiveOnScroll } = props, restProps = __rest(props, ["children", "style", "index", "setItemHeight", "isActiveOnScroll"]);
|
|
49
|
+
const containerRef = React.useRef(null);
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
const el = containerRef.current;
|
|
52
|
+
if (!el)
|
|
53
|
+
return;
|
|
54
|
+
const observer = new ResizeObserver(entries => {
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
const { height } = entry.contentRect;
|
|
57
|
+
if (height) {
|
|
58
|
+
setItemHeight(index, height);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
observer.observe(el);
|
|
63
|
+
return () => observer.disconnect();
|
|
64
|
+
}, [index, setItemHeight]);
|
|
65
|
+
return (React.createElement(StyledVirtualizedItem, Object.assign({ style: style }, restProps, { ref: ref }),
|
|
66
|
+
React.createElement("div", { ref: containerRef }, children({ index, isActiveOnScroll }))));
|
|
67
|
+
});
|
|
68
|
+
exports.VirtualizedItem.displayName = 'VirtualizedItem';
|
|
69
|
+
exports.default = exports.VirtualizedItem;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VirtualizedListRef, VirtualizedRenderItem } from './VirtualizedListComponent';
|
|
3
|
+
export type ScrollAlign = 'start' | 'center' | 'end' | 'auto';
|
|
4
|
+
export * from './VirtualizedListComponent';
|
|
5
|
+
export type VirtualizedListProps<T> = {
|
|
6
|
+
readonly items: readonly T[];
|
|
7
|
+
readonly renderItem: VirtualizedRenderItem<T>;
|
|
8
|
+
readonly estimatedItemHeight?: number;
|
|
9
|
+
readonly itemHeight?: number;
|
|
10
|
+
readonly overscan?: number;
|
|
11
|
+
readonly scrollToIndex?: number | null;
|
|
12
|
+
readonly scrollToAlign?: ScrollAlign;
|
|
13
|
+
readonly onEndReached?: () => void;
|
|
14
|
+
};
|
|
15
|
+
declare const _default: <T>(props: VirtualizedListProps<T> & {
|
|
16
|
+
ref?: React.Ref<VirtualizedListRef> | undefined;
|
|
17
|
+
}) => React.ReactElement;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const react_1 = __importDefault(require("react"));
|
|
21
|
+
const AutoHeightWrapper_1 = __importDefault(require("./AutoHeightWrapper"));
|
|
22
|
+
const VirtualizedListComponent_1 = __importDefault(require("./VirtualizedListComponent"));
|
|
23
|
+
__exportStar(require("./VirtualizedListComponent"), exports);
|
|
24
|
+
const VirtualizedList = react_1.default.forwardRef((props, ref) => {
|
|
25
|
+
return (react_1.default.createElement(AutoHeightWrapper_1.default, null, height => height > 0 && react_1.default.createElement(VirtualizedListComponent_1.default, Object.assign({}, props, { height: height, ref: ref }))));
|
|
26
|
+
});
|
|
27
|
+
VirtualizedList.displayName = 'VirtualizedList';
|
|
28
|
+
exports.default = VirtualizedList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type VirtualizedRenderItem<T> = (item: T, index: number) => React.ReactNode;
|
|
3
|
+
export type VirtualizedListComponentProp<T> = {
|
|
4
|
+
readonly items: readonly T[];
|
|
5
|
+
readonly height: number;
|
|
6
|
+
readonly renderItem: VirtualizedRenderItem<T>;
|
|
7
|
+
readonly estimatedItemHeight?: number;
|
|
8
|
+
readonly itemHeight?: number;
|
|
9
|
+
readonly overscan?: number;
|
|
10
|
+
readonly scrollToIndex?: number | null;
|
|
11
|
+
readonly scrollToAlign?: ScrollAlign;
|
|
12
|
+
readonly onEndReached?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type ScrollAlign = 'start' | 'center' | 'end' | 'auto';
|
|
15
|
+
export type VirtualizedListRef = {
|
|
16
|
+
scrollToIndex: (index: number, align?: ScrollAlign) => void;
|
|
17
|
+
getTopVisibleIndex: () => number;
|
|
18
|
+
};
|
|
19
|
+
declare const VirtualizedListComponent: React.ForwardRefExoticComponent<VirtualizedListComponentProp<unknown> & React.RefAttributes<VirtualizedListRef>>;
|
|
20
|
+
export default VirtualizedListComponent;
|