@k8slens/drop-down-menu-contracts 1.0.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.
@@ -0,0 +1,51 @@
1
+ import type { DropDownMenuKind } from "./drop-down-menu-kind";
2
+ /**
3
+ * One drop-down menu that exists, announced so it can be discovered rather
4
+ * than found by reading the source.
5
+ */
6
+ export interface DropDownMenuKindDeclaration {
7
+ /** The kind itself, as `dropDownMenuItemInjectionToken.for(kind)` takes it. */
8
+ readonly kind: DropDownMenuKind<any>;
9
+ /** One line on what the menu is, for a reader deciding whether to contribute. */
10
+ readonly description: string;
11
+ }
12
+ /** Produces one declaration, possibly later. */
13
+ export type DropDownMenuKindDeclarationFactory = () => DropDownMenuKindDeclaration;
14
+ /**
15
+ * Every drop-down menu kind the running build knows about.
16
+ *
17
+ * Injecting many of these is how a surface enumerates the menus that exist —
18
+ * the extension-development instructions render their list from it, so a new
19
+ * menu becomes documented by registering here rather than by someone
20
+ * remembering to edit prose.
21
+ */
22
+ export declare const dropDownMenuKindInjectionToken: import("@k8slens/injectable").InjectionToken2Base<DropDownMenuKindDeclarationFactory, () => DropDownMenuKindDeclaration[], "zero-or-many", () => import("@k8slens/injectable").InjectionInstanceWithMeta<DropDownMenuKindDeclaration>, () => import("@k8slens/injectable").InjectionInstanceWithMeta<DropDownMenuKindDeclaration>[]> & {
23
+ readonly __abstract?: never;
24
+ };
25
+ export interface DropDownMenuKindInjectableParams {
26
+ /** Unique id for the registered injectable. */
27
+ readonly id: string;
28
+ /** The kind being announced. */
29
+ readonly kind: DropDownMenuKind<any>;
30
+ /** One line on what the menu is. */
31
+ readonly description: string;
32
+ }
33
+ /**
34
+ * Announce a drop-down menu kind, so anything enumerating the menus finds it.
35
+ *
36
+ * Register this wherever the menu's own surface is registered — a contracts
37
+ * package exports the kind, but not the registration.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * export default getDropDownMenuKindInjectableBunch({
42
+ * id: "ai-tool-top-bar-menu-kind",
43
+ * kind: aiToolTopBarMenuKind,
44
+ * description: "The menu of the AI tool button in the top bar.",
45
+ * });
46
+ * ```
47
+ */
48
+ export declare const getDropDownMenuKindInjectableBunch: (params: DropDownMenuKindInjectableParams) => {
49
+ dropDownMenuKind: import("@k8slens/injectable").Injectable2<() => DropDownMenuKindDeclaration>;
50
+ };
51
+ //# sourceMappingURL=drop-down-menu-kind-injection-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop-down-menu-kind-injection-token.d.ts","sourceRoot":"","sources":["../../src/drop-down-menu-kind-injection-token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACrC,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,gDAAgD;AAChD,MAAM,MAAM,kCAAkC,GAAG,MAAM,2BAA2B,CAAC;AAEnF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B;;CAKvC,CAAC;AAEL,MAAM,WAAW,gCAAgC;IAC/C,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACrC,oCAAoC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kCAAkC,WAAY,gCAAgC;sEAK9D,2BAA2B;CAOpD,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type TypedSpecifier, type TypedSpecifierType } from "@k8slens/injectable";
2
+ /**
3
+ * Identifies one family of drop-down menu items. Items are contributed against
4
+ * a kind via `dropDownMenuItemInjectionToken.for(kind)`, and a host element
5
+ * opens the menu of a kind with `$dropDownMenu={dropDownMenu(kind)}`.
6
+ *
7
+ * `TData` is the data the host element supplies when opening the menu; item
8
+ * factories of the kind receive it. A kind created without `TData` needs no
9
+ * data.
10
+ *
11
+ * At runtime a kind is a branded string, so it is usable as a `.for()` key.
12
+ */
13
+ export type DropDownMenuKind<TData = void> = TypedSpecifier<string, {
14
+ dropDownMenuData: TData;
15
+ }>;
16
+ /**
17
+ * Recovers the data type bound to a {@link DropDownMenuKind}.
18
+ */
19
+ export type DropDownMenuData<K extends DropDownMenuKind<any>> = TypedSpecifierType<"dropDownMenuData", K>;
20
+ /**
21
+ * Curried creator for a {@link DropDownMenuKind}. The first call binds the data
22
+ * type; the second the globally unique specifier string.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * // A menu whose items need no data:
27
+ * export const aiToolsMenuKind = getDropDownMenuKind()("ai-tools-menu");
28
+ *
29
+ * // A menu whose items derive from the host element's data:
30
+ * export const podActionsMenuKind = getDropDownMenuKind<{ podName: string }>()("pod-actions-menu");
31
+ * ```
32
+ */
33
+ export declare const getDropDownMenuKind: <TData = void>() => <S extends string>(specifier: S) => TypedSpecifier<S, {
34
+ dropDownMenuData: TData;
35
+ }>;
36
+ //# sourceMappingURL=drop-down-menu-kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop-down-menu-kind.d.ts","sourceRoot":"","sources":["../../src/drop-down-menu-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEtG;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,IAAI,IAAI,cAAc,CAAC,MAAM,EAAE;IAAE,gBAAgB,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;AAE1G;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,GAC7B,KAAK,GAAG,IAAI,QACZ,CAAC,SAAS,MAAM,aAAa,CAAC;sBACS,KAAK;EAAgB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import type { DropDownMenuData, DropDownMenuKind } from "./drop-down-menu-kind";
2
+ /**
3
+ * How the menu opens from its host element.
4
+ *
5
+ * - `"click"` (the default): clicking the element toggles the menu.
6
+ * - `"hover"`: the menu opens while the pointer is over the element or the menu.
7
+ * - `"right-click"`: right-clicking the element toggles the menu. The menu stays anchored to the
8
+ * element; cursor-anchored right-click menus are the concern of `@lensapp/context-menu`.
9
+ */
10
+ export type DropDownMenuOpenOn = "click" | "hover" | "right-click";
11
+ /**
12
+ * Where the menu sits relative to its host element: a side of the host, optionally refined with how
13
+ * the menu extends along that side. A bare side centers the menu on it; `span-<direction>` aligns
14
+ * their edges and lets the menu extend toward that direction.
15
+ *
16
+ * Defaults to `"bottom span-right"`. When the menu would not fit the viewport, it falls back to the
17
+ * mirrored positions.
18
+ *
19
+ * Note: kept identical to `AnchorPosition` of `@k8slens/element-components`, which cannot be
20
+ * imported here — it depends on this package.
21
+ */
22
+ export type DropDownMenuPosition = "top" | "bottom" | "left" | "right" | "top span-left" | "top span-right" | "bottom span-left" | "bottom span-right" | "left span-top" | "left span-bottom" | "right span-top" | "right span-bottom";
23
+ /**
24
+ * How far from its host the menu sits, on the shared t-shirt scale. Defaults to `"xs"`.
25
+ *
26
+ * Note: kept identical to `TShirtSize` of `@k8slens/element-components`, which cannot be imported
27
+ * here — it depends on this package.
28
+ */
29
+ export type DropDownMenuGap = "zero" | "4xs" | "3xs" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "11xl";
30
+ /**
31
+ * The value of the `$dropDownMenu` element prop: which menu kind to open, the data its item
32
+ * factories receive, how the menu opens and where it sits. Create with {@link dropDownMenu} so the
33
+ * data is typed by the kind.
34
+ */
35
+ export type DropDownMenuSpec = {
36
+ readonly kind: DropDownMenuKind<any>;
37
+ readonly data?: unknown;
38
+ readonly openOn?: DropDownMenuOpenOn;
39
+ readonly position?: DropDownMenuPosition;
40
+ readonly gap?: DropDownMenuGap;
41
+ };
42
+ export type DropDownMenuOptions = {
43
+ readonly openOn?: DropDownMenuOpenOn;
44
+ readonly position?: DropDownMenuPosition;
45
+ readonly gap?: DropDownMenuGap;
46
+ };
47
+ /**
48
+ * Typed constructor for a {@link DropDownMenuSpec}: a kind created for a data type makes `data`
49
+ * required and typed; a kind without data forbids it.
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * <Button $dropDownMenu={dropDownMenu(aiToolsMenuKind)}>Open</Button>
54
+ * <Button $dropDownMenu={dropDownMenu(podActionsMenuKind, { data: { podName } })}>Pod</Button>
55
+ * <Button $dropDownMenu={dropDownMenu(rowActionsMenuKind, { position: "bottom span-left" })}>⋮</Button>
56
+ * ```
57
+ */
58
+ export declare function dropDownMenu<K extends DropDownMenuKind<void>>(kind: K, options?: DropDownMenuOptions): DropDownMenuSpec;
59
+ export declare function dropDownMenu<K extends DropDownMenuKind<any>>(kind: K, options: DropDownMenuOptions & {
60
+ readonly data: DropDownMenuData<K>;
61
+ }): DropDownMenuSpec;
62
+ //# sourceMappingURL=drop-down-menu-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop-down-menu-spec.d.ts","sourceRoot":"","sources":["../../src/drop-down-menu-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAC5B,KAAK,GACL,QA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EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;CAAE,GACpE,gBAAgB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Told by an item when it is activated, so the menu it belongs to — and the menus it was opened
3
+ * from — can close. Items themselves know nothing of menus.
4
+ */
5
+ export declare const menuItemActivatedContext: import("react").Context<VoidFunction | undefined>;
6
+ //# sourceMappingURL=menu-item-activated-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-item-activated-context.d.ts","sourceRoot":"","sources":["../../src/menu-item-activated-context.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,mDAAqD,CAAC"}