brix-runtime-sdk-api-web 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.
- package/dist/index.js +190 -0
- package/dist/types/api-exports.test.d.ts +33 -0
- package/dist/types/api-exports.test.d.ts.map +1 -0
- package/dist/types/context/RuntimeContext.d.ts +69 -0
- package/dist/types/context/RuntimeContext.d.ts.map +1 -0
- package/dist/types/context/index.d.ts +23 -0
- package/dist/types/context/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +52 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/auth.d.ts +405 -0
- package/dist/types/types/auth.d.ts.map +1 -0
- package/dist/types/types/capability.d.ts +218 -0
- package/dist/types/types/capability.d.ts.map +1 -0
- package/dist/types/types/common.d.ts +99 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/config.d.ts +85 -0
- package/dist/types/types/config.d.ts.map +1 -0
- package/dist/types/types/event.d.ts +658 -0
- package/dist/types/types/event.d.ts.map +1 -0
- package/dist/types/types/http.d.ts +132 -0
- package/dist/types/types/http.d.ts.map +1 -0
- package/dist/types/types/i18n.d.ts +327 -0
- package/dist/types/types/i18n.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +61 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/layout.d.ts +301 -0
- package/dist/types/types/layout.d.ts.map +1 -0
- package/dist/types/types/module.d.ts +78 -0
- package/dist/types/types/module.d.ts.map +1 -0
- package/dist/types/types/navigation.d.ts +295 -0
- package/dist/types/types/navigation.d.ts.map +1 -0
- package/dist/types/types/plugin-loader-capability.d.ts +142 -0
- package/dist/types/types/plugin-loader-capability.d.ts.map +1 -0
- package/dist/types/types/plugin.d.ts +250 -0
- package/dist/types/types/plugin.d.ts.map +1 -0
- package/dist/types/types/state.d.ts +306 -0
- package/dist/types/types/state.d.ts.map +1 -0
- package/dist/types/types/theme.d.ts +279 -0
- package/dist/types/types/theme.d.ts.map +1 -0
- package/dist/types/types/ui/adapter.d.ts +181 -0
- package/dist/types/types/ui/adapter.d.ts.map +1 -0
- package/dist/types/types/ui/avatar.d.ts +102 -0
- package/dist/types/types/ui/avatar.d.ts.map +1 -0
- package/dist/types/types/ui/badge.d.ts +101 -0
- package/dist/types/types/ui/badge.d.ts.map +1 -0
- package/dist/types/types/ui/button.d.ts +135 -0
- package/dist/types/types/ui/button.d.ts.map +1 -0
- package/dist/types/types/ui/card.d.ts +105 -0
- package/dist/types/types/ui/card.d.ts.map +1 -0
- package/dist/types/types/ui/common.d.ts +29 -0
- package/dist/types/types/ui/common.d.ts.map +1 -0
- package/dist/types/types/ui/icon.d.ts +78 -0
- package/dist/types/types/ui/icon.d.ts.map +1 -0
- package/dist/types/types/ui/index.d.ts +59 -0
- package/dist/types/types/ui/index.d.ts.map +1 -0
- package/dist/types/types/ui/input.d.ts +200 -0
- package/dist/types/types/ui/input.d.ts.map +1 -0
- package/dist/types/types/ui/menu.d.ts +211 -0
- package/dist/types/types/ui/menu.d.ts.map +1 -0
- package/dist/types/types/ui/message.d.ts +121 -0
- package/dist/types/types/ui/message.d.ts.map +1 -0
- package/dist/types/types/ui/modal.d.ts +167 -0
- package/dist/types/types/ui/modal.d.ts.map +1 -0
- package/dist/types/types/ui/select.d.ts +213 -0
- package/dist/types/types/ui/select.d.ts.map +1 -0
- package/dist/types/types/ui/theme-tokens.d.ts +226 -0
- package/dist/types/types/ui/theme-tokens.d.ts.map +1 -0
- package/dist/types/types/ui/tooltip.d.ts +98 -0
- package/dist/types/types/ui/tooltip.d.ts.map +1 -0
- package/dist/types/types/ui.d.ts +49 -0
- package/dist/types/types/ui.d.ts.map +1 -0
- package/package.json +34 -0
- package/src/api-exports.test.ts +199 -0
- package/src/context/RuntimeContext.d.ts +69 -0
- package/src/context/RuntimeContext.d.ts.map +1 -0
- package/src/context/RuntimeContext.ts +75 -0
- package/src/context/index.d.ts +23 -0
- package/src/context/index.d.ts.map +1 -0
- package/src/context/index.ts +23 -0
- package/src/index.d.ts +52 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +59 -0
- package/src/types/auth.d.ts +146 -0
- package/src/types/auth.d.ts.map +1 -0
- package/src/types/auth.ts +479 -0
- package/src/types/capability.d.ts +218 -0
- package/src/types/capability.d.ts.map +1 -0
- package/src/types/capability.ts +302 -0
- package/src/types/common.d.ts +99 -0
- package/src/types/common.d.ts.map +1 -0
- package/src/types/common.ts +115 -0
- package/src/types/config.d.ts +64 -0
- package/src/types/config.d.ts.map +1 -0
- package/src/types/config.ts +96 -0
- package/src/types/event.d.ts +206 -0
- package/src/types/event.d.ts.map +1 -0
- package/src/types/event.ts +776 -0
- package/src/types/http.d.ts +132 -0
- package/src/types/http.d.ts.map +1 -0
- package/src/types/http.ts +156 -0
- package/src/types/i18n.ts +420 -0
- package/src/types/index.d.ts +50 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.ts +120 -0
- package/src/types/layout.ts +394 -0
- package/src/types/module.d.ts +78 -0
- package/src/types/module.d.ts.map +1 -0
- package/src/types/module.ts +92 -0
- package/src/types/navigation.d.ts +101 -0
- package/src/types/navigation.d.ts.map +1 -0
- package/src/types/navigation.ts +361 -0
- package/src/types/plugin-loader-capability.ts +159 -0
- package/src/types/plugin.d.ts +250 -0
- package/src/types/plugin.d.ts.map +1 -0
- package/src/types/plugin.ts +344 -0
- package/src/types/state.d.ts +119 -0
- package/src/types/state.d.ts.map +1 -0
- package/src/types/state.ts +366 -0
- package/src/types/theme.ts +378 -0
- package/src/types/ui/adapter.ts +222 -0
- package/src/types/ui/avatar.ts +113 -0
- package/src/types/ui/badge.ts +112 -0
- package/src/types/ui/button.ts +148 -0
- package/src/types/ui/card.ts +116 -0
- package/src/types/ui/common.ts +29 -0
- package/src/types/ui/icon.ts +85 -0
- package/src/types/ui/index.ts +78 -0
- package/src/types/ui/input.ts +225 -0
- package/src/types/ui/menu.ts +237 -0
- package/src/types/ui/message.ts +135 -0
- package/src/types/ui/modal.ts +188 -0
- package/src/types/ui/select.ts +239 -0
- package/src/types/ui/theme-tokens.ts +357 -0
- package/src/types/ui/tooltip.ts +120 -0
- package/src/types/ui.ts +49 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Brix Platform Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @file Theme Capability Type Definitions
|
|
18
|
+
* @description Defines core types for the theme system, including theme mode, color configuration, theme switching, etc.
|
|
19
|
+
* @module @brix/runtime-sdk-api-web/types/theme
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*
|
|
22
|
+
* [v3.2.0 Addition]
|
|
23
|
+
* Phase 1 contract layer fix: elevated ThemeCapability interface from shell-web to runtime-sdk-api-web.
|
|
24
|
+
*
|
|
25
|
+
* [Design Principles]
|
|
26
|
+
* - Theme variables are implemented via CSS variables, ensuring runtime switchability
|
|
27
|
+
* - Plugins cannot directly modify global styles, only through ThemeCapability
|
|
28
|
+
* - Theme switching notifies all modules via events
|
|
29
|
+
* - Hardcoding color values in components is prohibited
|
|
30
|
+
*
|
|
31
|
+
* [Architectural Constraints]
|
|
32
|
+
* ❌ Do not directly manipulate document.documentElement.style
|
|
33
|
+
* ❌ Do not hardcode color values
|
|
34
|
+
* ❌ Do not directly use localStorage to store theme preferences
|
|
35
|
+
* ✅ Operate theme through ThemeCapability or useTheme hook
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import type { Unsubscribe } from './event';
|
|
39
|
+
|
|
40
|
+
// =========================================
|
|
41
|
+
// Theme Mode
|
|
42
|
+
// =========================================
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Theme Mode
|
|
46
|
+
*
|
|
47
|
+
* - 'light': Light mode
|
|
48
|
+
* - 'dark': Dark mode
|
|
49
|
+
* - 'system': Follow system settings
|
|
50
|
+
*/
|
|
51
|
+
export type ThemeMode = 'light' | 'dark' | 'system';
|
|
52
|
+
|
|
53
|
+
// =========================================
|
|
54
|
+
// Theme Colors
|
|
55
|
+
// =========================================
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Theme Color Configuration
|
|
59
|
+
*
|
|
60
|
+
* <p>Defines the core color variables for the theme.</p>
|
|
61
|
+
*/
|
|
62
|
+
export interface ThemeColors {
|
|
63
|
+
/** Primary Color - Used for main buttons, links, highlighted elements */
|
|
64
|
+
readonly primary: string;
|
|
65
|
+
|
|
66
|
+
/** Secondary Color - Used for backgrounds, borders, auxiliary elements */
|
|
67
|
+
readonly secondary: string;
|
|
68
|
+
|
|
69
|
+
/** Tertiary Color - Used for page backgrounds, card backgrounds */
|
|
70
|
+
readonly tertiary?: string;
|
|
71
|
+
|
|
72
|
+
/** Success color */
|
|
73
|
+
readonly success: string;
|
|
74
|
+
|
|
75
|
+
/** Warning color */
|
|
76
|
+
readonly warning: string;
|
|
77
|
+
|
|
78
|
+
/** Error color */
|
|
79
|
+
readonly error: string;
|
|
80
|
+
|
|
81
|
+
/** Info color */
|
|
82
|
+
readonly info: string;
|
|
83
|
+
|
|
84
|
+
/** Primary text color */
|
|
85
|
+
readonly textPrimary?: string;
|
|
86
|
+
|
|
87
|
+
/** Secondary text color */
|
|
88
|
+
readonly textSecondary?: string;
|
|
89
|
+
|
|
90
|
+
/** Disabled text color */
|
|
91
|
+
readonly textDisabled?: string;
|
|
92
|
+
|
|
93
|
+
/** Default background color */
|
|
94
|
+
readonly backgroundDefault?: string;
|
|
95
|
+
|
|
96
|
+
/** Paper/card background color */
|
|
97
|
+
readonly backgroundPaper?: string;
|
|
98
|
+
|
|
99
|
+
/** Border color */
|
|
100
|
+
readonly border?: string;
|
|
101
|
+
|
|
102
|
+
/** Divider color */
|
|
103
|
+
readonly divider?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// =========================================
|
|
107
|
+
// Theme Configuration
|
|
108
|
+
// =========================================
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Theme Configuration
|
|
112
|
+
*
|
|
113
|
+
* <p>Complete theme configuration, including colors and other style parameters.</p>
|
|
114
|
+
*/
|
|
115
|
+
export interface ThemeConfig {
|
|
116
|
+
/** Color configuration */
|
|
117
|
+
readonly colors: ThemeColors;
|
|
118
|
+
|
|
119
|
+
/** Font family */
|
|
120
|
+
readonly fontFamily?: string;
|
|
121
|
+
|
|
122
|
+
/** Base font size */
|
|
123
|
+
readonly fontSize?: number;
|
|
124
|
+
|
|
125
|
+
/** Border radius base */
|
|
126
|
+
readonly borderRadius?: number;
|
|
127
|
+
|
|
128
|
+
/** Spacing base */
|
|
129
|
+
readonly spacing?: number;
|
|
130
|
+
|
|
131
|
+
/** Shadow configuration */
|
|
132
|
+
readonly shadows?: {
|
|
133
|
+
readonly sm?: string;
|
|
134
|
+
readonly md?: string;
|
|
135
|
+
readonly lg?: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** Whether to use system font */
|
|
139
|
+
readonly useSystemFont?: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// =========================================
|
|
143
|
+
// Theme Preset
|
|
144
|
+
// =========================================
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Theme Preset
|
|
148
|
+
*
|
|
149
|
+
* <p>Predefined theme configurations for quick switching.</p>
|
|
150
|
+
*/
|
|
151
|
+
export interface ThemePreset {
|
|
152
|
+
/** Preset ID */
|
|
153
|
+
readonly id: string;
|
|
154
|
+
|
|
155
|
+
/** Preset name */
|
|
156
|
+
readonly name: string;
|
|
157
|
+
|
|
158
|
+
/** Preset description */
|
|
159
|
+
readonly description?: string;
|
|
160
|
+
|
|
161
|
+
/** Light mode configuration */
|
|
162
|
+
readonly light: ThemeConfig;
|
|
163
|
+
|
|
164
|
+
/** Dark mode configuration */
|
|
165
|
+
readonly dark: ThemeConfig;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// =========================================
|
|
169
|
+
// Theme State
|
|
170
|
+
// =========================================
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Theme State
|
|
174
|
+
*
|
|
175
|
+
* <p>Describes the complete state of the current theme.</p>
|
|
176
|
+
*/
|
|
177
|
+
export interface ThemeState {
|
|
178
|
+
/** User selected theme mode */
|
|
179
|
+
readonly mode: ThemeMode;
|
|
180
|
+
|
|
181
|
+
/** Actual resolved theme mode (system resolves to light or dark) */
|
|
182
|
+
readonly resolvedMode: 'light' | 'dark';
|
|
183
|
+
|
|
184
|
+
/** Current theme configuration */
|
|
185
|
+
readonly config: ThemeConfig;
|
|
186
|
+
|
|
187
|
+
/** Current preset ID (if using preset) */
|
|
188
|
+
readonly presetId?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// =========================================
|
|
192
|
+
// Theme Change Event
|
|
193
|
+
// =========================================
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Theme Change Event
|
|
197
|
+
*
|
|
198
|
+
* <p>Triggered when theme mode or configuration changes.</p>
|
|
199
|
+
*/
|
|
200
|
+
export interface ThemeChangeEvent {
|
|
201
|
+
/** New theme mode */
|
|
202
|
+
readonly mode: ThemeMode;
|
|
203
|
+
|
|
204
|
+
/** New resolved mode */
|
|
205
|
+
readonly resolvedMode: 'light' | 'dark';
|
|
206
|
+
|
|
207
|
+
/** Previous theme mode */
|
|
208
|
+
readonly previousMode: ThemeMode;
|
|
209
|
+
|
|
210
|
+
/** New theme configuration */
|
|
211
|
+
readonly config: ThemeConfig;
|
|
212
|
+
|
|
213
|
+
/** Change source */
|
|
214
|
+
readonly source: 'user' | 'system' | 'api';
|
|
215
|
+
|
|
216
|
+
/** Change timestamp */
|
|
217
|
+
readonly timestamp: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Theme Change Handler
|
|
222
|
+
*/
|
|
223
|
+
export type ThemeChangeHandler = (event: ThemeChangeEvent) => void;
|
|
224
|
+
|
|
225
|
+
// =========================================
|
|
226
|
+
// Theme Capability
|
|
227
|
+
// =========================================
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Theme Capability Type Identifier
|
|
231
|
+
*/
|
|
232
|
+
export const ThemeCapabilityType = Symbol.for('ThemeCapability');
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Theme Capability Contract
|
|
236
|
+
*
|
|
237
|
+
* <p>Provides theme management capability for plugins, including mode switching, color retrieval, theme configuration, etc.</p>
|
|
238
|
+
*
|
|
239
|
+
* <h3>Design Principles</h3>
|
|
240
|
+
* <ul>
|
|
241
|
+
* <li>Theme is uniformly controlled by Host</li>
|
|
242
|
+
* <li>Plugins can only read theme or request switching</li>
|
|
243
|
+
* <li>Theme variables are automatically applied via CSS variables</li>
|
|
244
|
+
* </ul>
|
|
245
|
+
*
|
|
246
|
+
* <h3>Usage Example</h3>
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const theme = context.getCapability<ThemeCapability>(ThemeCapabilityType);
|
|
249
|
+
*
|
|
250
|
+
* // Get current mode
|
|
251
|
+
* const mode = theme.getMode();
|
|
252
|
+
*
|
|
253
|
+
* // Switch mode
|
|
254
|
+
* theme.setMode('dark');
|
|
255
|
+
* theme.toggleMode();
|
|
256
|
+
*
|
|
257
|
+
* // Get color
|
|
258
|
+
* const primaryColor = theme.getColor('primary');
|
|
259
|
+
*
|
|
260
|
+
* // Listen to theme changes
|
|
261
|
+
* const unsubscribe = theme.onThemeChange((event) => {
|
|
262
|
+
* console.log(`Theme switched to ${event.resolvedMode}`);
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* @since 3.2.0
|
|
267
|
+
*/
|
|
268
|
+
export interface ThemeCapability {
|
|
269
|
+
// =========================================
|
|
270
|
+
// Mode Management
|
|
271
|
+
// =========================================
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Get Current Theme Mode
|
|
275
|
+
*
|
|
276
|
+
* @returns Theme mode
|
|
277
|
+
*/
|
|
278
|
+
getMode(): ThemeMode;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Get Actual Resolved Theme Mode
|
|
282
|
+
*
|
|
283
|
+
* <p>When mode='system', returns actual 'light' or 'dark'.</p>
|
|
284
|
+
*
|
|
285
|
+
* @returns Resolved mode
|
|
286
|
+
*/
|
|
287
|
+
getResolvedMode(): 'light' | 'dark';
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Set Theme Mode
|
|
291
|
+
*
|
|
292
|
+
* @param mode Target mode
|
|
293
|
+
*/
|
|
294
|
+
setMode(mode: ThemeMode): void;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Toggle Light/Dark Mode
|
|
298
|
+
*
|
|
299
|
+
* <p>Toggles between light and dark. If current is system, switches to the opposite of current system mode.</p>
|
|
300
|
+
*/
|
|
301
|
+
toggleMode(): void;
|
|
302
|
+
|
|
303
|
+
// =========================================
|
|
304
|
+
// Configuration Access
|
|
305
|
+
// =========================================
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Get Current Theme Configuration
|
|
309
|
+
*
|
|
310
|
+
* @returns Theme configuration object
|
|
311
|
+
*/
|
|
312
|
+
getConfig(): ThemeConfig;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Get Specified Color Value
|
|
316
|
+
*
|
|
317
|
+
* @param colorKey Color key name
|
|
318
|
+
* @returns Color value (CSS format)
|
|
319
|
+
*/
|
|
320
|
+
getColor(colorKey: keyof ThemeColors): string;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Get CSS Variable Value
|
|
324
|
+
*
|
|
325
|
+
* @param varName CSS variable name (without --)
|
|
326
|
+
* @returns Variable value
|
|
327
|
+
*/
|
|
328
|
+
getCssVar?(varName: string): string;
|
|
329
|
+
|
|
330
|
+
// =========================================
|
|
331
|
+
// State Access
|
|
332
|
+
// =========================================
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Get Complete Theme State
|
|
336
|
+
*
|
|
337
|
+
* @returns Theme state object
|
|
338
|
+
*/
|
|
339
|
+
getState?(): ThemeState;
|
|
340
|
+
|
|
341
|
+
// =========================================
|
|
342
|
+
// Preset Management
|
|
343
|
+
// =========================================
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Get Available Preset List
|
|
347
|
+
*
|
|
348
|
+
* @returns Array of presets
|
|
349
|
+
*/
|
|
350
|
+
getPresets?(): ThemePreset[];
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Apply Specified Preset
|
|
354
|
+
*
|
|
355
|
+
* @param presetId Preset ID
|
|
356
|
+
* @returns Whether successful
|
|
357
|
+
*/
|
|
358
|
+
applyPreset?(presetId: string): boolean;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Get Current Preset ID
|
|
362
|
+
*
|
|
363
|
+
* @returns Preset ID, returns undefined when not using preset
|
|
364
|
+
*/
|
|
365
|
+
getCurrentPresetId?(): string | undefined;
|
|
366
|
+
|
|
367
|
+
// =========================================
|
|
368
|
+
// Event Subscription
|
|
369
|
+
// =========================================
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Subscribe to Theme Change Events
|
|
373
|
+
*
|
|
374
|
+
* @param handler Event handler
|
|
375
|
+
* @returns Unsubscribe function
|
|
376
|
+
*/
|
|
377
|
+
onThemeChange?(handler: ThemeChangeHandler): Unsubscribe;
|
|
378
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Brix Platform Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @file UI Adapter Interface Definition
|
|
18
|
+
* @description Defines the core UIAdapter interface that all UI library implementations must follow
|
|
19
|
+
* @module @brix/runtime-sdk-api-web/types/ui/adapter
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*
|
|
22
|
+
* [Architectural Constraints - v3.0.4 Blueprint]
|
|
23
|
+
* ❌ Layout components (Sidebar, Header, Layout) are FORBIDDEN in UIAdapter
|
|
24
|
+
* ❌ Direct dependency on specific UI libraries (MUI, Ant Design) in contract layer is FORBIDDEN
|
|
25
|
+
* ✅ UIAdapter only defines atomic component contracts
|
|
26
|
+
* ✅ Shell layer assembles layout using atomic components from UIAdapter
|
|
27
|
+
* ✅ Host layer selects UI adapter implementation via configuration
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import type { FC } from 'react';
|
|
31
|
+
import type { ButtonProps } from './button';
|
|
32
|
+
import type { InputProps } from './input';
|
|
33
|
+
import type { SelectProps } from './select';
|
|
34
|
+
import type { CardProps } from './card';
|
|
35
|
+
import type { AvatarProps } from './avatar';
|
|
36
|
+
import type { BadgeProps } from './badge';
|
|
37
|
+
import type { TooltipProps } from './tooltip';
|
|
38
|
+
import type { MenuProps, MenuItemProps } from './menu';
|
|
39
|
+
import type { ModalProps } from './modal';
|
|
40
|
+
import type { MessageAPI } from './message';
|
|
41
|
+
import type { ThemeTokens, ThemeProviderProps } from './theme-tokens';
|
|
42
|
+
import type { IconProps } from './icon';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* UI Adapter Interface
|
|
46
|
+
*
|
|
47
|
+
* Defines the contract for UI library implementations. All UI adapters
|
|
48
|
+
* (MUI, Ant Design, Native CSS) must implement this interface.
|
|
49
|
+
*
|
|
50
|
+
* **Architectural Constraints (v3.0.4 Blueprint):**
|
|
51
|
+
* - This interface only contains ATOMIC components
|
|
52
|
+
* - Layout components (Sidebar, Header, Layout) are FORBIDDEN here
|
|
53
|
+
* - Shell layer assembles layouts using these atomic components
|
|
54
|
+
* - Host layer selects adapter via configuration
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // MUI Adapter Implementation
|
|
59
|
+
* export const muiAdapter: UIAdapter = {
|
|
60
|
+
* Button: MuiButton,
|
|
61
|
+
* Input: MuiInput,
|
|
62
|
+
* Select: MuiSelect,
|
|
63
|
+
* Card: MuiCard,
|
|
64
|
+
* Avatar: MuiAvatar,
|
|
65
|
+
* Badge: MuiBadge,
|
|
66
|
+
* Tooltip: MuiTooltip,
|
|
67
|
+
* Menu: MuiMenu,
|
|
68
|
+
* MenuItem: MuiMenuItem,
|
|
69
|
+
* Modal: MuiModal,
|
|
70
|
+
* message: createMuiMessageAPI(),
|
|
71
|
+
* ThemeProvider: MuiThemeProvider,
|
|
72
|
+
* getThemeTokens: () => MUI_THEME_TOKENS,
|
|
73
|
+
* Icon: MuiIcon,
|
|
74
|
+
* };
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export interface UIAdapter {
|
|
78
|
+
// ========================================
|
|
79
|
+
// Form Components
|
|
80
|
+
// ========================================
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Button Component
|
|
84
|
+
*
|
|
85
|
+
* Primary action trigger component.
|
|
86
|
+
*/
|
|
87
|
+
Button: FC<ButtonProps>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Input Component
|
|
91
|
+
*
|
|
92
|
+
* Text input field component.
|
|
93
|
+
*/
|
|
94
|
+
Input: FC<InputProps>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Select Component
|
|
98
|
+
*
|
|
99
|
+
* Dropdown selection component.
|
|
100
|
+
*/
|
|
101
|
+
Select: FC<SelectProps>;
|
|
102
|
+
|
|
103
|
+
// ========================================
|
|
104
|
+
// Display Components
|
|
105
|
+
// ========================================
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Card Component
|
|
109
|
+
*
|
|
110
|
+
* Content container component.
|
|
111
|
+
*/
|
|
112
|
+
Card: FC<CardProps>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Avatar Component
|
|
116
|
+
*
|
|
117
|
+
* User avatar display component.
|
|
118
|
+
*/
|
|
119
|
+
Avatar: FC<AvatarProps>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Badge Component
|
|
123
|
+
*
|
|
124
|
+
* Status indicator component.
|
|
125
|
+
*/
|
|
126
|
+
Badge: FC<BadgeProps>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Tooltip Component
|
|
130
|
+
*
|
|
131
|
+
* Hover information component.
|
|
132
|
+
*/
|
|
133
|
+
Tooltip: FC<TooltipProps>;
|
|
134
|
+
|
|
135
|
+
// ========================================
|
|
136
|
+
// Navigation Components (Atomic Level)
|
|
137
|
+
// NOTE: These are atomic components for Shell layer assembly.
|
|
138
|
+
// Sidebar and Header are assembled in Shell layer using these.
|
|
139
|
+
// ========================================
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Menu Component
|
|
143
|
+
*
|
|
144
|
+
* Navigation menu list component. Used by Shell layer to assemble Sidebar.
|
|
145
|
+
*/
|
|
146
|
+
Menu: FC<MenuProps>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Menu Item Component
|
|
150
|
+
*
|
|
151
|
+
* Single menu item for custom rendering scenarios.
|
|
152
|
+
*/
|
|
153
|
+
MenuItem: FC<MenuItemProps>;
|
|
154
|
+
|
|
155
|
+
// ========================================
|
|
156
|
+
// Feedback Components
|
|
157
|
+
// ========================================
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Modal Component
|
|
161
|
+
*
|
|
162
|
+
* Dialog/overlay component.
|
|
163
|
+
*/
|
|
164
|
+
Modal: FC<ModalProps>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Message API
|
|
168
|
+
*
|
|
169
|
+
* Imperative toast/snackbar API.
|
|
170
|
+
*/
|
|
171
|
+
message: MessageAPI;
|
|
172
|
+
|
|
173
|
+
// ========================================
|
|
174
|
+
// Theme System
|
|
175
|
+
// ========================================
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Theme Provider Component
|
|
179
|
+
*
|
|
180
|
+
* Wraps the application to provide theme context.
|
|
181
|
+
*/
|
|
182
|
+
ThemeProvider: FC<ThemeProviderProps>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Get Theme Tokens
|
|
186
|
+
*
|
|
187
|
+
* Returns the current theme tokens for use in styled components.
|
|
188
|
+
*/
|
|
189
|
+
getThemeTokens: () => ThemeTokens;
|
|
190
|
+
|
|
191
|
+
// ========================================
|
|
192
|
+
// Icon System
|
|
193
|
+
// ========================================
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Icon Component
|
|
197
|
+
*
|
|
198
|
+
* Name-based icon lookup component.
|
|
199
|
+
*/
|
|
200
|
+
Icon: FC<IconProps>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* UI Capability Type Symbol
|
|
205
|
+
*
|
|
206
|
+
* Symbol used to retrieve UIAdapter from RuntimeContext.
|
|
207
|
+
* Use with context.getCapability() to obtain the UI adapter instance.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // Get UI adapter from context
|
|
212
|
+
* const ui = context.getCapability<UIAdapter>(UICapabilityType);
|
|
213
|
+
* if (ui) {
|
|
214
|
+
* const { Button, Menu, Icon } = ui;
|
|
215
|
+
* // Use components...
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @see UIAdapter
|
|
220
|
+
* @see RuntimeContext
|
|
221
|
+
*/
|
|
222
|
+
export const UICapabilityType = Symbol.for('UICapability');
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Brix Platform Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @file Avatar Component Type Definitions
|
|
18
|
+
* @description Defines types for the Avatar component in the UI adapter system
|
|
19
|
+
* @module @brix/runtime-sdk-api-web/types/ui/avatar
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { ReactNode, CSSProperties } from 'react';
|
|
24
|
+
import type { ComponentSize } from './common';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Avatar Shape Variants
|
|
28
|
+
*/
|
|
29
|
+
export type AvatarShape = 'circle' | 'square' | 'rounded';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Avatar Component Props
|
|
33
|
+
*
|
|
34
|
+
* User avatar or icon display component with various presentation options.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Avatar
|
|
39
|
+
* src={user.avatarUrl}
|
|
40
|
+
* alt={user.name}
|
|
41
|
+
* size="large"
|
|
42
|
+
* fallback={user.initials}
|
|
43
|
+
* />
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export interface AvatarProps {
|
|
47
|
+
/**
|
|
48
|
+
* Image Source URL
|
|
49
|
+
*
|
|
50
|
+
* URL of the avatar image.
|
|
51
|
+
*/
|
|
52
|
+
src?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Alt Text
|
|
56
|
+
*
|
|
57
|
+
* Alternative text for accessibility.
|
|
58
|
+
*/
|
|
59
|
+
alt?: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Fallback Content
|
|
63
|
+
*
|
|
64
|
+
* Content to display when image fails to load (e.g., initials).
|
|
65
|
+
*/
|
|
66
|
+
fallback?: ReactNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Avatar Size
|
|
70
|
+
*
|
|
71
|
+
* Predefined size or custom pixel value.
|
|
72
|
+
* @default 'medium'
|
|
73
|
+
*/
|
|
74
|
+
size?: ComponentSize | number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Avatar Shape
|
|
78
|
+
*
|
|
79
|
+
* @default 'circle'
|
|
80
|
+
*/
|
|
81
|
+
shape?: AvatarShape;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Background Color
|
|
85
|
+
*
|
|
86
|
+
* Custom background color (CSS value).
|
|
87
|
+
*/
|
|
88
|
+
backgroundColor?: string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Icon Name
|
|
92
|
+
*
|
|
93
|
+
* Icon to display when no image or fallback is provided.
|
|
94
|
+
*/
|
|
95
|
+
icon?: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Custom Inline Styles
|
|
99
|
+
*/
|
|
100
|
+
style?: CSSProperties;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Custom CSS Class Name
|
|
104
|
+
*/
|
|
105
|
+
className?: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Avatar Content
|
|
109
|
+
*
|
|
110
|
+
* Direct content to display (e.g., text initials).
|
|
111
|
+
*/
|
|
112
|
+
children?: ReactNode;
|
|
113
|
+
}
|