gov-layout 1.3.6 → 1.3.8

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/index.mjs CHANGED
@@ -1,30 +1,7 @@
1
- import { createContext, useState, useEffect, useRef, useCallback, useContext, useId } from 'react';
1
+ import { createContext, useState, useEffect, useCallback, useRef, useContext, useId } from 'react';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
 
4
- // #style-inject:#style-inject
5
- function styleInject(css, { insertAt } = {}) {
6
- if (typeof document === "undefined") return;
7
- const head = document.head || document.getElementsByTagName("head")[0];
8
- const style = document.createElement("style");
9
- style.type = "text/css";
10
- if (insertAt === "top") {
11
- if (head.firstChild) {
12
- head.insertBefore(style, head.firstChild);
13
- } else {
14
- head.appendChild(style);
15
- }
16
- } else {
17
- head.appendChild(style);
18
- }
19
- if (style.styleSheet) {
20
- style.styleSheet.cssText = css;
21
- } else {
22
- style.appendChild(document.createTextNode(css));
23
- }
24
- }
25
-
26
- // src/styles.css
27
- styleInject(".text-primary,\n.text-text-primary {\n color: var(--color-alias-text-colors-primary, #060d26);\n}\n.text-secondary,\n.text-text-secondary {\n color: var(--color-alias-text-colors-secondary, #1e7d55);\n}\n.text-tertiary,\n.text-text-tertiary {\n color: var(--color-alias-text-colors-tertiary, #475272);\n}\n.text-placeholder,\n.text-text-placeholder {\n color: var(--color-alias-text-colors-placeholder, #707993);\n}\n.text-critical,\n.text-text-critical {\n color: var(--color-alias-text-colors-critical, #f21515);\n}\n");
4
+ // src/sidebar/StaffSidebar.tsx
28
5
  function useDarkMode() {
29
6
  const [isDark, setIsDark] = useState(false);
30
7
  useEffect(() => {
@@ -901,6 +878,18 @@ function SidebarUserProfile({
901
878
  }
902
879
  );
903
880
  }
881
+ function useIsMobile(breakpoint = 768) {
882
+ const [isMobile, setIsMobile] = useState(false);
883
+ useEffect(() => {
884
+ if (typeof window === "undefined") return;
885
+ const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
886
+ setIsMobile(mql.matches);
887
+ const handler = (e) => setIsMobile(e.matches);
888
+ mql.addEventListener("change", handler);
889
+ return () => mql.removeEventListener("change", handler);
890
+ }, [breakpoint]);
891
+ return isMobile;
892
+ }
904
893
  function ToggleIcon({ isOpen }) {
905
894
  return /* @__PURE__ */ jsx(
906
895
  "svg",
@@ -921,6 +910,21 @@ function ToggleIcon({ isOpen }) {
921
910
  }
922
911
  );
923
912
  }
913
+ function HamburgerIcon() {
914
+ return /* @__PURE__ */ jsx("svg", { width: "24", height: "18", viewBox: "0 0 27 18", fill: "none", children: /* @__PURE__ */ jsx(
915
+ "path",
916
+ {
917
+ d: "M1.1875 17.8426C0.851042 17.8426 0.569077 17.7287 0.341604 17.501C0.113868 17.2735 0 16.9914 0 16.6547C0 16.3182 0.113868 16.0363 0.341604 15.8088C0.569077 15.5816 0.851042 15.468 1.1875 15.468H25.7292C26.0656 15.468 26.3476 15.5817 26.5751 15.8092C26.8028 16.0369 26.9167 16.3192 26.9167 16.6559C26.9167 16.9923 26.8028 17.2743 26.5751 17.5018C26.3476 17.729 26.0656 17.8426 25.7292 17.8426H1.1875ZM1.1875 10.1088C0.851042 10.1088 0.569077 9.99492 0.341604 9.76719C0.113868 9.53945 0 9.25735 0 8.9209C0 8.58417 0.113868 8.30221 0.341604 8.075C0.569077 7.84753 0.851042 7.73379 1.1875 7.73379H25.7292C26.0656 7.73379 26.3476 7.84766 26.5751 8.0754C26.8028 8.30313 26.9167 8.58523 26.9167 8.92169C26.9167 9.25841 26.8028 9.54037 26.5751 9.76758C26.3476 9.99506 26.0656 10.1088 25.7292 10.1088H1.1875ZM1.1875 2.3746C0.851042 2.3746 0.569077 2.26087 0.341604 2.0334C0.113868 1.80566 0 1.52343 0 1.18671C0 0.850249 0.113868 0.568284 0.341604 0.340812C0.569077 0.113604 0.851042 0 1.1875 0H25.7292C26.0656 0 26.3476 0.113868 26.5751 0.341604C26.8028 0.569077 26.9167 0.851174 26.9167 1.1879C26.9167 1.52435 26.8028 1.80632 26.5751 2.03379C26.3476 2.261 26.0656 2.3746 25.7292 2.3746H1.1875Z",
918
+ fill: "currentColor"
919
+ }
920
+ ) });
921
+ }
922
+ function CloseIcon() {
923
+ return /* @__PURE__ */ jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
924
+ /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
925
+ /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
926
+ ] });
927
+ }
924
928
  function HelpCircleIcon2() {
925
929
  return /* @__PURE__ */ jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
926
930
  /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
@@ -956,10 +960,13 @@ function StaffSidebar({
956
960
  isOpen: controlledIsOpen,
957
961
  onToggle,
958
962
  onExpandRequest,
959
- topOffset = 0
963
+ topOffset = 0,
964
+ mobileBreakpoint = 768
960
965
  }) {
961
966
  const isDark = useDarkMode();
967
+ const isMobile = useIsMobile(mobileBreakpoint);
962
968
  const [internalOpen, setInternalOpen] = useState(true);
969
+ const [mobileDrawerOpen, setMobileDrawerOpen] = useState(false);
963
970
  const sidebarOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalOpen;
964
971
  const collapsed = collapsible && !sidebarOpen;
965
972
  const collapsedWidth = "64px";
@@ -983,6 +990,283 @@ function StaffSidebar({
983
990
  }
984
991
  }
985
992
  };
993
+ const openDrawer = useCallback(() => setMobileDrawerOpen(true), []);
994
+ const closeDrawer = useCallback(() => setMobileDrawerOpen(false), []);
995
+ const handleMobileNavigate = useCallback((path) => {
996
+ onNavigate(path);
997
+ if (isMobile) closeDrawer();
998
+ }, [onNavigate, isMobile, closeDrawer]);
999
+ useEffect(() => {
1000
+ if (isMobile && mobileDrawerOpen) {
1001
+ const originalOverflow = document.body.style.overflow;
1002
+ document.body.style.overflow = "hidden";
1003
+ return () => {
1004
+ document.body.style.overflow = originalOverflow;
1005
+ };
1006
+ }
1007
+ }, [isMobile, mobileDrawerOpen]);
1008
+ useEffect(() => {
1009
+ if (!isMobile || !mobileDrawerOpen) return;
1010
+ const handler = (e) => {
1011
+ if (e.key === "Escape") closeDrawer();
1012
+ };
1013
+ window.addEventListener("keydown", handler);
1014
+ return () => window.removeEventListener("keydown", handler);
1015
+ }, [isMobile, mobileDrawerOpen, closeDrawer]);
1016
+ if (isMobile) {
1017
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1018
+ /* @__PURE__ */ jsxs(
1019
+ "header",
1020
+ {
1021
+ style: {
1022
+ position: "sticky",
1023
+ top: 0,
1024
+ left: 0,
1025
+ right: 0,
1026
+ height: "60px",
1027
+ background: "linear-gradient(to bottom left, #3AAE7D, #346D55)",
1028
+ display: "flex",
1029
+ alignItems: "center",
1030
+ justifyContent: "space-between",
1031
+ padding: "0 16px",
1032
+ zIndex: 49,
1033
+ boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
1034
+ },
1035
+ children: [
1036
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "12px", flex: 1, minWidth: 0 }, children: [
1037
+ orgLogo ? /* @__PURE__ */ jsx(
1038
+ "img",
1039
+ {
1040
+ src: orgLogo,
1041
+ alt: orgName,
1042
+ style: {
1043
+ width: "40px",
1044
+ height: "40px",
1045
+ borderRadius: "50%",
1046
+ objectFit: "cover",
1047
+ flexShrink: 0,
1048
+ border: "2px solid rgba(255,255,255,0.3)"
1049
+ }
1050
+ }
1051
+ ) : /* @__PURE__ */ jsx("div", { style: {
1052
+ width: "40px",
1053
+ height: "40px",
1054
+ borderRadius: "50%",
1055
+ background: "rgba(255,255,255,0.2)",
1056
+ display: "flex",
1057
+ alignItems: "center",
1058
+ justifyContent: "center",
1059
+ color: "#fff",
1060
+ fontWeight: 700,
1061
+ fontSize: "16px",
1062
+ flexShrink: 0
1063
+ }, children: orgName.slice(0, 2) }),
1064
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
1065
+ /* @__PURE__ */ jsx("p", { style: {
1066
+ color: "#fff",
1067
+ fontWeight: 700,
1068
+ fontSize: "15px",
1069
+ lineHeight: "20px",
1070
+ margin: 0,
1071
+ overflow: "hidden",
1072
+ textOverflow: "ellipsis",
1073
+ whiteSpace: "nowrap"
1074
+ }, children: orgName }),
1075
+ orgSubtitle && /* @__PURE__ */ jsx("p", { style: {
1076
+ color: "rgba(255,255,255,0.75)",
1077
+ fontSize: "12px",
1078
+ lineHeight: "16px",
1079
+ margin: 0,
1080
+ overflow: "hidden",
1081
+ textOverflow: "ellipsis",
1082
+ whiteSpace: "nowrap"
1083
+ }, children: orgSubtitle })
1084
+ ] })
1085
+ ] }),
1086
+ /* @__PURE__ */ jsx(
1087
+ "button",
1088
+ {
1089
+ onClick: openDrawer,
1090
+ "aria-label": "\u0E40\u0E1B\u0E34\u0E14\u0E40\u0E21\u0E19\u0E39",
1091
+ style: {
1092
+ width: "44px",
1093
+ height: "44px",
1094
+ borderRadius: "10px",
1095
+ border: "none",
1096
+ background: "rgba(255,255,255,0.12)",
1097
+ cursor: "pointer",
1098
+ display: "flex",
1099
+ alignItems: "center",
1100
+ justifyContent: "center",
1101
+ color: "#ffffff",
1102
+ flexShrink: 0,
1103
+ transition: "background-color 0.15s ease",
1104
+ WebkitTapHighlightColor: "transparent"
1105
+ },
1106
+ children: /* @__PURE__ */ jsx(HamburgerIcon, {})
1107
+ }
1108
+ )
1109
+ ]
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ jsx(
1113
+ "div",
1114
+ {
1115
+ onClick: closeDrawer,
1116
+ style: {
1117
+ position: "fixed",
1118
+ inset: 0,
1119
+ background: "rgba(0,0,0,0.45)",
1120
+ zIndex: 99,
1121
+ opacity: mobileDrawerOpen ? 1 : 0,
1122
+ pointerEvents: mobileDrawerOpen ? "auto" : "none",
1123
+ transition: "opacity 0.3s ease",
1124
+ WebkitTapHighlightColor: "transparent"
1125
+ }
1126
+ }
1127
+ ),
1128
+ /* @__PURE__ */ jsxs(
1129
+ "aside",
1130
+ {
1131
+ className,
1132
+ style: {
1133
+ position: "fixed",
1134
+ top: 0,
1135
+ left: 0,
1136
+ bottom: 0,
1137
+ width: "min(85vw, 320px)",
1138
+ background: isDark ? "#1e293b" : "#fff",
1139
+ zIndex: 100,
1140
+ display: "flex",
1141
+ flexDirection: "column",
1142
+ overflow: "hidden",
1143
+ boxShadow: mobileDrawerOpen ? "4px 0 24px rgba(0,0,0,0.2)" : "none",
1144
+ transform: mobileDrawerOpen ? "translateX(0)" : "translateX(-100%)",
1145
+ transition: "transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
1146
+ color: isDark ? "#ffffff" : void 0
1147
+ },
1148
+ children: [
1149
+ /* @__PURE__ */ jsxs("div", { style: {
1150
+ display: "flex",
1151
+ alignItems: "center",
1152
+ justifyContent: "space-between",
1153
+ padding: "16px 16px 16px 20px",
1154
+ background: "linear-gradient(to bottom left, #3AAE7D, #346D55)",
1155
+ flexShrink: 0
1156
+ }, children: [
1157
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "12px", flex: 1, minWidth: 0 }, children: [
1158
+ orgLogo ? /* @__PURE__ */ jsx(
1159
+ "img",
1160
+ {
1161
+ src: orgLogo,
1162
+ alt: orgName,
1163
+ style: {
1164
+ width: "44px",
1165
+ height: "44px",
1166
+ borderRadius: "50%",
1167
+ objectFit: "cover",
1168
+ flexShrink: 0,
1169
+ border: "2px solid rgba(255,255,255,0.3)"
1170
+ }
1171
+ }
1172
+ ) : /* @__PURE__ */ jsx("div", { style: {
1173
+ width: "44px",
1174
+ height: "44px",
1175
+ borderRadius: "50%",
1176
+ background: "rgba(255,255,255,0.2)",
1177
+ display: "flex",
1178
+ alignItems: "center",
1179
+ justifyContent: "center",
1180
+ color: "#fff",
1181
+ fontWeight: 700,
1182
+ fontSize: "16px",
1183
+ flexShrink: 0
1184
+ }, children: orgName.slice(0, 2) }),
1185
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
1186
+ /* @__PURE__ */ jsx("p", { style: {
1187
+ color: "#fff",
1188
+ fontWeight: 700,
1189
+ fontSize: "15px",
1190
+ lineHeight: "20px",
1191
+ margin: 0,
1192
+ overflow: "hidden",
1193
+ textOverflow: "ellipsis",
1194
+ whiteSpace: "nowrap"
1195
+ }, children: orgName }),
1196
+ orgSubtitle && /* @__PURE__ */ jsx("p", { style: {
1197
+ color: "rgba(255,255,255,0.75)",
1198
+ fontSize: "12px",
1199
+ lineHeight: "16px",
1200
+ margin: 0
1201
+ }, children: orgSubtitle })
1202
+ ] })
1203
+ ] }),
1204
+ /* @__PURE__ */ jsx(
1205
+ "button",
1206
+ {
1207
+ onClick: closeDrawer,
1208
+ "aria-label": "\u0E1B\u0E34\u0E14\u0E40\u0E21\u0E19\u0E39",
1209
+ style: {
1210
+ width: "40px",
1211
+ height: "40px",
1212
+ borderRadius: "10px",
1213
+ border: "none",
1214
+ background: "rgba(255,255,255,0.15)",
1215
+ cursor: "pointer",
1216
+ display: "flex",
1217
+ alignItems: "center",
1218
+ justifyContent: "center",
1219
+ color: "#ffffff",
1220
+ flexShrink: 0,
1221
+ transition: "background-color 0.15s ease",
1222
+ WebkitTapHighlightColor: "transparent"
1223
+ },
1224
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
1225
+ }
1226
+ )
1227
+ ] }),
1228
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, overflowY: "auto", minHeight: 0 }, children: /* @__PURE__ */ jsx(
1229
+ SidebarMenu,
1230
+ {
1231
+ menuItems,
1232
+ onItemClick: handleMobileNavigate,
1233
+ currentPath,
1234
+ collapsed: false
1235
+ }
1236
+ ) }),
1237
+ /* @__PURE__ */ jsxs("div", { style: { flexShrink: 0 }, children: [
1238
+ resolvedBottomMenu && resolvedBottomMenu.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
1239
+ /* @__PURE__ */ jsx("hr", { style: {
1240
+ border: "none",
1241
+ borderTop: `1px solid ${isDark ? "#374151" : "var(--color-border-colors-neutral, #c8cedd)"}`,
1242
+ margin: "4px 12px"
1243
+ } }),
1244
+ /* @__PURE__ */ jsx(
1245
+ SidebarMenu,
1246
+ {
1247
+ menuItems: resolvedBottomMenu,
1248
+ onItemClick: handleMobileNavigate,
1249
+ currentPath,
1250
+ collapsed: false
1251
+ }
1252
+ )
1253
+ ] }),
1254
+ /* @__PURE__ */ jsx(
1255
+ SidebarUserProfile,
1256
+ {
1257
+ user,
1258
+ roleLabel,
1259
+ onLogout,
1260
+ onProfile,
1261
+ collapsed: false
1262
+ }
1263
+ )
1264
+ ] })
1265
+ ]
1266
+ }
1267
+ )
1268
+ ] });
1269
+ }
986
1270
  return /* @__PURE__ */ jsxs(Fragment, { children: [
987
1271
  /* @__PURE__ */ jsxs(
988
1272
  "aside",
@@ -1098,7 +1382,7 @@ function BellIcon2() {
1098
1382
  }
1099
1383
  ) });
1100
1384
  }
1101
- function HamburgerIcon() {
1385
+ function HamburgerIcon2() {
1102
1386
  return /* @__PURE__ */ jsx("svg", { width: "24", height: "18", viewBox: "0 0 27 18", fill: "none", children: /* @__PURE__ */ jsx(
1103
1387
  "path",
1104
1388
  {
@@ -1614,7 +1898,7 @@ function UserHeader({
1614
1898
  onMouseLeave: (e) => {
1615
1899
  e.currentTarget.style.backgroundColor = "transparent";
1616
1900
  },
1617
- children: /* @__PURE__ */ jsx(HamburgerIcon, {})
1901
+ children: /* @__PURE__ */ jsx(HamburgerIcon2, {})
1618
1902
  }
1619
1903
  )
1620
1904
  ] })