@cosxai/ui 0.10.2 → 0.10.3
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.
- package/package.json +1 -1
- package/src/actionbar/ActionBar.tsx +12 -1
- package/src/actionbar/types.ts +12 -0
package/package.json
CHANGED
|
@@ -209,8 +209,19 @@ export function ActionBar({
|
|
|
209
209
|
});
|
|
210
210
|
}, [storageKey]);
|
|
211
211
|
const hasAdminItems = useMemo(() => items.some((it) => it.adminOnly === true), [items]);
|
|
212
|
+
// Filter semantics:
|
|
213
|
+
// admin OFF → hide items marked adminOnly (the toggle would reveal them)
|
|
214
|
+
// admin ON → hide items marked hiddenInAdmin (page opted them out of admin view)
|
|
215
|
+
// Together, adminOnly + hiddenInAdmin let pages choose:
|
|
216
|
+
// - additive: normal items unmarked → visible in both modes;
|
|
217
|
+
// admin items marked adminOnly → visible only in admin
|
|
218
|
+
// - exclusive: normal items marked hiddenInAdmin → hidden in admin;
|
|
219
|
+
// admin items marked adminOnly → visible only in admin
|
|
212
220
|
const visibleItems = useMemo(
|
|
213
|
-
() =>
|
|
221
|
+
() =>
|
|
222
|
+
adminMode
|
|
223
|
+
? items.filter((it) => it.hiddenInAdmin !== true)
|
|
224
|
+
: items.filter((it) => it.adminOnly !== true),
|
|
214
225
|
[items, adminMode],
|
|
215
226
|
);
|
|
216
227
|
|
package/src/actionbar/types.ts
CHANGED
|
@@ -60,6 +60,18 @@ export interface ActionBarItem {
|
|
|
60
60
|
// (or an equivalent gate) === true. The kit does not check
|
|
61
61
|
// permissions; it only handles the toggle UX.
|
|
62
62
|
adminOnly?: boolean;
|
|
63
|
+
// Marks a normally-visible item as hidden when admin mode is on.
|
|
64
|
+
// Symmetric counterpart to `adminOnly`: pages that want an
|
|
65
|
+
// exclusive "different toolset" UX (e.g. Share disappears in favour
|
|
66
|
+
// of Manage Share + Activity + History) mark their regular items
|
|
67
|
+
// hiddenInAdmin=true so they clear when the toggle flips on.
|
|
68
|
+
// Pages that want additive layering (regular items stay + admin
|
|
69
|
+
// items appear alongside) just leave this unset.
|
|
70
|
+
//
|
|
71
|
+
// Per-item because different pages within the same app want
|
|
72
|
+
// different behaviour: block_doc viewer wants exclusive; a
|
|
73
|
+
// hypothetical PDF admin surface might want additive.
|
|
74
|
+
hiddenInAdmin?: boolean;
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
// Category definition — declared at the provider level. Drives
|