@burdenoff/microfe-timecampus 2026.1107.4 → 2026.1107.6

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 (62) hide show
  1. package/dist/generated/wspace-operations.d.ts +1463 -0
  2. package/dist/generated/wspace-operations.d.ts.map +1 -1
  3. package/dist/generated/wspace-operations.js +1849 -1414
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/generated/wspace-types.d.ts +223 -0
  6. package/dist/generated/wspace-types.d.ts.map +1 -1
  7. package/dist/generated/wspace-types.js +21 -17
  8. package/dist/generated/wspace-types.js.map +1 -1
  9. package/dist/index.js +7 -7
  10. package/dist/timecampus/TimeCampusRoutes.d.ts.map +1 -1
  11. package/dist/timecampus/TimeCampusRoutes.js +132 -124
  12. package/dist/timecampus/TimeCampusRoutes.js.map +1 -1
  13. package/dist/timecampus/analytics/timecampusAnalytics.d.ts +7 -1
  14. package/dist/timecampus/analytics/timecampusAnalytics.d.ts.map +1 -1
  15. package/dist/timecampus/analytics/timecampusAnalytics.js +12 -0
  16. package/dist/timecampus/analytics/timecampusAnalytics.js.map +1 -1
  17. package/dist/timecampus/analytics/useTimeCampusAnalytics.d.ts.map +1 -1
  18. package/dist/timecampus/analytics/useTimeCampusAnalytics.js +1 -0
  19. package/dist/timecampus/analytics/useTimeCampusAnalytics.js.map +1 -1
  20. package/dist/timecampus/index.js +7 -7
  21. package/dist/timecampus/pages/extend/AppletDeveloperPage.d.ts +2 -0
  22. package/dist/timecampus/pages/extend/AppletDeveloperPage.d.ts.map +1 -0
  23. package/dist/timecampus/pages/extend/AppletDeveloperPage.js +366 -0
  24. package/dist/timecampus/pages/extend/AppletDeveloperPage.js.map +1 -0
  25. package/dist/timecampus/pages/extend/AppletReviewPage.d.ts +2 -0
  26. package/dist/timecampus/pages/extend/AppletReviewPage.d.ts.map +1 -0
  27. package/dist/timecampus/pages/extend/AppletReviewPage.js +308 -0
  28. package/dist/timecampus/pages/extend/AppletReviewPage.js.map +1 -0
  29. package/dist/timecampus/pages/extend/AppletStorePage.d.ts.map +1 -1
  30. package/dist/timecampus/pages/extend/AppletStorePage.js +88 -83
  31. package/dist/timecampus/pages/extend/AppletStorePage.js.map +1 -1
  32. package/dist/timecampus/pages/extend/SandboxedAppletWidget.d.ts +14 -0
  33. package/dist/timecampus/pages/extend/SandboxedAppletWidget.d.ts.map +1 -0
  34. package/dist/timecampus/pages/extend/SandboxedAppletWidget.js +86 -0
  35. package/dist/timecampus/pages/extend/SandboxedAppletWidget.js.map +1 -0
  36. package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.d.ts +11 -0
  37. package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.d.ts.map +1 -0
  38. package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js +267 -0
  39. package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js.map +1 -0
  40. package/dist/timecampus/pages/extend/WidgetDashboardPage.d.ts.map +1 -1
  41. package/dist/timecampus/pages/extend/WidgetDashboardPage.js +147 -141
  42. package/dist/timecampus/pages/extend/WidgetDashboardPage.js.map +1 -1
  43. package/dist/timecampus/pages/extend/appletBridge.d.ts +70 -0
  44. package/dist/timecampus/pages/extend/appletBridge.d.ts.map +1 -0
  45. package/dist/timecampus/pages/extend/appletBridge.js +67 -0
  46. package/dist/timecampus/pages/extend/appletBridge.js.map +1 -0
  47. package/dist/timecampus/pages/extend/appletPublishingHelpers.d.ts +36 -0
  48. package/dist/timecampus/pages/extend/appletPublishingHelpers.d.ts.map +1 -0
  49. package/dist/timecampus/pages/extend/appletPublishingHelpers.js +120 -0
  50. package/dist/timecampus/pages/extend/appletPublishingHelpers.js.map +1 -0
  51. package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.d.ts +14 -0
  52. package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.d.ts.map +1 -0
  53. package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js +238 -0
  54. package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js.map +1 -0
  55. package/dist/timecampus/pages/time-approval/TimeApprovalPage.d.ts.map +1 -1
  56. package/dist/timecampus/pages/time-approval/TimeApprovalPage.js +122 -87
  57. package/dist/timecampus/pages/time-approval/TimeApprovalPage.js.map +1 -1
  58. package/dist/timecampus/pages/time-approval/timesheetPeriod.d.ts +80 -0
  59. package/dist/timecampus/pages/time-approval/timesheetPeriod.d.ts.map +1 -0
  60. package/dist/timecampus/pages/time-approval/timesheetPeriod.js +103 -0
  61. package/dist/timecampus/pages/time-approval/timesheetPeriod.js.map +1 -0
  62. package/package.json +1 -1
@@ -8,55 +8,56 @@ import { StatusBadge as c } from "../../components/StatusBadge.js";
8
8
  import { ToastContainer as l, useToast as u } from "../../components/Toast.js";
9
9
  import { APPLET_CATEGORIES as d, appletCategoryLabel as f, catalogueIcon as p, matchesAppletSearch as m } from "./extendHelpers.js";
10
10
  import { useOpenRoute as h } from "./useOpenRoute.js";
11
- import { useMemo as g, useState as _ } from "react";
12
- import { ArrowRight as v, Check as y, Download as b, Search as x, Trash2 as S } from "lucide-react";
13
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
14
- import { GlassCard as E } from "@burdenoff/fe-libs/ui";
11
+ import { ThirdPartyAppletsSection as g } from "./ThirdPartyAppletsSection.js";
12
+ import { useMemo as _, useState as v } from "react";
13
+ import { ArrowRight as y, Check as b, Download as x, Search as S, Trash2 as C } from "lucide-react";
14
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
15
+ import { GlassCard as D } from "@burdenoff/fe-libs/ui";
15
16
  //#region src/timecampus/pages/extend/AppletStorePage.tsx
16
- var D = ["ListApplets", "GetWidgetDashboard"], O = "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50", k = "inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50", A = "rounded-full border px-3 py-1 text-xs font-medium transition-colors";
17
- function j(e) {
17
+ var O = ["ListApplets", "GetWidgetDashboard"], k = "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50", A = "inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50", j = "rounded-full border px-3 py-1 text-xs font-medium transition-colors";
18
+ function M(e) {
18
19
  let t = e instanceof Error ? e.message : "";
19
20
  return /forbidden|permission|not authori[sz]ed/i.test(t) ? "Only workspace admins can install or remove applets." : t || "Something went wrong";
20
21
  }
21
- function M({ applet: e, busy: n, onInstall: r, onUninstall: i, onOpen: a }) {
22
+ function N({ applet: e, busy: n, onInstall: r, onUninstall: i, onOpen: a }) {
22
23
  let o = p(e.icon);
23
- return /* @__PURE__ */ T(E, {
24
+ return /* @__PURE__ */ E(D, {
24
25
  treatment: "glass",
25
26
  className: "flex h-full flex-col gap-3 p-5",
26
27
  "data-testid": `applet-card-${e.key}`,
27
28
  children: [
28
- /* @__PURE__ */ T("div", {
29
+ /* @__PURE__ */ E("div", {
29
30
  className: "flex items-start gap-3",
30
31
  children: [
31
- /* @__PURE__ */ w("div", {
32
+ /* @__PURE__ */ T("div", {
32
33
  className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
33
- children: /* @__PURE__ */ w(o, {
34
+ children: /* @__PURE__ */ T(o, {
34
35
  className: "h-5 w-5",
35
36
  "aria-hidden": "true"
36
37
  })
37
38
  }),
38
- /* @__PURE__ */ T("div", {
39
+ /* @__PURE__ */ E("div", {
39
40
  className: "min-w-0 flex-1",
40
- children: [/* @__PURE__ */ w("p", {
41
+ children: [/* @__PURE__ */ T("p", {
41
42
  className: "text-xs font-medium uppercase tracking-wide text-text-tertiary",
42
43
  children: f(e.category)
43
- }), /* @__PURE__ */ w("h3", {
44
+ }), /* @__PURE__ */ T("h3", {
44
45
  className: "truncate text-base font-semibold text-text-primary",
45
46
  children: e.name
46
47
  })]
47
48
  }),
48
- e.installed && /* @__PURE__ */ w(c, {
49
+ e.installed && /* @__PURE__ */ T(c, {
49
50
  label: "Installed",
50
51
  variant: "success",
51
52
  dot: !0
52
53
  })
53
54
  ]
54
55
  }),
55
- /* @__PURE__ */ w("p", {
56
+ /* @__PURE__ */ T("p", {
56
57
  className: "flex-1 text-sm text-text-secondary",
57
58
  children: e.description
58
59
  }),
59
- e.widgetKeys.length > 0 && /* @__PURE__ */ T("p", {
60
+ e.widgetKeys.length > 0 && /* @__PURE__ */ E("p", {
60
61
  className: "text-xs text-text-tertiary",
61
62
  children: [
62
63
  "Adds ",
@@ -66,7 +67,7 @@ function M({ applet: e, busy: n, onInstall: r, onUninstall: i, onOpen: a }) {
66
67
  " to My Widgets"
67
68
  ]
68
69
  }),
69
- e.installed && e.installedAt && /* @__PURE__ */ T("p", {
70
+ e.installed && e.installedAt && /* @__PURE__ */ E("p", {
70
71
  className: "text-xs text-text-tertiary",
71
72
  children: [
72
73
  "Installed ",
@@ -74,33 +75,33 @@ function M({ applet: e, busy: n, onInstall: r, onUninstall: i, onOpen: a }) {
74
75
  e.installSource === "TEMPLATE" && e.templateKey ? " by a workspace template" : ""
75
76
  ]
76
77
  }),
77
- /* @__PURE__ */ w("div", {
78
+ /* @__PURE__ */ T("div", {
78
79
  className: "flex flex-wrap gap-2",
79
- children: e.installed ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ T("button", {
80
+ children: e.installed ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ E("button", {
80
81
  type: "button",
81
- className: O,
82
+ className: k,
82
83
  onClick: a,
83
- children: ["Open", /* @__PURE__ */ w(v, {
84
+ children: ["Open", /* @__PURE__ */ T(y, {
84
85
  className: "h-4 w-4",
85
86
  "aria-hidden": "true"
86
87
  })]
87
- }), /* @__PURE__ */ T("button", {
88
+ }), /* @__PURE__ */ E("button", {
88
89
  type: "button",
89
- className: k,
90
+ className: A,
90
91
  onClick: i,
91
92
  disabled: n,
92
93
  "aria-label": `Remove ${e.name}`,
93
- children: [/* @__PURE__ */ w(S, {
94
+ children: [/* @__PURE__ */ T(C, {
94
95
  className: "h-4 w-4",
95
96
  "aria-hidden": "true"
96
97
  }), "Remove"]
97
- })] }) : /* @__PURE__ */ T("button", {
98
+ })] }) : /* @__PURE__ */ E("button", {
98
99
  type: "button",
99
- className: O,
100
+ className: k,
100
101
  onClick: r,
101
102
  disabled: n,
102
103
  "aria-label": `Install ${e.name}`,
103
- children: [/* @__PURE__ */ w(b, {
104
+ children: [/* @__PURE__ */ T(x, {
104
105
  className: "h-4 w-4",
105
106
  "aria-hidden": "true"
106
107
  }), n ? "Installing…" : "Install"]
@@ -109,140 +110,144 @@ function M({ applet: e, busy: n, onInstall: r, onUninstall: i, onOpen: a }) {
109
110
  ]
110
111
  });
111
112
  }
112
- function N() {
113
- let { workspaceId: t = "" } = e(), { toasts: c, addToast: p, dismissToast: v } = u(), b = h(), [S, C] = _("store"), [E, k] = _(null), [N, P] = _(""), [F, I] = _(null), { data: L, loading: R, error: z } = a({ skip: !t }), [B] = i({ refetchQueries: D }), [V] = o({ refetchQueries: D }), H = g(() => L?.timeCampusApplets ?? [], [L]), U = H.filter((e) => e.installed).length, W = g(() => H.filter((e) => S === "store" || e.installed).filter((e) => !E || e.category === E).filter((e) => m(e, N)), [
114
- H,
115
- S,
116
- E,
117
- N
118
- ]), G = async (e, t) => {
119
- I(e.key);
113
+ function P() {
114
+ let { workspaceId: t = "" } = e(), { toasts: c, addToast: p, dismissToast: y } = u(), x = h(), [C, w] = v("store"), [D, A] = v(null), [P, F] = v(""), [I, L] = v(null), { data: R, loading: z, error: B } = a({ skip: !t }), [V] = i({ refetchQueries: O }), [H] = o({ refetchQueries: O }), U = _(() => R?.timeCampusApplets ?? [], [R]), W = U.filter((e) => e.installed).length, G = _(() => U.filter((e) => C === "store" || e.installed).filter((e) => !D || e.category === D).filter((e) => m(e, P)), [
115
+ U,
116
+ C,
117
+ D,
118
+ P
119
+ ]), K = async (e, t) => {
120
+ L(e.key);
120
121
  try {
121
- t === "install" ? (await B({ variables: { key: e.key } }), p({
122
+ t === "install" ? (await V({ variables: { key: e.key } }), p({
122
123
  title: `${e.name} installed`,
123
124
  description: e.widgetKeys.length > 0 ? "Its widgets are now available in My Widgets." : void 0,
124
125
  variant: "success"
125
- })) : (await V({ variables: { key: e.key } }), p({
126
+ })) : (await H({ variables: { key: e.key } }), p({
126
127
  title: `${e.name} removed`,
127
128
  variant: "success"
128
129
  }));
129
130
  } catch (e) {
130
131
  p({
131
- title: j(e),
132
+ title: M(e),
132
133
  variant: "error"
133
134
  });
134
135
  } finally {
135
- I(null);
136
+ L(null);
136
137
  }
137
138
  };
138
- return /* @__PURE__ */ T(s, {
139
+ return /* @__PURE__ */ E(s, {
139
140
  title: "Applet Store",
140
141
  description: "Add capabilities to your workspace",
141
142
  purpose: "Applets are focused tools that plug into TimeCampus — focus protection, invoicing, client portals, FluidGrids workflow automations and more. Install the ones your team needs; each applet's widgets then become available on My Widgets.",
142
143
  children: [
143
- /* @__PURE__ */ w(l, {
144
+ /* @__PURE__ */ T(l, {
144
145
  toasts: c,
145
- onDismiss: v
146
+ onDismiss: y
146
147
  }),
147
- /* @__PURE__ */ T("div", {
148
+ /* @__PURE__ */ E("div", {
148
149
  className: "mb-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",
149
- children: [/* @__PURE__ */ w("div", {
150
+ children: [/* @__PURE__ */ T("div", {
150
151
  className: "inline-flex w-fit items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5",
151
152
  role: "tablist",
152
153
  "aria-label": "Applet store view",
153
154
  children: [[
154
155
  "store",
155
156
  "Store",
156
- H.length
157
+ U.length
157
158
  ], [
158
159
  "installed",
159
160
  "Installed",
160
- U
161
+ W
161
162
  ]].map(([e, t, n]) => {
162
- let r = S === e;
163
- return /* @__PURE__ */ T("button", {
163
+ let r = C === e;
164
+ return /* @__PURE__ */ E("button", {
164
165
  type: "button",
165
166
  role: "tab",
166
167
  "aria-selected": r,
167
- onClick: () => C(e),
168
+ onClick: () => w(e),
168
169
  className: r ? "flex items-center gap-1.5 rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm" : "flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary",
169
- children: [t, /* @__PURE__ */ w("span", {
170
+ children: [t, /* @__PURE__ */ T("span", {
170
171
  className: "rounded-full bg-bg-sunken px-1.5 text-xs font-semibold text-text-secondary",
171
172
  children: n
172
173
  })]
173
174
  }, e);
174
175
  })
175
- }), /* @__PURE__ */ T("label", {
176
+ }), /* @__PURE__ */ E("label", {
176
177
  className: "relative block w-full lg:w-72",
177
178
  children: [
178
- /* @__PURE__ */ w("span", {
179
+ /* @__PURE__ */ T("span", {
179
180
  className: "sr-only",
180
181
  children: "Search applets"
181
182
  }),
182
- /* @__PURE__ */ w(x, {
183
+ /* @__PURE__ */ T(S, {
183
184
  className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-tertiary",
184
185
  "aria-hidden": "true"
185
186
  }),
186
- /* @__PURE__ */ w("input", {
187
+ /* @__PURE__ */ T("input", {
187
188
  type: "search",
188
- value: N,
189
- onChange: (e) => P(e.target.value),
189
+ value: P,
190
+ onChange: (e) => F(e.target.value),
190
191
  placeholder: "Search applets…",
191
192
  className: "w-full rounded-md border border-border-subtle bg-bg-surface py-1.5 pl-9 pr-3 text-sm text-text-primary"
192
193
  })
193
194
  ]
194
195
  })]
195
196
  }),
196
- /* @__PURE__ */ T("div", {
197
+ /* @__PURE__ */ E("div", {
197
198
  className: "mb-5 flex flex-wrap gap-2",
198
199
  "aria-label": "Filter by category",
199
- children: [/* @__PURE__ */ w("button", {
200
+ children: [/* @__PURE__ */ T("button", {
200
201
  type: "button",
201
- onClick: () => k(null),
202
- "aria-pressed": E === null,
203
- className: `${A} ${E === null ? "border-action-primary-bg bg-action-primary-bg/10 text-primary" : "border-border-subtle text-text-secondary hover:text-text-primary"}`,
202
+ onClick: () => A(null),
203
+ "aria-pressed": D === null,
204
+ className: `${j} ${D === null ? "border-action-primary-bg bg-action-primary-bg/10 text-primary" : "border-border-subtle text-text-secondary hover:text-text-primary"}`,
204
205
  children: "All"
205
- }), d.filter((e) => H.some((t) => t.category === e)).map((e) => /* @__PURE__ */ w("button", {
206
+ }), d.filter((e) => U.some((t) => t.category === e)).map((e) => /* @__PURE__ */ T("button", {
206
207
  type: "button",
207
- onClick: () => k(E === e ? null : e),
208
- "aria-pressed": E === e,
209
- className: `${A} ${E === e ? "border-action-primary-bg bg-action-primary-bg/10 text-primary" : "border-border-subtle text-text-secondary hover:text-text-primary"}`,
208
+ onClick: () => A(D === e ? null : e),
209
+ "aria-pressed": D === e,
210
+ className: `${j} ${D === e ? "border-action-primary-bg bg-action-primary-bg/10 text-primary" : "border-border-subtle text-text-secondary hover:text-text-primary"}`,
210
211
  children: f(e)
211
212
  }, e))]
212
213
  }),
213
- R && !L ? /* @__PURE__ */ w(n, {
214
+ z && !R ? /* @__PURE__ */ T(n, {
214
215
  variant: "card",
215
216
  count: 6
216
- }) : z ? /* @__PURE__ */ w(r, {
217
+ }) : B ? /* @__PURE__ */ T(r, {
217
218
  title: "Couldn't load the applet store",
218
- description: z.message,
219
+ description: B.message,
219
220
  illustration: "error-state"
220
- }) : W.length === 0 ? /* @__PURE__ */ w(r, {
221
- title: S === "installed" && U === 0 ? "No applets installed yet" : "No applets match",
222
- description: S === "installed" && U === 0 ? "Install applets from the Store tab, or apply a workspace template to install a curated set." : "Try another search or category.",
223
- action: S === "installed" && U === 0 ? /* @__PURE__ */ T("button", {
221
+ }) : G.length === 0 ? /* @__PURE__ */ T(r, {
222
+ title: C === "installed" && W === 0 ? "No applets installed yet" : "No applets match",
223
+ description: C === "installed" && W === 0 ? "Install applets from the Store tab, or apply a workspace template to install a curated set." : "Try another search or category.",
224
+ action: C === "installed" && W === 0 ? /* @__PURE__ */ E("button", {
224
225
  type: "button",
225
- className: O,
226
- onClick: () => C("store"),
227
- children: [/* @__PURE__ */ w(y, {
226
+ className: k,
227
+ onClick: () => w("store"),
228
+ children: [/* @__PURE__ */ T(b, {
228
229
  className: "h-4 w-4",
229
230
  "aria-hidden": "true"
230
231
  }), "Browse the store"]
231
232
  }) : void 0
232
- }) : /* @__PURE__ */ w("div", {
233
+ }) : /* @__PURE__ */ T("div", {
233
234
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4",
234
- children: W.map((e) => /* @__PURE__ */ w(M, {
235
+ children: G.map((e) => /* @__PURE__ */ T(N, {
235
236
  applet: e,
236
- busy: F === e.key,
237
- onInstall: () => G(e, "install"),
238
- onUninstall: () => G(e, "uninstall"),
239
- onOpen: () => b(e.route)
237
+ busy: I === e.key,
238
+ onInstall: () => K(e, "install"),
239
+ onUninstall: () => K(e, "uninstall"),
240
+ onOpen: () => x(e.route)
240
241
  }, e.key))
242
+ }),
243
+ /* @__PURE__ */ T(g, {
244
+ workspaceId: t,
245
+ addToast: p
241
246
  })
242
247
  ]
243
248
  });
244
249
  }
245
250
  //#endregion
246
- export { N as AppletStorePage };
251
+ export { P as AppletStorePage };
247
252
 
248
253
  //# sourceMappingURL=AppletStorePage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppletStorePage.js","names":[],"sources":["../../../../src/timecampus/pages/extend/AppletStorePage.tsx"],"sourcesContent":["/**\n * Applet Store (BOFF-4039)\n *\n * Browse TimeCampus applets, install them for the whole workspace, and open\n * the ones you have. Installing an applet adds its widgets to the widget\n * catalogue (My Widgets); templates install curated sets of applets.\n * Install and uninstall are workspace-admin actions; every member can browse\n * and open installed applets.\n */\nimport { useMemo, useState } from \"react\";\nimport { ArrowRight, Check, Download, Search, Trash2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { PageLayout } from \"../../components/PageLayout\";\nimport { StatusBadge } from \"../../components/StatusBadge\";\nimport { LoadingSkeleton } from \"../../components/LoadingSkeleton\";\nimport { EmptyState } from \"../../components/EmptyState\";\nimport { ToastContainer, useToast } from \"../../components/Toast\";\nimport { formatDate } from \"../../utils/helpers\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport {\n useInstallAppletMutation,\n useListAppletsQuery,\n useUninstallAppletMutation,\n type AppletFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n APPLET_CATEGORIES,\n appletCategoryLabel,\n catalogueIcon,\n matchesAppletSearch,\n} from \"./extendHelpers\";\nimport { useOpenRoute } from \"./useOpenRoute\";\n\ntype StoreTab = \"store\" | \"installed\";\n\nconst REFRESH_QUERIES = [\"ListApplets\", \"GetWidgetDashboard\"];\nconst primaryButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\";\nconst outlineButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50\";\nconst chipBase =\n \"rounded-full border px-3 py-1 text-xs font-medium transition-colors\";\n\nfunction errorMessage(err: unknown): string {\n const message = err instanceof Error ? err.message : \"\";\n if (/forbidden|permission|not authori[sz]ed/i.test(message)) {\n return \"Only workspace admins can install or remove applets.\";\n }\n return message || \"Something went wrong\";\n}\n\nfunction AppletCard({\n applet,\n busy,\n onInstall,\n onUninstall,\n onOpen,\n}: {\n applet: AppletFieldsFragment;\n busy: boolean;\n onInstall: () => void;\n onUninstall: () => void;\n onOpen: () => void;\n}) {\n const Icon = catalogueIcon(applet.icon);\n return (\n <GlassCard\n treatment=\"glass\"\n className=\"flex h-full flex-col gap-3 p-5\"\n data-testid={`applet-card-${applet.key}`}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary\">\n <Icon className=\"h-5 w-5\" aria-hidden=\"true\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-tertiary\">\n {appletCategoryLabel(applet.category)}\n </p>\n <h3 className=\"truncate text-base font-semibold text-text-primary\">\n {applet.name}\n </h3>\n </div>\n {applet.installed && (\n <StatusBadge label=\"Installed\" variant=\"success\" dot />\n )}\n </div>\n <p className=\"flex-1 text-sm text-text-secondary\">{applet.description}</p>\n {applet.widgetKeys.length > 0 && (\n <p className=\"text-xs text-text-tertiary\">\n Adds {applet.widgetKeys.length} widget\n {applet.widgetKeys.length === 1 ? \"\" : \"s\"} to My Widgets\n </p>\n )}\n {applet.installed && applet.installedAt && (\n <p className=\"text-xs text-text-tertiary\">\n Installed {formatDate(applet.installedAt)}\n {applet.installSource === \"TEMPLATE\" && applet.templateKey\n ? \" by a workspace template\"\n : \"\"}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {applet.installed ? (\n <>\n <button type=\"button\" className={primaryButton} onClick={onOpen}>\n Open\n <ArrowRight className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={onUninstall}\n disabled={busy}\n aria-label={`Remove ${applet.name}`}\n >\n <Trash2 className=\"h-4 w-4\" aria-hidden=\"true\" />\n Remove\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n className={primaryButton}\n onClick={onInstall}\n disabled={busy}\n aria-label={`Install ${applet.name}`}\n >\n <Download className=\"h-4 w-4\" aria-hidden=\"true\" />\n {busy ? \"Installing…\" : \"Install\"}\n </button>\n )}\n </div>\n </GlassCard>\n );\n}\n\nexport function AppletStorePage() {\n const { workspaceId = \"\" } = useTimeCampus();\n const { toasts, addToast, dismissToast } = useToast();\n const openRoute = useOpenRoute();\n const [tab, setTab] = useState<StoreTab>(\"store\");\n const [category, setCategory] = useState<string | null>(null);\n const [search, setSearch] = useState(\"\");\n const [busyKey, setBusyKey] = useState<string | null>(null);\n\n const { data, loading, error } = useListAppletsQuery({\n skip: !workspaceId,\n });\n const [installApplet] = useInstallAppletMutation({\n refetchQueries: REFRESH_QUERIES,\n });\n const [uninstallApplet] = useUninstallAppletMutation({\n refetchQueries: REFRESH_QUERIES,\n });\n\n const applets = useMemo<AppletFieldsFragment[]>(\n () => data?.timeCampusApplets ?? [],\n [data],\n );\n const installedCount = applets.filter((applet) => applet.installed).length;\n const visible = useMemo(\n () =>\n applets\n .filter((applet) => tab === \"store\" || applet.installed)\n .filter((applet) => !category || applet.category === category)\n .filter((applet) => matchesAppletSearch(applet, search)),\n [applets, tab, category, search],\n );\n\n const run = async (\n applet: AppletFieldsFragment,\n action: \"install\" | \"uninstall\",\n ) => {\n setBusyKey(applet.key);\n try {\n if (action === \"install\") {\n await installApplet({ variables: { key: applet.key } });\n addToast({\n title: `${applet.name} installed`,\n description:\n applet.widgetKeys.length > 0\n ? \"Its widgets are now available in My Widgets.\"\n : undefined,\n variant: \"success\",\n });\n } else {\n await uninstallApplet({ variables: { key: applet.key } });\n addToast({ title: `${applet.name} removed`, variant: \"success\" });\n }\n } catch (err) {\n addToast({ title: errorMessage(err), variant: \"error\" });\n } finally {\n setBusyKey(null);\n }\n };\n\n return (\n <PageLayout\n title=\"Applet Store\"\n description=\"Add capabilities to your workspace\"\n purpose=\"Applets are focused tools that plug into TimeCampus — focus protection, invoicing, client portals, FluidGrids workflow automations and more. Install the ones your team needs; each applet's widgets then become available on My Widgets.\"\n >\n <ToastContainer toasts={toasts} onDismiss={dismissToast} />\n\n <div className=\"mb-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between\">\n <div\n className=\"inline-flex w-fit items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5\"\n role=\"tablist\"\n aria-label=\"Applet store view\"\n >\n {(\n [\n [\"store\", \"Store\", applets.length],\n [\"installed\", \"Installed\", installedCount],\n ] as const\n ).map(([key, label, count]) => {\n const active = tab === key;\n return (\n <button\n key={key}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setTab(key)}\n className={\n active\n ? \"flex items-center gap-1.5 rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm\"\n : \"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary\"\n }\n >\n {label}\n <span className=\"rounded-full bg-bg-sunken px-1.5 text-xs font-semibold text-text-secondary\">\n {count}\n </span>\n </button>\n );\n })}\n </div>\n <label className=\"relative block w-full lg:w-72\">\n <span className=\"sr-only\">Search applets</span>\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-tertiary\"\n aria-hidden=\"true\"\n />\n <input\n type=\"search\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n placeholder=\"Search applets…\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface py-1.5 pl-9 pr-3 text-sm text-text-primary\"\n />\n </label>\n </div>\n\n <div\n className=\"mb-5 flex flex-wrap gap-2\"\n aria-label=\"Filter by category\"\n >\n <button\n type=\"button\"\n onClick={() => setCategory(null)}\n aria-pressed={category === null}\n className={`${chipBase} ${category === null ? \"border-action-primary-bg bg-action-primary-bg/10 text-primary\" : \"border-border-subtle text-text-secondary hover:text-text-primary\"}`}\n >\n All\n </button>\n {APPLET_CATEGORIES.filter((key) =>\n applets.some((applet) => applet.category === key),\n ).map((key) => (\n <button\n key={key}\n type=\"button\"\n onClick={() => setCategory(category === key ? null : key)}\n aria-pressed={category === key}\n className={`${chipBase} ${category === key ? \"border-action-primary-bg bg-action-primary-bg/10 text-primary\" : \"border-border-subtle text-text-secondary hover:text-text-primary\"}`}\n >\n {appletCategoryLabel(key)}\n </button>\n ))}\n </div>\n\n {loading && !data ? (\n <LoadingSkeleton variant=\"card\" count={6} />\n ) : error ? (\n <EmptyState\n title=\"Couldn't load the applet store\"\n description={error.message}\n illustration=\"error-state\"\n />\n ) : visible.length === 0 ? (\n <EmptyState\n title={\n tab === \"installed\" && installedCount === 0\n ? \"No applets installed yet\"\n : \"No applets match\"\n }\n description={\n tab === \"installed\" && installedCount === 0\n ? \"Install applets from the Store tab, or apply a workspace template to install a curated set.\"\n : \"Try another search or category.\"\n }\n action={\n tab === \"installed\" && installedCount === 0 ? (\n <button\n type=\"button\"\n className={primaryButton}\n onClick={() => setTab(\"store\")}\n >\n <Check className=\"h-4 w-4\" aria-hidden=\"true\" />\n Browse the store\n </button>\n ) : undefined\n }\n />\n ) : (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4\">\n {visible.map((applet) => (\n <AppletCard\n key={applet.key}\n applet={applet}\n busy={busyKey === applet.key}\n onInstall={() => run(applet, \"install\")}\n onUninstall={() => run(applet, \"uninstall\")}\n onOpen={() => openRoute(applet.route)}\n />\n ))}\n </div>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmCA,IAAM,IAAkB,CAAC,eAAe,oBAAoB,GACtD,IACJ,8LACI,IACJ,wMACI,IACJ;AAEF,SAAS,EAAa,GAAsB;CAC1C,IAAM,IAAU,aAAe,QAAQ,EAAI,UAAU;CAIrD,OAHI,0CAA0C,KAAK,CAAO,IACjD,yDAEF,KAAW;AACpB;AAEA,SAAS,EAAW,EAClB,WACA,SACA,cACA,gBACA,aAOC;CACD,IAAM,IAAO,EAAc,EAAO,IAAI;CACtC,OACE,kBAAC,GAAD;EACE,WAAU;EACV,WAAU;EACV,eAAa,eAAe,EAAO;EAHrC,UAAA;GAKE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,kBAAC,OAAD;MAAK,WAAU;MACb,UAAA,kBAAC,GAAD;OAAM,WAAU;OAAU,eAAY;MAAQ,CAAA;KA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CAAG,CAClD,CAAC,CAAC,KAAK,MACL,kBAAC,UAAD;KAEE,MAAK;KACL,eAAe,EAAY,MAAa,IAAM,OAAO,CAAG;KACxD,gBAAc,MAAa;KAC3B,WAAW,GAAG,EAAS,GAAG,MAAa,IAAM,kEAAkE;KAE9G,UAAA,EAAoB,CAAG;IAClB,GAPD,CAOC,CACT,CACE;;GAEJ,KAAW,CAAC,IACX,kBAAC,GAAD;IAAiB,SAAQ;IAAO,OAAO;GAAI,CAAA,IACzC,IACF,kBAAC,GAAD;IACE,OAAM;IACN,aAAa,EAAM;IACnB,cAAa;GACd,CAAA,IACC,EAAQ,WAAW,IACrB,kBAAC,GAAD;IACE,OACE,MAAQ,eAAe,MAAmB,IACtC,6BACA;IAEN,aACE,MAAQ,eAAe,MAAmB,IACtC,gGACA;IAEN,QACE,MAAQ,eAAe,MAAmB,IACxC,kBAAC,UAAD;KACE,MAAK;KACL,WAAW;KACX,eAAe,EAAO,OAAO;KAH/B,UAAA,CAKE,kBAAC,GAAD;MAAO,WAAU;MAAU,eAAY;KAAQ,CAAA,GAAC,kBAE1C;IACN,CAAA,IAAA,KAAA;GAEP,CAAA,IAED,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAA,EAAQ,KAAK,MACZ,kBAAC,GAAD;KAEU;KACR,MAAM,MAAY,EAAO;KACzB,iBAAiB,EAAI,GAAQ,SAAS;KACtC,mBAAmB,EAAI,GAAQ,WAAW;KAC1C,cAAc,EAAU,EAAO,KAAK;IACrC,GANM,EAAO,GAMb,CACF;GACE,CAAA;EAEG;;AAEhB"}
1
+ {"version":3,"file":"AppletStorePage.js","names":[],"sources":["../../../../src/timecampus/pages/extend/AppletStorePage.tsx"],"sourcesContent":["/**\n * Applet Store (BOFF-4039)\n *\n * Browse TimeCampus applets, install them for the whole workspace, and open\n * the ones you have. Installing an applet adds its widgets to the widget\n * catalogue (My Widgets); templates install curated sets of applets.\n * Install and uninstall are workspace-admin actions; every member can browse\n * and open installed applets. Workspace applets built by third-party\n * developers (BOFF-10827) are listed below the first-party store.\n */\nimport { useMemo, useState } from \"react\";\nimport { ArrowRight, Check, Download, Search, Trash2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { PageLayout } from \"../../components/PageLayout\";\nimport { StatusBadge } from \"../../components/StatusBadge\";\nimport { LoadingSkeleton } from \"../../components/LoadingSkeleton\";\nimport { EmptyState } from \"../../components/EmptyState\";\nimport { ToastContainer, useToast } from \"../../components/Toast\";\nimport { formatDate } from \"../../utils/helpers\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport {\n useInstallAppletMutation,\n useListAppletsQuery,\n useUninstallAppletMutation,\n type AppletFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n APPLET_CATEGORIES,\n appletCategoryLabel,\n catalogueIcon,\n matchesAppletSearch,\n} from \"./extendHelpers\";\nimport { useOpenRoute } from \"./useOpenRoute\";\nimport { ThirdPartyAppletsSection } from \"./ThirdPartyAppletsSection\";\n\ntype StoreTab = \"store\" | \"installed\";\n\nconst REFRESH_QUERIES = [\"ListApplets\", \"GetWidgetDashboard\"];\nconst primaryButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\";\nconst outlineButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50\";\nconst chipBase =\n \"rounded-full border px-3 py-1 text-xs font-medium transition-colors\";\n\nfunction errorMessage(err: unknown): string {\n const message = err instanceof Error ? err.message : \"\";\n if (/forbidden|permission|not authori[sz]ed/i.test(message)) {\n return \"Only workspace admins can install or remove applets.\";\n }\n return message || \"Something went wrong\";\n}\n\nfunction AppletCard({\n applet,\n busy,\n onInstall,\n onUninstall,\n onOpen,\n}: {\n applet: AppletFieldsFragment;\n busy: boolean;\n onInstall: () => void;\n onUninstall: () => void;\n onOpen: () => void;\n}) {\n const Icon = catalogueIcon(applet.icon);\n return (\n <GlassCard\n treatment=\"glass\"\n className=\"flex h-full flex-col gap-3 p-5\"\n data-testid={`applet-card-${applet.key}`}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary\">\n <Icon className=\"h-5 w-5\" aria-hidden=\"true\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-tertiary\">\n {appletCategoryLabel(applet.category)}\n </p>\n <h3 className=\"truncate text-base font-semibold text-text-primary\">\n {applet.name}\n </h3>\n </div>\n {applet.installed && (\n <StatusBadge label=\"Installed\" variant=\"success\" dot />\n )}\n </div>\n <p className=\"flex-1 text-sm text-text-secondary\">{applet.description}</p>\n {applet.widgetKeys.length > 0 && (\n <p className=\"text-xs text-text-tertiary\">\n Adds {applet.widgetKeys.length} widget\n {applet.widgetKeys.length === 1 ? \"\" : \"s\"} to My Widgets\n </p>\n )}\n {applet.installed && applet.installedAt && (\n <p className=\"text-xs text-text-tertiary\">\n Installed {formatDate(applet.installedAt)}\n {applet.installSource === \"TEMPLATE\" && applet.templateKey\n ? \" by a workspace template\"\n : \"\"}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {applet.installed ? (\n <>\n <button type=\"button\" className={primaryButton} onClick={onOpen}>\n Open\n <ArrowRight className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={onUninstall}\n disabled={busy}\n aria-label={`Remove ${applet.name}`}\n >\n <Trash2 className=\"h-4 w-4\" aria-hidden=\"true\" />\n Remove\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n className={primaryButton}\n onClick={onInstall}\n disabled={busy}\n aria-label={`Install ${applet.name}`}\n >\n <Download className=\"h-4 w-4\" aria-hidden=\"true\" />\n {busy ? \"Installing…\" : \"Install\"}\n </button>\n )}\n </div>\n </GlassCard>\n );\n}\n\nexport function AppletStorePage() {\n const { workspaceId = \"\" } = useTimeCampus();\n const { toasts, addToast, dismissToast } = useToast();\n const openRoute = useOpenRoute();\n const [tab, setTab] = useState<StoreTab>(\"store\");\n const [category, setCategory] = useState<string | null>(null);\n const [search, setSearch] = useState(\"\");\n const [busyKey, setBusyKey] = useState<string | null>(null);\n\n const { data, loading, error } = useListAppletsQuery({\n skip: !workspaceId,\n });\n const [installApplet] = useInstallAppletMutation({\n refetchQueries: REFRESH_QUERIES,\n });\n const [uninstallApplet] = useUninstallAppletMutation({\n refetchQueries: REFRESH_QUERIES,\n });\n\n const applets = useMemo<AppletFieldsFragment[]>(\n () => data?.timeCampusApplets ?? [],\n [data],\n );\n const installedCount = applets.filter((applet) => applet.installed).length;\n const visible = useMemo(\n () =>\n applets\n .filter((applet) => tab === \"store\" || applet.installed)\n .filter((applet) => !category || applet.category === category)\n .filter((applet) => matchesAppletSearch(applet, search)),\n [applets, tab, category, search],\n );\n\n const run = async (\n applet: AppletFieldsFragment,\n action: \"install\" | \"uninstall\",\n ) => {\n setBusyKey(applet.key);\n try {\n if (action === \"install\") {\n await installApplet({ variables: { key: applet.key } });\n addToast({\n title: `${applet.name} installed`,\n description:\n applet.widgetKeys.length > 0\n ? \"Its widgets are now available in My Widgets.\"\n : undefined,\n variant: \"success\",\n });\n } else {\n await uninstallApplet({ variables: { key: applet.key } });\n addToast({ title: `${applet.name} removed`, variant: \"success\" });\n }\n } catch (err) {\n addToast({ title: errorMessage(err), variant: \"error\" });\n } finally {\n setBusyKey(null);\n }\n };\n\n return (\n <PageLayout\n title=\"Applet Store\"\n description=\"Add capabilities to your workspace\"\n purpose=\"Applets are focused tools that plug into TimeCampus — focus protection, invoicing, client portals, FluidGrids workflow automations and more. Install the ones your team needs; each applet's widgets then become available on My Widgets.\"\n >\n <ToastContainer toasts={toasts} onDismiss={dismissToast} />\n\n <div className=\"mb-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between\">\n <div\n className=\"inline-flex w-fit items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5\"\n role=\"tablist\"\n aria-label=\"Applet store view\"\n >\n {(\n [\n [\"store\", \"Store\", applets.length],\n [\"installed\", \"Installed\", installedCount],\n ] as const\n ).map(([key, label, count]) => {\n const active = tab === key;\n return (\n <button\n key={key}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setTab(key)}\n className={\n active\n ? \"flex items-center gap-1.5 rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm\"\n : \"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary\"\n }\n >\n {label}\n <span className=\"rounded-full bg-bg-sunken px-1.5 text-xs font-semibold text-text-secondary\">\n {count}\n </span>\n </button>\n );\n })}\n </div>\n <label className=\"relative block w-full lg:w-72\">\n <span className=\"sr-only\">Search applets</span>\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-tertiary\"\n aria-hidden=\"true\"\n />\n <input\n type=\"search\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n placeholder=\"Search applets…\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface py-1.5 pl-9 pr-3 text-sm text-text-primary\"\n />\n </label>\n </div>\n\n <div\n className=\"mb-5 flex flex-wrap gap-2\"\n aria-label=\"Filter by category\"\n >\n <button\n type=\"button\"\n onClick={() => setCategory(null)}\n aria-pressed={category === null}\n className={`${chipBase} ${category === null ? \"border-action-primary-bg bg-action-primary-bg/10 text-primary\" : \"border-border-subtle text-text-secondary hover:text-text-primary\"}`}\n >\n All\n </button>\n {APPLET_CATEGORIES.filter((key) =>\n applets.some((applet) => applet.category === key),\n ).map((key) => (\n <button\n key={key}\n type=\"button\"\n onClick={() => setCategory(category === key ? null : key)}\n aria-pressed={category === key}\n className={`${chipBase} ${category === key ? \"border-action-primary-bg bg-action-primary-bg/10 text-primary\" : \"border-border-subtle text-text-secondary hover:text-text-primary\"}`}\n >\n {appletCategoryLabel(key)}\n </button>\n ))}\n </div>\n\n {loading && !data ? (\n <LoadingSkeleton variant=\"card\" count={6} />\n ) : error ? (\n <EmptyState\n title=\"Couldn't load the applet store\"\n description={error.message}\n illustration=\"error-state\"\n />\n ) : visible.length === 0 ? (\n <EmptyState\n title={\n tab === \"installed\" && installedCount === 0\n ? \"No applets installed yet\"\n : \"No applets match\"\n }\n description={\n tab === \"installed\" && installedCount === 0\n ? \"Install applets from the Store tab, or apply a workspace template to install a curated set.\"\n : \"Try another search or category.\"\n }\n action={\n tab === \"installed\" && installedCount === 0 ? (\n <button\n type=\"button\"\n className={primaryButton}\n onClick={() => setTab(\"store\")}\n >\n <Check className=\"h-4 w-4\" aria-hidden=\"true\" />\n Browse the store\n </button>\n ) : undefined\n }\n />\n ) : (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4\">\n {visible.map((applet) => (\n <AppletCard\n key={applet.key}\n applet={applet}\n busy={busyKey === applet.key}\n onInstall={() => run(applet, \"install\")}\n onUninstall={() => run(applet, \"uninstall\")}\n onOpen={() => openRoute(applet.route)}\n />\n ))}\n </div>\n )}\n\n <ThirdPartyAppletsSection workspaceId={workspaceId} addToast={addToast} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,IAAM,IAAkB,CAAC,eAAe,oBAAoB,GACtD,IACJ,8LACI,IACJ,wMACI,IACJ;AAEF,SAAS,EAAa,GAAsB;CAC1C,IAAM,IAAU,aAAe,QAAQ,EAAI,UAAU;CAIrD,OAHI,0CAA0C,KAAK,CAAO,IACjD,yDAEF,KAAW;AACpB;AAEA,SAAS,EAAW,EAClB,WACA,SACA,cACA,gBACA,aAOC;CACD,IAAM,IAAO,EAAc,EAAO,IAAI;CACtC,OACE,kBAAC,GAAD;EACE,WAAU;EACV,WAAU;EACV,eA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appletKey: string;
3
+ appletName: string;
4
+ widgetKey: string;
5
+ url: string;
6
+ origin: string;
7
+ height: number;
8
+ grantedScopes: string[];
9
+ }
10
+ export declare function SandboxedAppletWidget({ frame, title, }: {
11
+ frame: AppletWidgetFrame;
12
+ title: string;
13
+ }): import("react").JSX.Element;
14
+ //# sourceMappingURL=SandboxedAppletWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SandboxedAppletWidget.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/extend/SandboxedAppletWidget.tsx"],"names":[],"mappings":"AA0BA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAMD,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,KAAK,GACN,EAAE;IACD,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,+BAoHA"}
@@ -0,0 +1,86 @@
1
+ import { GetAppletBridgeDataDocument as e } from "../../../generated/wspace-operations.js";
2
+ import { APPLET_IFRAME_SANDBOX as t, bridgeErrorMessage as n, bridgeInit as r, bridgeResponse as i, createRateLimiter as a, isFrameableUrl as o, parseAppletRequest as s } from "./appletBridge.js";
3
+ import { useEffect as c, useMemo as l, useRef as u } from "react";
4
+ import { useApolloClient as d } from "@apollo/client/react";
5
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
6
+ //#region src/timecampus/pages/extend/SandboxedAppletWidget.tsx
7
+ function m() {
8
+ return document.documentElement.classList.contains("dark") ? "dark" : "light";
9
+ }
10
+ function h({ frame: h, title: g }) {
11
+ let _ = d(), v = u(null), y = u(a()), b = l(() => new Set(h.grantedScopes), [h.grantedScopes]), x = o(h.url, h.origin);
12
+ return c(() => {
13
+ if (!x) return;
14
+ let t = y.current, r = (e, t) => {
15
+ e.postMessage(t, "*");
16
+ }, a = (a) => {
17
+ let o = v.current?.contentWindow;
18
+ if (!o || a.source !== o) return;
19
+ let c = s(a.data);
20
+ if (c) {
21
+ if (!t()) {
22
+ r(o, i(c.requestId, { error: "Too many requests; try again in a minute." }));
23
+ return;
24
+ }
25
+ if (!b.has(c.scope)) {
26
+ r(o, i(c.requestId, { error: "This workspace has not granted that data scope." }));
27
+ return;
28
+ }
29
+ _.query({
30
+ query: e,
31
+ variables: {
32
+ appletKey: h.appletKey,
33
+ scope: c.scope
34
+ },
35
+ fetchPolicy: "no-cache"
36
+ }).then((e) => {
37
+ let t = e.data?.timeCampusAppletBridgeData;
38
+ r(o, i(c.requestId, t ? { data: t } : { error: "No data was returned." }));
39
+ }).catch((e) => {
40
+ r(o, i(c.requestId, { error: n(e) }));
41
+ });
42
+ }
43
+ };
44
+ return window.addEventListener("message", a), () => window.removeEventListener("message", a);
45
+ }, [
46
+ b,
47
+ _,
48
+ h.appletKey,
49
+ x
50
+ ]), x ? /* @__PURE__ */ p("div", {
51
+ className: "flex flex-col gap-1",
52
+ children: [/* @__PURE__ */ f("iframe", {
53
+ ref: v,
54
+ src: h.url,
55
+ title: g,
56
+ sandbox: t,
57
+ referrerPolicy: "no-referrer",
58
+ allow: "",
59
+ loading: "lazy",
60
+ onLoad: () => {
61
+ let e = v.current?.contentWindow;
62
+ e && e.postMessage(r(h, m()), "*");
63
+ },
64
+ className: "w-full rounded-md border border-border-subtle bg-bg-surface",
65
+ style: { height: h.height },
66
+ "data-testid": `applet-frame-${h.appletKey}-${h.widgetKey}`
67
+ }), /* @__PURE__ */ p("p", {
68
+ className: "text-xs text-text-tertiary",
69
+ children: [
70
+ "Third-party widget by ",
71
+ h.appletName,
72
+ ". It only sees",
73
+ " ",
74
+ h.grantedScopes.length === 0 ? "no TimeCampus data" : "the data scopes this workspace granted",
75
+ "."
76
+ ]
77
+ })]
78
+ }) : /* @__PURE__ */ f("p", {
79
+ className: "text-sm text-text-secondary",
80
+ children: "This widget's address is not allowed."
81
+ });
82
+ }
83
+ //#endregion
84
+ export { h as SandboxedAppletWidget };
85
+
86
+ //# sourceMappingURL=SandboxedAppletWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SandboxedAppletWidget.js","names":[],"sources":["../../../../src/timecampus/pages/extend/SandboxedAppletWidget.tsx"],"sourcesContent":["/**\n * Sandboxed third-party widget (BOFF-10827).\n *\n * Renders an installed third-party applet's widget in an iframe sandboxed to\n * scripts only and answers its data requests over the postMessage bridge in\n * appletBridge.ts. The iframe gets no token and no same-origin access; the\n * host checks every request's source and scope, and the service checks the\n * workspace's grant again before it returns data.\n */\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useApolloClient } from \"@apollo/client/react\";\nimport {\n GetAppletBridgeDataDocument,\n type GetAppletBridgeDataQuery,\n type GetAppletBridgeDataQueryVariables,\n} from \"@/generated/wspace-operations\";\nimport {\n APPLET_IFRAME_SANDBOX,\n bridgeErrorMessage,\n bridgeInit,\n bridgeResponse,\n createRateLimiter,\n isFrameableUrl,\n parseAppletRequest,\n} from \"./appletBridge\";\n\nexport interface AppletWidgetFrame {\n appletKey: string;\n appletName: string;\n widgetKey: string;\n url: string;\n origin: string;\n height: number;\n grantedScopes: string[];\n}\n\nfunction currentTheme(): \"light\" | \"dark\" {\n return document.documentElement.classList.contains(\"dark\") ? \"dark\" : \"light\";\n}\n\nexport function SandboxedAppletWidget({\n frame,\n title,\n}: {\n frame: AppletWidgetFrame;\n title: string;\n}) {\n const client = useApolloClient();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n // One limiter per mounted widget, so re-running the effect never resets the window.\n const rateLimiter = useRef(createRateLimiter());\n const allowed = useMemo(\n () => new Set(frame.grantedScopes),\n [frame.grantedScopes],\n );\n const frameable = isFrameableUrl(frame.url, frame.origin);\n\n useEffect(() => {\n if (!frameable) return undefined;\n const withinRate = rateLimiter.current;\n // A sandboxed frame has an opaque origin, so replies cannot be addressed\n // to an origin; they go only to this iframe's window and carry nothing\n // beyond what the workspace granted.\n const reply = (target: MessageEventSource, message: unknown) => {\n (target as Window).postMessage(message, \"*\");\n };\n\n const onMessage = (event: MessageEvent) => {\n const own = iframeRef.current?.contentWindow;\n if (!own || event.source !== own) return;\n const request = parseAppletRequest(event.data);\n if (!request) return;\n if (!withinRate()) {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: \"Too many requests; try again in a minute.\",\n }),\n );\n return;\n }\n if (!allowed.has(request.scope)) {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: \"This workspace has not granted that data scope.\",\n }),\n );\n return;\n }\n void client\n .query({\n query: GetAppletBridgeDataDocument,\n variables: {\n appletKey: frame.appletKey,\n scope: request.scope,\n } satisfies GetAppletBridgeDataQueryVariables,\n fetchPolicy: \"no-cache\",\n })\n .then((result) => {\n const data = (result.data as GetAppletBridgeDataQuery | undefined)\n ?.timeCampusAppletBridgeData;\n reply(\n own,\n bridgeResponse(\n request.requestId,\n data ? { data } : { error: \"No data was returned.\" },\n ),\n );\n })\n .catch((err: unknown) => {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: bridgeErrorMessage(err),\n }),\n );\n });\n };\n\n window.addEventListener(\"message\", onMessage);\n return () => window.removeEventListener(\"message\", onMessage);\n }, [allowed, client, frame.appletKey, frameable]);\n\n if (!frameable) {\n return (\n <p className=\"text-sm text-text-secondary\">\n This widget's address is not allowed.\n </p>\n );\n }\n\n const sendInit = () => {\n const target = iframeRef.current?.contentWindow;\n if (!target) return;\n target.postMessage(bridgeInit(frame, currentTheme()), \"*\");\n };\n\n return (\n <div className=\"flex flex-col gap-1\">\n <iframe\n ref={iframeRef}\n src={frame.url}\n title={title}\n sandbox={APPLET_IFRAME_SANDBOX}\n referrerPolicy=\"no-referrer\"\n allow=\"\"\n loading=\"lazy\"\n onLoad={sendInit}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface\"\n style={{ height: frame.height }}\n data-testid={`applet-frame-${frame.appletKey}-${frame.widgetKey}`}\n />\n <p className=\"text-xs text-text-tertiary\">\n Third-party widget by {frame.appletName}. It only sees{\" \"}\n {frame.grantedScopes.length === 0\n ? \"no TimeCampus data\"\n : \"the data scopes this workspace granted\"}\n .\n </p>\n </div>\n );\n}\n"],"mappings":";;;;;;AAoCA,SAAS,IAAiC;CACxC,OAAO,SAAS,gBAAgB,UAAU,SAAS,MAAM,IAAI,SAAS;AACxE;AAEA,SAAgB,EAAsB,EACpC,UACA,YAIC;CACD,IAAM,IAAS,EAAgB,GACzB,IAAY,EAA0B,IAAI,GAE1C,IAAc,EAAO,EAAkB,CAAC,GACxC,IAAU,QACR,IAAI,IAAI,EAAM,aAAa,GACjC,CAAC,EAAM,aAAa,CACtB,GACM,IAAY,EAAe,EAAM,KAAK,EAAM,MAAM;CAmFxD,OAjFA,QAAgB;EACd,IAAI,CAAC,GAAW;EAChB,IAAM,IAAa,EAAY,SAIzB,KAAS,GAA4B,MAAqB;GAC9D,EAAmB,YAAY,GAAS,GAAG;EAC7C,GAEM,KAAa,MAAwB;GACzC,IAAM,IAAM,EAAU,SAAS;GAC/B,IAAI,CAAC,KAAO,EAAM,WAAW,GAAK;GAClC,IAAM,IAAU,EAAmB,EAAM,IAAI;GACxC,OACL;QAAI,CAAC,EAAW,GAAG;KACjB,EACE,GACA,EAAe,EAAQ,WAAW,EAChC,OAAO,4CACT,CAAC,CACH;KACA;IACF;IACA,IAAI,CAAC,EAAQ,IAAI,EAAQ,KAAK,GAAG;KAC/B,EACE,GACA,EAAe,EAAQ,WAAW,EAChC,OAAO,kDACT,CAAC,CACH;KACA;IACF;IACA,EACG,MAAM;KACL,OAAO;KACP,WAAW;MACT,WAAW,EAAM;MACjB,OAAO,EAAQ;KACjB;KACA,aAAa;IACf,CAAC,CAAC,CACD,MAAM,MAAW;KAChB,IAAM,IAAQ,EAAO,MACjB;KACJ,EACE,GACA,EACE,EAAQ,WACR,IAAO,EAAE,QAAK,IAAI,EAAE,OAAO,wBAAwB,CACrD,CACF;IACF,CAAC,CAAC,CACD,OAAO,MAAiB;KACvB,EACE,GACA,EAAe,EAAQ,WAAW,EAChC,OAAO,EAAmB,CAAG,EAC/B,CAAC,CACH;IACF,CAAC;GArCH;EAsCF;EAGA,OADA,OAAO,iBAAiB,WAAW,CAAS,SAC/B,OAAO,oBAAoB,WAAW,CAAS;CAC9D,GAAG;EAAC;EAAS;EAAQ,EAAM;EAAW;CAAS,CAAC,GAE3C,IAeH,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,UAAD;GACE,KAAK;GACL,KAAK,EAAM;GACJ;GACP,SAAS;GACT,gBAAe;GACf,OAAM;GACN,SAAQ;GACR,cAhBiB;IACrB,IAAM,IAAS,EAAU,SAAS;IAC7B,KACL,EAAO,YAAY,EAAW,GAAO,EAAa,CAAC,GAAG,GAAG;GAC3D;GAaM,WAAU;GACV,OAAO,EAAE,QAAQ,EAAM,OAAO;GAC9B,eAAa,gBAAgB,EAAM,UAAU,GAAG,EAAM;EACvD,CAAA,GACD,kBAAC,KAAD;GAAG,WAAU;GAAb,UAAA;IAA0C;IACjB,EAAM;IAAW;IAAe;IACtD,EAAM,cAAc,WAAW,IAC5B,uBACA;IAAyC;GAE5C;EACA,CAAA,CAAA;MAlCH,kBAAC,KAAD;EAAG,WAAU;EAA8B,UAAA;CAExC,CAAA;AAkCT"}
@@ -0,0 +1,11 @@
1
+ type Toast = (toast: {
2
+ title: string;
3
+ description?: string;
4
+ variant: "success" | "error";
5
+ }) => void;
6
+ export declare function ThirdPartyAppletsSection({ workspaceId, addToast, }: {
7
+ workspaceId: string;
8
+ addToast: Toast;
9
+ }): import("react").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=ThirdPartyAppletsSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThirdPartyAppletsSection.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/extend/ThirdPartyAppletsSection.tsx"],"names":[],"mappings":"AA+BA,KAAK,KAAK,GAAG,CAAC,KAAK,EAAE;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;CAC9B,KAAK,IAAI,CAAC;AAgLX,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,QAAQ,GACT,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC;CACjB,+BA0HA"}