Skip to content

Commit f25cf59

Browse files
committed
fix: components cleanup
1 parent c8905a3 commit f25cf59

33 files changed

+158
-162
lines changed

src/CAlert.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const CAlert = props=>{
1515
cssModule,
1616
custom,
1717
//
18-
innerRef,
1918
toggle,
2019
transition,
2120
closeAriaLabel,
@@ -61,7 +60,7 @@ const CAlert = props=>{
6160
return (
6261
<CFade {...attributes} {...alertTransition} tag={Tag} className={classes} in={show} role="alert">
6362
{!custom ?
64-
<button type="button" className={closeClasses} aria-label={closeAriaLabel} onClick={toggle} {...closeProps} ref={innerRef}>
63+
<button type="button" className={closeClasses} aria-label={closeAriaLabel} onClick={toggle} {...closeProps}>
6564
<span aria-hidden="true">{iconSlot}</span>
6665
</button>
6766
: null}

src/CButton.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ const CButton = props=>{
6868
type={(Tag === 'button' && attributes.onClick) ? 'button' : undefined}
6969
{...attributes}
7070
className={classes}
71-
ref={innerRef}
7271
onClick={onClick}
7372
aria-label={ariaLabel || defaultAriaLabel}
73+
ref={innerRef}
7474
children={textHtml ? textHtml : children}
7575
/>;
7676

src/CButtonGroup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const CButtonGroup = props=>{
2727
), cssModule);
2828

2929
return (
30-
<Tag {...attributes} className={classes} ref={innerRef}/>
30+
<Tag {...attributes} className={classes} ref={innerRef} />
3131
);
3232

3333
}

src/CButtonToolbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const CButtonToolbar = props=>{
2626
), cssModule);
2727

2828
return (
29-
<Tag {...attributes} className={classes} ref={innerRef}/>
29+
<Tag {...attributes} className={classes} ref={innerRef} />
3030
);
3131

3232
}

src/CCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ CCard.propTypes = {
8484
cssModule: PropTypes.object,
8585
custom: PropTypes.bool,
8686
//
87+
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
8788
align: PropTypes.string,
8889
color: PropTypes.string,
8990
borderColor: PropTypes.string,
9091
textColor: PropTypes.string,
9192
accentColor: PropTypes.string,
9293
bodyClassName: PropTypes.string,
9394
bodyProps: PropTypes.object,
94-
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
9595
headerSlot: PropTypes.node,
9696
footerSlot: PropTypes.node
9797
}

src/CCardLink.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import classNames from 'classnames';
44
import {tagPropType, mapToCssModules} from './Shared/helper.js';
5+
import CLink from './CLink';
56

67
//component - CoreUI / CCardLink
78

@@ -12,7 +13,6 @@ const CCardLink = props=>{
1213
className,
1314
cssModule,
1415
//
15-
innerRef,
1616
...attributes
1717
} = props;
1818

@@ -24,7 +24,7 @@ const CCardLink = props=>{
2424
), cssModule);
2525

2626
return (
27-
<Tag {...attributes} className={classes} ref={innerRef} />
27+
<CLink {...attributes} className={classes} />
2828
);
2929

3030
}
@@ -38,7 +38,6 @@ CCardLink.propTypes = {
3838
};
3939

4040
CCardLink.defaultProps = {
41-
tag: 'a'
4241
};
4342

4443
export default CCardLink;

src/CCarousel.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CCarouselCaption from './CCarouselCaption';
1111
const CCarousel = props=>{
1212

1313
const {
14+
//
1415
custom,
1516
autoPlay,
1617
indicators,

src/CCollapse.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const CCollapse = props=>{
1313
custom,
1414
//
1515
toggle,
16-
show
16+
show,
17+
...attributes
1718
} = props;
1819

1920
const [isOpen, setIsOpen] = useState(props.defaultOpen || false);
@@ -56,7 +57,7 @@ const CCollapse = props=>{
5657

5758
//render
5859

59-
return <CCollapseCustom show={show} {...omit(props, omitKeys)} />;
60+
return <CCollapseCustom {...attributes} how={show} {...omit(props, omitKeys)} />;
6061

6162
}
6263

src/CCustomInput.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ const CCustomInput = props=>{
3838
), cssModule);
3939

4040
if (type === 'select') {
41-
return <select {...attributes} ref={innerRef} className={classNames(validationClassNames, customClass)}>{children}</select>;
41+
return <select {...attributes} className={classNames(validationClassNames, customClass)} ref={innerRef}>{children}</select>;
4242
}
4343

4444
if (type === 'file') {
4545
return (
46-
<div className={customClass} {...wrapperProps}>
47-
<input {...attributes} ref={innerRef} className={classNames(validationClassNames, mapToCssModules('custom-file-input', cssModule))} />
46+
<div className={customClass} {...wrapperProps} ref={innerRef}>
47+
<input {...attributes} className={classNames(validationClassNames, mapToCssModules('custom-file-input', cssModule))} />
4848
<label className={mapToCssModules('custom-file-label', cssModule)} htmlFor={attributes.id}>{label || 'Choose file'}</label>
4949
</div>
5050
);
5151
}
5252

5353
if (type !== 'checkbox' && type !== 'radio' && type !== 'switch') {
54-
return <input {...attributes} ref={innerRef} className={classNames(validationClassNames, customClass)} />;
54+
return <input {...attributes} className={classNames(validationClassNames, customClass)} ref={innerRef} />;
5555
}
5656

5757
const wrapperClasses = classNames(
@@ -67,8 +67,8 @@ const CCustomInput = props=>{
6767
<input
6868
{...attributes}
6969
type={type === 'switch' ? 'checkbox' : type}
70-
ref={innerRef}
7170
className={classNames(validationClassNames, mapToCssModules('custom-control-input', cssModule))}
71+
ref={innerRef}
7272
/>
7373
<label className={mapToCssModules('custom-control-label', cssModule)} htmlFor={attributes.id}>{label}</label>
7474
{children}

src/CDataTable.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -604,11 +604,7 @@ CDataTable.propTypes = {
604604
cssModule: PropTypes.object,
605605
//custom: PropTypes.bool,
606606
//
607-
innerRef: PropTypes.oneOfType([
608-
PropTypes.object,
609-
PropTypes.string,
610-
PropTypes.func,
611-
]),
607+
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
612608
overTableSlot: PropTypes.node,
613609
colNameSlot: PropTypes.node,
614610
columnHeaderSlot: PropTypes.array,

src/CDropdownCustom.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ export const Context = React.createContext({});
1010
//component - CoreUI / CPopperContentWrapper
1111

1212
class CPopperContentWrapper extends React.Component {
13-
1413
getChildContext(){
1514
return this.context;
1615
}
17-
1816
render(){
1917
return this.props.children;
2018
}
21-
2219
}
2320

2421
CPopperContentWrapper.contextType = Context;
@@ -38,6 +35,7 @@ const CDropdownCustom = props=>{
3835
className,
3936
cssModule,
4037
//
38+
innerRef,
4139
dropup,
4240
show,
4341
group,
@@ -50,14 +48,18 @@ const CDropdownCustom = props=>{
5048
} = omit(props, ['toggle', 'disabled', 'inNavbar', 'direction']);
5149

5250
const fields = useRef({
53-
firstRender: true
51+
firstRender: true,
52+
ref: {current: null}
5453
}).current;
5554

56-
const ref = useRef(null);
55+
const reference = (r)=>{
56+
fields.ref.current = r;
57+
innerRef && innerRef(r);
58+
}
5759

5860
const getContainer = ()=>{
5961
if (fields._$container) return fields._$container;
60-
fields._$container = ReactDOM.findDOMNode(ref.current);
62+
fields._$container = ReactDOM.findDOMNode(fields.ref.current);
6163
return fields._$container;
6264
}
6365

@@ -224,7 +226,7 @@ const CDropdownCustom = props=>{
224226
inNavbar: props.inNavbar,
225227
}}>
226228
<CPopperContentWrapper>
227-
<Manager {...attributes} className={classes} onKeyDown={handleKeyDown} ref={ref} />
229+
<Manager {...attributes} className={classes} onKeyDown={handleKeyDown} ref={reference} />
228230
</CPopperContentWrapper>
229231
</Context.Provider>
230232
);

src/CDropdownMenu.js

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const CDropdownMenu = props=>{
4242
'show': context.isOpen,
4343
}
4444
), cssModule);
45-
//dash
4645

4746
let Tag = tag;
4847

src/CFooter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CFooter.propTypes = {
4343

4444
CFooter.defaultProps = {
4545
tag: 'footer',
46-
fixed: true
46+
fixed: false
4747
};
4848

4949
export default CFooter;

src/CHeaderNavLink.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const CHeaderNavLink = props=>{
1212
className,
1313
cssModule,
1414
//
15-
innerRef,
1615
...attributes
1716
} = props;
1817

@@ -24,7 +23,7 @@ const CHeaderNavLink = props=>{
2423
), cssModule);
2524

2625
return (
27-
<CLink {...attributes} className={classes} ref={innerRef} />
26+
<CLink {...attributes} className={classes} />
2827
);
2928

3029
}

src/CIconRaw.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ const CIconRaw = props=>{
4242
if (content) {
4343
return content
4444
} else if (React.icons) {
45-
return React.icons[iconName] ? React.icons[iconName] : console.log(iconName)
45+
return React.icons[iconName] ?
46+
React.icons[iconName] :
47+
React.icons['cil'+iconName] ?
48+
React.icons['cil'+iconName] :
49+
console.log('Not existing icon: '+iconName)
4650
}
4751
return content;
4852
})();

src/CInput.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ const CInput = props=>{
2727
let fields = useRef({}).current;
2828

2929
const getRef = (ref)=>{
30-
if (props.innerRef) {
31-
props.innerRef(ref);
32-
}
3330
fields.ref = ref;
31+
innerRef && innerRef(ref);
3432
}
3533

3634
const focus = ()=>{

0 commit comments

Comments
 (0)