oolib 2.17.7 → 2.17.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,8 +1,8 @@
1
- export function ActionMenu({ icon, invert, actions, align, buttonText, sideEffect }: {
1
+ export function ActionMenu({ icon, invert, actions, align, iconSize, sideEffect }: {
2
2
  icon?: string;
3
3
  invert: any;
4
4
  actions: any;
5
5
  align?: string;
6
- buttonText: any;
6
+ iconSize?: string;
7
7
  sideEffect: any;
8
8
  }): JSX.Element;
@@ -42,21 +42,21 @@ var utils_1 = require("./utils");
42
42
  var styled_1 = require("./styled");
43
43
  var ActionMenu = function (_a) {
44
44
  var _b, _c;
45
- var _d = _a.icon, icon = _d === void 0 ? 'DotsThree' : _d, invert = _a.invert, actions = _a.actions, _e = _a.align, align = _e === void 0 ? 'right' : _e, buttonText = _a.buttonText, sideEffect = _a.sideEffect;
45
+ var _d = _a.icon, icon = _d === void 0 ? 'DotsThree' : _d, //most likely will never change
46
+ invert = _a.invert, actions = _a.actions, _e = _a.align, align = _e === void 0 ? 'right' : _e, _f = _a.iconSize, iconSize = _f === void 0 ? 'S' : _f, sideEffect = _a.sideEffect // if you want this click to trigger a sideeffect in parent. e.g in table elem we set table overflow to unset when action menu is open
47
+ ;
46
48
  var actionMenuRef = (0, react_1.useRef)(null);
47
49
  var optionsWrapperRef = (0, react_1.useRef)(null);
48
- var _f = (0, react_1.useState)(false), showActions = _f[0], setShowActions = _f[1];
50
+ var _g = (0, react_1.useState)(false), showActions = _g[0], setShowActions = _g[1];
49
51
  (0, utils_1.useTrackFocus)(actionMenuRef, setShowActions);
50
52
  (0, react_1.useEffect)(function () {
51
- // if you want this click to trigger a sideeffect in parent.
52
- //e.g in table elem we set table overflow to unset when action menu is open
53
53
  sideEffect && sideEffect(showActions);
54
54
  }, [showActions]);
55
55
  if (!actions || actions.length === 0)
56
56
  return null;
57
57
  var getOpsRect = function () { var _a; return (_a = optionsWrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); };
58
58
  return (react_1.default.createElement(styled_1.StyledActionMenu, { ref: actionMenuRef },
59
- react_1.default.createElement(Buttons_1.ButtonGhost, { icon: icon, iconSize: 'M', children: buttonText, invert: invert, onClick: function (e) {
59
+ react_1.default.createElement(Buttons_1.ButtonGhost, { icon: icon, iconSize: iconSize, invert: invert, onClick: function (e) {
60
60
  e.stopPropagation();
61
61
  setShowActions(!showActions);
62
62
  }, active: showActions }),
@@ -69,7 +69,7 @@ var ActionMenu = function (_a) {
69
69
  }),
70
70
  react_1.default.createElement(styled_1.StyledOptionsWrapper, { invert: invert, align: align, ref: optionsWrapperRef }, actions.map(function (action) {
71
71
  var ActionButton = action.buttonComp || styled_1.StyledOption;
72
- return (react_1.default.createElement(ActionButton, __assign({ style: { justifyContent: 'left' } }, action, { onClick: function (ev) {
72
+ return (react_1.default.createElement(ActionButton, __assign({}, action, { onClick: function (ev) {
73
73
  action.onClick && action.onClick(ev);
74
74
  setShowActions(false);
75
75
  }, key: action.display, invert: invert }),
@@ -33,40 +33,52 @@ var themes_1 = require("../../themes");
33
33
  var mixins_1 = require("../../themes/mixins");
34
34
  var greyColor5 = themes_1.colors.greyColor5, white = themes_1.colors.white, greyColor10 = themes_1.colors.greyColor10, greyColor70 = themes_1.colors.greyColor70, greyColor100 = themes_1.colors.greyColor100, greyColor80 = themes_1.colors.greyColor80;
35
35
  var pointerHeight = 10;
36
+ /**
37
+ * we add bottom, left and right margin on the StyledOptionsWrapper
38
+ * & increase the width by 20 and height by 10 of StyledActionsDropMenu
39
+ * so that the dropshadow shows (since StyledActionsDropMenu has overflow hidden)
40
+ *
41
+ * this offset needs to be cancelled by the absolute positioning of StyledActionsDropMenu
42
+ */
43
+ var offset = 10;
36
44
  exports.StyledActionMenu = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: max-content;\n"], ["\n position: relative;\n width: max-content;\n"])));
37
- exports.StyledActionsDropMenu = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n bottom: 0;\n transform: translateY(100%);\n z-index: 1001;\n transform-origin: left top;\n ", ";\n overflow: hidden;\n width: ", ";\n height: ", ";\n ", "\n box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);\n \n"], ["\n position: absolute;\n bottom: 0;\n transform: translateY(100%);\n z-index: 1001;\n transform-origin: left top;\n ", ";\n overflow: hidden;\n width: ", ";\n height: ", ";\n ", "\n box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);\n \n"])), (0, mixins_1.transition)("height"), function (_a) {
45
+ exports.StyledActionsDropMenu = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n bottom: 0;\n transform: translateY(100%);\n z-index: 1001;\n transform-origin: left top;\n ", ";\n overflow: hidden;\n width: ", ";\n height: ", ";\n ", "\n"], ["\n position: absolute;\n bottom: 0;\n transform: translateY(100%);\n z-index: 1001;\n transform-origin: left top;\n ", ";\n overflow: hidden;\n width: ", ";\n height: ", ";\n ", "\n"])), (0, mixins_1.transition)("height"), function (_a) {
38
46
  var optionsWidth = _a.optionsWidth;
39
- return optionsWidth + "px";
47
+ return (optionsWidth + (offset * 2)) + "px";
40
48
  }, function (_a) {
41
49
  var showActions = _a.showActions, optionsHeight = _a.optionsHeight;
42
- return showActions ? (optionsHeight + pointerHeight) + "px" || "auto" : 0;
50
+ return showActions ? (optionsHeight + pointerHeight + offset) + "px" || "auto" : 0;
43
51
  }, function (_a) {
44
52
  var align = _a.align;
45
53
  return align == "center"
46
- ? (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: 2rem;\n transform: translate(-50%, 100%);\n "], ["\n left: 2rem;\n transform: translate(-50%, 100%);\n "]))) : (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", ": 0;\n "], ["\n ", ": 0;\n "])), align);
54
+ ? (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: 1.5rem;\n transform: translate(-50%, 100%);\n "], ["\n left: 1.5rem;\n transform: translate(-50%, 100%);\n "]))) : (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", ": ", "px;\n "], ["\n ", ": ", "px;\n "])), align, 0 - offset);
47
55
  });
48
- exports.StyledOptionsWrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: absolute;\n bottom: 0;\n padding: 0.6rem 0;\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n\n &::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n\n ", "\n\n border: 1rem solid transparent;\n border-bottom: 1rem solid\n ", ";\n }\n"], ["\n position: absolute;\n bottom: 0;\n padding: 0.6rem 0;\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n\n &::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n\n ", "\n\n border: 1rem solid transparent;\n border-bottom: 1rem solid\n ", ";\n }\n"])), function (_a) {
56
+ exports.StyledOptionsWrapper = styled_components_1.default.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n position: absolute;\n bottom: 10px;\n padding: 0.6rem 0;\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);\n margin: 0 ", "px;\n \n //pointer outline\n &::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n\n ", "\n\n border: 1rem solid transparent;\n border-bottom: 1rem solid\n ", ";\n }\n\n //pointer fill\n &::before {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n ", "\n border: 0.85rem solid transparent;\n border-bottom: 0.85rem solid \n ", ";\n z-index: 1;\n }\n"], ["\n position: absolute;\n bottom: 10px;\n padding: 0.6rem 0;\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);\n margin: 0 ", "px;\n \n //pointer outline\n &::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n\n ", "\n\n border: 1rem solid transparent;\n border-bottom: 1rem solid\n ", ";\n }\n\n //pointer fill\n &::before {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n bottom: 100%;\n ", "\n border: 0.85rem solid transparent;\n border-bottom: 0.85rem solid \n ", ";\n z-index: 1;\n }\n"])), function (_a) {
49
57
  var invert = _a.invert;
50
58
  return (invert ? greyColor70 : greyColor5);
51
59
  }, function (_a) {
52
60
  var invert = _a.invert;
53
61
  return (invert ? greyColor80 : white);
54
- }, function (_a) {
62
+ }, offset, function (_a) {
55
63
  var align = _a.align;
56
64
  return align === "center"
57
- ? (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n left: 50%;\n transform: translateX(-50%);\n "], ["\n left: 50%;\n transform: translateX(-50%);\n "]))) : (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ": 1rem;\n "], ["\n ", ": 1rem;\n "])), align);
65
+ ? (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n left: 50%;\n transform: translateX(-50%);\n "], ["\n left: 50%;\n transform: translateX(-50%);\n "]))) : (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ": 0.5rem;\n "], ["\n ", ": 0.5rem;\n "])), align);
58
66
  }, function (_a) {
59
67
  var invert = _a.invert;
60
- return (invert ? greyColor80 : greyColor5);
61
- });
62
- exports.StyledOption = styled_components_1.default.button(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n white-space: nowrap;\n border: none;\n cursor: pointer;\n width: 100%;\n text-align: ", ";\n padding: 1rem 1.6rem;\n background-color: transparent;\n color: ", ";\n ", ";\n &:hover {\n background-color: ", ";\n }\n"], ["\n white-space: nowrap;\n border: none;\n cursor: pointer;\n width: 100%;\n text-align: ", ";\n padding: 1rem 1.6rem;\n background-color: transparent;\n color: ", ";\n ", ";\n &:hover {\n background-color: ", ";\n }\n"])), function (_a) {
68
+ return (invert ? greyColor70 : greyColor5);
69
+ }, function (_a) {
63
70
  var align = _a.align;
64
- return (align === "center" ? "center" : "left");
71
+ return align === "center"
72
+ ? (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n left: 50%;\n transform: translateX(-50%);\n "], ["\n left: 50%;\n transform: translateX(-50%);\n "]))) : (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n ", ": 0.65rem;\n "], ["\n ", ": 0.65rem;\n "])), align);
65
73
  }, function (_a) {
74
+ var invert = _a.invert;
75
+ return (invert ? greyColor80 : white);
76
+ });
77
+ exports.StyledOption = styled_components_1.default.button(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n white-space: nowrap;\n border: none;\n cursor: pointer;\n width: 100%;\n text-align: left;\n padding: 0.25rem 1.2rem;\n background-color: transparent;\n color: ", ";\n ", ";\n &:hover {\n background-color: ", ";\n }\n"], ["\n white-space: nowrap;\n border: none;\n cursor: pointer;\n width: 100%;\n text-align: left;\n padding: 0.25rem 1.2rem;\n background-color: transparent;\n color: ", ";\n ", ";\n &:hover {\n background-color: ", ";\n }\n"])), function (_a) {
66
78
  var invert = _a.invert;
67
79
  return (invert ? white : greyColor100);
68
80
  }, (0, mixins_1.transition)("background-color"), function (_a) {
69
81
  var invert = _a.invert;
70
82
  return invert ? greyColor70 : greyColor10;
71
83
  });
72
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
84
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -51,8 +51,10 @@ var ButtonStyledWrapper = function (_a) {
51
51
  var displayText = (link === null || link === void 0 ? void 0 : link.displayText) || children || value;
52
52
  var composition = (icon || iconAfter) && displayText
53
53
  ? "icon+text"
54
- : !displayText && "iconOnly";
55
- var size = composition === 'icon+text'
54
+ : !displayText
55
+ ? "iconOnly"
56
+ : "textOnly";
57
+ var size = ['icon+text', 'textOnly'].indexOf(composition) !== -1
56
58
  ? (S && 'S') || 'M' //icon+text defaults to 'M'
57
59
  : (M && 'M') || 'S'; //iconOnly defaults to 'S'
58
60
  /**
@@ -1,6 +1,13 @@
1
- export function Container({ children, className, style, noPadding }: {
1
+ export function Comp({ children, className, style, noPadding }: {
2
2
  children: any;
3
3
  className: any;
4
4
  style: any;
5
5
  noPadding: any;
6
- }): JSX.Element;
6
+ }, ref: any): JSX.Element;
7
+ export const Container: React.ForwardRefExoticComponent<{
8
+ children: any;
9
+ className: any;
10
+ style: any;
11
+ noPadding: any;
12
+ } & React.RefAttributes<any>>;
13
+ import React from "react";
@@ -10,15 +10,36 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
15
35
  };
16
36
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Container = void 0;
18
- var react_1 = __importDefault(require("react"));
37
+ exports.Container = exports.Comp = void 0;
38
+ var react_1 = __importStar(require("react"));
19
39
  var index_styled_1 = require("./index.styled");
20
- var Container = function (_a) {
40
+ var Comp = function (_a, ref) {
21
41
  var children = _a.children, className = _a.className, style = _a.style, noPadding = _a.noPadding;
22
- return (react_1.default.createElement(index_styled_1.StyledContainer, { className: className || '', style: __assign(__assign({}, (noPadding ? { padding: 0 } : {})), style) }, children));
42
+ return (react_1.default.createElement(index_styled_1.StyledContainer, { ref: ref, className: className || '', style: __assign(__assign({}, (noPadding ? { padding: 0 } : {})), style) }, children));
23
43
  };
24
- exports.Container = Container;
44
+ exports.Comp = Comp;
45
+ exports.Container = (0, react_1.forwardRef)(exports.Comp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.17.7",
3
+ "version": "2.17.10",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",