@geneui/components 2.11.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/ActionableList.js +1761 -0
- package/AdvancedSearch.js +872 -0
- package/Alert.js +98 -0
- package/Avatar.js +77 -0
- package/Badge.js +76 -0
- package/Breadcrumb.js +128 -0
- package/BusyLoader.js +69 -0
- package/Button.js +130 -0
- package/CHANGELOG.md +424 -0
- package/Card.js +513 -0
- package/CardList.js +705 -0
- package/CellMeasurerCache-c11cec83.js +229 -0
- package/Charts.js +99 -0
- package/Checkbox.js +232 -0
- package/CheckboxGroup.js +206 -0
- package/CheckboxGroupWithSearch.js +279 -0
- package/Collapse.js +196 -0
- package/ColorPicker.js +210 -0
- package/ComboBox.js +99 -0
- package/Counter.js +99 -0
- package/DateFilter.js +179 -0
- package/DatePicker.js +1231 -0
- package/DatePickerInput.js +30 -0
- package/Divider.js +56 -0
- package/Drawer.js +264 -0
- package/Dropdown.js +99 -0
- package/Editor.js +22965 -0
- package/Empty.js +132 -0
- package/ExtendedInput.js +578 -0
- package/Form.js +116 -0
- package/FormContainer.js +189 -0
- package/FormableCheckbox.js +27 -0
- package/FormableDatePicker.js +39 -0
- package/FormableDropdown.js +105 -0
- package/FormableEditor.js +24 -0
- package/FormableHOC-21051057.js +83 -0
- package/FormableMultiSelectDropdown.js +105 -0
- package/FormableNumberInput.js +31 -0
- package/FormableRadio.js +23 -0
- package/FormableSwitcher.js +23 -0
- package/FormableTextInput.js +31 -0
- package/FormableUploader.js +40 -0
- package/GeneUIProvider.js +256 -0
- package/Grid.js +166 -0
- package/Holder.js +99 -0
- package/Icon.js +63 -0
- package/Image.js +130 -0
- package/ImagePreview.js +99 -0
- package/KeyValue.js +63 -0
- package/Label.js +58 -0
- package/LinkButton.js +104 -0
- package/Menu.js +277 -0
- package/MobileNavigation.js +95 -0
- package/MobilePopup.js +180 -0
- package/Modal.js +251 -0
- package/ModuleTitle.js +99 -0
- package/NavigationMenu.js +212 -0
- package/Notification.js +120 -0
- package/Option.js +186 -0
- package/Overlay.js +99 -0
- package/Overspread.js +343 -0
- package/Pagination.js +258 -0
- package/Paper.js +97 -0
- package/Popover-f4d1cac0.js +411 -0
- package/Popover.js +20 -0
- package/PopoverV2.js +19 -0
- package/Portal.js +58 -0
- package/Products.js +115 -0
- package/Profile.js +99 -0
- package/Progress.js +200 -0
- package/QRCode.js +816 -0
- package/README.md +90 -0
- package/Radio.js +152 -0
- package/RadioGroup.js +105 -0
- package/Range.js +14 -0
- package/RichEditor-b7928765.js +228 -0
- package/RichEditor.js +13 -0
- package/Scrollbar.js +1587 -0
- package/Search.js +72 -0
- package/SearchWithDropdown.js +195 -0
- package/Section.js +62 -0
- package/SkeletonLoader.js +82 -0
- package/Slider.js +256 -0
- package/Status.js +104 -0
- package/Steps.js +312 -0
- package/SuggestionList.js +15 -0
- package/Switcher.js +194 -0
- package/Table.js +102 -0
- package/TableCompositions.js +17028 -0
- package/Tabs.js +236 -0
- package/Tag.js +103 -0
- package/TextLink.js +22 -0
- package/Textarea.js +239 -0
- package/Time.js +63 -0
- package/TimePicker.js +99 -0
- package/Timeline.js +114 -0
- package/Title.js +66 -0
- package/Toaster.js +116 -0
- package/Tooltip.js +157 -0
- package/TransferList.js +502 -0
- package/Uploader.js +32 -0
- package/ValidatableCheckbox.js +126 -0
- package/ValidatableDatePicker.js +312 -0
- package/ValidatableDropdown.js +99 -0
- package/ValidatableElements.js +99 -0
- package/ValidatableMultiSelectDropdown.js +99 -0
- package/ValidatableNumberInput.js +194 -0
- package/ValidatableRadio.js +117 -0
- package/ValidatableSwitcher.js +94 -0
- package/ValidatableTextInput.js +164 -0
- package/ValidatableTimeInput.js +171 -0
- package/ValidatableUploader.js +94 -0
- package/Widget.js +99 -0
- package/_commonjsHelpers-24198af3.js +35 -0
- package/_rollupPluginBabelHelpers-e8fb2e5c.js +16 -0
- package/checkTimeValidation-e56771be.js +16 -0
- package/checkboxRadioSwitcher-5b69d7bd.js +4 -0
- package/clsx.m-2bb6df4b.js +3 -0
- package/configs-91c86664.js +96 -0
- package/configs.js +131 -0
- package/dateValidation-67caec66.js +225 -0
- package/debounce-4419bc2f.js +17 -0
- package/globalStyling-9c60a159.js +4 -0
- package/guid-8ddf77b3.js +16 -0
- package/index-00fe8887.js +193 -0
- package/index-0cf65939.js +30991 -0
- package/index-122432cd.js +270 -0
- package/index-262edd7a.js +77 -0
- package/index-5cea9a7d.js +407 -0
- package/index-5e722d91.js +867 -0
- package/index-67f4d4d1.js +6568 -0
- package/index-6ff23041.js +66 -0
- package/index-702bf24a.js +1938 -0
- package/index-a4635754.js +329 -0
- package/index-a59530cd.js +4 -0
- package/index-ac59cb10.js +169 -0
- package/index-b7a33c58.js +11 -0
- package/index-d9e8a888.js +987 -0
- package/index-e0af0caf.js +1182 -0
- package/index-e8776f3d.js +807 -0
- package/index.js +128 -0
- package/localization-4ba17032.js +46 -0
- package/objectWithoutPropertiesLoose-299691d8.js +78 -0
- package/package.json +190 -0
- package/rangeAndSlider-20599da4.js +8839 -0
- package/react-beautiful-dnd.esm-38c37304.js +10117 -0
- package/style-inject.es-746bb8ed.js +28 -0
- package/useClickOutside-5183e396.js +25 -0
- package/useDeviceType-dd51db38.js +15 -0
- package/useEllipsisDetection-ef536015.js +23 -0
- package/useKeyDown-38102ae7.js +21 -0
- package/useMount-6fef51a5.js +9 -0
- package/useWidth-9f4647f8.js +15 -0
- package/useWindowSize-80369d76.js +33 -0
package/Menu.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { _ as _extends } from './_rollupPluginBabelHelpers-e8fb2e5c.js';
|
|
2
|
+
import React__default, { forwardRef, useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
import { p as propTypesExports } from './index-e0af0caf.js';
|
|
4
|
+
import { s as screenTypes } from './configs-91c86664.js';
|
|
5
|
+
import { c as classnames } from './index-6ff23041.js';
|
|
6
|
+
import Option from './Option.js';
|
|
7
|
+
import CustomScrollbar from './Scrollbar.js';
|
|
8
|
+
import './globalStyling-9c60a159.js';
|
|
9
|
+
import { s as styleInject } from './style-inject.es-746bb8ed.js';
|
|
10
|
+
import './dateValidation-67caec66.js';
|
|
11
|
+
import './_commonjsHelpers-24198af3.js';
|
|
12
|
+
import 'react-dom';
|
|
13
|
+
import './useDeviceType-dd51db38.js';
|
|
14
|
+
import './useWindowSize-80369d76.js';
|
|
15
|
+
import './useEllipsisDetection-ef536015.js';
|
|
16
|
+
import './Tooltip.js';
|
|
17
|
+
import './Popover-f4d1cac0.js';
|
|
18
|
+
import './index-ac59cb10.js';
|
|
19
|
+
import './GeneUIProvider.js';
|
|
20
|
+
import './Icon.js';
|
|
21
|
+
|
|
22
|
+
const findDeep = function (data, indexStack) {
|
|
23
|
+
let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
24
|
+
return index < indexStack.length ? findDeep(data[indexStack[index]].children, indexStack, index + 1) : data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var css_248z = "[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper{min-width:18rem;overflow:hidden;white-space:nowrap;width:100%}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper>ul{display:flex;min-width:100%;transform:translateX(calc(var(--translate-x)*-1));transition:transform .3s}html[dir=rtl] .menu-items-wrapper>ul{transform:translateX(var(--translate-x))}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper>ul.reversed>li:first-child{order:0}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper>ul.reversed>li:nth-child(2){order:2}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper>ul.reversed>li:nth-child(3){order:1}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper>ul>li{display:flex;flex-direction:column;flex-shrink:0;width:100%}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .divider.type-horizontal{margin:0;width:100%}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .divider.type-horizontal.full-width{margin:1rem 0;width:100%}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item{align-items:center;cursor:pointer;display:flex;font:600 1.4rem/2rem var(--font-family);padding:1rem 1.4rem;transition:color .3s,background .3s}[data-gene-ui-version=\"2.11.0\"] .popover-positioner.mobile-view .menu-items-wrapper .menu-item{padding:1.4rem 2rem}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item.highlighted{color:var(--hero)}@media (hover:hover){[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item:hover{background:rgba(var(--background-sc-rgb),.05)}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item.act-direction:hover{background:var(--hero);color:var(--hero-sc)}}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item .icon{margin:-.2rem 0}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item .icon.menu-custom-icon{margin-inline-end:1rem}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-item.header{flex-direction:row-reverse}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-text{flex:auto}[data-gene-ui-version=\"2.11.0\"] .menu-items-wrapper .menu-text .small-text{font-size:1.2rem;line-height:1.4rem;opacity:.7}";
|
|
28
|
+
styleInject(css_248z);
|
|
29
|
+
|
|
30
|
+
const Menu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
31
|
+
var _activeElementRef$cur2;
|
|
32
|
+
let {
|
|
33
|
+
data,
|
|
34
|
+
onBack,
|
|
35
|
+
toggle,
|
|
36
|
+
onNext,
|
|
37
|
+
onSelect,
|
|
38
|
+
screenType,
|
|
39
|
+
scrollToActiveElement,
|
|
40
|
+
initialIndexStack,
|
|
41
|
+
...restProps
|
|
42
|
+
} = _ref;
|
|
43
|
+
const initialHeader = useMemo(() => initialIndexStack === null || initialIndexStack === void 0 ? void 0 : initialIndexStack.reduce((headerItem, stackIndex, index) => {
|
|
44
|
+
const nextItem = headerItem ? headerItem[stackIndex] : data[stackIndex];
|
|
45
|
+
const isLast = index === initialIndexStack.length - 1;
|
|
46
|
+
return isLast ? nextItem : nextItem.children;
|
|
47
|
+
}, null), [initialIndexStack, data]);
|
|
48
|
+
const [header, setHeader] = useState(initialHeader);
|
|
49
|
+
const [indexStack, setIndexStack] = useState(initialIndexStack !== null && initialIndexStack !== void 0 ? initialIndexStack : []);
|
|
50
|
+
const listRef = useRef(null);
|
|
51
|
+
const activeElementRef = useRef(null);
|
|
52
|
+
const [scrollTopGap, setScrollTopGap] = useState(0);
|
|
53
|
+
const layer = useMemo(() => findDeep(data === null || data === void 0 ? void 0 : data.filter(item => item), indexStack), [data, indexStack]);
|
|
54
|
+
|
|
55
|
+
// Scroll to active element
|
|
56
|
+
const [activeElementTop, setActiveElementTop] = useState(null);
|
|
57
|
+
const [allowScroll, setAllowScroll] = useState(false);
|
|
58
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
59
|
+
const [scrollWithArrowKey, setScrollWithArrowKey] = useState(false);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (allowScroll || scrollWithArrowKey) {
|
|
62
|
+
var _activeElementRef$cur;
|
|
63
|
+
setActiveElementTop((activeElementRef === null || activeElementRef === void 0 ? void 0 : (_activeElementRef$cur = activeElementRef.current) === null || _activeElementRef$cur === void 0 ? void 0 : _activeElementRef$cur.offsetTop) - scrollTopGap);
|
|
64
|
+
setAllowScroll(false);
|
|
65
|
+
setScrollWithArrowKey(false);
|
|
66
|
+
}
|
|
67
|
+
}, [allowScroll, indexStack, activeElementRef === null || activeElementRef === void 0 ? void 0 : (_activeElementRef$cur2 = activeElementRef.current) === null || _activeElementRef$cur2 === void 0 ? void 0 : _activeElementRef$cur2.offsetTop, scrollTopGap, scrollWithArrowKey]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
var _listRef$current;
|
|
70
|
+
if (!isScrolled && (listRef === null || listRef === void 0 ? void 0 : (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.container.firstChild.children.length) === layer.length) {
|
|
71
|
+
setAllowScroll(true);
|
|
72
|
+
setIsScrolled(true);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const [prevHeader, setPrevHeader] = useState([]);
|
|
76
|
+
const handleClick = useCallback((e, item, isHeader, index) => {
|
|
77
|
+
setWithSmoothScroll(false);
|
|
78
|
+
setAllowScroll(true);
|
|
79
|
+
setHoverIndex(null);
|
|
80
|
+
setScrollTopGap(item !== null && item !== void 0 && item.scrollTopGap ? item === null || item === void 0 ? void 0 : item.scrollTopGap : 0);
|
|
81
|
+
if (isHeader) {
|
|
82
|
+
setIndexStack(indexStack.slice(0, -1));
|
|
83
|
+
setPrevHeader(prev => prev.slice(0, -1));
|
|
84
|
+
!(indexStack.length - 1) && setHeader(null);
|
|
85
|
+
onBack && onBack(e, item);
|
|
86
|
+
setHeader(prevHeader[prevHeader.length - 2]);
|
|
87
|
+
} else {
|
|
88
|
+
const {
|
|
89
|
+
onClick,
|
|
90
|
+
children
|
|
91
|
+
} = item;
|
|
92
|
+
if (children) {
|
|
93
|
+
setIndexStack([...indexStack, index]);
|
|
94
|
+
setHeader(item);
|
|
95
|
+
setPrevHeader(prev => [...prev, item]);
|
|
96
|
+
onNext && onNext(e, item);
|
|
97
|
+
} else {
|
|
98
|
+
onSelect && onSelect(e, item);
|
|
99
|
+
}
|
|
100
|
+
onClick && onClick(e, item);
|
|
101
|
+
}
|
|
102
|
+
}, [indexStack]);
|
|
103
|
+
const isOtherLayoutExists = layer === null || layer === void 0 ? void 0 : layer.some(item => !!item.children);
|
|
104
|
+
|
|
105
|
+
// key accessibility
|
|
106
|
+
const [hoverIndex, setHoverIndex] = useState(null);
|
|
107
|
+
const [allowHoverOnActiveElement, setAllowHoverOnActiveElement] = useState(false);
|
|
108
|
+
const [withHeader, setWithHeader] = useState(false);
|
|
109
|
+
const [hoveredHeader, setHoveredHeader] = useState(false);
|
|
110
|
+
const [withSmoothScroll, setWithSmoothScroll] = useState(false);
|
|
111
|
+
const handleMenuFocus = () => setHoverIndex(0);
|
|
112
|
+
const keyDownHandler = e => {
|
|
113
|
+
setWithSmoothScroll(true);
|
|
114
|
+
switch (e.key) {
|
|
115
|
+
case 'ArrowDown':
|
|
116
|
+
{
|
|
117
|
+
if (hoveredHeader) {
|
|
118
|
+
setHoverIndex(0);
|
|
119
|
+
setHoveredHeader(false);
|
|
120
|
+
} else {
|
|
121
|
+
setHoverIndex(prev => prev >= layer.length - 1 ? layer.length - 1 : prev + 1);
|
|
122
|
+
setScrollWithArrowKey(true);
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'ArrowUp':
|
|
127
|
+
{
|
|
128
|
+
if (hoverIndex <= 0) {
|
|
129
|
+
setHoverIndex(null);
|
|
130
|
+
if (withHeader) {
|
|
131
|
+
setHoveredHeader(true);
|
|
132
|
+
} else {
|
|
133
|
+
setScrollWithArrowKey(true);
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
setHoverIndex(prev => prev - 1);
|
|
137
|
+
setScrollWithArrowKey(true);
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case 'Enter':
|
|
142
|
+
{
|
|
143
|
+
setAllowHoverOnActiveElement(true);
|
|
144
|
+
const selectedItem = layer[hoverIndex];
|
|
145
|
+
if (selectedItem) {
|
|
146
|
+
handleClick(e, selectedItem, false, hoverIndex);
|
|
147
|
+
setHoverIndex(0);
|
|
148
|
+
}
|
|
149
|
+
if (hoveredHeader) handleClick(e, header, true);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'Tab':
|
|
153
|
+
case 'Escape':
|
|
154
|
+
toggle && toggle(false);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const omitLayoutProps = obj => {
|
|
159
|
+
let result = obj;
|
|
160
|
+
if (obj !== null && obj !== void 0 && obj.maxHeight) {
|
|
161
|
+
const {
|
|
162
|
+
maxHeight,
|
|
163
|
+
...restProps
|
|
164
|
+
} = result;
|
|
165
|
+
result = restProps;
|
|
166
|
+
}
|
|
167
|
+
if (obj !== null && obj !== void 0 && obj.scrollTopGap) {
|
|
168
|
+
const {
|
|
169
|
+
scrollTopGap,
|
|
170
|
+
...restProps
|
|
171
|
+
} = result;
|
|
172
|
+
result = restProps;
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
};
|
|
176
|
+
const contentListMemo = useMemo(() => layer === null || layer === void 0 ? void 0 : layer.map((item, index) => {
|
|
177
|
+
const itemProps = omitLayoutProps(item);
|
|
178
|
+
if (allowHoverOnActiveElement && item.active) {
|
|
179
|
+
setHoverIndex(index);
|
|
180
|
+
setAllowHoverOnActiveElement(false);
|
|
181
|
+
}
|
|
182
|
+
return item.component || /*#__PURE__*/React__default.createElement(Option, _extends({
|
|
183
|
+
key: "".concat(item.header).concat(index),
|
|
184
|
+
title: item.title,
|
|
185
|
+
onClick: e => handleClick(e, item, false, index),
|
|
186
|
+
forwardMark: !!item.children,
|
|
187
|
+
screenType: screenType
|
|
188
|
+
}, scrollToActiveElement && item.active && allowScroll || index === hoverIndex ? {
|
|
189
|
+
forwardedRef: activeElementRef
|
|
190
|
+
} : {}, itemProps, {
|
|
191
|
+
className: classnames({
|
|
192
|
+
hovered: index === hoverIndex
|
|
193
|
+
}, itemProps.className)
|
|
194
|
+
}));
|
|
195
|
+
}), [indexStack, layer, hoverIndex]);
|
|
196
|
+
const headerMemo = useMemo(() => {
|
|
197
|
+
const headerProps = omitLayoutProps(header);
|
|
198
|
+
setWithHeader(!!headerProps);
|
|
199
|
+
return header && /*#__PURE__*/React__default.createElement(Option, _extends({
|
|
200
|
+
onClick: e => handleClick(e, header, true),
|
|
201
|
+
icon: "bc-icon-arrow-left",
|
|
202
|
+
border: "bottom",
|
|
203
|
+
className: classnames({
|
|
204
|
+
hovered: hoveredHeader
|
|
205
|
+
}),
|
|
206
|
+
screenType: screenType,
|
|
207
|
+
titlePosition: "center"
|
|
208
|
+
}, headerProps, {
|
|
209
|
+
title: header.title
|
|
210
|
+
}));
|
|
211
|
+
}, [header, screenType, header === null || header === void 0 ? void 0 : header.maxHeight, indexStack, hoveredHeader]);
|
|
212
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
213
|
+
className: "menu-items-wrapper popover-top-bottom-padding",
|
|
214
|
+
onKeyDown: keyDownHandler,
|
|
215
|
+
onFocus: handleMenuFocus,
|
|
216
|
+
tabIndex: 0,
|
|
217
|
+
ref: ref
|
|
218
|
+
}, restProps), /*#__PURE__*/React__default.createElement("ul", {
|
|
219
|
+
style: {
|
|
220
|
+
'--translate-x': "".concat(indexStack.length * 100, "%")
|
|
221
|
+
}
|
|
222
|
+
}, indexStack.map((_, index) => /*#__PURE__*/React__default.createElement("li", {
|
|
223
|
+
key: index
|
|
224
|
+
})), /*#__PURE__*/React__default.createElement("li", null, headerMemo, header !== null && header !== void 0 && header.maxHeight ? /*#__PURE__*/React__default.createElement(CustomScrollbar, {
|
|
225
|
+
style: {
|
|
226
|
+
height: "".concat(header.maxHeight, "px")
|
|
227
|
+
},
|
|
228
|
+
ref: listRef,
|
|
229
|
+
scrollTop: activeElementTop,
|
|
230
|
+
withSmoothScroll: withSmoothScroll
|
|
231
|
+
}, contentListMemo) : contentListMemo), isOtherLayoutExists && /*#__PURE__*/React__default.createElement("li", null)));
|
|
232
|
+
});
|
|
233
|
+
Menu.defaultProps = {
|
|
234
|
+
screenType: screenTypes[0]
|
|
235
|
+
};
|
|
236
|
+
Menu.propTypes = {
|
|
237
|
+
/**
|
|
238
|
+
* This is an array where you send menu options, if you send a component,
|
|
239
|
+
* then your component will be rendered, and if parameters, they will be
|
|
240
|
+
* used for the atoms/Option component.<br/>
|
|
241
|
+
* Add <code>maxHeight</code> to data to add scrollbar with maxHeight(px)
|
|
242
|
+
*/
|
|
243
|
+
data: propTypesExports.arrayOf(propTypesExports.shape({
|
|
244
|
+
component: propTypesExports.node,
|
|
245
|
+
maxHeight: propTypesExports.number,
|
|
246
|
+
...Option.propTypes
|
|
247
|
+
})),
|
|
248
|
+
/**
|
|
249
|
+
* Fires event when user click on header elements;
|
|
250
|
+
* (event: Event, item: Object) => void
|
|
251
|
+
*/
|
|
252
|
+
onBack: propTypesExports.func,
|
|
253
|
+
/**
|
|
254
|
+
* Fires event when user click on option elements;
|
|
255
|
+
* (event: Event, item: Object) => void
|
|
256
|
+
*/
|
|
257
|
+
onNext: propTypesExports.func,
|
|
258
|
+
/**
|
|
259
|
+
* Fires event when user click on elements;
|
|
260
|
+
* (event: Event, item: Object) => void
|
|
261
|
+
*/
|
|
262
|
+
onSelect: propTypesExports.func,
|
|
263
|
+
/**
|
|
264
|
+
* Controls screen type
|
|
265
|
+
*/
|
|
266
|
+
screenType: propTypesExports.oneOf(screenTypes),
|
|
267
|
+
/**
|
|
268
|
+
* auto scroll to activeElement
|
|
269
|
+
*/
|
|
270
|
+
scrollToActiveElement: propTypesExports.bool,
|
|
271
|
+
/**
|
|
272
|
+
* Initial selected options indexes array
|
|
273
|
+
*/
|
|
274
|
+
initialIndexStack: propTypesExports.arrayOf(propTypesExports.string)
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export { Menu as default };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { _ as _extends } from './_rollupPluginBabelHelpers-e8fb2e5c.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { p as propTypesExports } from './index-e0af0caf.js';
|
|
4
|
+
import { c as classnames } from './index-6ff23041.js';
|
|
5
|
+
import Badge from './Badge.js';
|
|
6
|
+
import Icon from './Icon.js';
|
|
7
|
+
import './globalStyling-9c60a159.js';
|
|
8
|
+
import { s as styleInject } from './style-inject.es-746bb8ed.js';
|
|
9
|
+
import './configs.js';
|
|
10
|
+
|
|
11
|
+
var css_248z = "[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar{background:var(--background);border-top:1px solid rgba(var(--background-sc-rgb),.06);bottom:0;font:600 1rem/1.4rem var(--font-family);left:0;position:fixed;text-align:center;width:100%;z-index:200}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul{display:table;table-layout:fixed;width:100%}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li{display:table-cell;overflow:hidden;padding:.8rem 0 .4rem;position:relative;transition:color .3s,opacity .3s}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li .badge{margin:0 auto;position:absolute;top:.8rem;width:5.2rem}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li .badge-right .badge{right:calc(50% - 2.5rem)}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li .badge-left .badge{left:calc(50% - 2.5rem)}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li:before{background:var(--hero);border-radius:0 0 .5rem .5rem;content:\"\";display:block;height:.3rem;left:calc(50% - 2.6rem);position:absolute;top:0;transform:translateY(-100%);transition:transform .3s;width:5.2rem}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li.active{color:var(--hero)}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li.active:before{transform:translateY(0)}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar>ul>li.disabled{opacity:.5;pointer-events:none}[data-gene-ui-version=\"2.11.0\"] .mob-navigation-bar .icon{margin:0 0 .2rem}";
|
|
12
|
+
styleInject(css_248z);
|
|
13
|
+
|
|
14
|
+
function MobileNavigation(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
list,
|
|
17
|
+
activeSlug,
|
|
18
|
+
onChange,
|
|
19
|
+
className,
|
|
20
|
+
...restProps
|
|
21
|
+
} = _ref;
|
|
22
|
+
const handleClick = event => {
|
|
23
|
+
const {
|
|
24
|
+
index
|
|
25
|
+
} = event.currentTarget.dataset;
|
|
26
|
+
const item = list[index];
|
|
27
|
+
onChange && onChange(item);
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
30
|
+
className: classnames('mob-navigation-bar', className)
|
|
31
|
+
}, restProps), /*#__PURE__*/React__default.createElement("ul", null, list.map((item, index) => /*#__PURE__*/React__default.createElement("li", {
|
|
32
|
+
key: item.slug,
|
|
33
|
+
"data-index": index,
|
|
34
|
+
className: classnames({
|
|
35
|
+
active: item.slug === activeSlug,
|
|
36
|
+
disabled: item.disabled
|
|
37
|
+
}),
|
|
38
|
+
onClick: !item.disabled ? handleClick : null
|
|
39
|
+
}, item.badge && /*#__PURE__*/React__default.createElement("div", {
|
|
40
|
+
className: "badge-".concat(item.badge.position || 'right')
|
|
41
|
+
}, /*#__PURE__*/React__default.createElement(Badge, {
|
|
42
|
+
size: "default",
|
|
43
|
+
maxCount: item.badge.maxCount,
|
|
44
|
+
count: item.badge.count
|
|
45
|
+
})), /*#__PURE__*/React__default.createElement(Icon, {
|
|
46
|
+
type: item.icon
|
|
47
|
+
}), /*#__PURE__*/React__default.createElement("p", {
|
|
48
|
+
className: "ellipsis-text"
|
|
49
|
+
}, item.title)))));
|
|
50
|
+
}
|
|
51
|
+
MobileNavigation.propTypes = {
|
|
52
|
+
/**
|
|
53
|
+
* Array of menu items data
|
|
54
|
+
*/
|
|
55
|
+
list: propTypesExports.arrayOf(propTypesExports.shape({
|
|
56
|
+
/**
|
|
57
|
+
* Title for navigation item
|
|
58
|
+
*/
|
|
59
|
+
title: propTypesExports.string,
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
slug: propTypesExports.string,
|
|
64
|
+
/**
|
|
65
|
+
* Icon for navigation item
|
|
66
|
+
*/
|
|
67
|
+
icon: propTypesExports.string,
|
|
68
|
+
/**
|
|
69
|
+
* Notification Badge
|
|
70
|
+
* count - the value of badge
|
|
71
|
+
* maxCount - if the count is greater than the max count, the Badge shows maxCount+
|
|
72
|
+
* position - position of Badge
|
|
73
|
+
*/
|
|
74
|
+
badge: propTypesExports.shape({
|
|
75
|
+
count: propTypesExports.number,
|
|
76
|
+
maxCount: propTypesExports.number,
|
|
77
|
+
position: propTypesExports.oneOf(['left', 'right'])
|
|
78
|
+
})
|
|
79
|
+
}).isRequired),
|
|
80
|
+
/**
|
|
81
|
+
* Initially selected item
|
|
82
|
+
*/
|
|
83
|
+
activeSlug: propTypesExports.string,
|
|
84
|
+
/**
|
|
85
|
+
* CSS class name for element
|
|
86
|
+
*/
|
|
87
|
+
className: propTypesExports.string,
|
|
88
|
+
/**
|
|
89
|
+
* Fires event when user click on one of the items
|
|
90
|
+
* (item: Object) => void
|
|
91
|
+
*/
|
|
92
|
+
onChange: propTypesExports.func
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { MobileNavigation as default };
|
package/MobilePopup.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { _ as _extends } from './_rollupPluginBabelHelpers-e8fb2e5c.js';
|
|
2
|
+
import React__default, { useState, useCallback, forwardRef } from 'react';
|
|
3
|
+
import { p as propTypesExports } from './index-e0af0caf.js';
|
|
4
|
+
import { c as classnames } from './index-6ff23041.js';
|
|
5
|
+
import { n as noop } from './index-ac59cb10.js';
|
|
6
|
+
import Icon from './Icon.js';
|
|
7
|
+
import Portal from './Portal.js';
|
|
8
|
+
import './dateValidation-67caec66.js';
|
|
9
|
+
import 'react-dom';
|
|
10
|
+
import './configs-91c86664.js';
|
|
11
|
+
import { u as useClickOutside } from './useClickOutside-5183e396.js';
|
|
12
|
+
import { P as Popover } from './index-a4635754.js';
|
|
13
|
+
import Menu from './Menu.js';
|
|
14
|
+
import { s as styleInject } from './style-inject.es-746bb8ed.js';
|
|
15
|
+
import './globalStyling-9c60a159.js';
|
|
16
|
+
import './GeneUIProvider.js';
|
|
17
|
+
import './_commonjsHelpers-24198af3.js';
|
|
18
|
+
import './Popover-f4d1cac0.js';
|
|
19
|
+
import './index-122432cd.js';
|
|
20
|
+
import './useDeviceType-dd51db38.js';
|
|
21
|
+
import './useWindowSize-80369d76.js';
|
|
22
|
+
import './Scrollbar.js';
|
|
23
|
+
import './guid-8ddf77b3.js';
|
|
24
|
+
import './Option.js';
|
|
25
|
+
import './useEllipsisDetection-ef536015.js';
|
|
26
|
+
import './Tooltip.js';
|
|
27
|
+
|
|
28
|
+
function ActionMenu(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
action,
|
|
31
|
+
children
|
|
32
|
+
} = _ref;
|
|
33
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
34
|
+
const toggleMenu = useCallback(() => setIsOpened(status => !status), []);
|
|
35
|
+
const handleOutsideClick = useClickOutside(toggleMenu);
|
|
36
|
+
if (action.menuOptions) {
|
|
37
|
+
return /*#__PURE__*/React__default.createElement(Popover, {
|
|
38
|
+
swipeable: true,
|
|
39
|
+
align: "end",
|
|
40
|
+
screenType: "mobile",
|
|
41
|
+
isOpen: isOpened,
|
|
42
|
+
onSwipedDown: toggleMenu,
|
|
43
|
+
contentRef: handleOutsideClick,
|
|
44
|
+
Content: /*#__PURE__*/React__default.createElement(Menu, {
|
|
45
|
+
screenType: "mobile",
|
|
46
|
+
onClick: toggleMenu,
|
|
47
|
+
data: [...action.menuOptions, {
|
|
48
|
+
title: 'Cancel',
|
|
49
|
+
icon: 'bc-icon-clear',
|
|
50
|
+
border: 'top'
|
|
51
|
+
}]
|
|
52
|
+
})
|
|
53
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
54
|
+
onClick: toggleMenu
|
|
55
|
+
}, children));
|
|
56
|
+
}
|
|
57
|
+
return children;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var css_248z = "[data-gene-ui-version=\"2.11.0\"] .m-popup-holder{height:100%;left:0;overflow:hidden;position:fixed;top:0;width:100%;z-index:400}[data-gene-ui-version=\"2.11.0\"] .m-popup-backdrop{animation:m-popup-backdrop-reveal .3s forwards;background-color:#0003;height:100%;left:0;opacity:0;position:absolute;top:0;width:100%}@keyframes m-popup-backdrop-reveal{to{opacity:1}}[data-gene-ui-version=\"2.11.0\"] .m-popup-c{animation:m-popup-c-reveal .4s .25s forwards;background:var(--background);border-radius:1rem 1rem 0 0;bottom:0;box-shadow:0 -1px .2rem 0 #0000000d;display:flex;flex-direction:column;left:0;max-height:calc(100% - 2rem);padding:0 1.6rem;position:absolute;right:0;transform:translate3d(0,100%,0)}@keyframes m-popup-c-reveal{to{transform:translateZ(0)}}[data-gene-ui-version=\"2.11.0\"] .m-popup-head{border-bottom:1px solid rgba(var(--background-sc-rgb),.1);display:grid;font-weight:700;grid-template-columns:1fr auto 1fr;height:5.1rem;position:relative}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li{align-items:center;display:flex;overflow:hidden}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li:first-child .mp-action .icon{margin-inline-end:1rem}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li:last-child .mp-action{flex-direction:row-reverse}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li:last-child .mp-action .icon{margin-inline-start:1rem}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li:nth-child(2){padding:0 1rem}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li:not(:nth-child(2)){min-width:-webkit-fit-content;min-width:-moz-fit-content;min-width:fit-content}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li:nth-child(3){justify-content:flex-end}[data-gene-ui-version=\"2.11.0\"] .m-popup-head>li .mp-action{align-items:center;color:var(--hero);cursor:pointer;display:flex;font:600 1.4rem/3.6rem var(--font-family);overflow:hidden}[data-gene-ui-version=\"2.11.0\"] .m-popup-content{-webkit-overflow-scrolling:auto;flex:auto;margin:0 -1.6rem;overflow-y:auto;padding:0 1.6rem env(safe-area-inset-bottom);transition:padding .4s;width:calc(100% + 3.2rem)}";
|
|
61
|
+
styleInject(css_248z);
|
|
62
|
+
|
|
63
|
+
const MobilePopUp = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
64
|
+
let {
|
|
65
|
+
onBackdropClick,
|
|
66
|
+
rightActionClick,
|
|
67
|
+
leftActionClick,
|
|
68
|
+
portalContainer,
|
|
69
|
+
rightAction,
|
|
70
|
+
leftAction,
|
|
71
|
+
className,
|
|
72
|
+
isOpened,
|
|
73
|
+
children,
|
|
74
|
+
title,
|
|
75
|
+
...restProps
|
|
76
|
+
} = _ref;
|
|
77
|
+
const generateAction = (action, onClick) => {
|
|
78
|
+
if (action) {
|
|
79
|
+
if ( /*#__PURE__*/React__default.isValidElement(action)) {
|
|
80
|
+
return action;
|
|
81
|
+
}
|
|
82
|
+
return /*#__PURE__*/React__default.createElement(ActionMenu, {
|
|
83
|
+
action: action
|
|
84
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
85
|
+
className: "mp-action",
|
|
86
|
+
onClick: onClick
|
|
87
|
+
}, action.iconType && /*#__PURE__*/React__default.createElement(Icon, {
|
|
88
|
+
type: action.iconType
|
|
89
|
+
}), action.text && /*#__PURE__*/React__default.createElement("p", {
|
|
90
|
+
className: "ellipsis-text"
|
|
91
|
+
}, action.text)));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const handleBackdropClick = useCallback(event => {
|
|
95
|
+
onBackdropClick(event, true);
|
|
96
|
+
}, [onBackdropClick]);
|
|
97
|
+
return /*#__PURE__*/React__default.createElement(Portal, {
|
|
98
|
+
isOpen: isOpened,
|
|
99
|
+
container: portalContainer
|
|
100
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({}, restProps, {
|
|
101
|
+
className: classnames('m-popup-holder', className)
|
|
102
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
103
|
+
className: "m-popup-backdrop",
|
|
104
|
+
onClick: handleBackdropClick
|
|
105
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
106
|
+
className: "m-popup-c"
|
|
107
|
+
}, /*#__PURE__*/React__default.createElement("ul", {
|
|
108
|
+
className: "m-popup-head"
|
|
109
|
+
}, /*#__PURE__*/React__default.createElement("li", null, generateAction(leftAction, leftActionClick)), /*#__PURE__*/React__default.createElement("li", null, /*#__PURE__*/React__default.createElement("div", {
|
|
110
|
+
className: "ellipsis-text"
|
|
111
|
+
}, title)), /*#__PURE__*/React__default.createElement("li", null, generateAction(rightAction, rightActionClick))), /*#__PURE__*/React__default.createElement("div", {
|
|
112
|
+
className: "m-popup-content",
|
|
113
|
+
ref: ref
|
|
114
|
+
}, children))));
|
|
115
|
+
});
|
|
116
|
+
MobilePopUp.propTypes = {
|
|
117
|
+
/**
|
|
118
|
+
* Fires event when user clicks on right action button
|
|
119
|
+
* (event: SyntheticEvent) => void
|
|
120
|
+
*/
|
|
121
|
+
rightActionClick: propTypesExports.func,
|
|
122
|
+
/**
|
|
123
|
+
* Fires event when user clicks on left action button
|
|
124
|
+
* (event: SyntheticEvent) => void
|
|
125
|
+
*/
|
|
126
|
+
leftActionClick: propTypesExports.func,
|
|
127
|
+
/**
|
|
128
|
+
* Container for portal
|
|
129
|
+
*/
|
|
130
|
+
portalContainer: propTypesExports.any,
|
|
131
|
+
/**
|
|
132
|
+
* Props for right action
|
|
133
|
+
* iconType: String
|
|
134
|
+
* text: String
|
|
135
|
+
* menuOptions: Option atom's props
|
|
136
|
+
*/
|
|
137
|
+
rightAction: propTypesExports.oneOfType([propTypesExports.any, propTypesExports.shape({
|
|
138
|
+
iconType: propTypesExports.string,
|
|
139
|
+
text: propTypesExports.string,
|
|
140
|
+
menuOptions: propTypesExports.arrayOf(propTypesExports.object)
|
|
141
|
+
})]),
|
|
142
|
+
/**
|
|
143
|
+
* Props for left action
|
|
144
|
+
* iconType: String
|
|
145
|
+
* text: String
|
|
146
|
+
* menuOptions: Option atom's props
|
|
147
|
+
*/
|
|
148
|
+
leftAction: propTypesExports.oneOfType([propTypesExports.any, propTypesExports.shape({
|
|
149
|
+
iconType: propTypesExports.string,
|
|
150
|
+
text: propTypesExports.string,
|
|
151
|
+
menuOptions: propTypesExports.arrayOf(propTypesExports.object)
|
|
152
|
+
})]),
|
|
153
|
+
/**
|
|
154
|
+
* Additional classname
|
|
155
|
+
*/
|
|
156
|
+
className: propTypesExports.string,
|
|
157
|
+
/**
|
|
158
|
+
* Displays popup if [true]
|
|
159
|
+
*/
|
|
160
|
+
isOpened: propTypesExports.bool,
|
|
161
|
+
/**
|
|
162
|
+
* Valid React elements for popup body
|
|
163
|
+
*/
|
|
164
|
+
children: propTypesExports.node,
|
|
165
|
+
/**
|
|
166
|
+
* Custom title for popup
|
|
167
|
+
*/
|
|
168
|
+
title: propTypesExports.string,
|
|
169
|
+
/*
|
|
170
|
+
* Backdrop click event handler
|
|
171
|
+
*/
|
|
172
|
+
onBackdropClick: propTypesExports.func
|
|
173
|
+
};
|
|
174
|
+
MobilePopUp.defaultProps = {
|
|
175
|
+
onBackdropClick: noop,
|
|
176
|
+
leftActionClick: noop,
|
|
177
|
+
rightActionClick: noop
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export { MobilePopUp as default };
|