@unofficialbox/box-open-elements 0.5.0 → 0.7.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 (227) hide show
  1. package/README.md +27 -73
  2. package/dist/components/collections/table.d.ts +113 -3
  3. package/dist/components/collections/table.js +540 -37
  4. package/dist/components/feedback/due-badge.d.ts +38 -0
  5. package/dist/components/feedback/due-badge.js +168 -0
  6. package/dist/components/feedback/due-types.d.ts +32 -0
  7. package/dist/components/feedback/due-types.js +91 -0
  8. package/dist/components/feedback/progress-steps.d.ts +51 -5
  9. package/dist/components/feedback/progress-steps.js +200 -22
  10. package/dist/components/feedback/stage-path.d.ts +44 -0
  11. package/dist/components/feedback/stage-path.js +235 -0
  12. package/dist/components/forms/select.d.ts +21 -0
  13. package/dist/components/forms/select.js +100 -3
  14. package/dist/components/forms/text-field.d.ts +21 -0
  15. package/dist/components/forms/text-field.js +100 -1
  16. package/dist/components/layout/nav-sidebar.d.ts +14 -0
  17. package/dist/components/layout/nav-sidebar.js +49 -0
  18. package/dist/components/layout/split-view.d.ts +14 -0
  19. package/dist/components/layout/split-view.js +80 -1
  20. package/dist/components/overlays/command-palette.d.ts +62 -0
  21. package/dist/components/overlays/command-palette.js +537 -0
  22. package/dist/components/overlays/command-types.d.ts +90 -0
  23. package/dist/components/overlays/command-types.js +259 -0
  24. package/dist/components/overlays/drawer.d.ts +18 -0
  25. package/dist/components/overlays/drawer.js +135 -9
  26. package/dist/components/overlays/shortcuts-overlay.d.ts +48 -0
  27. package/dist/components/overlays/shortcuts-overlay.js +385 -0
  28. package/dist/components/overlays/tooltip.js +1 -1
  29. package/dist/core/index.d.ts +4 -0
  30. package/dist/core/index.js +2 -0
  31. package/dist/core/offset-window.d.ts +70 -0
  32. package/dist/core/offset-window.js +134 -0
  33. package/dist/core/virtualize.d.ts +71 -0
  34. package/dist/core/virtualize.js +67 -0
  35. package/dist/element-maps.d.ts +292 -0
  36. package/dist/element-maps.js +1 -0
  37. package/dist/entries/activity-density.d.ts +1 -0
  38. package/dist/entries/activity-density.js +1 -0
  39. package/dist/entries/agent-chat.d.ts +1 -0
  40. package/dist/entries/agent-chat.js +1 -0
  41. package/dist/entries/audit-log.d.ts +1 -0
  42. package/dist/entries/audit-log.js +1 -0
  43. package/dist/entries/command-palette.d.ts +1 -0
  44. package/dist/entries/command-palette.js +1 -0
  45. package/dist/entries/compare-view.d.ts +1 -0
  46. package/dist/entries/compare-view.js +1 -0
  47. package/dist/entries/diff-viewer.d.ts +1 -0
  48. package/dist/entries/diff-viewer.js +1 -0
  49. package/dist/entries/due-badge.d.ts +1 -0
  50. package/dist/entries/due-badge.js +1 -0
  51. package/dist/entries/form-wizard.d.ts +1 -0
  52. package/dist/entries/form-wizard.js +1 -0
  53. package/dist/entries/lineage-graph.d.ts +1 -0
  54. package/dist/entries/lineage-graph.js +1 -0
  55. package/dist/entries/notification-bell.d.ts +1 -0
  56. package/dist/entries/notification-bell.js +1 -0
  57. package/dist/entries/notification-inbox.d.ts +1 -0
  58. package/dist/entries/notification-inbox.js +1 -0
  59. package/dist/entries/provenance-strip.d.ts +1 -0
  60. package/dist/entries/provenance-strip.js +1 -0
  61. package/dist/entries/run-trace.d.ts +1 -0
  62. package/dist/entries/run-trace.js +1 -0
  63. package/dist/entries/shortcuts-overlay.d.ts +1 -0
  64. package/dist/entries/shortcuts-overlay.js +1 -0
  65. package/dist/entries/signature-ceremony.d.ts +1 -0
  66. package/dist/entries/signature-ceremony.js +1 -0
  67. package/dist/entries/stage-path.d.ts +1 -0
  68. package/dist/entries/stage-path.js +1 -0
  69. package/dist/entries/timeline.d.ts +1 -0
  70. package/dist/entries/timeline.js +1 -0
  71. package/dist/entries/version-graph.d.ts +1 -0
  72. package/dist/entries/version-graph.js +1 -0
  73. package/dist/entries/version-list.d.ts +1 -0
  74. package/dist/entries/version-list.js +1 -0
  75. package/dist/entries/wizard-summary.d.ts +1 -0
  76. package/dist/entries/wizard-summary.js +1 -0
  77. package/dist/entries/work-queue.d.ts +1 -0
  78. package/dist/entries/work-queue.js +1 -0
  79. package/dist/entries/workload-board.d.ts +1 -0
  80. package/dist/entries/workload-board.js +1 -0
  81. package/dist/index.d.ts +21 -0
  82. package/dist/index.js +21 -0
  83. package/dist/patterns/agent-chat/agent-chat.d.ts +75 -0
  84. package/dist/patterns/agent-chat/agent-chat.js +820 -0
  85. package/dist/patterns/agent-chat/controller.d.ts +27 -0
  86. package/dist/patterns/agent-chat/controller.js +182 -0
  87. package/dist/patterns/agent-chat/index.d.ts +3 -0
  88. package/dist/patterns/agent-chat/index.js +6 -0
  89. package/dist/patterns/agent-chat/types.d.ts +109 -0
  90. package/dist/patterns/agent-chat/types.js +1 -0
  91. package/dist/patterns/audit/activity-density.d.ts +68 -0
  92. package/dist/patterns/audit/activity-density.js +428 -0
  93. package/dist/patterns/audit/audit-log.d.ts +182 -0
  94. package/dist/patterns/audit/audit-log.js +1082 -0
  95. package/dist/patterns/audit/index.d.ts +3 -0
  96. package/dist/patterns/audit/index.js +7 -0
  97. package/dist/patterns/audit/shared.d.ts +10 -0
  98. package/dist/patterns/audit/shared.js +50 -0
  99. package/dist/patterns/audit/types.d.ts +143 -0
  100. package/dist/patterns/audit/types.js +327 -0
  101. package/dist/patterns/audit/window.d.ts +116 -0
  102. package/dist/patterns/audit/window.js +132 -0
  103. package/dist/patterns/content-explorer/actions/controller.js +12 -2
  104. package/dist/patterns/content-explorer/box-transport.js +117 -25
  105. package/dist/patterns/content-explorer/content-explorer.d.ts +13 -1
  106. package/dist/patterns/content-explorer/content-explorer.js +36 -3
  107. package/dist/patterns/content-explorer/contracts.d.ts +24 -1
  108. package/dist/patterns/content-explorer/contracts.js +68 -11
  109. package/dist/patterns/content-explorer/controller.d.ts +16 -1
  110. package/dist/patterns/content-explorer/controller.js +130 -4
  111. package/dist/patterns/content-explorer/navigation/controller.js +11 -9
  112. package/dist/patterns/content-explorer/types.d.ts +58 -1
  113. package/dist/patterns/content-picker/content-picker.d.ts +71 -0
  114. package/dist/patterns/content-picker/content-picker.js +747 -0
  115. package/dist/patterns/content-picker/controller.d.ts +38 -0
  116. package/dist/patterns/content-picker/controller.js +141 -0
  117. package/dist/patterns/content-picker/index.d.ts +3 -0
  118. package/dist/patterns/content-picker/index.js +6 -0
  119. package/dist/patterns/content-picker/types.d.ts +52 -0
  120. package/dist/patterns/content-picker/types.js +26 -0
  121. package/dist/patterns/content-sidebar/content-sidebar.d.ts +43 -0
  122. package/dist/patterns/content-sidebar/content-sidebar.js +293 -0
  123. package/dist/patterns/content-sidebar/index.d.ts +2 -0
  124. package/dist/patterns/content-sidebar/index.js +4 -0
  125. package/dist/patterns/content-sidebar/types.d.ts +18 -0
  126. package/dist/patterns/content-sidebar/types.js +20 -0
  127. package/dist/patterns/content-uploader/box-transport.d.ts +14 -0
  128. package/dist/patterns/content-uploader/box-transport.js +54 -0
  129. package/dist/patterns/content-uploader/content-uploader.d.ts +62 -0
  130. package/dist/patterns/content-uploader/content-uploader.js +559 -0
  131. package/dist/patterns/content-uploader/controller.d.ts +39 -0
  132. package/dist/patterns/content-uploader/controller.js +227 -0
  133. package/dist/patterns/content-uploader/index.d.ts +4 -0
  134. package/dist/patterns/content-uploader/index.js +8 -0
  135. package/dist/patterns/content-uploader/types.d.ts +120 -0
  136. package/dist/patterns/content-uploader/types.js +38 -0
  137. package/dist/patterns/diff/compare-view.d.ts +47 -0
  138. package/dist/patterns/diff/compare-view.js +276 -0
  139. package/dist/patterns/diff/diff-viewer.d.ts +42 -0
  140. package/dist/patterns/diff/diff-viewer.js +434 -0
  141. package/dist/patterns/diff/engine.d.ts +22 -0
  142. package/dist/patterns/diff/engine.js +276 -0
  143. package/dist/patterns/diff/index.d.ts +4 -0
  144. package/dist/patterns/diff/index.js +8 -0
  145. package/dist/patterns/diff/types.d.ts +69 -0
  146. package/dist/patterns/diff/types.js +24 -0
  147. package/dist/patterns/form-wizard/controller.d.ts +39 -0
  148. package/dist/patterns/form-wizard/controller.js +157 -0
  149. package/dist/patterns/form-wizard/form-wizard.d.ts +63 -0
  150. package/dist/patterns/form-wizard/form-wizard.js +468 -0
  151. package/dist/patterns/form-wizard/index.d.ts +4 -0
  152. package/dist/patterns/form-wizard/index.js +8 -0
  153. package/dist/patterns/form-wizard/types.d.ts +109 -0
  154. package/dist/patterns/form-wizard/types.js +83 -0
  155. package/dist/patterns/form-wizard/wizard-summary.d.ts +62 -0
  156. package/dist/patterns/form-wizard/wizard-summary.js +324 -0
  157. package/dist/patterns/internal/safe-href.d.ts +17 -0
  158. package/dist/patterns/internal/safe-href.js +17 -0
  159. package/dist/patterns/lineage/index.d.ts +3 -0
  160. package/dist/patterns/lineage/index.js +6 -0
  161. package/dist/patterns/lineage/lineage-graph.d.ts +30 -0
  162. package/dist/patterns/lineage/lineage-graph.js +434 -0
  163. package/dist/patterns/lineage/provenance-strip.d.ts +22 -0
  164. package/dist/patterns/lineage/provenance-strip.js +194 -0
  165. package/dist/patterns/lineage/types.d.ts +53 -0
  166. package/dist/patterns/lineage/types.js +49 -0
  167. package/dist/patterns/notifications/index.d.ts +3 -0
  168. package/dist/patterns/notifications/index.js +6 -0
  169. package/dist/patterns/notifications/notification-bell.d.ts +38 -0
  170. package/dist/patterns/notifications/notification-bell.js +198 -0
  171. package/dist/patterns/notifications/notification-inbox.d.ts +46 -0
  172. package/dist/patterns/notifications/notification-inbox.js +537 -0
  173. package/dist/patterns/notifications/types.d.ts +61 -0
  174. package/dist/patterns/notifications/types.js +108 -0
  175. package/dist/patterns/preview/annotation-inspector.d.ts +25 -6
  176. package/dist/patterns/preview/annotation-inspector.js +239 -94
  177. package/dist/patterns/preview/annotation-thread.d.ts +25 -5
  178. package/dist/patterns/preview/annotation-thread.js +233 -82
  179. package/dist/patterns/preview/annotation-toolbar.d.ts +20 -6
  180. package/dist/patterns/preview/annotation-toolbar.js +162 -96
  181. package/dist/patterns/preview/content-preview-adapter.d.ts +10 -1
  182. package/dist/patterns/preview/content-preview-adapter.js +26 -1
  183. package/dist/patterns/preview/preview-element.d.ts +15 -2
  184. package/dist/patterns/preview/preview-element.js +223 -52
  185. package/dist/patterns/preview/provider-adapter.d.ts +47 -0
  186. package/dist/patterns/preview/provider-adapter.js +17 -0
  187. package/dist/patterns/run/index.d.ts +2 -0
  188. package/dist/patterns/run/index.js +4 -0
  189. package/dist/patterns/run/run-trace.d.ts +40 -0
  190. package/dist/patterns/run/run-trace.js +441 -0
  191. package/dist/patterns/run/types.d.ts +66 -0
  192. package/dist/patterns/run/types.js +152 -0
  193. package/dist/patterns/signature/index.d.ts +2 -0
  194. package/dist/patterns/signature/index.js +4 -0
  195. package/dist/patterns/signature/signature-ceremony.d.ts +33 -0
  196. package/dist/patterns/signature/signature-ceremony.js +317 -0
  197. package/dist/patterns/signature/types.d.ts +68 -0
  198. package/dist/patterns/signature/types.js +89 -0
  199. package/dist/patterns/timeline/index.d.ts +2 -0
  200. package/dist/patterns/timeline/index.js +4 -0
  201. package/dist/patterns/timeline/timeline.d.ts +27 -0
  202. package/dist/patterns/timeline/timeline.js +430 -0
  203. package/dist/patterns/timeline/types.d.ts +36 -0
  204. package/dist/patterns/timeline/types.js +27 -0
  205. package/dist/patterns/versions/graph-layout.d.ts +43 -0
  206. package/dist/patterns/versions/graph-layout.js +159 -0
  207. package/dist/patterns/versions/index.d.ts +4 -0
  208. package/dist/patterns/versions/index.js +8 -0
  209. package/dist/patterns/versions/shared.d.ts +4 -0
  210. package/dist/patterns/versions/shared.js +13 -0
  211. package/dist/patterns/versions/types.d.ts +37 -0
  212. package/dist/patterns/versions/types.js +39 -0
  213. package/dist/patterns/versions/version-graph.d.ts +36 -0
  214. package/dist/patterns/versions/version-graph.js +438 -0
  215. package/dist/patterns/versions/version-list.d.ts +39 -0
  216. package/dist/patterns/versions/version-list.js +407 -0
  217. package/dist/patterns/work-queue/controller.d.ts +26 -0
  218. package/dist/patterns/work-queue/controller.js +150 -0
  219. package/dist/patterns/work-queue/index.d.ts +4 -0
  220. package/dist/patterns/work-queue/index.js +7 -0
  221. package/dist/patterns/work-queue/types.d.ts +128 -0
  222. package/dist/patterns/work-queue/types.js +45 -0
  223. package/dist/patterns/work-queue/work-queue.d.ts +48 -0
  224. package/dist/patterns/work-queue/work-queue.js +534 -0
  225. package/dist/patterns/work-queue/workload-board.d.ts +53 -0
  226. package/dist/patterns/work-queue/workload-board.js +608 -0
  227. package/package.json +89 -5
@@ -0,0 +1,534 @@
1
+ import { WorkQueueController } from "./controller.js";
2
+ import { DUE_BUCKET_LABELS, DUE_BUCKET_ORDER, resolveDueBucket, } from "./types.js";
3
+ import { formatItemDate } from "../content-explorer/adapters/item-summary.js";
4
+ import { BaseElement } from "../../core/index.js";
5
+ import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
6
+ import { boePanel, boeRadius } from "../../foundations/geometry/index.js";
7
+ const DEFAULT_TAG_NAME = "box-work-queue";
8
+ const escapeHtml = (value) => value
9
+ .replaceAll("&", "&")
10
+ .replaceAll("<", "&lt;")
11
+ .replaceAll(">", "&gt;")
12
+ .replaceAll('"', "&quot;")
13
+ .replaceAll("'", "&#39;");
14
+ const elementStyles = `
15
+ [hidden] {
16
+ display: none !important;
17
+ }
18
+
19
+ :host {
20
+ display: block;
21
+ color: inherit;
22
+ font: inherit;
23
+ }
24
+
25
+ section[part="panel"] {
26
+ display: grid;
27
+ gap: ${boePanel.gap};
28
+ padding: ${boePanel.padding};
29
+ border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
30
+ border-radius: ${boePanel.radius};
31
+ background: ${boePanel.background};
32
+ transition: opacity ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
33
+ }
34
+
35
+ section[part="panel"][aria-busy="true"] {
36
+ opacity: 0.65;
37
+ }
38
+
39
+ [part="title"] {
40
+ margin: 0;
41
+ font: inherit;
42
+ font-size: 1.1rem;
43
+ font-weight: 700;
44
+ color: var(--boe-token-text-text, #1f1e1b);
45
+ }
46
+
47
+ [part="error"] {
48
+ margin: 0;
49
+ padding: 0.55rem 0.7rem;
50
+ border-radius: ${boeRadius.large};
51
+ font-size: 0.9rem;
52
+ background: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 10%, var(--boe-token-surface-surface, #ffffff));
53
+ border: 1px solid color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 34%, transparent);
54
+ color: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 72%, black 28%);
55
+ }
56
+
57
+ [part="bucket"] {
58
+ display: grid;
59
+ gap: 0.45rem;
60
+ }
61
+
62
+ [part="bucket-title"] {
63
+ display: flex;
64
+ align-items: center;
65
+ gap: 0.45rem;
66
+ font-size: 0.74rem;
67
+ font-weight: 700;
68
+ letter-spacing: 0.08em;
69
+ text-transform: uppercase;
70
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
71
+ }
72
+
73
+ [part="bucket"][data-bucket="overdue"] [part="bucket-title"] {
74
+ color: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 74%, black 26%);
75
+ }
76
+
77
+ [part="items"] {
78
+ list-style: none;
79
+ margin: 0;
80
+ padding: 0;
81
+ display: grid;
82
+ gap: 0.45rem;
83
+ }
84
+
85
+ [part="row"] {
86
+ display: grid;
87
+ gap: 0.35rem;
88
+ padding: 0.55rem 0.6rem;
89
+ border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 52%, transparent);
90
+ border-radius: ${boeRadius.large};
91
+ background: color-mix(in srgb, var(--boe-token-surface-surface, #ffffff) 82%, transparent);
92
+ }
93
+
94
+ [part="row"][data-bucket="overdue"] {
95
+ border-color: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 40%, transparent);
96
+ }
97
+
98
+ [part="row-header"] {
99
+ display: flex;
100
+ flex-wrap: wrap;
101
+ align-items: center;
102
+ gap: 0.45rem;
103
+ }
104
+
105
+ [part="row-title"] {
106
+ appearance: none;
107
+ border: none;
108
+ background: transparent;
109
+ padding: 0;
110
+ font: inherit;
111
+ font-weight: 700;
112
+ color: var(--boe-token-text-text, #1f1e1b);
113
+ text-align: left;
114
+ cursor: pointer;
115
+ }
116
+
117
+ [part="row-title"]:hover {
118
+ color: var(--boe-token-surface-surface-brand, #0061d5);
119
+ }
120
+
121
+ [part="row-title"]:focus-visible {
122
+ outline: none;
123
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
124
+ border-radius: ${boeRadius.med};
125
+ }
126
+
127
+ [part="entity"] {
128
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
129
+ font-size: 0.82rem;
130
+ }
131
+
132
+ [part="type"],
133
+ [part="risk"],
134
+ [part="priority"],
135
+ [part="assignee"] {
136
+ display: inline-flex;
137
+ padding: 0.16rem 0.45rem;
138
+ border-radius: 999px;
139
+ background: var(--boe-token-surface-item-surface-selected, #f2f7fd);
140
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
141
+ font-size: 0.75rem;
142
+ font-weight: 600;
143
+ }
144
+
145
+ [part="risk"][data-risk="high"],
146
+ [part="priority"][data-priority="urgent"] {
147
+ background: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 12%, transparent);
148
+ color: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 74%, black 26%);
149
+ }
150
+
151
+ [part="risk"][data-risk="medium"],
152
+ [part="priority"][data-priority="high"] {
153
+ background: color-mix(in srgb, var(--boe-token-surface-status-surface-warning, #f5b31b) 18%, transparent);
154
+ color: color-mix(in srgb, var(--boe-token-surface-status-surface-warning, #f5b31b) 46%, black 54%);
155
+ }
156
+
157
+ [part="due"] {
158
+ margin-left: auto;
159
+ font-size: 0.78rem;
160
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
161
+ white-space: nowrap;
162
+ }
163
+
164
+ [part="due"][data-bucket="overdue"] {
165
+ color: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 74%, black 26%);
166
+ font-weight: 700;
167
+ }
168
+
169
+ [part="row-actions"] {
170
+ display: flex;
171
+ flex-wrap: wrap;
172
+ gap: 0.4rem;
173
+ }
174
+
175
+ [part="row-action"] {
176
+ appearance: none;
177
+ font: inherit;
178
+ font-size: 0.78rem;
179
+ font-weight: 600;
180
+ padding: 0.28rem 0.6rem;
181
+ border-radius: 999px;
182
+ border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 60%, transparent);
183
+ background: var(--boe-token-surface-surface, #ffffff);
184
+ color: inherit;
185
+ cursor: pointer;
186
+ transition: background ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
187
+ }
188
+
189
+ [part="row-action"]:hover {
190
+ background: var(--boe-token-surface-surface-hover, #f4f4f4);
191
+ }
192
+
193
+ [part="row-action"]:focus-visible {
194
+ outline: none;
195
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
196
+ }
197
+
198
+ [part="empty"] {
199
+ padding: ${boePanel.padding};
200
+ border-radius: ${boeRadius.large};
201
+ border: 1px dashed color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 70%, transparent);
202
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
203
+ }
204
+ `;
205
+ export class WorkQueue extends BaseElement {
206
+ static tagName = DEFAULT_TAG_NAME;
207
+ static get observedAttributes() {
208
+ return ["assignee-id", "heading", "reference-time", "token"];
209
+ }
210
+ controller = null;
211
+ ownsController = false;
212
+ pendingStart = false;
213
+ unsubscribeFns = [];
214
+ transportValue = null;
215
+ hostEl;
216
+ get heading() {
217
+ return this.getAttribute("heading") ?? "My work";
218
+ }
219
+ set heading(value) {
220
+ this.setAttribute("heading", value);
221
+ }
222
+ get token() {
223
+ return this.getAttribute("token");
224
+ }
225
+ set token(value) {
226
+ if (!value) {
227
+ this.removeAttribute("token");
228
+ return;
229
+ }
230
+ this.setAttribute("token", value);
231
+ }
232
+ /** The current user; enables per-row Claim on unassigned open items. */
233
+ get assigneeId() {
234
+ return this.getAttribute("assignee-id");
235
+ }
236
+ set assigneeId(value) {
237
+ if (!value) {
238
+ this.removeAttribute("assignee-id");
239
+ return;
240
+ }
241
+ this.setAttribute("assignee-id", value);
242
+ }
243
+ /** ISO reference time for the urgency buckets; defaults to now. */
244
+ get referenceTime() {
245
+ return this.getAttribute("reference-time");
246
+ }
247
+ set referenceTime(value) {
248
+ if (!value) {
249
+ this.removeAttribute("reference-time");
250
+ return;
251
+ }
252
+ this.setAttribute("reference-time", value);
253
+ }
254
+ get transport() {
255
+ return this.transportValue;
256
+ }
257
+ set transport(value) {
258
+ this.transportValue = value;
259
+ this.scheduleStart();
260
+ }
261
+ /**
262
+ * The live session controller. Assign one to share a session with another
263
+ * projection (e.g. a `box-workload-board` on the same page); otherwise the
264
+ * element creates and owns its own from `transport` + `token`.
265
+ */
266
+ get queueController() {
267
+ return this.controller;
268
+ }
269
+ set queueController(value) {
270
+ this.adoptController(value);
271
+ }
272
+ attributeChangedCallback(name, oldValue, newValue) {
273
+ if (name === "token") {
274
+ this.scheduleStart();
275
+ }
276
+ super.attributeChangedCallback(name, oldValue, newValue);
277
+ }
278
+ connectedCallback() {
279
+ super.connectedCallback();
280
+ this.scheduleStart();
281
+ }
282
+ disconnectedCallback() {
283
+ this.teardownController();
284
+ }
285
+ async setFilters(patch) {
286
+ await this.controller?.setFilters(patch);
287
+ }
288
+ async refresh() {
289
+ await this.controller?.reload();
290
+ }
291
+ now() {
292
+ const raw = this.referenceTime;
293
+ if (raw) {
294
+ const parsed = new Date(raw);
295
+ if (!Number.isNaN(parsed.getTime())) {
296
+ return parsed;
297
+ }
298
+ }
299
+ return new Date();
300
+ }
301
+ scheduleStart() {
302
+ if (this.pendingStart) {
303
+ return;
304
+ }
305
+ this.pendingStart = true;
306
+ queueMicrotask(() => {
307
+ this.pendingStart = false;
308
+ this.startController();
309
+ });
310
+ }
311
+ startController() {
312
+ if (!this.isConnected || (this.controller && !this.ownsController)) {
313
+ return;
314
+ }
315
+ if (!this.transportValue || !this.token) {
316
+ this.teardownController();
317
+ if (this.isRendered) {
318
+ this.update();
319
+ }
320
+ return;
321
+ }
322
+ this.teardownController();
323
+ const controller = new WorkQueueController({
324
+ token: this.token,
325
+ transport: this.transportValue,
326
+ });
327
+ this.controller = controller;
328
+ this.ownsController = true;
329
+ this.subscribeToController(controller);
330
+ if (this.isRendered) {
331
+ this.update();
332
+ }
333
+ void controller.connect();
334
+ }
335
+ adoptController(controller) {
336
+ this.teardownController();
337
+ if (!controller) {
338
+ if (this.isRendered) {
339
+ this.update();
340
+ }
341
+ // Fall back to the documented owned session from transport + token.
342
+ this.scheduleStart();
343
+ return;
344
+ }
345
+ this.controller = controller;
346
+ this.ownsController = false;
347
+ this.subscribeToController(controller);
348
+ if (this.isRendered) {
349
+ this.update();
350
+ }
351
+ }
352
+ subscribeToController(controller) {
353
+ const events = [
354
+ ["itemsChanged", "items-changed"],
355
+ ["loadingChanged", "loading-changed"],
356
+ ["loadFailed", "load-failed"],
357
+ ["filtersChanged", "filters-changed"],
358
+ ["itemMutated", "item-mutated"],
359
+ ["mutationFailed", "mutation-failed"],
360
+ ];
361
+ this.unsubscribeFns = events.map(([eventName, domEventName]) => controller.subscribe(eventName, payload => {
362
+ this.dispatchEvent(new CustomEvent(domEventName, {
363
+ bubbles: true,
364
+ composed: true,
365
+ detail: payload,
366
+ }));
367
+ if (this.isRendered) {
368
+ this.update();
369
+ }
370
+ }));
371
+ }
372
+ teardownController() {
373
+ for (const unsubscribe of this.unsubscribeFns) {
374
+ unsubscribe();
375
+ }
376
+ this.unsubscribeFns = [];
377
+ if (this.controller && this.ownsController) {
378
+ this.controller.disconnect();
379
+ this.controller.destroy();
380
+ }
381
+ this.controller = null;
382
+ this.ownsController = false;
383
+ }
384
+ rowActionsHtml(item) {
385
+ const transport = this.controller?.config.transport;
386
+ const actions = [];
387
+ if (transport?.claimItem &&
388
+ item.status === "open" &&
389
+ !item.assignee &&
390
+ this.assigneeId) {
391
+ actions.push({ action: "claim", label: "Claim" });
392
+ }
393
+ if (transport?.completeItem && item.status !== "completed") {
394
+ actions.push({ action: "complete", label: "Complete" });
395
+ }
396
+ if (transport?.escalateItem && item.status !== "completed" && item.status !== "escalated") {
397
+ actions.push({ action: "escalate", label: "Escalate" });
398
+ }
399
+ if (transport?.reassignItem) {
400
+ actions.push({ action: "reassign", label: "Reassign" });
401
+ }
402
+ return actions
403
+ .map(({ action, label }) => `
404
+ <button
405
+ type="button"
406
+ part="row-action"
407
+ data-action="${action}"
408
+ data-item-id="${escapeHtml(item.id)}"
409
+ aria-label="${label} ${escapeHtml(item.title)}"
410
+ >${label}</button>
411
+ `)
412
+ .join("");
413
+ }
414
+ rowHtml(item, bucket) {
415
+ const due = item.dueAt ? formatItemDate(item.dueAt) : "";
416
+ return `
417
+ <li part="row" data-item-id="${escapeHtml(item.id)}" data-bucket="${bucket}" data-status="${escapeHtml(item.status)}">
418
+ <div part="row-header">
419
+ <button type="button" part="row-title" data-item-id="${escapeHtml(item.id)}">${escapeHtml(item.title)}</button>
420
+ <span part="type">${escapeHtml(item.type)}</span>
421
+ ${item.riskLevel ? `<span part="risk" data-risk="${escapeHtml(item.riskLevel)}">Risk: ${escapeHtml(item.riskLevel)}</span>` : ""}
422
+ ${item.priority ? `<span part="priority" data-priority="${escapeHtml(item.priority)}">${escapeHtml(item.priority)}</span>` : ""}
423
+ ${item.assignee ? `<span part="assignee">${escapeHtml(item.assignee.name)}</span>` : ""}
424
+ ${due ? `<time part="due" data-bucket="${bucket}" datetime="${escapeHtml(item.dueAt ?? "")}">${bucket === "overdue" ? "Overdue · " : ""}${escapeHtml(due)}</time>` : ""}
425
+ </div>
426
+ ${item.entityRef?.label ? `<span part="entity">${escapeHtml(item.entityRef.label)}</span>` : ""}
427
+ <div part="row-actions">${this.rowActionsHtml(item)}</div>
428
+ </li>
429
+ `;
430
+ }
431
+ renderTemplate() {
432
+ if (!this.shadowRoot) {
433
+ return;
434
+ }
435
+ this.shadowRoot.innerHTML = `
436
+ <style>${elementStyles}</style>
437
+ <div part="content-host"></div>
438
+ `;
439
+ this.hostEl = this.shadowRoot.querySelector('[part="content-host"]');
440
+ }
441
+ setupListeners() {
442
+ this.hostEl.addEventListener("click", event => {
443
+ const target = event.target;
444
+ const actionButton = target.closest('[part="row-action"]');
445
+ if (actionButton && this.hostEl.contains(actionButton)) {
446
+ const itemId = actionButton.getAttribute("data-item-id") ?? "";
447
+ const action = actionButton.getAttribute("data-action") ?? "";
448
+ const item = this.controller?.getItem(itemId);
449
+ if (!item) {
450
+ return;
451
+ }
452
+ if (action === "claim" && this.assigneeId) {
453
+ void this.controller?.claimItem(itemId, this.assigneeId);
454
+ }
455
+ else if (action === "complete") {
456
+ void this.controller?.completeItem(itemId);
457
+ }
458
+ else if (action === "escalate") {
459
+ void this.controller?.escalateItem(itemId);
460
+ }
461
+ else if (action === "reassign") {
462
+ // Reassignment needs a target person — the host owns that choice
463
+ // (confirm-before-apply), so this only surfaces intent.
464
+ this.dispatchEvent(new CustomEvent("reassign-requested", {
465
+ bubbles: true,
466
+ composed: true,
467
+ detail: { item },
468
+ }));
469
+ }
470
+ return;
471
+ }
472
+ const titleButton = target.closest('[part="row-title"]');
473
+ if (titleButton && this.hostEl.contains(titleButton)) {
474
+ const item = this.controller?.getItem(titleButton.getAttribute("data-item-id") ?? "");
475
+ if (item) {
476
+ this.dispatchEvent(new CustomEvent("item-selected", {
477
+ bubbles: true,
478
+ composed: true,
479
+ detail: { item },
480
+ }));
481
+ }
482
+ }
483
+ });
484
+ }
485
+ update() {
486
+ if (!this.hostEl) {
487
+ return;
488
+ }
489
+ // Sample in-element focus before the rebuild so a mutation-driven
490
+ // re-render puts focus back on the equivalent control.
491
+ const active = this.shadowRoot?.activeElement;
492
+ const focusKey = active && this.hostEl.contains(active)
493
+ ? {
494
+ part: active.getAttribute("part") ?? "",
495
+ itemId: active.getAttribute("data-item-id"),
496
+ action: active.getAttribute("data-action"),
497
+ }
498
+ : null;
499
+ const state = this.controller?.getState() ?? null;
500
+ const items = state?.items ?? [];
501
+ const now = this.now();
502
+ const buckets = new Map();
503
+ for (const item of items) {
504
+ const bucket = resolveDueBucket(item.dueAt, now);
505
+ const list = buckets.get(bucket) ?? [];
506
+ list.push(item);
507
+ buckets.set(bucket, list);
508
+ }
509
+ const sections = DUE_BUCKET_ORDER.filter(bucket => buckets.get(bucket)?.length)
510
+ .map(bucket => {
511
+ const bucketItems = buckets.get(bucket);
512
+ return `
513
+ <section part="bucket" data-bucket="${bucket}">
514
+ <h3 part="bucket-title">${DUE_BUCKET_LABELS[bucket]} (${String(bucketItems.length)})</h3>
515
+ <ul part="items" role="list">${bucketItems.map(item => this.rowHtml(item, bucket)).join("")}</ul>
516
+ </section>
517
+ `;
518
+ })
519
+ .join("");
520
+ this.hostEl.innerHTML = `
521
+ <section part="panel" aria-busy="${state?.loading ? "true" : "false"}" aria-label="${escapeHtml(this.heading)}">
522
+ <h2 part="title">${escapeHtml(this.heading)}</h2>
523
+ ${state?.error ? `<p part="error" role="alert">${escapeHtml(state.error)}</p>` : ""}
524
+ ${sections || `<div part="empty">No work items.</div>`}
525
+ </section>
526
+ `;
527
+ if (focusKey?.part) {
528
+ const target = Array.from(this.hostEl.querySelectorAll(`[part="${focusKey.part}"]`)).find(node => node.getAttribute("data-item-id") === focusKey.itemId &&
529
+ (!focusKey.action || node.getAttribute("data-action") === focusKey.action));
530
+ target?.focus();
531
+ }
532
+ }
533
+ }
534
+ WorkQueue.register();
@@ -0,0 +1,53 @@
1
+ import { WorkQueueController } from "./controller.js";
2
+ import type { WorkItemAssignee, WorkQueueTransport } from "./types.js";
3
+ import { BaseElement } from "../../core/index.js";
4
+ export declare class WorkloadBoard extends BaseElement {
5
+ static readonly tagName: string;
6
+ static get observedAttributes(): string[];
7
+ private controller;
8
+ private ownsController;
9
+ private pendingStart;
10
+ private unsubscribeFns;
11
+ private transportValue;
12
+ private teamValue;
13
+ private hostEl;
14
+ get heading(): string;
15
+ set heading(value: string);
16
+ get token(): string | null;
17
+ set token(value: string | null);
18
+ /** Lane dimension: `assignee` (team workload, default) or `status` (pipeline). */
19
+ get laneBy(): "assignee" | "status";
20
+ set laneBy(value: "assignee" | "status");
21
+ /** Items-per-person threshold that flags a lane as over capacity. */
22
+ get wipLimit(): number | null;
23
+ set wipLimit(value: number | null);
24
+ /** ISO reference time for overdue detection; defaults to now. */
25
+ get referenceTime(): string | null;
26
+ set referenceTime(value: string | null);
27
+ get team(): WorkItemAssignee[];
28
+ set team(value: WorkItemAssignee[]);
29
+ get transport(): WorkQueueTransport | null;
30
+ set transport(value: WorkQueueTransport | null);
31
+ /**
32
+ * The live session controller. Assign one to share a session with a
33
+ * `box-work-queue` on the same page; otherwise the element creates and
34
+ * owns its own from `transport` + `token`.
35
+ */
36
+ get queueController(): WorkQueueController | null;
37
+ set queueController(value: WorkQueueController | null);
38
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
39
+ connectedCallback(): void;
40
+ disconnectedCallback(): void;
41
+ refresh(): Promise<void>;
42
+ private now;
43
+ private scheduleStart;
44
+ private startController;
45
+ private adoptController;
46
+ private subscribeToController;
47
+ private teardownController;
48
+ private cardHtml;
49
+ private laneHtml;
50
+ protected renderTemplate(): void;
51
+ protected setupListeners(): void;
52
+ protected update(): void;
53
+ }