@bayonai/mui-design 1.0.0 → 1.2.0

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.
Files changed (137) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +124 -7
  3. package/dist/cjs/actions/ActionMenu.js +36 -0
  4. package/dist/cjs/actions/DialogActionButtons.js +33 -0
  5. package/dist/cjs/actions/LoadingIconButton.js +10 -0
  6. package/dist/cjs/actions/StickyActionFooter.js +27 -0
  7. package/dist/cjs/actions/StickySubmitButton.js +10 -0
  8. package/dist/cjs/actions/index.js +18 -0
  9. package/dist/cjs/drawers/BottomDrawer.js +43 -0
  10. package/dist/cjs/drawers/MobileBottomDrawer.js +102 -0
  11. package/dist/cjs/drawers/MobileBottomDrawerHeader.js +36 -0
  12. package/dist/cjs/drawers/ResponsiveDrawer.js +22 -0
  13. package/dist/cjs/drawers/drawerAppearance.js +10 -0
  14. package/dist/cjs/drawers/index.js +17 -0
  15. package/dist/cjs/drawers/useVisualViewportBottomInset.js +33 -0
  16. package/dist/cjs/feedback/StatusNotice.js +62 -0
  17. package/dist/cjs/feedback/index.js +7 -0
  18. package/dist/cjs/links/LinkAddressPreview.js +80 -0
  19. package/dist/cjs/links/index.js +9 -0
  20. package/dist/cjs/links/useLinkAddressPreview.js +152 -0
  21. package/dist/cjs/pending/PendingChangesDialogShell.js +16 -0
  22. package/dist/cjs/pending/PendingChangesDialogView.js +130 -0
  23. package/dist/cjs/pending/PendingChangesIndicatorView.js +27 -0
  24. package/dist/cjs/pending/index.js +9 -0
  25. package/dist/cjs/pending/types.js +2 -0
  26. package/dist/cjs/pricing/PricingTable.js +58 -0
  27. package/dist/cjs/pricing/index.js +6 -0
  28. package/dist/cjs/providers/BayonThemeProvider.js +51 -11
  29. package/dist/cjs/sections/ExpandableSectionToggle.js +32 -0
  30. package/dist/cjs/sections/index.js +7 -0
  31. package/dist/cjs/swipe/SwipeActionRow.js +123 -0
  32. package/dist/cjs/swipe/index.js +8 -0
  33. package/dist/cjs/toasts/ActionToast.js +12 -0
  34. package/dist/cjs/toasts/Toast.js +55 -0
  35. package/dist/cjs/toasts/index.js +12 -0
  36. package/dist/cjs/toasts/useUpwardToastDismiss.js +73 -0
  37. package/dist/cjs/uploads/CameraCaptureDialog.js +187 -0
  38. package/dist/cjs/uploads/FileRow.js +23 -0
  39. package/dist/cjs/uploads/FileSwipeActionRow.js +11 -0
  40. package/dist/cjs/uploads/FileThumbnail.js +104 -0
  41. package/dist/cjs/uploads/FileUpload.js +98 -0
  42. package/dist/cjs/uploads/FileViewer.js +151 -0
  43. package/dist/cjs/uploads/ImageCropDialog.js +215 -0
  44. package/dist/cjs/uploads/UploadProgressRing.js +32 -0
  45. package/dist/cjs/uploads/cameraCropPresentation.js +12 -0
  46. package/dist/cjs/uploads/index.js +20 -0
  47. package/dist/esm/actions/ActionMenu.js +30 -0
  48. package/dist/esm/actions/DialogActionButtons.js +24 -0
  49. package/dist/esm/actions/LoadingIconButton.js +7 -0
  50. package/dist/esm/actions/StickyActionFooter.js +24 -0
  51. package/dist/esm/actions/StickySubmitButton.js +7 -0
  52. package/dist/esm/actions/index.js +7 -0
  53. package/dist/esm/drawers/BottomDrawer.js +37 -0
  54. package/dist/esm/drawers/MobileBottomDrawer.js +95 -0
  55. package/dist/esm/drawers/MobileBottomDrawerHeader.js +30 -0
  56. package/dist/esm/drawers/ResponsiveDrawer.js +19 -0
  57. package/dist/esm/drawers/drawerAppearance.js +7 -0
  58. package/dist/esm/drawers/index.js +7 -0
  59. package/dist/esm/drawers/useVisualViewportBottomInset.js +29 -0
  60. package/dist/esm/feedback/StatusNotice.js +56 -0
  61. package/dist/esm/feedback/index.js +3 -0
  62. package/dist/esm/links/LinkAddressPreview.js +74 -0
  63. package/dist/esm/links/index.js +4 -0
  64. package/dist/esm/links/useLinkAddressPreview.js +149 -0
  65. package/dist/esm/pending/PendingChangesDialogShell.js +10 -0
  66. package/dist/esm/pending/PendingChangesDialogView.js +124 -0
  67. package/dist/esm/pending/PendingChangesIndicatorView.js +21 -0
  68. package/dist/esm/pending/index.js +4 -0
  69. package/dist/esm/pending/types.js +1 -0
  70. package/dist/esm/pricing/PricingTable.js +52 -0
  71. package/dist/esm/pricing/index.js +2 -0
  72. package/dist/esm/providers/BayonThemeProvider.js +51 -11
  73. package/dist/esm/sections/ExpandableSectionToggle.js +26 -0
  74. package/dist/esm/sections/index.js +3 -0
  75. package/dist/esm/swipe/SwipeActionRow.js +116 -0
  76. package/dist/esm/swipe/index.js +3 -0
  77. package/dist/esm/toasts/ActionToast.js +9 -0
  78. package/dist/esm/toasts/Toast.js +52 -0
  79. package/dist/esm/toasts/index.js +5 -0
  80. package/dist/esm/toasts/useUpwardToastDismiss.js +69 -0
  81. package/dist/esm/uploads/CameraCaptureDialog.js +181 -0
  82. package/dist/esm/uploads/FileRow.js +17 -0
  83. package/dist/esm/uploads/FileSwipeActionRow.js +7 -0
  84. package/dist/esm/uploads/FileThumbnail.js +98 -0
  85. package/dist/esm/uploads/FileUpload.js +92 -0
  86. package/dist/esm/uploads/FileViewer.js +145 -0
  87. package/dist/esm/uploads/ImageCropDialog.js +212 -0
  88. package/dist/esm/uploads/UploadProgressRing.js +29 -0
  89. package/dist/esm/uploads/cameraCropPresentation.js +5 -0
  90. package/dist/esm/uploads/index.js +9 -0
  91. package/dist/types/actions/ActionMenu.d.ts +24 -0
  92. package/dist/types/actions/DialogActionButtons.d.ts +22 -0
  93. package/dist/types/actions/LoadingIconButton.d.ts +11 -0
  94. package/dist/types/actions/StickyActionFooter.d.ts +14 -0
  95. package/dist/types/actions/StickySubmitButton.d.ts +10 -0
  96. package/dist/types/actions/index.d.ts +5 -0
  97. package/dist/types/drawers/BottomDrawer.d.ts +16 -0
  98. package/dist/types/drawers/MobileBottomDrawer.d.ts +20 -0
  99. package/dist/types/drawers/MobileBottomDrawerHeader.d.ts +11 -0
  100. package/dist/types/drawers/ResponsiveDrawer.d.ts +25 -0
  101. package/dist/types/drawers/drawerAppearance.d.ts +8 -0
  102. package/dist/types/drawers/index.d.ts +6 -0
  103. package/dist/types/drawers/useVisualViewportBottomInset.d.ts +6 -0
  104. package/dist/types/feedback/StatusNotice.d.ts +13 -0
  105. package/dist/types/feedback/index.d.ts +1 -0
  106. package/dist/types/links/LinkAddressPreview.d.ts +19 -0
  107. package/dist/types/links/index.d.ts +3 -0
  108. package/dist/types/links/useLinkAddressPreview.d.ts +24 -0
  109. package/dist/types/pending/PendingChangesDialogShell.d.ts +2 -0
  110. package/dist/types/pending/PendingChangesDialogView.d.ts +2 -0
  111. package/dist/types/pending/PendingChangesIndicatorView.d.ts +10 -0
  112. package/dist/types/pending/index.d.ts +3 -0
  113. package/dist/types/pending/types.d.ts +53 -0
  114. package/dist/types/pricing/PricingTable.d.ts +25 -0
  115. package/dist/types/pricing/index.d.ts +2 -0
  116. package/dist/types/sections/ExpandableSectionToggle.d.ts +12 -0
  117. package/dist/types/sections/index.d.ts +2 -0
  118. package/dist/types/swipe/SwipeActionRow.d.ts +8 -0
  119. package/dist/types/swipe/index.d.ts +1 -0
  120. package/dist/types/toasts/ActionToast.d.ts +11 -0
  121. package/dist/types/toasts/Toast.d.ts +16 -0
  122. package/dist/types/toasts/index.d.ts +5 -0
  123. package/dist/types/toasts/useUpwardToastDismiss.d.ts +15 -0
  124. package/dist/types/uploads/CameraCaptureDialog.d.ts +22 -0
  125. package/dist/types/uploads/FileRow.d.ts +10 -0
  126. package/dist/types/uploads/FileSwipeActionRow.d.ts +1 -0
  127. package/dist/types/uploads/FileThumbnail.d.ts +5 -0
  128. package/dist/types/uploads/FileUpload.d.ts +26 -0
  129. package/dist/types/uploads/FileViewer.d.ts +9 -0
  130. package/dist/types/uploads/ImageCropDialog.d.ts +26 -0
  131. package/dist/types/uploads/UploadProgressRing.d.ts +24 -0
  132. package/dist/types/uploads/cameraCropPresentation.d.ts +2 -0
  133. package/dist/types/uploads/index.d.ts +10 -0
  134. package/docs/camera-crop-contract.md +50 -0
  135. package/docs/pending-contract.md +11 -0
  136. package/docs/uploads-contract.md +40 -0
  137. package/package.json +115 -48
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Dialog, DialogTitle, DialogContent, IconButton, Stack, Tooltip, } from "@mui/material";
4
+ import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
5
+ import { useId } from "react";
6
+ export function PendingChangesDialogShell({ children, open, onClose, title, titleIcon, contentHeader, contentTouchHandlers, contentSx, onEntered, closeLabel = "Close pending changes", }) {
7
+ const headerId = useId();
8
+ const titleId = `${headerId}-title`;
9
+ return (_jsxs(Dialog, { open: open, onClose: onClose, fullWidth: true, maxWidth: "sm", "aria-labelledby": titleId, slotProps: { transition: { onEntered } }, children: [_jsx(DialogTitle, { id: headerId, component: "div", children: _jsxs(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, children: [titleIcon, _jsx("span", { id: titleId, style: { flex: 1 }, children: title }), _jsx(Tooltip, { title: closeLabel, children: _jsx(IconButton, { "aria-label": closeLabel, onClick: onClose, sx: { width: 44, height: 44 }, children: _jsx(CloseRoundedIcon, {}) }) })] }) }), contentHeader ? (_jsx("div", { style: { padding: "0 24px 16px" }, children: contentHeader })) : null, _jsx(DialogContent, { ...contentTouchHandlers, sx: contentSx, children: children })] }));
10
+ }
@@ -0,0 +1,124 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { IconButton, List, ListItem, Pagination, Stack, Typography, Tooltip, } from "@mui/material";
4
+ import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
5
+ import DeleteOutlineRoundedIcon from "@mui/icons-material/DeleteOutlineRounded";
6
+ import CloudUploadOutlinedIcon from "@mui/icons-material/CloudUploadOutlined";
7
+ import { useRef, useState } from "react";
8
+ import { PendingChangesDialogShell } from "./PendingChangesDialogShell.js";
9
+ const pageSize = 10;
10
+ export function PendingChangesDialogView({ groups, open, onClose, title, summary, emptyMessage = "All changes are saved.", accountKey, onOpenItem, onDiscardRequest, discardLabel = "Discard a change", focusGroupKey, navigationError, contentHeader, contentTouchHandlers, shell: Shell = PendingChangesDialogShell, }) {
11
+ const returnItemButton = useRef(null);
12
+ const [page, setPage] = useState(1);
13
+ const [actionPages, setActionPages] = useState({});
14
+ const pages = Math.max(1, Math.ceil(groups.length / pageSize));
15
+ const visiblePage = Math.min(page, pages);
16
+ const [previousGroups, setPreviousGroups] = useState(groups);
17
+ const [previousAccount, setPreviousAccount] = useState(accountKey);
18
+ // Adjust pagination only when the source view changes. Guarded render state
19
+ // keeps the first painted frame bounded and avoids effect-driven page jumps.
20
+ if (previousGroups !== groups || previousAccount !== accountKey) {
21
+ setPreviousGroups(groups);
22
+ setPreviousAccount(accountKey);
23
+ if (previousAccount !== accountKey) {
24
+ setPage(1);
25
+ setActionPages({});
26
+ }
27
+ else {
28
+ setPage((current) => Math.min(current, pages));
29
+ setActionPages((current) => {
30
+ const next = {};
31
+ for (const group of groups)
32
+ if (current[group.key] !== undefined)
33
+ next[group.key] = Math.min(current[group.key], Math.max(1, Math.ceil(group.rows.length / pageSize)));
34
+ return Object.keys(next).length === Object.keys(current).length &&
35
+ Object.keys(next).every((key) => next[key] === current[key])
36
+ ? current
37
+ : next;
38
+ });
39
+ }
40
+ }
41
+ return (_jsxs(Shell, { autoFocusInput: false, closeLabel: "Close pending changes", closeTooltip: "Close pending changes", contentHeader: contentHeader !== null && contentHeader !== void 0 ? contentHeader : (groups.length ? (
42
+ // Product decision: the sync summary remains distinct and visible
43
+ // while the user scrolls through pending groups.
44
+ _jsxs(Stack, { component: "section", "aria-label": "Pending changes summary", direction: "row", spacing: 1, sx: { p: 2, borderRadius: 1, bgcolor: "action.selected", alignItems: "center" }, children: [_jsx(Typography, { variant: "body2", sx: { fontWeight: 600, flex: 1 }, children: summary }), onDiscardRequest ? (_jsx(Tooltip, { title: discardLabel, children: _jsx(IconButton, { "aria-label": discardLabel, onClick: onDiscardRequest, sx: { width: 44, height: 44 }, children: _jsx(DeleteOutlineRoundedIcon, {}) }) })) : null] })) : undefined), contentTouchHandlers: contentTouchHandlers, contentSx: { pt: 0.5, pb: 3, overscrollBehaviorY: "contain" }, exclusive: false, onClose: onClose, onEntered: () => {
45
+ // Entry focus runs after MUI settles its focus trap, including a reopen
46
+ // of the same inspector. A removed group retains the shell's fallback.
47
+ const target = returnItemButton.current;
48
+ if ((target === null || target === void 0 ? void 0 : target.isConnected) && !target.disabled)
49
+ target.focus();
50
+ }, open: open, title: title, titleIcon: _jsx(CloudUploadOutlinedIcon, {}), children: [navigationError ? (_jsx(Typography, { role: "alert", color: "error", variant: "body2", sx: { mb: 1 }, children: navigationError })) : null, groups.length ? (_jsxs(_Fragment, { children: [_jsx(List, { "aria-label": "Pending changes", disablePadding: true, sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: groups
51
+ .slice((visiblePage - 1) * pageSize, visiblePage * pageSize)
52
+ .map((group) => {
53
+ var _a;
54
+ const title = group.title;
55
+ const unavailableReason = group.unavailableReason;
56
+ const actionPageCount = Math.max(1, Math.ceil(group.rows.length / pageSize));
57
+ const actionPage = Math.min((_a = actionPages[group.key]) !== null && _a !== void 0 ? _a : 1, actionPageCount);
58
+ return (_jsx(ListItem, { disableGutters: true, sx: {
59
+ p: 2,
60
+ position: "relative",
61
+ alignItems: "flex-start",
62
+ border: 1,
63
+ borderColor: "divider",
64
+ borderRadius: 1,
65
+ }, children: _jsxs(Stack, { spacing: 0, sx: { minWidth: 0, width: "100%" }, children: [_jsxs(Stack, { direction: "row", spacing: 1, sx: {
66
+ alignItems: "center",
67
+ justifyContent: "space-between",
68
+ }, children: [_jsx(Tooltip, { title: title, children: _jsx(Typography, { component: "h3", "aria-label": title, tabIndex: 0, sx: {
69
+ flex: 1,
70
+ minWidth: 0,
71
+ fontWeight: 600,
72
+ // The item name owns one row; CSS handles the
73
+ // available width, while the tooltip retains it all.
74
+ overflow: "hidden",
75
+ textOverflow: "ellipsis",
76
+ whiteSpace: "nowrap",
77
+ }, variant: "body2", children: title }) }), _jsx(Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center", flexShrink: 0, position: "absolute", right: 8, top: group.rows.length ? 32 : 4 }, children: group.openLabel && onOpenItem ? (_jsx(Tooltip, { title: unavailableReason || group.openLabel, children: _jsx("span", { tabIndex: unavailableReason ? 0 : undefined, "aria-label": unavailableReason
78
+ ? `${group.openLabel} unavailable. ${unavailableReason}`
79
+ : undefined, children: _jsx(IconButton, { "aria-label": `${group.openLabel}: ${title}`, disabled: Boolean(unavailableReason), ref: focusGroupKey === group.key
80
+ ? returnItemButton
81
+ : undefined, onClick: () => onOpenItem(group.key), size: "small", sx: { width: 44, height: 44 }, children: _jsx(ArrowForwardRoundedIcon, { fontSize: "small" }) }) }) })) : null })] }), _jsx(List, { "aria-label": `Changes for ${group.title}`, disablePadding: true, children: group.rows
82
+ .slice((actionPage - 1) * pageSize, actionPage * pageSize)
83
+ .map((item, index) => {
84
+ const presentation = item;
85
+ const exception = item.exception;
86
+ if (!presentation.action &&
87
+ !exception &&
88
+ !presentation.targetLabel &&
89
+ !presentation.elapsedText &&
90
+ presentation.attemptedText === undefined)
91
+ return null;
92
+ return (_jsx(ListItem, { disableGutters: true, sx: {
93
+ display: "block",
94
+ py: 1,
95
+ borderTop: index > 0 ? 1 : 0,
96
+ borderColor: "divider",
97
+ }, children: _jsxs(Stack, { spacing: 0.75, children: [_jsxs(Stack, { direction: "row", spacing: 1, sx: {
98
+ alignItems: "baseline",
99
+ justifyContent: "space-between",
100
+ flexWrap: "wrap",
101
+ pr: index === 0 && group.openLabel && onOpenItem ? 5 : 0,
102
+ }, children: [presentation.action ? (_jsx(Typography, { component: "h4", color: "text.secondary", variant: "caption", children: presentation.action })) : null, exception ? (_jsx(Typography, { color: item.needsAttention
103
+ ? "error"
104
+ : "text.secondary", variant: "caption", children: exception })) : null] }), presentation.elapsedText ? (_jsx(Typography, { variant: "caption", sx: { fontSize: "0.6875rem", color: "text.primary", opacity: 0.78 }, children: presentation.elapsedText })) : null, presentation.targetLabel ? (_jsx(Typography, { color: "text.secondary", variant: "caption", sx: {
105
+ overflowWrap: "anywhere",
106
+ whiteSpace: "pre-wrap",
107
+ }, children: presentation.targetLabel })) : null, presentation.attemptedText !== undefined ? (_jsx(Typography, { variant: "body1", sx: {
108
+ whiteSpace: "pre-wrap",
109
+ overflowWrap: "anywhere",
110
+ }, children: presentation.attemptedText })) : null] }) }, item.id));
111
+ }) }), actionPageCount > 1 ? (_jsx(Pagination, { "aria-label": `Change pages for ${group.title}`, count: actionPageCount, page: actionPage, onChange: (_event, nextPage) => setActionPages((previous) => ({
112
+ ...previous,
113
+ [group.key]: nextPage,
114
+ })), sx: {
115
+ "& .MuiPaginationItem-root": {
116
+ minWidth: 44,
117
+ minHeight: 44,
118
+ },
119
+ } })) : null] }) }, group.key));
120
+ }) }), pages > 1 ? (_jsx(Pagination, { "aria-label": "Pending changes pages", count: pages, onChange: (_event, nextPage) => setPage(nextPage), page: visiblePage, sx: {
121
+ mt: 2,
122
+ "& .MuiPaginationItem-root": { minWidth: 44, minHeight: 44 },
123
+ } })) : null] })) : (_jsx(Typography, { role: "status", sx: { py: 2 }, children: emptyMessage }))] }));
124
+ }
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Badge, IconButton, Tooltip } from "@mui/material";
4
+ import { alpha } from "@mui/material/styles";
5
+ import CloudOffOutlinedIcon from "@mui/icons-material/CloudOffOutlined";
6
+ import CloudUploadOutlinedIcon from "@mui/icons-material/CloudUploadOutlined";
7
+ export function PendingChangesIndicatorView({ count, isOffline = false, label = `${count} pending ${count === 1 ? "change" : "changes"}`, explanation = "View pending changes", onOpen, sx, }) {
8
+ return (_jsx(Tooltip, { title: `${isOffline ? "Offline. " : ""}${label}. ${explanation}`, children: _jsx(IconButton, { "aria-label": `${isOffline ? "Offline. " : ""}${label}. View pending changes`, "aria-haspopup": "dialog", onClick: onOpen, sx: [
9
+ {
10
+ width: 44,
11
+ height: 44,
12
+ borderRadius: "50%",
13
+ color: "primary.main",
14
+ bgcolor: "background.paper",
15
+ "&:hover": {
16
+ bgcolor: (theme) => alpha(theme.palette.primary.main, 0.18),
17
+ },
18
+ },
19
+ ...(Array.isArray(sx) ? sx : sx ? [sx] : []),
20
+ ], children: _jsx(Badge, { badgeContent: count, color: "primary", max: Number.MAX_SAFE_INTEGER, slotProps: { badge: { "aria-hidden": true } }, children: isOffline ? _jsx(CloudOffOutlinedIcon, {}) : _jsx(CloudUploadOutlinedIcon, {}) }) }) }));
21
+ }
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ // TL-M249: preserve the established MUI presentation under its owning package.
3
+ export { PendingChangesDialogView } from "./PendingChangesDialogView.js";
4
+ export { PendingChangesIndicatorView, } from "./PendingChangesIndicatorView.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import CheckRoundedIcon from "@mui/icons-material/CheckRounded";
4
+ import { Box, Stack, Typography } from "@mui/material";
5
+ // Product decision: callers own plan content and actions; this component only
6
+ // presents the supplied plans and never determines prices or availability.
7
+ export function PricingTable({ label, plans, className, interactiveClassName, colors, }) {
8
+ return (_jsx(Box, { "aria-label": label, className: className, sx: {
9
+ display: "grid",
10
+ gap: 1.5,
11
+ gridTemplateColumns: {
12
+ xs: "1fr",
13
+ md: `repeat(${plans.length}, minmax(0, 1fr))`,
14
+ },
15
+ }, children: plans.map((plan) => {
16
+ const highlighted = Boolean(plan.highlighted);
17
+ const secondary = highlighted ? "rgba(255,255,255,0.86)" : colors.muted;
18
+ return (_jsxs(Stack, { className: interactiveClassName, spacing: 2.25, sx: {
19
+ bgcolor: highlighted ? colors.accent : "#FFFFFF",
20
+ boxShadow: highlighted
21
+ ? "0 8px 18px rgba(23, 106, 168, 0.22)"
22
+ : "none",
23
+ color: highlighted ? "#FFFFFF" : colors.text,
24
+ minHeight: { md: 430 },
25
+ p: { xs: 2.5, sm: 3 },
26
+ position: "relative",
27
+ borderRadius: 2,
28
+ ...(highlighted
29
+ ? {}
30
+ : { border: "1px solid rgba(23, 38, 56, 0.12)" }),
31
+ "&:hover": {
32
+ ...(highlighted
33
+ ? { boxShadow: "0 10px 22px rgba(23, 106, 168, 0.28)" }
34
+ : { bgcolor: "#FCFEFF" }),
35
+ transform: "translateY(-2px)",
36
+ },
37
+ }, children: [_jsxs(Stack, { direction: "row", spacing: 1, sx: { justifyContent: "space-between" }, children: [_jsx(Typography, { sx: { fontSize: 21, fontWeight: 780 }, children: plan.label }), plan.badge] }), _jsx(Typography, { sx: {
38
+ color: secondary,
39
+ fontSize: 14,
40
+ lineHeight: 1.5,
41
+ minHeight: { md: 42 },
42
+ }, children: plan.description }), _jsxs(Stack, { spacing: 0.25, children: [_jsx(Typography, { sx: {
43
+ fontSize: { xs: 25, sm: 28 },
44
+ fontWeight: 780,
45
+ letterSpacing: "-0.03em",
46
+ }, children: plan.price }), _jsx(Typography, { sx: { color: secondary, fontSize: 13 }, children: plan.priceNote })] }), _jsx(Stack, { component: "ul", spacing: 1.1, sx: { listStyle: "none", m: 0, p: 0 }, children: plan.features.map((feature, index) => (_jsxs(Stack, { component: "li", direction: "row", spacing: 1, children: [_jsx(CheckRoundedIcon, { sx: {
47
+ color: highlighted ? "#FFFFFF" : colors.accentDark,
48
+ fontSize: 18,
49
+ mt: "2px",
50
+ } }), _jsx(Typography, { sx: { fontSize: 14, lineHeight: 1.45 }, children: feature })] }, index))) }), _jsx(Box, { sx: { flex: 1 } }), plan.action] }, plan.id));
51
+ }) }));
52
+ }
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export { PricingTable } from "./PricingTable.js";
@@ -9,13 +9,45 @@ import { createBayonTheme } from '../theme/createBayonTheme.js';
9
9
  import { createBayonEmotionCache } from '../utils/createBayonEmotionCache.js';
10
10
  const clientSideEmotionCache = createBayonEmotionCache();
11
11
  const defaultStorageKey = 'bayon-theme-mode';
12
+ const themeModeChangeEvent = 'bayon-theme-mode-change';
13
+ const clientModeOverrides = new Map();
12
14
  const BayonThemeModeContext = React.createContext(undefined);
13
15
  function readStoredMode(storageKey, defaultMode) {
14
16
  if (typeof window === 'undefined') {
15
17
  return defaultMode;
16
18
  }
17
- const storedMode = window.localStorage.getItem(storageKey);
18
- return storedMode === 'light' || storedMode === 'dark' ? storedMode : defaultMode;
19
+ const clientOverride = clientModeOverrides.get(storageKey);
20
+ if (clientOverride) {
21
+ return clientOverride;
22
+ }
23
+ try {
24
+ const storedMode = window.localStorage.getItem(storageKey);
25
+ return storedMode === 'light' || storedMode === 'dark' ? storedMode : defaultMode;
26
+ }
27
+ catch (error) {
28
+ console.error('[bayon-theme] Failed to read the saved theme mode', { error, storageKey });
29
+ clientModeOverrides.set(storageKey, defaultMode);
30
+ return defaultMode;
31
+ }
32
+ }
33
+ function subscribeToStoredMode(storageKey, onStoreChange) {
34
+ const handleStorageChange = (event) => {
35
+ if (event.key === storageKey) {
36
+ clientModeOverrides.delete(storageKey);
37
+ onStoreChange();
38
+ }
39
+ };
40
+ const handleLocalChange = (event) => {
41
+ if (event instanceof CustomEvent && event.detail === storageKey) {
42
+ onStoreChange();
43
+ }
44
+ };
45
+ window.addEventListener('storage', handleStorageChange);
46
+ window.addEventListener(themeModeChangeEvent, handleLocalChange);
47
+ return () => {
48
+ window.removeEventListener('storage', handleStorageChange);
49
+ window.removeEventListener(themeModeChangeEvent, handleLocalChange);
50
+ };
19
51
  }
20
52
  export function useBayonThemeMode() {
21
53
  const context = React.useContext(BayonThemeModeContext);
@@ -49,12 +81,26 @@ class BayonThemeErrorBoundary extends React.Component {
49
81
  }
50
82
  }
51
83
  export function BayonThemeProvider({ children, emotionCache = clientSideEmotionCache, disableEmotionCacheProvider = false, theme, defaultMode = 'dark', storageKey = defaultStorageKey, enableErrorBoundary = true, }) {
52
- const [mode, setModeState] = React.useState(defaultMode);
84
+ const subscribe = React.useCallback((onStoreChange) => subscribeToStoredMode(storageKey, onStoreChange), [storageKey]);
85
+ const getSnapshot = React.useCallback(() => readStoredMode(storageKey, defaultMode), [defaultMode, storageKey]);
86
+ const getServerSnapshot = React.useCallback(() => defaultMode, [defaultMode]);
87
+ const mode = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
53
88
  const setMode = React.useCallback((nextMode) => {
54
- setModeState(nextMode);
55
- if (typeof window !== 'undefined') {
89
+ if (typeof window === 'undefined') {
90
+ return;
91
+ }
92
+ clientModeOverrides.set(storageKey, nextMode);
93
+ try {
56
94
  window.localStorage.setItem(storageKey, nextMode);
57
95
  }
96
+ catch (error) {
97
+ console.error('[bayon-theme] Failed to persist the selected theme mode', {
98
+ error,
99
+ mode: nextMode,
100
+ storageKey,
101
+ });
102
+ }
103
+ window.dispatchEvent(new CustomEvent(themeModeChangeEvent, { detail: storageKey }));
58
104
  }, [storageKey]);
59
105
  const toggleMode = React.useCallback(() => {
60
106
  setMode(mode === 'dark' ? 'light' : 'dark');
@@ -65,12 +111,6 @@ export function BayonThemeProvider({ children, emotionCache = clientSideEmotionC
65
111
  setMode,
66
112
  toggleMode,
67
113
  }), [mode, setMode, toggleMode]);
68
- React.useEffect(() => {
69
- const storedMode = readStoredMode(storageKey, defaultMode);
70
- if (storedMode !== mode) {
71
- setModeState(storedMode);
72
- }
73
- }, [defaultMode, mode, storageKey]);
74
114
  React.useEffect(() => {
75
115
  document.documentElement.setAttribute('data-theme', mode);
76
116
  }, [mode]);
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
4
+ import { Box, ButtonBase, Stack } from "@mui/material";
5
+ export function ExpandableSectionToggle({ ariaControls, ariaLabel, children, endAdornment, expanded, onToggle, showExpandIcon = true, sx, }) {
6
+ return (_jsxs(ButtonBase, { "aria-controls": ariaControls, "aria-expanded": expanded, "aria-label": ariaLabel, "data-expandable-section-toggle": "true", onClick: onToggle, sx: {
7
+ alignItems: "center",
8
+ borderRadius: 1,
9
+ color: "text.primary",
10
+ display: "flex",
11
+ gap: 1,
12
+ justifyContent: "space-between",
13
+ minWidth: 0,
14
+ px: 0.75,
15
+ py: 0.5,
16
+ textAlign: "left",
17
+ width: "100%",
18
+ "&:hover": { backgroundColor: "action.hover" },
19
+ "&:focus-visible": {
20
+ outline: "2px solid",
21
+ outlineColor: "primary.main",
22
+ outlineOffset: 2,
23
+ },
24
+ ...sx,
25
+ }, type: "button", children: [_jsx(Box, { sx: { flex: "1 1 auto", minWidth: 0 }, children: children }), _jsxs(Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center", flex: "0 0 auto" }, children: [endAdornment, showExpandIcon ? (_jsx(ExpandMoreIcon, { "aria-hidden": "true", fontSize: "small", sx: { transform: expanded ? "rotate(180deg)" : "none" } })) : null] })] }));
26
+ }
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ // TL-M249: preserve the established MUI presentation under its owning package.
3
+ export { ExpandableSectionToggle } from "./ExpandableSectionToggle.js";
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import DeleteOutlineRoundedIcon from "@mui/icons-material/DeleteOutlineRounded";
4
+ import { Box, Stack, Typography } from "@mui/material";
5
+ import { useRef, useState } from "react";
6
+ export const SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX = 72;
7
+ const SWIPE_ROW_MAX_SWIPE_DISTANCE_PX = 104;
8
+ const SWIPE_ROW_SWIPE_DIRECTION_DISTANCE_PX = 12;
9
+ export function SwipeActionRow({ children, onDelete, canDelete = true, dataComponent = "swipe-action-row", }) {
10
+ const [swipeOffset, setSwipeOffset] = useState(0);
11
+ const suppressNextClickRef = useRef(false);
12
+ const swipeStartRef = useRef(null);
13
+ function resetSwipe() {
14
+ swipeStartRef.current = null;
15
+ setSwipeOffset(0);
16
+ }
17
+ function handleTouchStart(event) {
18
+ resetSwipe();
19
+ if (!canDelete)
20
+ return;
21
+ if (event.touches.length !== 1)
22
+ return;
23
+ const touch = event.touches[0];
24
+ if (!touch)
25
+ return;
26
+ swipeStartRef.current = {
27
+ direction: null,
28
+ identifier: touch.identifier,
29
+ x: touch.clientX,
30
+ y: touch.clientY,
31
+ };
32
+ setSwipeOffset(0);
33
+ }
34
+ function handleTouchMove(event) {
35
+ if (!canDelete || event.touches.length !== 1) {
36
+ resetSwipe();
37
+ return;
38
+ }
39
+ const swipeStart = swipeStartRef.current;
40
+ const touch = getTouchByIdentifier(event.touches, swipeStart === null || swipeStart === void 0 ? void 0 : swipeStart.identifier);
41
+ if (!swipeStart || !touch || swipeStart.direction === "vertical")
42
+ return;
43
+ const offsetX = touch.clientX - swipeStart.x;
44
+ const offsetY = touch.clientY - swipeStart.y;
45
+ if (!swipeStart.direction) {
46
+ if (Math.abs(offsetX) < SWIPE_ROW_SWIPE_DIRECTION_DISTANCE_PX &&
47
+ Math.abs(offsetY) < SWIPE_ROW_SWIPE_DIRECTION_DISTANCE_PX) {
48
+ return;
49
+ }
50
+ if (offsetX > 0 || Math.abs(offsetY) >= Math.abs(offsetX)) {
51
+ swipeStart.direction = "vertical";
52
+ return;
53
+ }
54
+ swipeStart.direction = "horizontal";
55
+ }
56
+ // pan-y leaves vertical scrolling to the browser; only claim a left pull
57
+ // after direction lock so parent sheets do not also dismiss.
58
+ event.nativeEvent.stopImmediatePropagation();
59
+ setSwipeOffset(Math.max(-SWIPE_ROW_MAX_SWIPE_DISTANCE_PX, Math.min(0, offsetX)));
60
+ }
61
+ function handleTouchEnd(event) {
62
+ const swipeStart = swipeStartRef.current;
63
+ const touch = getTouchByIdentifier(event.changedTouches, swipeStart === null || swipeStart === void 0 ? void 0 : swipeStart.identifier);
64
+ if (!swipeStart || !touch || swipeStart.direction !== "horizontal") {
65
+ resetSwipe();
66
+ return;
67
+ }
68
+ event.nativeEvent.stopImmediatePropagation();
69
+ const swipeDistance = touch.clientX - swipeStart.x;
70
+ resetSwipe();
71
+ suppressNextClickRef.current = true;
72
+ globalThis.setTimeout(() => {
73
+ suppressNextClickRef.current = false;
74
+ }, 0);
75
+ if (canDelete && swipeDistance <= -SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX) {
76
+ onDelete();
77
+ }
78
+ }
79
+ return (_jsxs(Box, { "data-component": dataComponent, "data-drawer-gesture-exclude": true, onClickCapture: (event) => {
80
+ if (!suppressNextClickRef.current)
81
+ return;
82
+ suppressNextClickRef.current = false;
83
+ event.preventDefault();
84
+ event.stopPropagation();
85
+ }, onTouchCancel: resetSwipe, onTouchEnd: handleTouchEnd, onTouchMove: handleTouchMove, onTouchStart: handleTouchStart, sx: { overflow: "hidden", position: "relative", touchAction: "pan-y" }, children: [_jsx(Box, { "aria-hidden": true, "data-component": "swipe-delete-action", sx: {
86
+ alignItems: "center",
87
+ bgcolor: "error.main",
88
+ color: "common.white",
89
+ display: "flex",
90
+ inset: 0,
91
+ justifyContent: "flex-end",
92
+ opacity: swipeOffset === 0 ? 0 : 1,
93
+ px: 2,
94
+ pointerEvents: "none",
95
+ position: "absolute",
96
+ }, children: _jsxs(Stack, { direction: "row", spacing: 0.75, sx: { alignItems: "center" }, children: [_jsx(DeleteOutlineRoundedIcon, { fontSize: "small" }), _jsx(Typography, { component: "span", sx: { fontSize: 12, fontWeight: 700 }, children: "Delete" })] }) }), _jsx(Box, { sx: {
97
+ bgcolor: "background.paper",
98
+ transform: swipeOffset === 0
99
+ ? undefined
100
+ : `translate3d(${swipeOffset}px, 0, 0)`,
101
+ transition: swipeOffset
102
+ ? "none"
103
+ : "transform 160ms cubic-bezier(0.2, 0, 0, 1)",
104
+ "@media (prefers-reduced-motion: reduce)": { transition: "none" },
105
+ }, children: children })] }));
106
+ }
107
+ function getTouchByIdentifier(touches, identifier) {
108
+ if (identifier === undefined)
109
+ return undefined;
110
+ for (let index = 0; index < touches.length; index += 1) {
111
+ const touch = touches[index];
112
+ if ((touch === null || touch === void 0 ? void 0 : touch.identifier) === identifier)
113
+ return touch;
114
+ }
115
+ return undefined;
116
+ }
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ // TL-M249: preserve the established MUI presentation under its owning package.
3
+ export { SwipeActionRow, SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX } from "./SwipeActionRow.js";
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Button, Stack, Typography } from "@mui/material";
4
+ import { Toast } from "./Toast.js";
5
+ // The host owns expiry and action semantics: dismissing a notification must
6
+ // never implicitly commit a deletion or cancel a transaction in this package.
7
+ export function ActionToast({ message, actionLabel, actionAriaLabel, onAction, actionDisabled = false, ToastComponent = Toast, ...toastProps }) {
8
+ return (_jsx(ToastComponent, { ...toastProps, children: _jsxs(Stack, { direction: "row", sx: { alignItems: "center", gap: 1, justifyContent: "space-between" }, children: [_jsx(Typography, { noWrap: true, sx: { fontSize: 14, fontWeight: 650 }, children: message }), _jsx(Button, { "aria-label": actionAriaLabel, disabled: actionDisabled, onClick: onAction, size: "small", sx: { flexShrink: 0, fontWeight: 760, minWidth: 0, px: 1 }, children: actionLabel })] }) }));
9
+ }
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Box } from "@mui/material";
4
+ import { useUpwardToastDismiss } from "./useUpwardToastDismiss.js";
5
+ export function Toast({ ariaLive, mobileTopOffset = 16, mobileBottomOffset = 16, children, contained = false, dataComponent, onDismiss, placement = "bottom-end", role = "status", sx, variant = "standard", }) {
6
+ const topCentered = placement === "top-center";
7
+ const swipeDismiss = useUpwardToastDismiss({
8
+ onDismiss,
9
+ transform: topCentered ? "translateX(-50%)" : "",
10
+ });
11
+ return (_jsx(Box, { "aria-live": ariaLive, "data-component": dataComponent, "data-presentation": contained ? "workspace-contained" : "viewport", "data-swipe-dismiss": onDismiss ? "up" : undefined, role: role, ...swipeDismiss.pointerHandlers, sx: [
12
+ {
13
+ ...(topCentered
14
+ ? {
15
+ bottom: { xs: "auto", md: contained ? 24 : "auto" },
16
+ left: "50%",
17
+ maxWidth: { xs: "none", md: 460 },
18
+ position: contained
19
+ ? { xs: "fixed", md: "absolute" }
20
+ : "fixed",
21
+ top: { xs: mobileTopOffset, md: contained ? "auto" : 24 },
22
+ transform: "translateX(-50%)",
23
+ width: {
24
+ xs: "calc(100vw - 16px)",
25
+ md: contained ? "calc(100% - 32px)" : "calc(100vw - 32px)",
26
+ },
27
+ zIndex: 1600,
28
+ }
29
+ : {
30
+ bottom: { xs: mobileBottomOffset, md: 24 },
31
+ maxWidth: { xs: "calc(100vw - 32px)", sm: 476 },
32
+ position: "fixed",
33
+ right: { xs: 16, md: 24 },
34
+ zIndex: (theme) => theme.zIndex.snackbar,
35
+ }),
36
+ ...(variant === "standard"
37
+ ? {
38
+ bgcolor: "background.paper",
39
+ border: 1,
40
+ borderColor: "divider",
41
+ borderRadius: 2,
42
+ boxShadow: 6,
43
+ color: "text.primary",
44
+ px: 1.5,
45
+ py: 1.25,
46
+ }
47
+ : {}),
48
+ },
49
+ ...(Array.isArray(sx) ? sx : sx ? [sx] : []),
50
+ ...(swipeDismiss.sx ? [swipeDismiss.sx] : []),
51
+ ], children: children }));
52
+ }
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ // TL-M249: preserve the established MUI presentation under its owning package.
3
+ export { Toast } from "./Toast.js";
4
+ export { ActionToast } from "./ActionToast.js";
5
+ export { useUpwardToastDismiss, TOAST_UPWARD_DISMISS_DISTANCE_PX, } from "./useUpwardToastDismiss.js";
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { useCallback, useMemo, useRef, useState, } from "react";
3
+ export const TOAST_UPWARD_DISMISS_DISTANCE_PX = 64;
4
+ export function useUpwardToastDismiss({ onDismiss, transform, }) {
5
+ const pointerStartYRef = useRef(null);
6
+ const [isDragging, setIsDragging] = useState(false);
7
+ const [swipeOffsetY, setSwipeOffsetY] = useState(0);
8
+ const resetDrag = useCallback(() => {
9
+ pointerStartYRef.current = null;
10
+ setIsDragging(false);
11
+ setSwipeOffsetY(0);
12
+ }, []);
13
+ const onPointerDown = useCallback((event) => {
14
+ if (!onDismiss || isInteractiveTarget(event.target)) {
15
+ return;
16
+ }
17
+ pointerStartYRef.current = event.clientY;
18
+ setIsDragging(true);
19
+ event.currentTarget.setPointerCapture(event.pointerId);
20
+ }, [onDismiss]);
21
+ const onPointerMove = useCallback((event) => {
22
+ if (!onDismiss || pointerStartYRef.current === null) {
23
+ return;
24
+ }
25
+ event.preventDefault();
26
+ setSwipeOffsetY(Math.min(0, event.clientY - pointerStartYRef.current));
27
+ }, [onDismiss]);
28
+ const onPointerUp = useCallback((event) => {
29
+ const pointerStartY = pointerStartYRef.current;
30
+ if (!onDismiss || pointerStartY === null) {
31
+ return;
32
+ }
33
+ const upwardDistance = pointerStartY - event.clientY;
34
+ resetDrag();
35
+ if (upwardDistance >= TOAST_UPWARD_DISMISS_DISTANCE_PX) {
36
+ onDismiss();
37
+ }
38
+ }, [onDismiss, resetDrag]);
39
+ const pointerHandlers = useMemo(() => onDismiss
40
+ ? {
41
+ onPointerCancel: resetDrag,
42
+ onPointerDown,
43
+ onPointerMove,
44
+ onPointerUp,
45
+ }
46
+ : undefined, [onDismiss, onPointerDown, onPointerMove, onPointerUp, resetDrag]);
47
+ const sx = useMemo(() => onDismiss
48
+ ? {
49
+ // Product decision: direct manipulation is reserved for the toast
50
+ // surface; nested actions such as Undo retain their normal taps.
51
+ animation: isDragging ? "none" : undefined,
52
+ touchAction: "none",
53
+ transform: `${transform ? `${transform} ` : ""}translateY(${swipeOffsetY}px)`,
54
+ transition: isDragging
55
+ ? "none"
56
+ : "transform 160ms cubic-bezier(0.2, 0, 0, 1)",
57
+ userSelect: "none",
58
+ WebkitTouchCallout: "none",
59
+ WebkitUserSelect: "none",
60
+ willChange: isDragging ? "transform" : "auto",
61
+ }
62
+ : undefined, [isDragging, onDismiss, swipeOffsetY, transform]);
63
+ return { pointerHandlers, sx };
64
+ }
65
+ function isInteractiveTarget(target) {
66
+ var _a;
67
+ const element = target;
68
+ return Boolean((_a = element === null || element === void 0 ? void 0 : element.closest) === null || _a === void 0 ? void 0 : _a.call(element, "button, a, input, select, textarea, [role='button']"));
69
+ }