Skip to content

Commit f6d2210

Browse files
committed
chore: delete dead code
1 parent 79bddb8 commit f6d2210

File tree

6 files changed

+3
-256
lines changed

6 files changed

+3
-256
lines changed

src/Shared/Slot.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Shared/classes.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Shared/element-closest.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Shared/helper.js

Lines changed: 2 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import PropTypes from 'prop-types';
2-
import isFunction from 'lodash.isfunction';
32

43
let globalCssModule;
54

@@ -57,19 +56,6 @@ export const TransitionStatuses = {
5756
EXITED: 'exited',
5857
};
5958

60-
export const keyCodes = {
61-
esc: 27,
62-
space: 32,
63-
enter: 13,
64-
tab: 9,
65-
up: 38,
66-
down: 40,
67-
home: 36,
68-
end: 35,
69-
n: 78,
70-
p: 80,
71-
};
72-
7359
export const canUseDOM = !!(
7460
typeof window !== 'undefined' &&
7561
window.document &&
@@ -94,23 +80,6 @@ const tagPropType = PropTypes.oneOfType([
9480
]))
9581
]);
9682

97-
export const focusableElements = [
98-
'a[href]',
99-
'area[href]',
100-
'input:not([disabled]):not([type=hidden])',
101-
'select:not([disabled])',
102-
'textarea:not([disabled])',
103-
'button:not([disabled])',
104-
'object',
105-
'embed',
106-
'[tabindex]:not(.modal)',
107-
'audio[controls]',
108-
'video[controls]',
109-
'[contenteditable]:not([contenteditable="false"])',
110-
];
111-
112-
export const defaultToggleEvents = ['touchstart', 'click'];
113-
11483
export function omit(obj, omitKeys) {
11584
const result = {};
11685
Object.keys(obj).forEach(key => {
@@ -135,20 +104,6 @@ export function pick(obj, keys) {
135104
return result;
136105
}
137106

138-
export function conditionallyUpdateScrollbar() {
139-
const scrollbarWidth = getScrollbarWidth();
140-
// https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.6/js/src/modal.js#L433
141-
const fixedContent = document.querySelectorAll(
142-
'.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
143-
)[0];
144-
const bodyPadding = fixedContent
145-
? parseInt(fixedContent.style.paddingRight || 0, 10)
146-
: 0;
147-
148-
if (isBodyOverflowing()) {
149-
setScrollbarWidth(bodyPadding + scrollbarWidth);
150-
}
151-
}
152107

153108
export function DOMElement(props, propName, componentName) {
154109
if (!(props[propName] instanceof Element)) {
@@ -162,49 +117,6 @@ export function DOMElement(props, propName, componentName) {
162117
}
163118
}
164119

165-
export function isReactRefObj(target) {
166-
if (target && typeof target === 'object') {
167-
return 'current' in target;
168-
}
169-
return false;
170-
}
171-
172-
export function findDOMElements(target) {
173-
if (isReactRefObj(target)) {
174-
return target.current;
175-
}
176-
if (isFunction(target)) {
177-
return target();
178-
}
179-
if (typeof target === 'string' && canUseDOM) {
180-
let selection = document.querySelectorAll(target);
181-
if (!selection.length) {
182-
selection = document.querySelectorAll(`#${target}`);
183-
}
184-
if (!selection.length) {
185-
throw new Error(
186-
`The target '${target}' could not be identified in the dom, tip: check spelling`
187-
);
188-
}
189-
return selection;
190-
}
191-
return target;
192-
}
193-
194-
export function isArrayOrNodeList(els) {
195-
if (els === null) {
196-
return false;
197-
}
198-
return Array.isArray(els) || (canUseDOM && typeof els.length === 'number');
199-
}
200-
201-
export function getTarget(target) {
202-
const els = findDOMElements(target);
203-
if (isArrayOrNodeList(els)) {
204-
return els[0];
205-
}
206-
return els;
207-
}
208120

209121
const mapToCssModules = (className = '', cssModule = globalCssModule)=>{
210122
if (!cssModule) return className;
@@ -214,108 +126,16 @@ const mapToCssModules = (className = '', cssModule = globalCssModule)=>{
214126
.join(' ');
215127
}
216128

217-
export function colog() {
218-
if (process.env.NODE_ENV === 'development')
219-
console.log.apply(this, arguments);
220-
}
221-
222-
let warned = {};
223-
export function warnOnce(message) {
224-
if (!warned[message]) {
225-
/* istanbul ignore else */
226-
if (typeof console !== 'undefined') {
227-
console.error(message); // eslint-disable-line no-console
228-
}
229-
warned[message] = true;
230-
}
231-
}
232129

233130
function deprecated(propType, explanation) {
234131
return function validate(props, propName, componentName, ...rest) {
235132
if (props[propName] !== null && typeof props[propName] !== 'undefined') {
236133
warnOnce(
237134
`"${propName}" property of "${componentName}" has been deprecated.\n${explanation}`
238-
);
135+
)
239136
}
240137
return propType(props, propName, componentName, ...rest);
241-
};
242-
}
243-
244-
export {tagPropType, mapToCssModules, deprecated};
245-
246-
export function getOriginalBodyPadding() {
247-
const style = window.getComputedStyle(document.body, null);
248-
249-
return parseInt((style && style.getPropertyValue('padding-right')) || 0, 10);
250-
}
251-
252-
// https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.4/js/src/modal.js#L436-L443
253-
export function getScrollbarWidth() {
254-
let scrollDiv = document.createElement('div');
255-
// .modal-scrollbar-measure styles // https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.4/scss/_modal.scss#L106-L113
256-
scrollDiv.style.position = 'absolute';
257-
scrollDiv.style.top = '-9999px';
258-
scrollDiv.style.width = '50px';
259-
scrollDiv.style.height = '50px';
260-
scrollDiv.style.overflow = 'scroll';
261-
document.body.appendChild(scrollDiv);
262-
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
263-
document.body.removeChild(scrollDiv);
264-
return scrollbarWidth;
265-
}
266-
267-
export function setScrollbarWidth(padding) {
268-
document.body.style.paddingRight = padding > 0 ? `${padding}px` : null;
269-
}
270-
271-
export function isBodyOverflowing() {
272-
return document.body.clientWidth < window.innerWidth;
273-
}
274-
275-
export function addMultipleEventListeners(_els, handler, _events, useCapture) {
276-
let els = _els;
277-
if (!isArrayOrNodeList(els)) {
278-
els = [els];
279138
}
280-
let events = _events;
281-
if (typeof events === 'string') {
282-
events = events.split(/\s+/);
283-
}
284-
if (
285-
!isArrayOrNodeList(els) ||
286-
typeof handler !== 'function' ||
287-
!Array.isArray(events)
288-
) {
289-
throw new Error(`
290-
The first argument of this function must be DOM node or an array on DOM nodes or NodeList.
291-
The second must be a function.
292-
The third is a string or an array of strings that represents DOM events
293-
`);
294-
}
295-
Array.prototype.forEach.call(events, event => {
296-
Array.prototype.forEach.call(els, el => {
297-
el.addEventListener(event, handler, useCapture);
298-
});
299-
});
300-
return function removeEvents() {
301-
Array.prototype.forEach.call(events, event => {
302-
Array.prototype.forEach.call(els, el => {
303-
el.removeEventListener(event, handler, useCapture);
304-
});
305-
});
306-
};
307139
}
308140

309-
export function toggleClasses (toggleClass, classList, force) {
310-
const level = classList.indexOf(toggleClass)
311-
const removeClassList = classList.slice(0, level)
312-
removeClassList.map((className) => document.body.classList.remove(className))
313-
if (force === true) {
314-
document.body.classList.add(toggleClass);
315-
} else if (force === false) {
316-
document.body.classList.remove(toggleClass);
317-
} else {
318-
document.body.classList.toggle(toggleClass);
319-
}
320-
return document.body.classList.contains(toggleClass);
321-
}
141+
export { tagPropType, mapToCssModules, deprecated }

src/Shared/index.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ export {default as CWidgetProgressIcon} from './CWidgetProgressIcon';
124124
export {default as CWidgetDropdown} from './CWidgetDropdown';
125125
export {default as CWidgetSimple} from './CWidgetSimple';
126126

127-
import { mapToCssModules, tagPropType, colog } from './Shared/helper'
127+
import { mapToCssModules, tagPropType } from './Shared/helper'
128128
export { mapToCssModules }
129129
export { tagPropType }
130-
export { colog }

0 commit comments

Comments
 (0)