plataforma-fundacao-componentes 2.25.9 → 2.25.10

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.
@@ -1,4 +1,4 @@
1
- import React$1, { useMemo, useState, useEffect, memo, useCallback, useRef, useLayoutEffect, Fragment as Fragment$1, forwardRef, useImperativeHandle, createRef } from 'react';
1
+ import React$1, { useMemo, useState, useEffect, memo, useCallback, useRef, useLayoutEffect, createRef, Fragment as Fragment$1, forwardRef, useImperativeHandle } from 'react';
2
2
  import { CSSTransition, TransitionGroup } from 'react-transition-group';
3
3
  import { Chart } from 'chart.js';
4
4
  import moment from 'moment';
@@ -7529,39 +7529,54 @@ function DropdownItem(props) {
7529
7529
  }
7530
7530
  var DropdownItem$1 = memo(DropdownItem);
7531
7531
 
7532
- function useOutsideClick(refs, handler) {
7532
+ function useOutsideClick(refs, handler, options) {
7533
+ var _options3;
7534
+ if (options === void 0) {
7535
+ options = {
7536
+ events: ['mouseup', 'touchstart']
7537
+ };
7538
+ }
7533
7539
  var handleClickOutside = useCallback(function (e) {
7534
- if (refs && 'current' in refs && refs.current) {
7535
- var isInside = Array.isArray(refs.current) ? refs.current.some(function (element) {
7536
- return !!element && element.contains(e.target);
7537
- }) : !!refs && !!refs.current && refs.current.contains(e.target);
7538
- handler(isInside);
7539
- } else {
7540
- var _isInside = Array.isArray(refs) && refs.some(function (element) {
7541
- return !!element && !!element.current && element.current.contains(e.target);
7542
- });
7543
- handler(_isInside);
7544
- }
7540
+ var isInside = refs.some(function (r) {
7541
+ return (r === null || r === void 0 ? void 0 : r.current) && r.current.contains(e.target);
7542
+ });
7543
+ handler(isInside);
7545
7544
  }, [handler, refs]);
7546
7545
  useEffect(function () {
7547
- document.addEventListener('mouseup', handleClickOutside);
7548
- document.addEventListener('touchstart', handleClickOutside);
7546
+ var _options;
7547
+ (_options = options) === null || _options === void 0 ? void 0 : _options.events.forEach(function (evt) {
7548
+ document.addEventListener(evt, handleClickOutside);
7549
+ });
7549
7550
  return function () {
7550
- document.removeEventListener('mouseup', handleClickOutside);
7551
- document.removeEventListener('touchstart', handleClickOutside);
7551
+ var _options2;
7552
+ (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.events.forEach(function (evt) {
7553
+ document.removeEventListener(evt, handleClickOutside);
7554
+ });
7552
7555
  };
7553
- }, [refs, handler, handleClickOutside]);
7556
+ }, [refs, handler, handleClickOutside, (_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.events]);
7554
7557
  }
7555
7558
 
7559
+ var _excluded = ["opened", "setOpened", "content", "closeOnEsc", "closeOnOutClick", "children", "panelProps"];
7556
7560
  var rootClassName$1Z = 'component-dropdown-menu';
7557
- function DropdownMenu(props) {
7561
+ function DropdownMenu(_ref) {
7562
+ var _panelProps$className;
7563
+ var opened = _ref.opened,
7564
+ setOpened = _ref.setOpened,
7565
+ content = _ref.content,
7566
+ closeOnEsc = _ref.closeOnEsc,
7567
+ closeOnOutClick = _ref.closeOnOutClick,
7568
+ children = _ref.children,
7569
+ _ref$panelProps = _ref.panelProps,
7570
+ panelProps = _ref$panelProps === void 0 ? {} : _ref$panelProps,
7571
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
7558
7572
  var id = useMemo(function () {
7559
7573
  return props.id ? props.id : getUniqueKey();
7560
7574
  }, [props.id]);
7561
7575
  var _useState = useState(null),
7562
7576
  inter = _useState[0],
7563
7577
  setInter = _useState[1];
7564
- var panelRef = useRef(null);
7578
+ var wrapperRef = createRef();
7579
+ var panelRef = createRef();
7565
7580
  var interRef = useRef(inter);
7566
7581
  interRef.current = inter;
7567
7582
  useEffect(function () {
@@ -7595,7 +7610,7 @@ function DropdownMenu(props) {
7595
7610
  }
7596
7611
  }
7597
7612
  };
7598
- if (props.opened) {
7613
+ if (opened) {
7599
7614
  position();
7600
7615
  var _inter = setInterval(position, 100);
7601
7616
  setInter(_inter);
@@ -7606,20 +7621,20 @@ function DropdownMenu(props) {
7606
7621
  setInter(null);
7607
7622
  }
7608
7623
  };
7609
- }, [props.opened]);
7610
- useOutsideClick([panelRef], function (isInside) {
7611
- if (props.closeOnOutClick && !isInside) {
7612
- props.setOpened(false);
7624
+ }, [opened]);
7625
+ useOutsideClick([wrapperRef], function (isInside) {
7626
+ if (closeOnOutClick && !isInside) {
7627
+ setOpened(false);
7613
7628
  }
7614
7629
  });
7615
7630
  useEffect(function () {
7616
7631
  var onEscPress = function onEscPress(evt) {
7617
7632
  if (evt.key === 'Escape') {
7618
- props.setOpened(false);
7633
+ setOpened(false);
7619
7634
  }
7620
7635
  };
7621
- if (props.closeOnEsc) {
7622
- if (props.opened) {
7636
+ if (closeOnEsc) {
7637
+ if (opened) {
7623
7638
  document.addEventListener('keyup', onEscPress);
7624
7639
  } else {
7625
7640
  document.removeEventListener('keyup', onEscPress);
@@ -7628,30 +7643,24 @@ function DropdownMenu(props) {
7628
7643
  return function () {
7629
7644
  document.removeEventListener('keyup', onEscPress);
7630
7645
  };
7631
- }, [props.opened]);
7632
- var getProps = function getProps() {
7633
- var p = _extends({}, props, {
7634
- id: id,
7635
- className: getMergedClassNames([rootClassName$1Z, props.className || ''])
7636
- });
7637
- delete p.opened;
7638
- delete p.setOpened;
7639
- delete p.content;
7640
- delete p.closeOnOutClick;
7641
- delete p.closeOnEsc;
7642
- return p;
7643
- };
7644
- return React$1.createElement("div", Object.assign({}, getProps()), React$1.createElement("div", {
7646
+ }, [opened]);
7647
+ return React$1.createElement("div", Object.assign({
7648
+ ref: wrapperRef
7649
+ }, props, {
7650
+ id: id,
7651
+ className: [rootClassName$1Z, props.className || ''].join(' ')
7652
+ }), React$1.createElement("div", {
7645
7653
  className: rootClassName$1Z + "-children"
7646
- }, props.children), React$1.createElement(CSSTransition, {
7647
- "in": props.opened,
7654
+ }, children), React$1.createElement(CSSTransition, {
7655
+ "in": opened,
7648
7656
  timeout: 300,
7649
7657
  classNames: rootClassName$1Z + "-panel-fade",
7650
7658
  unmountOnExit: true
7651
- }, React$1.createElement("div", {
7652
- ref: panelRef,
7653
- className: rootClassName$1Z + "-panel scroll-white"
7654
- }, props.content)));
7659
+ }, React$1.createElement("div", Object.assign({
7660
+ ref: panelRef
7661
+ }, panelProps, {
7662
+ className: [rootClassName$1Z + "-panel scroll-white", (_panelProps$className = panelProps === null || panelProps === void 0 ? void 0 : panelProps.className) != null ? _panelProps$className : ''].join(' ')
7663
+ }), content)));
7655
7664
  }
7656
7665
  DropdownMenu.defaultProps = {
7657
7666
  closeOnOutClick: true,
@@ -9100,7 +9109,7 @@ function Paginator(props) {
9100
9109
  }
9101
9110
  Paginator.defaultProps = {};
9102
9111
 
9103
- var _excluded = ["boundaryCount", "count", "currentPage", "disabled", "hideNextButton", "hidePrevButton", "onChange", "page", "siblingCount", "maxLength"];
9112
+ var _excluded$1 = ["boundaryCount", "count", "currentPage", "disabled", "hideNextButton", "hidePrevButton", "onChange", "page", "siblingCount", "maxLength"];
9104
9113
  function usePagination(props) {
9105
9114
  if (props === void 0) {
9106
9115
  props = {};
@@ -9123,7 +9132,7 @@ function usePagination(props) {
9123
9132
  _props$siblingCount = _props.siblingCount,
9124
9133
  siblingCount = _props$siblingCount === void 0 ? 1 : _props$siblingCount,
9125
9134
  maxLength = _props.maxLength,
9126
- other = _objectWithoutPropertiesLoose(_props, _excluded);
9135
+ other = _objectWithoutPropertiesLoose(_props, _excluded$1);
9127
9136
  var isControlledRef = useRef(pageProp !== undefined);
9128
9137
  var _useState = useState(currentPage),
9129
9138
  pageCurrent = _useState[0],
@@ -9262,7 +9271,7 @@ function useScreenSize() {
9262
9271
  return value;
9263
9272
  }
9264
9273
 
9265
- var _excluded$1 = ["page", "type", "selected"];
9274
+ var _excluded$2 = ["page", "type", "selected"];
9266
9275
  var rootClassName$2k = 'pagination-component';
9267
9276
  var Pagination = function Pagination(props) {
9268
9277
  var screenSize = useScreenSize();
@@ -9386,7 +9395,7 @@ var Pagination = function Pagination(props) {
9386
9395
  var page = _ref2.page,
9387
9396
  type = _ref2.type,
9388
9397
  selected = _ref2.selected,
9389
- item = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
9398
+ item = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
9390
9399
  var children = null;
9391
9400
  if (type === 'start-ellipsis' || type === 'end-ellipsis') {
9392
9401
  children = React$1.createElement("li", {
@@ -9721,11 +9730,11 @@ function Search(props) {
9721
9730
  var _useState7 = useState(false),
9722
9731
  showResults = _useState7[0],
9723
9732
  setShowResults = _useState7[1];
9724
- var wrapperRef = useRef(null);
9733
+ var wrapperRef = createRef();
9725
9734
  var handleClickOutside = function handleClickOutside(e) {
9726
9735
  if (!e) setShowResults(false);
9727
9736
  };
9728
- useOutsideClick(wrapperRef, handleClickOutside);
9737
+ useOutsideClick([wrapperRef], handleClickOutside);
9729
9738
  var onEsc = function onEsc(evt) {
9730
9739
  if (evt.key === 'Escape') {
9731
9740
  setShowResults(false);
@@ -11158,13 +11167,13 @@ TextEditorColorPicker.defaultProps = {
11158
11167
  onChange: function onChange() {}
11159
11168
  };
11160
11169
 
11161
- var _excluded$2 = ["icon", "active"];
11170
+ var _excluded$3 = ["icon", "active"];
11162
11171
  var rootClassName$2B = 'text-editor-header-button';
11163
11172
  function TextEditorHeaderButton(_ref) {
11164
11173
  var _props$className;
11165
11174
  var icon = _ref.icon,
11166
11175
  active = _ref.active,
11167
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
11176
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
11168
11177
  return React$1.createElement("button", Object.assign({
11169
11178
  className: getMergedClassNames([rootClassName$2B, active ? 'active' : '', (_props$className = props.className) != null ? _props$className : ''])
11170
11179
  }, props), icon);