@onepercentio/one-ui 0.19.6 → 0.19.7
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/dist/components/AnchoredTooltip/AnchoredTooltip.d.ts +5 -1
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +11 -3
- package/dist/components/Collapsable/Collapsable.d.ts +2 -1
- package/dist/components/Collapsable/Collapsable.js +1 -1
- package/dist/components/OrderableList/OrderableList.js +20 -15
- package/dist/components/Select/Select.js +2 -1
- package/package.json +1 -1
|
@@ -18,7 +18,11 @@ export declare enum AnchoredTooltipAlignment {
|
|
|
18
18
|
CENTER = 1,
|
|
19
19
|
RIGHT = 2
|
|
20
20
|
}
|
|
21
|
-
export declare
|
|
21
|
+
export declare enum AnchoredTooltipAnchor {
|
|
22
|
+
TOP = 0,
|
|
23
|
+
BOTTOM = 1
|
|
24
|
+
}
|
|
25
|
+
export declare function updateTooltipPosition(tooltipRef: HTMLDivElement, anchorRef: HTMLElement, limitToViewport?: boolean, alignment?: AnchoredTooltipAlignment, anchorTo?: AnchoredTooltipAnchor): {
|
|
22
26
|
shouldAnchorToBottom: boolean;
|
|
23
27
|
};
|
|
24
28
|
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<{
|
|
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.AnchoredTooltipAlignment = void 0;
|
|
7
|
+
exports.default = exports.AnchoredTooltipAnchor = exports.AnchoredTooltipAlignment = void 0;
|
|
8
8
|
exports.updateTooltipPosition = updateTooltipPosition;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _OneUIProvider = require("../../context/OneUIProvider");
|
|
@@ -33,10 +33,17 @@ let AnchoredTooltipAlignment = /*#__PURE__*/function (AnchoredTooltipAlignment)
|
|
|
33
33
|
return AnchoredTooltipAlignment;
|
|
34
34
|
}({});
|
|
35
35
|
exports.AnchoredTooltipAlignment = AnchoredTooltipAlignment;
|
|
36
|
+
let AnchoredTooltipAnchor = /*#__PURE__*/function (AnchoredTooltipAnchor) {
|
|
37
|
+
AnchoredTooltipAnchor[AnchoredTooltipAnchor["TOP"] = 0] = "TOP";
|
|
38
|
+
AnchoredTooltipAnchor[AnchoredTooltipAnchor["BOTTOM"] = 1] = "BOTTOM";
|
|
39
|
+
return AnchoredTooltipAnchor;
|
|
40
|
+
}({});
|
|
41
|
+
exports.AnchoredTooltipAnchor = AnchoredTooltipAnchor;
|
|
36
42
|
function calculateTooltipFromAnchor(anchorRef, tooltipRef, containInViewport) {
|
|
37
43
|
let alignTo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : AnchoredTooltipAlignment.CENTER;
|
|
44
|
+
let anchorTo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : AnchoredTooltipAnchor.TOP;
|
|
38
45
|
const anchorPosition = getPositionOnViewport(anchorRef);
|
|
39
|
-
const shouldAnchorToBottom = tooltipRef.clientHeight > anchorPosition.top;
|
|
46
|
+
const shouldAnchorToBottom = anchorTo === AnchoredTooltipAnchor.BOTTOM || tooltipRef.clientHeight > anchorPosition.top;
|
|
40
47
|
let top = anchorPosition.top - tooltipRef.clientHeight;
|
|
41
48
|
|
|
42
49
|
/**
|
|
@@ -85,7 +92,8 @@ function calculateTooltipFromAnchor(anchorRef, tooltipRef, containInViewport) {
|
|
|
85
92
|
function updateTooltipPosition(tooltipRef, anchorRef) {
|
|
86
93
|
let limitToViewport = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
87
94
|
let alignment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : AnchoredTooltipAlignment.CENTER;
|
|
88
|
-
|
|
95
|
+
let anchorTo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : AnchoredTooltipAnchor.TOP;
|
|
96
|
+
const _calculateTooltipFrom = calculateTooltipFromAnchor(anchorRef, tooltipRef, limitToViewport, alignment, anchorTo),
|
|
89
97
|
top = _calculateTooltipFrom.top,
|
|
90
98
|
left = _calculateTooltipFrom.left,
|
|
91
99
|
shouldAnchorToBottom = _calculateTooltipFrom.shouldAnchorToBottom,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { AnchoredTooltipAlignment } from "../AnchoredTooltip/AnchoredTooltip";
|
|
2
|
+
import { AnchoredTooltipAlignment, AnchoredTooltipAnchor } from "../AnchoredTooltip/AnchoredTooltip";
|
|
3
3
|
declare class _CollapsableInterface {
|
|
4
4
|
_id: string;
|
|
5
5
|
constructor(id: string);
|
|
@@ -39,6 +39,7 @@ declare const _default: React.ForwardRefExoticComponent<(React.PropsWithChildren
|
|
|
39
39
|
} | {
|
|
40
40
|
mode: "float";
|
|
41
41
|
alignTo: AnchoredTooltipAlignment;
|
|
42
|
+
anchorTo?: AnchoredTooltipAnchor | undefined;
|
|
42
43
|
})> & Omit<React.HTMLAttributes<HTMLDivElement>, "title">) & React.RefAttributes<{
|
|
43
44
|
redimension: () => void;
|
|
44
45
|
}>>;
|
|
@@ -62,7 +62,7 @@ function Collapsable(_ref, ref) {
|
|
|
62
62
|
el.parentElement.style.position = "relative";
|
|
63
63
|
if (mode === "float") {
|
|
64
64
|
el.style.minHeight = el.style.height;
|
|
65
|
-
const _updateTooltipPositio = (0, _AnchoredTooltip.updateTooltipPosition)(el, toggleRef.current, true, "alignTo" in props ? props.alignTo : _AnchoredTooltip.AnchoredTooltipAlignment.CENTER),
|
|
65
|
+
const _updateTooltipPositio = (0, _AnchoredTooltip.updateTooltipPosition)(el, toggleRef.current, true, "alignTo" in props ? props.alignTo : _AnchoredTooltip.AnchoredTooltipAlignment.CENTER, "anchorTo" in props ? props.anchorTo : undefined),
|
|
66
66
|
shouldAnchorToBottom = _updateTooltipPositio.shouldAnchorToBottom;
|
|
67
67
|
el.style.minHeight = "";
|
|
68
68
|
if (!shouldAnchorToBottom) {
|
|
@@ -28,16 +28,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
28
28
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
29
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
30
30
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
31
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
32
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
33
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
34
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
35
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
32
36
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
37
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
38
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
34
39
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
35
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
36
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
37
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
38
40
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
39
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
40
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
41
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
42
42
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
43
43
|
const OrderableListContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
@@ -66,29 +66,34 @@ function OrderableList(_ref) {
|
|
|
66
66
|
reorderingClassName = _ref.reorderingClassName,
|
|
67
67
|
cloneClassName = _ref.cloneClassName,
|
|
68
68
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
69
|
+
const availableKeys = children.map(function (a) {
|
|
70
|
+
return a.key;
|
|
71
|
+
});
|
|
72
|
+
const availableKeysDep = availableKeys.join(",");
|
|
73
|
+
const initializeOrder = (0, _react.useCallback)(function () {
|
|
74
|
+
const missingOrderKeys = "keyOrder" in props && props.keyOrder ? availableKeys.filter(function (a) {
|
|
75
|
+
return !props.keyOrder.includes(a);
|
|
76
|
+
}) : [];
|
|
77
|
+
return ("keyOrder" in props && props.keyOrder ? [].concat(_toConsumableArray(props.keyOrder), _toConsumableArray(missingOrderKeys)) : undefined) || availableKeys;
|
|
78
|
+
}, [availableKeysDep, props.keyOrder]);
|
|
69
79
|
const _useRef = (0, _react.useRef)([]),
|
|
70
80
|
anchorsList = _useRef.current;
|
|
71
81
|
const eventEmitter = (0, _useEvents.default)();
|
|
72
82
|
const currentClone = (0, _react.useRef)(null);
|
|
73
83
|
const currentWorkingKey = (0, _react.useRef)();
|
|
74
|
-
const availableKeys = children.map(function (a) {
|
|
75
|
-
return a.key;
|
|
76
|
-
});
|
|
77
84
|
const rootRef = (0, _react.useRef)(null);
|
|
78
|
-
const _useState = (0, _react.useState)(
|
|
79
|
-
const missingOrderKeys = "keyOrder" in props && props.keyOrder ? availableKeys.filter(function (a) {
|
|
80
|
-
return !props.keyOrder.includes(a);
|
|
81
|
-
}) : [];
|
|
82
|
-
return ("keyOrder" in props && props.keyOrder ? [].concat(_toConsumableArray(props.keyOrder), _toConsumableArray(missingOrderKeys)) : undefined) || availableKeys;
|
|
83
|
-
}),
|
|
85
|
+
const _useState = (0, _react.useState)(initializeOrder),
|
|
84
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
85
87
|
_order = _useState2[0],
|
|
86
88
|
setOrder = _useState2[1];
|
|
89
|
+
(0, _react.useEffect)(function () {
|
|
90
|
+
return setOrder(initializeOrder());
|
|
91
|
+
}, [initializeOrder]);
|
|
87
92
|
const order = (0, _react.useMemo)(function () {
|
|
88
93
|
return ("currentOrder" in props ? props.currentOrder || _order : _order).filter(function (o) {
|
|
89
94
|
return o.includes(";") || availableKeys.includes(o);
|
|
90
95
|
});
|
|
91
|
-
}, [props.currentOrder, _order,
|
|
96
|
+
}, [props.currentOrder, _order, availableKeysDep]);
|
|
92
97
|
const cleanOrder = (0, _react.useMemo)(function () {
|
|
93
98
|
return order.map(function (a) {
|
|
94
99
|
return a.split(";")[0];
|
|
@@ -103,7 +103,8 @@ function Select(_ref) {
|
|
|
103
103
|
className: "".concat(otherProps.disabled ? "disabled" : "", " ").concat(rootClassName),
|
|
104
104
|
contentClassName: "".concat(_SelectModule.default.optionsContainer, " ").concat(dropdownClassNames.dropdown),
|
|
105
105
|
alignTo: alignTo,
|
|
106
|
-
ref: collapsableRef
|
|
106
|
+
ref: collapsableRef,
|
|
107
|
+
anchorTo: _AnchoredTooltip.AnchoredTooltipAnchor.BOTTOM
|
|
107
108
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
108
109
|
className: _SelectModule.default.items,
|
|
109
110
|
onClick: function onClick(e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onepercentio/one-ui",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"description": "A set of reusable components created through the development of Onepercent projects",
|
|
5
5
|
"repository": "git@github.com:onepercentio/one-ui.git",
|
|
6
6
|
"author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",
|