@eintrek/erp-shell 0.1.73 → 0.1.74

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.cjs CHANGED
@@ -14,7 +14,7 @@ var Link = require('next/link');
14
14
  var reactDom = require('react-dom');
15
15
  var nextThemes = require('next-themes');
16
16
  var axios = require('axios');
17
- var guideRuntime = require('./chunks/guide-runtime-CLVSNkTN.cjs');
17
+ var guideRuntime = require('./chunks/guide-runtime-YS2nUhwS.cjs');
18
18
  var reactQueryDevtools = require('@tanstack/react-query-devtools');
19
19
  require('@floating-ui/dom');
20
20
 
@@ -1740,7 +1740,7 @@ function platformApiBase(app) {
1740
1740
  * This package's version, attached to help messages so the back office can
1741
1741
  * tell which shell a report came from. Keep in step with package.json.
1742
1742
  */
1743
- const SHELL_VERSION = "0.1.73";
1743
+ const SHELL_VERSION = "0.1.74";
1744
1744
 
1745
1745
  const HELP_APP_LABEL = {
1746
1746
  platform: "แพลตฟอร์ม",
@@ -2572,15 +2572,24 @@ const BUTTON_CLASS = "grid size-[34px] shrink-0 place-items-center rounded-lg te
2572
2572
  * The ช่วยเหลือ button in the top bar. Drawn in the header's ink (the
2573
2573
  * --header-* variables of the workspace chrome, white on the brand chrome).
2574
2574
  *
2575
- * When this user has a guided tour in this app, it opens a small menu:
2576
- * "ไกด์เริ่มต้น n/N" (the quest panel) and "ติดต่อทีมช่วยเหลือ" (the help
2577
- * dialog). Otherwise one press opens the help dialog, as before.
2575
+ * When this user has something to open here, it opens a small menu:
2576
+ * "คู่มือหน้านี้" (this page's guide), "ไกด์เริ่มต้น n/N" (the quest
2577
+ * panel), "คู่มือทุกหน้า" (the panel's page guides) and "ติดต่อทีมช่วยเหลือ"
2578
+ * (the help dialog), each only when it has something. Otherwise one press
2579
+ * opens the help dialog, as before.
2578
2580
  */
2579
2581
  function HelpButton({ className }) {
2580
2582
  const guide = guideRuntime.useGuideEntry();
2583
+ const pages = guideRuntime.usePageGuides();
2581
2584
  const toGuide = React.useRef(false);
2582
2585
  const cls = BUTTON_CLASS + (className ? ` ${className}` : "");
2583
- if (!guideRuntime.guideMenuShown(guide)) {
2586
+ const items = guideRuntime.guideMenuItems(guide, pages);
2587
+ // The tour takes focus (a step, the panel); the button must not take it back.
2588
+ const toTour = (open) => () => {
2589
+ toGuide.current = true;
2590
+ setTimeout(open, 0);
2591
+ };
2592
+ if (!items.length) {
2584
2593
  return (jsxRuntime.jsx("button", { type: "button", onClick: openHelp, "aria-label": "\u0E0A\u0E48\u0E27\u0E22\u0E40\u0E2B\u0E25\u0E37\u0E2D", title: "\u0E0A\u0E48\u0E27\u0E22\u0E40\u0E2B\u0E25\u0E37\u0E2D", className: cls, "data-guide": "shell.help", children: jsxRuntime.jsx(lucideReact.CircleHelp, { className: "size-5", strokeWidth: 1.65 }) }));
2585
2594
  }
2586
2595
  return (jsxRuntime.jsxs(erpTheme.DropdownMenu, { children: [jsxRuntime.jsx(erpTheme.DropdownMenuTrigger, { asChild: true, children: jsxRuntime.jsx("button", { type: "button", "aria-label": "\u0E0A\u0E48\u0E27\u0E22\u0E40\u0E2B\u0E25\u0E37\u0E2D", title: "\u0E0A\u0E48\u0E27\u0E22\u0E40\u0E2B\u0E25\u0E37\u0E2D", className: cls, "data-guide": "shell.help", children: jsxRuntime.jsx(lucideReact.CircleHelp, { className: "size-5", strokeWidth: 1.65 }) }) }), jsxRuntime.jsxs(erpTheme.DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-64", onCloseAutoFocus: e => {
@@ -2589,10 +2598,7 @@ function HelpButton({ className }) {
2589
2598
  e.preventDefault();
2590
2599
  toGuide.current = false;
2591
2600
  }
2592
- }, children: [jsxRuntime.jsxs(erpTheme.DropdownMenuItem, { onSelect: () => {
2593
- toGuide.current = true;
2594
- setTimeout(guideRuntime.openGuidePanel, 0);
2595
- }, className: "gap-2.5", children: [jsxRuntime.jsx(lucideReact.Flag, { className: "size-4" }), jsxRuntime.jsx("span", { className: "flex-1", children: "\u0E44\u0E01\u0E14\u0E4C\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19" }), jsxRuntime.jsxs("span", { className: "text-xs font-semibold text-primary tabular-nums", children: [guide.done, "/", guide.total] })] }), jsxRuntime.jsxs(erpTheme.DropdownMenuItem, { onSelect: () => setTimeout(openHelp, 0), className: "gap-2.5", children: [jsxRuntime.jsx(lucideReact.MessageCircle, { className: "size-4" }), jsxRuntime.jsx("span", { className: "flex-1", children: "\u0E15\u0E34\u0E14\u0E15\u0E48\u0E2D\u0E17\u0E35\u0E21\u0E0A\u0E48\u0E27\u0E22\u0E40\u0E2B\u0E25\u0E37\u0E2D" })] })] })] }));
2601
+ }, children: [items.includes("page") ? (jsxRuntime.jsxs(erpTheme.DropdownMenuItem, { onSelect: toTour(guideRuntime.openPageGuide), className: "gap-2.5", children: [jsxRuntime.jsx(lucideReact.BookOpen, { className: "size-4" }), jsxRuntime.jsx("span", { className: "flex-1", children: "\u0E04\u0E39\u0E48\u0E21\u0E37\u0E2D\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49" })] })) : null, items.includes("missions") && guide ? (jsxRuntime.jsxs(erpTheme.DropdownMenuItem, { onSelect: toTour(guideRuntime.openGuidePanel), className: "gap-2.5", children: [jsxRuntime.jsx(lucideReact.Flag, { className: "size-4" }), jsxRuntime.jsx("span", { className: "flex-1", children: "\u0E44\u0E01\u0E14\u0E4C\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19" }), jsxRuntime.jsxs("span", { className: "text-xs font-semibold text-primary tabular-nums", children: [guide.done, "/", guide.total] })] })) : null, items.includes("pages") ? (jsxRuntime.jsxs(erpTheme.DropdownMenuItem, { onSelect: toTour(guideRuntime.openPagesPanel), className: "gap-2.5", children: [jsxRuntime.jsx(lucideReact.Library, { className: "size-4" }), jsxRuntime.jsx("span", { className: "flex-1", children: "\u0E04\u0E39\u0E48\u0E21\u0E37\u0E2D\u0E17\u0E38\u0E01\u0E2B\u0E19\u0E49\u0E32" })] })) : null, jsxRuntime.jsxs(erpTheme.DropdownMenuItem, { onSelect: () => setTimeout(openHelp, 0), className: "gap-2.5", children: [jsxRuntime.jsx(lucideReact.MessageCircle, { className: "size-4" }), jsxRuntime.jsx("span", { className: "flex-1", children: "\u0E15\u0E34\u0E14\u0E15\u0E48\u0E2D\u0E17\u0E35\u0E21\u0E0A\u0E48\u0E27\u0E22\u0E40\u0E2B\u0E25\u0E37\u0E2D" })] })] })] }));
2596
2602
  }
2597
2603
 
2598
2604
  const hasPaginationShape = (payload) => {
@@ -4443,11 +4449,16 @@ exports.GuideProgressConflict = guideRuntime.GuideProgressConflict;
4443
4449
  exports.GuideRuntime = guideRuntime.GuideRuntime;
4444
4450
  exports.emitGuideEvent = guideRuntime.emitGuideEvent;
4445
4451
  exports.guideAnchor = guideRuntime.guideAnchor;
4452
+ exports.guideMenuItems = guideRuntime.guideMenuItems;
4446
4453
  exports.guideMenuShown = guideRuntime.guideMenuShown;
4447
4454
  exports.openGuidePanel = guideRuntime.openGuidePanel;
4455
+ exports.openPageGuide = guideRuntime.openPageGuide;
4456
+ exports.openPagesPanel = guideRuntime.openPagesPanel;
4448
4457
  exports.reportApiCall = guideRuntime.reportApiCall;
4449
4458
  exports.reportApiEvent = guideRuntime.reportApiEvent;
4450
4459
  exports.useGuideEntry = guideRuntime.useGuideEntry;
4460
+ exports.usePageGuideEntry = guideRuntime.usePageGuideEntry;
4461
+ exports.usePageGuides = guideRuntime.usePageGuides;
4451
4462
  exports.AccessDenied = AccessDenied;
4452
4463
  exports.ApiError = ApiError;
4453
4464
  exports.AppBreadcrumb = AppBreadcrumb;