gov-layout 1.1.4 → 1.1.6

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,4 +1,4 @@
1
- import { useState, useRef, useEffect } from 'react';
1
+ import { createContext, useState, useRef, useEffect, useCallback, useContext } from 'react';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
 
4
4
  // src/sidebar/StaffSidebar.tsx
@@ -1209,7 +1209,379 @@ function UserSidebar({
1209
1209
  )
1210
1210
  ] });
1211
1211
  }
1212
+ var FONT_SIZE_OPTIONS = [
1213
+ { key: "xsmall", label: "\u0E40\u0E25\u0E47\u0E01\u0E21\u0E32\u0E01", scale: 0.8 },
1214
+ { key: "small", label: "\u0E40\u0E25\u0E47\u0E01", scale: 0.9 },
1215
+ { key: "medium", label: "\u0E01\u0E25\u0E32\u0E07", scale: 1 },
1216
+ { key: "large", label: "\u0E43\u0E2B\u0E0D\u0E48", scale: 1.2 },
1217
+ { key: "xlarge", label: "\u0E43\u0E2B\u0E0D\u0E48\u0E21\u0E32\u0E01", scale: 1.4 }
1218
+ ];
1219
+ var BASE_FONT_SIZES = {
1220
+ "--font-alias-mobile-body-fontsize": 16,
1221
+ "--font-alias-mobile-h1-fontsize": 28,
1222
+ "--font-alias-mobile-h2-fontsize": 24,
1223
+ "--font-alias-mobile-h3-fontsize": 20,
1224
+ "--font-alias-mobile-sub-fontsize": 14,
1225
+ "--font-alias-mobile-button-fontsize": 16
1226
+ };
1227
+ var SettingsContext = createContext(void 0);
1228
+ function SettingsProvider({
1229
+ children,
1230
+ defaultTheme = "light",
1231
+ defaultFontSize = "medium",
1232
+ themeStorageKey = "app-theme",
1233
+ fontSizeStorageKey = "app-font-size"
1234
+ }) {
1235
+ const [theme, setThemeState] = useState(defaultTheme);
1236
+ const [fontSize, setFontSizeState] = useState(defaultFontSize);
1237
+ useEffect(() => {
1238
+ try {
1239
+ const savedTheme = localStorage.getItem(themeStorageKey);
1240
+ if (savedTheme === "light" || savedTheme === "dark") {
1241
+ setThemeState(savedTheme);
1242
+ }
1243
+ const savedFontSize = localStorage.getItem(fontSizeStorageKey);
1244
+ if (savedFontSize && FONT_SIZE_OPTIONS.some((o) => o.key === savedFontSize)) {
1245
+ setFontSizeState(savedFontSize);
1246
+ }
1247
+ } catch {
1248
+ }
1249
+ }, [themeStorageKey, fontSizeStorageKey]);
1250
+ useEffect(() => {
1251
+ const root = document.documentElement;
1252
+ if (theme === "dark") {
1253
+ root.classList.add("dark");
1254
+ } else {
1255
+ root.classList.remove("dark");
1256
+ }
1257
+ try {
1258
+ localStorage.setItem(themeStorageKey, theme);
1259
+ } catch {
1260
+ }
1261
+ }, [theme, themeStorageKey]);
1262
+ useEffect(() => {
1263
+ const option = FONT_SIZE_OPTIONS.find((o) => o.key === fontSize) || FONT_SIZE_OPTIONS[2];
1264
+ const root = document.documentElement;
1265
+ Object.entries(BASE_FONT_SIZES).forEach(([varName, baseValue]) => {
1266
+ root.style.setProperty(varName, `${baseValue * option.scale}px`);
1267
+ });
1268
+ root.style.fontSize = `${16 * option.scale}px`;
1269
+ root.style.setProperty("--global-font-scale", option.scale.toString());
1270
+ document.body.style.zoom = option.scale.toString();
1271
+ try {
1272
+ localStorage.setItem(fontSizeStorageKey, fontSize);
1273
+ } catch {
1274
+ }
1275
+ }, [fontSize, fontSizeStorageKey]);
1276
+ const setTheme = useCallback((t) => {
1277
+ setThemeState(t);
1278
+ }, []);
1279
+ const toggleTheme = useCallback(() => {
1280
+ setThemeState((prev) => prev === "light" ? "dark" : "light");
1281
+ }, []);
1282
+ const setFontSize = useCallback((s) => {
1283
+ setFontSizeState(s);
1284
+ }, []);
1285
+ const fontSizeOption = FONT_SIZE_OPTIONS.find((o) => o.key === fontSize) || FONT_SIZE_OPTIONS[2];
1286
+ return /* @__PURE__ */ jsx(
1287
+ SettingsContext.Provider,
1288
+ {
1289
+ value: { theme, setTheme, toggleTheme, fontSize, setFontSize, fontSizeOption },
1290
+ children
1291
+ }
1292
+ );
1293
+ }
1294
+ function useSettings() {
1295
+ const context = useContext(SettingsContext);
1296
+ if (!context) {
1297
+ throw new Error("useSettings must be used within <SettingsProvider>");
1298
+ }
1299
+ return context;
1300
+ }
1301
+ function SunIcon() {
1302
+ return /* @__PURE__ */ jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1303
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "5" }),
1304
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "1", x2: "12", y2: "3" }),
1305
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "21", x2: "12", y2: "23" }),
1306
+ /* @__PURE__ */ jsx("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }),
1307
+ /* @__PURE__ */ jsx("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }),
1308
+ /* @__PURE__ */ jsx("line", { x1: "1", y1: "12", x2: "3", y2: "12" }),
1309
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "23", y2: "12" }),
1310
+ /* @__PURE__ */ jsx("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }),
1311
+ /* @__PURE__ */ jsx("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })
1312
+ ] });
1313
+ }
1314
+ function MoonIcon() {
1315
+ return /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) });
1316
+ }
1317
+ function ThemeSettings({ onBack }) {
1318
+ const { theme, setTheme } = useSettings();
1319
+ const options = [
1320
+ { key: "light", label: "\u0E2A\u0E27\u0E48\u0E32\u0E07", icon: /* @__PURE__ */ jsx(SunIcon, {}), bg: "#fff", text: "#111" },
1321
+ { key: "dark", label: "\u0E21\u0E37\u0E14", icon: /* @__PURE__ */ jsx(MoonIcon, {}), bg: "#1f2937", text: "#f9fafb" }
1322
+ ];
1323
+ return /* @__PURE__ */ jsxs("div", { children: [
1324
+ onBack && /* @__PURE__ */ jsxs(
1325
+ "button",
1326
+ {
1327
+ onClick: onBack,
1328
+ style: {
1329
+ display: "flex",
1330
+ alignItems: "center",
1331
+ gap: 8,
1332
+ padding: "12px 16px",
1333
+ width: "100%",
1334
+ border: "none",
1335
+ background: "transparent",
1336
+ cursor: "pointer",
1337
+ fontSize: 15,
1338
+ fontWeight: 600,
1339
+ color: "var(--color-alias-text-colors-primary, #060d26)"
1340
+ },
1341
+ children: [
1342
+ /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { d: "M19 12H5M12 19l-7-7 7-7" }) }),
1343
+ "\u0E42\u0E2B\u0E21\u0E14\u0E2A\u0E27\u0E48\u0E32\u0E07/\u0E21\u0E37\u0E14"
1344
+ ]
1345
+ }
1346
+ ),
1347
+ /* @__PURE__ */ jsx("div", { style: { padding: "12px 16px", display: "flex", gap: 12 }, children: options.map((opt) => {
1348
+ const isSelected = theme === opt.key;
1349
+ return /* @__PURE__ */ jsxs(
1350
+ "button",
1351
+ {
1352
+ onClick: () => setTheme(opt.key),
1353
+ style: {
1354
+ flex: 1,
1355
+ padding: "20px 12px",
1356
+ borderRadius: 12,
1357
+ border: isSelected ? "2px solid var(--color-alias-color-brand-primary, #1e7d55)" : "2px solid var(--color-border-colors-neutral, #c8cedd)",
1358
+ background: opt.bg,
1359
+ cursor: "pointer",
1360
+ display: "flex",
1361
+ flexDirection: "column",
1362
+ alignItems: "center",
1363
+ gap: 8,
1364
+ transition: "all 0.2s ease"
1365
+ },
1366
+ children: [
1367
+ /* @__PURE__ */ jsx("span", { style: { color: opt.text }, children: opt.icon }),
1368
+ /* @__PURE__ */ jsx("span", { style: {
1369
+ fontSize: 13,
1370
+ fontWeight: isSelected ? 700 : 500,
1371
+ color: opt.text
1372
+ }, children: opt.label }),
1373
+ isSelected && /* @__PURE__ */ jsx("span", { style: {
1374
+ width: 20,
1375
+ height: 20,
1376
+ borderRadius: "50%",
1377
+ background: "var(--color-alias-color-brand-primary, #1e7d55)",
1378
+ display: "flex",
1379
+ alignItems: "center",
1380
+ justifyContent: "center"
1381
+ }, children: /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "#fff", strokeWidth: "3", children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) }) })
1382
+ ]
1383
+ },
1384
+ opt.key
1385
+ );
1386
+ }) })
1387
+ ] });
1388
+ }
1389
+ function FontSizeSettings({ onBack }) {
1390
+ const { fontSize, setFontSize, fontSizeOption } = useSettings();
1391
+ return /* @__PURE__ */ jsxs("div", { children: [
1392
+ onBack && /* @__PURE__ */ jsxs(
1393
+ "button",
1394
+ {
1395
+ onClick: onBack,
1396
+ style: {
1397
+ display: "flex",
1398
+ alignItems: "center",
1399
+ gap: 8,
1400
+ padding: "12px 16px",
1401
+ width: "100%",
1402
+ border: "none",
1403
+ background: "transparent",
1404
+ cursor: "pointer",
1405
+ fontSize: 15,
1406
+ fontWeight: 600,
1407
+ color: "var(--color-alias-text-colors-primary, #060d26)"
1408
+ },
1409
+ children: [
1410
+ /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { d: "M19 12H5M12 19l-7-7 7-7" }) }),
1411
+ "\u0E02\u0E19\u0E32\u0E14\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23"
1412
+ ]
1413
+ }
1414
+ ),
1415
+ /* @__PURE__ */ jsxs("div", { style: {
1416
+ margin: "8px 16px",
1417
+ padding: "16px",
1418
+ borderRadius: 10,
1419
+ background: "var(--color-foundations-fuji-pallet-light, #f5f6fa)",
1420
+ textAlign: "center"
1421
+ }, children: [
1422
+ /* @__PURE__ */ jsx("p", { style: {
1423
+ fontSize: `${16 * fontSizeOption.scale}px`,
1424
+ fontWeight: 500,
1425
+ color: "var(--color-alias-text-colors-primary, #060d26)",
1426
+ margin: 0
1427
+ }, children: "\u0E15\u0E31\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21" }),
1428
+ /* @__PURE__ */ jsxs("p", { style: {
1429
+ fontSize: `${12 * fontSizeOption.scale}px`,
1430
+ color: "var(--color-alias-text-colors-tertiary, #475272)",
1431
+ margin: "4px 0 0"
1432
+ }, children: [
1433
+ "\xD7",
1434
+ fontSizeOption.scale
1435
+ ] })
1436
+ ] }),
1437
+ /* @__PURE__ */ jsx("div", { style: { padding: "8px 16px", display: "flex", flexDirection: "column", gap: 4 }, children: FONT_SIZE_OPTIONS.map((opt) => {
1438
+ const isSelected = fontSize === opt.key;
1439
+ return /* @__PURE__ */ jsxs(
1440
+ "button",
1441
+ {
1442
+ onClick: () => setFontSize(opt.key),
1443
+ onMouseEnter: (e) => {
1444
+ if (!isSelected) e.currentTarget.style.backgroundColor = "#f9fafb";
1445
+ },
1446
+ onMouseLeave: (e) => {
1447
+ if (!isSelected) e.currentTarget.style.backgroundColor = "transparent";
1448
+ },
1449
+ style: {
1450
+ display: "flex",
1451
+ alignItems: "center",
1452
+ justifyContent: "space-between",
1453
+ padding: "12px 14px",
1454
+ borderRadius: 8,
1455
+ border: isSelected ? "2px solid var(--color-alias-color-brand-primary, #1e7d55)" : "1px solid transparent",
1456
+ background: isSelected ? "color-mix(in srgb, var(--color-alias-color-brand-primary, #1e7d55) 8%, transparent)" : "transparent",
1457
+ cursor: "pointer",
1458
+ transition: "all 0.15s ease"
1459
+ },
1460
+ children: [
1461
+ /* @__PURE__ */ jsx("span", { style: {
1462
+ fontSize: `${14 * opt.scale}px`,
1463
+ fontWeight: isSelected ? 600 : 400,
1464
+ color: isSelected ? "var(--color-alias-color-brand-primary, #1e7d55)" : "var(--color-alias-text-colors-primary, #060d26)"
1465
+ }, children: opt.label }),
1466
+ /* @__PURE__ */ jsxs("span", { style: {
1467
+ fontSize: 12,
1468
+ color: "var(--color-alias-text-colors-tertiary, #475272)"
1469
+ }, children: [
1470
+ "\xD7",
1471
+ opt.scale
1472
+ ] })
1473
+ ]
1474
+ },
1475
+ opt.key
1476
+ );
1477
+ }) })
1478
+ ] });
1479
+ }
1480
+ function FontSizeIcon() {
1481
+ return /* @__PURE__ */ jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1482
+ /* @__PURE__ */ jsx("polyline", { points: "4 7 4 4 20 4 20 7" }),
1483
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "20", x2: "15", y2: "20" }),
1484
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "4", x2: "12", y2: "20" })
1485
+ ] });
1486
+ }
1487
+ function PaletteIcon() {
1488
+ return /* @__PURE__ */ jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1489
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
1490
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "8", r: "1.5", fill: "currentColor" }),
1491
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "14", r: "1.5", fill: "currentColor" }),
1492
+ /* @__PURE__ */ jsx("circle", { cx: "16", cy: "14", r: "1.5", fill: "currentColor" })
1493
+ ] });
1494
+ }
1495
+ function SettingsPanel({ className, showTheme = true }) {
1496
+ const [view, setView] = useState("menu");
1497
+ if (view === "theme" && showTheme) {
1498
+ return /* @__PURE__ */ jsx(ThemeSettings, { onBack: () => setView("menu") });
1499
+ }
1500
+ if (view === "fontSize") {
1501
+ return /* @__PURE__ */ jsx(FontSizeSettings, { onBack: () => setView("menu") });
1502
+ }
1503
+ const allMenuItems = [
1504
+ {
1505
+ id: "fontSize",
1506
+ icon: /* @__PURE__ */ jsx(FontSizeIcon, {}),
1507
+ label: "\u0E02\u0E19\u0E32\u0E14\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",
1508
+ description: "\u0E40\u0E25\u0E47\u0E01\u0E21\u0E32\u0E01 / \u0E40\u0E25\u0E47\u0E01 / \u0E01\u0E25\u0E32\u0E07 / \u0E43\u0E2B\u0E0D\u0E48 / \u0E43\u0E2B\u0E0D\u0E48\u0E21\u0E32\u0E01",
1509
+ onClick: () => setView("fontSize")
1510
+ },
1511
+ ...showTheme ? [{
1512
+ id: "theme",
1513
+ icon: /* @__PURE__ */ jsx(PaletteIcon, {}),
1514
+ label: "\u0E42\u0E2B\u0E21\u0E14\u0E2A\u0E27\u0E48\u0E32\u0E07/\u0E21\u0E37\u0E14",
1515
+ description: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E18\u0E35\u0E21\u0E41\u0E2D\u0E1B\u0E1E\u0E25\u0E34\u0E40\u0E04\u0E0A\u0E31\u0E19",
1516
+ onClick: () => setView("theme")
1517
+ }] : []
1518
+ ];
1519
+ return /* @__PURE__ */ jsxs("div", { className, children: [
1520
+ /* @__PURE__ */ jsx("div", { style: {
1521
+ padding: "16px",
1522
+ borderBottom: "1px solid var(--color-border-colors-neutral, #e5e7eb)"
1523
+ }, children: /* @__PURE__ */ jsx("h3", { style: {
1524
+ fontSize: 16,
1525
+ fontWeight: 700,
1526
+ margin: 0,
1527
+ color: "var(--color-alias-text-colors-primary, #060d26)"
1528
+ }, children: "\u0E15\u0E31\u0E49\u0E07\u0E04\u0E48\u0E32\u0E23\u0E30\u0E1A\u0E1A" }) }),
1529
+ /* @__PURE__ */ jsx("div", { style: { padding: "8px", display: "flex", flexDirection: "column", gap: 2 }, children: allMenuItems.map((item) => /* @__PURE__ */ jsxs(
1530
+ "button",
1531
+ {
1532
+ onClick: item.onClick,
1533
+ onMouseEnter: (e) => {
1534
+ e.currentTarget.style.backgroundColor = "#f9fafb";
1535
+ },
1536
+ onMouseLeave: (e) => {
1537
+ e.currentTarget.style.backgroundColor = "transparent";
1538
+ },
1539
+ style: {
1540
+ display: "flex",
1541
+ alignItems: "center",
1542
+ gap: 14,
1543
+ padding: "14px 12px",
1544
+ borderRadius: 10,
1545
+ border: "none",
1546
+ background: "transparent",
1547
+ cursor: "pointer",
1548
+ width: "100%",
1549
+ textAlign: "left",
1550
+ transition: "background-color 0.15s ease"
1551
+ },
1552
+ children: [
1553
+ /* @__PURE__ */ jsx("span", { style: {
1554
+ width: 40,
1555
+ height: 40,
1556
+ borderRadius: 10,
1557
+ background: "var(--color-foundations-fuji-pallet-light, #ebedf5)",
1558
+ display: "flex",
1559
+ alignItems: "center",
1560
+ justifyContent: "center",
1561
+ color: "var(--color-alias-color-brand-primary, #1e7d55)",
1562
+ flexShrink: 0
1563
+ }, children: item.icon }),
1564
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
1565
+ /* @__PURE__ */ jsx("p", { style: {
1566
+ fontSize: 15,
1567
+ fontWeight: 600,
1568
+ margin: 0,
1569
+ color: "var(--color-alias-text-colors-primary, #060d26)"
1570
+ }, children: item.label }),
1571
+ /* @__PURE__ */ jsx("p", { style: {
1572
+ fontSize: 12,
1573
+ margin: "2px 0 0",
1574
+ color: "var(--color-alias-text-colors-tertiary, #475272)"
1575
+ }, children: item.description })
1576
+ ] }),
1577
+ /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { d: "M9 18l6-6-6-6" }) })
1578
+ ]
1579
+ },
1580
+ item.id
1581
+ )) })
1582
+ ] });
1583
+ }
1212
1584
 
1213
- export { SidebarHeader, SidebarMenu, SidebarUserProfile, StaffSidebar, UserHeader, UserSidebar };
1585
+ export { FONT_SIZE_OPTIONS, FontSizeSettings, SettingsPanel, SettingsProvider, SidebarHeader, SidebarMenu, SidebarUserProfile, StaffSidebar, ThemeSettings, UserHeader, UserSidebar, useSettings };
1214
1586
  //# sourceMappingURL=index.mjs.map
1215
1587
  //# sourceMappingURL=index.mjs.map