hi-tm 0.21.2 → 0.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Layout/Headers/HeaderLayout.js +55 -6
- package/dist/components/Wrapper/Modals/DeleteConfirmationModal.d.ts +2 -1
- package/dist/components/Wrapper/Modals/DeleteConfirmationModal.js +42 -19
- package/dist/index.d.ts +1 -0
- package/dist/types/Layout/Headers/HeaderLayout.d.ts +29 -0
- package/package.json +1 -1
|
@@ -123,7 +123,7 @@ const ModalSearchContentInHeader_1 = __importDefault(require("../../sections/com
|
|
|
123
123
|
* ```
|
|
124
124
|
* @param refreshPageHandler - Function to refresh the page when the refresh icon is clicked.
|
|
125
125
|
*/
|
|
126
|
-
const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, userLastName, logOutText, imageDefaultSRC, logOutHandler, modalData, modalItemOnClickHandler, iconsSRC, cdnURL, userBranchesData, selectBranchHandler, sidebarData, searchIconSRC, searchItemHandler, refreshPageHandler, brandNameText, languages, changeLanguageHandler, onLogoClickHandler, }) => {
|
|
126
|
+
const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, userLastName, logOutText, imageDefaultSRC, logOutHandler, modalData, modalItemOnClickHandler, iconsSRC, cdnURL, userBranchesData, selectBranchHandler, sidebarData, searchIconSRC, searchItemHandler, refreshPageHandler, brandNameText, languages, changeLanguageHandler, onLogoClickHandler, branchPanel, }) => {
|
|
127
127
|
const [isShowModalSearch, setIsShowModalSearch] = (0, react_1.useState)(false);
|
|
128
128
|
const [isOpenModal, setIsOpenModal] = (0, react_1.useState)(false);
|
|
129
129
|
const [isOpenModalBranches, setIsOpenModalBranches] = (0, react_1.useState)(false);
|
|
@@ -148,7 +148,7 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
148
148
|
setIsOpenModal(!isOpenModal);
|
|
149
149
|
};
|
|
150
150
|
const handleModalShowBranches = () => {
|
|
151
|
-
if (userBranchesData !== undefined && userBranchesData.length > 0) {
|
|
151
|
+
if (userBranchesData !== undefined && userBranchesData.length > 0 && isBranchSelectorClickable) {
|
|
152
152
|
setIsOpenModalBranches(!isOpenModalBranches);
|
|
153
153
|
}
|
|
154
154
|
};
|
|
@@ -175,6 +175,8 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
175
175
|
const hasBranchChoices = userBranchesData !== undefined &&
|
|
176
176
|
(userBranchesData.length > 1 ||
|
|
177
177
|
userBranchesData.some((branch) => branch.subBranch?.length > 0));
|
|
178
|
+
// With a branch panel there is always something to show (actions), even for a single branch
|
|
179
|
+
const isBranchSelectorClickable = hasBranchChoices || branchPanel !== undefined;
|
|
178
180
|
const selectLanguageHandler = (language) => {
|
|
179
181
|
changeLanguageHandler(language);
|
|
180
182
|
setIsOpenLanguageModal(false);
|
|
@@ -238,12 +240,59 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
238
240
|
}
|
|
239
241
|
} }));
|
|
240
242
|
};
|
|
243
|
+
const renderPanelIcon = (item, size) => {
|
|
244
|
+
if (item.icon)
|
|
245
|
+
return item.icon;
|
|
246
|
+
if (item.iconSrc) {
|
|
247
|
+
return react_1.default.createElement(image_1.default, { src: item.iconSrc, alt: "", width: size, height: size, style: { width: size, height: size } });
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
};
|
|
251
|
+
const panelItemClickHandler = (config, item) => {
|
|
252
|
+
setIsOpenModalBranches(false);
|
|
253
|
+
config.onItemClick(item);
|
|
254
|
+
};
|
|
255
|
+
const renderPanelBranchRow = (branch, isSub) => {
|
|
256
|
+
const isSelected = branchNameSelected.id === branch.id;
|
|
257
|
+
return (react_1.default.createElement("div", { onClick: () => selectItemBranchHandler(branch), className: `customTransition flex w-full cursor-pointer flex-row items-center gap-2 rounded-lg px-2 py-1.5 text-text-color-primary hover:bg-gray-primary ${isSelected ? "bg-back-ground-color-primary font-medium" : ""}` },
|
|
258
|
+
renderBranchLogo(branch, isSub ? 20 : 24),
|
|
259
|
+
react_1.default.createElement("p", { className: "select-none-custom flex-1 truncate text-sm" }, branch.name),
|
|
260
|
+
isSelected && (react_1.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "shrink-0" },
|
|
261
|
+
react_1.default.createElement("path", { d: "M5 12.5L10 17.5L19 7", stroke: "#006fee", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round" })))));
|
|
262
|
+
};
|
|
263
|
+
const renderBranchPanel = (config) => {
|
|
264
|
+
const primaryActions = config.primaryActions ?? [];
|
|
265
|
+
const manageItems = config.manageItems ?? [];
|
|
266
|
+
return (react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-1/2 top-full z-60 mt-2 flex w-[300px] max-w-[92vw] -translate-x-1/2 origin-top flex-col rounded-xl border border-border-color-primary bg-white-color text-text-color-primary ${isOpenModalBranches
|
|
267
|
+
? "pointer-events-auto scale-y-100 opacity-100"
|
|
268
|
+
: "pointer-events-none scale-y-0 opacity-0"}` },
|
|
269
|
+
react_1.default.createElement("div", { className: "flex flex-col gap-3 p-3" },
|
|
270
|
+
react_1.default.createElement("div", { className: "flex flex-row items-center gap-3" },
|
|
271
|
+
renderBranchLogo(branchNameSelected, 44, "rounded-lg"),
|
|
272
|
+
react_1.default.createElement("div", { className: "flex min-w-0 flex-col" },
|
|
273
|
+
react_1.default.createElement("p", { className: "truncate text-base font-semibold" }, branchNameSelected.name),
|
|
274
|
+
config.subtitle && react_1.default.createElement("p", { className: "truncate text-xs opacity-60" }, config.subtitle))),
|
|
275
|
+
primaryActions.length > 0 && (react_1.default.createElement("div", { className: "grid grid-cols-2 gap-2" }, primaryActions.map((item) => (react_1.default.createElement("button", { key: item.id, type: "button", onClick: () => panelItemClickHandler(config, item), className: "customTransition flex flex-row items-center justify-center gap-2 rounded-lg border border-border-color-primary px-2 py-1.5 text-sm hover:bg-gray-primary" },
|
|
276
|
+
renderPanelIcon(item, 16),
|
|
277
|
+
react_1.default.createElement("span", { className: "truncate" }, item.title))))))),
|
|
278
|
+
react_1.default.createElement("div", { className: "flex max-h-[60vh] flex-col overflow-y-auto" },
|
|
279
|
+
hasBranchChoices && (react_1.default.createElement("div", { className: "flex flex-col gap-1 border-t border-border-color-primary p-2" },
|
|
280
|
+
config.branchesTitle && react_1.default.createElement("p", { className: "px-2 pb-1 pt-1 text-xs opacity-50" }, config.branchesTitle),
|
|
281
|
+
userBranchesData.map((item) => (react_1.default.createElement("div", { key: item.id, className: "flex flex-col gap-1" },
|
|
282
|
+
renderPanelBranchRow(item, false),
|
|
283
|
+
item.subBranch?.length > 0 && (react_1.default.createElement("div", { className: "ms-4 flex flex-col gap-1 border-s border-border-color-primary ps-2" }, item.subBranch.map((subItem) => (react_1.default.createElement("div", { key: subItem.id }, renderPanelBranchRow(subItem, true))))))))))),
|
|
284
|
+
manageItems.length > 0 && (react_1.default.createElement("div", { className: "flex flex-col gap-0.5 border-t border-border-color-primary p-2" },
|
|
285
|
+
config.manageTitle && react_1.default.createElement("p", { className: "px-2 pb-1 pt-1 text-xs opacity-50" }, config.manageTitle),
|
|
286
|
+
manageItems.map((item) => (react_1.default.createElement("button", { key: item.id, type: "button", onClick: () => panelItemClickHandler(config, item), className: "customTransition flex w-full flex-row items-center gap-2 rounded-lg px-2 py-2 text-start text-sm hover:bg-gray-primary" },
|
|
287
|
+
renderPanelIcon(item, 18),
|
|
288
|
+
react_1.default.createElement("span", { className: "truncate" }, item.title)))))))));
|
|
289
|
+
};
|
|
241
290
|
const renderBranchSelector = (ref) => (react_1.default.createElement("div", { ref: ref, className: `relative bg-inherit ${branchNameSelected?.id === 0 ? "hidden" : "flex"}` },
|
|
242
|
-
react_1.default.createElement("div", { onClick: handleModalShowBranches, className: `select-none-custom flex flex-row items-center justify-center gap-2 rounded-lg px-2 py-1 customTransition ${
|
|
291
|
+
react_1.default.createElement("div", { onClick: handleModalShowBranches, className: `select-none-custom flex flex-row items-center justify-center gap-2 rounded-lg px-2 py-1 customTransition ${isBranchSelectorClickable ? "cursor-pointer hover:bg-gray-primary" : "cursor-default"}` },
|
|
243
292
|
renderBranchLogo(branchNameSelected, 24),
|
|
244
293
|
react_1.default.createElement("p", { className: "text-nowrap text-sm" }, branchNameSelected.name),
|
|
245
|
-
|
|
246
|
-
react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-1/2 top-full z-60 mt-2 min-w-[240px] max-w-[90vw] -translate-x-1/2 origin-top rounded-lg bg-white-color p-2 ${isOpenModalBranches
|
|
294
|
+
isBranchSelectorClickable && (react_1.default.createElement(image_1.default, { src: iconsSRC.arrowSRC, alt: "arrow.svg", width: 14, height: 14, className: `customTransition ${isOpenModalBranches ? "rotate-180" : "rotate-0"}` }))),
|
|
295
|
+
branchPanel ? renderBranchPanel(branchPanel) : (react_1.default.createElement("div", { className: `customShadowBox customTransition absolute left-1/2 top-full z-60 mt-2 min-w-[240px] max-w-[90vw] -translate-x-1/2 origin-top rounded-lg bg-white-color p-2 ${isOpenModalBranches
|
|
247
296
|
? "pointer-events-auto scale-y-100 opacity-100"
|
|
248
297
|
: "pointer-events-none scale-y-0 opacity-0"}` },
|
|
249
298
|
react_1.default.createElement("ul", { className: "flex max-h-[60vh] w-full flex-col gap-1 overflow-y-auto" }, userBranchesData?.map((item) => {
|
|
@@ -262,7 +311,7 @@ const HeaderLayout = ({ appVersion, branchName, userFirstName, sidebarHandler, u
|
|
|
262
311
|
hasSub && isExpanded && (react_1.default.createElement("ul", { className: "ms-5 mt-1 flex flex-col gap-1 border-s border-border-color-primary ps-2" }, item.subBranch.map((subItem) => (react_1.default.createElement("li", { key: subItem.id, onClick: () => selectItemBranchHandler(subItem), className: `customTransition flex cursor-pointer flex-row items-center gap-2 rounded-md px-3 py-2 text-text-color-primary hover:bg-gray-primary ${branchNameSelected.id === subItem.id ? "bg-back-ground-color-primary font-medium" : ""}` },
|
|
263
312
|
renderBranchLogo(subItem, 18),
|
|
264
313
|
react_1.default.createElement("p", { className: "select-none-custom text-nowrap text-sm" }, subItem.name))))))));
|
|
265
|
-
})))));
|
|
314
|
+
}))))));
|
|
266
315
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
267
316
|
react_1.default.createElement("header", { style: { zIndex: 100 }, className: "hidden h-[50px] w-full flex-row items-center justify-between bg-back-ground-color-primary p-1 xl:flex fixed top-0" },
|
|
268
317
|
react_1.default.createElement(link_1.default, { href: "/", className: "flex w-auto flex-row-reverse items-center justify-end" },
|
|
@@ -12,7 +12,8 @@ interface DeleteConfirmationModalProps {
|
|
|
12
12
|
btnText: string;
|
|
13
13
|
btnDeleteText: string;
|
|
14
14
|
type: 'submit' | 'button';
|
|
15
|
+
/** Kept for backward compatibility; the cancel button now has a fixed neutral style. */
|
|
15
16
|
buttonClassStyle: 'dangerBtn' | 'successBtn' | 'warningBtn' | 'infoBtn' | 'primaryBtn' | 'secondaryBtn';
|
|
16
17
|
}
|
|
17
|
-
declare const DeleteConfirmationModal: ({ isOpen, onClose, onConfirm,
|
|
18
|
+
declare const DeleteConfirmationModal: ({ isOpen, onClose, onConfirm, btnDisabled, btnText, type, text, btnDeleteText, }: DeleteConfirmationModalProps) => React.JSX.Element | null;
|
|
18
19
|
export default DeleteConfirmationModal;
|
|
@@ -32,37 +32,60 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const Button_1 = __importDefault(require("../../../components/Inputs/Buttons/Button"));
|
|
40
36
|
const react_1 = __importStar(require("react"));
|
|
41
|
-
const DeleteConfirmationModal = ({ isOpen, onClose, onConfirm,
|
|
37
|
+
const DeleteConfirmationModal = ({ isOpen, onClose, onConfirm, btnDisabled, btnText, type, text, btnDeleteText, }) => {
|
|
42
38
|
const modalRef = (0, react_1.useRef)(null);
|
|
39
|
+
const cancelRef = (0, react_1.useRef)(null);
|
|
40
|
+
const [isVisible, setIsVisible] = (0, react_1.useState)(false);
|
|
41
|
+
const titleId = (0, react_1.useId)();
|
|
42
|
+
const descriptionId = (0, react_1.useId)();
|
|
43
|
+
// Keep the latest onClose without re-binding listeners on every parent render.
|
|
44
|
+
const onCloseRef = (0, react_1.useRef)(onClose);
|
|
45
|
+
onCloseRef.current = onClose;
|
|
43
46
|
(0, react_1.useEffect)(() => {
|
|
47
|
+
if (!isOpen) {
|
|
48
|
+
setIsVisible(false);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const frame = requestAnimationFrame(() => setIsVisible(true));
|
|
52
|
+
cancelRef.current?.focus();
|
|
53
|
+
const previousOverflow = document.body.style.overflow;
|
|
54
|
+
document.body.style.overflow = 'hidden';
|
|
44
55
|
const handleClickOutside = (event) => {
|
|
45
56
|
if (modalRef.current && !modalRef.current.contains(event.target)) {
|
|
46
|
-
|
|
57
|
+
onCloseRef.current();
|
|
47
58
|
}
|
|
48
59
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
const handleKeyDown = (event) => {
|
|
61
|
+
if (event.key === 'Escape')
|
|
62
|
+
onCloseRef.current();
|
|
63
|
+
};
|
|
64
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
65
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
52
66
|
return () => {
|
|
67
|
+
cancelAnimationFrame(frame);
|
|
68
|
+
document.body.style.overflow = previousOverflow;
|
|
53
69
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
70
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
54
71
|
};
|
|
55
|
-
}, [isOpen
|
|
72
|
+
}, [isOpen]);
|
|
56
73
|
if (!isOpen)
|
|
57
74
|
return null;
|
|
58
|
-
return (react_1.default.createElement("div", { className:
|
|
59
|
-
react_1.default.createElement("div", { ref: modalRef,
|
|
60
|
-
react_1.default.createElement("
|
|
61
|
-
" ",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
return (react_1.default.createElement("div", { className: `fixed inset-0 z-[9999] flex items-center justify-center bg-[#212121]/30 p-4 backdrop-blur-[2px] transition-opacity duration-200 ${isVisible ? 'opacity-100' : 'opacity-0'}` },
|
|
76
|
+
react_1.default.createElement("div", { ref: modalRef, role: "alertdialog", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": descriptionId, className: `w-full max-w-sm rounded-2xl border border-[#E9E9F0] bg-white p-6 shadow-[0_12px_40px_rgba(75,77,98,0.18)] transition-all duration-200 ease-out ${isVisible ? 'translate-y-0 scale-100 opacity-100' : 'translate-y-2 scale-95 opacity-0'}` },
|
|
77
|
+
react_1.default.createElement("div", { className: "flex flex-col items-center text-center" },
|
|
78
|
+
react_1.default.createElement("div", { className: "mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[#f7ddd8]" },
|
|
79
|
+
react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", className: "h-7 w-7 text-[#ba2520]", "aria-hidden": "true" },
|
|
80
|
+
react_1.default.createElement("path", { d: "M3 6h18" }),
|
|
81
|
+
react_1.default.createElement("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
|
|
82
|
+
react_1.default.createElement("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }),
|
|
83
|
+
react_1.default.createElement("path", { d: "M10 11v6" }),
|
|
84
|
+
react_1.default.createElement("path", { d: "M14 11v6" }))),
|
|
85
|
+
react_1.default.createElement("h3", { id: titleId, className: "mb-2 text-lg font-bold text-[#212121]" }, text.titleText),
|
|
86
|
+
react_1.default.createElement("div", { id: descriptionId, className: "text-sm leading-7 text-[#737589]" }, text.confirmationText)),
|
|
87
|
+
react_1.default.createElement("div", { className: "mt-6 flex gap-3" },
|
|
88
|
+
react_1.default.createElement("button", { ref: cancelRef, type: type, disabled: btnDisabled, onClick: onClose, className: "h-11 flex-1 rounded-xl border border-[#E9E9F0] bg-white text-sm font-medium text-[#4B4D62] transition-colors hover:bg-[#F5F6F9] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#d1d5db] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" }, btnText),
|
|
89
|
+
react_1.default.createElement("button", { type: "button", disabled: btnDisabled, onClick: onConfirm, className: "h-11 flex-1 rounded-xl bg-[#ba2520] text-sm font-medium text-white transition-colors hover:bg-[#9e1f1b] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#ba2520]/40 focus-visible:ring-offset-2 active:bg-[#861a17] disabled:cursor-not-allowed disabled:opacity-50" }, btnDeleteText)))));
|
|
67
90
|
};
|
|
68
91
|
exports.default = DeleteConfirmationModal;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as GlobalWrapper } from './components/Wrapper/GlobalWrapper';
|
|
|
3
3
|
export { default as Bounded } from './components/Wrapper/Bounded';
|
|
4
4
|
export { default as ModernTableBounded } from './components/Wrapper/ModernTable/ModernTableBounded';
|
|
5
5
|
export { default as HeaderLayout } from './components/Layout/Headers/HeaderLayout';
|
|
6
|
+
export type { BranchPanelConfig, BranchPanelItem } from './types/Layout/Headers/HeaderLayout';
|
|
6
7
|
export { default as SidebarLayout } from './components/Layout/Sidebar';
|
|
7
8
|
export { default as SelectBranchHeader } from './components/Layout/Headers/HeaderSelectBranch';
|
|
8
9
|
export { default as RangePicker } from './components/Inputs/RangePicker';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import { SecondarySubset, SideBarItem } from "../Sidebar";
|
|
2
3
|
export interface HeaderLayoutProps {
|
|
3
4
|
appVersion: string;
|
|
@@ -22,6 +23,34 @@ export interface HeaderLayoutProps {
|
|
|
22
23
|
languages: LanguageDataType[];
|
|
23
24
|
changeLanguageHandler: (language: LanguageDataType) => void;
|
|
24
25
|
onLogoClickHandler: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Optional branch panel. When given, clicking the branch logo/name opens a
|
|
28
|
+
* workspace-style panel (branch header, primary actions, branches and
|
|
29
|
+
* sub-branches, manage items) instead of the plain branch list.
|
|
30
|
+
*/
|
|
31
|
+
branchPanel?: BranchPanelConfig;
|
|
32
|
+
}
|
|
33
|
+
export interface BranchPanelItem {
|
|
34
|
+
id: number;
|
|
35
|
+
title: string;
|
|
36
|
+
/** Image path, used when `icon` is not given. */
|
|
37
|
+
iconSrc?: string;
|
|
38
|
+
/** Inline icon (e.g. an svg element). Takes precedence over `iconSrc`. */
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export interface BranchPanelConfig {
|
|
42
|
+
/** Small text under the branch name in the panel header. */
|
|
43
|
+
subtitle?: string;
|
|
44
|
+
/** Buttons shown side by side under the header (e.g. Settings, People). */
|
|
45
|
+
primaryActions?: BranchPanelItem[];
|
|
46
|
+
/** Title of the branches / sub-branches section. */
|
|
47
|
+
branchesTitle?: string;
|
|
48
|
+
/** Title of the bottom section. */
|
|
49
|
+
manageTitle?: string;
|
|
50
|
+
/** Items listed at the bottom of the panel. */
|
|
51
|
+
manageItems?: BranchPanelItem[];
|
|
52
|
+
/** Called for primaryActions and manageItems. The panel closes itself. */
|
|
53
|
+
onItemClick: (item: BranchPanelItem) => void;
|
|
25
54
|
}
|
|
26
55
|
export interface iconsSRC {
|
|
27
56
|
logoSRC: string;
|