@rio-cloud/rio-uikit 1.4.0 → 1.4.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/components/charts/Legend.js +1 -1
- package/components/dropdown/ButtonDropdown.d.ts +3 -1
- package/components/dropdown/ButtonDropdown.js +6 -5
- package/components/dropdown/DropdownToggleButton.d.ts +1 -0
- package/components/dropdown/DropdownToggleButton.js +4 -2
- package/components/switch/Switch.d.ts +6 -5
- package/components/switch/Switch.js +5 -5
- package/components/tag/Tag.d.ts +2 -2
- package/components/tag/Tag.js +5 -6
- package/hooks/useDOMNodeCount.d.ts +2 -0
- package/hooks/useDOMNodeCount.js +29 -0
- package/hooks/useEventListenerCount.d.ts +5 -0
- package/hooks/useEventListenerCount.js +42 -0
- package/lib/es/components/charts/Legend.js +1 -1
- package/lib/es/components/dropdown/ButtonDropdown.d.ts +3 -1
- package/lib/es/components/dropdown/ButtonDropdown.js +5 -4
- package/lib/es/components/dropdown/DropdownToggleButton.d.ts +1 -0
- package/lib/es/components/dropdown/DropdownToggleButton.js +4 -2
- package/lib/es/components/switch/Switch.d.ts +6 -5
- package/lib/es/components/switch/Switch.js +5 -5
- package/lib/es/components/tag/Tag.d.ts +2 -2
- package/lib/es/components/tag/Tag.js +5 -6
- package/lib/es/hooks/useDOMNodeCount.d.ts +2 -0
- package/lib/es/hooks/useDOMNodeCount.js +31 -0
- package/lib/es/hooks/useEventListenerCount.d.ts +5 -0
- package/lib/es/hooks/useEventListenerCount.js +45 -0
- package/lib/es/useDOMNodeCount.d.ts +2 -0
- package/lib/es/useDOMNodeCount.js +7 -0
- package/lib/es/useEventListenerCount.d.ts +2 -0
- package/lib/es/useEventListenerCount.js +7 -0
- package/lib/es/version.json +1 -1
- package/package.json +4 -12
- package/useDOMNodeCount.d.ts +2 -0
- package/useDOMNodeCount.js +2 -0
- package/useEventListenerCount.d.ts +2 -0
- package/useEventListenerCount.js +2 -0
- package/version.json +1 -1
|
@@ -117,5 +117,7 @@ export type ButtonDropdownProps = {
|
|
|
117
117
|
*/
|
|
118
118
|
className?: string;
|
|
119
119
|
};
|
|
120
|
-
declare const ButtonDropdown:
|
|
120
|
+
declare const ButtonDropdown: React.ForwardRefExoticComponent<ButtonDropdownProps & {
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
121
123
|
export default ButtonDropdown;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
// biome-ignore lint/style/useImportType: <explanation>
|
|
4
|
+
import { useState, useEffect, forwardRef } from 'react';
|
|
4
5
|
import ReactDOM from 'react-dom';
|
|
5
6
|
import { usePopper } from 'react-popper';
|
|
6
7
|
import classNames from 'classnames';
|
|
@@ -25,8 +26,8 @@ const getPlacement = (pullRight, dropup) => {
|
|
|
25
26
|
}
|
|
26
27
|
return 'bottom-start';
|
|
27
28
|
};
|
|
28
|
-
const ButtonDropdown = (props) => {
|
|
29
|
-
const { id = Math.random().toString(36).
|
|
29
|
+
const ButtonDropdown = forwardRef((props, ref) => {
|
|
30
|
+
const { id = Math.random().toString(36).slice(2, 16), items = [], bsSize = 'md', bsStyle = 'default', variant, disabled = false, iconOnly = false, title, splitButton = false, customDropdown, open, dropup = false, pullRight = false, noCaret = false, onOpen = noop, onClose = noop, onLabelButtonClick = noop, usePortal = false, popperConfig, toggleClassName = '', dropdownClassName, className = '' } = props, remainingProps = __rest(props, ["id", "items", "bsSize", "bsStyle", "variant", "disabled", "iconOnly", "title", "splitButton", "customDropdown", "open", "dropup", "pullRight", "noCaret", "onOpen", "onClose", "onLabelButtonClick", "usePortal", "popperConfig", "toggleClassName", "dropdownClassName", "className"]);
|
|
30
31
|
const [internalOpen, setInternalOpen] = useState(open);
|
|
31
32
|
const [refDropdownToggle, setRefDropdownToggle] = useState(null);
|
|
32
33
|
const [refDropdownMenu, setRefDropdownMenu] = useState(null);
|
|
@@ -89,6 +90,6 @@ const ButtonDropdown = (props) => {
|
|
|
89
90
|
const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);
|
|
90
91
|
const dropdownClasses = classNames(usePortal && 'dropdown-portal', splitButton && pullRight && 'pull-right', dropdownClassName);
|
|
91
92
|
const dropdownMenu = (_jsx(MenuItemList, Object.assign({ className: dropdownClasses, ref: setRefDropdownMenu, style: styles.popper }, attributes.popper, { children: customDropdown ? customDropdown : _jsx(MenuItems, { items: items, closeMenu: toggleOpen }) })));
|
|
92
|
-
return (_jsxs("div", Object.assign({}, remainingProps, { className: wrapperClasses, ref: wrapperRef }, { children: [_jsx(DropdownToggleButton, Object.assign({ id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, className: toggleClassName }, { children: _jsxs(_Fragment, { children: [title, shouldShowCaret && _jsx(Caret, {})] }) })), splitButton && (_jsx(SplitCaretButton, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: toggleOpen, ref: setRefSplitButtonToggle })), isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] })));
|
|
93
|
-
};
|
|
93
|
+
return (_jsxs("div", Object.assign({}, remainingProps, { className: wrapperClasses, ref: wrapperRef }, { children: [_jsx(DropdownToggleButton, Object.assign({ id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, outerRef: ref, className: toggleClassName }, { children: _jsxs(_Fragment, { children: [title, shouldShowCaret && _jsx(Caret, {})] }) })), splitButton && (_jsx(SplitCaretButton, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: toggleOpen, ref: setRefSplitButtonToggle })), isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] })));
|
|
94
|
+
});
|
|
94
95
|
export default ButtonDropdown;
|
|
@@ -9,6 +9,7 @@ export type DropdownToggleButtonProps = HTMLProps<HTMLButtonElement> & {
|
|
|
9
9
|
bsSize: BUTTON_SIZE;
|
|
10
10
|
bsStyle: BUTTON_STYLE;
|
|
11
11
|
variant?: BUTTON_VARIANT;
|
|
12
|
+
outerRef?: React.Ref<HTMLButtonElement>;
|
|
12
13
|
className?: string;
|
|
13
14
|
};
|
|
14
15
|
declare const DropdownToggleButton: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<DropdownToggleButtonProps>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -3,9 +3,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import Button from '../button/Button';
|
|
6
|
+
import useMergeRefs from '../../hooks/useMergeRefs';
|
|
6
7
|
const DropdownToggleButton = forwardRef((props, ref) => {
|
|
7
|
-
const { id, disabled, bsSize, bsStyle, variant, splitButton = false, onClick, className = '', children } = props, remainingProps = __rest(props, ["id", "disabled", "bsSize", "bsStyle", "variant", "splitButton", "onClick", "className", "children"]);
|
|
8
|
+
const { id, disabled, bsSize, bsStyle, variant, splitButton = false, onClick, className = '', children, outerRef } = props, remainingProps = __rest(props, ["id", "disabled", "bsSize", "bsStyle", "variant", "splitButton", "onClick", "className", "children", "outerRef"]);
|
|
9
|
+
const toggleRef = useMergeRefs(outerRef, ref);
|
|
8
10
|
const labelButtonClasses = classNames(!splitButton && 'dropdown-toggle', !splitButton && className);
|
|
9
|
-
return (_jsx(Button, Object.assign({}, remainingProps, { id: splitButton ? `button-${id}` : id, type: 'button', ref:
|
|
11
|
+
return (_jsx(Button, Object.assign({}, remainingProps, { id: splitButton ? `button-${id}` : id, type: 'button', ref: toggleRef, disabled: disabled, bsStyle: bsStyle, bsSize: bsSize, variant: variant, onClick: onClick, className: labelButtonClasses }, { children: children })));
|
|
10
12
|
});
|
|
11
13
|
export default DropdownToggleButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { type CurrentColor } from '../../utils/currentColors';
|
|
3
3
|
export type SwitchProps = {
|
|
4
4
|
/**
|
|
@@ -46,9 +46,10 @@ export type SwitchProps = {
|
|
|
46
46
|
*/
|
|
47
47
|
labelPosition?: 'left' | 'right';
|
|
48
48
|
};
|
|
49
|
-
declare const Switch: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
declare const Switch: React.ForwardRefExoticComponent<SwitchProps & {
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
} & React.RefAttributes<HTMLDivElement>> & {
|
|
52
|
+
LABEL_POSITION_LEFT: 'left';
|
|
53
|
+
LABEL_POSITION_RIGHT: 'right';
|
|
53
54
|
};
|
|
54
55
|
export default Switch;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
4
|
-
import 'react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import noop from 'lodash/fp/noop';
|
|
7
7
|
import { getCurrentBackgroundColor } from '../../utils/currentColors';
|
|
8
|
-
const Switch = (props) => {
|
|
9
|
-
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition =
|
|
8
|
+
const Switch = forwardRef((props, ref) => {
|
|
9
|
+
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition = children ? 'right' : undefined, onChange = noop } = props, remainingProps = __rest(props, ["keyName", "checked", "enabledText", "minWidth", "disabled", "color", "disabledText", "children", "labelPosition", "onChange"]);
|
|
10
10
|
const handleChange = (event) => {
|
|
11
11
|
onChange(event.target.checked);
|
|
12
12
|
};
|
|
@@ -17,8 +17,8 @@ const Switch = (props) => {
|
|
|
17
17
|
// !hasMultipleText && !hasSingleText && 'width-40'
|
|
18
18
|
);
|
|
19
19
|
const switchBackgroundColor = getCurrentBackgroundColor(color);
|
|
20
|
-
return (_jsx("div", Object.assign({}, remainingProps, { className: 'uikit-switch' }, { children: _jsxs("label", Object.assign({ className: switchLabelClasses }, { children: [_jsx("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), _jsxs("div", Object.assign({ className: switchContentClasses, style: { color: switchBackgroundColor, minWidth } }, { children: [hasMultipleText ? (_jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && _jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), _jsx("div", { className: 'switch-handle' })] })), children && children] })) })));
|
|
21
|
-
};
|
|
20
|
+
return (_jsx("div", Object.assign({ ref: ref }, remainingProps, { className: 'uikit-switch' }, { children: _jsxs("label", Object.assign({ className: switchLabelClasses }, { children: [_jsx("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), _jsxs("div", Object.assign({ className: switchContentClasses, style: { color: switchBackgroundColor, minWidth } }, { children: [hasMultipleText ? (_jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && _jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), _jsx("div", { className: 'switch-handle' })] })), children && children] })) })));
|
|
21
|
+
});
|
|
22
22
|
Switch.LABEL_POSITION_LEFT = 'left';
|
|
23
23
|
Switch.LABEL_POSITION_RIGHT = 'right';
|
|
24
24
|
export default Switch;
|
package/components/tag/Tag.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type TagProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Defines if the tag is active.
|
|
@@ -65,5 +65,5 @@ export type TagProps = {
|
|
|
65
65
|
*/
|
|
66
66
|
className?: string;
|
|
67
67
|
};
|
|
68
|
-
declare const Tag:
|
|
68
|
+
declare const Tag: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<TagProps>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
69
69
|
export default Tag;
|
package/components/tag/Tag.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
4
|
-
import 'react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
const Tag = (props) => {
|
|
6
|
+
const Tag = forwardRef((props, ref) => {
|
|
7
7
|
const { children, icon, active = false, disabled = false, clickable = false, selectable = false, deletable = false, revertable = false, multiline = false, muted = false, round = true, size, className } = props, remainingProps = __rest(props, ["children", "icon", "active", "disabled", "clickable", "selectable", "deletable", "revertable", "multiline", "muted", "round", "size", "className"]);
|
|
8
|
-
const tagClasses = classNames('tag', size === 'small' && 'tag-small', icon && `rioglyph ${icon}`, active && 'active clickable rioglyph rioglyph-ok', disabled && 'disabled', clickable && 'clickable', selectable && 'selectable clickable rioglyph rioglyph-checkbox', deletable && 'deletable clickable rioglyph rioglyph-remove', revertable && 'revertable clickable rioglyph rioglyph-revert', multiline && 'multiline', muted && 'tag-muted', !round && 'rounded',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
8
|
+
const tagClasses = classNames('tag', size === 'small' && 'tag-small', icon && `rioglyph ${icon}`, active && 'active clickable rioglyph rioglyph-ok', disabled && 'disabled', clickable && 'clickable', selectable && 'selectable clickable rioglyph rioglyph-checkbox', deletable && 'deletable clickable rioglyph rioglyph-remove', revertable && 'revertable clickable rioglyph rioglyph-revert', multiline && 'multiline', muted && 'tag-muted', !round && 'rounded', className);
|
|
9
|
+
return (_jsx("div", Object.assign({ ref: ref }, remainingProps, { className: tagClasses }, { children: _jsx("div", Object.assign({ className: 'tag-inner' }, { children: children })) })));
|
|
10
|
+
});
|
|
12
11
|
export default Tag;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
const useDOMNodeCount = () => {
|
|
3
|
+
const [nodeCount, setNodeCount] = useState(0);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const countNodes = () => {
|
|
6
|
+
const body = document.body;
|
|
7
|
+
if (body) {
|
|
8
|
+
setNodeCount(body.getElementsByTagName('*').length);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
// Initial count
|
|
12
|
+
countNodes();
|
|
13
|
+
// Create a MutationObserver to watch for changes in the DOM
|
|
14
|
+
const observer = new MutationObserver(() => {
|
|
15
|
+
countNodes();
|
|
16
|
+
});
|
|
17
|
+
// Observe the body element for changes in the child list or subtree
|
|
18
|
+
observer.observe(document.body, {
|
|
19
|
+
childList: true,
|
|
20
|
+
subtree: true,
|
|
21
|
+
});
|
|
22
|
+
// Cleanup on unmount
|
|
23
|
+
return () => {
|
|
24
|
+
observer.disconnect();
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
return nodeCount;
|
|
28
|
+
};
|
|
29
|
+
export default useDOMNodeCount;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import throttle from 'lodash/fp/throttle';
|
|
3
|
+
const useEventListenerCount = () => {
|
|
4
|
+
const [listenerCounts, setListenerCounts] = useState({});
|
|
5
|
+
const [totalCount, setTotalCount] = useState(0);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
console.log('init useEventListener interceptor');
|
|
8
|
+
const eventListeners = new Set();
|
|
9
|
+
const originalAddEventListener = EventTarget.prototype.addEventListener;
|
|
10
|
+
const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
|
|
11
|
+
const updateListeners = throttle(1000)(() => {
|
|
12
|
+
const counts = Array.from(eventListeners).reduce((acc, { type }) => {
|
|
13
|
+
acc[type] = (acc[type] || 0) + 1;
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
setListenerCounts(counts);
|
|
17
|
+
setTotalCount(eventListeners.size);
|
|
18
|
+
});
|
|
19
|
+
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
|
20
|
+
if (listener) {
|
|
21
|
+
eventListeners.add({ type, listener });
|
|
22
|
+
updateListeners();
|
|
23
|
+
}
|
|
24
|
+
originalAddEventListener.call(this, type, listener, options);
|
|
25
|
+
};
|
|
26
|
+
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
27
|
+
eventListeners.forEach(item => {
|
|
28
|
+
if (item.type === type && item.listener === listener) {
|
|
29
|
+
eventListeners.delete(item);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
updateListeners();
|
|
33
|
+
originalRemoveEventListener.call(this, type, listener, options);
|
|
34
|
+
};
|
|
35
|
+
return () => {
|
|
36
|
+
EventTarget.prototype.addEventListener = originalAddEventListener;
|
|
37
|
+
EventTarget.prototype.removeEventListener = originalRemoveEventListener;
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
return { counts: listenerCounts, total: totalCount };
|
|
41
|
+
};
|
|
42
|
+
export default useEventListenerCount;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLegendDefaultProps = void 0;
|
|
4
|
-
// @ts-ignore
|
|
4
|
+
// @ts-ignore importsNotUsedAsValues
|
|
5
5
|
require("react");
|
|
6
6
|
const getLegendDefaultProps = () => ({
|
|
7
7
|
iconType: 'circle',
|
|
@@ -117,5 +117,7 @@ export type ButtonDropdownProps = {
|
|
|
117
117
|
*/
|
|
118
118
|
className?: string;
|
|
119
119
|
};
|
|
120
|
-
declare const ButtonDropdown:
|
|
120
|
+
declare const ButtonDropdown: React.ForwardRefExoticComponent<ButtonDropdownProps & {
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
121
123
|
export default ButtonDropdown;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// biome-ignore lint/style/useImportType: <explanation>
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
|
|
7
8
|
const react_popper_1 = require("react-popper");
|
|
@@ -27,8 +28,8 @@ const getPlacement = (pullRight, dropup) => {
|
|
|
27
28
|
}
|
|
28
29
|
return 'bottom-start';
|
|
29
30
|
};
|
|
30
|
-
const ButtonDropdown = (props) => {
|
|
31
|
-
const { id = Math.random().toString(36).
|
|
31
|
+
const ButtonDropdown = (0, react_1.forwardRef)((props, ref) => {
|
|
32
|
+
const { id = Math.random().toString(36).slice(2, 16), items = [], bsSize = 'md', bsStyle = 'default', variant, disabled = false, iconOnly = false, title, splitButton = false, customDropdown, open, dropup = false, pullRight = false, noCaret = false, onOpen = noop_1.default, onClose = noop_1.default, onLabelButtonClick = noop_1.default, usePortal = false, popperConfig, toggleClassName = '', dropdownClassName, className = '' } = props, remainingProps = tslib_1.__rest(props, ["id", "items", "bsSize", "bsStyle", "variant", "disabled", "iconOnly", "title", "splitButton", "customDropdown", "open", "dropup", "pullRight", "noCaret", "onOpen", "onClose", "onLabelButtonClick", "usePortal", "popperConfig", "toggleClassName", "dropdownClassName", "className"]);
|
|
32
33
|
const [internalOpen, setInternalOpen] = (0, react_1.useState)(open);
|
|
33
34
|
const [refDropdownToggle, setRefDropdownToggle] = (0, react_1.useState)(null);
|
|
34
35
|
const [refDropdownMenu, setRefDropdownMenu] = (0, react_1.useState)(null);
|
|
@@ -91,6 +92,6 @@ const ButtonDropdown = (props) => {
|
|
|
91
92
|
const wrapperClasses = (0, classnames_1.default)('dropdown', 'btn-group', isOpen && 'open', className);
|
|
92
93
|
const dropdownClasses = (0, classnames_1.default)(usePortal && 'dropdown-portal', splitButton && pullRight && 'pull-right', dropdownClassName);
|
|
93
94
|
const dropdownMenu = ((0, jsx_runtime_1.jsx)(MenuItemList_1.default, Object.assign({ className: dropdownClasses, ref: setRefDropdownMenu, style: styles.popper }, attributes.popper, { children: customDropdown ? customDropdown : (0, jsx_runtime_1.jsx)(MenuItems_1.default, { items: items, closeMenu: toggleOpen }) })));
|
|
94
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: wrapperClasses, ref: wrapperRef }, { children: [(0, jsx_runtime_1.jsx)(DropdownToggleButton_1.default, Object.assign({ id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, className: toggleClassName }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [title, shouldShowCaret && (0, jsx_runtime_1.jsx)(Caret_1.default, {})] }) })), splitButton && ((0, jsx_runtime_1.jsx)(SplitCaretButton_1.default, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: toggleOpen, ref: setRefSplitButtonToggle })), isOpen && usePortal && react_dom_1.default.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] })));
|
|
95
|
-
};
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: wrapperClasses, ref: wrapperRef }, { children: [(0, jsx_runtime_1.jsx)(DropdownToggleButton_1.default, Object.assign({ id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, outerRef: ref, className: toggleClassName }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [title, shouldShowCaret && (0, jsx_runtime_1.jsx)(Caret_1.default, {})] }) })), splitButton && ((0, jsx_runtime_1.jsx)(SplitCaretButton_1.default, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: toggleOpen, ref: setRefSplitButtonToggle })), isOpen && usePortal && react_dom_1.default.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] })));
|
|
96
|
+
});
|
|
96
97
|
exports.default = ButtonDropdown;
|
|
@@ -9,6 +9,7 @@ export type DropdownToggleButtonProps = HTMLProps<HTMLButtonElement> & {
|
|
|
9
9
|
bsSize: BUTTON_SIZE;
|
|
10
10
|
bsStyle: BUTTON_STYLE;
|
|
11
11
|
variant?: BUTTON_VARIANT;
|
|
12
|
+
outerRef?: React.Ref<HTMLButtonElement>;
|
|
12
13
|
className?: string;
|
|
13
14
|
};
|
|
14
15
|
declare const DropdownToggleButton: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<DropdownToggleButtonProps>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -5,9 +5,11 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
7
7
|
const Button_1 = tslib_1.__importDefault(require("../button/Button"));
|
|
8
|
+
const useMergeRefs_1 = tslib_1.__importDefault(require("../../hooks/useMergeRefs"));
|
|
8
9
|
const DropdownToggleButton = (0, react_1.forwardRef)((props, ref) => {
|
|
9
|
-
const { id, disabled, bsSize, bsStyle, variant, splitButton = false, onClick, className = '', children } = props, remainingProps = tslib_1.__rest(props, ["id", "disabled", "bsSize", "bsStyle", "variant", "splitButton", "onClick", "className", "children"]);
|
|
10
|
+
const { id, disabled, bsSize, bsStyle, variant, splitButton = false, onClick, className = '', children, outerRef } = props, remainingProps = tslib_1.__rest(props, ["id", "disabled", "bsSize", "bsStyle", "variant", "splitButton", "onClick", "className", "children", "outerRef"]);
|
|
11
|
+
const toggleRef = (0, useMergeRefs_1.default)(outerRef, ref);
|
|
10
12
|
const labelButtonClasses = (0, classnames_1.default)(!splitButton && 'dropdown-toggle', !splitButton && className);
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)(Button_1.default, Object.assign({}, remainingProps, { id: splitButton ? `button-${id}` : id, type: 'button', ref:
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.default, Object.assign({}, remainingProps, { id: splitButton ? `button-${id}` : id, type: 'button', ref: toggleRef, disabled: disabled, bsStyle: bsStyle, bsSize: bsSize, variant: variant, onClick: onClick, className: labelButtonClasses }, { children: children })));
|
|
12
14
|
});
|
|
13
15
|
exports.default = DropdownToggleButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { type CurrentColor } from '../../utils/currentColors';
|
|
3
3
|
export type SwitchProps = {
|
|
4
4
|
/**
|
|
@@ -46,9 +46,10 @@ export type SwitchProps = {
|
|
|
46
46
|
*/
|
|
47
47
|
labelPosition?: 'left' | 'right';
|
|
48
48
|
};
|
|
49
|
-
declare const Switch: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
declare const Switch: React.ForwardRefExoticComponent<SwitchProps & {
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
} & React.RefAttributes<HTMLDivElement>> & {
|
|
52
|
+
LABEL_POSITION_LEFT: 'left';
|
|
53
|
+
LABEL_POSITION_RIGHT: 'right';
|
|
53
54
|
};
|
|
54
55
|
export default Switch;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
6
|
-
require("react");
|
|
6
|
+
const react_1 = require("react");
|
|
7
7
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
8
|
const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
|
|
9
9
|
const currentColors_1 = require("../../utils/currentColors");
|
|
10
|
-
const Switch = (props) => {
|
|
11
|
-
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition =
|
|
10
|
+
const Switch = (0, react_1.forwardRef)((props, ref) => {
|
|
11
|
+
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition = children ? 'right' : undefined, onChange = noop_1.default } = props, remainingProps = tslib_1.__rest(props, ["keyName", "checked", "enabledText", "minWidth", "disabled", "color", "disabledText", "children", "labelPosition", "onChange"]);
|
|
12
12
|
const handleChange = (event) => {
|
|
13
13
|
onChange(event.target.checked);
|
|
14
14
|
};
|
|
@@ -19,8 +19,8 @@ const Switch = (props) => {
|
|
|
19
19
|
// !hasMultipleText && !hasSingleText && 'width-40'
|
|
20
20
|
);
|
|
21
21
|
const switchBackgroundColor = (0, currentColors_1.getCurrentBackgroundColor)(color);
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, remainingProps, { className: 'uikit-switch' }, { children: (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: switchLabelClasses }, { children: [(0, jsx_runtime_1.jsx)("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: switchContentClasses, style: { color: switchBackgroundColor, minWidth } }, { children: [hasMultipleText ? ((0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && (0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), (0, jsx_runtime_1.jsx)("div", { className: 'switch-handle' })] })), children && children] })) })));
|
|
23
|
-
};
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref }, remainingProps, { className: 'uikit-switch' }, { children: (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: switchLabelClasses }, { children: [(0, jsx_runtime_1.jsx)("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: switchContentClasses, style: { color: switchBackgroundColor, minWidth } }, { children: [hasMultipleText ? ((0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && (0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), (0, jsx_runtime_1.jsx)("div", { className: 'switch-handle' })] })), children && children] })) })));
|
|
23
|
+
});
|
|
24
24
|
Switch.LABEL_POSITION_LEFT = 'left';
|
|
25
25
|
Switch.LABEL_POSITION_RIGHT = 'right';
|
|
26
26
|
exports.default = Switch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type TagProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Defines if the tag is active.
|
|
@@ -65,5 +65,5 @@ export type TagProps = {
|
|
|
65
65
|
*/
|
|
66
66
|
className?: string;
|
|
67
67
|
};
|
|
68
|
-
declare const Tag:
|
|
68
|
+
declare const Tag: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<TagProps>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
69
69
|
export default Tag;
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
6
|
-
require("react");
|
|
6
|
+
const react_1 = require("react");
|
|
7
7
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
|
-
const Tag = (props) => {
|
|
8
|
+
const Tag = (0, react_1.forwardRef)((props, ref) => {
|
|
9
9
|
const { children, icon, active = false, disabled = false, clickable = false, selectable = false, deletable = false, revertable = false, multiline = false, muted = false, round = true, size, className } = props, remainingProps = tslib_1.__rest(props, ["children", "icon", "active", "disabled", "clickable", "selectable", "deletable", "revertable", "multiline", "muted", "round", "size", "className"]);
|
|
10
|
-
const tagClasses = (0, classnames_1.default)('tag', size === 'small' && 'tag-small', icon && `rioglyph ${icon}`, active && 'active clickable rioglyph rioglyph-ok', disabled && 'disabled', clickable && 'clickable', selectable && 'selectable clickable rioglyph rioglyph-checkbox', deletable && 'deletable clickable rioglyph rioglyph-remove', revertable && 'revertable clickable rioglyph rioglyph-revert', multiline && 'multiline', muted && 'tag-muted', !round && 'rounded',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
10
|
+
const tagClasses = (0, classnames_1.default)('tag', size === 'small' && 'tag-small', icon && `rioglyph ${icon}`, active && 'active clickable rioglyph rioglyph-ok', disabled && 'disabled', clickable && 'clickable', selectable && 'selectable clickable rioglyph rioglyph-checkbox', deletable && 'deletable clickable rioglyph rioglyph-remove', revertable && 'revertable clickable rioglyph rioglyph-revert', multiline && 'multiline', muted && 'tag-muted', !round && 'rounded', className);
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref }, remainingProps, { className: tagClasses }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'tag-inner' }, { children: children })) })));
|
|
12
|
+
});
|
|
14
13
|
exports.default = Tag;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const useDOMNodeCount = () => {
|
|
5
|
+
const [nodeCount, setNodeCount] = (0, react_1.useState)(0);
|
|
6
|
+
(0, react_1.useEffect)(() => {
|
|
7
|
+
const countNodes = () => {
|
|
8
|
+
const body = document.body;
|
|
9
|
+
if (body) {
|
|
10
|
+
setNodeCount(body.getElementsByTagName('*').length);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
// Initial count
|
|
14
|
+
countNodes();
|
|
15
|
+
// Create a MutationObserver to watch for changes in the DOM
|
|
16
|
+
const observer = new MutationObserver(() => {
|
|
17
|
+
countNodes();
|
|
18
|
+
});
|
|
19
|
+
// Observe the body element for changes in the child list or subtree
|
|
20
|
+
observer.observe(document.body, {
|
|
21
|
+
childList: true,
|
|
22
|
+
subtree: true,
|
|
23
|
+
});
|
|
24
|
+
// Cleanup on unmount
|
|
25
|
+
return () => {
|
|
26
|
+
observer.disconnect();
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
return nodeCount;
|
|
30
|
+
};
|
|
31
|
+
exports.default = useDOMNodeCount;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const throttle_1 = tslib_1.__importDefault(require("lodash/fp/throttle"));
|
|
6
|
+
const useEventListenerCount = () => {
|
|
7
|
+
const [listenerCounts, setListenerCounts] = (0, react_1.useState)({});
|
|
8
|
+
const [totalCount, setTotalCount] = (0, react_1.useState)(0);
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
console.log('init useEventListener interceptor');
|
|
11
|
+
const eventListeners = new Set();
|
|
12
|
+
const originalAddEventListener = EventTarget.prototype.addEventListener;
|
|
13
|
+
const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
|
|
14
|
+
const updateListeners = (0, throttle_1.default)(1000)(() => {
|
|
15
|
+
const counts = Array.from(eventListeners).reduce((acc, { type }) => {
|
|
16
|
+
acc[type] = (acc[type] || 0) + 1;
|
|
17
|
+
return acc;
|
|
18
|
+
}, {});
|
|
19
|
+
setListenerCounts(counts);
|
|
20
|
+
setTotalCount(eventListeners.size);
|
|
21
|
+
});
|
|
22
|
+
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
|
23
|
+
if (listener) {
|
|
24
|
+
eventListeners.add({ type, listener });
|
|
25
|
+
updateListeners();
|
|
26
|
+
}
|
|
27
|
+
originalAddEventListener.call(this, type, listener, options);
|
|
28
|
+
};
|
|
29
|
+
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
30
|
+
eventListeners.forEach(item => {
|
|
31
|
+
if (item.type === type && item.listener === listener) {
|
|
32
|
+
eventListeners.delete(item);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
updateListeners();
|
|
36
|
+
originalRemoveEventListener.call(this, type, listener, options);
|
|
37
|
+
};
|
|
38
|
+
return () => {
|
|
39
|
+
EventTarget.prototype.addEventListener = originalAddEventListener;
|
|
40
|
+
EventTarget.prototype.removeEventListener = originalRemoveEventListener;
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
return { counts: listenerCounts, total: totalCount };
|
|
44
|
+
};
|
|
45
|
+
exports.default = useEventListenerCount;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var useDOMNodeCount_1 = require("./hooks/useDOMNodeCount");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(useDOMNodeCount_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./hooks/useDOMNodeCount"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var useEventListenerCount_1 = require("./hooks/useEventListenerCount");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(useEventListenerCount_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./hooks/useEventListenerCount"), exports);
|
package/lib/es/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rio-cloud/rio-uikit",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "The RIO UIKIT component library",
|
|
5
5
|
"repository": "https://bitbucket.collaboration-man.com/projects/RIOFRONT/repos/uikit-web/browse",
|
|
6
6
|
"scripts": {
|
|
@@ -43,9 +43,7 @@
|
|
|
43
43
|
"module": "index.js",
|
|
44
44
|
"types": "index.d.ts",
|
|
45
45
|
"less": "./styles/css/rio-uikit.less",
|
|
46
|
-
"files": [
|
|
47
|
-
"**/*.*"
|
|
48
|
-
],
|
|
46
|
+
"files": ["**/*.*"],
|
|
49
47
|
"devDependencies": {
|
|
50
48
|
"@testing-library/dom": "9.3.3",
|
|
51
49
|
"@testing-library/jest-dom": "5.17.0",
|
|
@@ -132,12 +130,6 @@
|
|
|
132
130
|
"overrides": {
|
|
133
131
|
"iframe-resizer": "4.3.11"
|
|
134
132
|
},
|
|
135
|
-
"pre-commit": [
|
|
136
|
-
|
|
137
|
-
],
|
|
138
|
-
"browserslist": [
|
|
139
|
-
"> 0.5%",
|
|
140
|
-
"Firefox ESR",
|
|
141
|
-
"not dead"
|
|
142
|
-
]
|
|
133
|
+
"pre-commit": ["format-code"],
|
|
134
|
+
"browserslist": ["> 0.5%", "Firefox ESR", "not dead"]
|
|
143
135
|
}
|
package/version.json
CHANGED