oolib 2.190.4 → 2.192.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.
Files changed (65) hide show
  1. package/dist/components/Divider/index.d.ts +2 -1
  2. package/dist/components/Divider/index.js +2 -2
  3. package/dist/components/Dropdowns/comps/OptionsMulti/index.js +1 -0
  4. package/dist/components/ImageInput/comps/ImageEditor/index.js +1 -1
  5. package/dist/stories/v2/components/{Dropdowns.stories.d.ts → Dropdown/Dropdowns.stories.d.ts} +46 -18
  6. package/dist/stories/v2/components/Dropdown/Dropdowns.stories.js +204 -0
  7. package/dist/stories/v2/components/Dropdown/dropdownOptions.d.ts +15 -0
  8. package/dist/stories/v2/components/Dropdown/dropdownOptions.js +156 -0
  9. package/dist/stories/v2/components/List.stories.d.ts +96 -0
  10. package/dist/stories/v2/components/List.stories.js +219 -0
  11. package/dist/utils/useStyleUpdateAfterToggleTransition.js +6 -2
  12. package/dist/v2/components/Dropdowns/DropdownMulti/index.d.ts +3 -2
  13. package/dist/v2/components/Dropdowns/DropdownMulti/index.js +36 -19
  14. package/dist/v2/components/Dropdowns/DropdownSingle/index.d.ts +3 -2
  15. package/dist/v2/components/Dropdowns/DropdownSingle/index.js +12 -13
  16. package/dist/v2/components/Dropdowns/comps/Caret/index.d.ts +1 -2
  17. package/dist/v2/components/Dropdowns/comps/Caret/index.js +15 -5
  18. package/dist/v2/components/Dropdowns/comps/DisplayCompSingle/index.d.ts +1 -2
  19. package/dist/v2/components/Dropdowns/comps/DisplayCompSingle/index.js +8 -8
  20. package/dist/v2/components/Dropdowns/comps/NoOptionResultsComp/index.js +4 -4
  21. package/dist/v2/components/Dropdowns/comps/OptionsMulti/index.d.ts +2 -2
  22. package/dist/v2/components/Dropdowns/comps/OptionsMulti/index.js +12 -70
  23. package/dist/v2/components/Dropdowns/comps/OptionsShell/comps/OptionsAnimateWrapper/index.d.ts +1 -2
  24. package/dist/v2/components/Dropdowns/comps/OptionsShell/comps/OptionsAnimateWrapper/index.js +3 -3
  25. package/dist/v2/components/Dropdowns/comps/OptionsShell/comps/OptionsAnimateWrapper/styled.js +5 -2
  26. package/dist/v2/components/Dropdowns/comps/OptionsShell/index.js +12 -26
  27. package/dist/v2/components/Dropdowns/comps/OptionsShell/styled.js +8 -8
  28. package/dist/v2/components/Dropdowns/comps/OptionsSingle/index.d.ts +3 -3
  29. package/dist/v2/components/Dropdowns/comps/OptionsSingle/index.js +9 -33
  30. package/dist/v2/components/Dropdowns/comps/OptionsSingle/styled.js +13 -12
  31. package/dist/v2/components/Dropdowns/comps/SearchBar/index.d.ts +8 -0
  32. package/dist/v2/components/Dropdowns/comps/SearchBar/index.js +21 -0
  33. package/dist/v2/components/Dropdowns/comps/SelectDropdown/index.d.ts +2 -2
  34. package/dist/v2/components/Dropdowns/comps/SelectDropdown/index.js +13 -15
  35. package/dist/v2/components/Dropdowns/comps/SelectDropdown/styled.js +10 -9
  36. package/dist/v2/components/Dropdowns/comps/SelectTagsInput/index.d.ts +1 -2
  37. package/dist/v2/components/Dropdowns/comps/SelectTagsInput/index.js +6 -9
  38. package/dist/v2/components/Dropdowns/comps/SelectTagsInput/styled.js +3 -6
  39. package/dist/v2/components/Dropdowns/styled.js +1 -1
  40. package/dist/v2/components/Dropdowns/utils/genColor.js +2 -2
  41. package/dist/v2/components/Dropdowns/utils/genIcon.d.ts +3 -3
  42. package/dist/v2/components/Dropdowns/utils/genIcon.js +4 -2
  43. package/dist/v2/components/Dropdowns/utils/genProfileImg.d.ts +1 -2
  44. package/dist/v2/components/Dropdowns/utils/genProfileImg.js +2 -2
  45. package/dist/v2/components/Dropdowns/utils/genTagComp.js +3 -3
  46. package/dist/v2/components/Dropdowns/utils/getValue.d.ts +1 -0
  47. package/dist/v2/components/Dropdowns/utils/getValue.js +64 -10
  48. package/dist/v2/components/Dropdowns/utils/keywordSearchOptions.js +53 -9
  49. package/dist/v2/components/List/comps/ListGroup.d.ts +20 -0
  50. package/dist/v2/components/List/comps/ListGroup.js +39 -0
  51. package/dist/v2/components/List/comps/ListItem.d.ts +15 -0
  52. package/dist/v2/components/List/comps/ListItem.js +59 -0
  53. package/dist/v2/components/List/comps/styled.d.ts +1 -0
  54. package/dist/v2/components/List/comps/styled.js +71 -0
  55. package/dist/v2/components/List/index.d.ts +27 -0
  56. package/dist/v2/components/List/index.js +87 -0
  57. package/dist/v2/components/dataviz/BarGraphCollection/index.d.ts +2 -1
  58. package/dist/v2/components/dataviz/BarGraphCollection/index.js +17 -2
  59. package/dist/v2/components/dataviz/BarGraphCollection/utils/useGetDimensions.d.ts +1 -1
  60. package/dist/v2/components/dataviz/BarGraphCollection/utils/useGetDimensions.js +27 -3
  61. package/dist/v2/themes/globalStyles.js +2 -2
  62. package/package.json +1 -1
  63. package/dist/stories/v2/components/Dropdowns.stories.js +0 -289
  64. package/dist/v2/components/Dropdowns/comps/OptionContent/index.d.ts +0 -8
  65. package/dist/v2/components/Dropdowns/comps/OptionContent/index.js +0 -35
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
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 () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.List = exports.StyledListWrapper = void 0;
41
+ var react_1 = __importStar(require("react"));
42
+ var styled_components_1 = __importStar(require("styled-components"));
43
+ var NoOptionResultsComp_1 = require("../Dropdowns/comps/NoOptionResultsComp");
44
+ var ListItem_1 = require("./comps/ListItem");
45
+ var SearchBar_1 = require("../Dropdowns/comps/SearchBar");
46
+ var ListGroup_1 = require("./comps/ListGroup");
47
+ var themes_1 = require("../../themes");
48
+ exports.StyledListWrapper = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: white;\n border-radius: 0.6rem;\n padding: 0.4rem;\n padding-top: ", ";\n\n ", "\n\n ", "\n"], ["\n background: white;\n border-radius: 0.6rem;\n padding: 0.4rem;\n padding-top: ", ";\n\n ", "\n\n ", "\n"])), function (_a) {
49
+ var isSearchable = _a.isSearchable;
50
+ return isSearchable ? "0rem" : "0.4rem";
51
+ }, function (_a) {
52
+ var disableShadow = _a.disableShadow;
53
+ return !disableShadow && (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.15);\n "], ["\n box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.15);\n "])));
54
+ }, function (_a) {
55
+ var enableBorder = _a.enableBorder;
56
+ return enableBorder && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border: 1px solid ", ";\n "], ["\n border: 1px solid ", ";\n "])), themes_1.colors.grey10);
57
+ });
58
+ var List = function (_a) {
59
+ // const theme = useTheme();
60
+ var _b = _a.options, options = _b === void 0 ? [] : _b, value = _a.value, focussedOp = _a.focussedOp, scrollFocussedOpIntoView = _a.scrollFocussedOpIntoView, handleSelect = _a.handleSelect, optionsClassName = _a.optionsClassName, invert = _a.invert, S = _a.S, observerRef = _a.observerRef, _c = _a.isMulti, isMulti = _c === void 0 ? false : _c, isTagsStyle = _a.isTagsStyle, setFocusSelectTagsInput = _a.setFocusSelectTagsInput, _d = _a.grouped, grouped = _d === void 0 ? false : _d, disableShadow = _a.disableShadow, isSearchable = _a.isSearchable, searchbarPlaceholder = _a.searchbarPlaceholder, searchBarFocus = _a.searchBarFocus, searchString = _a.searchString, setSearchString = _a.setSearchString, setSearchBarFocus = _a.setSearchBarFocus, children = _a.children, enableBorder = _a.enableBorder, style = _a.style;
61
+ var renderListItems = function () {
62
+ if (options.length === 0) {
63
+ return react_1.default.createElement(NoOptionResultsComp_1.NoOptionResultsComp, { S: S });
64
+ }
65
+ if (grouped) {
66
+ return (react_1.default.createElement(react_1.Fragment, null, options.map(function (group, index) { return (react_1.default.createElement(ListGroup_1.ListGroup, { key: "group-".concat(index), group: group, index: index, value: value, focussedOp: focussedOp, scrollFocussedOpIntoView: scrollFocussedOpIntoView, handleSelect: handleSelect, optionsClassName: optionsClassName, invert: invert, S: S, observerRef: observerRef, isMulti: isMulti, isTagsStyle: isTagsStyle, setFocusSelectTagsInput: setFocusSelectTagsInput, setSearchString: setSearchString, setSearchBarFocus: setSearchBarFocus, disableShadow: disableShadow })); })));
67
+ }
68
+ return options.map(function (option, index) { return (react_1.default.createElement(ListItem_1.ListItem, { key: option.value, option: option, isSelected: (!option.loading && (value === null || value === void 0 ? void 0 : value.value) === option.value), isFocussed: focussedOp === index, index: index, scrollFocussedOpIntoView: scrollFocussedOpIntoView, handleSelect: function () {
69
+ if (!option.loading) {
70
+ handleSelect(option);
71
+ if (setSearchString)
72
+ setSearchString("");
73
+ if (setSearchBarFocus)
74
+ setSearchBarFocus(true);
75
+ if (setFocusSelectTagsInput)
76
+ setFocusSelectTagsInput(true);
77
+ }
78
+ }, optionsClassName: optionsClassName, invert: invert, S: S, observerRef: options.length === index + 1 ? observerRef : null, isMulti: isMulti, isTagsStyle: isTagsStyle, value: value })); });
79
+ };
80
+ return (react_1.default.createElement(exports.StyledListWrapper, { disableShadow: disableShadow, style: style, isSearchable: isSearchable, enableBorder: enableBorder },
81
+ isSearchable && (react_1.default.createElement(SearchBar_1.SearchBar, { searchbarPlaceholder: searchbarPlaceholder, searchBarFocus: searchBarFocus, searchString: searchString, setSearchString: setSearchString, setSearchBarFocus: setSearchBarFocus })),
82
+ children,
83
+ " ",
84
+ renderListItems()));
85
+ };
86
+ exports.List = List;
87
+ var templateObject_1, templateObject_2, templateObject_3;
@@ -1,7 +1,7 @@
1
1
  export const BAR_GRAPH_HEIGHT: 250;
2
2
  export const DEFAULT_SINGLE_BAR_WIDTH: 24;
3
3
  export const BAR_GAP: 0.3;
4
- export function BarGraphCollection({ data: originalData, valuePath, labelPath, tooltipLabelsMapping, onClick, showCount, showPercent, groupBy, }: {
4
+ export function BarGraphCollection({ data: originalData, valuePath, labelPath, tooltipLabelsMapping, onClick, showCount, showPercent, groupBy, totalDataCount, }: {
5
5
  data: any;
6
6
  valuePath: any;
7
7
  labelPath?: string;
@@ -10,6 +10,7 @@ export function BarGraphCollection({ data: originalData, valuePath, labelPath, t
10
10
  showCount?: boolean;
11
11
  showPercent?: boolean;
12
12
  groupBy: any;
13
+ totalDataCount: any;
13
14
  }): React.JSX.Element;
14
15
  export function BarGraph({ tagCategory, index1, showCount, showPercent, onClick }: {
15
16
  tagCategory: any;
@@ -50,13 +50,15 @@ exports.BAR_GRAPH_HEIGHT = 250;
50
50
  exports.DEFAULT_SINGLE_BAR_WIDTH = 24;
51
51
  exports.BAR_GAP = 0.3;
52
52
  var BarGraphCollection = function (_a) {
53
- var originalData = _a.data, valuePath = _a.valuePath, _b = _a.labelPath, labelPath = _b === void 0 ? "display" : _b, _c = _a.tooltipLabelsMapping, tooltipLabelsMapping = _c === void 0 ? {} : _c, onClick = _a.onClick, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, groupBy = _a.groupBy;
53
+ var originalData = _a.data, valuePath = _a.valuePath, _b = _a.labelPath, labelPath = _b === void 0 ? "display" : _b, _c = _a.tooltipLabelsMapping, tooltipLabelsMapping = _c === void 0 ? {} : _c, onClick = _a.onClick, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, groupBy = _a.groupBy, totalDataCount = _a.totalDataCount;
54
54
  var containerRef = (0, react_1.useRef)();
55
55
  var _f = (0, react_1.useState)(0), containerWidth = _f[0], setContainerWidth = _f[1];
56
+ var highestCount = originalData === null || originalData === void 0 ? void 0 : originalData.reduce(function (highest, item) { return item.value > highest ? item.value : highest; }, 0);
56
57
  var transformedData = (0, react_1.useMemo)(function () {
57
58
  return (0, usePrepareData_1.usePrepareData)({ data: originalData, valuePath: valuePath, labelPath: labelPath, tooltipLabelsMapping: tooltipLabelsMapping, groupBy: groupBy });
58
59
  }, [originalData, valuePath, labelPath, tooltipLabelsMapping, groupBy]);
59
- var data = (0, useGetDimensions_1.useGetDimensions)(transformedData, exports.BAR_GRAPH_HEIGHT, containerWidth);
60
+ var data = (0, useGetDimensions_1.useGetDimensions)(transformedData, exports.BAR_GRAPH_HEIGHT, containerWidth, totalDataCount, highestCount);
61
+ // console.log({ total: calculateTotalPercentage(data) })
60
62
  (0, react_1.useEffect)(function () {
61
63
  var handleResize = function () {
62
64
  var _a, _b;
@@ -157,3 +159,16 @@ var BarGraph = function (_a) {
157
159
  })));
158
160
  };
159
161
  exports.BarGraph = BarGraph;
162
+ // function calculateTotalPercentage(data) {
163
+ // let totalPercentage = 0;
164
+ // // Iterate through each category
165
+ // data.forEach(category => {
166
+ // // Sum all percentages within tagSpecificCount
167
+ // if (category.tagSpecificCount && Array.isArray(category.tagSpecificCount)) {
168
+ // category.tagSpecificCount.forEach(tag => {
169
+ // totalPercentage += tag.percentage || 0;
170
+ // });
171
+ // }
172
+ // });
173
+ // return totalPercentage;
174
+ // }
@@ -1 +1 @@
1
- export function useGetDimensions(data: any, maxHeight: any, containerWidth: any): any;
1
+ export function useGetDimensions(data: any, maxHeight: any, containerWidth: any, totalDataCount: any, highestCount: any): any;
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.useGetDimensions = void 0;
15
15
  var __1 = require("..");
16
16
  var styled_1 = require("../styled");
17
- var useGetDimensions = function (data, maxHeight, containerWidth) {
17
+ var useGetDimensions = function (data, maxHeight, containerWidth, totalDataCount, highestCount) {
18
18
  var singleBarWidth;
19
19
  var totalBars = data === null || data === void 0 ? void 0 : data.reduce(function (total, tagCategory) {
20
20
  var _a;
@@ -25,6 +25,26 @@ var useGetDimensions = function (data, maxHeight, containerWidth) {
25
25
  // const defaultWidthForBars = (totalBars - 1) * DEFAULT_SINGLE_BAR_WIDTH - (CONTAINER_PADDING * 2);
26
26
  var dynamicBarWidth = availableWidthForBars / totalBars;
27
27
  singleBarWidth = Math.max(dynamicBarWidth, __1.DEFAULT_SINGLE_BAR_WIDTH);
28
+ // Calculate the ceiling value for the highest count
29
+ var getCeilingValue = function (num) {
30
+ if (num === 0)
31
+ return 10;
32
+ // Find the power of 10 (magnitude)
33
+ var magnitude = Math.pow(10, Math.floor(Math.log10(num)));
34
+ // Round up to the nearest "nice" number
35
+ var normalized = num / magnitude; // This gives us a number between 1-10
36
+ var multiplier;
37
+ if (normalized <= 1)
38
+ multiplier = 1;
39
+ else if (normalized <= 2)
40
+ multiplier = 2;
41
+ else if (normalized <= 5)
42
+ multiplier = 5;
43
+ else
44
+ multiplier = 10;
45
+ return multiplier * magnitude;
46
+ };
47
+ var ceilingValue = getCeilingValue(highestCount);
28
48
  return data === null || data === void 0 ? void 0 : data.map(function (category) {
29
49
  // total count for this category
30
50
  var total = category.tagSpecificCount.reduce(function (sum, tag) { return sum + tag.count; }, 0);
@@ -33,8 +53,12 @@ var useGetDimensions = function (data, maxHeight, containerWidth) {
33
53
  var categoryTotalWidth = (barsInCategory * singleBarWidth) + (gapsInCategory * Math.floor(__1.BAR_GAP * 10));
34
54
  // percentage to each tag
35
55
  return __assign(__assign({}, category), { width: categoryTotalWidth, tagSpecificCount: category.tagSpecificCount.map(function (tag) {
36
- var percentage = Number((tag.count / total * 100).toFixed(1));
37
- return __assign({ percentage: percentage, height: Math.round((percentage / 100) * maxHeight), width: singleBarWidth }, tag);
56
+ // Original percentage relative to total dataset
57
+ var percentage = Number((tag.count / (totalDataCount || total) * 100).toFixed(1));
58
+ // New height calculation relative to highest count and ceiling
59
+ // This creates a "zoomed in" effect where bars are more visible
60
+ var relativeHeight = Math.round((tag.count / ceilingValue) * maxHeight);
61
+ return __assign({ percentage: percentage, height: relativeHeight, width: singleBarWidth }, tag);
38
62
  }) });
39
63
  });
40
64
  };
@@ -11,8 +11,8 @@ exports.globalInputElemPadding_v2 = (0, styled_components_1.css)(templateObject_
11
11
  var size = _a.size;
12
12
  return size === "S" ? '0 10px' : '0 12px';
13
13
  });
14
- exports.globalInputElemHover_v2 = (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:hover {\n &::before{\n border: 1.5px solid ", ";\n /* box-shadow: 0 4px 10px #00000012; */\n }\n }\n"], ["\n &:hover {\n &::before{\n border: 1.5px solid ", ";\n /* box-shadow: 0 4px 10px #00000012; */\n }\n }\n"])), colors_1.colors.grey30);
15
- exports.globalInputElemFocused_v2 = (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n&:focus-within {\n &::before{\n border: 1.5px solid ", ";\n box-shadow: 0 4px 10px #00000012;\n }\n }\n"], ["\n&:focus-within {\n &::before{\n border: 1.5px solid ", ";\n box-shadow: 0 4px 10px #00000012;\n }\n }\n"])), colors_1.colors.grey80);
14
+ exports.globalInputElemHover_v2 = (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:hover {\n &::before{\n border: 1px solid ", ";\n /* box-shadow: 0 4px 10px #00000012; */\n }\n }\n"], ["\n &:hover {\n &::before{\n border: 1px solid ", ";\n /* box-shadow: 0 4px 10px #00000012; */\n }\n }\n"])), colors_1.colors.grey30);
15
+ exports.globalInputElemFocused_v2 = (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n&:focus-within {\n &::before{\n border: 1px solid ", ";\n box-shadow: 0 4px 10px #00000012;\n }\n }\n"], ["\n&:focus-within {\n &::before{\n border: 1px solid ", ";\n box-shadow: 0 4px 10px #00000012;\n }\n }\n"])), colors_1.colors.grey80);
16
16
  exports.globalInputElemBaseBorderStyling_v2 = (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n&::before {\n content: \"\";\n background-color: ", ";\n position: absolute;\n z-index: 0;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n border: 1px solid ", ";\n border-radius: 6px;\n }\n"], ["\n&::before {\n content: \"\";\n background-color: ", ";\n position: absolute;\n z-index: 0;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n border: 1px solid ", ";\n border-radius: 6px;\n }\n"])), colors_1.colors.white, colors_1.colors.grey10);
17
17
  exports.globalInputElemDisabledStyling_v2 = (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n", ";\n"], ["\n", ";\n"])), function (_a) {
18
18
  var disabled = _a.disabled;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.190.4",
3
+ "version": "2.192.0",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,289 +0,0 @@
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
- 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 () {
30
- var ownKeys = function(o) {
31
- ownKeys = Object.getOwnPropertyNames || function (o) {
32
- var ar = [];
33
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
- return ar;
35
- };
36
- return ownKeys(o);
37
- };
38
- return function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
45
- })();
46
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
47
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
48
- if (ar || !(i in from)) {
49
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
50
- ar[i] = from[i];
51
- }
52
- }
53
- return to.concat(ar || Array.prototype.slice.call(from));
54
- };
55
- Object.defineProperty(exports, "__esModule", { value: true });
56
- exports.Dropdowns = void 0;
57
- var react_1 = __importStar(require("react"));
58
- var Container_1 = require("../../../components/Container");
59
- var Paddings_1 = require("../../../components/Paddings");
60
- var themes_1 = require("../../../themes");
61
- var icons_1 = require("../../../icons");
62
- var DropdownMulti_1 = require("../../../v2/components/Dropdowns/DropdownMulti");
63
- var DropdownSingle_1 = require("../../../v2/components/Dropdowns/DropdownSingle");
64
- // import { faker } from '@faker-js/faker';
65
- // const generateRandomCountry = () => ({
66
- // display: faker.address.country(),
67
- // value: faker.address.countryCode().toLowerCase(),
68
- // });
69
- // const generateDropdownOptions = (length) => {
70
- // const dropdownOptions = [];
71
- // for (let i = 0; i < length; i++) {
72
- // dropdownOptions.push(generateRandomCountry());
73
- // }
74
- // return dropdownOptions;
75
- // };
76
- // const dropdownOptions2 = generateDropdownOptions(200);
77
- var availableIcons = __spreadArray([undefined], Object.keys(icons_1.icons).sort(), true);
78
- exports.default = {
79
- title: "Oolib V 2.0/Components/Dropdowns",
80
- argTypes: {
81
- // label: {
82
- // name: "Label",
83
- // },
84
- // sublabel: {
85
- // name: "Sub Label",
86
- // },
87
- placeholder: {
88
- name: "Placeholder Text",
89
- },
90
- optionIcon: {
91
- options: availableIcons,
92
- control: { type: "select" },
93
- },
94
- selection: {
95
- options: ["single", "multi"],
96
- control: { type: "inline-radio" },
97
- },
98
- size: {
99
- name: "Size",
100
- control: { type: "inline-radio" },
101
- options: ["Small", "Medium"],
102
- mapping: {
103
- Small: "S",
104
- Medium: "M",
105
- },
106
- },
107
- selection: {
108
- name: "Selection Type",
109
- options: ["single", "multi"],
110
- control: { type: "select" },
111
- },
112
- isSearchable: {
113
- name: "Searchable",
114
- },
115
- showIconInSelectArea: {
116
- name: "Show Icon in Select Area",
117
- },
118
- optionImage: {
119
- name: "Option Image",
120
- },
121
- optionDescription: {
122
- name: "Option Description",
123
- },
124
- colors: {
125
- name: 'Show Colors'
126
- },
127
- disabled: {
128
- name: "Disabled",
129
- },
130
- readOnly: {
131
- name: "Read Only",
132
- },
133
- invert: {
134
- name: "Invert",
135
- },
136
- showColorInSelectArea: {
137
- name: "Show Color in Select Area"
138
- },
139
- alignDropdown: {
140
- name: "Align Dropdown",
141
- options: ["left", "right"],
142
- control: { type: "select" }
143
- },
144
- },
145
- args: {
146
- // label: "This is a label",
147
- // sublabel: "This is a sub label",
148
- placeholder: "",
149
- size: "Medium",
150
- selection: "single",
151
- isSearchable: false,
152
- optionDescription: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
153
- optionImage: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSrVSkmNOQ6abMCc5e6R2r7VwRZDkBHFTyzAg&usqp=CAU",
154
- optionIcon: undefined,
155
- showIconInSelectArea: false,
156
- colors: false,
157
- showColorInSelectArea: false,
158
- disabled: false,
159
- readOnly: false,
160
- invert: false,
161
- popOutOfOverflowHiddenParent: false,
162
- alignDropdown: "left",
163
- }
164
- };
165
- var dropdownOptions = [
166
- {
167
- display: "Option with a slightly longer name",
168
- value: "india",
169
- color: themes_1.colors.lightRed,
170
- // image: "xyz",
171
- // icon: "Trash",
172
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
173
- },
174
- {
175
- display: "Sri Lanka",
176
- value: "sriLanka",
177
- color: themes_1.colors.invertRed,
178
- // image: "xyz",
179
- // icon: "Trash",
180
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
181
- },
182
- {
183
- display: "Japan",
184
- value: "japan",
185
- color: themes_1.colors.lightBlue
186
- // image: "xyz",
187
- // icon: "Trash",
188
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
189
- },
190
- {
191
- display: "Germany",
192
- value: "germany",
193
- color: themes_1.colors.primaryColor100
194
- // image: "xyz",
195
- // icon: "Trash",
196
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
197
- },
198
- {
199
- display: "USA",
200
- value: "usa",
201
- color: themes_1.colors.greyColor100
202
- // image: "xyz",
203
- // icon: "Trash",
204
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
205
- },
206
- {
207
- display: "Columbia",
208
- value: "columbia",
209
- color: themes_1.colors.lightRed,
210
- // image: "xyz",
211
- // icon: "Trash",
212
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
213
- },
214
- {
215
- display: "Brazil",
216
- value: "brazil",
217
- color: themes_1.colors.invertRed,
218
- // image: "xyz",
219
- // icon: "Trash",
220
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
221
- },
222
- {
223
- display: "Australia",
224
- value: "australia",
225
- color: themes_1.colors.lightBlue
226
- // image: "xyz",
227
- // icon: "Trash",
228
- // desc: "This is a story about schnil-tu, a.k.a tubito senpai. Tubito senpai loves to say bhai-god. Lol.",
229
- },
230
- ];
231
- var Dropdowns = function (args) {
232
- var _a = (0, react_1.useState)({
233
- single: undefined,
234
- multi: undefined,
235
- }), val = _a[0], setVal = _a[1];
236
- var _b = (0, react_1.useState)([]), options = _b[0], setOptions = _b[1];
237
- (0, react_1.useEffect)(function () {
238
- var delayOptions = setTimeout(function () {
239
- var newOptions = dropdownOptions.map(function (op) { return (__assign(__assign({}, op), { desc: args.optionDescription, icon: !args.optionImage && args.optionIcon, image: args.optionImage && [{ publicUrl: args.optionImage }], color: args.colors && op.color })); });
240
- setOptions(newOptions);
241
- }, 2000);
242
- // Cleanup the timeout on component unmount
243
- return function () { return clearTimeout(delayOptions); };
244
- }, [args.optionDescription, args.optionImage, args.optionIcon, args.colors]);
245
- var Comp = args.selection === "single" ? DropdownSingle_1.DropdownSingle : DropdownMulti_1.DropdownMulti;
246
- return (react_1.default.createElement("div", { style: { background: args.invert && themes_1.colors.greyColor100 } },
247
- react_1.default.createElement(Container_1.Container, null,
248
- react_1.default.createElement(Paddings_1.PaddingTopBottom40, null,
249
- react_1.default.createElement(Comp, __assign({ key: args.selection }, args, { S: args.size == "S", options: dropdownOptions.map(function (op) { return (__assign(__assign({}, op), { desc: args.optionDescription, icon: !args.optionImage && args.optionIcon, image: args.optionImage && [{ publicUrl: args.optionImage }], color: args.colors && op.color })); }), value: val[args.selection], onChange: function (k, v) {
250
- return setVal(function (prev) {
251
- var _a;
252
- return (__assign(__assign({}, prev), (_a = {}, _a[args.selection] = v, _a)));
253
- });
254
- }, selectConfig: args.showIconInSelectArea ? ["display", "icon"] : args.showColorInSelectArea ? ["display", "color"] : ["display"], label: "Dropdown Component", sublabel: "Select single or multiple options in dropdown based on Selection Type", popOutOfOverflowHiddenParent: args.popOutOfOverflowHiddenParent }))),
255
- react_1.default.createElement("div", { style: { height: '1000px', background: 'red' } }))));
256
- };
257
- exports.Dropdowns = Dropdowns;
258
- // export const Button_Primary = (args) => (
259
- // <GenButtonStory args={args} Comp={ButtonPrimary} />
260
- // )
261
- // Button_Primary.parameters = { controls: { exclude: ['variant', 'color'] } }
262
- // export const Button_Secondary = (args) => (
263
- // <GenButtonStory args={args} Comp={ButtonSecondary} />
264
- // )
265
- // Button_Secondary.parameters = { controls: { exclude: ['variant', 'color'] } }
266
- // Button_Secondary.args = {
267
- // active: false,
268
- // }
269
- // export const Button_Ghost = (args) => (
270
- // <GenButtonStory args={args} Comp={ButtonGhost} />
271
- // )
272
- // Button_Ghost.args = {
273
- // active: false,
274
- // }
275
- // Button_Ghost.parameters = { controls: { exclude: ['variant'] } }
276
- // export const Button_Custom = (args) => (
277
- // <GenButtonStory args={args} Comp={ButtonCustom} />
278
- // )
279
- // Button_Custom.parameters = { controls: { exclude: ['variant', 'color'] } }
280
- // export const Google_Login = (args) => (
281
- // <GenButtonStory args={args} Comp={GoogleLogin} />
282
- // )
283
- // Google_Login.parameters = {
284
- // controls: { exclude: ['variant', 'color', 'iconOnly', 'icon + text'] },
285
- // }
286
- // export const Upload_Button = (args) => (
287
- // <GenButtonStory args={{ ...args, children: 'Upload' }} Comp={UploadButton} />
288
- // )
289
- // Upload_Button.parameters = { controls: { exclude: ['color'] } }
@@ -1,8 +0,0 @@
1
- export function OptionContent({ option, optionsClassName, invert, S, observerRef }: {
2
- option: any;
3
- optionsClassName: any;
4
- invert: any;
5
- S: any;
6
- observerRef: any;
7
- }): React.JSX.Element;
8
- import React from "react";
@@ -1,35 +0,0 @@
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.OptionContent = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var genProfileImg_1 = require("../../utils/genProfileImg");
9
- var genIcon_1 = require("../../utils/genIcon");
10
- var styled_components_1 = require("styled-components");
11
- var genColor_1 = require("../../utils/genColor");
12
- var getText_1 = require("../../../../../utils/getText");
13
- var Typo_1 = require("../../../../../components/Typo");
14
- var Typo2_1 = require("../../../Typo2");
15
- var OptionContent = function (_a) {
16
- var option = _a.option, optionsClassName = _a.optionsClassName, invert = _a.invert, S = _a.S, observerRef = _a.observerRef;
17
- var theme = (0, styled_components_1.useTheme)();
18
- var TypoComp = S ? Typo_1.SANS_2 : Typo2_1.UI_BODY_SEMIBOLD_SM_DF;
19
- var image = option.image, display = option.display, icon = option.icon, desc = option.desc, color = option.color;
20
- return (react_1.default.createElement("div", { ref: observerRef, style: {
21
- display: "flex",
22
- alignItems: "flex-start",
23
- gap: "0.6rem",
24
- maxWidth: "36rem",
25
- } },
26
- (image || icon || color) &&
27
- react_1.default.createElement("div", { style: { marginTop: desc && '0.2rem', display: 'flex', alignContent: 'center' } },
28
- image && (0, genProfileImg_1.genProfileImg)({ image: image, display: display, invert: invert, theme: theme }),
29
- icon && (0, genIcon_1.genIcon)({ icon: icon, invert: invert, S: S, className: "OKE-Dropdown__optionIcon" }),
30
- color && (0, genColor_1.genColor)({ color: color })),
31
- react_1.default.createElement("div", null,
32
- react_1.default.createElement(TypoComp, { invert: invert, semibold: desc ? true : false, className: "OKE-Dropdown__optionText ".concat(optionsClassName || "") }, (0, getText_1.getText)(display)),
33
- desc && (react_1.default.createElement(TypoComp, { invert: invert, className: "OKE-Dropdown__optionDesc" }, (0, getText_1.getText)(desc))))));
34
- };
35
- exports.OptionContent = OptionContent;