linear-react-components-ui 1.0.10-beta.8 → 1.0.10-beta.9

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.
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _lodash = _interopRequireDefault(require("lodash"));
9
10
  var _icons = _interopRequireDefault(require("../../lib/icons"));
10
11
  var _withTooltip = _interopRequireDefault(require("../internals/withTooltip"));
11
12
  var _spinner = _interopRequireDefault(require("../spinner"));
12
13
  var _withDropdown = _interopRequireDefault(require("../dropdown/withDropdown"));
13
14
  var _permissionValidations = require("../permissionValidations");
14
- var _excluded = ["dropdown", "onClick", "disabled", "iconName", "icon", "targetRef", "tabIndex", "isLoading", "label", "showDropdown", "getDropdownPopup", "isDropdownOpened", "showIconDropdown", "content", "style", "toggleable", "activeIconColor", "iconStyle", "visible", "customClass", "className", "size", "iconAlign", "boxShadow", "transparent", "round", "permissionAttr", "skeletonize", "tooltipPosition", "tooltipWidth", "isFloatMenu", "dropdownAlign", "customClassForDropdown"];
15
+ var _excluded = ["dropdown", "onClick", "disabled", "iconName", "icon", "targetRef", "tabIndex", "isLoading", "label", "showDropdown", "getDropdownPopup", "isDropdownOpened", "showIconDropdown", "content", "style", "toggleable", "activeIconColor", "iconStyle", "visible", "customClass", "className", "size", "iconAlign", "boxShadow", "transparent", "round", "permissionAttr", "skeletonize", "tooltipPosition", "tooltipWidth", "isFloatMenu", "dropdownAlign", "customClassForDropdown", "buttonRef"];
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -63,6 +64,7 @@ var DefaultButton = function DefaultButton(_ref) {
63
64
  isFloatMenu = _ref.isFloatMenu,
64
65
  dropdownAlign = _ref.dropdownAlign,
65
66
  customClassForDropdown = _ref.customClassForDropdown,
67
+ buttonRef = _ref.buttonRef,
66
68
  rest = _objectWithoutProperties(_ref, _excluded);
67
69
  var options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible];
68
70
  var _useState = (0, _react.useState)(false),
@@ -72,7 +74,7 @@ var DefaultButton = function DefaultButton(_ref) {
72
74
  var _useState3 = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr)),
73
75
  _useState4 = _slicedToArray(_useState3, 1),
74
76
  onDenied = _useState4[0];
75
- var buttonRef = (0, _react.useRef)(null);
77
+ var refButton = (0, _react.useRef)(null);
76
78
  var disabledIconColor = 'rgb(193, 193, 193)';
77
79
  var shouldDisable = function shouldDisable() {
78
80
  return !!onDenied.disabled || disabled;
@@ -126,8 +128,15 @@ var DefaultButton = function DefaultButton(_ref) {
126
128
  disabled: shouldDisable(),
127
129
  className: "".concat(getClass(), " ").concat(activeButton ? '-toggleable' : '', " ").concat(skeletonize ? '-skeletonized' : ''),
128
130
  ref: function ref(r) {
131
+ if (buttonRef) {
132
+ if (!_lodash.default.isFunction(buttonRef)) {
133
+ refButton.current = r;
134
+ } else {
135
+ buttonRef(r);
136
+ }
137
+ }
129
138
  if (targetRef) targetRef(r);
130
- buttonRef.current = r;
139
+ refButton.current = r;
131
140
  },
132
141
  tabIndex: tabIndex
133
142
  }), content, getIcon(), label || '', isLoading && /*#__PURE__*/_react.default.createElement("div", {
@@ -135,7 +144,7 @@ var DefaultButton = function DefaultButton(_ref) {
135
144
  }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
136
145
  align: "none",
137
146
  delayTime: 0
138
- }))), dropdown && buttonRef.current && getDropdownPopup && getDropdownPopup(buttonRef.current));
147
+ }))), dropdown && refButton.current && getDropdownPopup && getDropdownPopup(refButton.current));
139
148
  };
140
149
  var _default = (0, _withDropdown.default)((0, _withTooltip.default)(DefaultButton));
141
150
  exports.default = _default;
@@ -1,4 +1,4 @@
1
- import { ButtonHTMLAttributes, ReactNode, CSSProperties, ReactElement, MouseEvent } from 'react';
1
+ import { ButtonHTMLAttributes, ReactNode, CSSProperties, ReactElement, MutableRefObject, MouseEvent } from 'react';
2
2
  import { PermissionAttr } from '../@types/PermissionAttr.js';
3
3
  import { Position } from '../@types/Position.js';
4
4
  import { Size } from '../@types/Size.js';
@@ -16,6 +16,7 @@ interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
16
16
  iconStyle?: CSSProperties;
17
17
  boxShadow?: boolean;
18
18
  icon?: ReactElement;
19
+ buttonRef?: MutableRefObject<HTMLButtonElement | null> | ((ref: HTMLButtonElement | null) => void);
19
20
  targetRef?: (ref: HTMLButtonElement) => void;
20
21
  dropdown?: boolean;
21
22
  dropdownOnHover?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.0.10-beta.8",
3
+ "version": "1.0.10-beta.9",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",