@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
@@ -49,13 +49,45 @@ const createBayonTheme_js_1 = require("../theme/createBayonTheme.js");
49
49
  const createBayonEmotionCache_js_1 = require("../utils/createBayonEmotionCache.js");
50
50
  const clientSideEmotionCache = (0, createBayonEmotionCache_js_1.createBayonEmotionCache)();
51
51
  const defaultStorageKey = 'bayon-theme-mode';
52
+ const themeModeChangeEvent = 'bayon-theme-mode-change';
53
+ const clientModeOverrides = new Map();
52
54
  const BayonThemeModeContext = React.createContext(undefined);
53
55
  function readStoredMode(storageKey, defaultMode) {
54
56
  if (typeof window === 'undefined') {
55
57
  return defaultMode;
56
58
  }
57
- const storedMode = window.localStorage.getItem(storageKey);
58
- return storedMode === 'light' || storedMode === 'dark' ? storedMode : defaultMode;
59
+ const clientOverride = clientModeOverrides.get(storageKey);
60
+ if (clientOverride) {
61
+ return clientOverride;
62
+ }
63
+ try {
64
+ const storedMode = window.localStorage.getItem(storageKey);
65
+ return storedMode === 'light' || storedMode === 'dark' ? storedMode : defaultMode;
66
+ }
67
+ catch (error) {
68
+ console.error('[bayon-theme] Failed to read the saved theme mode', { error, storageKey });
69
+ clientModeOverrides.set(storageKey, defaultMode);
70
+ return defaultMode;
71
+ }
72
+ }
73
+ function subscribeToStoredMode(storageKey, onStoreChange) {
74
+ const handleStorageChange = (event) => {
75
+ if (event.key === storageKey) {
76
+ clientModeOverrides.delete(storageKey);
77
+ onStoreChange();
78
+ }
79
+ };
80
+ const handleLocalChange = (event) => {
81
+ if (event instanceof CustomEvent && event.detail === storageKey) {
82
+ onStoreChange();
83
+ }
84
+ };
85
+ window.addEventListener('storage', handleStorageChange);
86
+ window.addEventListener(themeModeChangeEvent, handleLocalChange);
87
+ return () => {
88
+ window.removeEventListener('storage', handleStorageChange);
89
+ window.removeEventListener(themeModeChangeEvent, handleLocalChange);
90
+ };
59
91
  }
60
92
  function useBayonThemeMode() {
61
93
  const context = React.useContext(BayonThemeModeContext);
@@ -89,12 +121,26 @@ class BayonThemeErrorBoundary extends React.Component {
89
121
  }
90
122
  }
91
123
  function BayonThemeProvider({ children, emotionCache = clientSideEmotionCache, disableEmotionCacheProvider = false, theme, defaultMode = 'dark', storageKey = defaultStorageKey, enableErrorBoundary = true, }) {
92
- const [mode, setModeState] = React.useState(defaultMode);
124
+ const subscribe = React.useCallback((onStoreChange) => subscribeToStoredMode(storageKey, onStoreChange), [storageKey]);
125
+ const getSnapshot = React.useCallback(() => readStoredMode(storageKey, defaultMode), [defaultMode, storageKey]);
126
+ const getServerSnapshot = React.useCallback(() => defaultMode, [defaultMode]);
127
+ const mode = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
93
128
  const setMode = React.useCallback((nextMode) => {
94
- setModeState(nextMode);
95
- if (typeof window !== 'undefined') {
129
+ if (typeof window === 'undefined') {
130
+ return;
131
+ }
132
+ clientModeOverrides.set(storageKey, nextMode);
133
+ try {
96
134
  window.localStorage.setItem(storageKey, nextMode);
97
135
  }
136
+ catch (error) {
137
+ console.error('[bayon-theme] Failed to persist the selected theme mode', {
138
+ error,
139
+ mode: nextMode,
140
+ storageKey,
141
+ });
142
+ }
143
+ window.dispatchEvent(new CustomEvent(themeModeChangeEvent, { detail: storageKey }));
98
144
  }, [storageKey]);
99
145
  const toggleMode = React.useCallback(() => {
100
146
  setMode(mode === 'dark' ? 'light' : 'dark');
@@ -105,12 +151,6 @@ function BayonThemeProvider({ children, emotionCache = clientSideEmotionCache, d
105
151
  setMode,
106
152
  toggleMode,
107
153
  }), [mode, setMode, toggleMode]);
108
- React.useEffect(() => {
109
- const storedMode = readStoredMode(storageKey, defaultMode);
110
- if (storedMode !== mode) {
111
- setModeState(storedMode);
112
- }
113
- }, [defaultMode, mode, storageKey]);
114
154
  React.useEffect(() => {
115
155
  document.documentElement.setAttribute('data-theme', mode);
116
156
  }, [mode]);
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ExpandableSectionToggle = ExpandableSectionToggle;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
10
+ const material_1 = require("@mui/material");
11
+ function ExpandableSectionToggle({ ariaControls, ariaLabel, children, endAdornment, expanded, onToggle, showExpandIcon = true, sx, }) {
12
+ return ((0, jsx_runtime_1.jsxs)(material_1.ButtonBase, { "aria-controls": ariaControls, "aria-expanded": expanded, "aria-label": ariaLabel, "data-expandable-section-toggle": "true", onClick: onToggle, sx: {
13
+ alignItems: "center",
14
+ borderRadius: 1,
15
+ color: "text.primary",
16
+ display: "flex",
17
+ gap: 1,
18
+ justifyContent: "space-between",
19
+ minWidth: 0,
20
+ px: 0.75,
21
+ py: 0.5,
22
+ textAlign: "left",
23
+ width: "100%",
24
+ "&:hover": { backgroundColor: "action.hover" },
25
+ "&:focus-visible": {
26
+ outline: "2px solid",
27
+ outlineColor: "primary.main",
28
+ outlineOffset: 2,
29
+ },
30
+ ...sx,
31
+ }, type: "button", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { flex: "1 1 auto", minWidth: 0 }, children: children }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center", flex: "0 0 auto" }, children: [endAdornment, showExpandIcon ? ((0, jsx_runtime_1.jsx)(ExpandMore_1.default, { "aria-hidden": "true", fontSize: "small", sx: { transform: expanded ? "rotate(180deg)" : "none" } })) : null] })] }));
32
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ExpandableSectionToggle = void 0;
5
+ // TL-M249: preserve the established MUI presentation under its owning package.
6
+ var ExpandableSectionToggle_js_1 = require("./ExpandableSectionToggle.js");
7
+ Object.defineProperty(exports, "ExpandableSectionToggle", { enumerable: true, get: function () { return ExpandableSectionToggle_js_1.ExpandableSectionToggle; } });
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX = void 0;
8
+ exports.SwipeActionRow = SwipeActionRow;
9
+ const jsx_runtime_1 = require("react/jsx-runtime");
10
+ const DeleteOutlineRounded_1 = __importDefault(require("@mui/icons-material/DeleteOutlineRounded"));
11
+ const material_1 = require("@mui/material");
12
+ const react_1 = require("react");
13
+ exports.SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX = 72;
14
+ const SWIPE_ROW_MAX_SWIPE_DISTANCE_PX = 104;
15
+ const SWIPE_ROW_SWIPE_DIRECTION_DISTANCE_PX = 12;
16
+ function SwipeActionRow({ children, onDelete, canDelete = true, dataComponent = "swipe-action-row", }) {
17
+ const [swipeOffset, setSwipeOffset] = (0, react_1.useState)(0);
18
+ const suppressNextClickRef = (0, react_1.useRef)(false);
19
+ const swipeStartRef = (0, react_1.useRef)(null);
20
+ function resetSwipe() {
21
+ swipeStartRef.current = null;
22
+ setSwipeOffset(0);
23
+ }
24
+ function handleTouchStart(event) {
25
+ resetSwipe();
26
+ if (!canDelete)
27
+ return;
28
+ if (event.touches.length !== 1)
29
+ return;
30
+ const touch = event.touches[0];
31
+ if (!touch)
32
+ return;
33
+ swipeStartRef.current = {
34
+ direction: null,
35
+ identifier: touch.identifier,
36
+ x: touch.clientX,
37
+ y: touch.clientY,
38
+ };
39
+ setSwipeOffset(0);
40
+ }
41
+ function handleTouchMove(event) {
42
+ if (!canDelete || event.touches.length !== 1) {
43
+ resetSwipe();
44
+ return;
45
+ }
46
+ const swipeStart = swipeStartRef.current;
47
+ const touch = getTouchByIdentifier(event.touches, swipeStart === null || swipeStart === void 0 ? void 0 : swipeStart.identifier);
48
+ if (!swipeStart || !touch || swipeStart.direction === "vertical")
49
+ return;
50
+ const offsetX = touch.clientX - swipeStart.x;
51
+ const offsetY = touch.clientY - swipeStart.y;
52
+ if (!swipeStart.direction) {
53
+ if (Math.abs(offsetX) < SWIPE_ROW_SWIPE_DIRECTION_DISTANCE_PX &&
54
+ Math.abs(offsetY) < SWIPE_ROW_SWIPE_DIRECTION_DISTANCE_PX) {
55
+ return;
56
+ }
57
+ if (offsetX > 0 || Math.abs(offsetY) >= Math.abs(offsetX)) {
58
+ swipeStart.direction = "vertical";
59
+ return;
60
+ }
61
+ swipeStart.direction = "horizontal";
62
+ }
63
+ // pan-y leaves vertical scrolling to the browser; only claim a left pull
64
+ // after direction lock so parent sheets do not also dismiss.
65
+ event.nativeEvent.stopImmediatePropagation();
66
+ setSwipeOffset(Math.max(-SWIPE_ROW_MAX_SWIPE_DISTANCE_PX, Math.min(0, offsetX)));
67
+ }
68
+ function handleTouchEnd(event) {
69
+ const swipeStart = swipeStartRef.current;
70
+ const touch = getTouchByIdentifier(event.changedTouches, swipeStart === null || swipeStart === void 0 ? void 0 : swipeStart.identifier);
71
+ if (!swipeStart || !touch || swipeStart.direction !== "horizontal") {
72
+ resetSwipe();
73
+ return;
74
+ }
75
+ event.nativeEvent.stopImmediatePropagation();
76
+ const swipeDistance = touch.clientX - swipeStart.x;
77
+ resetSwipe();
78
+ suppressNextClickRef.current = true;
79
+ globalThis.setTimeout(() => {
80
+ suppressNextClickRef.current = false;
81
+ }, 0);
82
+ if (canDelete && swipeDistance <= -exports.SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX) {
83
+ onDelete();
84
+ }
85
+ }
86
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { "data-component": dataComponent, "data-drawer-gesture-exclude": true, onClickCapture: (event) => {
87
+ if (!suppressNextClickRef.current)
88
+ return;
89
+ suppressNextClickRef.current = false;
90
+ event.preventDefault();
91
+ event.stopPropagation();
92
+ }, onTouchCancel: resetSwipe, onTouchEnd: handleTouchEnd, onTouchMove: handleTouchMove, onTouchStart: handleTouchStart, sx: { overflow: "hidden", position: "relative", touchAction: "pan-y" }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { "aria-hidden": true, "data-component": "swipe-delete-action", sx: {
93
+ alignItems: "center",
94
+ bgcolor: "error.main",
95
+ color: "common.white",
96
+ display: "flex",
97
+ inset: 0,
98
+ justifyContent: "flex-end",
99
+ opacity: swipeOffset === 0 ? 0 : 1,
100
+ px: 2,
101
+ pointerEvents: "none",
102
+ position: "absolute",
103
+ }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 0.75, sx: { alignItems: "center" }, children: [(0, jsx_runtime_1.jsx)(DeleteOutlineRounded_1.default, { fontSize: "small" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "span", sx: { fontSize: 12, fontWeight: 700 }, children: "Delete" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
104
+ bgcolor: "background.paper",
105
+ transform: swipeOffset === 0
106
+ ? undefined
107
+ : `translate3d(${swipeOffset}px, 0, 0)`,
108
+ transition: swipeOffset
109
+ ? "none"
110
+ : "transform 160ms cubic-bezier(0.2, 0, 0, 1)",
111
+ "@media (prefers-reduced-motion: reduce)": { transition: "none" },
112
+ }, children: children })] }));
113
+ }
114
+ function getTouchByIdentifier(touches, identifier) {
115
+ if (identifier === undefined)
116
+ return undefined;
117
+ for (let index = 0; index < touches.length; index += 1) {
118
+ const touch = touches[index];
119
+ if ((touch === null || touch === void 0 ? void 0 : touch.identifier) === identifier)
120
+ return touch;
121
+ }
122
+ return undefined;
123
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX = exports.SwipeActionRow = void 0;
5
+ // TL-M249: preserve the established MUI presentation under its owning package.
6
+ var SwipeActionRow_js_1 = require("./SwipeActionRow.js");
7
+ Object.defineProperty(exports, "SwipeActionRow", { enumerable: true, get: function () { return SwipeActionRow_js_1.SwipeActionRow; } });
8
+ Object.defineProperty(exports, "SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX", { enumerable: true, get: function () { return SwipeActionRow_js_1.SWIPE_ROW_SWIPE_DELETE_DISTANCE_PX; } });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ActionToast = ActionToast;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const material_1 = require("@mui/material");
7
+ const Toast_js_1 = require("./Toast.js");
8
+ // The host owns expiry and action semantics: dismissing a notification must
9
+ // never implicitly commit a deletion or cancel a transaction in this package.
10
+ function ActionToast({ message, actionLabel, actionAriaLabel, onAction, actionDisabled = false, ToastComponent = Toast_js_1.Toast, ...toastProps }) {
11
+ return ((0, jsx_runtime_1.jsx)(ToastComponent, { ...toastProps, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", sx: { alignItems: "center", gap: 1, justifyContent: "space-between" }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, sx: { fontSize: 14, fontWeight: 650 }, children: message }), (0, jsx_runtime_1.jsx)(material_1.Button, { "aria-label": actionAriaLabel, disabled: actionDisabled, onClick: onAction, size: "small", sx: { flexShrink: 0, fontWeight: 760, minWidth: 0, px: 1 }, children: actionLabel })] }) }));
12
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Toast = Toast;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const material_1 = require("@mui/material");
7
+ const useUpwardToastDismiss_js_1 = require("./useUpwardToastDismiss.js");
8
+ function Toast({ ariaLive, mobileTopOffset = 16, mobileBottomOffset = 16, children, contained = false, dataComponent, onDismiss, placement = "bottom-end", role = "status", sx, variant = "standard", }) {
9
+ const topCentered = placement === "top-center";
10
+ const swipeDismiss = (0, useUpwardToastDismiss_js_1.useUpwardToastDismiss)({
11
+ onDismiss,
12
+ transform: topCentered ? "translateX(-50%)" : "",
13
+ });
14
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { "aria-live": ariaLive, "data-component": dataComponent, "data-presentation": contained ? "workspace-contained" : "viewport", "data-swipe-dismiss": onDismiss ? "up" : undefined, role: role, ...swipeDismiss.pointerHandlers, sx: [
15
+ {
16
+ ...(topCentered
17
+ ? {
18
+ bottom: { xs: "auto", md: contained ? 24 : "auto" },
19
+ left: "50%",
20
+ maxWidth: { xs: "none", md: 460 },
21
+ position: contained
22
+ ? { xs: "fixed", md: "absolute" }
23
+ : "fixed",
24
+ top: { xs: mobileTopOffset, md: contained ? "auto" : 24 },
25
+ transform: "translateX(-50%)",
26
+ width: {
27
+ xs: "calc(100vw - 16px)",
28
+ md: contained ? "calc(100% - 32px)" : "calc(100vw - 32px)",
29
+ },
30
+ zIndex: 1600,
31
+ }
32
+ : {
33
+ bottom: { xs: mobileBottomOffset, md: 24 },
34
+ maxWidth: { xs: "calc(100vw - 32px)", sm: 476 },
35
+ position: "fixed",
36
+ right: { xs: 16, md: 24 },
37
+ zIndex: (theme) => theme.zIndex.snackbar,
38
+ }),
39
+ ...(variant === "standard"
40
+ ? {
41
+ bgcolor: "background.paper",
42
+ border: 1,
43
+ borderColor: "divider",
44
+ borderRadius: 2,
45
+ boxShadow: 6,
46
+ color: "text.primary",
47
+ px: 1.5,
48
+ py: 1.25,
49
+ }
50
+ : {}),
51
+ },
52
+ ...(Array.isArray(sx) ? sx : sx ? [sx] : []),
53
+ ...(swipeDismiss.sx ? [swipeDismiss.sx] : []),
54
+ ], children: children }));
55
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TOAST_UPWARD_DISMISS_DISTANCE_PX = exports.useUpwardToastDismiss = exports.ActionToast = exports.Toast = void 0;
5
+ // TL-M249: preserve the established MUI presentation under its owning package.
6
+ var Toast_js_1 = require("./Toast.js");
7
+ Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_js_1.Toast; } });
8
+ var ActionToast_js_1 = require("./ActionToast.js");
9
+ Object.defineProperty(exports, "ActionToast", { enumerable: true, get: function () { return ActionToast_js_1.ActionToast; } });
10
+ var useUpwardToastDismiss_js_1 = require("./useUpwardToastDismiss.js");
11
+ Object.defineProperty(exports, "useUpwardToastDismiss", { enumerable: true, get: function () { return useUpwardToastDismiss_js_1.useUpwardToastDismiss; } });
12
+ Object.defineProperty(exports, "TOAST_UPWARD_DISMISS_DISTANCE_PX", { enumerable: true, get: function () { return useUpwardToastDismiss_js_1.TOAST_UPWARD_DISMISS_DISTANCE_PX; } });
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TOAST_UPWARD_DISMISS_DISTANCE_PX = void 0;
5
+ exports.useUpwardToastDismiss = useUpwardToastDismiss;
6
+ const react_1 = require("react");
7
+ exports.TOAST_UPWARD_DISMISS_DISTANCE_PX = 64;
8
+ function useUpwardToastDismiss({ onDismiss, transform, }) {
9
+ const pointerStartYRef = (0, react_1.useRef)(null);
10
+ const [isDragging, setIsDragging] = (0, react_1.useState)(false);
11
+ const [swipeOffsetY, setSwipeOffsetY] = (0, react_1.useState)(0);
12
+ const resetDrag = (0, react_1.useCallback)(() => {
13
+ pointerStartYRef.current = null;
14
+ setIsDragging(false);
15
+ setSwipeOffsetY(0);
16
+ }, []);
17
+ const onPointerDown = (0, react_1.useCallback)((event) => {
18
+ if (!onDismiss || isInteractiveTarget(event.target)) {
19
+ return;
20
+ }
21
+ pointerStartYRef.current = event.clientY;
22
+ setIsDragging(true);
23
+ event.currentTarget.setPointerCapture(event.pointerId);
24
+ }, [onDismiss]);
25
+ const onPointerMove = (0, react_1.useCallback)((event) => {
26
+ if (!onDismiss || pointerStartYRef.current === null) {
27
+ return;
28
+ }
29
+ event.preventDefault();
30
+ setSwipeOffsetY(Math.min(0, event.clientY - pointerStartYRef.current));
31
+ }, [onDismiss]);
32
+ const onPointerUp = (0, react_1.useCallback)((event) => {
33
+ const pointerStartY = pointerStartYRef.current;
34
+ if (!onDismiss || pointerStartY === null) {
35
+ return;
36
+ }
37
+ const upwardDistance = pointerStartY - event.clientY;
38
+ resetDrag();
39
+ if (upwardDistance >= exports.TOAST_UPWARD_DISMISS_DISTANCE_PX) {
40
+ onDismiss();
41
+ }
42
+ }, [onDismiss, resetDrag]);
43
+ const pointerHandlers = (0, react_1.useMemo)(() => onDismiss
44
+ ? {
45
+ onPointerCancel: resetDrag,
46
+ onPointerDown,
47
+ onPointerMove,
48
+ onPointerUp,
49
+ }
50
+ : undefined, [onDismiss, onPointerDown, onPointerMove, onPointerUp, resetDrag]);
51
+ const sx = (0, react_1.useMemo)(() => onDismiss
52
+ ? {
53
+ // Product decision: direct manipulation is reserved for the toast
54
+ // surface; nested actions such as Undo retain their normal taps.
55
+ animation: isDragging ? "none" : undefined,
56
+ touchAction: "none",
57
+ transform: `${transform ? `${transform} ` : ""}translateY(${swipeOffsetY}px)`,
58
+ transition: isDragging
59
+ ? "none"
60
+ : "transform 160ms cubic-bezier(0.2, 0, 0, 1)",
61
+ userSelect: "none",
62
+ WebkitTouchCallout: "none",
63
+ WebkitUserSelect: "none",
64
+ willChange: isDragging ? "transform" : "auto",
65
+ }
66
+ : undefined, [isDragging, onDismiss, swipeOffsetY, transform]);
67
+ return { pointerHandlers, sx };
68
+ }
69
+ function isInteractiveTarget(target) {
70
+ var _a;
71
+ const element = target;
72
+ 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']"));
73
+ }
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.CameraCaptureDialog = CameraCaptureDialog;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const material_1 = require("@mui/material");
11
+ const CameraAlt_1 = __importDefault(require("@mui/icons-material/CameraAlt"));
12
+ const cameraCropPresentation_js_1 = require("./cameraCropPresentation.js");
13
+ const cameraCropPresentation_js_2 = require("./cameraCropPresentation.js");
14
+ const DEFAULT_LABELS = {
15
+ title: "Take photo",
16
+ close: "Close camera",
17
+ preview: "Camera preview",
18
+ capture: "Take photo",
19
+ opening: "Opening camera…",
20
+ ready: "Take a photo, then adjust its crop.",
21
+ denied: "Camera access was denied. Allow camera access in your browser, then reopen the camera, or choose a photo.",
22
+ unavailable: "The camera is unavailable. Check that it is connected and not in use, then reopen the camera, or choose a photo.",
23
+ previewError: "The camera preview could not start. Close the camera and try again, or choose a photo.",
24
+ captureError: "The photo could not be captured. Close the camera and try again, or choose a photo.",
25
+ };
26
+ /** Owns camera resources only; the host owns crop, upload and persistence. */
27
+ function CameraCaptureDialog({ onClose, onCapture, labels, facingMode = "user", fileName = "camera.jpg", previewMaxHeight = "50dvh", }) {
28
+ const copy = { ...DEFAULT_LABELS, ...labels };
29
+ const copyRef = (0, react_1.useRef)(copy);
30
+ // Publish copy after commit so abandoned renders cannot change async feedback.
31
+ (0, react_1.useEffect)(() => {
32
+ copyRef.current = copy;
33
+ });
34
+ // Product decision: changing copy must never request camera permission again.
35
+ const initialFacingMode = (0, react_1.useRef)(facingMode);
36
+ const titleId = (0, react_1.useId)();
37
+ const video = (0, react_1.useRef)(null);
38
+ const stream = (0, react_1.useRef)(null);
39
+ const active = (0, react_1.useRef)(true);
40
+ const capturing = (0, react_1.useRef)(false);
41
+ const [ready, setReady] = (0, react_1.useState)(false);
42
+ const [busy, setBusy] = (0, react_1.useState)(false);
43
+ const [error, setError] = (0, react_1.useState)(null);
44
+ const attachPreview = (0, react_1.useCallback)((preview) => {
45
+ video.current = preview;
46
+ const acquired = stream.current;
47
+ if (!preview || !acquired || !active.current)
48
+ return;
49
+ // Dialog portals can mount after permission resolves. Attach from both sides
50
+ // of that race so an accepted camera never waits forever for its preview.
51
+ preview.srcObject = acquired;
52
+ void preview
53
+ .play()
54
+ .then(() => {
55
+ if (active.current &&
56
+ stream.current === acquired &&
57
+ video.current === preview &&
58
+ preview.readyState >= 2)
59
+ setReady(true);
60
+ })
61
+ .catch((cause) => {
62
+ if (!active.current ||
63
+ stream.current !== acquired ||
64
+ video.current !== preview)
65
+ return;
66
+ console.error("[CameraCaptureDialog] Could not play camera preview.", {
67
+ cause,
68
+ });
69
+ acquired.getTracks().forEach((track) => track.stop());
70
+ stream.current = null;
71
+ preview.srcObject = null;
72
+ setReady(false);
73
+ setError(copyRef.current.previewError);
74
+ });
75
+ }, []);
76
+ function stop() {
77
+ var _a;
78
+ (_a = stream.current) === null || _a === void 0 ? void 0 : _a.getTracks().forEach((track) => track.stop());
79
+ stream.current = null;
80
+ if (video.current)
81
+ video.current.srcObject = null;
82
+ }
83
+ function close() {
84
+ active.current = false;
85
+ stop();
86
+ onClose();
87
+ }
88
+ (0, react_1.useEffect)(() => {
89
+ let cancelled = false;
90
+ active.current = true;
91
+ // Camera consent follows the explicit menu action. Every owned stream, including
92
+ // a permission result arriving after dismissal, must stop before leaving capture.
93
+ async function start() {
94
+ var _a;
95
+ try {
96
+ if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia))
97
+ throw new Error("Camera API unavailable");
98
+ const acquired = await navigator.mediaDevices.getUserMedia({
99
+ video: { facingMode: initialFacingMode.current },
100
+ audio: false,
101
+ });
102
+ if (cancelled || !active.current) {
103
+ acquired.getTracks().forEach((track) => track.stop());
104
+ return;
105
+ }
106
+ stream.current = acquired;
107
+ attachPreview(video.current);
108
+ }
109
+ catch (cause) {
110
+ if (cancelled || !active.current)
111
+ return;
112
+ console.error("[CameraCaptureDialog] Could not start camera.", {
113
+ cause,
114
+ });
115
+ stop();
116
+ const denied = cause instanceof DOMException &&
117
+ (cause.name === "NotAllowedError" || cause.name === "SecurityError");
118
+ setError(denied ? copyRef.current.denied : copyRef.current.unavailable);
119
+ }
120
+ }
121
+ void start();
122
+ return () => {
123
+ cancelled = true;
124
+ active.current = false;
125
+ stop();
126
+ };
127
+ }, [attachPreview]);
128
+ function capture() {
129
+ if (!ready || error || capturing.current || !active.current)
130
+ return;
131
+ capturing.current = true;
132
+ setBusy(true);
133
+ try {
134
+ const preview = video.current;
135
+ if (!preview || !preview.videoWidth || !preview.videoHeight)
136
+ throw new Error("Camera frame is not ready");
137
+ const canvas = document.createElement("canvas");
138
+ canvas.width = preview.videoWidth;
139
+ canvas.height = preview.videoHeight;
140
+ const context = canvas.getContext("2d");
141
+ if (!context)
142
+ throw new Error("Camera capture canvas is unavailable");
143
+ context.drawImage(preview, 0, 0);
144
+ canvas.toBlob((blob) => {
145
+ if (!active.current)
146
+ return;
147
+ if (!blob) {
148
+ console.error("[CameraCaptureDialog] Camera capture returned no image.");
149
+ setError(copyRef.current.captureError);
150
+ setBusy(false);
151
+ capturing.current = false;
152
+ return;
153
+ }
154
+ active.current = false;
155
+ stop();
156
+ // Capture only prepares the existing crop flow; it never uploads or publishes.
157
+ onCapture(new File([blob], fileName, { type: "image/jpeg" }));
158
+ }, "image/jpeg", 0.92);
159
+ }
160
+ catch (cause) {
161
+ console.error("[CameraCaptureDialog] Could not capture photo.", {
162
+ cause,
163
+ });
164
+ setError(copyRef.current.captureError);
165
+ setBusy(false);
166
+ capturing.current = false;
167
+ }
168
+ }
169
+ return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: true, fullWidth: true, maxWidth: "xs", onClose: close, "aria-labelledby": titleId, onKeyDown: (event) => {
170
+ if (event.key === "Enter") {
171
+ event.stopPropagation();
172
+ if (!(event.target instanceof HTMLButtonElement))
173
+ event.preventDefault();
174
+ }
175
+ }, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { id: titleId, sx: { pr: 7 }, children: [copy.title, (0, jsx_runtime_1.jsx)(cameraCropPresentation_js_1.DialogCloseButton, { label: copy.close, onClose: close })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: "video", ref: attachPreview, autoPlay: true, muted: true, playsInline: true, "aria-label": copy.preview, onLoadedData: () => {
176
+ var _a;
177
+ if (active.current &&
178
+ stream.current &&
179
+ ((_a = video.current) === null || _a === void 0 ? void 0 : _a.srcObject) === stream.current)
180
+ setReady(true);
181
+ }, sx: {
182
+ width: "100%",
183
+ maxHeight: previewMaxHeight,
184
+ bgcolor: "action.hover",
185
+ borderRadius: 1,
186
+ } }), error ? ((0, jsx_runtime_1.jsx)(cameraCropPresentation_js_2.StatusNotice, { tone: "error", message: error })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", role: "status", children: ready ? copy.ready : copy.opening }))] }), (0, jsx_runtime_1.jsx)(cameraCropPresentation_js_1.DialogActionButtons, { confirmLabel: copy.capture, confirmDisabled: !ready || Boolean(error) || busy, confirmIcon: busy ? (0, jsx_runtime_1.jsx)(cameraCropPresentation_js_1.DialogActionProgress, {}) : (0, jsx_runtime_1.jsx)(CameraAlt_1.default, {}), onConfirm: capture })] }));
187
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.FileRow = FileRow;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const DeleteOutlineRounded_1 = __importDefault(require("@mui/icons-material/DeleteOutlineRounded"));
10
+ const material_1 = require("@mui/material");
11
+ const FileSwipeActionRow_js_1 = require("./FileSwipeActionRow.js");
12
+ function FileRow({ attachment, canDelete, onDelete, onPreview, thumbnail, sizeLabel, }) {
13
+ return ((0, jsx_runtime_1.jsx)(FileSwipeActionRow_js_1.SwipeActionRow, { canDelete: canDelete, onDelete: () => onDelete(attachment), dataComponent: "attachment-row-swipe-container", children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", sx: { alignItems: "center", gap: 1, minHeight: 56, px: 1.5 }, children: [(0, jsx_runtime_1.jsxs)(material_1.ButtonBase, { "aria-label": `Preview attachment ${attachment.fileName}`, "data-component": "attachment-preview-target", onClick: () => onPreview(attachment), sx: {
14
+ alignItems: "center",
15
+ borderRadius: 1,
16
+ flex: 1,
17
+ gap: 1,
18
+ justifyContent: "flex-start",
19
+ minWidth: 0,
20
+ p: 0.5,
21
+ textAlign: "left",
22
+ }, children: [thumbnail, (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { flex: 1, minWidth: 0 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, sx: { color: "text.primary", fontSize: 14 }, children: attachment.fileName }), (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.secondary", sx: { fontSize: 12 }, children: sizeLabel })] })] }), canDelete ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": `Delete attachment ${attachment.fileName}`, onClick: () => onDelete(attachment), size: "small", children: (0, jsx_runtime_1.jsx)(DeleteOutlineRounded_1.default, { fontSize: "small" }) })) : null] }) }));
23
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SwipeActionRow = void 0;
5
+ // The shared MUI row preserves the file adapter's error.main/common.white delete
6
+ // surface, background.paper content, spacing(2), Delete label, 160ms easing and
7
+ // reduced-motion behavior. Its gesture contract is the same: 12px direction lock,
8
+ // 72px delete threshold, 104px cap, pan-y, cancellation and click suppression.
9
+ // Keep one gesture implementation and the host's existing MUI theme context.
10
+ var SwipeActionRow_js_1 = require("../swipe/SwipeActionRow.js");
11
+ Object.defineProperty(exports, "SwipeActionRow", { enumerable: true, get: function () { return SwipeActionRow_js_1.SwipeActionRow; } });