UNPKG

@checksub_team/react-widgets

Version:
33 lines (26 loc) 867 B
"use strict"; exports.__esModule = true; exports.notify = notify; exports.instanceId = instanceId; exports.isFirstFocusedRender = isFirstFocusedRender; var idCount = 0; function uniqueId(prefix) { return '' + ((prefix == null ? '' : prefix) + ++idCount); } function notify(handler, args) { handler && handler.apply(null, [].concat(args)); } function instanceId(component, suffix) { if (suffix === void 0) { suffix = ''; } component.__id || (component.__id = uniqueId('rw_')); return (component.props.id || component.__id) + suffix; } /** * Allows for defering popup rendering untill the widget is focused, * or has been opened (in order to not remove it suddenly on close) */ function isFirstFocusedRender(component) { return component._firstFocus || (component.state.focused || !!component.props.open) && (component._firstFocus = true); }