@fntio/infra-client-plugin-ui 0.0.0-stage → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -1,3 +1,105 @@
1
- # Temporary Holding Version
1
+ # @fntio/infra-client-plugin-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Theme helpers, the portal's component styles, and an HTTP interceptor for Angular plugins.
4
+ Private until publishing is enabled.
5
+
6
+ ## Theme
7
+
8
+ ```ts
9
+ import { applyPluginTheme, pluginThemeCss } from "@fntio/infra-client-plugin-ui";
10
+ ```
11
+
12
+ Re-exports of the SDK's browser entry for plugins that only want the tokens; the rules are
13
+ documented there (SDK README, "Browser SDK", Theme). `connectToInfraClient` already applies
14
+ the theme on `init` and `themeChanged`.
15
+
16
+ ## Components
17
+
18
+ Tokens alone leave every plugin author re-inventing buttons, tables and headers, and landing somewhere
19
+ close but visibly foreign. These classes reproduce the portal's shipped control scale, type roles and
20
+ surface treatments, so a plugin page reads as part of the app without copying anything from it.
21
+
22
+ ```ts
23
+ import { applyPluginUi } from "@fntio/infra-client-plugin-ui";
24
+
25
+ applyPluginUi(document); // once, alongside connectToInfraClient()
26
+ ```
27
+
28
+ `applyPluginUi` also sets the page itself up: a see-through background (the portal's own surface shows
29
+ behind the frame, in light and dark), no body margin, and the portal's text colour and typeface. Leave
30
+ `html` and `body` without a background of your own; painting `var(--background)` there gives a flat
31
+ slab that does not match the rest of the portal. Your own rules still win over these defaults.
32
+
33
+ ```html
34
+ <div class="ic-card">
35
+ <div class="ic-card-head">
36
+ <h2 class="ic-card-title">3 parameters</h2>
37
+ <span class="ic-caption">/myapp/prod</span>
38
+ </div>
39
+ <div class="ic-table-wrap">
40
+ <table class="ic-table">…</table>
41
+ </div>
42
+ </div>
43
+ ```
44
+
45
+ | Class | For |
46
+ | --- | --- |
47
+ | `ic-page`, `ic-header`, `ic-actions` | page scaffolding |
48
+ | `ic-title`, `ic-subtitle`, `ic-card-title`, `ic-caption`, `ic-muted`, `ic-mono` | the portal's type roles |
49
+ | `ic-card`, `ic-card-head` | a panel |
50
+ | `ic-table`, `ic-table-wrap` | a table, scrolling in its own box so the frame never scrolls the portal sideways |
51
+ | `ic-btn` + `ic-btn-primary\|secondary\|outline\|ghost\|danger`, `ic-btn-sm\|lg` | buttons, on the 24/32/36px control scale inputs share |
52
+ | `ic-field`, `ic-label`, `ic-input`, `ic-select` | forms |
53
+ | `ic-badge` + `ic-badge-brand\|green\|amber\|red` | status pills; keep plain `ic-badge` for a type or a label, and colour for a state |
54
+ | `ic-empty`, `ic-error`, `ic-skeleton` | the three states every page needs |
55
+
56
+ Every value resolves from a theme token, so a customer's branding and the viewer's light or dark choice
57
+ carry through, and a test fails if a colour literal creeps in. `pluginUiCss()` returns the stylesheet for
58
+ a plugin that manages its own document.
59
+
60
+ ## Angular
61
+
62
+ ```ts
63
+ import { bootstrapApplication } from "@angular/platform-browser";
64
+ import { provideHttpClient, withInterceptors } from "@angular/common/http";
65
+ import { InjectionToken } from "@angular/core";
66
+ import { connectToInfraClient, PluginContext } from "@fntio/infra-client-plugin-sdk/browser";
67
+ import { createPluginInterceptor } from "@fntio/infra-client-plugin-ui/angular";
68
+
69
+ export const PLUGIN = new InjectionToken<PluginContext>("infra-client plugin");
70
+
71
+ const context = await connectToInfraClient();
72
+ await bootstrapApplication(AppComponent, {
73
+ providers: [
74
+ { provide: PLUGIN, useValue: context },
75
+ provideHttpClient(withInterceptors([createPluginInterceptor(context)])),
76
+ ],
77
+ });
78
+ ```
79
+
80
+ `createPluginInterceptor(context)` attaches the current bearer token to requests whose URL
81
+ starts with `context.plugin.apiBaseUrl` (build them with `context.api.url(path)`), leaves
82
+ other URLs untouched, and after an authentication-layer 401 renews through the host and
83
+ retries once under the SDK's shared rule (`canRetryAfterUnauthorized`): never after 403, 5xx
84
+ or a timeout, never with a streamed body, never for an account in the request path that is no longer in
85
+ `context.accounts()`, never with the same token again. Like `context.api`, a 403 asks the host to refresh discovery unless
86
+ `accessRefreshOnForbidden: false`. The match is a plain prefix test, so absolute URLs are not
87
+ tokenised: place this interceptor after any base-URL-rewriting one. It needs only
88
+ `plugin`, `accounts`, `session` and `requestAccessRefresh` from the context
89
+ (`PluginInterceptorContext`).
90
+
91
+ The function is typed structurally against `HttpInterceptorFn`, so this entry depends on
92
+ `rxjs` only and no Angular version is pinned by the package;
93
+ `src/__tests__/angular-typecheck.ts` holds the shape to the real Angular type at
94
+ `tsc --noEmit` time.
95
+
96
+ ## Develop
97
+
98
+ ```
99
+ cd packages/infra-client-plugin-ui
100
+ npx tsc --noEmit && npm test
101
+ ```
102
+
103
+ Same arrangement as the CDK package: checks resolve the SDK from `src/`, the build from
104
+ `dist/` (`npm run build:plugins` at the repository root). The Angular packages are dev
105
+ dependencies for the type check only.
@@ -0,0 +1,26 @@
1
+ import { PluginContext } from "@fntio/infra-client-plugin-sdk/browser";
2
+ import { Observable } from "rxjs";
3
+ export interface PluginHttpRequestLike<Self> {
4
+ readonly url: string;
5
+ readonly body: unknown;
6
+ clone(update: {
7
+ setHeaders: Record<string, string>;
8
+ }): Self;
9
+ }
10
+ export type PluginHttpHandlerLike<Request, Event> = (request: Request) => Observable<Event>;
11
+ export type PluginHttpInterceptor = <Request extends PluginHttpRequestLike<Request>, Event>(request: Request, next: PluginHttpHandlerLike<Request, Event>) => Observable<Event>;
12
+ /** What the interceptor needs from a `PluginContext`. */
13
+ export type PluginInterceptorContext = Pick<PluginContext, "plugin" | "accounts" | "session" | "requestAccessRefresh">;
14
+ export interface PluginInterceptorOptions {
15
+ /** Requests whose URL starts here get the token; default `context.plugin.apiBaseUrl`. */
16
+ readonly apiBaseUrl?: string;
17
+ /** Ask the host to refresh discovery after a 403, as `context.api` does. Default true. */
18
+ readonly accessRefreshOnForbidden?: boolean;
19
+ }
20
+ /** Attaches the current bearer token to requests whose URL starts with the plugin's API base
21
+ * (`context.api.url(path)` builds such URLs; absolute URLs are not matched, so place this after
22
+ * any base-URL-rewriting interceptor) and retries once after an authentication-layer 401 under
23
+ * the same shared rules as `context.api` (`shouldRefreshAfterUnauthorized`, then
24
+ * `canRetryAfterUnauthorized`). Other URLs pass through — and after the host ends the session
25
+ * `context.session.token()` rejects, so no request leaves on a dead token. */
26
+ export declare function createPluginInterceptor(context: PluginInterceptorContext, options?: PluginInterceptorOptions): PluginHttpInterceptor;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPluginInterceptor = createPluginInterceptor;
4
+ // An Angular-shaped HTTP interceptor without an Angular import: it is typed structurally against
5
+ // `HttpInterceptorFn`, so this entry needs only rxjs at runtime and any supported Angular version can
6
+ // hand it to `withInterceptors`. `src/__tests__/angular-typecheck.ts` holds the shape to the real type.
7
+ const browser_1 = require("@fntio/infra-client-plugin-sdk/browser");
8
+ const rxjs_1 = require("rxjs");
9
+ function statusOf(error) {
10
+ return typeof error === "object" && error !== null && typeof error.status === "number"
11
+ ? error.status
12
+ : undefined;
13
+ }
14
+ /** Attaches the current bearer token to requests whose URL starts with the plugin's API base
15
+ * (`context.api.url(path)` builds such URLs; absolute URLs are not matched, so place this after
16
+ * any base-URL-rewriting interceptor) and retries once after an authentication-layer 401 under
17
+ * the same shared rules as `context.api` (`shouldRefreshAfterUnauthorized`, then
18
+ * `canRetryAfterUnauthorized`). Other URLs pass through — and after the host ends the session
19
+ * `context.session.token()` rejects, so no request leaves on a dead token. */
20
+ function createPluginInterceptor(context, options = {}) {
21
+ const base = (options.apiBaseUrl ?? context.plugin.apiBaseUrl).replace(/\/+$/, "");
22
+ const inScope = (url) => url === base || url.startsWith(`${base}/`) || url.startsWith(`${base}?`);
23
+ const fail = (error) => {
24
+ if (statusOf(error) === 403 && options.accessRefreshOnForbidden !== false)
25
+ context.requestAccessRefresh("forbidden");
26
+ return (0, rxjs_1.throwError)(() => error);
27
+ };
28
+ return (request, next) => {
29
+ if (!inScope(request.url))
30
+ return next(request);
31
+ // Always against the plugin's own API root: a narrowed `apiBaseUrl` option may itself contain the account.
32
+ const replayable = () => ({
33
+ body: request.body, account: (0, browser_1.pluginRequestAccount)(context.plugin.apiBaseUrl, request.url), permitted: context.accounts(),
34
+ });
35
+ const send = (token) => next(request.clone({ setHeaders: { Authorization: `Bearer ${token}` } }));
36
+ return (0, rxjs_1.from)(context.session.token()).pipe((0, rxjs_1.switchMap)((token) => send(token).pipe((0, rxjs_1.catchError)((error) => {
37
+ if (statusOf(error) !== 401 || !(0, browser_1.shouldRefreshAfterUnauthorized)(replayable()))
38
+ return fail(error);
39
+ return (0, rxjs_1.from)(context.session.refresh("unauthorized")).pipe((0, rxjs_1.switchMap)((session) => (0, browser_1.canRetryAfterUnauthorized)({ ...replayable(), rejectedToken: token, retryToken: session.token })
40
+ ? send(session.token).pipe((0, rxjs_1.catchError)(fail))
41
+ : fail(error)));
42
+ }))));
43
+ };
44
+ }
@@ -0,0 +1,5 @@
1
+ export declare const PLUGIN_UI_VERSION = "0.2.0";
2
+ export { applyPluginUi, PLUGIN_UI_STYLE_ID, pluginUiCss } from "./styles";
3
+ export type { PluginUiDocument, PluginUiNode, PluginUiStyleElement } from "./styles";
4
+ export { applyPluginTheme, isPluginThemeToken, isSafeCssValue, PLUGIN_THEME_STYLE_ID, PLUGIN_THEME_TOKENS, pluginThemeCss, } from "@fntio/infra-client-plugin-sdk/browser";
5
+ export type { PluginTheme, PluginThemeDocument, PluginThemeToken, PluginThemeTokens } from "@fntio/infra-client-plugin-sdk/browser";
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pluginThemeCss = exports.PLUGIN_THEME_TOKENS = exports.PLUGIN_THEME_STYLE_ID = exports.isSafeCssValue = exports.isPluginThemeToken = exports.applyPluginTheme = exports.pluginUiCss = exports.PLUGIN_UI_STYLE_ID = exports.applyPluginUi = exports.PLUGIN_UI_VERSION = void 0;
4
+ exports.PLUGIN_UI_VERSION = "0.2.0";
5
+ var styles_1 = require("./styles");
6
+ Object.defineProperty(exports, "applyPluginUi", { enumerable: true, get: function () { return styles_1.applyPluginUi; } });
7
+ Object.defineProperty(exports, "PLUGIN_UI_STYLE_ID", { enumerable: true, get: function () { return styles_1.PLUGIN_UI_STYLE_ID; } });
8
+ Object.defineProperty(exports, "pluginUiCss", { enumerable: true, get: function () { return styles_1.pluginUiCss; } });
9
+ var browser_1 = require("@fntio/infra-client-plugin-sdk/browser");
10
+ Object.defineProperty(exports, "applyPluginTheme", { enumerable: true, get: function () { return browser_1.applyPluginTheme; } });
11
+ Object.defineProperty(exports, "isPluginThemeToken", { enumerable: true, get: function () { return browser_1.isPluginThemeToken; } });
12
+ Object.defineProperty(exports, "isSafeCssValue", { enumerable: true, get: function () { return browser_1.isSafeCssValue; } });
13
+ Object.defineProperty(exports, "PLUGIN_THEME_STYLE_ID", { enumerable: true, get: function () { return browser_1.PLUGIN_THEME_STYLE_ID; } });
14
+ Object.defineProperty(exports, "PLUGIN_THEME_TOKENS", { enumerable: true, get: function () { return browser_1.PLUGIN_THEME_TOKENS; } });
15
+ Object.defineProperty(exports, "pluginThemeCss", { enumerable: true, get: function () { return browser_1.pluginThemeCss; } });
@@ -0,0 +1,21 @@
1
+ export declare const PLUGIN_UI_STYLE_ID = "infra-client-plugin-ui";
2
+ /** The stylesheet, for a plugin that manages its own document or server-renders. */
3
+ export declare function pluginUiCss(): string;
4
+ export interface PluginUiNode {
5
+ textContent: string | null;
6
+ }
7
+ export interface PluginUiStyleElement extends PluginUiNode {
8
+ id: string;
9
+ }
10
+ /** The slice of `Document` this touches; a real `Document` satisfies it. `appendChild` takes the wider
11
+ * node type on purpose — the DOM's own signature accepts any Node, and a narrower one would not match. */
12
+ export interface PluginUiDocument {
13
+ readonly head: {
14
+ appendChild(node: PluginUiNode): unknown;
15
+ };
16
+ getElementById(id: string): PluginUiNode | null;
17
+ createElement(tagName: "style"): PluginUiStyleElement;
18
+ }
19
+ /** Puts the component styles in the document, once. Call it alongside the SDK's theme application:
20
+ * the theme supplies the values, this supplies the shapes. */
21
+ export declare function applyPluginUi(doc: PluginUiDocument): void;
package/dist/styles.js ADDED
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_UI_STYLE_ID = void 0;
4
+ exports.pluginUiCss = pluginUiCss;
5
+ exports.applyPluginUi = applyPluginUi;
6
+ /** The portal's own look, as plain CSS classes a plugin of any framework can use.
7
+ *
8
+ * A plugin frame is handed the portal's colour and typography tokens, but tokens alone leave every
9
+ * author re-inventing buttons, tables and headers — and landing somewhere close but visibly foreign.
10
+ * These classes reproduce the shipped control scale (24/32/36px), type roles and surface treatments so a
11
+ * plugin page reads as part of the app without copying anything.
12
+ *
13
+ * Every value resolves from a theme token, so a customer's branding and the viewer's light/dark choice
14
+ * carry through. The `ic-` prefix keeps them out of a plugin's own namespace. */
15
+ const CSS = `
16
+ /* The page itself: see-through so the portal's own surface shows behind the frame, in the portal's
17
+ text colour and type. :where() keeps these at zero specificity, so a plugin's own rules win. */
18
+ :where(html, body) { background: transparent; }
19
+ :where(body) { margin: 0; color: var(--surface-foreground); font-family: var(--font-sans, system-ui, sans-serif); font-size: 0.875rem; line-height: 1.5; }
20
+
21
+ .ic-page { display: flex; flex-direction: column; gap: 1rem; color: var(--surface-foreground); font-family: var(--font-sans, system-ui, sans-serif); font-size: 0.875rem; line-height: 1.5; }
22
+ .ic-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
23
+ .ic-title { margin: 0; font-size: 1.75rem; font-weight: 500; letter-spacing: -0.02em; color: var(--surface-foreground); }
24
+ .ic-card-title { margin: 0; font-size: 0.875rem; font-weight: 500; letter-spacing: -0.01em; color: var(--surface-foreground); }
25
+ .ic-subtitle { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--surface-foreground); }
26
+ .ic-muted { color: var(--muted-foreground); }
27
+ .ic-caption { font-size: 0.75rem; color: var(--muted-foreground); }
28
+ .ic-mono { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-variant-numeric: tabular-nums; }
29
+ .ic-actions { display: flex; align-items: center; gap: 0.5rem; }
30
+
31
+ .ic-card { border: 1px solid var(--border); border-radius: var(--radius-lg, 0.75rem); background: var(--card-bg, transparent); padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
32
+ .ic-card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
33
+
34
+ /* Wide content scrolls in its own box; a plugin frame must never scroll the portal sideways. */
35
+ .ic-table-wrap { overflow-x: auto; }
36
+ .ic-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
37
+ .ic-table th { text-align: left; font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted-foreground); padding: 0 0.75rem 0.5rem; white-space: nowrap; }
38
+ .ic-table td { padding: 0.55rem 0.75rem; border-top: 1px solid var(--border); vertical-align: middle; }
39
+ .ic-table tbody tr:hover { background: var(--state-hover, transparent); }
40
+ .ic-table td:last-child, .ic-table th:last-child { text-align: right; }
41
+
42
+ /* Control scale shared with the portal: sm 24px, md 32px, lg 36px. */
43
+ .ic-btn { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; gap: 0.5rem; white-space: nowrap; height: 2rem; padding: 0 0.75rem; border: 0; border-radius: var(--radius, 0.5rem); font: inherit; font-size: 0.875rem; cursor: pointer; transition: background-color 120ms var(--ease-standard, ease); }
44
+ .ic-btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
45
+ .ic-btn:disabled { opacity: 0.5; cursor: not-allowed; }
46
+ .ic-btn-sm { height: 1.5rem; padding: 0 0.625rem; font-size: 0.75rem; font-weight: 500; }
47
+ .ic-btn-lg { height: 2.25rem; padding: 0 1rem; }
48
+ .ic-btn-primary { background: var(--brand-primary); color: var(--brand-foreground); }
49
+ .ic-btn-primary:hover:not(:disabled) { background: var(--brand-primary-hover, var(--brand-primary)); }
50
+ /* Alpha fills, like the portal's: they tune independently of the accent scale and survive rebranding. */
51
+ .ic-btn-secondary { background: color-mix(in srgb, var(--brand-primary) 12%, transparent); color: var(--brand-muted-foreground, var(--brand-primary)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-primary) 25%, transparent); }
52
+ .ic-btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-primary) 18%, transparent); }
53
+ .ic-btn-outline { background: transparent; color: var(--surface-foreground); font-weight: 500; box-shadow: inset 0 0 0 1px var(--border-strong); }
54
+ .ic-btn-outline:hover:not(:disabled) { background: var(--muted, var(--state-hover)); }
55
+ .ic-btn-ghost { background: transparent; color: var(--muted-foreground); }
56
+ .ic-btn-ghost:hover:not(:disabled) { background: var(--muted, var(--state-hover)); }
57
+ .ic-btn-danger { background: transparent; color: var(--danger); font-weight: 500; box-shadow: inset 0 0 0 1px var(--border-strong); }
58
+ .ic-btn-danger:hover:not(:disabled) { background: var(--danger-muted, transparent); }
59
+
60
+ .ic-field { display: flex; flex-direction: column; gap: 0.25rem; }
61
+ .ic-label { font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground); }
62
+ .ic-input, .ic-select { height: 2.25rem; padding: 0 0.5rem; font: inherit; font-size: 0.875rem; color: var(--surface-foreground); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius, 0.5rem); }
63
+ .ic-input:focus-visible, .ic-select:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 1px; }
64
+
65
+ .ic-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.6875rem; white-space: nowrap; background: var(--card-bg); color: var(--muted-foreground); }
66
+ .ic-badge-brand { background: color-mix(in srgb, var(--brand-primary) 14%, transparent); color: var(--brand-muted-foreground, var(--brand-primary)); }
67
+ .ic-badge-green { background: var(--success-muted, transparent); color: var(--success); }
68
+ .ic-badge-amber { background: var(--warning-muted, transparent); color: var(--warning); }
69
+ .ic-badge-red { background: var(--danger-muted, transparent); color: var(--danger); }
70
+
71
+ /* Every plugin needs these three, and a plugin that improvises them is where the look breaks down. */
72
+ .ic-empty, .ic-error { border: 1px solid var(--border); border-radius: var(--radius-lg, 0.75rem); background: var(--card-bg, transparent); padding: 1.5rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
73
+ .ic-empty p, .ic-error p { margin: 0; }
74
+ .ic-error { border-left: 3px solid var(--danger); }
75
+ .ic-error .ic-error-title { color: var(--danger); font-weight: 500; }
76
+
77
+ .ic-skeleton { height: 1rem; border-radius: var(--radius, 0.5rem); background: var(--muted, var(--card-bg)); animation: ic-pulse 1.4s ease-in-out infinite; }
78
+ .ic-skeleton + .ic-skeleton { margin-top: 0.5rem; }
79
+ @keyframes ic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
80
+ @media (prefers-reduced-motion: reduce) { .ic-skeleton { animation: none; } }
81
+ `;
82
+ exports.PLUGIN_UI_STYLE_ID = "infra-client-plugin-ui";
83
+ /** The stylesheet, for a plugin that manages its own document or server-renders. */
84
+ function pluginUiCss() {
85
+ return CSS;
86
+ }
87
+ /** Puts the component styles in the document, once. Call it alongside the SDK's theme application:
88
+ * the theme supplies the values, this supplies the shapes. */
89
+ function applyPluginUi(doc) {
90
+ const existing = doc.getElementById(exports.PLUGIN_UI_STYLE_ID);
91
+ if (existing) {
92
+ existing.textContent = CSS;
93
+ return;
94
+ }
95
+ const element = doc.createElement("style");
96
+ element.id = exports.PLUGIN_UI_STYLE_ID;
97
+ element.textContent = CSS;
98
+ doc.head.appendChild(element);
99
+ }
package/package.json CHANGED
@@ -1,6 +1,95 @@
1
1
  {
2
2
  "name": "@fntio/infra-client-plugin-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Theme helpers and an Angular-compatible HTTP interceptor for infra-client plugin frontends.",
5
+ "license": "Elastic-2.0",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/FNTIO/aws-infrastructure-client.git",
12
+ "directory": "packages/infra-client-plugin-ui"
13
+ },
14
+ "homepage": "https://github.com/FNTIO/aws-infrastructure-client/wiki",
15
+ "bugs": {
16
+ "url": "https://github.com/FNTIO/aws-infrastructure-client/issues"
17
+ },
18
+ "main": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "exports": {
21
+ "./package.json": "./package.json",
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./angular": {
27
+ "types": "./dist/angular/index.d.ts",
28
+ "default": "./dist/angular/index.js"
29
+ }
30
+ },
31
+ "typesVersions": {
32
+ "*": {
33
+ "angular": [
34
+ "dist/angular/index.d.ts"
35
+ ]
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "README.md"
41
+ ],
42
+ "sideEffects": false,
43
+ "engines": {
44
+ "node": ">=20"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.build.json",
48
+ "prepack": "npm run build",
49
+ "test": "jest"
50
+ },
51
+ "jest": {
52
+ "testEnvironment": "node",
53
+ "roots": [
54
+ "<rootDir>/src"
55
+ ],
56
+ "testMatch": [
57
+ "**/*.test.ts"
58
+ ],
59
+ "transform": {
60
+ "^.+\\.tsx?$": [
61
+ "ts-jest",
62
+ {
63
+ "tsconfig": "<rootDir>/tsconfig.jest.json"
64
+ }
65
+ ]
66
+ },
67
+ "moduleNameMapper": {
68
+ "^@fntio/infra-client-plugin-sdk$": "<rootDir>/../infra-client-plugin-sdk/src/index.ts",
69
+ "^@fntio/infra-client-plugin-sdk/(.*)$": "<rootDir>/../infra-client-plugin-sdk/src/$1/index.ts"
70
+ },
71
+ "maxWorkers": "50%",
72
+ "workerIdleMemoryLimit": "2GB"
73
+ },
74
+ "dependencies": {
75
+ "@fntio/infra-client-plugin-sdk": "^0.2.0"
76
+ },
77
+ "peerDependencies": {
78
+ "rxjs": "^7.8.0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "rxjs": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "devDependencies": {
86
+ "@angular/common": "^20.3.27",
87
+ "@angular/core": "^20.3.27",
88
+ "@types/jest": "^29.5.14",
89
+ "@types/node": "^20.19.43",
90
+ "jest": "^29.7.0",
91
+ "rxjs": "^7.8.0",
92
+ "ts-jest": "^29.2.0",
93
+ "typescript": "^5.5.0"
94
+ }
95
+ }