@molecule/app-http-inspector-angular 0.0.0-stage → 1.1.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,220 @@
1
+ import type { UIClassMap } from '@molecule/app-ui';
2
+ import type { HttpHeader, HttpMethod, HttpResponse } from './types.js';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * HttpInspector component.
6
+ *
7
+ * Controlled HTTP request builder + response panel. The host IS the outer
8
+ * `<div>` React renders (`div[mol-http-inspector]`), with the same classes.
9
+ * App owns request state + the actual `fetch`; this component renders the UI:
10
+ * method + URL row, headers key/value editor, body textarea (methods that
11
+ * allow a body), Send button, then a response panel showing status + timing +
12
+ * body.
13
+ */
14
+ export declare class HttpInspector {
15
+ /** The request's HTTP method. */
16
+ method: HttpMethod;
17
+ /** Called with the new method when the user picks one (React's `onMethodChange`). */
18
+ onMethodChange?: (method: HttpMethod) => void;
19
+ /** The request URL. */
20
+ url: string;
21
+ /** Called with the new URL as the user types (React's `onUrlChange`). */
22
+ onUrlChange?: (url: string) => void;
23
+ /** The request headers, in render order. */
24
+ headers: HttpHeader[];
25
+ /** Called with the next header list on any header edit (React's `onHeadersChange`). */
26
+ onHeadersChange?: (headers: HttpHeader[]) => void;
27
+ /** The request body. */
28
+ body: string;
29
+ /** Called with the new body as the user types (React's `onBodyChange`). */
30
+ onBodyChange?: (body: string) => void;
31
+ /** Sends the request (React's `onSend`). */
32
+ onSend?: () => void | Promise<void>;
33
+ /** Whether a send is in flight (React's `sending`). */
34
+ sending?: boolean;
35
+ /** The last response to show (React's `response`). */
36
+ response?: HttpResponse | null;
37
+ /** Extra classes on the outer wrapper (React's `className`). */
38
+ className?: string;
39
+ /** The method options, in React's order. */
40
+ readonly methodOptions: {
41
+ value: HttpMethod;
42
+ label: HttpMethod;
43
+ }[];
44
+ /** The body textarea's placeholder (React's literal). */
45
+ readonly bodyPlaceholder = "{\"key\": \"value\"}";
46
+ /**
47
+ * Reactive translation, read in the injection context. Its `t` reads the
48
+ * locale, so the view re-renders the labels on a locale switch (the static
49
+ * `t` does not).
50
+ */
51
+ private readonly i18n;
52
+ /**
53
+ * The current class map.
54
+ * @returns The UIClassMap.
55
+ */
56
+ cm(): UIClassMap;
57
+ /**
58
+ * The wrapper class list (React's `cm.cn(cm.stack(3), className)`).
59
+ * @returns The class string.
60
+ */
61
+ classes(): string;
62
+ /**
63
+ * The method + URL row's class (React's `cm.flex({ align: 'center', gap: 'sm' })`).
64
+ * @returns The class string.
65
+ */
66
+ rowClasses(): string;
67
+ /**
68
+ * A header row's class (React's `cm.flex({ align: 'center', gap: 'xs' })`).
69
+ * @returns The class string.
70
+ */
71
+ headerRowClasses(): string;
72
+ /**
73
+ * The headers / body section's class (React's `cm.stack(1)`).
74
+ * @returns The class string.
75
+ */
76
+ stack1Classes(): string;
77
+ /**
78
+ * The response section's class (React's `cm.stack(2)`).
79
+ * @returns The class string.
80
+ */
81
+ stack2Classes(): string;
82
+ /**
83
+ * A section label's class (React's `cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'))`).
84
+ * @returns The class string.
85
+ */
86
+ labelClasses(): string;
87
+ /**
88
+ * The timing span's class (React's `cm.textSize('xs')`).
89
+ * @returns The class string.
90
+ */
91
+ textXsClasses(): string;
92
+ /**
93
+ * The response body panel's class (React's `cm.cn(cm.sp('p', 3), cm.textSize('xs'))`).
94
+ * @returns The class string.
95
+ */
96
+ preClasses(): string;
97
+ /**
98
+ * The URL input's extra class (React's `cm.flex1`).
99
+ * @returns The class string.
100
+ */
101
+ flexClasses(): string;
102
+ /**
103
+ * The status badge's class list (React's `cm.bgTone(tone)` + `cm.textOnTone`).
104
+ *
105
+ * @param code - The response status code.
106
+ * @returns The class string.
107
+ */
108
+ statusClasses(code: number): string;
109
+ /**
110
+ * The status badge's inline style (React's padding, radius and weight; the
111
+ * tone colours come from {@link statusClasses}).
112
+ *
113
+ * @returns The style map.
114
+ */
115
+ statusStyle(): Record<string, string>;
116
+ /**
117
+ * The response body panel's inline style (horizontal scrolling).
118
+ * @returns The style map.
119
+ */
120
+ preStyle(): Record<string, string>;
121
+ /**
122
+ * Whether the body editor renders (React hides it for GET and HEAD).
123
+ * @returns True when the method allows a body.
124
+ */
125
+ showBody(): boolean;
126
+ /**
127
+ * The Send button's pending label (React's `httpInspector.sending`).
128
+ * @returns The label text.
129
+ */
130
+ sendingText(): string;
131
+ /**
132
+ * The Send button's idle label (React's `httpInspector.send`).
133
+ * @returns The label text.
134
+ */
135
+ sendText(): string;
136
+ /**
137
+ * The headers section's label (React's `httpInspector.headers`).
138
+ * @returns The label text.
139
+ */
140
+ headersLabel(): string;
141
+ /**
142
+ * The body section's label (React's `httpInspector.body`).
143
+ * @returns The label text.
144
+ */
145
+ bodyLabel(): string;
146
+ /**
147
+ * The add-header button's label (React's `httpInspector.addHeader`).
148
+ * @returns The label text.
149
+ */
150
+ addHeaderLabel(): string;
151
+ /**
152
+ * The method select's accessible label (React's `httpInspector.methodLabel`).
153
+ * @returns The label text.
154
+ */
155
+ methodLabel(): string;
156
+ /**
157
+ * The URL field's accessible label (React's `httpInspector.urlLabel`).
158
+ * @returns The label text.
159
+ */
160
+ urlLabel(): string;
161
+ /**
162
+ * A header row's key placeholder (React's `httpInspector.headerPlaceholder`).
163
+ * @returns The placeholder text.
164
+ */
165
+ headerPlaceholder(): string;
166
+ /**
167
+ * A header row's value placeholder (React's `httpInspector.valuePlaceholder`).
168
+ * @returns The placeholder text.
169
+ */
170
+ valuePlaceholder(): string;
171
+ /**
172
+ * Reports a picked method (React's `onMethodChange`).
173
+ *
174
+ * @param method - The selected option value.
175
+ */
176
+ handleMethodChange(method: string): void;
177
+ /**
178
+ * Adopts the typed URL (React's `onUrlChange`).
179
+ *
180
+ * @param event - The native input event.
181
+ */
182
+ handleUrlChange(event: Event): void;
183
+ /**
184
+ * Updates a single header's key, keeping its value (React's `setHeader`).
185
+ *
186
+ * @param i - The row index.
187
+ * @param event - The native input event.
188
+ */
189
+ handleHeaderKey(i: number, event: Event): void;
190
+ /**
191
+ * Updates a single header's value, keeping its key (React's `setHeader`).
192
+ *
193
+ * @param i - The row index.
194
+ * @param event - The native input event.
195
+ */
196
+ handleHeaderValue(i: number, event: Event): void;
197
+ /**
198
+ * Removes one header (React's `headers.filter((_, j) => j !== i)`).
199
+ *
200
+ * @param i - The row index.
201
+ */
202
+ removeHeader(i: number): void;
203
+ /**
204
+ * Appends an empty header (React's `[...headers, { key: '', value: '' }]`).
205
+ */
206
+ addHeader(): void;
207
+ /**
208
+ * Adopts the typed body (React's `onBodyChange`).
209
+ *
210
+ * @param event - The native input event.
211
+ */
212
+ handleBodyChange(event: Event): void;
213
+ /**
214
+ * Calls the app's send handler (React's `void onSend()`).
215
+ */
216
+ send(): void;
217
+ static ɵfac: i0.ɵɵFactoryDeclaration<HttpInspector, never>;
218
+ static ɵcmp: i0.ɵɵComponentDeclaration<HttpInspector, "div[mol-http-inspector]", never, { "method": { "alias": "method"; "required": false; }; "onMethodChange": { "alias": "onMethodChange"; "required": false; }; "url": { "alias": "url"; "required": false; }; "onUrlChange": { "alias": "onUrlChange"; "required": false; }; "headers": { "alias": "headers"; "required": false; }; "onHeadersChange": { "alias": "onHeadersChange"; "required": false; }; "body": { "alias": "body"; "required": false; }; "onBodyChange": { "alias": "onBodyChange"; "required": false; }; "onSend": { "alias": "onSend"; "required": false; }; "sending": { "alias": "sending"; "required": false; }; "response": { "alias": "response"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, never, true, never>;
219
+ }
220
+ //# sourceMappingURL=http-inspector.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-inspector.component.d.ts","sourceRoot":"","sources":["../src/http-inspector.component.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;;AAoBtE;;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