oolib 2.64.1 → 2.64.3
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/Container/index.d.ts +3 -1
- package/dist/components/Container/index.js +8 -14
- package/dist/components/Container/index.styled.js +33 -5
- package/dist/components/Dropdowns/comps/OptionsShell/styled.js +2 -2
- package/dist/utils/customHooks/useContainerQuery.d.ts +4 -0
- package/dist/utils/customHooks/useContainerQuery.js +33 -0
- package/package.json +2 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export function Comp({ children, className, style }: {
|
|
1
|
+
export function Comp({ children, className, style, enableContainerQuery }: {
|
|
2
2
|
children: any;
|
|
3
3
|
className: any;
|
|
4
4
|
style: any;
|
|
5
|
+
enableContainerQuery: any;
|
|
5
6
|
}, ref: any): React.JSX.Element;
|
|
6
7
|
export const Container: React.ForwardRefExoticComponent<{
|
|
7
8
|
children: any;
|
|
8
9
|
className: any;
|
|
9
10
|
style: any;
|
|
11
|
+
enableContainerQuery: any;
|
|
10
12
|
} & React.RefAttributes<any>>;
|
|
11
13
|
import React from "react";
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,9 +26,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
26
|
exports.Container = exports.Comp = void 0;
|
|
38
27
|
var react_1 = __importStar(require("react"));
|
|
39
28
|
var index_styled_1 = require("./index.styled");
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
var useContainerQuery_1 = require("../../utils/customHooks/useContainerQuery");
|
|
30
|
+
var Comp = function (_a, ref //if a ref is passed from outside, it will override the containerQuery feature
|
|
31
|
+
) {
|
|
32
|
+
var children = _a.children, className = _a.className, style = _a.style, enableContainerQuery = _a.enableContainerQuery;
|
|
33
|
+
var _b = (0, useContainerQuery_1.useContainerQuery)({
|
|
34
|
+
enabled: enableContainerQuery,
|
|
35
|
+
}), selfRef = _b.ref, containerQuery = _b.containerQuery;
|
|
36
|
+
return (react_1.default.createElement(index_styled_1.StyledContainer, { ref: ref || selfRef, className: className || "", style: style, containerQuery: containerQuery }, children));
|
|
43
37
|
};
|
|
44
38
|
exports.Comp = Comp;
|
|
45
39
|
exports.Container = (0, react_1.forwardRef)(exports.Comp);
|
|
@@ -3,12 +3,40 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
|
-
var
|
|
7
|
-
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
8
28
|
};
|
|
9
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
30
|
exports.StyledContainer = void 0;
|
|
11
|
-
var styled_components_1 =
|
|
31
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
12
32
|
var mixins_1 = require("../../themes/mixins");
|
|
13
|
-
exports.StyledContainer = styled_components_1.default.div(
|
|
14
|
-
var
|
|
33
|
+
exports.StyledContainer = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding: 0 2rem;\n ", "\n"], ["\n padding: 0 2rem;\n ", "\n"])), function (_a) {
|
|
34
|
+
var containerQuery = _a.containerQuery;
|
|
35
|
+
if (containerQuery) {
|
|
36
|
+
return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), containerQuery("sm", (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["padding: 0 6rem;"], ["padding: 0 6rem;"])))));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", " {\n padding: 0 6rem;\n }\n "], ["\n ", " {\n padding: 0 6rem;\n }\n "])), (0, mixins_1.mediaQuery)("sm"));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -13,12 +13,12 @@ var themes_1 = require("../../../../themes");
|
|
|
13
13
|
var mixins_1 = require("../../../../themes/mixins");
|
|
14
14
|
var globalVariables_1 = require("../../../../globalStyles/globalVariables");
|
|
15
15
|
/** for lightbox shell */
|
|
16
|
-
exports.StyledOptionsAnimateWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", ";\n width: ", ";\n overflow: hidden;\n ", ";\n ", ";\n border-width: ", "; //hack, otherwsie this shit line shows when options are closed\n"], ["\n height: ", ";\n width: ", ";\n overflow: hidden;\n ", ";\n ", ";\n border-width: ", "; //hack, otherwsie this shit line shows when options are closed\n"])), function (_a) {
|
|
16
|
+
exports.StyledOptionsAnimateWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", ";\n /**\n 'else 100%' is very important. \n what this does is, on first render, it allows the optionsWrapper within to take whatever width \n its supposed to i.e max-content / 100% width of select / 36rem.\n Then on the next render (after the ref has already been attached to optionsWrapper), the proper width\n gets calculated and passed to this component.\n\n Without this 100%, this will not work > scenarios where there is enough space for the dropdown to \n stretch to the width of the select OR 36rem. Instead it will always stick to its min-width which is \n max-content\n */\n width: ", ";\n overflow: hidden;\n ", ";\n ", ";\n border-width: ", "; //hack, otherwsie this shit line shows when options are closed\n"], ["\n height: ", ";\n /**\n 'else 100%' is very important. \n what this does is, on first render, it allows the optionsWrapper within to take whatever width \n its supposed to i.e max-content / 100% width of select / 36rem.\n Then on the next render (after the ref has already been attached to optionsWrapper), the proper width\n gets calculated and passed to this component.\n\n Without this 100%, this will not work > scenarios where there is enough space for the dropdown to \n stretch to the width of the select OR 36rem. Instead it will always stick to its min-width which is \n max-content\n */\n width: ", ";\n overflow: hidden;\n ", ";\n ", ";\n border-width: ", "; //hack, otherwsie this shit line shows when options are closed\n"])), function (_a) {
|
|
17
17
|
var isOpen = _a.isOpen, openHeight = _a.openHeight;
|
|
18
18
|
return isOpen ? (openHeight ? openHeight + 'px' : 'auto') : 0;
|
|
19
19
|
}, function (_a) {
|
|
20
20
|
var width = _a.width;
|
|
21
|
-
return width + 'px';
|
|
21
|
+
return width ? width + 'px' : '100%';
|
|
22
22
|
}, (0, mixins_1.transition)('height', 'border-width'), globalVariables_1.globalLightboxStyle, function (_a) {
|
|
23
23
|
var isOpen = _a.isOpen;
|
|
24
24
|
return isOpen ? '1px' : 0;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useContainerQuery = void 0;
|
|
7
|
+
var resize_observer_1 = __importDefault(require("@react-hook/resize-observer"));
|
|
8
|
+
var mixins_1 = require("../../themes/mixins");
|
|
9
|
+
var react_1 = require("react");
|
|
10
|
+
var useContainerQuery = function (options) {
|
|
11
|
+
if (options === void 0) { options = {}; }
|
|
12
|
+
var enabled = options.enabled;
|
|
13
|
+
var ref = (0, react_1.useRef)(null);
|
|
14
|
+
var _a = (0, react_1.useState)(undefined), containerWidth = _a[0], setContainerWidth = _a[1];
|
|
15
|
+
(0, resize_observer_1.default)(ref, function (entry) {
|
|
16
|
+
var width = entry.borderBoxSize[0].inlineSize;
|
|
17
|
+
setContainerWidth(width);
|
|
18
|
+
});
|
|
19
|
+
//if container queries are written for multiple breakpoints
|
|
20
|
+
//then they must be written in the order of small to big.
|
|
21
|
+
//so for example, the 'sm' query should be written before the 'md'
|
|
22
|
+
//query and so on. Else bugs will happen.
|
|
23
|
+
var containerQuery = function (size, css) {
|
|
24
|
+
var bp = (0, mixins_1.getBreakPoint)(size);
|
|
25
|
+
if (containerWidth >= bp)
|
|
26
|
+
return css;
|
|
27
|
+
};
|
|
28
|
+
return ({
|
|
29
|
+
ref: enabled && ref,
|
|
30
|
+
containerQuery: enabled && containerQuery
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.useContainerQuery = useContainerQuery;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oolib",
|
|
3
|
-
"version": "2.64.
|
|
3
|
+
"version": "2.64.3",
|
|
4
4
|
"description": " OKE Component Library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
+
"@react-hook/resize-observer": "^1.2.6",
|
|
87
88
|
"babel-polyfill": "^6.26.0",
|
|
88
89
|
"d3": "^7.8.5",
|
|
89
90
|
"d3-collection": "^1.0.7",
|