valtech-components 2.0.325 → 2.0.326
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/esm2022/lib/services/lang-provider/lang-provider.service.mjs +133 -2
- package/esm2022/public-api.mjs +1 -2
- package/fesm2022/valtech-components.mjs +132 -182
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/services/lang-provider/lang-provider.service.d.ts +58 -1
- package/package.json +1 -1
- package/public-api.d.ts +0 -1
- package/esm2022/lib/services/content-loader.service.mjs +0 -185
- package/lib/services/content-loader.service.d.ts +0 -98
|
@@ -991,6 +991,137 @@ class LangService {
|
|
|
991
991
|
const targetContent = classContent.Content[lang] || {};
|
|
992
992
|
return Object.keys(referenceContent).filter(key => !targetContent[key] || typeof targetContent[key] !== 'string');
|
|
993
993
|
}
|
|
994
|
+
/**
|
|
995
|
+
* Register or update content for a component dynamically.
|
|
996
|
+
* This allows registering content at runtime without APP_INITIALIZER.
|
|
997
|
+
*
|
|
998
|
+
* @param className - The component class name
|
|
999
|
+
* @param content - The multilingual content object
|
|
1000
|
+
* @param merge - Whether to merge with existing content (default: true)
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* ```typescript
|
|
1004
|
+
* this.langService.registerContent('MyComponent', {
|
|
1005
|
+
* [LANGUAGES.ES]: { title: 'Título', description: 'Descripción' },
|
|
1006
|
+
* [LANGUAGES.EN]: { title: 'Title', description: 'Description' }
|
|
1007
|
+
* });
|
|
1008
|
+
* ```
|
|
1009
|
+
*/
|
|
1010
|
+
registerContent(className, content, merge = true) {
|
|
1011
|
+
if (!className) {
|
|
1012
|
+
console.error('LangService: className is required for registerContent');
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
if (!content || typeof content !== 'object') {
|
|
1016
|
+
console.error('LangService: Invalid content provided for registerContent');
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
console.log(`LangService: Registering content for "${className}"`, {
|
|
1020
|
+
merge,
|
|
1021
|
+
languages: Object.keys(content),
|
|
1022
|
+
});
|
|
1023
|
+
// Initialize component content if it doesn't exist
|
|
1024
|
+
if (!this.content[className]) {
|
|
1025
|
+
this.content[className] = new TextContent({});
|
|
1026
|
+
}
|
|
1027
|
+
// Merge or replace content for each language
|
|
1028
|
+
Object.entries(content).forEach(([lang, langContent]) => {
|
|
1029
|
+
if (!langContent || typeof langContent !== 'object') {
|
|
1030
|
+
console.warn(`LangService: Invalid content for language "${lang}" in "${className}"`);
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
if (!this.content[className].Content[lang]) {
|
|
1034
|
+
this.content[className].Content[lang] = {};
|
|
1035
|
+
}
|
|
1036
|
+
if (merge) {
|
|
1037
|
+
this.content[className].Content[lang] = {
|
|
1038
|
+
...this.content[className].Content[lang],
|
|
1039
|
+
...langContent,
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
else {
|
|
1043
|
+
this.content[className].Content[lang] = { ...langContent };
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
// Update available languages
|
|
1047
|
+
this.detectAvailableLanguages();
|
|
1048
|
+
console.log(`LangService: Content registered successfully for "${className}"`);
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Update multiple content registrations at once.
|
|
1052
|
+
*
|
|
1053
|
+
* @param contentMap - Map of className to content
|
|
1054
|
+
* @param merge - Whether to merge with existing content (default: true)
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* ```typescript
|
|
1058
|
+
* this.langService.registerMultipleContent({
|
|
1059
|
+
* 'Component1': { [LANGUAGES.ES]: { key1: 'valor1' } },
|
|
1060
|
+
* 'Component2': { [LANGUAGES.EN]: { key2: 'value2' } }
|
|
1061
|
+
* });
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
registerMultipleContent(contentMap, merge = true) {
|
|
1065
|
+
if (!contentMap || typeof contentMap !== 'object') {
|
|
1066
|
+
console.error('LangService: Invalid contentMap provided for registerMultipleContent');
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
console.log('LangService: Registering multiple content entries', {
|
|
1070
|
+
classes: Object.keys(contentMap),
|
|
1071
|
+
merge,
|
|
1072
|
+
});
|
|
1073
|
+
Object.entries(contentMap).forEach(([className, content]) => {
|
|
1074
|
+
this.registerContent(className, content, merge);
|
|
1075
|
+
});
|
|
1076
|
+
console.log('LangService: Multiple content registration completed');
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Remove content for a specific component.
|
|
1080
|
+
*
|
|
1081
|
+
* @param className - The component class name to remove
|
|
1082
|
+
*/
|
|
1083
|
+
removeContent(className) {
|
|
1084
|
+
if (!className) {
|
|
1085
|
+
console.error('LangService: className is required for removeContent');
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
if (this.content[className]) {
|
|
1089
|
+
delete this.content[className];
|
|
1090
|
+
this.detectAvailableLanguages();
|
|
1091
|
+
console.log(`LangService: Content removed for "${className}"`);
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
console.warn(`LangService: No content found for "${className}" to remove`);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Get a list of all registered component classes.
|
|
1099
|
+
*
|
|
1100
|
+
* @returns Array of registered class names
|
|
1101
|
+
*/
|
|
1102
|
+
getRegisteredClasses() {
|
|
1103
|
+
return Object.keys(this.content);
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Get the complete content configuration (for debugging purposes).
|
|
1107
|
+
* Returns a deep copy to prevent accidental mutations.
|
|
1108
|
+
*
|
|
1109
|
+
* @returns Complete content configuration
|
|
1110
|
+
*/
|
|
1111
|
+
getContentConfiguration() {
|
|
1112
|
+
return JSON.parse(JSON.stringify(this.content));
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Clear all content and reset to initial state.
|
|
1116
|
+
* Useful for testing or complete reinitialization.
|
|
1117
|
+
*/
|
|
1118
|
+
clearAllContent() {
|
|
1119
|
+
console.log('LangService: Clearing all content');
|
|
1120
|
+
this.content = {};
|
|
1121
|
+
this.availableLanguages = [LANGUAGES.ES]; // Reset to default
|
|
1122
|
+
this.warnedMissingLanguages.clear();
|
|
1123
|
+
console.log('LangService: All content cleared');
|
|
1124
|
+
}
|
|
994
1125
|
// Legacy getters/setters for backward compatibility
|
|
995
1126
|
get Lang() {
|
|
996
1127
|
return this.currentLang;
|
|
@@ -8109,187 +8240,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
8109
8240
|
type: Output
|
|
8110
8241
|
}] } });
|
|
8111
8242
|
|
|
8112
|
-
/**
|
|
8113
|
-
* ContentLoader Service - Dynamic content loading system.
|
|
8114
|
-
*
|
|
8115
|
-
* REFACTORED: Now uses ValtechConfigService properly instead of hacking LangService.
|
|
8116
|
-
* This provides a clean, maintainable way to register content dynamically.
|
|
8117
|
-
*
|
|
8118
|
-
* @example Basic usage:
|
|
8119
|
-
* ```typescript
|
|
8120
|
-
* // user-page.content.ts
|
|
8121
|
-
* export const UserPageContent = {
|
|
8122
|
-
* es: { title: 'Mi Página de Usuario', welcome: 'Bienvenido {{name}}' },
|
|
8123
|
-
* en: { title: 'My User Page', welcome: 'Welcome {{name}}' }
|
|
8124
|
-
* };
|
|
8125
|
-
*
|
|
8126
|
-
* // In component
|
|
8127
|
-
* import { UserPageContent } from './user-page.content';
|
|
8128
|
-
* registerContent('UserPage', UserPageContent);
|
|
8129
|
-
* ```
|
|
8130
|
-
*/
|
|
8131
|
-
class ContentLoaderService {
|
|
8132
|
-
constructor() {
|
|
8133
|
-
this.valtechConfig = inject(ValtechConfigService);
|
|
8134
|
-
this.registeredContent = new Map();
|
|
8135
|
-
}
|
|
8136
|
-
/**
|
|
8137
|
-
* Register content for a specific component/page class.
|
|
8138
|
-
* ✅ CLEAN: Uses proper ValtechConfigService API instead of hacking LangService
|
|
8139
|
-
*/
|
|
8140
|
-
registerContent(className, content) {
|
|
8141
|
-
// Store locally for tracking
|
|
8142
|
-
this.registeredContent.set(className, content);
|
|
8143
|
-
// Update the configuration properly
|
|
8144
|
-
this.addContentToProvider(className, content);
|
|
8145
|
-
console.log(`✅ ContentLoader: Registered content for "${className}"`);
|
|
8146
|
-
}
|
|
8147
|
-
/**
|
|
8148
|
-
* Register multiple content modules at once.
|
|
8149
|
-
*/
|
|
8150
|
-
loadContent(contentModules) {
|
|
8151
|
-
console.log(`🔄 ContentLoader: Loading ${contentModules.length} content modules...`);
|
|
8152
|
-
contentModules.forEach(module => {
|
|
8153
|
-
this.registerContent(module.className, module.content);
|
|
8154
|
-
});
|
|
8155
|
-
console.log('✅ ContentLoader: All content modules loaded successfully');
|
|
8156
|
-
}
|
|
8157
|
-
/**
|
|
8158
|
-
* Check if content is registered for a class.
|
|
8159
|
-
*/
|
|
8160
|
-
hasContentFor(className) {
|
|
8161
|
-
return this.registeredContent.has(className);
|
|
8162
|
-
}
|
|
8163
|
-
/**
|
|
8164
|
-
* Get all registered class names.
|
|
8165
|
-
*/
|
|
8166
|
-
getRegisteredClasses() {
|
|
8167
|
-
return Array.from(this.registeredContent.keys());
|
|
8168
|
-
}
|
|
8169
|
-
/**
|
|
8170
|
-
* Get registered content for a specific class.
|
|
8171
|
-
*/
|
|
8172
|
-
getContentFor(className) {
|
|
8173
|
-
return this.registeredContent.get(className);
|
|
8174
|
-
}
|
|
8175
|
-
/**
|
|
8176
|
-
* Remove content registration for a class.
|
|
8177
|
-
*/
|
|
8178
|
-
unregisterContent(className) {
|
|
8179
|
-
const existed = this.registeredContent.has(className);
|
|
8180
|
-
this.registeredContent.delete(className);
|
|
8181
|
-
// Also remove from the provider
|
|
8182
|
-
if (existed && this.valtechConfig.content) {
|
|
8183
|
-
const updatedContent = { ...this.valtechConfig.content };
|
|
8184
|
-
delete updatedContent[className];
|
|
8185
|
-
this.valtechConfig.content = updatedContent;
|
|
8186
|
-
console.log(`🗑️ ContentLoader: Unregistered content for "${className}"`);
|
|
8187
|
-
}
|
|
8188
|
-
return existed;
|
|
8189
|
-
}
|
|
8190
|
-
/**
|
|
8191
|
-
* Clear all registered content.
|
|
8192
|
-
*/
|
|
8193
|
-
clearAllContent() {
|
|
8194
|
-
this.registeredContent.clear();
|
|
8195
|
-
console.log('🧹 ContentLoader: Cleared all registered content');
|
|
8196
|
-
}
|
|
8197
|
-
/**
|
|
8198
|
-
* Get current content provider state.
|
|
8199
|
-
* Useful for debugging.
|
|
8200
|
-
*/
|
|
8201
|
-
getContentProvider() {
|
|
8202
|
-
return this.valtechConfig.content;
|
|
8203
|
-
}
|
|
8204
|
-
/**
|
|
8205
|
-
* ✅ CLEAN: Add content to provider using proper API
|
|
8206
|
-
* @private
|
|
8207
|
-
*/
|
|
8208
|
-
addContentToProvider(className, content) {
|
|
8209
|
-
try {
|
|
8210
|
-
// Get current content provider
|
|
8211
|
-
const currentContent = this.valtechConfig.content || {};
|
|
8212
|
-
// Create TextContent instance
|
|
8213
|
-
const textContent = new TextContent(content);
|
|
8214
|
-
// Update the content provider properly
|
|
8215
|
-
const updatedContent = {
|
|
8216
|
-
...currentContent,
|
|
8217
|
-
[className]: textContent,
|
|
8218
|
-
};
|
|
8219
|
-
// Set the updated content - this is the clean way
|
|
8220
|
-
this.valtechConfig.content = updatedContent;
|
|
8221
|
-
console.log(`📝 ContentLoader: Added "${className}" to content provider`);
|
|
8222
|
-
}
|
|
8223
|
-
catch (error) {
|
|
8224
|
-
console.error(`❌ ContentLoader: Error adding content for "${className}":`, error);
|
|
8225
|
-
}
|
|
8226
|
-
}
|
|
8227
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentLoaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
8228
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentLoaderService, providedIn: 'root' }); }
|
|
8229
|
-
}
|
|
8230
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentLoaderService, decorators: [{
|
|
8231
|
-
type: Injectable,
|
|
8232
|
-
args: [{
|
|
8233
|
-
providedIn: 'root',
|
|
8234
|
-
}]
|
|
8235
|
-
}] });
|
|
8236
|
-
/**
|
|
8237
|
-
* Helper function to create a content module.
|
|
8238
|
-
*/
|
|
8239
|
-
function createContentModule(className, content) {
|
|
8240
|
-
return { className, content };
|
|
8241
|
-
}
|
|
8242
|
-
/**
|
|
8243
|
-
* ✅ CLEAN: Global registry using proper array instead of globalThis hack
|
|
8244
|
-
*/
|
|
8245
|
-
const globalContentRegistry = [];
|
|
8246
|
-
/**
|
|
8247
|
-
* Simple function to register content directly.
|
|
8248
|
-
* ✅ IMPROVED: Cleaner global registry management
|
|
8249
|
-
*/
|
|
8250
|
-
function registerContent(className, content) {
|
|
8251
|
-
// Add to global registry
|
|
8252
|
-
globalContentRegistry.push({ className, content });
|
|
8253
|
-
console.log(`📝 registerContent: Queued "${className}" for registration`);
|
|
8254
|
-
}
|
|
8255
|
-
/**
|
|
8256
|
-
* Load all content from the global registry.
|
|
8257
|
-
* ✅ IMPROVED: Better error handling and logging
|
|
8258
|
-
*/
|
|
8259
|
-
function loadRegisteredContent(contentLoader) {
|
|
8260
|
-
if (globalContentRegistry.length === 0) {
|
|
8261
|
-
console.log('ℹ️ ContentLoader: No content registered to load');
|
|
8262
|
-
return;
|
|
8263
|
-
}
|
|
8264
|
-
console.log(`🚀 ContentLoader: Loading ${globalContentRegistry.length} registered content modules...`);
|
|
8265
|
-
try {
|
|
8266
|
-
// Load all content
|
|
8267
|
-
contentLoader.loadContent([...globalContentRegistry]);
|
|
8268
|
-
// Clear the registry after loading
|
|
8269
|
-
globalContentRegistry.length = 0;
|
|
8270
|
-
console.log('🎉 ContentLoader: All registered content loaded and registry cleared');
|
|
8271
|
-
}
|
|
8272
|
-
catch (error) {
|
|
8273
|
-
console.error('❌ ContentLoader: Error loading registered content:', error);
|
|
8274
|
-
}
|
|
8275
|
-
}
|
|
8276
|
-
/**
|
|
8277
|
-
* ✅ NEW: Debugging helper
|
|
8278
|
-
* Get current global registry state
|
|
8279
|
-
*/
|
|
8280
|
-
function getRegisteredContentQueue() {
|
|
8281
|
-
return [...globalContentRegistry];
|
|
8282
|
-
}
|
|
8283
|
-
/**
|
|
8284
|
-
* ✅ NEW: Debugging helper
|
|
8285
|
-
* Clear the global registry without loading
|
|
8286
|
-
*/
|
|
8287
|
-
function clearRegisteredContentQueue() {
|
|
8288
|
-
const count = globalContentRegistry.length;
|
|
8289
|
-
globalContentRegistry.length = 0;
|
|
8290
|
-
console.log(`🧹 ContentLoader: Cleared ${count} items from registration queue`);
|
|
8291
|
-
}
|
|
8292
|
-
|
|
8293
8243
|
const text = {
|
|
8294
8244
|
es: {
|
|
8295
8245
|
spanish: 'Español',
|
|
@@ -8464,5 +8414,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
8464
8414
|
* Generated bundle index. Do not edit.
|
|
8465
8415
|
*/
|
|
8466
8416
|
|
|
8467
|
-
export { ARTICLE_SPACING, ActionType, AlertBoxComponent, ArticleBuilder, ArticleComponent, AvatarComponent, BannerComponent, BaseDefault, BoxComponent, ButtonComponent, ButtonGroupComponent, CardComponent, CardSection, CardType, CheckInputComponent, ClearDefault, ClearDefaultBlock, ClearDefaultFull, ClearDefaultRound, ClearDefaultRoundBlock, ClearDefaultRoundFull, CommentInputComponent, ComponentContentHelper, ComponentStates, ContentLoaderComponent,
|
|
8417
|
+
export { ARTICLE_SPACING, ActionType, AlertBoxComponent, ArticleBuilder, ArticleComponent, AvatarComponent, BannerComponent, BaseDefault, BoxComponent, ButtonComponent, ButtonGroupComponent, CardComponent, CardSection, CardType, CheckInputComponent, ClearDefault, ClearDefaultBlock, ClearDefaultFull, ClearDefaultRound, ClearDefaultRoundBlock, ClearDefaultRoundFull, CommentInputComponent, ComponentContentHelper, ComponentStates, ContentLoaderComponent, ContentService, DateInputComponent, DisplayComponent, DividerComponent, DownloadService, EmailInputComponent, ExpandableTextComponent, FileInputComponent, FooterComponent, FormComponent, FormFooterComponent, GlobalContent, HeaderComponent, HintComponent, HourInputComponent, HrefComponent, Icon, IconComponent, IconService, ImageComponent, InAppBrowserService, InputType, ItemListComponent, LANGUAGES, LangService, LanguageSelectorComponent, LayeredCardComponent, LayoutComponent, LinkComponent, LinkProcessorService, LinksCakeComponent, ListContentHelper, LocalStorageService, MOTION, NavigationService, NoContentComponent, NotesBoxComponent, NumberInputComponent, OutlineDefault, OutlineDefaultBlock, OutlineDefaultFull, OutlineDefaultRound, OutlineDefaultRoundBlock, OutlineDefaultRoundFull, PasswordInputComponent, PinInputComponent, PopoverSelectorComponent, PrimarySolidBlockButton, PrimarySolidBlockHrefButton, PrimarySolidBlockIconButton, PrimarySolidBlockIconHrefButton, PrimarySolidDefaultRoundButton, PrimarySolidDefaultRoundHrefButton, PrimarySolidDefaultRoundIconButton, PrimarySolidDefaultRoundIconHrefButton, PrimarySolidFullButton, PrimarySolidFullHrefButton, PrimarySolidFullIconButton, PrimarySolidFullIconHrefButton, PrimarySolidLargeRoundButton, PrimarySolidLargeRoundHrefButton, PrimarySolidLargeRoundIconButton, PrimarySolidLargeRoundIconHrefButton, PrimarySolidSmallRoundButton, PrimarySolidSmallRoundHrefButton, PrimarySolidSmallRoundIconButton, PrimarySolidSmallRoundIconHrefButton, ProcessLinksPipe, ProgressBarComponent, ProgressStatusComponent, PrompterComponent, RadioInputComponent, SearchSelectorComponent, SearchbarComponent, SecondarySolidBlockButton, SecondarySolidBlockHrefButton, SecondarySolidBlockIconButton, SecondarySolidBlockIconHrefButton, SecondarySolidDefaultRoundButton, SecondarySolidDefaultRoundHrefButton, SecondarySolidDefaultRoundIconButton, SecondarySolidDefaultRoundIconHrefButton, SecondarySolidFullButton, SecondarySolidFullHrefButton, SecondarySolidFullIconButton, SecondarySolidFullIconHrefButton, SecondarySolidLargeRoundButton, SecondarySolidLargeRoundHrefButton, SecondarySolidLargeRoundIconButton, SecondarySolidLargeRoundIconHrefButton, SecondarySolidSmallRoundButton, SecondarySolidSmallRoundHrefButton, SecondarySolidSmallRoundIconButton, SecondarySolidSmallRoundIconHrefButton, SelectSearchComponent, SimpleComponent, SolidBlockButton, SolidDefault, SolidDefaultBlock, SolidDefaultButton, SolidDefaultFull, SolidDefaultRound, SolidDefaultRoundBlock, SolidDefaultRoundButton, SolidDefaultRoundFull, SolidFullButton, SolidLargeButton, SolidLargeRoundButton, SolidSmallButton, SolidSmallRoundButton, TextComponent, TextContent, TextInputComponent, ThemeOption, ThemeService, TitleBlockComponent, TitleComponent, ToastService, ToolbarActionType, ToolbarComponent, ValtechConfigService, WizardComponent, WizardFooterComponent, applyDefaultValueToControl, content, createButtonProps, createComponentContentHelper, createContentHelper, createDisplayProps, createReactiveProps, createTextProps, createTitleProps, fromContent, fromContentWithInterpolation, fromMultipleContent, globalContentData, goToTop, interpolateContent, isAtEnd, maxLength, replaceSpecialChars, resolveColor, resolveInputDefaultValue, shouldUseReactiveContent };
|
|
8468
8418
|
//# sourceMappingURL=valtech-components.mjs.map
|