pixelize-design-library 2.3.1-beta.9 → 2.3.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/.cursor/TASK-SETUP.md +43 -0
- package/.cursor/agents/be-impl.md +37 -0
- package/.cursor/agents/fe-impl.md +39 -0
- package/.cursor/agents/task-plan.md +56 -0
- package/.cursor/agents/test-create.md +31 -0
- package/.cursor/agents/test-exec.md +26 -0
- package/.cursor/hooks/task-hint.env +1 -0
- package/.cursor/hooks/task-skill-nudge.sh +71 -0
- package/.cursor/hooks/task-slash-guard.sh +31 -0
- package/.cursor/hooks.json +13 -0
- package/.cursor/modules/account-management/MODULE.md +16 -0
- package/.cursor/modules/buttons/MODULE.md +13 -0
- package/.cursor/modules/cards/MODULE.md +13 -0
- package/.cursor/modules/charts/MODULE.md +13 -0
- package/.cursor/modules/common/MODULE.md +13 -0
- package/.cursor/modules/contact-auth/MODULE.md +13 -0
- package/.cursor/modules/data-display/MODULE.md +18 -0
- package/.cursor/modules/feedback/MODULE.md +14 -0
- package/.cursor/modules/form/MODULE.md +13 -0
- package/.cursor/modules/inputs-basic/MODULE.md +13 -0
- package/.cursor/modules/inputs-date-file/MODULE.md +19 -0
- package/.cursor/modules/inputs-select/MODULE.md +15 -0
- package/.cursor/modules/inputs-toggle/MODULE.md +13 -0
- package/.cursor/modules/kanban/MODULE.md +14 -0
- package/.cursor/modules/layout-navigation/MODULE.md +14 -0
- package/.cursor/modules/overlays/MODULE.md +13 -0
- package/.cursor/modules/playground/MODULE.md +15 -0
- package/.cursor/modules/table/MODULE.md +15 -0
- package/.cursor/modules/theme/MODULE.md +15 -0
- package/.cursor/modules/types-exports/MODULE.md +17 -0
- package/.cursor/modules/utility-ui/MODULE.md +15 -0
- package/.cursor/modules/utils-hooks/MODULE.md +13 -0
- package/.cursor/pixelize-task-statusline.sh +64 -0
- package/.cursor/plans/blocked/.gitkeep +0 -0
- package/.cursor/plans/current.md +35 -0
- package/.cursor/plans/done/.gitkeep +0 -0
- package/.cursor/rules +31 -0
- package/.cursor/skills/task/SKILL.md +167 -0
- package/CLAUDE.md +122 -0
- package/dist/Components/Card/PaymentCard/PaymentCard.d.ts +1 -1
- package/dist/Components/Card/PaymentCard/PaymentCard.js +3 -3
- package/dist/Components/Card/PaymentCard/PaymentCardProps.d.ts +1 -0
- package/dist/Components/CopyButton/CopyButton.d.ts +22 -0
- package/dist/Components/CopyButton/CopyButton.js +126 -0
- package/dist/Components/CustomModulesTable/CustomModulesTable.d.ts +4 -0
- package/dist/Components/CustomModulesTable/CustomModulesTable.js +182 -0
- package/dist/Components/CustomModulesTable/CustomModulesTable.test.d.ts +1 -0
- package/dist/Components/CustomModulesTable/CustomModulesTable.test.js +84 -0
- package/dist/Components/CustomModulesTable/CustomModulesTableProps.d.ts +54 -0
- package/dist/Components/CustomModulesTable/CustomModulesTableProps.js +2 -0
- package/dist/Components/CustomModulesTable/DeleteModuleModal.d.ts +4 -0
- package/dist/Components/CustomModulesTable/DeleteModuleModal.js +33 -0
- package/dist/Components/CustomModulesTable/EditModuleModal.d.ts +4 -0
- package/dist/Components/CustomModulesTable/EditModuleModal.js +63 -0
- package/dist/Components/Dropdown/DropDown.js +110 -28
- package/dist/Components/Dropdown/Dropdown.test.d.ts +1 -0
- package/dist/Components/Dropdown/Dropdown.test.js +102 -0
- package/dist/Components/Dropdown/DropdownProps.d.ts +4 -1
- package/dist/Components/EmptyState/EmptyState.d.ts +4 -0
- package/dist/Components/EmptyState/EmptyState.js +65 -0
- package/dist/Components/EmptyState/EmptyStateProps.d.ts +28 -0
- package/dist/Components/EmptyState/EmptyStateProps.js +2 -0
- package/dist/Components/FieldSelectModal/FieldSelectModal.d.ts +26 -0
- package/dist/Components/FieldSelectModal/FieldSelectModal.js +107 -0
- package/dist/Components/FilePreview/FilePreview.d.ts +6 -0
- package/dist/Components/FilePreview/FilePreview.js +190 -0
- package/dist/Components/FilePreview/FilePreviewProps.d.ts +26 -0
- package/dist/Components/FilePreview/FilePreviewProps.js +2 -0
- package/dist/Components/LazyWrapper/LazyWrapper.d.ts +10 -0
- package/dist/Components/LazyWrapper/LazyWrapper.js +50 -0
- package/dist/Components/MoreItems/MoreItems.d.ts +4 -0
- package/dist/Components/MoreItems/MoreItems.js +35 -0
- package/dist/Components/MoreItems/MoreItemsProps.d.ts +29 -0
- package/dist/Components/MoreItems/MoreItemsProps.js +2 -0
- package/dist/Components/OrgSwitcher/OrgSwitcher.d.ts +4 -0
- package/dist/Components/OrgSwitcher/OrgSwitcher.js +121 -0
- package/dist/Components/OrgSwitcher/OrgSwitcherProps.d.ts +41 -0
- package/dist/Components/OrgSwitcher/OrgSwitcherProps.js +25 -0
- package/dist/Components/OrganizationDetails/CreateOrgModal.d.ts +4 -0
- package/dist/Components/OrganizationDetails/CreateOrgModal.js +122 -0
- package/dist/Components/OrganizationDetails/DeleteOrgModal.d.ts +4 -0
- package/dist/Components/OrganizationDetails/DeleteOrgModal.js +29 -0
- package/dist/Components/OrganizationDetails/OrganizationDetails.d.ts +4 -0
- package/dist/Components/OrganizationDetails/OrganizationDetails.js +264 -0
- package/dist/Components/OrganizationDetails/OrganizationDetails.test.d.ts +1 -0
- package/dist/Components/OrganizationDetails/OrganizationDetails.test.js +122 -0
- package/dist/Components/OrganizationDetails/OrganizationDetailsProps.d.ts +88 -0
- package/dist/Components/OrganizationDetails/OrganizationDetailsProps.js +2 -0
- package/dist/Components/PdfViewer/PdfViewer.d.ts +15 -0
- package/dist/Components/PdfViewer/PdfViewer.js +29 -0
- package/dist/Components/RolesPermission/DeleteRoleModal.d.ts +4 -0
- package/dist/Components/RolesPermission/DeleteRoleModal.js +29 -0
- package/dist/Components/RolesPermission/RolesPermission.d.ts +4 -0
- package/dist/Components/RolesPermission/RolesPermission.js +243 -0
- package/dist/Components/RolesPermission/RolesPermission.test.d.ts +1 -0
- package/dist/Components/RolesPermission/RolesPermission.test.js +150 -0
- package/dist/Components/RolesPermission/RolesPermissionProps.d.ts +117 -0
- package/dist/Components/RolesPermission/RolesPermissionProps.js +2 -0
- package/dist/Components/ScrollToTop/ScrollToTop.d.ts +19 -0
- package/dist/Components/ScrollToTop/ScrollToTop.js +104 -0
- package/dist/Components/SearchSelect/SearchSelect.dropdownPosition.test.d.ts +1 -0
- package/dist/Components/SearchSelect/SearchSelect.dropdownPosition.test.js +195 -0
- package/dist/Components/SearchSelect/SearchSelect.insideSelect.test.d.ts +1 -0
- package/dist/Components/SearchSelect/SearchSelect.insideSelect.test.js +274 -0
- package/dist/Components/SearchSelect/SearchSelect.js +133 -39
- package/dist/Components/SearchSelect/SearchSelectProps.d.ts +2 -0
- package/dist/Components/SideBar/components/OtherApps.test.js +3 -2
- package/dist/Components/SignInActivityTable/SignInActivityTable.d.ts +4 -0
- package/dist/Components/SignInActivityTable/SignInActivityTable.js +95 -0
- package/dist/Components/SignInActivityTable/SignInActivityTable.test.d.ts +1 -0
- package/dist/Components/SignInActivityTable/SignInActivityTable.test.js +63 -0
- package/dist/Components/SignInActivityTable/SignInActivityTableProps.d.ts +21 -0
- package/dist/Components/SignInActivityTable/SignInActivityTableProps.js +2 -0
- package/dist/Components/StageProgress/StageItem.d.ts +4 -0
- package/dist/Components/StageProgress/StageItem.js +137 -0
- package/dist/Components/StageProgress/StageProgress.d.ts +4 -0
- package/dist/Components/StageProgress/StageProgress.js +59 -0
- package/dist/Components/StageProgress/StageProgressProps.d.ts +85 -0
- package/dist/Components/StageProgress/StageProgressProps.js +27 -0
- package/dist/Components/StageProgress/StepperStage.d.ts +4 -0
- package/dist/Components/StageProgress/StepperStage.js +78 -0
- package/dist/Components/Table/Table.js +66 -45
- package/dist/Components/Table/TableProps.d.ts +4 -2
- package/dist/Components/Table/components/Pagination.js +1 -1
- package/dist/Components/Table/components/TableBody.js +15 -12
- package/dist/Components/Table/components/TableBody.virtualize.test.js +13 -3
- package/dist/Components/Table/components/TableHeader.d.ts +1 -1
- package/dist/Components/Table/components/TableHeader.js +9 -9
- package/dist/Components/Table/hooks/useTable.d.ts +1 -0
- package/dist/Components/Table/hooks/useTable.js +21 -8
- package/dist/Components/Table/settings/ManageColumns.test.js +1 -0
- package/dist/Components/Tag/Tag.d.ts +3 -11
- package/dist/Components/Tag/Tag.js +10 -2
- package/dist/Components/Tag/Tag.styles.d.ts +2 -2
- package/dist/Components/Tag/Tag.styles.js +58 -33
- package/dist/Components/Tag/Tag.test.d.ts +1 -0
- package/dist/Components/Tag/Tag.test.js +68 -0
- package/dist/Components/Tag/TagProps.d.ts +13 -0
- package/dist/Components/Tag/TagProps.js +2 -0
- package/dist/Components/UpgradeButton/UpgradeButton.d.ts +4 -0
- package/dist/Components/UpgradeButton/UpgradeButton.js +73 -0
- package/dist/Components/UpgradeButton/UpgradeButtonProps.d.ts +43 -0
- package/dist/Components/UpgradeButton/UpgradeButtonProps.js +2 -0
- package/dist/Components/UserDetails/AddUserModal.d.ts +4 -0
- package/dist/Components/UserDetails/AddUserModal.js +218 -0
- package/dist/Components/UserDetails/ChangeRoleModal.d.ts +4 -0
- package/dist/Components/UserDetails/ChangeRoleModal.js +150 -0
- package/dist/Components/UserDetails/DeactivateConfirmModal.d.ts +4 -0
- package/dist/Components/UserDetails/DeactivateConfirmModal.js +34 -0
- package/dist/Components/UserDetails/UserDetails.d.ts +4 -0
- package/dist/Components/UserDetails/UserDetails.js +263 -0
- package/dist/Components/UserDetails/UserDetails.test.d.ts +1 -0
- package/dist/Components/UserDetails/UserDetails.test.js +129 -0
- package/dist/Components/UserDetails/UserDetailsProps.d.ts +151 -0
- package/dist/Components/UserDetails/UserDetailsProps.js +2 -0
- package/dist/Theme/componentStyles.d.ts +1 -1
- package/dist/Theme/index.d.ts +4 -4
- package/dist/Theme/index.js +4 -4
- package/dist/index.d.ts +23 -1
- package/dist/index.js +37 -2
- package/package.json +2 -2
- package/.claude/settings.local.json +0 -44
- package/coverage/clover.xml +0 -638
- package/coverage/coverage-final.json +0 -20
- package/coverage/lcov-report/Table/CompactSelect.tsx.html +0 -379
- package/coverage/lcov-report/Table/Components/ActiveFilters.tsx.html +0 -514
- package/coverage/lcov-report/Table/Components/HeaderActions.tsx.html +0 -373
- package/coverage/lcov-report/Table/Components/Pagination.tsx.html +0 -574
- package/coverage/lcov-report/Table/Components/TableActions.tsx.html +0 -574
- package/coverage/lcov-report/Table/Components/TableBody.tsx.html +0 -1027
- package/coverage/lcov-report/Table/Components/TableFilters.tsx.html +0 -397
- package/coverage/lcov-report/Table/Components/TableHeader.tsx.html +0 -1060
- package/coverage/lcov-report/Table/Components/TableLoading.tsx.html +0 -361
- package/coverage/lcov-report/Table/Components/TableSearch.tsx.html +0 -337
- package/coverage/lcov-report/Table/Components/index.html +0 -266
- package/coverage/lcov-report/Table/Components/useDebounce.ts.html +0 -178
- package/coverage/lcov-report/Table/Components/useTable.ts.html +0 -778
- package/coverage/lcov-report/Table/LeftFilterPane.tsx.html +0 -1810
- package/coverage/lcov-report/Table/SelectOperationControls.tsx.html +0 -178
- package/coverage/lcov-report/Table/Table.tsx.html +0 -1567
- package/coverage/lcov-report/Table/TableProps.tsx.html +0 -658
- package/coverage/lcov-report/Table/TableSettings/ManageColumns.tsx.html +0 -619
- package/coverage/lcov-report/Table/TableSettings/TableFilters.tsx.html +0 -229
- package/coverage/lcov-report/Table/TableSettings/TableSettings.tsx.html +0 -532
- package/coverage/lcov-report/Table/TableSettings/index.html +0 -146
- package/coverage/lcov-report/Table/TableToDo.tsx.html +0 -973
- package/coverage/lcov-report/Table/TextOperationControls.tsx.html +0 -271
- package/coverage/lcov-report/Table/filterTypes.ts.html +0 -97
- package/coverage/lcov-report/Table/index.html +0 -176
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -1836
- package/dist/Assets/defaultLogo.tsx +0 -31
|
@@ -0,0 +1,195 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = __importDefault(require("react"));
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
require("@testing-library/jest-dom");
|
|
56
|
+
var react_3 = require("@chakra-ui/react");
|
|
57
|
+
var SearchSelect_1 = __importDefault(require("./SearchSelect"));
|
|
58
|
+
jest.mock("../../Theme/useCustomTheme", function () { return ({
|
|
59
|
+
useCustomTheme: function () { return ({
|
|
60
|
+
colors: {
|
|
61
|
+
white: "#ffffff",
|
|
62
|
+
black: "#000000",
|
|
63
|
+
gray: {
|
|
64
|
+
50: "#f9fafb",
|
|
65
|
+
100: "#f3f4f6",
|
|
66
|
+
200: "#e5e7eb",
|
|
67
|
+
300: "#d1d5db",
|
|
68
|
+
500: "#6b7280",
|
|
69
|
+
600: "#4b5563",
|
|
70
|
+
800: "#1f2937",
|
|
71
|
+
},
|
|
72
|
+
primary: {
|
|
73
|
+
500: "#6366f1",
|
|
74
|
+
600: "#4f46e5",
|
|
75
|
+
700: "#4338ca",
|
|
76
|
+
opacity: { 8: "rgba(99,102,241,0.08)" },
|
|
77
|
+
},
|
|
78
|
+
placeholder: { 500: "#9ca3af" },
|
|
79
|
+
semantic: { error: { 500: "#ef4444" } },
|
|
80
|
+
boxborder: { 200: "#e5e7eb", 500: "#d1d5db" },
|
|
81
|
+
background: { 50: "#ffffff" },
|
|
82
|
+
text: { 700: "#374151" },
|
|
83
|
+
boxShadow: { primary: "rgba(99,102,241,0.2)", error: "rgba(239,68,68,0.2)" },
|
|
84
|
+
},
|
|
85
|
+
shadows: { md: "0 4px 6px rgba(0,0,0,0.1)" },
|
|
86
|
+
}); },
|
|
87
|
+
}); });
|
|
88
|
+
beforeAll(function () {
|
|
89
|
+
Object.defineProperty(window, "matchMedia", {
|
|
90
|
+
writable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
value: jest.fn().mockImplementation(function (query) { return ({
|
|
93
|
+
matches: false,
|
|
94
|
+
media: query,
|
|
95
|
+
onchange: null,
|
|
96
|
+
addListener: jest.fn(),
|
|
97
|
+
removeListener: jest.fn(),
|
|
98
|
+
addEventListener: jest.fn(),
|
|
99
|
+
removeEventListener: jest.fn(),
|
|
100
|
+
dispatchEvent: jest.fn(),
|
|
101
|
+
}); }),
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(window, "innerWidth", { writable: true, configurable: true, value: 1000 });
|
|
104
|
+
Object.defineProperty(window, "innerHeight", { writable: true, configurable: true, value: 800 });
|
|
105
|
+
});
|
|
106
|
+
var options = [
|
|
107
|
+
{ id: "1", label: "User One" },
|
|
108
|
+
{ id: "2", label: "User Two" },
|
|
109
|
+
];
|
|
110
|
+
var renderWithChakra = function (ui) {
|
|
111
|
+
return (0, react_2.render)(react_1.default.createElement(react_3.ChakraProvider, null, ui));
|
|
112
|
+
};
|
|
113
|
+
var openMainDropdown = function () {
|
|
114
|
+
react_2.fireEvent.focus(react_2.screen.getByPlaceholderText("Select"));
|
|
115
|
+
};
|
|
116
|
+
var mockControlRect = function (rect) {
|
|
117
|
+
var control = react_2.screen.getByPlaceholderText("Select").parentElement;
|
|
118
|
+
jest.spyOn(control, "getBoundingClientRect").mockReturnValue(__assign({ top: 100, bottom: 140, left: 100, right: 400, width: 300, height: 40, x: 100, y: 100, toJSON: function () { return ({}); } }, rect));
|
|
119
|
+
};
|
|
120
|
+
var setPortalDimensions = function (height, width) {
|
|
121
|
+
if (width === void 0) { width = 300; }
|
|
122
|
+
var portal = document.getElementById("searchselect-dropdown-portal");
|
|
123
|
+
expect(portal).toBeTruthy();
|
|
124
|
+
Object.defineProperty(portal, "offsetHeight", { configurable: true, value: height });
|
|
125
|
+
Object.defineProperty(portal, "offsetWidth", { configurable: true, value: width });
|
|
126
|
+
react_2.fireEvent.scroll(window);
|
|
127
|
+
};
|
|
128
|
+
describe("SearchSelect dropdown positioning", function () {
|
|
129
|
+
afterEach(function () {
|
|
130
|
+
jest.restoreAllMocks();
|
|
131
|
+
});
|
|
132
|
+
it("anchors the options menu with position fixed below the control by default", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
+
var portal;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, onSelect: jest.fn() }));
|
|
138
|
+
mockControlRect({ top: 100, bottom: 140, left: 100, right: 400, width: 300 });
|
|
139
|
+
openMainDropdown();
|
|
140
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
141
|
+
expect(document.getElementById("searchselect-dropdown-portal")).toBeInTheDocument();
|
|
142
|
+
})];
|
|
143
|
+
case 1:
|
|
144
|
+
_a.sent();
|
|
145
|
+
portal = document.getElementById("searchselect-dropdown-portal");
|
|
146
|
+
expect(portal).toHaveStyle({ position: "fixed" });
|
|
147
|
+
setPortalDimensions(120);
|
|
148
|
+
expect(getComputedStyle(portal).top).toBe("140px");
|
|
149
|
+
return [2 /*return*/];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}); });
|
|
153
|
+
it("flips the menu above the control when there is more space above than below", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
154
|
+
var portal;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, onSelect: jest.fn() }));
|
|
159
|
+
mockControlRect({ top: 700, bottom: 740, left: 100, right: 400, width: 300 });
|
|
160
|
+
openMainDropdown();
|
|
161
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
162
|
+
expect(document.getElementById("searchselect-dropdown-portal")).toBeInTheDocument();
|
|
163
|
+
})];
|
|
164
|
+
case 1:
|
|
165
|
+
_a.sent();
|
|
166
|
+
portal = document.getElementById("searchselect-dropdown-portal");
|
|
167
|
+
setPortalDimensions(200);
|
|
168
|
+
expect(getComputedStyle(portal).top).toBe("500px");
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}); });
|
|
173
|
+
it("clamps the menu horizontally when the control is near the right edge", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var portal, left;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, onSelect: jest.fn() }));
|
|
179
|
+
mockControlRect({ top: 100, bottom: 140, left: 960, right: 1000, width: 40 });
|
|
180
|
+
openMainDropdown();
|
|
181
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
182
|
+
expect(document.getElementById("searchselect-dropdown-portal")).toBeInTheDocument();
|
|
183
|
+
})];
|
|
184
|
+
case 1:
|
|
185
|
+
_a.sent();
|
|
186
|
+
portal = document.getElementById("searchselect-dropdown-portal");
|
|
187
|
+
setPortalDimensions(120, 300);
|
|
188
|
+
left = parseFloat(getComputedStyle(portal).left);
|
|
189
|
+
expect(left).toBeLessThan(960);
|
|
190
|
+
expect(left).toBeGreaterThanOrEqual(8);
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
195
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,274 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = __importDefault(require("react"));
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
require("@testing-library/jest-dom");
|
|
56
|
+
var react_3 = require("@chakra-ui/react");
|
|
57
|
+
var SearchSelect_1 = __importDefault(require("./SearchSelect"));
|
|
58
|
+
jest.mock("../../Theme/useCustomTheme", function () { return ({
|
|
59
|
+
useCustomTheme: function () { return ({
|
|
60
|
+
colors: {
|
|
61
|
+
white: "#ffffff",
|
|
62
|
+
black: "#000000",
|
|
63
|
+
gray: {
|
|
64
|
+
50: "#f9fafb",
|
|
65
|
+
100: "#f3f4f6",
|
|
66
|
+
200: "#e5e7eb",
|
|
67
|
+
300: "#d1d5db",
|
|
68
|
+
500: "#6b7280",
|
|
69
|
+
600: "#4b5563",
|
|
70
|
+
800: "#1f2937",
|
|
71
|
+
},
|
|
72
|
+
primary: {
|
|
73
|
+
500: "#6366f1",
|
|
74
|
+
600: "#4f46e5",
|
|
75
|
+
700: "#4338ca",
|
|
76
|
+
opacity: { 8: "rgba(99,102,241,0.08)" },
|
|
77
|
+
},
|
|
78
|
+
placeholder: { 500: "#9ca3af" },
|
|
79
|
+
semantic: { error: { 500: "#ef4444" } },
|
|
80
|
+
boxborder: { 200: "#e5e7eb", 500: "#d1d5db" },
|
|
81
|
+
background: { 50: "#ffffff" },
|
|
82
|
+
text: { 700: "#374151" },
|
|
83
|
+
boxShadow: { primary: "rgba(99,102,241,0.2)", error: "rgba(239,68,68,0.2)" },
|
|
84
|
+
},
|
|
85
|
+
shadows: { md: "0 4px 6px rgba(0,0,0,0.1)" },
|
|
86
|
+
}); },
|
|
87
|
+
}); });
|
|
88
|
+
beforeAll(function () {
|
|
89
|
+
Object.defineProperty(window, "innerWidth", { writable: true, configurable: true, value: 1000 });
|
|
90
|
+
Object.defineProperty(window, "innerHeight", { writable: true, configurable: true, value: 800 });
|
|
91
|
+
Object.defineProperty(window, "matchMedia", {
|
|
92
|
+
writable: true,
|
|
93
|
+
configurable: true,
|
|
94
|
+
value: jest.fn().mockImplementation(function (query) { return ({
|
|
95
|
+
matches: false,
|
|
96
|
+
media: query,
|
|
97
|
+
onchange: null,
|
|
98
|
+
addListener: jest.fn(),
|
|
99
|
+
removeListener: jest.fn(),
|
|
100
|
+
addEventListener: jest.fn(),
|
|
101
|
+
removeEventListener: jest.fn(),
|
|
102
|
+
dispatchEvent: jest.fn(),
|
|
103
|
+
}); }),
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
var options = [
|
|
107
|
+
{ id: "1", label: "User One" },
|
|
108
|
+
{ id: "2", label: "User Two" },
|
|
109
|
+
];
|
|
110
|
+
var renderWithChakra = function (ui) {
|
|
111
|
+
return (0, react_2.render)(react_1.default.createElement(react_3.ChakraProvider, null, ui));
|
|
112
|
+
};
|
|
113
|
+
var clickInsideTrigger = function () {
|
|
114
|
+
var _a;
|
|
115
|
+
var input = react_2.screen.getByPlaceholderText("Select");
|
|
116
|
+
var prefix = (_a = input.parentElement) === null || _a === void 0 ? void 0 : _a.firstElementChild;
|
|
117
|
+
expect(prefix).toBeTruthy();
|
|
118
|
+
react_2.fireEvent.click(prefix);
|
|
119
|
+
};
|
|
120
|
+
var mockInsideTriggerRect = function (rect) {
|
|
121
|
+
var _a;
|
|
122
|
+
var input = react_2.screen.getByPlaceholderText("Select");
|
|
123
|
+
var prefix = (_a = input.parentElement) === null || _a === void 0 ? void 0 : _a.firstElementChild;
|
|
124
|
+
jest.spyOn(prefix, "getBoundingClientRect").mockReturnValue(__assign({ top: 100, bottom: 140, left: 100, right: 180, width: 80, height: 40, x: 100, y: 100, toJSON: function () { return ({}); } }, rect));
|
|
125
|
+
};
|
|
126
|
+
var setInsidePortalDimensions = function (height, width) {
|
|
127
|
+
if (width === void 0) { width = 128; }
|
|
128
|
+
var portal = document.getElementById("custom-select-portal");
|
|
129
|
+
expect(portal).toBeTruthy();
|
|
130
|
+
Object.defineProperty(portal, "offsetHeight", { configurable: true, value: height });
|
|
131
|
+
Object.defineProperty(portal, "offsetWidth", { configurable: true, value: width });
|
|
132
|
+
react_2.fireEvent.scroll(window);
|
|
133
|
+
};
|
|
134
|
+
describe("SearchSelect insideSelect", function () {
|
|
135
|
+
afterEach(function () {
|
|
136
|
+
jest.restoreAllMocks();
|
|
137
|
+
});
|
|
138
|
+
it("opens only the insideSelect dropdown when its trigger is clicked", function () {
|
|
139
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { label: "Users", options: options, isMultiple: true, insideSelect: {
|
|
140
|
+
width: "80px",
|
|
141
|
+
option: [
|
|
142
|
+
{ id: 1, label: "Option 1" },
|
|
143
|
+
{ id: 2, label: "Option 2" },
|
|
144
|
+
],
|
|
145
|
+
onSelect: jest.fn(),
|
|
146
|
+
} }));
|
|
147
|
+
clickInsideTrigger();
|
|
148
|
+
expect(document.getElementById("custom-select-portal")).toBeInTheDocument();
|
|
149
|
+
expect(document.getElementById("searchselect-dropdown-portal")).not.toBeInTheDocument();
|
|
150
|
+
});
|
|
151
|
+
it("shows insideSelect placeholder when no value is selected", function () {
|
|
152
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, isMultiple: true, insideSelect: {
|
|
153
|
+
width: "80px",
|
|
154
|
+
placeholder: "Filter type",
|
|
155
|
+
option: [{ id: 1, label: "Option 1" }],
|
|
156
|
+
onSelect: jest.fn(),
|
|
157
|
+
} }));
|
|
158
|
+
expect(react_2.screen.getByText("Filter type")).toBeInTheDocument();
|
|
159
|
+
});
|
|
160
|
+
it("anchors insideSelect portal with position fixed", function () {
|
|
161
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, isMultiple: true, insideSelect: {
|
|
162
|
+
width: "80px",
|
|
163
|
+
option: [{ id: 1, label: "Option 1" }],
|
|
164
|
+
onSelect: jest.fn(),
|
|
165
|
+
} }));
|
|
166
|
+
clickInsideTrigger();
|
|
167
|
+
var portal = document.getElementById("custom-select-portal");
|
|
168
|
+
expect(portal).toHaveStyle({ position: "fixed" });
|
|
169
|
+
});
|
|
170
|
+
it("opens insideSelect below the trigger by default", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
+
var portal;
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
switch (_a.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, isMultiple: true, insideSelect: {
|
|
176
|
+
width: "80px",
|
|
177
|
+
option: [{ id: 1, label: "Option 1" }],
|
|
178
|
+
onSelect: jest.fn(),
|
|
179
|
+
} }));
|
|
180
|
+
mockInsideTriggerRect({ top: 100, bottom: 140, left: 100, right: 180, width: 80 });
|
|
181
|
+
clickInsideTrigger();
|
|
182
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
183
|
+
expect(document.getElementById("custom-select-portal")).toBeInTheDocument();
|
|
184
|
+
})];
|
|
185
|
+
case 1:
|
|
186
|
+
_a.sent();
|
|
187
|
+
portal = document.getElementById("custom-select-portal");
|
|
188
|
+
setInsidePortalDimensions(80);
|
|
189
|
+
expect(getComputedStyle(portal).top).toBe("140px");
|
|
190
|
+
return [2 /*return*/];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}); });
|
|
194
|
+
it("flips insideSelect above the trigger when near the bottom of the viewport", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
195
|
+
var portal;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, isMultiple: true, insideSelect: {
|
|
200
|
+
width: "80px",
|
|
201
|
+
option: [
|
|
202
|
+
{ id: 1, label: "Option 1" },
|
|
203
|
+
{ id: 2, label: "Option 2" },
|
|
204
|
+
],
|
|
205
|
+
onSelect: jest.fn(),
|
|
206
|
+
} }));
|
|
207
|
+
mockInsideTriggerRect({ top: 700, bottom: 740, left: 100, right: 180, width: 80 });
|
|
208
|
+
clickInsideTrigger();
|
|
209
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
210
|
+
expect(document.getElementById("custom-select-portal")).toBeInTheDocument();
|
|
211
|
+
})];
|
|
212
|
+
case 1:
|
|
213
|
+
_a.sent();
|
|
214
|
+
portal = document.getElementById("custom-select-portal");
|
|
215
|
+
setInsidePortalDimensions(120);
|
|
216
|
+
expect(getComputedStyle(portal).top).toBe("580px");
|
|
217
|
+
return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}); });
|
|
221
|
+
it("repositions insideSelect portal on scroll while open", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
222
|
+
var input, prefix, rectSpy;
|
|
223
|
+
var _a;
|
|
224
|
+
return __generator(this, function (_b) {
|
|
225
|
+
switch (_b.label) {
|
|
226
|
+
case 0:
|
|
227
|
+
renderWithChakra(react_1.default.createElement(SearchSelect_1.default, { options: options, isMultiple: true, insideSelect: {
|
|
228
|
+
width: "80px",
|
|
229
|
+
option: [{ id: 1, label: "Option 1" }],
|
|
230
|
+
onSelect: jest.fn(),
|
|
231
|
+
} }));
|
|
232
|
+
input = react_2.screen.getByPlaceholderText("Select");
|
|
233
|
+
prefix = (_a = input.parentElement) === null || _a === void 0 ? void 0 : _a.firstElementChild;
|
|
234
|
+
rectSpy = jest.spyOn(prefix, "getBoundingClientRect").mockReturnValue({
|
|
235
|
+
top: 20,
|
|
236
|
+
bottom: 60,
|
|
237
|
+
left: 10,
|
|
238
|
+
right: 90,
|
|
239
|
+
width: 80,
|
|
240
|
+
height: 40,
|
|
241
|
+
x: 10,
|
|
242
|
+
y: 20,
|
|
243
|
+
toJSON: function () { return ({}); },
|
|
244
|
+
});
|
|
245
|
+
clickInsideTrigger();
|
|
246
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
247
|
+
var portal = document.getElementById("custom-select-portal");
|
|
248
|
+
expect(getComputedStyle(portal).top).toBe("60px");
|
|
249
|
+
})];
|
|
250
|
+
case 1:
|
|
251
|
+
_b.sent();
|
|
252
|
+
rectSpy.mockReturnValue({
|
|
253
|
+
top: 120,
|
|
254
|
+
bottom: 160,
|
|
255
|
+
left: 40,
|
|
256
|
+
right: 120,
|
|
257
|
+
width: 80,
|
|
258
|
+
height: 40,
|
|
259
|
+
x: 40,
|
|
260
|
+
y: 120,
|
|
261
|
+
toJSON: function () { return ({}); },
|
|
262
|
+
});
|
|
263
|
+
react_2.fireEvent.scroll(window);
|
|
264
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
265
|
+
var portal = document.getElementById("custom-select-portal");
|
|
266
|
+
expect(getComputedStyle(portal).top).toBe("160px");
|
|
267
|
+
})];
|
|
268
|
+
case 2:
|
|
269
|
+
_b.sent();
|
|
270
|
+
return [2 /*return*/];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}); });
|
|
274
|
+
});
|