funda-ui 1.0.272
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/BackToTop/index.css +34 -0
- package/BackToTop/index.d.ts +11 -0
- package/BackToTop/index.js +458 -0
- package/CascadingSelect/index.css +159 -0
- package/CascadingSelect/index.d.ts +56 -0
- package/CascadingSelect/index.js +958 -0
- package/CascadingSelectE2E/index.css +159 -0
- package/CascadingSelectE2E/index.d.ts +60 -0
- package/CascadingSelectE2E/index.js +1126 -0
- package/Checkbox/index.d.ts +30 -0
- package/Checkbox/index.js +226 -0
- package/ColorPicker/index.css +38 -0
- package/ColorPicker/index.d.ts +27 -0
- package/ColorPicker/index.js +246 -0
- package/DigitalClock/index.d.ts +7 -0
- package/DigitalClock/index.js +208 -0
- package/DropdownMenu/index.css +127 -0
- package/DropdownMenu/index.d.ts +37 -0
- package/DropdownMenu/index.js +237 -0
- package/DynamicFields/index.d.ts +26 -0
- package/DynamicFields/index.js +412 -0
- package/File/index.d.ts +36 -0
- package/File/index.js +473 -0
- package/Input/index.d.ts +42 -0
- package/Input/index.js +286 -0
- package/LiveSearch/index.d.ts +37 -0
- package/LiveSearch/index.js +1195 -0
- package/ModalDialog/index.d.ts +60 -0
- package/ModalDialog/index.js +725 -0
- package/ModeSwitch/index.d.ts +17 -0
- package/ModeSwitch/index.js +202 -0
- package/MultiFuncSelect/index.css +178 -0
- package/MultiFuncSelect/index.d.ts +67 -0
- package/MultiFuncSelect/index.js +1826 -0
- package/MultilevelDropdownMenu/index.css +35 -0
- package/MultilevelDropdownMenu/index.d.ts +25 -0
- package/MultilevelDropdownMenu/index.js +464 -0
- package/Pagination/index.d.ts +49 -0
- package/Pagination/index.js +341 -0
- package/README.md +108 -0
- package/Radio/index.d.ts +31 -0
- package/Radio/index.js +246 -0
- package/RangeSlider/index.css +149 -0
- package/RangeSlider/index.d.ts +21 -0
- package/RangeSlider/index.js +730 -0
- package/ScrollReveal/index.css +23 -0
- package/ScrollReveal/index.d.ts +21 -0
- package/ScrollReveal/index.js +216 -0
- package/Scrollbar/index.css +168 -0
- package/Scrollbar/index.d.ts +15 -0
- package/Scrollbar/index.js +605 -0
- package/SearchBar/index.d.ts +32 -0
- package/SearchBar/index.js +246 -0
- package/Select/index.d.ts +34 -0
- package/Select/index.js +331 -0
- package/ShowMoreLess/index.css +23 -0
- package/ShowMoreLess/index.d.ts +30 -0
- package/ShowMoreLess/index.js +202 -0
- package/Switch/index.d.ts +29 -0
- package/Switch/index.js +211 -0
- package/Table/index.css +533 -0
- package/Table/index.d.ts +25 -0
- package/Table/index.js +2113 -0
- package/Tabs/index.d.ts +3 -0
- package/Tabs/index.js +323 -0
- package/TagInput/index.css +90 -0
- package/TagInput/index.d.ts +28 -0
- package/TagInput/index.js +370 -0
- package/Textarea/index.d.ts +30 -0
- package/Textarea/index.js +242 -0
- package/Toast/index.css +95 -0
- package/Toast/index.d.ts +35 -0
- package/Toast/index.js +340 -0
- package/Tooltip/index.css +240 -0
- package/Tooltip/index.d.ts +19 -0
- package/Tooltip/index.js +200 -0
- package/Tree/index.css +225 -0
- package/Tree/index.d.ts +37 -0
- package/Tree/index.js +1406 -0
- package/all.d.ts +33 -0
- package/all.js +35 -0
- package/lib/cjs/BackToTop/index.d.ts +11 -0
- package/lib/cjs/BackToTop/index.js +458 -0
- package/lib/cjs/CascadingSelect/index.d.ts +56 -0
- package/lib/cjs/CascadingSelect/index.js +958 -0
- package/lib/cjs/CascadingSelectE2E/index.d.ts +60 -0
- package/lib/cjs/CascadingSelectE2E/index.js +1126 -0
- package/lib/cjs/Checkbox/index.d.ts +30 -0
- package/lib/cjs/Checkbox/index.js +226 -0
- package/lib/cjs/ColorPicker/index.d.ts +27 -0
- package/lib/cjs/ColorPicker/index.js +246 -0
- package/lib/cjs/DigitalClock/index.d.ts +7 -0
- package/lib/cjs/DigitalClock/index.js +208 -0
- package/lib/cjs/DropdownMenu/index.d.ts +37 -0
- package/lib/cjs/DropdownMenu/index.js +237 -0
- package/lib/cjs/DynamicFields/index.d.ts +26 -0
- package/lib/cjs/DynamicFields/index.js +412 -0
- package/lib/cjs/File/index.d.ts +36 -0
- package/lib/cjs/File/index.js +473 -0
- package/lib/cjs/Input/index.d.ts +42 -0
- package/lib/cjs/Input/index.js +286 -0
- package/lib/cjs/LiveSearch/index.d.ts +37 -0
- package/lib/cjs/LiveSearch/index.js +1195 -0
- package/lib/cjs/ModalDialog/index.d.ts +60 -0
- package/lib/cjs/ModalDialog/index.js +725 -0
- package/lib/cjs/ModeSwitch/index.d.ts +17 -0
- package/lib/cjs/ModeSwitch/index.js +202 -0
- package/lib/cjs/MultiFuncSelect/index.d.ts +67 -0
- package/lib/cjs/MultiFuncSelect/index.js +1826 -0
- package/lib/cjs/MultilevelDropdownMenu/index.d.ts +25 -0
- package/lib/cjs/MultilevelDropdownMenu/index.js +464 -0
- package/lib/cjs/Pagination/index.d.ts +49 -0
- package/lib/cjs/Pagination/index.js +341 -0
- package/lib/cjs/Radio/index.d.ts +31 -0
- package/lib/cjs/Radio/index.js +246 -0
- package/lib/cjs/RangeSlider/index.d.ts +21 -0
- package/lib/cjs/RangeSlider/index.js +730 -0
- package/lib/cjs/ScrollReveal/index.d.ts +21 -0
- package/lib/cjs/ScrollReveal/index.js +216 -0
- package/lib/cjs/Scrollbar/index.d.ts +15 -0
- package/lib/cjs/Scrollbar/index.js +605 -0
- package/lib/cjs/SearchBar/index.d.ts +32 -0
- package/lib/cjs/SearchBar/index.js +246 -0
- package/lib/cjs/Select/index.d.ts +34 -0
- package/lib/cjs/Select/index.js +331 -0
- package/lib/cjs/ShowMoreLess/index.d.ts +30 -0
- package/lib/cjs/ShowMoreLess/index.js +202 -0
- package/lib/cjs/Switch/index.d.ts +29 -0
- package/lib/cjs/Switch/index.js +211 -0
- package/lib/cjs/Table/index.d.ts +25 -0
- package/lib/cjs/Table/index.js +2113 -0
- package/lib/cjs/Tabs/index.d.ts +3 -0
- package/lib/cjs/Tabs/index.js +323 -0
- package/lib/cjs/TagInput/index.d.ts +28 -0
- package/lib/cjs/TagInput/index.js +370 -0
- package/lib/cjs/Textarea/index.d.ts +30 -0
- package/lib/cjs/Textarea/index.js +242 -0
- package/lib/cjs/Toast/index.d.ts +35 -0
- package/lib/cjs/Toast/index.js +340 -0
- package/lib/cjs/Tooltip/index.d.ts +19 -0
- package/lib/cjs/Tooltip/index.js +200 -0
- package/lib/cjs/Tree/index.d.ts +37 -0
- package/lib/cjs/Tree/index.js +1406 -0
- package/lib/cjs/index.d.ts +33 -0
- package/lib/cjs/index.js +35 -0
- package/lib/css/BackToTop/index.css +34 -0
- package/lib/css/CascadingSelect/index.css +159 -0
- package/lib/css/CascadingSelectE2E/index.css +159 -0
- package/lib/css/ColorPicker/index.css +38 -0
- package/lib/css/DropdownMenu/index.css +127 -0
- package/lib/css/MultiFuncSelect/index.css +178 -0
- package/lib/css/MultilevelDropdownMenu/index.css +35 -0
- package/lib/css/RangeSlider/index.css +149 -0
- package/lib/css/ScrollReveal/index.css +23 -0
- package/lib/css/Scrollbar/index.css +168 -0
- package/lib/css/ShowMoreLess/index.css +23 -0
- package/lib/css/Table/index.css +533 -0
- package/lib/css/TagInput/index.css +90 -0
- package/lib/css/Toast/index.css +95 -0
- package/lib/css/Tooltip/index.css +240 -0
- package/lib/css/Tree/index.css +225 -0
- package/lib/esm/BackToTop/index.scss +47 -0
- package/lib/esm/BackToTop/index.tsx +182 -0
- package/lib/esm/BackToTop/utils/easing.js +200 -0
- package/lib/esm/BackToTop/utils/performance.js +52 -0
- package/lib/esm/CascadingSelect/Group.tsx +39 -0
- package/lib/esm/CascadingSelect/index.scss +214 -0
- package/lib/esm/CascadingSelect/index.tsx +922 -0
- package/lib/esm/CascadingSelect/utils/performance.js +52 -0
- package/lib/esm/CascadingSelectE2E/Group.tsx +39 -0
- package/lib/esm/CascadingSelectE2E/index.scss +214 -0
- package/lib/esm/CascadingSelectE2E/index.tsx +1091 -0
- package/lib/esm/CascadingSelectE2E/utils/performance.js +52 -0
- package/lib/esm/Checkbox/index.tsx +160 -0
- package/lib/esm/ColorPicker/index.scss +48 -0
- package/lib/esm/ColorPicker/index.tsx +187 -0
- package/lib/esm/DigitalClock/index.tsx +72 -0
- package/lib/esm/DigitalClock/utils/useInterval.js +43 -0
- package/lib/esm/DropdownMenu/Option.tsx +27 -0
- package/lib/esm/DropdownMenu/index.scss +180 -0
- package/lib/esm/DropdownMenu/index.tsx +148 -0
- package/lib/esm/DynamicFields/index.tsx +386 -0
- package/lib/esm/File/index.tsx +302 -0
- package/lib/esm/Input/index.tsx +233 -0
- package/lib/esm/LiveSearch/index.tsx +582 -0
- package/lib/esm/LiveSearch/utils/performance.js +52 -0
- package/lib/esm/LiveSearch/utils/useThrottle.js +36 -0
- package/lib/esm/ModalDialog/index.tsx +479 -0
- package/lib/esm/ModalDialog/plugins/BSL/bodyScrollLock.es6.js +262 -0
- package/lib/esm/ModalDialog/plugins/BSL/index.ts +2 -0
- package/lib/esm/ModeSwitch/index.tsx +82 -0
- package/lib/esm/MultiFuncSelect/index.scss +269 -0
- package/lib/esm/MultiFuncSelect/index.tsx +1597 -0
- package/lib/esm/MultiFuncSelect/utils/performance.js +52 -0
- package/lib/esm/MultiFuncSelect/utils/tree.js +103 -0
- package/lib/esm/MultiFuncSelect/utils/useThrottle.js +36 -0
- package/lib/esm/MultilevelDropdownMenu/MenuList.tsx +230 -0
- package/lib/esm/MultilevelDropdownMenu/index.scss +75 -0
- package/lib/esm/MultilevelDropdownMenu/index.tsx +71 -0
- package/lib/esm/MultilevelDropdownMenu/utils/dom.js +81 -0
- package/lib/esm/Pagination/index.tsx +230 -0
- package/lib/esm/Pagination/pagination-navigators.tsx +60 -0
- package/lib/esm/Radio/index.tsx +201 -0
- package/lib/esm/RangeSlider/index.scss +184 -0
- package/lib/esm/RangeSlider/index.tsx +223 -0
- package/lib/esm/ScrollReveal/index.scss +27 -0
- package/lib/esm/ScrollReveal/index.tsx +146 -0
- package/lib/esm/Scrollbar/index.scss +217 -0
- package/lib/esm/Scrollbar/index.tsx +497 -0
- package/lib/esm/Scrollbar/utils/performance.js +52 -0
- package/lib/esm/SearchBar/index.tsx +181 -0
- package/lib/esm/Select/index.tsx +276 -0
- package/lib/esm/ShowMoreLess/index.scss +27 -0
- package/lib/esm/ShowMoreLess/index.tsx +144 -0
- package/lib/esm/Switch/index.tsx +143 -0
- package/lib/esm/Table/TableColgroup.tsx +29 -0
- package/lib/esm/Table/TableField.tsx +40 -0
- package/lib/esm/Table/TableFieldRow.tsx +212 -0
- package/lib/esm/Table/TableHeaders.tsx +146 -0
- package/lib/esm/Table/TableRow.tsx +127 -0
- package/lib/esm/Table/TableSummaries.tsx +36 -0
- package/lib/esm/Table/index.scss +364 -0
- package/lib/esm/Table/index.tsx +576 -0
- package/lib/esm/Table/table-utils.ts +65 -0
- package/lib/esm/Table/utils/dom.js +81 -0
- package/lib/esm/Table/utils/performance.js +52 -0
- package/lib/esm/Tabs/TabList.tsx +42 -0
- package/lib/esm/Tabs/TabPanel.tsx +34 -0
- package/lib/esm/Tabs/Tabs.tsx +232 -0
- package/lib/esm/Tabs/index.tsx +3 -0
- package/lib/esm/TagInput/index.scss +125 -0
- package/lib/esm/TagInput/index.tsx +314 -0
- package/lib/esm/Textarea/index.tsx +178 -0
- package/lib/esm/Toast/Item.tsx +75 -0
- package/lib/esm/Toast/index.scss +120 -0
- package/lib/esm/Toast/index.tsx +249 -0
- package/lib/esm/Tooltip/index.scss +327 -0
- package/lib/esm/Tooltip/index.tsx +142 -0
- package/lib/esm/Tree/TreeList.tsx +503 -0
- package/lib/esm/Tree/index.scss +375 -0
- package/lib/esm/Tree/index.tsx +301 -0
- package/lib/esm/Tree/init-height.tsx +27 -0
- package/lib/esm/Tree/utils/convert-tree.js +29 -0
- package/lib/esm/Tree/utils/dom.js +81 -0
- package/lib/esm/index.js +31 -0
- package/package.json +40 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// Older browsers don't support event options, feature detect it.
|
|
4
|
+
|
|
5
|
+
// Adopted and modified solution from Bohdan Didukh (2017)
|
|
6
|
+
// https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi
|
|
7
|
+
|
|
8
|
+
let hasPassiveEvents = false;
|
|
9
|
+
if (typeof window !== 'undefined') {
|
|
10
|
+
const passiveTestOptions = {
|
|
11
|
+
get passive() {
|
|
12
|
+
hasPassiveEvents = true;
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
window.addEventListener('testPassive', null, passiveTestOptions);
|
|
17
|
+
window.removeEventListener('testPassive', null, passiveTestOptions);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
let locks = [];
|
|
24
|
+
let documentListenerAdded = false;
|
|
25
|
+
let initialClientY = -1;
|
|
26
|
+
let previousBodyOverflowSetting;
|
|
27
|
+
let previousBodyPosition;
|
|
28
|
+
let previousBodyPaddingRight;
|
|
29
|
+
|
|
30
|
+
// returns true if `el` should be allowed to receive touchmove events.
|
|
31
|
+
const allowTouchMove = el => locks.some(lock => {
|
|
32
|
+
if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const preventDefault = rawEvent => {
|
|
40
|
+
const e = rawEvent || window.event;
|
|
41
|
+
|
|
42
|
+
// For the case whereby consumers adds a touchmove event listener to document.
|
|
43
|
+
// Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })
|
|
44
|
+
// in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then
|
|
45
|
+
// the touchmove event on document will break.
|
|
46
|
+
if (allowTouchMove(e.target)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
|
|
51
|
+
if (e.touches.length > 1) return true;
|
|
52
|
+
|
|
53
|
+
if (e.preventDefault) e.preventDefault();
|
|
54
|
+
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const setOverflowHidden = options => {
|
|
59
|
+
// If previousBodyPaddingRight is already set, don't set it again.
|
|
60
|
+
if (previousBodyPaddingRight === undefined) {
|
|
61
|
+
const reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
|
|
62
|
+
const scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
|
|
63
|
+
|
|
64
|
+
if (reserveScrollBarGap && scrollBarGap > 0) {
|
|
65
|
+
const computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'), 10);
|
|
66
|
+
previousBodyPaddingRight = document.body.style.paddingRight;
|
|
67
|
+
document.body.style.paddingRight = `${computedBodyPaddingRight + scrollBarGap}px`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// If previousBodyOverflowSetting is already set, don't set it again.
|
|
72
|
+
if (previousBodyOverflowSetting === undefined) {
|
|
73
|
+
previousBodyOverflowSetting = document.body.style.overflow;
|
|
74
|
+
document.body.style.overflow = 'hidden';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const restoreOverflowSetting = () => {
|
|
79
|
+
if (previousBodyPaddingRight !== undefined) {
|
|
80
|
+
document.body.style.paddingRight = previousBodyPaddingRight;
|
|
81
|
+
|
|
82
|
+
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it
|
|
83
|
+
// can be set again.
|
|
84
|
+
previousBodyPaddingRight = undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (previousBodyOverflowSetting !== undefined) {
|
|
88
|
+
document.body.style.overflow = previousBodyOverflowSetting;
|
|
89
|
+
|
|
90
|
+
// Restore previousBodyOverflowSetting to undefined
|
|
91
|
+
// so setOverflowHidden knows it can be set again.
|
|
92
|
+
previousBodyOverflowSetting = undefined;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const setPositionFixed = () => window.requestAnimationFrame(() => {
|
|
97
|
+
// If previousBodyPosition is already set, don't set it again.
|
|
98
|
+
if (previousBodyPosition === undefined) {
|
|
99
|
+
previousBodyPosition = {
|
|
100
|
+
position: document.body.style.position,
|
|
101
|
+
top: document.body.style.top,
|
|
102
|
+
left: document.body.style.left
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Update the dom inside an animation frame
|
|
106
|
+
const { scrollY, scrollX, innerHeight } = window;
|
|
107
|
+
document.body.style.position = 'fixed';
|
|
108
|
+
document.body.style.top = `${-scrollY}px`;
|
|
109
|
+
document.body.style.left = `${-scrollX}px`;
|
|
110
|
+
|
|
111
|
+
setTimeout(() => window.requestAnimationFrame(() => {
|
|
112
|
+
// Attempt to check if the bottom bar appeared due to the position change
|
|
113
|
+
const bottomBarHeight = innerHeight - window.innerHeight;
|
|
114
|
+
if (bottomBarHeight && scrollY >= innerHeight) {
|
|
115
|
+
// Move the content further up so that the bottom bar doesn't hide it
|
|
116
|
+
document.body.style.top = -(scrollY + bottomBarHeight);
|
|
117
|
+
}
|
|
118
|
+
}), 300);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const restorePositionSetting = () => {
|
|
123
|
+
if (previousBodyPosition !== undefined) {
|
|
124
|
+
// Convert the position from "px" to Int
|
|
125
|
+
const y = -parseInt(document.body.style.top, 10);
|
|
126
|
+
const x = -parseInt(document.body.style.left, 10);
|
|
127
|
+
|
|
128
|
+
// Restore styles
|
|
129
|
+
document.body.style.position = previousBodyPosition.position;
|
|
130
|
+
document.body.style.top = previousBodyPosition.top;
|
|
131
|
+
document.body.style.left = previousBodyPosition.left;
|
|
132
|
+
|
|
133
|
+
// Restore scroll
|
|
134
|
+
window.scrollTo(x, y);
|
|
135
|
+
|
|
136
|
+
previousBodyPosition = undefined;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
|
|
141
|
+
const isTargetElementTotallyScrolled = targetElement => targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
|
|
142
|
+
|
|
143
|
+
const handleScroll = (event, targetElement) => {
|
|
144
|
+
const clientY = event.targetTouches[0].clientY - initialClientY;
|
|
145
|
+
|
|
146
|
+
if (allowTouchMove(event.target)) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {
|
|
151
|
+
// element is at the top of its scroll.
|
|
152
|
+
return preventDefault(event);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {
|
|
156
|
+
// element is at the bottom of its scroll.
|
|
157
|
+
return preventDefault(event);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
event.stopPropagation();
|
|
161
|
+
return true;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const disableBodyScroll = (targetElement, options) => {
|
|
165
|
+
// targetElement must be provided
|
|
166
|
+
if (!targetElement) {
|
|
167
|
+
// eslint-disable-next-line no-console
|
|
168
|
+
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// disableBodyScroll must not have been called on this targetElement before
|
|
173
|
+
if (locks.some(lock => lock.targetElement === targetElement)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const lock = {
|
|
178
|
+
targetElement,
|
|
179
|
+
options: options || {}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
locks = [...locks, lock];
|
|
183
|
+
|
|
184
|
+
if (isIosDevice) {
|
|
185
|
+
setPositionFixed();
|
|
186
|
+
} else {
|
|
187
|
+
setOverflowHidden(options);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (isIosDevice) {
|
|
191
|
+
targetElement.ontouchstart = event => {
|
|
192
|
+
if (event.targetTouches.length === 1) {
|
|
193
|
+
// detect single touch.
|
|
194
|
+
initialClientY = event.targetTouches[0].clientY;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
targetElement.ontouchmove = event => {
|
|
198
|
+
if (event.targetTouches.length === 1) {
|
|
199
|
+
// detect single touch.
|
|
200
|
+
handleScroll(event, targetElement);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
if (!documentListenerAdded) {
|
|
205
|
+
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
|
|
206
|
+
documentListenerAdded = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const clearAllBodyScrollLocks = () => {
|
|
212
|
+
if (isIosDevice) {
|
|
213
|
+
// Clear all locks ontouchstart/ontouchmove handlers, and the references.
|
|
214
|
+
locks.forEach(lock => {
|
|
215
|
+
lock.targetElement.ontouchstart = null;
|
|
216
|
+
lock.targetElement.ontouchmove = null;
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
if (documentListenerAdded) {
|
|
220
|
+
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
|
|
221
|
+
documentListenerAdded = false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Reset initial clientY.
|
|
225
|
+
initialClientY = -1;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (isIosDevice) {
|
|
229
|
+
restorePositionSetting();
|
|
230
|
+
} else {
|
|
231
|
+
restoreOverflowSetting();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
locks = [];
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const enableBodyScroll = targetElement => {
|
|
238
|
+
if (!targetElement) {
|
|
239
|
+
// eslint-disable-next-line no-console
|
|
240
|
+
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
locks = locks.filter(lock => lock.targetElement !== targetElement);
|
|
245
|
+
|
|
246
|
+
if (isIosDevice) {
|
|
247
|
+
targetElement.ontouchstart = null;
|
|
248
|
+
targetElement.ontouchmove = null;
|
|
249
|
+
|
|
250
|
+
if (documentListenerAdded && locks.length === 0) {
|
|
251
|
+
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
|
|
252
|
+
documentListenerAdded = false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (isIosDevice) {
|
|
257
|
+
restorePositionSetting();
|
|
258
|
+
} else {
|
|
259
|
+
restoreOverflowSetting();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
type ModeSwitchProps = {
|
|
5
|
+
triggerClassName?: string;
|
|
6
|
+
/** The name of the local storage */
|
|
7
|
+
localStorageName?: string;
|
|
8
|
+
/** Style name for dark mode */
|
|
9
|
+
darkClassName?: string;
|
|
10
|
+
/** Set the light icon */
|
|
11
|
+
lightIcon?: React.ReactNode | string;
|
|
12
|
+
/** Set the dark icon */
|
|
13
|
+
darkIcon?: React.ReactNode | string;
|
|
14
|
+
/** -- */
|
|
15
|
+
tabIndex?: number;
|
|
16
|
+
onChange?: (e: any, param: boolean) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const ModeSwitch = (props: ModeSwitchProps) => {
|
|
21
|
+
const {
|
|
22
|
+
triggerClassName,
|
|
23
|
+
localStorageName,
|
|
24
|
+
darkClassName,
|
|
25
|
+
lightIcon,
|
|
26
|
+
darkIcon,
|
|
27
|
+
tabIndex,
|
|
28
|
+
onChange
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const darkBtnRef = useRef<any>(null);
|
|
32
|
+
const lightBtnRef = useRef<any>(null);
|
|
33
|
+
const [isDark, setIsDark] = useState<boolean>(false);
|
|
34
|
+
const _darkClassName = darkClassName ? darkClassName : 'dark-mode';
|
|
35
|
+
const _localStorageName = localStorageName ? localStorageName : 'SITE_THEME_MODE';
|
|
36
|
+
|
|
37
|
+
function handleClick(e) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
setIsDark(!isDark);
|
|
40
|
+
|
|
41
|
+
if (!isDark) {
|
|
42
|
+
document.body.classList.add(_darkClassName);
|
|
43
|
+
localStorage.setItem(_localStorageName, _darkClassName);
|
|
44
|
+
|
|
45
|
+
} else {
|
|
46
|
+
document.body.classList.remove(_darkClassName);
|
|
47
|
+
localStorage.removeItem(_localStorageName);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//
|
|
51
|
+
onChange?.(e, !isDark);
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
|
|
57
|
+
const modeName = localStorage.getItem(_localStorageName);
|
|
58
|
+
if (modeName !== null) {
|
|
59
|
+
document.body.classList.add(modeName);
|
|
60
|
+
setIsDark(true);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
|
|
68
|
+
<a className={triggerClassName ? triggerClassName : ''} tabIndex={tabIndex || -1} href="#" onClick={handleClick} >
|
|
69
|
+
<span ref={darkBtnRef} style={{ display: !isDark ? 'inline-block' : 'none' }}>{darkIcon || <>
|
|
70
|
+
<svg fill="#fff" width="26px" height="26px" viewBox="0 0 35 35"><path stroke="#000" strokeWidth="2" d="M10.895 7.574c0 7.55 5.179 13.67 11.567 13.67 1.588 0 3.101-0.38 4.479-1.063-1.695 4.46-5.996 7.636-11.051 7.636-6.533 0-11.83-5.297-11.83-11.83 0-4.82 2.888-8.959 7.023-10.803-0.116 0.778-0.188 1.573-0.188 2.39z"></path></svg>
|
|
71
|
+
</>}</span>
|
|
72
|
+
<span ref={lightBtnRef} style={{ display: isDark ? 'inline-block' : 'none' }}>{lightIcon || <>
|
|
73
|
+
<svg fill="#fff" height="26px" width="26px" viewBox="0 0 207.628 207.628"><circle cx="103.814" cy="103.814" r="45.868"/><path d="M103.814,157.183c-29.427,0-53.368-23.941-53.368-53.368s23.941-53.368,53.368-53.368s53.368,23.941,53.368,53.368S133.241,157.183,103.814,157.183z M103.814,65.446c-21.156,0-38.368,17.212-38.368,38.368s17.212,38.368,38.368,38.368s38.368-17.212,38.368-38.368S124.97,65.446,103.814,65.446z"/><path d="M103.814,39.385c-4.142,0-7.5-3.358-7.5-7.5V7.5c0-4.142,3.358-7.5,7.5-7.5s7.5,3.358,7.5,7.5v24.385C111.314,36.027,107.956,39.385,103.814,39.385z"/><path d="M103.814,207.628c-4.142,0-7.5-3.358-7.5-7.5v-24.385c0-4.142,3.358-7.5,7.5-7.5s7.5,3.358,7.5,7.5v24.385C111.314,204.271,107.956,207.628,103.814,207.628z"/><path d="M200.128,111.314h-24.385c-4.142,0-7.5-3.358-7.5-7.5s3.358-7.5,7.5-7.5h24.385c4.142,0,7.5,3.358,7.5,7.5S204.271,111.314,200.128,111.314z"/><path d="M31.885,111.314H7.5c-4.142,0-7.5-3.358-7.5-7.5s3.358-7.5,7.5-7.5h24.385c4.142,0,7.5,3.358,7.5,7.5S36.027,111.314,31.885,111.314z"/><path d="M154.676,60.452c-1.919,0-3.839-0.732-5.303-2.197c-2.929-2.929-2.929-7.678,0-10.606l17.243-17.242c2.929-2.929,7.678-2.93,10.606,0c2.929,2.929,2.929,7.678,0,10.606l-17.243,17.242C158.515,59.72,156.595,60.452,154.676,60.452z"/><path d="M35.709,179.419c-1.919,0-3.839-0.732-5.303-2.197c-2.929-2.929-2.929-7.678,0-10.606l17.243-17.243c2.929-2.929,7.678-2.929,10.606,0c2.929,2.929,2.929,7.678,0,10.606l-17.243,17.243C39.548,178.687,37.629,179.419,35.709,179.419z"/><path d="M171.918,179.419c-1.919,0-3.839-0.732-5.303-2.197l-17.243-17.243c-2.929-2.929-2.929-7.678,0-10.606c2.929-2.929,7.678-2.929,10.606,0l17.243,17.243c2.929,2.929,2.929,7.678,0,10.606C175.757,178.687,173.838,179.419,171.918,179.419z"/><path d="M52.952,60.452c-1.919,0-3.839-0.732-5.303-2.197L30.406,41.013c-2.929-2.929-2.929-7.677,0-10.606c2.929-2.929,7.678-2.93,10.606,0l17.243,17.242c2.929,2.929,2.929,7.677,0,10.606C56.791,59.72,54.872,60.452,52.952,60.452z"/></svg>
|
|
74
|
+
</>}</span>
|
|
75
|
+
</a>
|
|
76
|
+
|
|
77
|
+
</>
|
|
78
|
+
)
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export default ModeSwitch;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/* ======================================================
|
|
2
|
+
<!-- Multifunction Select -->
|
|
3
|
+
/* ====================================================== */
|
|
4
|
+
|
|
5
|
+
.multifunc-select__wrapper {
|
|
6
|
+
|
|
7
|
+
--multi-sel-popwin-min-width: 200px;
|
|
8
|
+
--multi-sel-focus-border-color:#86b7fe;
|
|
9
|
+
--multi-sel-focus-box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
|
|
10
|
+
--multi-sel-placeholder-color: rgba(33, 37, 41, 0.75);
|
|
11
|
+
--multi-sel-input-placeholder-color: #c5c9d1;
|
|
12
|
+
--multi-sel-control-wrapper-bg: #fff;
|
|
13
|
+
--multi-sel-control-wrapper-border-color: #dee2e6;
|
|
14
|
+
--multi-sel-control-list-bg: #efefef;
|
|
15
|
+
--multi-sel-arrow-fill: #a5a5a5;
|
|
16
|
+
--multi-sel-searchbtn-fill: #a5a5a5;
|
|
17
|
+
--multi-sel-searchbtn-hover-fill: #333;
|
|
18
|
+
--multi-sel-removebtn-fill: #000;
|
|
19
|
+
--multi-sel-removebtn-hover-fill: #f00;
|
|
20
|
+
|
|
21
|
+
--multi-sel-listgroup-tool-bg: rgb(248,249,250);
|
|
22
|
+
--multi-sel-listgroup-checkbox: #a5a5a5;
|
|
23
|
+
--multi-sel-listgroup-item-hover-focus-bg: rgba(0,0,0,.1);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/*------ Placeholder for input ------*/
|
|
27
|
+
input::placeholder {
|
|
28
|
+
color: var(--multi-sel-input-placeholder-color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/*------ Arrow ------*/
|
|
33
|
+
.arrow {
|
|
34
|
+
svg .arrow-fill-g {
|
|
35
|
+
fill: var(--multi-sel-arrow-fill);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/*------ Input ------*/
|
|
41
|
+
[data-select]:focus {
|
|
42
|
+
box-shadow: none;
|
|
43
|
+
border-color: transparent;
|
|
44
|
+
outline: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*------ List ------*/
|
|
48
|
+
.list-group {
|
|
49
|
+
display: none;
|
|
50
|
+
min-width: var(--multi-sel-popwin-min-width);
|
|
51
|
+
|
|
52
|
+
.bg-light {
|
|
53
|
+
background-color: var(--multi-sel-listgroup-tool-bg) !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.list-group-item {
|
|
57
|
+
svg {
|
|
58
|
+
fill: transparent;
|
|
59
|
+
|
|
60
|
+
path {
|
|
61
|
+
stroke: var(--multi-sel-listgroup-checkbox);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.item-selected {
|
|
66
|
+
svg {
|
|
67
|
+
fill: var(--multi-sel-listgroup-checkbox);
|
|
68
|
+
|
|
69
|
+
path {
|
|
70
|
+
stroke: var(--multi-sel-listgroup-checkbox);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:hover,
|
|
76
|
+
&:focus {
|
|
77
|
+
background-color: var(--multi-sel-listgroup-item-hover-focus-bg);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
&.active {
|
|
86
|
+
.list-group {
|
|
87
|
+
display: block;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/*------ Multiple selection ------*/
|
|
93
|
+
.multifunc-select-multi__control-select-all {
|
|
94
|
+
.btn {
|
|
95
|
+
font-size: 0.75rem;
|
|
96
|
+
padding: 0.1rem 0.5rem;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.multifunc-select-multi__wrapper {
|
|
101
|
+
|
|
102
|
+
position: absolute;
|
|
103
|
+
top: 0;
|
|
104
|
+
width: 100%;
|
|
105
|
+
pointer-events: none;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
ul,
|
|
109
|
+
li {
|
|
110
|
+
padding: 0;
|
|
111
|
+
margin: 0;
|
|
112
|
+
list-style: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.multifunc-select-multi__control-searchbtn {
|
|
116
|
+
z-index: 5;
|
|
117
|
+
pointer-events: auto;
|
|
118
|
+
|
|
119
|
+
svg,
|
|
120
|
+
path {
|
|
121
|
+
fill: var(--multi-sel-searchbtn-fill);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&:hover {
|
|
125
|
+
svg,
|
|
126
|
+
path {
|
|
127
|
+
fill: var(--multi-sel-searchbtn-hover-fill);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.multifunc-select-multi__control-wrapper {
|
|
133
|
+
|
|
134
|
+
> div {
|
|
135
|
+
position: relative;
|
|
136
|
+
|
|
137
|
+
/* bootstrap style that match ".form-control" */
|
|
138
|
+
//padding: 0.375rem 0.75rem;
|
|
139
|
+
background-color: var(--multi-sel-control-wrapper-bg);
|
|
140
|
+
background-clip: padding-box;
|
|
141
|
+
border: 1px solid var(--multi-sel-control-wrapper-border-color);
|
|
142
|
+
appearance: none;
|
|
143
|
+
border-radius: 0.375rem;
|
|
144
|
+
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
145
|
+
padding-bottom: 1px;
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
ul.multifunc-select-multi__list {
|
|
153
|
+
margin-right: 1rem;
|
|
154
|
+
|
|
155
|
+
li {
|
|
156
|
+
display: inline-block;
|
|
157
|
+
margin: 5px;
|
|
158
|
+
margin-bottom: 0;
|
|
159
|
+
padding: .1rem 1.5rem .1rem 1rem;
|
|
160
|
+
font-size: 0.875rem;
|
|
161
|
+
background: var(--multi-sel-control-list-bg);
|
|
162
|
+
border-radius: 30px;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
text-overflow: ellipsis;
|
|
165
|
+
position: relative;
|
|
166
|
+
|
|
167
|
+
&.multifunc-select-multi__list-item-placeholder {
|
|
168
|
+
background: transparent;
|
|
169
|
+
color: var(--multi-sel-placeholder-color);
|
|
170
|
+
padding-left: 0.75rem;
|
|
171
|
+
padding-right: 0;
|
|
172
|
+
margin-left: 0;
|
|
173
|
+
white-space: nowrap;
|
|
174
|
+
|
|
175
|
+
&.hide {
|
|
176
|
+
min-width: 100px;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
> a {
|
|
182
|
+
font-weight: 400;
|
|
183
|
+
opacity: .6;
|
|
184
|
+
font-size: 18px;
|
|
185
|
+
line-height: 20px;
|
|
186
|
+
position: absolute;
|
|
187
|
+
right: 8px;
|
|
188
|
+
top: 0;
|
|
189
|
+
pointer-events: auto;
|
|
190
|
+
|
|
191
|
+
path {
|
|
192
|
+
fill: var(--multi-sel-removebtn-fill);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&:hover {
|
|
196
|
+
path {
|
|
197
|
+
fill: var(--multi-sel-removebtn-hover-fill);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.multifunc-select-multi__control-blinking-cursor {
|
|
207
|
+
display: inline-block;
|
|
208
|
+
color: var(--multi-sel-placeholder-color);
|
|
209
|
+
|
|
210
|
+
&.animated {
|
|
211
|
+
animation: 1s multi-sel-blink step-end infinite;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&.control-placeholder {
|
|
215
|
+
color: var(--multi-sel-input-placeholder-color);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@keyframes multi-sel-blink {
|
|
221
|
+
from,
|
|
222
|
+
to {
|
|
223
|
+
color: transparent;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
50% {
|
|
227
|
+
color: var(--multi-sel-placeholder-color);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
/*------------*/
|
|
235
|
+
[data-select]:focus {
|
|
236
|
+
cursor: text !important;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&:not(.multiple-selection) {
|
|
240
|
+
[data-select]:focus {
|
|
241
|
+
box-shadow: var(--multi-sel-focus-box-shadow);
|
|
242
|
+
border-color: var(--multi-sel-focus-border-color);
|
|
243
|
+
outline: 0;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
&.active {
|
|
249
|
+
.list-group {
|
|
250
|
+
display: block;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
&.focus {
|
|
256
|
+
|
|
257
|
+
.multifunc-select-multi__control-wrapper {
|
|
258
|
+
> div {
|
|
259
|
+
box-shadow: var(--multi-sel-focus-box-shadow);
|
|
260
|
+
border-color: var(--multi-sel-focus-border-color);
|
|
261
|
+
outline: 0;
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
|