@striae-org/striae 3.0.4

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 (223) hide show
  1. package/.env.example +100 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +18 -0
  4. package/README.md +133 -0
  5. package/app/components/actions/case-export/core-export.ts +328 -0
  6. package/app/components/actions/case-export/data-processing.ts +167 -0
  7. package/app/components/actions/case-export/download-handlers.ts +900 -0
  8. package/app/components/actions/case-export/index.ts +41 -0
  9. package/app/components/actions/case-export/metadata-helpers.ts +107 -0
  10. package/app/components/actions/case-export/types-constants.ts +56 -0
  11. package/app/components/actions/case-export/validation-utils.ts +25 -0
  12. package/app/components/actions/case-export.ts +4 -0
  13. package/app/components/actions/case-import/annotation-import.ts +35 -0
  14. package/app/components/actions/case-import/confirmation-import.ts +363 -0
  15. package/app/components/actions/case-import/image-operations.ts +61 -0
  16. package/app/components/actions/case-import/index.ts +39 -0
  17. package/app/components/actions/case-import/orchestrator.ts +420 -0
  18. package/app/components/actions/case-import/storage-operations.ts +270 -0
  19. package/app/components/actions/case-import/validation.ts +189 -0
  20. package/app/components/actions/case-import/zip-processing.ts +413 -0
  21. package/app/components/actions/case-manage.ts +524 -0
  22. package/app/components/actions/case-review.ts +4 -0
  23. package/app/components/actions/confirm-export.ts +351 -0
  24. package/app/components/actions/generate-pdf.ts +210 -0
  25. package/app/components/actions/image-manage.ts +385 -0
  26. package/app/components/actions/notes-manage.ts +33 -0
  27. package/app/components/actions/signout.module.css +15 -0
  28. package/app/components/actions/signout.tsx +50 -0
  29. package/app/components/audit/user-audit-viewer.tsx +975 -0
  30. package/app/components/audit/user-audit.module.css +568 -0
  31. package/app/components/auth/auth-provider.tsx +78 -0
  32. package/app/components/auth/mfa-enrollment.module.css +268 -0
  33. package/app/components/auth/mfa-enrollment.tsx +398 -0
  34. package/app/components/auth/mfa-verification.module.css +251 -0
  35. package/app/components/auth/mfa-verification.tsx +295 -0
  36. package/app/components/button/button.module.css +63 -0
  37. package/app/components/button/button.tsx +46 -0
  38. package/app/components/canvas/box-annotations/box-annotations.module.css +170 -0
  39. package/app/components/canvas/box-annotations/box-annotations.tsx +634 -0
  40. package/app/components/canvas/canvas.module.css +314 -0
  41. package/app/components/canvas/canvas.tsx +449 -0
  42. package/app/components/canvas/confirmation/confirmation.module.css +187 -0
  43. package/app/components/canvas/confirmation/confirmation.tsx +214 -0
  44. package/app/components/colors/colors.module.css +59 -0
  45. package/app/components/colors/colors.tsx +68 -0
  46. package/app/components/form/base-form.tsx +21 -0
  47. package/app/components/form/form-button.tsx +28 -0
  48. package/app/components/form/form-field.tsx +53 -0
  49. package/app/components/form/form-message.tsx +17 -0
  50. package/app/components/form/form-toggle.tsx +23 -0
  51. package/app/components/form/form.module.css +427 -0
  52. package/app/components/form/index.ts +6 -0
  53. package/app/components/icon/icon.module.css +3 -0
  54. package/app/components/icon/icon.tsx +27 -0
  55. package/app/components/icon/icons.svg +102 -0
  56. package/app/components/icon/manifest.json +110 -0
  57. package/app/components/sidebar/case-export/case-export.module.css +386 -0
  58. package/app/components/sidebar/case-export/case-export.tsx +317 -0
  59. package/app/components/sidebar/case-import/case-import.module.css +626 -0
  60. package/app/components/sidebar/case-import/case-import.tsx +404 -0
  61. package/app/components/sidebar/case-import/components/CasePreviewSection.tsx +72 -0
  62. package/app/components/sidebar/case-import/components/ConfirmationDialog.tsx +72 -0
  63. package/app/components/sidebar/case-import/components/ConfirmationPreviewSection.tsx +71 -0
  64. package/app/components/sidebar/case-import/components/ExistingCaseSection.tsx +40 -0
  65. package/app/components/sidebar/case-import/components/FileSelector.tsx +161 -0
  66. package/app/components/sidebar/case-import/components/ProgressSection.tsx +46 -0
  67. package/app/components/sidebar/case-import/hooks/useFilePreview.ts +101 -0
  68. package/app/components/sidebar/case-import/hooks/useImportExecution.ts +152 -0
  69. package/app/components/sidebar/case-import/hooks/useImportState.ts +88 -0
  70. package/app/components/sidebar/case-import/index.ts +18 -0
  71. package/app/components/sidebar/case-import/utils/file-validation.ts +43 -0
  72. package/app/components/sidebar/cases/case-sidebar.tsx +827 -0
  73. package/app/components/sidebar/cases/cases-modal.module.css +166 -0
  74. package/app/components/sidebar/cases/cases-modal.tsx +201 -0
  75. package/app/components/sidebar/cases/cases.module.css +713 -0
  76. package/app/components/sidebar/files/files-modal.module.css +209 -0
  77. package/app/components/sidebar/files/files-modal.tsx +239 -0
  78. package/app/components/sidebar/hash/hash-utility.module.css +366 -0
  79. package/app/components/sidebar/hash/hash-utility.tsx +982 -0
  80. package/app/components/sidebar/notes/notes-modal.tsx +51 -0
  81. package/app/components/sidebar/notes/notes-sidebar.tsx +491 -0
  82. package/app/components/sidebar/notes/notes.module.css +360 -0
  83. package/app/components/sidebar/sidebar-container.tsx +149 -0
  84. package/app/components/sidebar/sidebar.module.css +321 -0
  85. package/app/components/sidebar/sidebar.tsx +215 -0
  86. package/app/components/sidebar/upload/image-upload-zone.module.css +123 -0
  87. package/app/components/sidebar/upload/image-upload-zone.tsx +330 -0
  88. package/app/components/theme-provider/theme-provider.tsx +131 -0
  89. package/app/components/theme-provider/theme.ts +155 -0
  90. package/app/components/toast/toast.module.css +137 -0
  91. package/app/components/toast/toast.tsx +56 -0
  92. package/app/components/toolbar/toolbar-color-selector.module.css +171 -0
  93. package/app/components/toolbar/toolbar-color-selector.tsx +129 -0
  94. package/app/components/toolbar/toolbar.module.css +42 -0
  95. package/app/components/toolbar/toolbar.tsx +167 -0
  96. package/app/components/user/delete-account.module.css +274 -0
  97. package/app/components/user/delete-account.tsx +471 -0
  98. package/app/components/user/inactivity-warning.module.css +145 -0
  99. package/app/components/user/inactivity-warning.tsx +84 -0
  100. package/app/components/user/manage-profile.module.css +190 -0
  101. package/app/components/user/manage-profile.tsx +253 -0
  102. package/app/components/user/mfa-phone-update.tsx +739 -0
  103. package/app/config-example/admin-service.json +13 -0
  104. package/app/config-example/config.json +17 -0
  105. package/app/config-example/firebase.ts +21 -0
  106. package/app/config-example/inactivity.ts +13 -0
  107. package/app/config-example/meta-config.json +6 -0
  108. package/app/contexts/auth.context.ts +12 -0
  109. package/app/entry.client.tsx +12 -0
  110. package/app/entry.server.tsx +44 -0
  111. package/app/hooks/useInactivityTimeout.ts +110 -0
  112. package/app/root.tsx +170 -0
  113. package/app/routes/_index.tsx +16 -0
  114. package/app/routes/auth/emailActionHandler.module.css +232 -0
  115. package/app/routes/auth/emailActionHandler.tsx +405 -0
  116. package/app/routes/auth/emailVerification.tsx +120 -0
  117. package/app/routes/auth/login.module.css +523 -0
  118. package/app/routes/auth/login.tsx +654 -0
  119. package/app/routes/auth/passwordReset.module.css +274 -0
  120. package/app/routes/auth/passwordReset.tsx +154 -0
  121. package/app/routes/auth/route.ts +16 -0
  122. package/app/routes/mobile-prevented/mobilePrevented.module.css +47 -0
  123. package/app/routes/mobile-prevented/mobilePrevented.tsx +26 -0
  124. package/app/routes/mobile-prevented/route.ts +14 -0
  125. package/app/routes/striae/striae.module.css +30 -0
  126. package/app/routes/striae/striae.tsx +417 -0
  127. package/app/services/audit-export.service.ts +755 -0
  128. package/app/services/audit.service.ts +1454 -0
  129. package/app/services/firebase-errors.ts +106 -0
  130. package/app/services/firebase.ts +15 -0
  131. package/app/styles/legal-pages.module.css +113 -0
  132. package/app/styles/root.module.css +146 -0
  133. package/app/tailwind.css +225 -0
  134. package/app/types/annotations.ts +45 -0
  135. package/app/types/audit.ts +301 -0
  136. package/app/types/case.ts +90 -0
  137. package/app/types/export.ts +8 -0
  138. package/app/types/file.ts +30 -0
  139. package/app/types/import.ts +107 -0
  140. package/app/types/index.ts +24 -0
  141. package/app/types/user.ts +38 -0
  142. package/app/utils/SHA256.ts +461 -0
  143. package/app/utils/annotation-timestamp.ts +25 -0
  144. package/app/utils/audit-export-signature.ts +117 -0
  145. package/app/utils/auth-action-settings.ts +48 -0
  146. package/app/utils/auth.ts +34 -0
  147. package/app/utils/batch-operations.ts +135 -0
  148. package/app/utils/confirmation-signature.ts +193 -0
  149. package/app/utils/data-operations.ts +871 -0
  150. package/app/utils/device-detection.ts +5 -0
  151. package/app/utils/html-sanitizer.ts +80 -0
  152. package/app/utils/id-generator.ts +36 -0
  153. package/app/utils/meta.ts +48 -0
  154. package/app/utils/mfa-phone.ts +97 -0
  155. package/app/utils/mfa.ts +79 -0
  156. package/app/utils/password-policy.ts +28 -0
  157. package/app/utils/permissions.ts +562 -0
  158. package/app/utils/signature-utils.ts +160 -0
  159. package/app/utils/style.ts +83 -0
  160. package/app/utils/version.ts +5 -0
  161. package/firebase.json +11 -0
  162. package/functions/[[path]].ts +10 -0
  163. package/package.json +138 -0
  164. package/postcss.config.js +6 -0
  165. package/public/.well-known/publickey.info@striae.org.asc +17 -0
  166. package/public/.well-known/security.txt +7 -0
  167. package/public/_headers +28 -0
  168. package/public/_routes.json +13 -0
  169. package/public/assets/striae.jpg +0 -0
  170. package/public/clear.jpg +0 -0
  171. package/public/favicon.ico +0 -0
  172. package/public/favicon.svg +9 -0
  173. package/public/icon-256.png +0 -0
  174. package/public/icon-512.png +0 -0
  175. package/public/logo-dark.png +0 -0
  176. package/public/manifest.json +25 -0
  177. package/public/oin-badge.png +0 -0
  178. package/public/shortcut.png +0 -0
  179. package/public/social-image.png +0 -0
  180. package/public/striae-ascii.txt +10 -0
  181. package/scripts/deploy-all.sh +100 -0
  182. package/scripts/deploy-config.sh +940 -0
  183. package/scripts/deploy-pages.sh +34 -0
  184. package/scripts/deploy-worker-secrets.sh +215 -0
  185. package/scripts/dev.cjs +23 -0
  186. package/scripts/install-workers.sh +88 -0
  187. package/scripts/run-eslint.cjs +35 -0
  188. package/scripts/update-compatibility-dates.cjs +124 -0
  189. package/scripts/update-markdown-versions.cjs +43 -0
  190. package/tailwind.config.ts +22 -0
  191. package/tsconfig.json +33 -0
  192. package/vite.config.ts +35 -0
  193. package/worker-configuration.d.ts +7490 -0
  194. package/workers/audit-worker/package.json +17 -0
  195. package/workers/audit-worker/src/audit-worker.example.ts +195 -0
  196. package/workers/audit-worker/worker-configuration.d.ts +7448 -0
  197. package/workers/audit-worker/wrangler.jsonc.example +29 -0
  198. package/workers/data-worker/package.json +17 -0
  199. package/workers/data-worker/src/data-worker.example.ts +267 -0
  200. package/workers/data-worker/src/signature-utils.ts +79 -0
  201. package/workers/data-worker/src/signing-payload-utils.ts +290 -0
  202. package/workers/data-worker/worker-configuration.d.ts +7448 -0
  203. package/workers/data-worker/wrangler.jsonc.example +30 -0
  204. package/workers/image-worker/package.json +17 -0
  205. package/workers/image-worker/src/image-worker.example.ts +180 -0
  206. package/workers/image-worker/worker-configuration.d.ts +7447 -0
  207. package/workers/image-worker/wrangler.jsonc.example +22 -0
  208. package/workers/keys-worker/package.json +17 -0
  209. package/workers/keys-worker/src/keys.example.ts +66 -0
  210. package/workers/keys-worker/src/keys.ts +66 -0
  211. package/workers/keys-worker/worker-configuration.d.ts +7447 -0
  212. package/workers/keys-worker/wrangler.jsonc.example +22 -0
  213. package/workers/pdf-worker/package.json +17 -0
  214. package/workers/pdf-worker/src/format-striae.ts +534 -0
  215. package/workers/pdf-worker/src/pdf-worker.example.ts +119 -0
  216. package/workers/pdf-worker/src/report-types.ts +69 -0
  217. package/workers/pdf-worker/worker-configuration.d.ts +7448 -0
  218. package/workers/pdf-worker/wrangler.jsonc.example +26 -0
  219. package/workers/user-worker/package.json +17 -0
  220. package/workers/user-worker/src/user-worker.example.ts +636 -0
  221. package/workers/user-worker/worker-configuration.d.ts +7448 -0
  222. package/workers/user-worker/wrangler.jsonc.example +29 -0
  223. package/wrangler.toml.example +8 -0
@@ -0,0 +1,137 @@
1
+ .backdrop {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ background: color-mix(in lab, var(--black) 40%, transparent);
8
+ z-index: 999;
9
+ cursor: pointer;
10
+ }
11
+
12
+ .toast {
13
+ position: fixed;
14
+ top: 50%;
15
+ left: 50%;
16
+ transform: translate(-50%, -50%) scale(0.8);
17
+ display: flex;
18
+ align-items: center;
19
+ gap: var(--spaceM);
20
+ padding: var(--spaceL) var(--spaceXL);
21
+ border-radius: var(--radiusL);
22
+ background: var(--backgroundLight);
23
+ border: 2px solid var(--border);
24
+ box-shadow: 0 8px 32px color-mix(in lab, var(--black) 25%, transparent);
25
+ z-index: 1000;
26
+ opacity: 0;
27
+ transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
28
+ max-width: 400px;
29
+ min-width: 300px;
30
+ backdrop-filter: blur(10px);
31
+ }
32
+
33
+ .toast.show {
34
+ transform: translate(-50%, -50%) scale(1);
35
+ opacity: 1;
36
+ }
37
+
38
+ .toast.success {
39
+ background: var(--backgroundLight);
40
+ border-color: var(--success);
41
+ box-shadow: 0 8px 32px color-mix(in lab, var(--success) 20%, transparent);
42
+ }
43
+
44
+ .toast.success .icon {
45
+ color: var(--success);
46
+ background: color-mix(in lab, var(--success) 15%, transparent);
47
+ border-radius: 50%;
48
+ width: 28px;
49
+ height: 28px;
50
+ display: flex;
51
+ align-items: center;
52
+ justify-content: center;
53
+ font-size: 14px;
54
+ }
55
+
56
+ .toast.error {
57
+ background: var(--backgroundLight);
58
+ border-color: var(--error);
59
+ box-shadow: 0 8px 32px color-mix(in lab, var(--error) 20%, transparent);
60
+ }
61
+
62
+ .toast.error .icon {
63
+ color: var(--error);
64
+ background: color-mix(in lab, var(--error) 15%, transparent);
65
+ border-radius: 50%;
66
+ width: 28px;
67
+ height: 28px;
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ font-size: 14px;
72
+ }
73
+
74
+ .toast.warning {
75
+ background: var(--backgroundLight);
76
+ border-color: var(--error);
77
+ box-shadow: 0 8px 32px color-mix(in lab, var(--error) 20%, transparent);
78
+ }
79
+
80
+ .toast.warning .icon {
81
+ color: var(--error);
82
+ background: color-mix(in lab, var(--error) 15%, transparent);
83
+ border-radius: 50%;
84
+ width: 28px;
85
+ height: 28px;
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ font-size: 14px;
90
+ }
91
+
92
+ .icon {
93
+ font-weight: bold;
94
+ flex-shrink: 0;
95
+ }
96
+
97
+ .message {
98
+ flex: 1;
99
+ font-size: 16px;
100
+ font-weight: 600;
101
+ color: var(--text);
102
+ line-height: 1.5;
103
+ }
104
+
105
+ .message a,
106
+ .message a:visited {
107
+ color: var(--primary);
108
+ text-decoration: underline;
109
+ text-underline-offset: 2px;
110
+ transition: color var(--durationS) var(--bezierFastoutSlowin);
111
+ }
112
+
113
+ .message a:hover {
114
+ color: color-mix(in lab, var(--primary) 85%, var(--black));
115
+ }
116
+
117
+ .closeButton {
118
+ background: none;
119
+ border: none;
120
+ font-size: 20px;
121
+ color: var(--textLight);
122
+ cursor: pointer;
123
+ padding: var(--spaceXS);
124
+ width: 32px;
125
+ height: 32px;
126
+ display: flex;
127
+ align-items: center;
128
+ justify-content: center;
129
+ border-radius: var(--radiusS);
130
+ transition: all 0.2s ease;
131
+ flex-shrink: 0;
132
+ }
133
+
134
+ .closeButton:hover {
135
+ background: color-mix(in lab, var(--text) 10%, transparent);
136
+ color: var(--text);
137
+ }
@@ -0,0 +1,56 @@
1
+ import { useEffect, type ReactNode } from 'react';
2
+ import styles from './toast.module.css';
3
+
4
+ interface ToastProps {
5
+ message: ReactNode;
6
+ type: 'success' | 'error' | 'warning';
7
+ isVisible: boolean;
8
+ onClose: () => void;
9
+ duration?: number;
10
+ }
11
+
12
+ export const Toast = ({ message, type, isVisible, onClose, duration = 4000 }: ToastProps) => {
13
+ useEffect(() => {
14
+ if (isVisible && duration > 0) {
15
+ const timer = setTimeout(() => {
16
+ onClose();
17
+ }, duration);
18
+
19
+ return () => clearTimeout(timer);
20
+ }
21
+ }, [isVisible, onClose, duration]);
22
+
23
+ if (!isVisible) return null;
24
+
25
+ const handleBackdropKeyDown = (e: React.KeyboardEvent) => {
26
+ if (e.key === 'Enter' || e.key === ' ') {
27
+ onClose();
28
+ }
29
+ };
30
+
31
+ return (
32
+ <>
33
+ <div
34
+ className={styles.backdrop}
35
+ onClick={onClose}
36
+ onKeyDown={handleBackdropKeyDown}
37
+ role="button"
38
+ tabIndex={0}
39
+ aria-label="Close notification"
40
+ ></div>
41
+ <div className={`${styles.toast} ${styles[type]} ${isVisible ? styles.show : ''}`}>
42
+ <div className={styles.icon}>
43
+ {type === 'success' ? '✓' : type === 'warning' ? '!' : '✗'}
44
+ </div>
45
+ <span className={styles.message}>{message}</span>
46
+ <button
47
+ className={styles.closeButton}
48
+ onClick={onClose}
49
+ aria-label="Close notification"
50
+ >
51
+ ×
52
+ </button>
53
+ </div>
54
+ </>
55
+ );
56
+ };
@@ -0,0 +1,171 @@
1
+ .toolbarColorSelector {
2
+ position: absolute;
3
+ left: calc(100% + var(--spaceM));
4
+ bottom: 0;
5
+ background: var(--background);
6
+ border-radius: 5px;
7
+ box-shadow: 0 var(--spaceXS) var(--spaceM)
8
+ color-mix(in lab, var(--black) 10%, transparent);
9
+ padding: var(--spaceS);
10
+ width: 200px;
11
+ z-index: 50;
12
+ }
13
+
14
+ .header {
15
+ display: flex;
16
+ justify-content: flex-start;
17
+ align-items: center;
18
+ margin-bottom: var(--spaceS);
19
+ padding-bottom: var(--spaceXS);
20
+ border-bottom: 1px solid var(--border);
21
+ }
22
+
23
+ .title {
24
+ font-size: var(--fontSizeS);
25
+ font-weight: 600;
26
+ color: var(--foreground);
27
+ }
28
+
29
+ .actions {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: var(--spaceXS);
33
+ margin-top: var(--spaceS);
34
+ padding-top: var(--spaceS);
35
+ border-top: 1px solid var(--border);
36
+ }
37
+
38
+ .actionButton {
39
+ width: 100%;
40
+ min-height: 38px;
41
+ border: none;
42
+ border-radius: 4px;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ cursor: pointer;
47
+ font-size: var(--fontSizeS);
48
+ font-weight: 600;
49
+ color: white;
50
+ transition: background-color var(--durationS) var(--bezierFastoutSlowin);
51
+ }
52
+
53
+ .confirmButton {
54
+ background: var(--success);
55
+ }
56
+
57
+ .confirmButton:hover {
58
+ background: color-mix(in lab, var(--success) 80%, var(--black));
59
+ }
60
+
61
+ .cancelButton {
62
+ background: var(--error);
63
+ }
64
+
65
+ .cancelButton:hover {
66
+ background: color-mix(in lab, var(--error) 80%, var(--black));
67
+ }
68
+
69
+ .content {
70
+ display: flex;
71
+ flex-direction: column;
72
+ gap: var(--spaceS);
73
+ }
74
+
75
+ .toggleSection {
76
+ display: flex;
77
+ justify-content: center;
78
+ }
79
+
80
+ .toggleButton {
81
+ background: var(--backgroundSecondary);
82
+ color: var(--foreground);
83
+ border: 1px solid var(--border);
84
+ border-radius: 3px;
85
+ padding: var(--spaceXS) var(--spaceS);
86
+ cursor: pointer;
87
+ font-size: var(--fontSizeXS);
88
+ }
89
+
90
+ .toggleButton:hover {
91
+ background: var(--backgroundTertiary);
92
+ }
93
+
94
+ .colorWheelSection {
95
+ display: flex;
96
+ justify-content: center;
97
+ }
98
+
99
+ .colorWheel {
100
+ width: 60px;
101
+ height: 40px;
102
+ border: 1px solid var(--border);
103
+ border-radius: 3px;
104
+ cursor: pointer;
105
+ }
106
+
107
+ .colorGrid {
108
+ display: grid;
109
+ grid-template-columns: repeat(5, 1fr);
110
+ gap: var(--spaceXS);
111
+ padding: var(--spaceXS);
112
+ }
113
+
114
+ .colorSwatch {
115
+ width: 28px;
116
+ height: 28px;
117
+ border: 2px solid var(--border);
118
+ border-radius: 3px;
119
+ cursor: pointer;
120
+ position: relative;
121
+ transition: all 0.2s ease;
122
+ }
123
+
124
+ .colorSwatch:hover {
125
+ transform: scale(1.1);
126
+ border-color: var(--foreground);
127
+ }
128
+
129
+ .colorSwatch.selected {
130
+ border-color: var(--foreground);
131
+ border-width: 3px;
132
+ box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--foreground);
133
+ transform: scale(1.15);
134
+ position: relative;
135
+ }
136
+
137
+ .colorSwatch.selected::after {
138
+ content: "✓";
139
+ position: absolute;
140
+ top: 50%;
141
+ left: 50%;
142
+ transform: translate(-50%, -50%);
143
+ color: var(--foreground);
144
+ font-weight: bold;
145
+ font-size: 14px;
146
+ text-shadow: 0 0 3px var(--background), 0 0 6px var(--background);
147
+ pointer-events: none;
148
+ }
149
+
150
+ .preview {
151
+ display: flex;
152
+ align-items: center;
153
+ gap: var(--spaceS);
154
+ padding: var(--spaceXS);
155
+ background: var(--backgroundSecondary);
156
+ border-radius: 3px;
157
+ }
158
+
159
+ .previewLabel {
160
+ font-size: var(--fontSizeXS);
161
+ color: var(--foreground);
162
+ font-weight: 500;
163
+ }
164
+
165
+ .previewSwatch {
166
+ width: 20px;
167
+ height: 20px;
168
+ border: 1px solid var(--border);
169
+ border-radius: 2px;
170
+ flex-shrink: 0;
171
+ }
@@ -0,0 +1,129 @@
1
+ import { useState, useEffect } from 'react';
2
+ import styles from './toolbar-color-selector.module.css';
3
+
4
+ interface ToolbarColorSelectorProps {
5
+ selectedColor: string;
6
+ onColorConfirm: (color: string) => void;
7
+ onCancel: () => void;
8
+ isVisible: boolean;
9
+ }
10
+
11
+ interface ColorOption {
12
+ value: string;
13
+ label: string;
14
+ }
15
+
16
+ const commonColors: ColorOption[] = [
17
+ { value: '#ff0000', label: 'Red' },
18
+ { value: '#ff8000', label: 'Orange' },
19
+ { value: '#ffde21', label: 'Yellow' },
20
+ { value: '#00ff00', label: 'Green' },
21
+ { value: '#00ffff', label: 'Cyan' },
22
+ { value: '#0000ff', label: 'Blue' },
23
+ { value: '#8000ff', label: 'Purple' },
24
+ { value: '#ff00ff', label: 'Magenta' },
25
+ { value: '#000000', label: 'Black' },
26
+ { value: '#ffffff', label: 'White' }
27
+ ];
28
+
29
+ export const ToolbarColorSelector = ({
30
+ selectedColor,
31
+ onColorConfirm,
32
+ onCancel,
33
+ isVisible
34
+ }: ToolbarColorSelectorProps) => {
35
+ const [tempSelectedColor, setTempSelectedColor] = useState(selectedColor);
36
+ const [showColorWheel, setShowColorWheel] = useState(false);
37
+
38
+ const handleConfirm = () => {
39
+ onColorConfirm(tempSelectedColor);
40
+ };
41
+
42
+ const handleCancel = () => {
43
+ setTempSelectedColor(selectedColor); // Reset to original color
44
+ setShowColorWheel(false); // Reset to presets view
45
+ onCancel();
46
+ };
47
+
48
+ // Handle keyboard events for escape
49
+ useEffect(() => {
50
+ const handleKeyDown = (e: KeyboardEvent) => {
51
+ if (e.key === 'Escape' && isVisible) {
52
+ handleCancel();
53
+ }
54
+ };
55
+
56
+ if (isVisible) {
57
+ document.addEventListener('keydown', handleKeyDown);
58
+ }
59
+
60
+ return () => {
61
+ document.removeEventListener('keydown', handleKeyDown);
62
+ };
63
+ }, [isVisible, handleCancel]);
64
+
65
+ if (!isVisible) return null;
66
+
67
+ return (
68
+ <div className={styles.toolbarColorSelector}>
69
+ <div className={styles.header}>
70
+ <span className={styles.title}>Select Box Color</span>
71
+ </div>
72
+
73
+ <div className={styles.content}>
74
+ <div className={styles.toggleSection}>
75
+ <button
76
+ onClick={() => setShowColorWheel(!showColorWheel)}
77
+ className={styles.toggleButton}
78
+ >
79
+ {showColorWheel ? 'Presets' : 'Custom'}
80
+ </button>
81
+ </div>
82
+
83
+ {showColorWheel ? (
84
+ <div className={styles.colorWheelSection}>
85
+ <input
86
+ type="color"
87
+ value={tempSelectedColor}
88
+ onChange={(e) => setTempSelectedColor(e.target.value)}
89
+ className={styles.colorWheel}
90
+ title="Choose a custom color"
91
+ />
92
+ </div>
93
+ ) : (
94
+ <div className={styles.colorGrid}>
95
+ {commonColors.map((color) => (
96
+ <button
97
+ key={color.value}
98
+ className={`${styles.colorSwatch} ${color.value === tempSelectedColor ? styles.selected : ''}`}
99
+ style={{ backgroundColor: color.value }}
100
+ onClick={() => setTempSelectedColor(color.value)}
101
+ aria-label={`Select ${color.label}`}
102
+ title={color.label}
103
+ />
104
+ ))}
105
+ </div>
106
+ )}
107
+ </div>
108
+
109
+ <div className={styles.actions}>
110
+ <button
111
+ type="button"
112
+ onClick={handleConfirm}
113
+ className={`${styles.actionButton} ${styles.confirmButton}`}
114
+ title="Apply selected color"
115
+ >
116
+ ✓ Apply Color
117
+ </button>
118
+ <button
119
+ type="button"
120
+ onClick={handleCancel}
121
+ className={`${styles.actionButton} ${styles.cancelButton}`}
122
+ title="Cancel color selection"
123
+ >
124
+ ✕ Cancel
125
+ </button>
126
+ </div>
127
+ </div>
128
+ );
129
+ };
@@ -0,0 +1,42 @@
1
+ .toolbarContainer {
2
+ position: relative;
3
+ }
4
+
5
+ .toolbar {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: var(--spaceS);
9
+ padding: var(--spaceS);
10
+ background: var(--background);
11
+ border-radius: 5px;
12
+ box-shadow: 0 var(--spaceXS) var(--spaceM) color-mix(in lab, var(--black) 10%, transparent);
13
+ height: auto;
14
+ overflow: hidden;
15
+ transition: opacity var(--durationM) var(--bezierFastoutSlowin);
16
+ }
17
+
18
+ .toggleButton {
19
+ height: 40px;
20
+ flex-shrink: 0;
21
+ margin-bottom: var(--spaceM);
22
+ }
23
+
24
+ .toolbarContent {
25
+ display: flex;
26
+ flex-direction: column;
27
+ gap: var(--spaceS);
28
+ height: auto;
29
+ transition: opacity var(--durationM) var(--bezierFastoutSlowin);
30
+ }
31
+
32
+ .hidden {
33
+ height: calc(50px + (var(--spaceS) * 2));
34
+ opacity: 0.3;
35
+ }
36
+
37
+ .hidden .toolbarContent {
38
+ opacity: 0;
39
+ pointer-events: none;
40
+ height: 0;
41
+ overflow: hidden;
42
+ }
@@ -0,0 +1,167 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { Button } from '../button/button';
3
+ import { ToolbarColorSelector } from './toolbar-color-selector';
4
+ import styles from './toolbar.module.css';
5
+
6
+ type ToolId = 'number' | 'class' | 'index' | 'id' | 'notes' | 'print' | 'visibility' | 'box';
7
+
8
+ interface ToolbarProps {
9
+ onToolSelect?: (toolId: ToolId, active: boolean) => void;
10
+ onGeneratePDF?: () => void;
11
+ canGeneratePDF?: boolean;
12
+ onVisibilityChange?: (visible: boolean) => void;
13
+ isGeneratingPDF?: boolean;
14
+ onColorChange?: (color: string) => void;
15
+ selectedColor?: string;
16
+ isReadOnly?: boolean;
17
+ isConfirmed?: boolean;
18
+ isNotesOpen?: boolean;
19
+ }
20
+
21
+ export const Toolbar = ({
22
+ onToolSelect,
23
+ onVisibilityChange,
24
+ onGeneratePDF,
25
+ canGeneratePDF,
26
+ isGeneratingPDF = false,
27
+ onColorChange,
28
+ selectedColor = '#ff0000',
29
+ isReadOnly = false,
30
+ isConfirmed = false,
31
+ isNotesOpen = false
32
+ }: ToolbarProps) => {
33
+ const [activeTools, setActiveTools] = useState<Set<ToolId>>(new Set());
34
+ const [isVisible, setIsVisible] = useState(true);
35
+ const [showColorSelector, setShowColorSelector] = useState(false);
36
+
37
+ // Automatically deactivate box annotations when notes are opened
38
+ useEffect(() => {
39
+ if (isNotesOpen && activeTools.has('box')) {
40
+ setActiveTools(prev => {
41
+ const next = new Set(prev);
42
+ next.delete('box');
43
+ onToolSelect?.('box', false);
44
+ return next;
45
+ });
46
+ setShowColorSelector(false);
47
+ }
48
+ }, [isNotesOpen, activeTools, onToolSelect]);
49
+
50
+ const handleToolClick = (toolId: ToolId) => {
51
+ if (toolId === 'print') {
52
+ if (onGeneratePDF && canGeneratePDF) {
53
+ onGeneratePDF();
54
+ }
55
+ onToolSelect?.('print', true);
56
+ return;
57
+ }
58
+
59
+ if (toolId === 'visibility') {
60
+ setIsVisible(!isVisible);
61
+ onVisibilityChange?.(!isVisible);
62
+ return;
63
+ }
64
+
65
+ // Prevent box annotations when notes sidebar is open
66
+ if (toolId === 'box' && isNotesOpen) {
67
+ return;
68
+ }
69
+
70
+ setActiveTools(prev => {
71
+ const next = new Set(prev);
72
+ if (next.has(toolId)) {
73
+ next.delete(toolId);
74
+ // Hide color selector when box tool is deactivated
75
+ if (toolId === 'box') {
76
+ setShowColorSelector(false);
77
+ }
78
+ } else {
79
+ next.add(toolId);
80
+ // Show color selector when box tool is activated (but not for confirmed images or read-only mode)
81
+ if (toolId === 'box' && !isConfirmed && !isReadOnly) {
82
+ setShowColorSelector(true);
83
+ }
84
+ }
85
+ onToolSelect?.(toolId, next.has(toolId));
86
+ return next;
87
+ });
88
+ };
89
+
90
+ const handleColorConfirm = (color: string) => {
91
+ onColorChange?.(color);
92
+ setShowColorSelector(false);
93
+ };
94
+
95
+ const handleColorCancel = () => {
96
+ setShowColorSelector(false);
97
+ };
98
+
99
+ return (
100
+ <div className={styles.toolbarContainer}>
101
+ <div className={`${styles.toolbar} ${!isVisible ? styles.hidden : ''}`}>
102
+ <div className={styles.toggleButton}>
103
+ <Button
104
+ iconId={isVisible ? 'eye-off' : 'eye'}
105
+ isActive={false}
106
+ onClick={() => handleToolClick('visibility')}
107
+ ariaLabel={isVisible ? "Hide toolbar" : "Show toolbar"}
108
+ />
109
+ </div>
110
+ <div className={styles.toolbarContent} role="toolbar" aria-label="Annotation tools">
111
+ <Button
112
+ iconId="number"
113
+ isActive={activeTools.has('number')}
114
+ onClick={() => handleToolClick('number')}
115
+ ariaLabel="Case & Item Numbers"
116
+ />
117
+ <Button
118
+ iconId="class"
119
+ isActive={activeTools.has('class')}
120
+ onClick={() => handleToolClick('class')}
121
+ ariaLabel="Class Characteristics"
122
+ />
123
+ <Button
124
+ iconId="index"
125
+ isActive={activeTools.has('index')}
126
+ onClick={() => handleToolClick('index')}
127
+ ariaLabel="Index Marks"
128
+ />
129
+ <Button
130
+ iconId="id"
131
+ isActive={activeTools.has('id')}
132
+ onClick={() => handleToolClick('id')}
133
+ ariaLabel="Support Level"
134
+ />
135
+ <Button
136
+ iconId="box"
137
+ isActive={activeTools.has('box')}
138
+ onClick={() => handleToolClick('box')}
139
+ ariaLabel="Box Annotations"
140
+ disabled={isNotesOpen}
141
+ />
142
+ <Button
143
+ iconId="notes"
144
+ isActive={activeTools.has('notes')}
145
+ onClick={() => handleToolClick('notes')}
146
+ ariaLabel="Additional Notes"
147
+ />
148
+ <Button
149
+ iconId="print"
150
+ isActive={false}
151
+ onClick={() => handleToolClick('print')}
152
+ ariaLabel={isGeneratingPDF ? "Generating PDF..." : "Save/Print to PDF"}
153
+ disabled={!canGeneratePDF || isGeneratingPDF || isReadOnly}
154
+ showSpinner={isGeneratingPDF}
155
+ />
156
+ </div>
157
+ </div>
158
+
159
+ <ToolbarColorSelector
160
+ selectedColor={selectedColor}
161
+ onColorConfirm={handleColorConfirm}
162
+ onCancel={handleColorCancel}
163
+ isVisible={showColorSelector && isVisible && !isReadOnly && !isConfirmed}
164
+ />
165
+ </div>
166
+ );
167
+ };