@cosxai/ui 0.4.5 → 0.4.7
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/useActionBarItems.ts +26 -13
- package/src/styles/index.css +11 -2
package/package.json
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
-
import { useContext, useEffect
|
|
1
|
+
import { useContext, useEffect } from "react";
|
|
2
2
|
import { ActionBarContext } from "./actionbar-context";
|
|
3
3
|
import type { ActionBarItem } from "./types";
|
|
4
4
|
|
|
5
5
|
// Register a set of items into the global action-bar registry.
|
|
6
6
|
// Auto-unregisters on unmount + on sourceKey change.
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
8
|
+
// **Pass a `useMemo`'d array.** The effect re-registers whenever
|
|
9
|
+
// the array identity changes; the provider's `register()` then
|
|
10
|
+
// dedups by item-by-item identity, so a fresh array with identical
|
|
11
|
+
// item refs is cheap (state stays === and no re-render fires) but
|
|
12
|
+
// a fresh array with NEW item objects (e.g. consumers whose
|
|
13
|
+
// onClick closures captured updated state) does re-register —
|
|
14
|
+
// downstream renders pick up the fresh handlers.
|
|
15
|
+
//
|
|
16
|
+
// Inline-array consumers (`useActionBarItems(key, [{...}])`)
|
|
17
|
+
// will allocate new items every render and loop infinitely
|
|
18
|
+
// through `register → setState → re-render → register`. The
|
|
19
|
+
// useMemo on the caller side is what keeps that loop bounded
|
|
20
|
+
// to "items whose deps actually changed".
|
|
21
|
+
//
|
|
22
|
+
// Previous versions wrapped items in a local `useMemo` keyed by
|
|
23
|
+
// `[items.length, items.map(i => i.key).join('|')]`. That gate
|
|
24
|
+
// suppressed identity updates whenever the keys + length stayed
|
|
25
|
+
// stable, which is precisely the case for a selection-mode
|
|
26
|
+
// toolbar whose buttons are fixed but whose onClicks close over
|
|
27
|
+
// changing state — they ended up registered ONCE with the first
|
|
28
|
+
// render's closures and never refreshed, shipping stale state to
|
|
29
|
+
// every subsequent click. The gate is gone; the provider's
|
|
30
|
+
// shallow item-identity dedup is the single source of truth.
|
|
13
31
|
//
|
|
14
32
|
// **Important**: the useEffect deps below intentionally do NOT
|
|
15
33
|
// include the ctx object itself — only its stable function refs
|
|
@@ -27,15 +45,10 @@ export function useActionBarItems(sourceKey: string, items: ActionBarItem[]) {
|
|
|
27
45
|
throw new Error("useActionBarItems must be used within <ActionBarProvider>");
|
|
28
46
|
}
|
|
29
47
|
const { register, unregister } = ctx;
|
|
30
|
-
const memo = useMemo(
|
|
31
|
-
() => items,
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
[items.length, items.map((i) => i.key).join("|")],
|
|
34
|
-
);
|
|
35
48
|
useEffect(() => {
|
|
36
|
-
register(sourceKey,
|
|
49
|
+
register(sourceKey, items);
|
|
37
50
|
return () => unregister(sourceKey);
|
|
38
|
-
}, [register, unregister, sourceKey,
|
|
51
|
+
}, [register, unregister, sourceKey, items]);
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
export function useActionBarItemsContext() {
|
package/src/styles/index.css
CHANGED
|
@@ -188,9 +188,18 @@ html[data-ck-chrome="seamless"] .ck-card__foot {
|
|
|
188
188
|
/* Children inside an open disclosure group sit on top of the wrapper's
|
|
189
189
|
--ck-accent-muted pill. The default gray hover above reads as a hue
|
|
190
190
|
collision against the coral/indigo wrapper — swap in an accent-blended
|
|
191
|
-
overlay so the hover signal stays in the accent family.
|
|
191
|
+
overlay so the hover signal stays in the accent family.
|
|
192
|
+
|
|
193
|
+
30% blend (was 18% in 0.4.5): 18% layered onto an --ck-accent-muted
|
|
194
|
+
wrapper (already 8–14% accent depending on chrome) composites to
|
|
195
|
+
~30% effective saturation. At that low saturation translucent
|
|
196
|
+
orange / coral / blue all read as washed-out salmon — the hover
|
|
197
|
+
loses its hue identity against the solid --ck-accent text right
|
|
198
|
+
beside it. 30% pushes the overlay past the "dilution reads as
|
|
199
|
+
pink" inflection so the workspace's actual brand colour is
|
|
200
|
+
recognisable. */
|
|
192
201
|
.ck-actionbar-group--open .ck-actionbar-btn:hover:not(:disabled):not(.ck-actionbar-btn--primary) {
|
|
193
|
-
background: color-mix(in oklab, var(--ck-accent)
|
|
202
|
+
background: color-mix(in oklab, var(--ck-accent) 30%, transparent);
|
|
194
203
|
}
|
|
195
204
|
.ck-actionbar-btn--primary {
|
|
196
205
|
background: var(--ck-accent);
|