@decisiv/ui-components 2.0.1-alpha.194 → 2.0.1-alpha.196
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/lib/components/JumpTo/JumpToMenu.d.ts.map +1 -1
- package/lib/components/JumpTo/JumpToMenu.js +50 -9
- package/lib/components/JumpTo/index.test.js +84 -0
- package/lib/components/JumpTo/schema.d.ts.map +1 -1
- package/lib/components/JumpTo/schema.js +2 -1
- package/lib/components/JumpTo/types.d.ts +1 -0
- package/lib/components/JumpTo/types.d.ts.map +1 -1
- package/lib/components/Popover/index.d.ts.map +1 -1
- package/lib/components/Popover/index.js +3 -2
- package/lib/components/Popover/types.d.ts +3 -2
- package/lib/components/Popover/types.d.ts.map +1 -1
- package/lib/utils/useDebounce.d.ts +2 -0
- package/lib/utils/useDebounce.d.ts.map +1 -0
- package/lib/utils/useDebounce.js +37 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JumpToMenu.d.ts","sourceRoot":"","sources":["../../../src/components/JumpTo/JumpToMenu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"JumpToMenu.d.ts","sourceRoot":"","sources":["../../../src/components/JumpTo/JumpToMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAcf,OAAO,EAAc,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA4J7D,QAAA,MAAM,iBAAiB,+EAAyB,CAAC;AAKjD,eAAe,iBAAiB,CAAC"}
|
|
@@ -15,6 +15,8 @@ var _focusWithoutScrolling = _interopRequireDefault(require("../../utils/focusWi
|
|
|
15
15
|
|
|
16
16
|
var _useTranslations = _interopRequireDefault(require("../../utils/useTranslations"));
|
|
17
17
|
|
|
18
|
+
var _useDebounce = _interopRequireDefault(require("../../utils/useDebounce"));
|
|
19
|
+
|
|
18
20
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
19
21
|
|
|
20
22
|
var _Menu = _interopRequireDefault(require("../Menu"));
|
|
@@ -55,20 +57,30 @@ function JumpToMenu(props, forwardedRef) {
|
|
|
55
57
|
globalOffset = props.offset,
|
|
56
58
|
onKeyDown = props.onKeyDown,
|
|
57
59
|
zIndex = props.zIndex,
|
|
58
|
-
|
|
60
|
+
_props$openOnMouseHov = props.openOnMouseHover,
|
|
61
|
+
openOnMouseHover = _props$openOnMouseHov === void 0 ? false : _props$openOnMouseHov,
|
|
62
|
+
rest = _objectWithoutProperties(props, ["items", "label", "offset", "onKeyDown", "zIndex", "openOnMouseHover"]);
|
|
59
63
|
|
|
60
64
|
var translate = (0, _useTranslations.default)();
|
|
61
65
|
var itemSelected = (0, _react.useRef)(false);
|
|
62
66
|
|
|
63
|
-
var _useState = (0, _react.useState)(
|
|
67
|
+
var _useState = (0, _react.useState)(false),
|
|
68
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
69
|
+
isPopoverVisible = _useState2[0],
|
|
70
|
+
setIsPopoverVisible = _useState2[1];
|
|
71
|
+
|
|
72
|
+
var debouncedVisible = (0, _useDebounce.default)(isPopoverVisible, 200);
|
|
73
|
+
|
|
74
|
+
var _useState3 = (0, _react.useState)({
|
|
64
75
|
hide: function hide() {},
|
|
65
76
|
isVisible: false,
|
|
66
77
|
show: function show() {},
|
|
67
|
-
toggle: function toggle() {}
|
|
78
|
+
toggle: function toggle() {},
|
|
79
|
+
contentNode: null
|
|
68
80
|
}),
|
|
69
|
-
|
|
70
|
-
popover =
|
|
71
|
-
setPopover =
|
|
81
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
82
|
+
popover = _useState4[0],
|
|
83
|
+
setPopover = _useState4[1];
|
|
72
84
|
|
|
73
85
|
var buttonRef = (0, _react.useRef)(null);
|
|
74
86
|
var popoverRef = (0, _react.useCallback)(setPopover, [popover]);
|
|
@@ -102,6 +114,7 @@ function JumpToMenu(props, forwardedRef) {
|
|
|
102
114
|
selector = _ref2.selector;
|
|
103
115
|
itemSelected.current = true;
|
|
104
116
|
popover.hide();
|
|
117
|
+
setIsPopoverVisible(false);
|
|
105
118
|
selector && (0, _utils.jumpToSelector)(selector, globalOffset, itemOffset);
|
|
106
119
|
};
|
|
107
120
|
|
|
@@ -111,6 +124,29 @@ function JumpToMenu(props, forwardedRef) {
|
|
|
111
124
|
var onHide = (0, _react.useCallback)(function () {
|
|
112
125
|
itemSelected && !itemSelected.current && buttonRef && buttonRef.current && (0, _focusWithoutScrolling.default)(buttonRef.current);
|
|
113
126
|
}, []);
|
|
127
|
+
var handleMouseEnter = (0, _react.useCallback)(function () {
|
|
128
|
+
setIsPopoverVisible(true);
|
|
129
|
+
|
|
130
|
+
if (popover && popover.contentNode) {
|
|
131
|
+
(0, _focusWithoutScrolling.default)(popover.contentNode);
|
|
132
|
+
}
|
|
133
|
+
}, [openOnMouseHover, popover, popover && popover.contentNode]);
|
|
134
|
+
var handleMouseLeave = (0, _react.useCallback)(function () {
|
|
135
|
+
setIsPopoverVisible(false);
|
|
136
|
+
}, [openOnMouseHover, popover]);
|
|
137
|
+
var handleMouseEnterButton = (0, _react.useCallback)(function () {
|
|
138
|
+
if (openOnMouseHover) {
|
|
139
|
+
buttonRef && buttonRef.current && (0, _focusWithoutScrolling.default)(buttonRef.current);
|
|
140
|
+
setIsPopoverVisible(true);
|
|
141
|
+
|
|
142
|
+
if (popover && popover.contentNode) {
|
|
143
|
+
(0, _focusWithoutScrolling.default)(popover.contentNode);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, [openOnMouseHover, buttonRef, popover && popover.contentNode]);
|
|
147
|
+
(0, _react.useEffect)(function () {
|
|
148
|
+
if (!debouncedVisible) itemSelected.current = false;
|
|
149
|
+
}, [debouncedVisible, itemSelected.current]);
|
|
114
150
|
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Button.default, _extends({
|
|
115
151
|
icon: popover.isVisible ? _ChevronUp.default : _ChevronDown.default,
|
|
116
152
|
iconPosition: "right",
|
|
@@ -119,16 +155,21 @@ function JumpToMenu(props, forwardedRef) {
|
|
|
119
155
|
ref: buttonRef,
|
|
120
156
|
size: "small",
|
|
121
157
|
text: translate(label, 'jumpTo.menuLabel'),
|
|
122
|
-
variant: "ghost"
|
|
158
|
+
variant: "ghost",
|
|
159
|
+
onMouseEnter: handleMouseEnterButton,
|
|
160
|
+
onMouseLeave: handleMouseLeave
|
|
123
161
|
}, popover.ariaAttributes)), _react.default.createElement(_Popover.default, {
|
|
124
162
|
contentRole: "menu",
|
|
125
|
-
manageEvents: false,
|
|
163
|
+
manageEvents: openOnMouseHover ? 'click' : false,
|
|
126
164
|
onRequestHide: onRequestHide,
|
|
127
165
|
ref: popoverRef,
|
|
128
166
|
target: buttonRef,
|
|
129
167
|
zIndex: zIndex,
|
|
130
168
|
onShow: onShow,
|
|
131
|
-
onHide: onHide
|
|
169
|
+
onHide: onHide,
|
|
170
|
+
visible: openOnMouseHover ? debouncedVisible && !itemSelected.current : undefined,
|
|
171
|
+
onMouseEnter: handleMouseEnter,
|
|
172
|
+
onMouseLeave: handleMouseLeave
|
|
132
173
|
}, _react.default.createElement(_Menu.default, _extends({
|
|
133
174
|
items: menuItems,
|
|
134
175
|
onSelectItem: onSelectItem,
|
|
@@ -124,4 +124,88 @@ describe('JumpTo', function () {
|
|
|
124
124
|
expect(container.children[0].childElementCount).toEqual(0);
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
+
describe('with openOnMouseHover', function () {
|
|
128
|
+
it('renders list on hover', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
129
|
+
var label, items, _renderJumpTo4, baseElement, getByText;
|
|
130
|
+
|
|
131
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
132
|
+
while (1) {
|
|
133
|
+
switch (_context2.prev = _context2.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
label = 'TEST LABEL';
|
|
136
|
+
items = [{
|
|
137
|
+
label: 'First Item',
|
|
138
|
+
selector: '#item-1'
|
|
139
|
+
}, {
|
|
140
|
+
label: 'Second Item',
|
|
141
|
+
selector: '#item-2'
|
|
142
|
+
}];
|
|
143
|
+
_renderJumpTo4 = renderJumpTo({
|
|
144
|
+
label: label,
|
|
145
|
+
items: items,
|
|
146
|
+
openOnMouseHover: true,
|
|
147
|
+
variant: 'menu'
|
|
148
|
+
}), baseElement = _renderJumpTo4.baseElement, getByText = _renderJumpTo4.getByText;
|
|
149
|
+
(0, _react2.act)(function () {
|
|
150
|
+
_react2.fireEvent.mouseEnter(getByText(label));
|
|
151
|
+
});
|
|
152
|
+
_context2.next = 6;
|
|
153
|
+
return (0, _react2.waitForElement)(function () {
|
|
154
|
+
return getByText(items[0].label);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
case 6:
|
|
158
|
+
expect(baseElement).toMatchSnapshot();
|
|
159
|
+
|
|
160
|
+
case 7:
|
|
161
|
+
case "end":
|
|
162
|
+
return _context2.stop();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, _callee2);
|
|
166
|
+
})));
|
|
167
|
+
it('closes popover after selecting an item', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
168
|
+
var label, items, _renderJumpTo5, baseElement, getByText, queryByText;
|
|
169
|
+
|
|
170
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
171
|
+
while (1) {
|
|
172
|
+
switch (_context3.prev = _context3.next) {
|
|
173
|
+
case 0:
|
|
174
|
+
label = 'TEST LABEL';
|
|
175
|
+
items = [{
|
|
176
|
+
label: 'First Item',
|
|
177
|
+
selector: '#item-1'
|
|
178
|
+
}, {
|
|
179
|
+
label: 'Second Item',
|
|
180
|
+
selector: '#item-2'
|
|
181
|
+
}];
|
|
182
|
+
_renderJumpTo5 = renderJumpTo({
|
|
183
|
+
label: label,
|
|
184
|
+
items: items,
|
|
185
|
+
openOnMouseHover: true,
|
|
186
|
+
variant: 'menu'
|
|
187
|
+
}), baseElement = _renderJumpTo5.baseElement, getByText = _renderJumpTo5.getByText, queryByText = _renderJumpTo5.queryByText;
|
|
188
|
+
(0, _react2.act)(function () {
|
|
189
|
+
_react2.fireEvent.mouseEnter(getByText(label));
|
|
190
|
+
});
|
|
191
|
+
_context3.next = 6;
|
|
192
|
+
return (0, _react2.waitForElement)(function () {
|
|
193
|
+
return getByText(items[0].label);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
case 6:
|
|
197
|
+
(0, _react2.act)(function () {
|
|
198
|
+
_react2.fireEvent.click(getByText(items[0].label));
|
|
199
|
+
});
|
|
200
|
+
expect(queryByText(items[0].label)).toBeNull();
|
|
201
|
+
expect(baseElement).toMatchSnapshot();
|
|
202
|
+
|
|
203
|
+
case 9:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context3.stop();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, _callee3);
|
|
209
|
+
})));
|
|
210
|
+
});
|
|
127
211
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/JumpTo/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/JumpTo/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAAsC,CAAC;AAuCnD,eAAe,MAAM,CAAC"}
|
|
@@ -20,7 +20,8 @@ schema.propTypes = {
|
|
|
20
20
|
label: _reactDesc.PropTypes.string.description('An optional string that sets the label for the component. You can also set the label using the translations object set in context.').defaultValue('Jump To:'),
|
|
21
21
|
offset: _reactDesc.PropTypes.number.description('A distance to offset the jump to target for _all_ selectors. Can be overridden when declaring jump to items.'),
|
|
22
22
|
variant: _reactDesc.PropTypes.oneOf(['menu']).description("Selects a specific variation for display. If set to 'menu', the Jump To will display as a drop-down menu. If not set, will display using the standard horizontal layout."),
|
|
23
|
-
zIndex: _reactDesc.PropTypes.number.description('For the nav variant, sets the z-index of the `<nav>` element. For the menu variant, sets the z-index of the Popover containing the menu items.')
|
|
23
|
+
zIndex: _reactDesc.PropTypes.number.description('For the nav variant, sets the z-index of the `<nav>` element. For the menu variant, sets the z-index of the Popover containing the menu items.'),
|
|
24
|
+
openOnMouseHover: _reactDesc.PropTypes.bool.description('For the menu variant, if true, the menu will open on mouse hover. If false, the menu will open on mouse click.').defaultValue(false)
|
|
24
25
|
};
|
|
25
26
|
var _default = schema;
|
|
26
27
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/JumpTo/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,oBAAY,SAAS,GAAG,cAAc,GAAG,OAAO,CAAC;AAEjD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACpE,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/JumpTo/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,oBAAY,SAAS,GAAG,cAAc,GAAG,OAAO,CAAC;AAEjD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACpE,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAUN,MAAM,OAAO,CAAC;AAWf,OAAc,EAAE,WAAW,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,UAAU,IAAI,cAAc,EAC5B,WAAW,IAAI,eAAe,EAE9B,SAAS,IAAI,aAAa,EAC1B,YAAY,IAAI,SAAS,EACzB,MAAM,IAAI,aAAa,EACvB,cAAc,IAAI,kBAAkB,EACpC,mBAAmB,IAAI,uBAAuB,EAE/C,MAAM,SAAS,CAAC;AAGjB,oBAAY,UAAU,GAAG,cAAc,CAAC;AACxC,oBAAY,WAAW,GAAG,eAAe,CAAC;AAC1C,oBAAY,WAAW,GAAG,eAAe,CAAC;AAC1C,oBAAY,SAAS,GAAG,aAAa,CAAC;AACtC,oBAAY,YAAY,GAAG,SAAS,CAAC;AACrC,oBAAY,MAAM,GAAG,aAAa,CAAC;AACnC,oBAAY,cAAc,GAAG,kBAAkB,CAAC;AAChD,oBAAY,mBAAmB,GAAG,uBAAuB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAUN,MAAM,OAAO,CAAC;AAWf,OAAc,EAAE,WAAW,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,UAAU,IAAI,cAAc,EAC5B,WAAW,IAAI,eAAe,EAE9B,SAAS,IAAI,aAAa,EAC1B,YAAY,IAAI,SAAS,EACzB,MAAM,IAAI,aAAa,EACvB,cAAc,IAAI,kBAAkB,EACpC,mBAAmB,IAAI,uBAAuB,EAE/C,MAAM,SAAS,CAAC;AAGjB,oBAAY,UAAU,GAAG,cAAc,CAAC;AACxC,oBAAY,WAAW,GAAG,eAAe,CAAC;AAC1C,oBAAY,WAAW,GAAG,eAAe,CAAC;AAC1C,oBAAY,SAAS,GAAG,aAAa,CAAC;AACtC,oBAAY,YAAY,GAAG,SAAS,CAAC;AACrC,oBAAY,MAAM,GAAG,aAAa,CAAC;AACnC,oBAAY,cAAc,GAAG,kBAAkB,CAAC;AAChD,oBAAY,mBAAmB,GAAG,uBAAuB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AAyQnC,QAAA,MAAM,cAAc,mFAAsB,CAAC;AAkD3C,eAAe,cAAc,CAAC"}
|
|
@@ -199,9 +199,10 @@ var Popover = function Popover(props, instanceRef) {
|
|
|
199
199
|
isVisible: isVisible,
|
|
200
200
|
show: show,
|
|
201
201
|
toggle: toggle,
|
|
202
|
-
targetNode: targetNode
|
|
202
|
+
targetNode: targetNode,
|
|
203
|
+
contentNode: contentRef.current
|
|
203
204
|
});
|
|
204
|
-
}, [instanceRef, ariaAttributes, hide, isVisible, show, toggle, targetNode]); // React to changes to the `visible` prop if we are a controlled component
|
|
205
|
+
}, [instanceRef, ariaAttributes, hide, isVisible, show, toggle, targetNode, contentRef && contentRef.current]); // React to changes to the `visible` prop if we are a controlled component
|
|
205
206
|
|
|
206
207
|
(0, _react.useEffect)(function () {
|
|
207
208
|
return setIsVisible(visible !== undefined ? visible : isVisible);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BorderRadiusProperty } from 'csstype';
|
|
2
|
-
import { AriaAttributes, ReactElement, ReactNode, RefObject } from 'react';
|
|
2
|
+
import { AriaAttributes, HTMLAttributes, ReactElement, ReactNode, RefObject } from 'react';
|
|
3
3
|
import { RefHandler } from 'react-popper';
|
|
4
4
|
import { CommonUIColorKeys } from '../../utils/commonUIColors';
|
|
5
5
|
import { placements } from './constants';
|
|
@@ -18,6 +18,7 @@ export interface InstanceRef {
|
|
|
18
18
|
toggle: VisibilityAction;
|
|
19
19
|
isVisible: boolean;
|
|
20
20
|
targetNode?: HTMLElement | null;
|
|
21
|
+
contentNode?: HTMLDivElement | null;
|
|
21
22
|
}
|
|
22
23
|
export interface TargetRendererProps {
|
|
23
24
|
ref: RefHandler;
|
|
@@ -41,7 +42,7 @@ interface ChildrenRendererProps {
|
|
|
41
42
|
export declare type ChildrenRenderer = (props: ChildrenRendererProps) => ReactNode;
|
|
42
43
|
export declare type Children = ReactNode | ChildrenRenderer;
|
|
43
44
|
export declare type ArrowColor = 'charcoal' | CommonUIColorKeys;
|
|
44
|
-
export interface PopoverProps {
|
|
45
|
+
export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
|
|
45
46
|
alwaysRender?: boolean;
|
|
46
47
|
arrowColor?: ArrowColor;
|
|
47
48
|
borderRadius?: BorderRadiusProperty<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EACL,cAAc,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AClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../src/utils/useDebounce.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAc7D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDebounce;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _useUpdateEffect = _interopRequireDefault(require("./useUpdateEffect"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
15
|
+
|
|
16
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
17
|
+
|
|
18
|
+
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
19
|
+
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
|
|
22
|
+
function useDebounce(value, delay) {
|
|
23
|
+
var _useState = (0, _react.useState)(value),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
debouncedValue = _useState2[0],
|
|
26
|
+
setDebouncedValue = _useState2[1];
|
|
27
|
+
|
|
28
|
+
(0, _useUpdateEffect.default)(function () {
|
|
29
|
+
var handler = setTimeout(function () {
|
|
30
|
+
setDebouncedValue(value);
|
|
31
|
+
}, delay);
|
|
32
|
+
return function () {
|
|
33
|
+
clearTimeout(handler);
|
|
34
|
+
};
|
|
35
|
+
}, [value, delay]);
|
|
36
|
+
return debouncedValue;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decisiv/ui-components",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.196+9518bb9",
|
|
4
4
|
"description": "Decisiv's design system React components",
|
|
5
5
|
"author": "Decisiv UI Development Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"private": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "9518bb958af5cb4a795b7feddcaf1695d75ac8ba"
|
|
75
75
|
}
|