@occmundial/occ-atomic 1.32.0 → 1.33.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [1.33.0](https://github.com/occmundial/occ-atomic/compare/v1.32.1...v1.33.0) (2023-08-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add noJustified to SlideDown component ([88a6925](https://github.com/occmundial/occ-atomic/commit/88a692587aa5d3328dce4a360f08a8a14cdce94d))
7
+ * Update description ([d833719](https://github.com/occmundial/occ-atomic/commit/d833719c9fab3c1c12ec4b1f07fa0d8acd4293c5))
8
+
9
+ ## [1.32.1](https://github.com/occmundial/occ-atomic/compare/v1.32.0...v1.32.1) (2023-05-31)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Tooltip close delay ([76c2c6b](https://github.com/occmundial/occ-atomic/commit/76c2c6b604193aff5d80668fe7a412c6778ca46b))
15
+
1
16
  # [1.32.0](https://github.com/occmundial/occ-atomic/compare/v1.31.0...v1.32.0) (2023-05-26)
2
17
 
3
18
 
@@ -107,7 +107,8 @@ var SlideDown = /*#__PURE__*/function (_React$Component) {
107
107
  tag = _this$props.tag,
108
108
  textSize = _this$props.textSize,
109
109
  strong = _this$props.strong,
110
- theme = _this$props.theme;
110
+ theme = _this$props.theme,
111
+ noJustified = _this$props.noJustified;
111
112
 
112
113
  var getTextSize = function getTextSize() {
113
114
  switch (textSize) {
@@ -170,7 +171,7 @@ var SlideDown = /*#__PURE__*/function (_React$Component) {
170
171
  }
171
172
  }, /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
172
173
  display: "flex",
173
- justifyContent: "between",
174
+ justifyContent: !noJustified ? 'between' : null,
174
175
  alignItems: "start"
175
176
  }, /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
176
177
  display: "flex",
@@ -208,7 +209,8 @@ SlideDown.defaultProps = {
208
209
  expanded: false,
209
210
  textSize: 'md',
210
211
  strong: false,
211
- theme: 'default'
212
+ theme: 'default',
213
+ noJustified: false
212
214
  };
213
215
  SlideDown.propTypes = {
214
216
  classes: _propTypes["default"].object,
@@ -233,7 +235,10 @@ SlideDown.propTypes = {
233
235
  strong: _propTypes["default"].bool,
234
236
 
235
237
  /** Theme of the SlideDown */
236
- theme: _propTypes["default"].oneOf(['default', 'blue'])
238
+ theme: _propTypes["default"].oneOf(['default', 'blue']),
239
+
240
+ /** The Title container has an alignment by default. Use this property if you need to remove it. */
241
+ noJustified: _propTypes["default"].bool
237
242
  };
238
243
  var _default = SlideDown;
239
244
  exports["default"] = _default;
@@ -80,6 +80,8 @@ function Tooltip(_ref) {
80
80
  fit = _ref$fit === void 0 ? false : _ref$fit,
81
81
  _ref$width = _ref.width,
82
82
  width = _ref$width === void 0 ? 220 : _ref$width,
83
+ _ref$strategy = _ref.strategy,
84
+ strategy = _ref$strategy === void 0 ? 'absolute' : _ref$strategy,
83
85
  onChange = _ref.onChange;
84
86
  var arrowRef = (0, _react.useRef)(null);
85
87
 
@@ -120,6 +122,7 @@ function Tooltip(_ref) {
120
122
  open: open,
121
123
  onOpenChange: setOpen,
122
124
  placement: placement,
125
+ strategy: strategy,
123
126
  whileElementsMounted: _react2.autoUpdate,
124
127
  middleware: getMiddlewares
125
128
  }),
@@ -146,7 +149,8 @@ function Tooltip(_ref) {
146
149
  className: "".concat(classes.tooltip, " ").concat(className.hasOwnProperty('tooltip') && className.tooltip, " ").concat(classes[theme] || classes.purple),
147
150
  ref: refs.setFloating,
148
151
  style: _objectSpread(_objectSpread({}, floatingStyles), {}, {
149
- zIndex: zIndex
152
+ zIndex: zIndex,
153
+ position: strategy
150
154
  })
151
155
  }, getFloatingProps()), text, showArrow && /*#__PURE__*/_react["default"].createElement(_react2.FloatingArrow, {
152
156
  ref: arrowRef,
@@ -196,6 +200,9 @@ Tooltip.propTypes = {
196
200
  /** The "Width" property of the Tooltip enables modification of its width and accepts a number (e.g., 220), a string (e.g., '220px' or 'auto') or null as its value. */
197
201
  width: _propTypes["default"].number,
198
202
 
203
+ /** The CSS position property to use to compute the tooltip position */
204
+ strategy: _propTypes["default"].oneOf(['absolute', 'fixed']),
205
+
199
206
  /** Callback fired when the Tooltip show state changes. */
200
207
  onChange: _propTypes["default"].func
201
208
  };
@@ -21,10 +21,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
21
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
22
 
23
23
  function useOpenTooltipState(openExternal, setOpenExternal, closeDelay) {
24
- var delay = useThrottle({
24
+ var _useThrottle = useThrottle({
25
25
  trailing: true,
26
26
  leading: false
27
- });
27
+ }),
28
+ throttle = _useThrottle.throttle,
29
+ cancel = _useThrottle.cancel;
28
30
 
29
31
  var _useState = (0, _react.useState)(false),
30
32
  _useState2 = _slicedToArray(_useState, 2),
@@ -37,20 +39,18 @@ function useOpenTooltipState(openExternal, setOpenExternal, closeDelay) {
37
39
  var setOpenSource = (0, _react.useMemo)(function () {
38
40
  return openExternal !== undefined ? setOpenExternal !== null && setOpenExternal !== void 0 ? setOpenExternal : function () {} : setOpenInternal;
39
41
  }, [openExternal, setOpenExternal, setOpenInternal]);
40
- var setOpenSourceDelay = (0, _react.useMemo)(function () {
41
- return function (show) {
42
- return delay({
43
- throttleTime: closeDelay,
44
- callback: function callback() {
45
- return setOpenSource(show);
46
- }
47
- });
48
- };
49
- }, [closeDelay, setOpenSource, delay]);
50
-
51
- function setOpen(open) {
52
- if (open) {
53
- delay.cancel();
42
+ var setOpenSourceDelay = (0, _react.useCallback)(function (show) {
43
+ throttle({
44
+ throttleTime: closeDelay,
45
+ callback: function callback() {
46
+ return setOpenSource(show);
47
+ }
48
+ });
49
+ }, [closeDelay, setOpenSource, throttle]);
50
+
51
+ function setOpen(openValue) {
52
+ if (openValue) {
53
+ if (open) cancel();
54
54
  setOpenSource(true);
55
55
  } else {
56
56
  closeDelay > 0 ? setOpenSourceDelay(false) : setOpenSource(false);
@@ -58,10 +58,14 @@ function useOpenTooltipState(openExternal, setOpenExternal, closeDelay) {
58
58
  }
59
59
 
60
60
  (0, _react.useEffect)(function () {
61
- if (openExternal === false || closeDelay <= 0) return;
62
- delay.cancel();
63
- setOpenSourceDelay(false);
64
- }, [openExternal, setOpenSourceDelay, setOpenSource, delay, closeDelay]);
61
+ if (closeDelay <= 0) return;
62
+
63
+ if (openExternal === false) {
64
+ cancel();
65
+ } else {
66
+ setOpenSourceDelay(false);
67
+ }
68
+ }, [openExternal, setOpenSourceDelay, setOpenSource, closeDelay, cancel]);
65
69
  return [open, setOpen];
66
70
  }
67
71
 
@@ -70,8 +74,20 @@ function useThrottle() {
70
74
  var timeout = (0, _react.useRef)(null);
71
75
  var lastCallback = (0, _react.useRef)(null);
72
76
  var date = (0, _react.useRef)(null);
73
-
74
- function throttle(_ref) {
77
+ var cancel = (0, _react.useCallback)(function () {
78
+ if (!timeout.current) return;
79
+ window.clearTimeout(timeout.current);
80
+ timeout.current = null;
81
+ date.current = null;
82
+ }, []);
83
+ var flush = (0, _react.useCallback)(function () {
84
+ if (!lastCallback.current) return;
85
+ lastCallback.current();
86
+ lastCallback.current = null;
87
+ date.current = null;
88
+ cancel();
89
+ }, [cancel]);
90
+ var throttle = (0, _react.useCallback)(function (_ref) {
75
91
  var _ref4;
76
92
 
77
93
  var callback = _ref.callback,
@@ -100,33 +116,17 @@ function useThrottle() {
100
116
 
101
117
  ((_defaults$trailing = defaults === null || defaults === void 0 ? void 0 : defaults.trailing) !== null && _defaults$trailing !== void 0 ? _defaults$trailing : trailing) ? flush() : cancel();
102
118
  }, (_ref4 = throttleTime !== null && throttleTime !== void 0 ? throttleTime : defaults.throttleTime) !== null && _ref4 !== void 0 ? _ref4 : 1000);
103
- }
104
-
105
- function flush() {
106
- if (!lastCallback.current) return;
107
- lastCallback.current();
108
- lastCallback.current = null;
109
- date.current = null;
110
- cancel();
111
- }
112
-
113
- function cancel() {
114
- if (!timeout.current) return;
115
- window.clearTimeout(timeout.current);
116
- timeout.current = null;
117
- date.current = null;
118
- }
119
-
119
+ }, [cancel, defaults.callback, defaults === null || defaults === void 0 ? void 0 : defaults.leading, defaults.throttleTime, defaults === null || defaults === void 0 ? void 0 : defaults.trailing, flush]);
120
120
  (0, _react.useEffect)(function () {
121
121
  return cancel;
122
- }, []);
123
- throttle.flush = flush;
124
- throttle.cancel = cancel;
125
- throttle.date = date;
126
-
127
- throttle.isActive = function () {
128
- return !!date.current;
122
+ }, [cancel]);
123
+ return {
124
+ throttle: throttle,
125
+ flush: flush,
126
+ cancel: cancel,
127
+ isActive: function isActive() {
128
+ return !!date.current;
129
+ },
130
+ date: date
129
131
  };
130
-
131
- return throttle;
132
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occmundial/occ-atomic",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "Collection of shareable styled React components for OCC applications.",
5
5
  "homepage": "http://occmundial.github.io/occ-atomic",
6
6
  "main": "build/index.js",