Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions src/bundle/ui-dev/src/modules/common/alert/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

const Alert = ({
type,
title,
subtitle,
size,
iconName: iconNameProp,
iconPath,
showSubtitleBelow,
showCloseBtn,
onClose,
extraClasses,
children,
title = null,
subtitle = null,
size = 'medium',
iconName: iconNameProp = null,
iconPath = null,
showSubtitleBelow = false,
showCloseBtn = false,
onClose = () => {},
extraClasses = '',
children = null,
}) => {
const className = createCssClassNames({
'alert ibexa-alert': true,
Expand Down Expand Up @@ -61,29 +61,16 @@

Alert.propTypes = {
type: PropTypes.oneOf(Object.values(ICON_NAME_MAP)).isRequired,
title: PropTypes.string,

Check failure on line 64 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "title" is not required, but has no corresponding defaultProps declaration
subtitle: PropTypes.string,

Check failure on line 65 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "subtitle" is not required, but has no corresponding defaultProps declaration
iconName: PropTypes.string,

Check failure on line 66 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "iconName" is not required, but has no corresponding defaultProps declaration
iconPath: PropTypes.string,

Check failure on line 67 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "iconPath" is not required, but has no corresponding defaultProps declaration
showSubtitleBelow: PropTypes.bool,

Check failure on line 68 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "showSubtitleBelow" is not required, but has no corresponding defaultProps declaration
showCloseBtn: PropTypes.bool,

Check failure on line 69 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "showCloseBtn" is not required, but has no corresponding defaultProps declaration
onClose: PropTypes.func,

Check failure on line 70 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "onClose" is not required, but has no corresponding defaultProps declaration
extraClasses: PropTypes.string,

Check failure on line 71 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "extraClasses" is not required, but has no corresponding defaultProps declaration
children: PropTypes.element,

Check failure on line 72 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "children" is not required, but has no corresponding defaultProps declaration
size: PropTypes.oneOf(SIZES),

Check failure on line 73 in src/bundle/ui-dev/src/modules/common/alert/alert.js

View workflow job for this annotation

GitHub Actions / Frontend build test

propType "size" is not required, but has no corresponding defaultProps declaration
};

Alert.defaultProps = {
title: null,
subtitle: null,
iconName: null,
iconPath: null,
showSubtitleBelow: false,
showCloseBtn: false,
onClose: () => {},
extraClasses: '',
children: null,
size: 'medium',
};

export default Alert;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createCssClassNames } from '@ibexa-admin-ui/src/bundle/ui-dev/src/modul

export const DraggableContext = createContext();

const DraggableDialog = ({ children, referenceElement, positionOffset }) => {
const DraggableDialog = ({ children = null, referenceElement, positionOffset = () => ({ x: 0, y: 0 }) }) => {
const rootDOMElement = getRootDOMElement();
const containerRef = useRef();
const dragOffsetPosition = useRef({ x: 0, y: 0 });
Expand Down Expand Up @@ -149,9 +149,4 @@ DraggableDialog.propTypes = {
positionOffset: PropTypes.func,
};

DraggableDialog.defaultProps = {
children: null,
positionOffset: () => ({ x: 0, y: 0 }),
};

export default DraggableDialog;
24 changes: 7 additions & 17 deletions src/bundle/ui-dev/src/modules/common/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const Dropdown = ({
value,
options,
onChange,
small,
single,
disabled,
placeholder,
extraClasses,
renderSelectedItem,
minSearchItems,
small = false,
single = false,
disabled = false,
placeholder = null,
extraClasses = '',
renderSelectedItem = (item) => item?.label,
minSearchItems = MIN_SEARCH_ITEMS_DEFAULT,
}) => {
const Translator = getTranslator();
const containerRef = useRef();
Expand Down Expand Up @@ -282,14 +282,4 @@ Dropdown.propTypes = {
minSearchItems: PropTypes.number,
};

Dropdown.defaultProps = {
small: false,
single: false,
disabled: false,
placeholder: null,
extraClasses: '',
renderSelectedItem: (item) => item?.label,
minSearchItems: MIN_SEARCH_ITEMS_DEFAULT,
};

export default Dropdown;
18 changes: 5 additions & 13 deletions src/bundle/ui-dev/src/modules/common/icon/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import { createCssClassNames } from '../helpers/css.class.names';
import UrlIcon from './urlIcon';
import InculdedIcon from './inculdedIcon';

const Icon = (props) => {
const Icon = ({ extraClasses = '', name = null, customPath = '', useIncludedIcon = false, defaultIconName = 'about-info' }) => {
const cssClass = createCssClassNames({
'ibexa-icon': true,
[props.extraClasses]: true,
[extraClasses]: true,
});

const isIconIncluded = props.useIncludedIcon || isExternalInstance();
const isIconIncluded = useIncludedIcon || isExternalInstance();

return (
<>
{isIconIncluded ? (
<InculdedIcon cssClass={cssClass} name={props.name} defaultIconName={props.defaultIconName} />
<InculdedIcon cssClass={cssClass} name={name} defaultIconName={defaultIconName} />
) : (
<UrlIcon cssClass={cssClass} name={props.name} customPath={props.customPath} />
<UrlIcon cssClass={cssClass} name={name} customPath={customPath} />
)}
</>
);
Expand All @@ -34,12 +34,4 @@ Icon.propTypes = {
defaultIconName: PropTypes.string,
};

Icon.defaultProps = {
customPath: null,
name: null,
extraClasses: null,
useIncludedIcon: false,
defaultIconName: 'about-info',
};

export default Icon;
9 changes: 1 addition & 8 deletions src/bundle/ui-dev/src/modules/common/icon/inculdedIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ const iconsMap = {
warning: Warning,
};

const InculdedIcon = (props) => {
const { name, cssClass, defaultIconName } = props;
const InculdedIcon = ({ name = 'about-info', cssClass = '', defaultIconName = 'about-info' }) => {
const IconComponent = iconsMap[name] ?? iconsMap[defaultIconName];

return <IconComponent className={cssClass} />;
Expand All @@ -110,10 +109,4 @@ InculdedIcon.propTypes = {
defaultIconName: PropTypes.string,
};

InculdedIcon.defaultProps = {
cssClass: '',
name: 'about-info',
defaultIconName: 'about-info',
};

export default InculdedIcon;
12 changes: 3 additions & 9 deletions src/bundle/ui-dev/src/modules/common/icon/urlIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import PropTypes from 'prop-types';

import { getIconPath } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/icon.helper';

const UrlIcon = (props) => {
const linkHref = props.customPath ?? getIconPath(props.name);
const UrlIcon = ({ cssClass = '', name = null, customPath = null }) => {
const linkHref = customPath && customPath !== '' ? customPath : getIconPath(name);

return (
<svg className={props.cssClass}>
<svg className={cssClass}>
<use xlinkHref={linkHref} />
</svg>
);
Expand All @@ -19,10 +19,4 @@ UrlIcon.propTypes = {
customPath: PropTypes.string,
};

UrlIcon.defaultProps = {
customPath: null,
name: null,
cssClass: '',
};

export default UrlIcon;
7 changes: 1 addition & 6 deletions src/bundle/ui-dev/src/modules/common/input/filter.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { createCssClassNames } from '../../common/helpers/css.class.names';
import { getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper';

const Search = ({ onChange, placeholder, extraClasses, value }) => {
const Search = ({ onChange, placeholder = '', extraClasses = '', value }) => {
const Translator = getTranslator();
const inputPlaceholder =
placeholder || Translator.trans(/*@Desc("Search...")*/ 'search.placeholder', {}, 'ibexa_universal_discovery_widget');
Expand All @@ -24,9 +24,4 @@ Search.propTypes = {
value: PropTypes.string.isRequired,
};

Search.defaultProps = {
placeholder: '',
extraClasses: '',
};

export default Search;
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';

const PaginationButton = ({ label, disabled, additionalClasses, buttonAdditionalClasses, onPageChange, pageIndex }) => {
const PaginationButton = ({
label = '',
disabled = false,
additionalClasses = '',
buttonAdditionalClasses = '',
onPageChange = () => {},
pageIndex = null,
}) => {
const handleClick = () => {
if (!disabled && Number.isInteger(pageIndex)) {
onPageChange(pageIndex);
Expand Down Expand Up @@ -30,13 +37,4 @@ PaginationButton.propTypes = {
buttonAdditionalClasses: PropTypes.string,
};

PaginationButton.defaultProps = {
pageIndex: null,
label: '',
disabled: false,
additionalClasses: '',
buttonAdditionalClasses: '',
onPageChange: () => {},
};

export default PaginationButton;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createCssClassNames } from '../helpers/css.class.names';

import { getTranslator } from '../../../../../Resources/public/js/scripts/helpers/context.helper';

const PaginationInfo = ({ totalCount, viewingCount, extraClasses }) => {
const PaginationInfo = ({ totalCount, viewingCount, extraClasses = '' }) => {
if (totalCount === 0) {
return null;
}
Expand All @@ -31,8 +31,4 @@ PaginationInfo.propTypes = {
extraClasses: PropTypes.string,
};

PaginationInfo.defaultProps = {
extraClasses: '',
};

export default PaginationInfo;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import PopupMenuItem from './popup.menu.item';
import { showItem } from './popup.menu.helper';

const PopupMenuGroup = ({ items, filterText, onItemClick }) => {
const PopupMenuGroup = ({ items = [], filterText = '', onItemClick }) => {
const isAnyItemVisible = items.some((item) => showItem(item, filterText));

if (!isAnyItemVisible) {
Expand All @@ -30,9 +30,4 @@ PopupMenuGroup.propTypes = {
filterText: PropTypes.string,
};

PopupMenuGroup.defaultProps = {
items: [],
filterText: '',
};

export default PopupMenuGroup;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';

import { showItem } from './popup.menu.helper';

const PopupMenuItem = ({ item, filterText, onItemClick }) => {
const PopupMenuItem = ({ item, filterText = '', onItemClick }) => {
if (!showItem(item, filterText)) {
return null;
}
Expand All @@ -25,8 +25,4 @@ PopupMenuItem.propTypes = {
filterText: PropTypes.string,
};

PopupMenuItem.defaultProps = {
filterText: '',
};

export default PopupMenuItem;
21 changes: 10 additions & 11 deletions src/bundle/ui-dev/src/modules/common/popup-menu/popup.menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ import PopupMenuGroup from './popup.menu.group';

const MIN_ITEMS_LIST_HEIGHT = 150;

const PopupMenu = ({ extraClasses, footer, items, onItemClick, positionOffset, referenceElement, scrollContainer, onClose }) => {
const PopupMenu = ({
extraClasses = '',
footer = null,
items = [],
onItemClick = () => {},
positionOffset = () => ({ x: 0, y: 0 }),
referenceElement,
scrollContainer = getRootDOMElement(),
onClose = () => {},
}) => {
const containerRef = useRef();
const [isRendered, setIsRendered] = useState(false);
const [itemsListStyles, setItemsListStyles] = useState({
Expand Down Expand Up @@ -108,14 +117,4 @@ PopupMenu.propTypes = {
scrollContainer: PropTypes.node,
};

PopupMenu.defaultProps = {
extraClasses: '',
footer: null,
items: [],
onClose: () => {},
onItemClick: () => {},
positionOffset: () => ({ x: 0, y: 0 }),
scrollContainer: getRootDOMElement(),
};

export default PopupMenu;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Icon from '@ibexa-admin-ui/src/bundle/ui-dev/src/modules/common/icon/icon

const MIN_SEARCH_ITEMS_DEFAULT = 5;

const PopupMenuSearch = ({ numberOfItems, filterText, setFilterText }) => {
const PopupMenuSearch = ({ numberOfItems, filterText = '', setFilterText }) => {
const Translator = getTranslator();
const searchPlaceholder = Translator.trans(/*@Desc("Search...")*/ 'ibexa_popup_menu.search.placeholder', {}, 'ibexa_popup_menu');
const updateFilterValue = (event) => setFilterText(event.target.value);
Expand Down Expand Up @@ -56,8 +56,4 @@ PopupMenuSearch.propTypes = {
filterText: PropTypes.string,
};

PopupMenuSearch.defaultProps = {
filterText: '',
};

export default PopupMenuSearch;
39 changes: 12 additions & 27 deletions src/bundle/ui-dev/src/modules/common/popup/popup.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ const MODAL_SIZE_CLASS = {

const Popup = ({
isVisible,
onClose,
onClose = null,
children,
title,
subtitle,
hasFocus,
noKeyboard,
title = null,
subtitle = null,
hasFocus = true,
noKeyboard = false,
actionBtnsConfig,
size,
noHeader,
noFooter,
noCloseBtn,
extraClasses,
showTooltip,
subheader,
size = 'large',
noHeader = false,
noFooter = false,
noCloseBtn = false,
extraClasses = '',
showTooltip = true,
subheader = null,
}) => {
const rootDOMElement = getRootDOMElement();
const modalRef = useRef(null);
Expand Down Expand Up @@ -198,19 +198,4 @@ Popup.propTypes = {
subheader: PropTypes.node,
};

Popup.defaultProps = {
hasFocus: true,
noKeyboard: false,
onClose: null,
size: 'large',
noHeader: false,
noFooter: false,
noCloseBtn: false,
extraClasses: '',
title: null,
subtitle: null,
showTooltip: true,
subheader: null,
};

export default Popup;
Loading
Loading