colibri-ui 0.8.34 → 0.8.36
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/Dropdown/index.js +19 -19
- package/Menu/components/MenuItem/index.d.ts +1 -1
- package/Menu/components/MenuItem/index.js +16 -12
- package/Menu/components/MenuItem/index.props.d.ts +1 -0
- package/base/BaseInput/index.d.ts +1 -1
- package/base/BaseInput/index.js +9 -1
- package/base/BaseInput/index.props.d.ts +7 -3
- package/esm/Dropdown/index.js +19 -19
- package/esm/Menu/components/MenuItem/index.d.ts +1 -1
- package/esm/Menu/components/MenuItem/index.js +16 -12
- package/esm/Menu/components/MenuItem/index.props.d.ts +1 -0
- package/esm/base/BaseInput/index.d.ts +1 -1
- package/esm/base/BaseInput/index.js +9 -1
- package/esm/base/BaseInput/index.props.d.ts +7 -3
- package/package.json +1 -1
package/Dropdown/index.js
CHANGED
|
@@ -77,7 +77,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
77
77
|
if (!children) return null;
|
|
78
78
|
return React.Children.only(isNotComponent ? /*#__PURE__*/React__default.default.createElement("button", null, children) : children);
|
|
79
79
|
}, [children, isNotComponent]);
|
|
80
|
-
var onToggle =
|
|
80
|
+
var onToggle = function onToggle(event) {
|
|
81
81
|
var _a;
|
|
82
82
|
if ((_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('[data-ignore-click="true"]')) {
|
|
83
83
|
return;
|
|
@@ -85,47 +85,47 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
85
85
|
setVisible(function (state) {
|
|
86
86
|
return !state;
|
|
87
87
|
});
|
|
88
|
-
}
|
|
89
|
-
var
|
|
90
|
-
setVisible(true);
|
|
91
|
-
}
|
|
92
|
-
var
|
|
88
|
+
};
|
|
89
|
+
var handleShow = function handleShow() {
|
|
90
|
+
return setVisible(true);
|
|
91
|
+
};
|
|
92
|
+
var handleHide = React.useCallback(function () {
|
|
93
93
|
setVisible(false);
|
|
94
|
-
}, [
|
|
94
|
+
}, []);
|
|
95
95
|
var onClickOutside = React.useCallback(function (event) {
|
|
96
96
|
if (controlElement === null || controlElement === void 0 ? void 0 : controlElement.contains(event.target)) return;
|
|
97
|
-
|
|
98
|
-
}, [
|
|
97
|
+
handleHide();
|
|
98
|
+
}, [handleHide, controlElement]);
|
|
99
99
|
var onClickOverlay = React.useCallback(function (event) {
|
|
100
100
|
event.stopPropagation();
|
|
101
101
|
if (!preventAutoClose) {
|
|
102
|
-
|
|
102
|
+
handleHide();
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
|
-
[
|
|
106
|
+
[handleHide]);
|
|
107
107
|
React.useEffect(function () {
|
|
108
108
|
var unsubscribes = [];
|
|
109
109
|
if (trigger.includes("click")) {
|
|
110
110
|
unsubscribes.push(on.on(controlElement, "click", onToggle, false));
|
|
111
111
|
}
|
|
112
112
|
if (trigger.includes("hover")) {
|
|
113
|
-
unsubscribes.push(on.on(controlElement, "mouseenter",
|
|
114
|
-
unsubscribes.push(on.on(controlElement, "mouseleave",
|
|
115
|
-
unsubscribes.push(on.on(popperElement, "mouseenter",
|
|
116
|
-
unsubscribes.push(on.on(popperElement, "mouseleave",
|
|
113
|
+
unsubscribes.push(on.on(controlElement, "mouseenter", handleShow, false));
|
|
114
|
+
unsubscribes.push(on.on(controlElement, "mouseleave", handleHide, false));
|
|
115
|
+
unsubscribes.push(on.on(popperElement, "mouseenter", handleShow, false));
|
|
116
|
+
unsubscribes.push(on.on(popperElement, "mouseleave", handleHide, false));
|
|
117
117
|
}
|
|
118
118
|
if (trigger.includes("focus")) {
|
|
119
119
|
var onFocusOut = function onFocusOut() {
|
|
120
120
|
requestAnimationFrame(function () {
|
|
121
121
|
if (controlElement === null || controlElement === void 0 ? void 0 : controlElement.contains(document.activeElement)) return;
|
|
122
122
|
if (popperElement === null || popperElement === void 0 ? void 0 : popperElement.contains(document.activeElement)) return;
|
|
123
|
-
|
|
123
|
+
handleHide();
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
|
-
unsubscribes.push(on.on(controlElement, "focusin",
|
|
126
|
+
unsubscribes.push(on.on(controlElement, "focusin", handleShow, false));
|
|
127
127
|
unsubscribes.push(on.on(controlElement, "focusout", onFocusOut, false));
|
|
128
|
-
unsubscribes.push(on.on(popperElement, "focusin",
|
|
128
|
+
unsubscribes.push(on.on(popperElement, "focusin", handleShow, false));
|
|
129
129
|
unsubscribes.push(on.on(popperElement, "focusout", onFocusOut, false));
|
|
130
130
|
}
|
|
131
131
|
return function () {
|
|
@@ -134,7 +134,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
136
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
137
|
-
}, [controlElement, popperElement, onToggle,
|
|
137
|
+
}, [controlElement, popperElement, onToggle, handleShow, handleHide]);
|
|
138
138
|
React.useEffect(function () {
|
|
139
139
|
if (onVisibleChange) onVisibleChange(visible);
|
|
140
140
|
}, [onVisibleChange, visible]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
3
|
import type { MenuItemProps } from "./index.props";
|
|
4
|
-
declare const MenuItem: ({ className, isSelected, variant, disabled, onClick, children, ref, }: PropsWithChildren<MenuItemProps>) => React.JSX.Element;
|
|
4
|
+
declare const MenuItem: ({ className, isSelected, variant, disabled, onClick, children, onMouseEnter, ref, ...props }: PropsWithChildren<MenuItemProps>) => React.JSX.Element;
|
|
5
5
|
export default MenuItem;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var tslib = require('tslib');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var classNames = require('classnames/bind');
|
|
8
9
|
var styles = require('./MenuItem.module.css');
|
|
@@ -15,19 +16,21 @@ var classNames__default = /*#__PURE__*/_interopDefault(classNames);
|
|
|
15
16
|
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
16
17
|
|
|
17
18
|
var clx = classNames__default.default.bind(styles__default.default);
|
|
18
|
-
var MenuItem = function MenuItem(
|
|
19
|
-
var className =
|
|
20
|
-
isSelected =
|
|
21
|
-
|
|
22
|
-
variant =
|
|
23
|
-
disabled =
|
|
24
|
-
onClick =
|
|
25
|
-
children =
|
|
26
|
-
|
|
19
|
+
var MenuItem = function MenuItem(_a) {
|
|
20
|
+
var className = _a.className,
|
|
21
|
+
isSelected = _a.isSelected,
|
|
22
|
+
_a$variant = _a.variant,
|
|
23
|
+
variant = _a$variant === void 0 ? "primary" : _a$variant,
|
|
24
|
+
disabled = _a.disabled,
|
|
25
|
+
onClick = _a.onClick,
|
|
26
|
+
children = _a.children,
|
|
27
|
+
onMouseEnter = _a.onMouseEnter,
|
|
28
|
+
ref = _a.ref,
|
|
29
|
+
props = tslib.__rest(_a, ["className", "isSelected", "variant", "disabled", "onClick", "children", "onMouseEnter", "ref"]);
|
|
27
30
|
return (
|
|
28
31
|
/*#__PURE__*/
|
|
29
32
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
30
|
-
React__default.default.createElement("li", {
|
|
33
|
+
React__default.default.createElement("li", Object.assign({
|
|
31
34
|
ref: ref,
|
|
32
35
|
style: {
|
|
33
36
|
backgroundColor: isSelected ? "var(--palette-bg-2, rgb(232, 240, 254))" : ""
|
|
@@ -38,8 +41,9 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
38
41
|
className: clx("item", _defineProperty__default.default({
|
|
39
42
|
item_disabled: !!disabled
|
|
40
43
|
}, "item_variant_".concat(variant), !!variant), className),
|
|
41
|
-
onClick: !disabled ? onClick : undefined
|
|
42
|
-
|
|
44
|
+
onClick: !disabled ? onClick : undefined,
|
|
45
|
+
onMouseEnter: onMouseEnter
|
|
46
|
+
}, props), children)
|
|
43
47
|
);
|
|
44
48
|
};
|
|
45
49
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Props } from "./index.props";
|
|
3
|
-
declare const BaseInput: ({ className, onChange, ref, ...props }: Props) => React.JSX.Element;
|
|
3
|
+
declare const BaseInput: ({ className, onFocus, onChange, onBlur, onKeyDown, ref, ...props }: Props) => React.JSX.Element;
|
|
4
4
|
export default BaseInput;
|
package/base/BaseInput/index.js
CHANGED
|
@@ -15,15 +15,23 @@ var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
|
15
15
|
|
|
16
16
|
var BaseInput = function BaseInput(_a) {
|
|
17
17
|
var className = _a.className,
|
|
18
|
+
onFocus = _a.onFocus,
|
|
18
19
|
onChange = _a.onChange,
|
|
20
|
+
onBlur = _a.onBlur,
|
|
21
|
+
onKeyDown = _a.onKeyDown,
|
|
19
22
|
ref = _a.ref,
|
|
20
|
-
props = tslib.__rest(_a, ["className", "onChange", "ref"]);
|
|
23
|
+
props = tslib.__rest(_a, ["className", "onFocus", "onChange", "onBlur", "onKeyDown", "ref"]);
|
|
21
24
|
var onChangeHandler = function onChangeHandler(e) {
|
|
22
25
|
if (onChange) onChange(e, e.target.value);
|
|
23
26
|
};
|
|
24
27
|
return /*#__PURE__*/React__default.default.createElement("input", Object.assign({
|
|
25
28
|
className: classNames__default.default(styles__default.default["base-input"], className),
|
|
26
29
|
onChange: onChangeHandler,
|
|
30
|
+
onFocus: onFocus,
|
|
31
|
+
onBlur: onBlur,
|
|
32
|
+
onKeyDown: onKeyDown,
|
|
33
|
+
autoCorrect: "off",
|
|
34
|
+
autoCapitalize: "off",
|
|
27
35
|
ref: ref
|
|
28
36
|
}, props));
|
|
29
37
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { ChangeEvent, InputHTMLAttributes } from "react";
|
|
1
|
+
import type { ChangeEvent, InputHTMLAttributes, KeyboardEvent, Ref, FormEvent, FocusEvent } from "react";
|
|
2
2
|
export interface Props extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
3
|
-
onChange?: (
|
|
4
|
-
|
|
3
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;
|
|
4
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
5
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
6
|
+
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
7
|
+
onInput?: (event: FormEvent<HTMLInputElement>) => void;
|
|
8
|
+
ref?: Ref<HTMLInputElement>;
|
|
5
9
|
}
|
package/esm/Dropdown/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
66
66
|
if (!children) return null;
|
|
67
67
|
return Children.only(isNotComponent ? /*#__PURE__*/React__default.createElement("button", null, children) : children);
|
|
68
68
|
}, [children, isNotComponent]);
|
|
69
|
-
var onToggle =
|
|
69
|
+
var onToggle = function onToggle(event) {
|
|
70
70
|
var _a;
|
|
71
71
|
if ((_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('[data-ignore-click="true"]')) {
|
|
72
72
|
return;
|
|
@@ -74,47 +74,47 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
74
74
|
setVisible(function (state) {
|
|
75
75
|
return !state;
|
|
76
76
|
});
|
|
77
|
-
}
|
|
78
|
-
var
|
|
79
|
-
setVisible(true);
|
|
80
|
-
}
|
|
81
|
-
var
|
|
77
|
+
};
|
|
78
|
+
var handleShow = function handleShow() {
|
|
79
|
+
return setVisible(true);
|
|
80
|
+
};
|
|
81
|
+
var handleHide = useCallback(function () {
|
|
82
82
|
setVisible(false);
|
|
83
|
-
}, [
|
|
83
|
+
}, []);
|
|
84
84
|
var onClickOutside = useCallback(function (event) {
|
|
85
85
|
if (controlElement === null || controlElement === void 0 ? void 0 : controlElement.contains(event.target)) return;
|
|
86
|
-
|
|
87
|
-
}, [
|
|
86
|
+
handleHide();
|
|
87
|
+
}, [handleHide, controlElement]);
|
|
88
88
|
var onClickOverlay = useCallback(function (event) {
|
|
89
89
|
event.stopPropagation();
|
|
90
90
|
if (!preventAutoClose) {
|
|
91
|
-
|
|
91
|
+
handleHide();
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
-
[
|
|
95
|
+
[handleHide]);
|
|
96
96
|
useEffect(function () {
|
|
97
97
|
var unsubscribes = [];
|
|
98
98
|
if (trigger.includes("click")) {
|
|
99
99
|
unsubscribes.push(on(controlElement, "click", onToggle, false));
|
|
100
100
|
}
|
|
101
101
|
if (trigger.includes("hover")) {
|
|
102
|
-
unsubscribes.push(on(controlElement, "mouseenter",
|
|
103
|
-
unsubscribes.push(on(controlElement, "mouseleave",
|
|
104
|
-
unsubscribes.push(on(popperElement, "mouseenter",
|
|
105
|
-
unsubscribes.push(on(popperElement, "mouseleave",
|
|
102
|
+
unsubscribes.push(on(controlElement, "mouseenter", handleShow, false));
|
|
103
|
+
unsubscribes.push(on(controlElement, "mouseleave", handleHide, false));
|
|
104
|
+
unsubscribes.push(on(popperElement, "mouseenter", handleShow, false));
|
|
105
|
+
unsubscribes.push(on(popperElement, "mouseleave", handleHide, false));
|
|
106
106
|
}
|
|
107
107
|
if (trigger.includes("focus")) {
|
|
108
108
|
var onFocusOut = function onFocusOut() {
|
|
109
109
|
requestAnimationFrame(function () {
|
|
110
110
|
if (controlElement === null || controlElement === void 0 ? void 0 : controlElement.contains(document.activeElement)) return;
|
|
111
111
|
if (popperElement === null || popperElement === void 0 ? void 0 : popperElement.contains(document.activeElement)) return;
|
|
112
|
-
|
|
112
|
+
handleHide();
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
|
-
unsubscribes.push(on(controlElement, "focusin",
|
|
115
|
+
unsubscribes.push(on(controlElement, "focusin", handleShow, false));
|
|
116
116
|
unsubscribes.push(on(controlElement, "focusout", onFocusOut, false));
|
|
117
|
-
unsubscribes.push(on(popperElement, "focusin",
|
|
117
|
+
unsubscribes.push(on(popperElement, "focusin", handleShow, false));
|
|
118
118
|
unsubscribes.push(on(popperElement, "focusout", onFocusOut, false));
|
|
119
119
|
}
|
|
120
120
|
return function () {
|
|
@@ -123,7 +123,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
123
123
|
});
|
|
124
124
|
};
|
|
125
125
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
|
-
}, [controlElement, popperElement, onToggle,
|
|
126
|
+
}, [controlElement, popperElement, onToggle, handleShow, handleHide]);
|
|
127
127
|
useEffect(function () {
|
|
128
128
|
if (onVisibleChange) onVisibleChange(visible);
|
|
129
129
|
}, [onVisibleChange, visible]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
3
|
import type { MenuItemProps } from "./index.props";
|
|
4
|
-
declare const MenuItem: ({ className, isSelected, variant, disabled, onClick, children, ref, }: PropsWithChildren<MenuItemProps>) => React.JSX.Element;
|
|
4
|
+
declare const MenuItem: ({ className, isSelected, variant, disabled, onClick, children, onMouseEnter, ref, ...props }: PropsWithChildren<MenuItemProps>) => React.JSX.Element;
|
|
5
5
|
export default MenuItem;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { __rest } from 'tslib';
|
|
2
3
|
import React__default from 'react';
|
|
3
4
|
import classNames from 'classnames/bind';
|
|
4
5
|
import styles from './MenuItem.module.css';
|
|
5
6
|
|
|
6
7
|
var clx = classNames.bind(styles);
|
|
7
|
-
var MenuItem = function MenuItem(
|
|
8
|
-
var className =
|
|
9
|
-
isSelected =
|
|
10
|
-
|
|
11
|
-
variant =
|
|
12
|
-
disabled =
|
|
13
|
-
onClick =
|
|
14
|
-
children =
|
|
15
|
-
|
|
8
|
+
var MenuItem = function MenuItem(_a) {
|
|
9
|
+
var className = _a.className,
|
|
10
|
+
isSelected = _a.isSelected,
|
|
11
|
+
_a$variant = _a.variant,
|
|
12
|
+
variant = _a$variant === void 0 ? "primary" : _a$variant,
|
|
13
|
+
disabled = _a.disabled,
|
|
14
|
+
onClick = _a.onClick,
|
|
15
|
+
children = _a.children,
|
|
16
|
+
onMouseEnter = _a.onMouseEnter,
|
|
17
|
+
ref = _a.ref,
|
|
18
|
+
props = __rest(_a, ["className", "isSelected", "variant", "disabled", "onClick", "children", "onMouseEnter", "ref"]);
|
|
16
19
|
return (
|
|
17
20
|
/*#__PURE__*/
|
|
18
21
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
19
|
-
React__default.createElement("li", {
|
|
22
|
+
React__default.createElement("li", Object.assign({
|
|
20
23
|
ref: ref,
|
|
21
24
|
style: {
|
|
22
25
|
backgroundColor: isSelected ? "var(--palette-bg-2, rgb(232, 240, 254))" : ""
|
|
@@ -27,8 +30,9 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
27
30
|
className: clx("item", _defineProperty({
|
|
28
31
|
item_disabled: !!disabled
|
|
29
32
|
}, "item_variant_".concat(variant), !!variant), className),
|
|
30
|
-
onClick: !disabled ? onClick : undefined
|
|
31
|
-
|
|
33
|
+
onClick: !disabled ? onClick : undefined,
|
|
34
|
+
onMouseEnter: onMouseEnter
|
|
35
|
+
}, props), children)
|
|
32
36
|
);
|
|
33
37
|
};
|
|
34
38
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Props } from "./index.props";
|
|
3
|
-
declare const BaseInput: ({ className, onChange, ref, ...props }: Props) => React.JSX.Element;
|
|
3
|
+
declare const BaseInput: ({ className, onFocus, onChange, onBlur, onKeyDown, ref, ...props }: Props) => React.JSX.Element;
|
|
4
4
|
export default BaseInput;
|
|
@@ -5,15 +5,23 @@ import styles from './BaseInput.module.css';
|
|
|
5
5
|
|
|
6
6
|
var BaseInput = function BaseInput(_a) {
|
|
7
7
|
var className = _a.className,
|
|
8
|
+
onFocus = _a.onFocus,
|
|
8
9
|
onChange = _a.onChange,
|
|
10
|
+
onBlur = _a.onBlur,
|
|
11
|
+
onKeyDown = _a.onKeyDown,
|
|
9
12
|
ref = _a.ref,
|
|
10
|
-
props = __rest(_a, ["className", "onChange", "ref"]);
|
|
13
|
+
props = __rest(_a, ["className", "onFocus", "onChange", "onBlur", "onKeyDown", "ref"]);
|
|
11
14
|
var onChangeHandler = function onChangeHandler(e) {
|
|
12
15
|
if (onChange) onChange(e, e.target.value);
|
|
13
16
|
};
|
|
14
17
|
return /*#__PURE__*/React__default.createElement("input", Object.assign({
|
|
15
18
|
className: classNames(styles["base-input"], className),
|
|
16
19
|
onChange: onChangeHandler,
|
|
20
|
+
onFocus: onFocus,
|
|
21
|
+
onBlur: onBlur,
|
|
22
|
+
onKeyDown: onKeyDown,
|
|
23
|
+
autoCorrect: "off",
|
|
24
|
+
autoCapitalize: "off",
|
|
17
25
|
ref: ref
|
|
18
26
|
}, props));
|
|
19
27
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { ChangeEvent, InputHTMLAttributes } from "react";
|
|
1
|
+
import type { ChangeEvent, InputHTMLAttributes, KeyboardEvent, Ref, FormEvent, FocusEvent } from "react";
|
|
2
2
|
export interface Props extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
3
|
-
onChange?: (
|
|
4
|
-
|
|
3
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;
|
|
4
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
5
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
6
|
+
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
7
|
+
onInput?: (event: FormEvent<HTMLInputElement>) => void;
|
|
8
|
+
ref?: Ref<HTMLInputElement>;
|
|
5
9
|
}
|