@mohamedatia/fly-design-system 2.11.0 → 2.12.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.
|
@@ -823,64 +823,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
823
823
|
}] });
|
|
824
824
|
|
|
825
825
|
/**
|
|
826
|
-
* Publishes a {@link WindowHelpHint} for
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
* (the listener). It exists in the design system so that **any app — and
|
|
832
|
-
* especially a federated remote — publishes hints the same way**, without
|
|
826
|
+
* Publishes a {@link WindowHelpHint} for a window so the shell's titlebar Help
|
|
827
|
+
* button deeplinks the help-center reader to the article most relevant to where
|
|
828
|
+
* the user is. The **publisher twin** of the shell's `WindowHelpHintService`
|
|
829
|
+
* (the listener): it exists in the design system so that **any app — in-shell
|
|
830
|
+
* OS-Core app or federated remote — publishes hints the same way**, without
|
|
833
831
|
* hand-rolling the cross-bundle CustomEvent contract.
|
|
834
832
|
*
|
|
835
833
|
* **Why a `window` CustomEvent and not the `WINDOW_HELP_HINT` DI token?**
|
|
836
|
-
* Native Federation can split an `InjectionToken` instance across
|
|
837
|
-
* remote bundles, so a remote that injects `WINDOW_HELP_HINT` may
|
|
834
|
+
* Native Federation can split an `InjectionToken` instance across host and
|
|
835
|
+
* remote bundles, so a remote that injects `WINDOW_HELP_HINT` may receive a
|
|
838
836
|
* different token than the one the shell provides. The string-keyed
|
|
839
|
-
* {@link FLY_WINDOW_HELP_HINT_EVENT} crosses bundles reliably; the shell
|
|
840
|
-
*
|
|
841
|
-
* may still use the DI token directly, but this service works for them too.
|
|
842
|
-
*
|
|
843
|
-
* **Imperative by design.** The service holds no signals and runs no effect —
|
|
844
|
-
* the *app* owns its reactivity (route + state → resolved hint) and pushes the
|
|
845
|
-
* result via {@link setHint}. The design system owns only the wire format. A
|
|
846
|
-
* hint set before {@link bindWindow} is buffered and emitted once the window id
|
|
847
|
-
* arrives, so call order doesn't matter.
|
|
837
|
+
* {@link FLY_WINDOW_HELP_HINT_EVENT} crosses bundles reliably; the shell mirrors
|
|
838
|
+
* it into the matching per-window hint signal.
|
|
848
839
|
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
855
|
-
* }
|
|
856
|
-
* ```
|
|
840
|
+
* **Why a per-window handle and not `bindWindow`/`setHint` state?**
|
|
841
|
+
* This service is `providedIn: 'root'` and the design system is a shared
|
|
842
|
+
* Native-Federation singleton, so a *single* instance is shared across the
|
|
843
|
+
* shell and every concurrently-open window (multiple in-shell apps, multiple
|
|
844
|
+
* remotes). A handle closes over its window id, so two windows never clobber a
|
|
845
|
+
* shared "current window" — each handle targets only its own titlebar.
|
|
857
846
|
*/
|
|
858
847
|
class FlyWindowHelpService {
|
|
859
|
-
windowId = null;
|
|
860
|
-
hint = null;
|
|
861
|
-
/**
|
|
862
|
-
* Bind (or clear) the host window id — typically once, from the app root,
|
|
863
|
-
* with `WINDOW_DATA.id`. Re-emits the current hint for the (new) window.
|
|
864
|
-
* Passing null/undefined (standalone, no shell) makes publishing a no-op.
|
|
865
|
-
*/
|
|
866
|
-
bindWindow(windowId) {
|
|
867
|
-
this.windowId = windowId ?? null;
|
|
868
|
-
this.publish();
|
|
869
|
-
}
|
|
870
848
|
/**
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
849
|
+
* Returns a publisher bound to a single window. Call once per window (e.g.
|
|
850
|
+
* from the app root with `WINDOW_DATA.id`) and keep the handle. A
|
|
851
|
+
* null/undefined id (standalone, no shell) yields a handle whose `setHint`
|
|
852
|
+
* is a no-op.
|
|
874
853
|
*/
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
854
|
+
forWindow(windowId) {
|
|
855
|
+
const id = windowId ?? null;
|
|
856
|
+
return {
|
|
857
|
+
setHint: (hint) => {
|
|
858
|
+
if (typeof window === 'undefined' || !id)
|
|
859
|
+
return;
|
|
860
|
+
const detail = { windowId: id, hint };
|
|
861
|
+
window.dispatchEvent(new CustomEvent(FLY_WINDOW_HELP_HINT_EVENT, { detail }));
|
|
862
|
+
},
|
|
863
|
+
};
|
|
884
864
|
}
|
|
885
865
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: FlyWindowHelpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
886
866
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: FlyWindowHelpService, providedIn: 'root' });
|