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
|
@@ -70,19 +70,29 @@ var Harness = function (_a) {
|
|
|
70
70
|
react_1.default.createElement(react_3.Tbody, null,
|
|
71
71
|
react_1.default.createElement(TableBody_1.default, { data: makeData(count), columns: columns, startRow: 0, endRow: count, columnWidths: [120], isCheckbox: false, isContent: false, isLink: false, isActionFreeze: false, noBorders: false, selections: [], handleCheckbox: function () { }, scrollContainerRef: ref }))))));
|
|
72
72
|
};
|
|
73
|
+
// Windowing math (normal density): ROW_HEIGHT=40, OVERSCAN=6, viewport falls
|
|
74
|
+
// back to 500px (jsdom clientHeight=0). Rows are unmeasured in jsdom, so every
|
|
75
|
+
// row is estimated at 40px. bottom = 0 + 500 + 6*40 = 740 -> last rendered row
|
|
76
|
+
// is the highest index with offset < 740 -> index 18 (offsets[18]=720). So rows
|
|
77
|
+
// 0..18 (19 rows) render and the trailing spacer reserves (100-19)*40 px.
|
|
78
|
+
var ROW_HEIGHT = 40;
|
|
79
|
+
var VISIBLE_COUNT = 19;
|
|
80
|
+
var LAST_VISIBLE = VISIBLE_COUNT - 1;
|
|
73
81
|
describe("TableBody virtualization", function () {
|
|
74
82
|
it("windows large pages and reserves height with spacer rows", function () {
|
|
75
83
|
var _a = (0, react_2.render)(react_1.default.createElement(Harness, { count: 100 })), container = _a.container, queryByText = _a.queryByText;
|
|
76
|
-
// jsdom clientHeight=0 -> 500px fallback -> ceil(500/45)+12 = 24 rows
|
|
77
84
|
expect(queryByText("Row 0")).toBeInTheDocument();
|
|
78
|
-
expect(queryByText("Row
|
|
85
|
+
expect(queryByText("Row ".concat(LAST_VISIBLE))).toBeInTheDocument();
|
|
79
86
|
// Rows beyond the window are not mounted.
|
|
87
|
+
expect(queryByText("Row ".concat(LAST_VISIBLE + 1))).not.toBeInTheDocument();
|
|
80
88
|
expect(queryByText("Row 50")).not.toBeInTheDocument();
|
|
81
89
|
expect(queryByText("Row 99")).not.toBeInTheDocument();
|
|
82
90
|
// A trailing spacer reserves the height of the unrendered rows.
|
|
83
91
|
var spacers = container.querySelectorAll('tr[aria-hidden="true"]');
|
|
84
92
|
expect(spacers.length).toBe(1);
|
|
85
|
-
expect(spacers[0]).toHaveStyle({
|
|
93
|
+
expect(spacers[0]).toHaveStyle({
|
|
94
|
+
height: "".concat((100 - VISIBLE_COUNT) * ROW_HEIGHT, "px"),
|
|
95
|
+
});
|
|
86
96
|
});
|
|
87
97
|
it("renders every row and no spacers below the threshold", function () {
|
|
88
98
|
var _a = (0, react_2.render)(react_1.default.createElement(Harness, { count: 30 })), container = _a.container, queryByText = _a.queryByText;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableHeaderPageProps } from "../TableProps";
|
|
3
|
-
declare const _default: React.MemoExoticComponent<({ columns, isCheckbox, handleSort, headerRefs, columnWidths, columnsSort, headerBgColor,
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ columns, isCheckbox, handleSort, headerRefs, columnWidths, columnsSort, headerBgColor, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, checked, isLoading, isContent, isLink, isActionFreeze, setColumnsSearch, columnsSearch, isSelecting, }: TableHeaderPageProps) => React.JSX.Element>;
|
|
4
4
|
export default _default;
|
|
@@ -55,12 +55,12 @@ var TableFilters_1 = __importDefault(require("../filters/TableFilters"));
|
|
|
55
55
|
var lucide_react_1 = require("lucide-react");
|
|
56
56
|
var Checkbox_1 = __importDefault(require("../../Checkbox/Checkbox"));
|
|
57
57
|
var TableHeader = function (_a) {
|
|
58
|
-
var columns = _a.columns, isCheckbox = _a.isCheckbox, handleSort = _a.handleSort, headerRefs = _a.headerRefs, columnWidths = _a.columnWidths, columnsSort = _a.columnsSort, headerBgColor = _a.headerBgColor,
|
|
58
|
+
var columns = _a.columns, isCheckbox = _a.isCheckbox, handleSort = _a.handleSort, headerRefs = _a.headerRefs, columnWidths = _a.columnWidths, columnsSort = _a.columnsSort, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, handleCheckbox = _a.handleCheckbox, checked = _a.checked, isLoading = _a.isLoading, isContent = _a.isContent, isLink = _a.isLink, isActionFreeze = _a.isActionFreeze, setColumnsSearch = _a.setColumnsSearch, columnsSearch = _a.columnsSearch, isSelecting = _a.isSelecting;
|
|
59
59
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
60
60
|
var _b = (0, react_2.useState)(null), openFilterId = _b[0], setOpenFilterId = _b[1];
|
|
61
61
|
var RenderCheckbox = (0, react_2.useCallback)(function () {
|
|
62
|
-
var _a, _b, _c, _d, _e;
|
|
63
|
-
return (react_2.default.createElement(react_1.Th, { w: 6, fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
63
|
+
return (react_2.default.createElement(react_1.Th, { w: 6, fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: (_d = (_c = (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.hover) === null || _c === void 0 ? void 0 : _c[200]) !== null && _d !== void 0 ? _d : (_f = (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.secondary) === null || _f === void 0 ? void 0 : _f[50], position: "sticky", className: "columns sticky-columns", left: "0px", zIndex: 9, borderBottom: noBorders ? "none" : "0.063rem solid ".concat((_g = theme.colors) === null || _g === void 0 ? void 0 : _g.gray[300]) }, isSelecting ? (react_2.default.createElement(react_1.Spinner, { size: "sm", color: (_j = (_h = theme.colors) === null || _h === void 0 ? void 0 : _h.primary) === null || _j === void 0 ? void 0 : _j[500] })) : (react_2.default.createElement(Checkbox_1.default, { "aria-label": "Select all rows", variant: "outline", onChange: function () { return handleCheckbox(0); }, isChecked: isLoading ? false : checked === true, isIndeterminate: checked === "indeterminate" }))));
|
|
64
64
|
}, [
|
|
65
65
|
checked,
|
|
66
66
|
freezedTextColor,
|
|
@@ -71,12 +71,12 @@ var TableHeader = function (_a) {
|
|
|
71
71
|
theme.colors,
|
|
72
72
|
]);
|
|
73
73
|
var RenderConent = (0, react_2.useCallback)(function () {
|
|
74
|
-
var _a, _b, _c;
|
|
75
|
-
return (react_2.default.createElement(react_1.Th, { w: 6, minW: "35px", p: 0, backgroundColor: (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.
|
|
74
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
75
|
+
return (react_2.default.createElement(react_1.Th, { w: 6, minW: "35px", p: 0, backgroundColor: (_d = (_c = (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.hover) === null || _c === void 0 ? void 0 : _c[200]) !== null && _d !== void 0 ? _d : (_f = (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.secondary) === null || _f === void 0 ? void 0 : _f[50], borderBottom: noBorders ? "none" : "0.063rem solid ".concat((_g = theme.colors) === null || _g === void 0 ? void 0 : _g.gray[300]), position: "sticky", className: "columns sticky-columns", left: "0px", zIndex: 1 }));
|
|
76
76
|
}, [noBorders, theme.colors]);
|
|
77
77
|
var RenderView = (0, react_2.useCallback)(function () {
|
|
78
|
-
var _a, _b, _c;
|
|
79
|
-
return (react_2.default.createElement(react_1.Th, { w: 2, p: 0, minW: "2.065rem", backgroundColor: (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
79
|
+
return (react_2.default.createElement(react_1.Th, { w: 2, p: 0, minW: "2.065rem", backgroundColor: (_d = (_c = (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.hover) === null || _c === void 0 ? void 0 : _c[200]) !== null && _d !== void 0 ? _d : (_f = (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.secondary) === null || _f === void 0 ? void 0 : _f[50], borderBottom: noBorders ? "none" : "0.063rem solid ".concat((_g = theme.colors) === null || _g === void 0 ? void 0 : _g.gray[300]), position: isActionFreeze ? "sticky" : "relative", className: "columns sticky-columns", right: "0px", zIndex: 1 }));
|
|
80
80
|
}, [noBorders, theme.colors, isActionFreeze]);
|
|
81
81
|
return (react_2.default.createElement(react_1.Tr, { pr: 0 },
|
|
82
82
|
isContent && react_2.default.createElement(RenderConent, null),
|
|
@@ -84,7 +84,7 @@ var TableHeader = function (_a) {
|
|
|
84
84
|
columns.map(function (header, index) {
|
|
85
85
|
if (header === null || header === void 0 ? void 0 : header.isHidden)
|
|
86
86
|
return null;
|
|
87
|
-
return (react_2.default.createElement(ColumnHeader, { header: header, index: index, key: header.label, columnWidths: columnWidths, handleSort: handleSort, isCheckbox: isCheckbox, headerBgColor: headerBgColor,
|
|
87
|
+
return (react_2.default.createElement(ColumnHeader, { header: header, index: index, key: header.label, columnWidths: columnWidths, handleSort: handleSort, isCheckbox: isCheckbox, headerBgColor: headerBgColor, freezedBgColor: freezedBgColor, noBorders: noBorders, columnsSort: columnsSort, headerRefs: headerRefs, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch, openFilterId: openFilterId, setOpenFilterId: setOpenFilterId }));
|
|
88
88
|
}),
|
|
89
89
|
isLink && react_2.default.createElement(RenderView, null)));
|
|
90
90
|
};
|
|
@@ -100,7 +100,7 @@ var SortingIcon = (0, react_2.memo)(function (_a) {
|
|
|
100
100
|
});
|
|
101
101
|
var ColumnHeader = (0, react_2.memo)(function (_a) {
|
|
102
102
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
103
|
-
var header = _a.header, index = _a.index, columnWidths = _a.columnWidths, isCheckbox = _a.isCheckbox,
|
|
103
|
+
var header = _a.header, index = _a.index, columnWidths = _a.columnWidths, isCheckbox = _a.isCheckbox, noBorders = _a.noBorders, columnsSort = _a.columnsSort, headerRefs = _a.headerRefs, columnsSearch = _a.columnsSearch, setColumnsSearch = _a.setColumnsSearch, handleSort = _a.handleSort, openFilterId = _a.openFilterId, setOpenFilterId = _a.setOpenFilterId;
|
|
104
104
|
var _v = (0, react_2.useState)(false), isHovered = _v[0], setIsHovered = _v[1];
|
|
105
105
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
106
106
|
var isFrozen = header.isFreeze;
|
|
@@ -43,5 +43,6 @@ declare const useTable: ({ tableBorderColor, data, isPagination, selections, onS
|
|
|
43
43
|
columnsList: TableHeaderProps[];
|
|
44
44
|
handleColumnPreferences: (columns: any, extra?: Record<string, any>) => void;
|
|
45
45
|
isSelecting: boolean;
|
|
46
|
+
selectAllRowsRef: import("react").MutableRefObject<DataObject[] | null>;
|
|
46
47
|
};
|
|
47
48
|
export default useTable;
|
|
@@ -47,13 +47,13 @@ var useTable = function (_a) {
|
|
|
47
47
|
var _f = (0, react_1.useState)([]), columnsSort = _f[0], setColumnsSort = _f[1];
|
|
48
48
|
var _g = (0, react_1.useState)(0), currentPage = _g[0], setCurrentPage = _g[1];
|
|
49
49
|
var _h = (0, react_1.useState)(noOfRowsPerPage !== null && noOfRowsPerPage !== void 0 ? noOfRowsPerPage : defaultPageSize), rowsPerPage = _h[0], setRowsPerPage = _h[1];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (noOfRowsPerPage !== undefined
|
|
50
|
+
// Keep the internal page size in sync with the `noOfRowsPerPage` prop when the
|
|
51
|
+
// consumer changes it (e.g. a page-size control outside the table).
|
|
52
|
+
(0, react_1.useEffect)(function () {
|
|
53
|
+
if (noOfRowsPerPage !== undefined) {
|
|
54
54
|
setRowsPerPage(noOfRowsPerPage);
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}, [noOfRowsPerPage]);
|
|
57
57
|
var tableData = data;
|
|
58
58
|
var _j = (0, react_1.useState)(function () {
|
|
59
59
|
return columns.map(function (col, i) {
|
|
@@ -162,14 +162,26 @@ var useTable = function (_a) {
|
|
|
162
162
|
selectionRef.current = selection;
|
|
163
163
|
var onSelectionRef = (0, react_1.useRef)(onSelection);
|
|
164
164
|
onSelectionRef.current = onSelection;
|
|
165
|
+
// Rows that "select all" should toggle. Defaults to `tableData`, but in grouped
|
|
166
|
+
// "load more" mode the parent points this at the accumulated/rendered rows so
|
|
167
|
+
// select-all covers everything on screen (not just the latest page).
|
|
168
|
+
var selectAllRowsRef = (0, react_1.useRef)(null);
|
|
165
169
|
var handleCheckbox = (0, react_1.useCallback)(function (id) {
|
|
166
|
-
var _a;
|
|
170
|
+
var _a, _b;
|
|
167
171
|
var current = selectionRef.current;
|
|
168
172
|
if (id === 0) {
|
|
173
|
+
var rows = (_a = selectAllRowsRef.current) !== null && _a !== void 0 ? _a : tableData;
|
|
174
|
+
var ids_1 = rows.map(function (item) { return item.id; });
|
|
175
|
+
var idSet_1 = new Set(ids_1);
|
|
176
|
+
var currentSet_1 = new Set(current);
|
|
177
|
+
var allSelected_1 = ids_1.length > 0 && ids_1.every(function (i) { return currentSet_1.has(i); });
|
|
169
178
|
setIsSelecting(true);
|
|
170
179
|
setTimeout(function () {
|
|
171
180
|
var _a;
|
|
172
|
-
|
|
181
|
+
// Toggle the rendered rows while preserving any selection outside them.
|
|
182
|
+
var selectedItems = allSelected_1
|
|
183
|
+
? current.filter(function (i) { return !idSet_1.has(i); })
|
|
184
|
+
: Array.from(new Set(__spreadArray(__spreadArray([], current, true), ids_1, true)));
|
|
173
185
|
setSelection(selectedItems);
|
|
174
186
|
(_a = onSelectionRef.current) === null || _a === void 0 ? void 0 : _a.call(onSelectionRef, selectedItems);
|
|
175
187
|
setIsSelecting(false);
|
|
@@ -184,7 +196,7 @@ var useTable = function (_a) {
|
|
|
184
196
|
selectedItems = __spreadArray(__spreadArray([], current, true), [id], false);
|
|
185
197
|
}
|
|
186
198
|
setSelection(selectedItems);
|
|
187
|
-
(
|
|
199
|
+
(_b = onSelectionRef.current) === null || _b === void 0 ? void 0 : _b.call(onSelectionRef, selectedItems);
|
|
188
200
|
}
|
|
189
201
|
}, [tableData]);
|
|
190
202
|
var handleColumnPreferences = function (columns, extra) {
|
|
@@ -215,6 +227,7 @@ var useTable = function (_a) {
|
|
|
215
227
|
columnsList: columnsList,
|
|
216
228
|
handleColumnPreferences: handleColumnPreferences,
|
|
217
229
|
isSelecting: isSelecting,
|
|
230
|
+
selectAllRowsRef: selectAllRowsRef,
|
|
218
231
|
};
|
|
219
232
|
};
|
|
220
233
|
exports.default = useTable;
|
|
@@ -97,6 +97,7 @@ jest.mock("../../../Theme/useCustomTheme", function () { return ({
|
|
|
97
97
|
},
|
|
98
98
|
red: { 50: "#fee", 200: "#fcc", 600: "#c00" },
|
|
99
99
|
border: { 200: "#e2e8f0" },
|
|
100
|
+
text: { 500: "#555", 700: "#333" },
|
|
100
101
|
white: "#fff",
|
|
101
102
|
},
|
|
102
103
|
shadows: { sm: "0 1px 2px rgba(0,0,0,0.05)" },
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import React
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
onIconClick?: () => void;
|
|
5
|
-
onTagClick?: () => void;
|
|
6
|
-
icon?: ElementType;
|
|
7
|
-
colorScheme?: "primary" | "secondary" | "tertiary" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink";
|
|
8
|
-
size?: "sm" | "md" | "lg";
|
|
9
|
-
variant?: "solid" | "outline";
|
|
10
|
-
}
|
|
11
|
-
declare const Tag: React.FC<ChipProps>;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TagProps } from "./TagProps";
|
|
3
|
+
declare const Tag: React.FC<TagProps>;
|
|
12
4
|
export default Tag;
|
|
@@ -5,11 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var react_1 = __importDefault(require("react"));
|
|
7
7
|
var react_2 = require("@chakra-ui/react");
|
|
8
|
+
// Icon size scales with the tag size so the right icon stays proportional.
|
|
9
|
+
var ICON_SIZE = {
|
|
10
|
+
xs: "0.75rem",
|
|
11
|
+
sm: "0.875rem",
|
|
12
|
+
md: "1em",
|
|
13
|
+
lg: "1.1em",
|
|
14
|
+
};
|
|
8
15
|
var Tag = function (_a) {
|
|
9
16
|
var label = _a.label, _b = _a.colorScheme, colorScheme = _b === void 0 ? "primary" : _b, _c = _a.variant, variant = _c === void 0 ? "solid" : _c, _d = _a.size, size = _d === void 0 ? "md" : _d, icon = _a.icon, onTagClick = _a.onTagClick, onIconClick = _a.onIconClick;
|
|
10
|
-
|
|
17
|
+
var isInteractive = !!onTagClick;
|
|
18
|
+
return (react_1.default.createElement(react_2.Tag, { size: size, variant: variant, colorScheme: colorScheme, borderRadius: "full", cursor: isInteractive ? "pointer" : "default", role: isInteractive ? "button" : undefined, "aria-label": isInteractive ? label : undefined, onClick: function () { return onTagClick === null || onTagClick === void 0 ? void 0 : onTagClick(); } },
|
|
11
19
|
react_1.default.createElement(react_2.TagLabel, null, label),
|
|
12
|
-
icon && (react_1.default.createElement(react_2.TagRightIcon, { as: icon, boxSize:
|
|
20
|
+
icon && (react_1.default.createElement(react_2.TagRightIcon, { as: icon, boxSize: ICON_SIZE[size], cursor: onIconClick ? "pointer" : "default", onClick: function (e) {
|
|
13
21
|
e.stopPropagation();
|
|
14
22
|
onIconClick === null || onIconClick === void 0 ? void 0 : onIconClick();
|
|
15
23
|
}, transition: "all 0.2s ease", _hover: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const Tag:
|
|
1
|
+
import { ComponentMultiStyleConfig } from "@chakra-ui/react";
|
|
2
|
+
export declare const Tag: ComponentMultiStyleConfig;
|
|
@@ -1,58 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tag = void 0;
|
|
4
|
+
// Resolve a colorScheme key to a numeric swatch from the theme. All supported
|
|
5
|
+
// colorScheme values (brand + global scales) expose a 50-900 scale; fall back to
|
|
6
|
+
// gray so an unknown/missing key can never throw at render time.
|
|
7
|
+
var swatch = function (theme, colorScheme) {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
if (colorScheme === void 0) { colorScheme = "primary"; }
|
|
10
|
+
return (_d = (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a[colorScheme]) !== null && _b !== void 0 ? _b : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray) !== null && _d !== void 0 ? _d : {};
|
|
11
|
+
};
|
|
12
|
+
// Chakra Tag is a multipart component (container / label / closeButton); styling
|
|
13
|
+
// is keyed under those parts, so it needs a multi-style config with `parts`.
|
|
4
14
|
exports.Tag = {
|
|
15
|
+
parts: ["container", "label", "closeButton"],
|
|
5
16
|
baseStyle: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
container: {
|
|
18
|
+
borderRadius: "full",
|
|
19
|
+
fontWeight: 600,
|
|
20
|
+
lineHeight: 1.2,
|
|
21
|
+
display: "inline-flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
transition: "background 0.15s ease, color 0.15s ease, border-color 0.15s ease",
|
|
24
|
+
},
|
|
10
25
|
},
|
|
11
26
|
sizes: {
|
|
27
|
+
xs: {
|
|
28
|
+
container: { fontSize: "0.6875rem", px: 2, py: 0.5, minH: "1.25rem" },
|
|
29
|
+
},
|
|
12
30
|
sm: {
|
|
13
|
-
fontSize: "0.75rem",
|
|
14
|
-
px: 2,
|
|
15
|
-
py: 1,
|
|
31
|
+
container: { fontSize: "0.75rem", px: 2.5, py: 1, minH: "1.5rem" },
|
|
16
32
|
},
|
|
17
33
|
md: {
|
|
18
|
-
fontSize: "0.
|
|
19
|
-
px: 3,
|
|
20
|
-
py: 1.5,
|
|
34
|
+
container: { fontSize: "0.8125rem", px: 3, py: 1, minH: "1.75rem" },
|
|
21
35
|
},
|
|
22
36
|
lg: {
|
|
23
|
-
fontSize: "
|
|
24
|
-
px: 4,
|
|
25
|
-
py: 2,
|
|
37
|
+
container: { fontSize: "0.9375rem", px: 3.5, py: 1.5, minH: "2rem" },
|
|
26
38
|
},
|
|
27
39
|
},
|
|
28
40
|
variants: {
|
|
29
41
|
solid: function (_a) {
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
bg:
|
|
42
|
+
var _b, _c;
|
|
43
|
+
var theme = _a.theme, _d = _a.colorScheme, colorScheme = _d === void 0 ? "primary" : _d;
|
|
44
|
+
var c = swatch(theme, colorScheme);
|
|
45
|
+
return {
|
|
46
|
+
container: {
|
|
47
|
+
bg: c[500],
|
|
48
|
+
color: (_c = (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.white) !== null && _c !== void 0 ? _c : "#fff",
|
|
49
|
+
_hover: { bg: c[600] },
|
|
50
|
+
_active: { bg: c[700] },
|
|
36
51
|
},
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
subtle: function (_a) {
|
|
55
|
+
var theme = _a.theme, _b = _a.colorScheme, colorScheme = _b === void 0 ? "primary" : _b;
|
|
56
|
+
var c = swatch(theme, colorScheme);
|
|
57
|
+
return {
|
|
58
|
+
container: {
|
|
59
|
+
bg: c[50],
|
|
60
|
+
color: c[700],
|
|
61
|
+
border: "0.063rem solid",
|
|
62
|
+
borderColor: c[100],
|
|
63
|
+
_hover: { bg: c[100] },
|
|
64
|
+
_active: { bg: c[200] },
|
|
39
65
|
},
|
|
40
|
-
}
|
|
66
|
+
};
|
|
41
67
|
},
|
|
42
68
|
outline: function (_a) {
|
|
43
69
|
var theme = _a.theme, _b = _a.colorScheme, colorScheme = _b === void 0 ? "primary" : _b;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
bg:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
bg: theme.colors[colorScheme][100],
|
|
70
|
+
var c = swatch(theme, colorScheme);
|
|
71
|
+
return {
|
|
72
|
+
container: {
|
|
73
|
+
border: "0.094rem solid",
|
|
74
|
+
borderColor: c[500],
|
|
75
|
+
color: c[600],
|
|
76
|
+
bg: "transparent",
|
|
77
|
+
_hover: { bg: c[50] },
|
|
78
|
+
_active: { bg: c[100] },
|
|
54
79
|
},
|
|
55
|
-
}
|
|
80
|
+
};
|
|
56
81
|
},
|
|
57
82
|
},
|
|
58
83
|
defaultProps: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var react_2 = require("@testing-library/react");
|
|
8
|
+
require("@testing-library/jest-dom");
|
|
9
|
+
var react_3 = require("@chakra-ui/react");
|
|
10
|
+
var lucide_react_1 = require("lucide-react");
|
|
11
|
+
var Tag_1 = __importDefault(require("./Tag"));
|
|
12
|
+
var Tag_styles_1 = require("./Tag.styles");
|
|
13
|
+
// Register the Tag component theme + the color scales the variants read, so the
|
|
14
|
+
// token-driven styles resolve exactly as they do inside the design library.
|
|
15
|
+
var theme = (0, react_3.extendTheme)({
|
|
16
|
+
colors: {
|
|
17
|
+
primary: { 50: "#f7edfc", 100: "#eacff7", 200: "#d4a0ef", 500: "#8B3FC8", 600: "#7632b0", 700: "#5e2789" },
|
|
18
|
+
green: { 50: "#e9f8ef", 100: "#bbe9cc", 200: "#9adeb4", 500: "#23b85c", 600: "#20a754", 700: "#198341" },
|
|
19
|
+
gray: { 50: "#f9f7fb", 100: "#f0eaf6", 200: "#e4d9f0", 500: "#7d6ea0", 600: "#5e527a", 700: "#4a4060" },
|
|
20
|
+
white: "#fff",
|
|
21
|
+
},
|
|
22
|
+
components: { Tag: Tag_styles_1.Tag },
|
|
23
|
+
});
|
|
24
|
+
var renderWithChakra = function (ui) {
|
|
25
|
+
return (0, react_2.render)(react_1.default.createElement(react_3.ChakraProvider, { theme: theme }, ui));
|
|
26
|
+
};
|
|
27
|
+
describe("Tag", function () {
|
|
28
|
+
it("renders its label", function () {
|
|
29
|
+
renderWithChakra(react_1.default.createElement(Tag_1.default, { label: "Active" }));
|
|
30
|
+
expect(react_2.screen.getByText("Active")).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
it("fires onTagClick when the tag is clicked", function () {
|
|
33
|
+
var onTagClick = jest.fn();
|
|
34
|
+
renderWithChakra(react_1.default.createElement(Tag_1.default, { label: "Click me", onTagClick: onTagClick }));
|
|
35
|
+
react_2.fireEvent.click(react_2.screen.getByText("Click me"));
|
|
36
|
+
expect(onTagClick).toHaveBeenCalledTimes(1);
|
|
37
|
+
});
|
|
38
|
+
it("exposes a button role and aria-label when interactive", function () {
|
|
39
|
+
renderWithChakra(react_1.default.createElement(Tag_1.default, { label: "Filter", onTagClick: function () { } }));
|
|
40
|
+
expect(react_2.screen.getByRole("button", { name: "Filter" })).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
it("is not a button when no onTagClick is provided", function () {
|
|
43
|
+
renderWithChakra(react_1.default.createElement(Tag_1.default, { label: "Static" }));
|
|
44
|
+
expect(react_2.screen.queryByRole("button")).not.toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
it("renders the icon and fires onIconClick without bubbling to onTagClick", function () {
|
|
47
|
+
var onTagClick = jest.fn();
|
|
48
|
+
var onIconClick = jest.fn();
|
|
49
|
+
var container = renderWithChakra(react_1.default.createElement(Tag_1.default, { label: "Removable", icon: lucide_react_1.X, onTagClick: onTagClick, onIconClick: onIconClick })).container;
|
|
50
|
+
var svg = container.querySelector("svg");
|
|
51
|
+
expect(svg).toBeTruthy();
|
|
52
|
+
react_2.fireEvent.click(svg);
|
|
53
|
+
expect(onIconClick).toHaveBeenCalledTimes(1);
|
|
54
|
+
// stopPropagation must prevent the icon click from triggering the tag click.
|
|
55
|
+
expect(onTagClick).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
it("renders across all sizes and variants without throwing", function () {
|
|
58
|
+
var sizes = ["xs", "sm", "md", "lg"];
|
|
59
|
+
var variants = ["solid", "subtle", "outline"];
|
|
60
|
+
sizes.forEach(function (size) {
|
|
61
|
+
return variants.forEach(function (variant) {
|
|
62
|
+
var unmount = renderWithChakra(react_1.default.createElement(Tag_1.default, { label: "".concat(size, "-").concat(variant), size: size, variant: variant })).unmount;
|
|
63
|
+
expect(react_2.screen.getByText("".concat(size, "-").concat(variant))).toBeInTheDocument();
|
|
64
|
+
unmount();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
export type TagColorScheme = "primary" | "secondary" | "tertiary" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink";
|
|
3
|
+
export type TagSize = "xs" | "sm" | "md" | "lg";
|
|
4
|
+
export type TagVariant = "solid" | "outline" | "subtle";
|
|
5
|
+
export interface TagProps {
|
|
6
|
+
label: string;
|
|
7
|
+
onIconClick?: () => void;
|
|
8
|
+
onTagClick?: () => void;
|
|
9
|
+
icon?: ElementType;
|
|
10
|
+
colorScheme?: TagColorScheme;
|
|
11
|
+
size?: TagSize;
|
|
12
|
+
variant?: TagVariant;
|
|
13
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
18
|
+
var react_2 = require("@chakra-ui/react");
|
|
19
|
+
var lucide_react_1 = require("lucide-react");
|
|
20
|
+
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
21
|
+
var sizeMap = {
|
|
22
|
+
sm: { px: "12px", py: "4px", font: "12px", sub: "8px", icon: 11, radius: "40px" },
|
|
23
|
+
md: { px: "20px", py: "5px", font: "14px", sub: "10px", icon: 13, radius: "50px" },
|
|
24
|
+
lg: { px: "26px", py: "8px", font: "16px", sub: "11px", icon: 16, radius: "60px" },
|
|
25
|
+
};
|
|
26
|
+
var FALLBACK_GRADIENT = { from: "#667eea", to: "#764ba2" };
|
|
27
|
+
var UpgradeButton = function (_a) {
|
|
28
|
+
var _b, _c;
|
|
29
|
+
var label = _a.label, mobileLabel = _a.mobileLabel, subtitle = _a.subtitle, _d = _a.icon, icon = _d === void 0 ? lucide_react_1.Sparkles : _d, _e = _a.iconColor, iconColor = _e === void 0 ? "#FFD66B" : _e, _f = _a.variant, variant = _f === void 0 ? "brand" : _f, gradient = _a.gradient, _g = _a.size, size = _g === void 0 ? "md" : _g, _h = _a.shimmer, shimmer = _h === void 0 ? true : _h, _j = _a.isLoading, isLoading = _j === void 0 ? false : _j, _k = _a.isDisabled, isDisabled = _k === void 0 ? false : _k, _l = _a.maxLabelWidth, maxLabelWidth = _l === void 0 ? "160px" : _l, ariaLabel = _a.ariaLabel, onClick = _a.onClick;
|
|
30
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
31
|
+
var c = theme.colors;
|
|
32
|
+
var themeGradient = (_b = c.gradient) !== null && _b !== void 0 ? _b : FALLBACK_GRADIENT;
|
|
33
|
+
var variantGradient = {
|
|
34
|
+
brand: themeGradient,
|
|
35
|
+
primary: { from: c.primary[500], to: c.primary[700] },
|
|
36
|
+
secondary: { from: c.secondary[400], to: c.secondary[600] },
|
|
37
|
+
success: { from: c.semantic.success[400], to: c.semantic.success[600] },
|
|
38
|
+
warning: { from: c.semantic.warning[400], to: c.semantic.warning[600] },
|
|
39
|
+
danger: { from: c.semantic.error[400], to: c.semantic.error[600] },
|
|
40
|
+
info: { from: c.semantic.info[400], to: c.semantic.info[600] },
|
|
41
|
+
};
|
|
42
|
+
var resolved = (_c = gradient !== null && gradient !== void 0 ? gradient : variantGradient[variant]) !== null && _c !== void 0 ? _c : themeGradient;
|
|
43
|
+
var s = sizeMap[size];
|
|
44
|
+
var Icon = icon;
|
|
45
|
+
var blocked = isLoading || isDisabled;
|
|
46
|
+
var g = "linear-gradient(135deg, ".concat(resolved.from, " 0%, ").concat(resolved.to, " 100%)");
|
|
47
|
+
var gReversed = "linear-gradient(135deg, ".concat(resolved.to, " 0%, ").concat(resolved.from, " 100%)");
|
|
48
|
+
var hasMobile = !!mobileLabel && mobileLabel !== label;
|
|
49
|
+
return (react_1.default.createElement(react_2.Box, { as: "button", type: "button", "aria-label": ariaLabel || label, onClick: blocked ? undefined : onClick, disabled: isDisabled, position: "relative", cursor: blocked ? "default" : "pointer", opacity: isDisabled ? 0.6 : 1, px: { base: s.px === "20px" ? "14px" : s.px, md: s.px }, py: s.py, bgImage: g, color: "white", borderRadius: s.radius, fontWeight: "bold", textAlign: "center", overflow: "hidden", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", transition: "transform 0.3s ease, box-shadow 0.3s ease, background-image 0.3s ease", _focusVisible: { outline: "none", boxShadow: "0 0 0 3px ".concat(resolved.from, "55") }, _hover: blocked
|
|
50
|
+
? undefined
|
|
51
|
+
: __assign({ transform: "translateY(-2px)", bgImage: gReversed, boxShadow: "0 10px 30px ".concat(resolved.from, "66") }, (shimmer ? { _before: { left: "130%" } } : {})), sx: shimmer
|
|
52
|
+
? {
|
|
53
|
+
_before: {
|
|
54
|
+
content: '""',
|
|
55
|
+
position: "absolute",
|
|
56
|
+
top: 0,
|
|
57
|
+
left: "-75%",
|
|
58
|
+
width: "55%",
|
|
59
|
+
height: "100%",
|
|
60
|
+
background: "linear-gradient(120deg, transparent, rgba(255,255,255,0.45), transparent)",
|
|
61
|
+
transform: "skewX(-20deg)",
|
|
62
|
+
transition: "left 0.7s ease",
|
|
63
|
+
pointerEvents: "none",
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
: undefined },
|
|
67
|
+
react_1.default.createElement(react_2.Flex, { align: "center", gap: "6px", maxW: maxLabelWidth, overflow: "hidden", whiteSpace: "nowrap", zIndex: 1 },
|
|
68
|
+
react_1.default.createElement(react_2.Text, { as: "span", fontSize: s.font, overflow: "hidden", textOverflow: "ellipsis", display: hasMobile ? { base: "none", md: "block" } : "block" }, label),
|
|
69
|
+
hasMobile && (react_1.default.createElement(react_2.Text, { as: "span", fontSize: s.font, overflow: "hidden", textOverflow: "ellipsis", display: { base: "block", md: "none" } }, mobileLabel)),
|
|
70
|
+
isLoading ? (react_1.default.createElement(react_2.Spinner, { size: "xs", thickness: "1.5px", color: iconColor })) : (Icon && react_1.default.createElement(Icon, { size: s.icon, color: iconColor, style: { flexShrink: 0 } }))),
|
|
71
|
+
subtitle && (react_1.default.createElement(react_2.Text, { as: "span", mt: "1px", fontSize: s.sub, fontWeight: "bold", color: iconColor, maxW: maxLabelWidth, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", zIndex: 1 }, subtitle))));
|
|
72
|
+
};
|
|
73
|
+
exports.default = UpgradeButton;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
export type UpgradeButtonSize = "sm" | "md" | "lg";
|
|
3
|
+
/**
|
|
4
|
+
* Theme-aware color variants. Each resolves to a gradient built from the
|
|
5
|
+
* active theme's tokens, so the button blends with whichever theme is active.
|
|
6
|
+
*/
|
|
7
|
+
export type UpgradeButtonVariant = "brand" | "primary" | "secondary" | "success" | "warning" | "danger" | "info";
|
|
8
|
+
export interface UpgradeButtonProps {
|
|
9
|
+
/** Primary label (shown on md+ screens). */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Compact label for small screens. Defaults to `label`. */
|
|
12
|
+
mobileLabel?: string;
|
|
13
|
+
/** Optional small second line, e.g. a plan-expiry message. */
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
/** Leading icon. Defaults to lucide `Sparkles`. Pass null to hide. */
|
|
16
|
+
icon?: ElementType | null;
|
|
17
|
+
/** Icon color. Defaults to a gold tone. */
|
|
18
|
+
iconColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Theme-aware color variant. Defaults to `brand` (the active theme's
|
|
21
|
+
* gradient). Ignored when an explicit `gradient` is provided.
|
|
22
|
+
*/
|
|
23
|
+
variant?: UpgradeButtonVariant;
|
|
24
|
+
/**
|
|
25
|
+
* Explicit gradient stops. Overrides `variant` and the theme gradient when
|
|
26
|
+
* provided.
|
|
27
|
+
*/
|
|
28
|
+
gradient?: {
|
|
29
|
+
from: string;
|
|
30
|
+
to: string;
|
|
31
|
+
};
|
|
32
|
+
size?: UpgradeButtonSize;
|
|
33
|
+
/** Animated light sweep on hover. Default true. */
|
|
34
|
+
shimmer?: boolean;
|
|
35
|
+
/** Show a spinner and block interaction. */
|
|
36
|
+
isLoading?: boolean;
|
|
37
|
+
isDisabled?: boolean;
|
|
38
|
+
/** Truncate the label beyond this width. */
|
|
39
|
+
maxLabelWidth?: string;
|
|
40
|
+
/** Accessible label (falls back to `label`). */
|
|
41
|
+
ariaLabel?: string;
|
|
42
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
43
|
+
}
|