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 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 = React.useCallback(function (event) {
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
- }, [setVisible]);
89
- var onShow = React.useCallback(function () {
90
- setVisible(true);
91
- }, [setVisible]);
92
- var onHide = React.useCallback(function () {
88
+ };
89
+ var handleShow = function handleShow() {
90
+ return setVisible(true);
91
+ };
92
+ var handleHide = React.useCallback(function () {
93
93
  setVisible(false);
94
- }, [setVisible]);
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
- onHide();
98
- }, [onHide, controlElement]);
97
+ handleHide();
98
+ }, [handleHide, controlElement]);
99
99
  var onClickOverlay = React.useCallback(function (event) {
100
100
  event.stopPropagation();
101
101
  if (!preventAutoClose) {
102
- onHide();
102
+ handleHide();
103
103
  }
104
104
  },
105
105
  // eslint-disable-next-line react-hooks/exhaustive-deps
106
- [onHide]);
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", onShow, false));
114
- unsubscribes.push(on.on(controlElement, "mouseleave", onHide, false));
115
- unsubscribes.push(on.on(popperElement, "mouseenter", onShow, false));
116
- unsubscribes.push(on.on(popperElement, "mouseleave", onHide, false));
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
- onHide();
123
+ handleHide();
124
124
  });
125
125
  };
126
- unsubscribes.push(on.on(controlElement, "focusin", onShow, false));
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", onShow, false));
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, onShow, onHide]);
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(_ref) {
19
- var className = _ref.className,
20
- isSelected = _ref.isSelected,
21
- _ref$variant = _ref.variant,
22
- variant = _ref$variant === void 0 ? "primary" : _ref$variant,
23
- disabled = _ref.disabled,
24
- onClick = _ref.onClick,
25
- children = _ref.children,
26
- ref = _ref.ref;
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
- }, children)
44
+ onClick: !disabled ? onClick : undefined,
45
+ onMouseEnter: onMouseEnter
46
+ }, props), children)
43
47
  );
44
48
  };
45
49
 
@@ -7,4 +7,5 @@ export interface MenuItemProps {
7
7
  variant?: MenuVariant;
8
8
  disabled?: boolean;
9
9
  ref?: React.Ref<HTMLLIElement>;
10
+ onMouseEnter?: () => void;
10
11
  }
@@ -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;
@@ -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?: (e: ChangeEvent<HTMLInputElement>, value: string) => void;
4
- ref?: React.Ref<HTMLInputElement>;
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
  }
@@ -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 = useCallback(function (event) {
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
- }, [setVisible]);
78
- var onShow = useCallback(function () {
79
- setVisible(true);
80
- }, [setVisible]);
81
- var onHide = useCallback(function () {
77
+ };
78
+ var handleShow = function handleShow() {
79
+ return setVisible(true);
80
+ };
81
+ var handleHide = useCallback(function () {
82
82
  setVisible(false);
83
- }, [setVisible]);
83
+ }, []);
84
84
  var onClickOutside = useCallback(function (event) {
85
85
  if (controlElement === null || controlElement === void 0 ? void 0 : controlElement.contains(event.target)) return;
86
- onHide();
87
- }, [onHide, controlElement]);
86
+ handleHide();
87
+ }, [handleHide, controlElement]);
88
88
  var onClickOverlay = useCallback(function (event) {
89
89
  event.stopPropagation();
90
90
  if (!preventAutoClose) {
91
- onHide();
91
+ handleHide();
92
92
  }
93
93
  },
94
94
  // eslint-disable-next-line react-hooks/exhaustive-deps
95
- [onHide]);
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", onShow, false));
103
- unsubscribes.push(on(controlElement, "mouseleave", onHide, false));
104
- unsubscribes.push(on(popperElement, "mouseenter", onShow, false));
105
- unsubscribes.push(on(popperElement, "mouseleave", onHide, false));
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
- onHide();
112
+ handleHide();
113
113
  });
114
114
  };
115
- unsubscribes.push(on(controlElement, "focusin", onShow, false));
115
+ unsubscribes.push(on(controlElement, "focusin", handleShow, false));
116
116
  unsubscribes.push(on(controlElement, "focusout", onFocusOut, false));
117
- unsubscribes.push(on(popperElement, "focusin", onShow, false));
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, onShow, onHide]);
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(_ref) {
8
- var className = _ref.className,
9
- isSelected = _ref.isSelected,
10
- _ref$variant = _ref.variant,
11
- variant = _ref$variant === void 0 ? "primary" : _ref$variant,
12
- disabled = _ref.disabled,
13
- onClick = _ref.onClick,
14
- children = _ref.children,
15
- ref = _ref.ref;
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
- }, children)
33
+ onClick: !disabled ? onClick : undefined,
34
+ onMouseEnter: onMouseEnter
35
+ }, props), children)
32
36
  );
33
37
  };
34
38
 
@@ -7,4 +7,5 @@ export interface MenuItemProps {
7
7
  variant?: MenuVariant;
8
8
  disabled?: boolean;
9
9
  ref?: React.Ref<HTMLLIElement>;
10
+ onMouseEnter?: () => void;
10
11
  }
@@ -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?: (e: ChangeEvent<HTMLInputElement>, value: string) => void;
4
- ref?: React.Ref<HTMLInputElement>;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "colibri-ui",
3
- "version": "0.8.34",
3
+ "version": "0.8.36",
4
4
  "description": "React UI components library",
5
5
  "main": "index.js",
6
6
  "scripts": {},