valtech-components 2.0.276 → 2.0.278
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/README.md +149 -6
- package/esm2022/lib/components/_examples/global-content-example-content.mjs +23 -0
- package/esm2022/lib/components/_examples/global-content-example.component.mjs +504 -0
- package/esm2022/lib/components/_examples/reactive-content-example-content.mjs +43 -0
- package/esm2022/lib/components/_examples/reactive-content-example.component.mjs +347 -0
- package/esm2022/lib/components/atoms/text/text.component.mjs +143 -15
- package/esm2022/lib/components/atoms/text/types.mjs +1 -1
- package/esm2022/lib/services/content.service.mjs +327 -0
- package/esm2022/lib/services/icons.service.mjs +3 -2
- package/esm2022/lib/services/lang-provider/content.mjs +136 -1
- package/esm2022/lib/services/lang-provider/lang-provider.service.mjs +118 -8
- package/esm2022/lib/shared/utils/content.mjs +186 -0
- package/esm2022/public-api.mjs +11 -5
- package/fesm2022/valtech-components.mjs +2938 -1359
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/_examples/global-content-example-content.d.ts +9 -0
- package/lib/components/_examples/global-content-example.component.d.ts +73 -0
- package/lib/components/_examples/reactive-content-example-content.d.ts +32 -0
- package/lib/components/_examples/reactive-content-example.component.d.ts +47 -0
- package/lib/components/atoms/text/text.component.d.ts +57 -8
- package/lib/components/atoms/text/types.d.ts +26 -5
- package/lib/services/content.service.d.ts +296 -0
- package/lib/services/lang-provider/lang-provider.service.d.ts +87 -7
- package/lib/shared/utils/content.d.ts +199 -0
- package/package.json +1 -1
- package/public-api.d.ts +9 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<img style="margin-bottom: 20px;" src="https://myvaltech.s3.us-east-2.amazonaws.com/logo-terminal-rounded.png" width="60px" />
|
|
2
2
|
|
|
3
|
-
# Valtech Components
|
|
3
|
+
# [Valtech Components](https://ui.myvaltech.com/)
|
|
4
4
|
|
|
5
|
-
Valtech Components is a reusable component library for building modern web and hybrid applications with Angular, Ionic, and Capacitor. It provides a set of UI components, utilities, and styles to accelerate and standardize the development of scalable applications.
|
|
5
|
+
[Valtech Components](https://ui.myvaltech.com/) is a reusable component library for building modern web and hybrid applications with Angular, Ionic, and Capacitor. It provides a set of UI components, utilities, and styles to accelerate and standardize the development of scalable applications.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -34,13 +34,13 @@ npm install valtech-components
|
|
|
34
34
|
Import the desired standalone components in your Angular modules or components:
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
|
-
import {
|
|
37
|
+
import { TextComponent } from 'valtech-components';
|
|
38
38
|
|
|
39
39
|
@Component({
|
|
40
40
|
selector: 'your-component',
|
|
41
41
|
standalone: true,
|
|
42
42
|
imports: [
|
|
43
|
-
|
|
43
|
+
TextComponent,
|
|
44
44
|
],
|
|
45
45
|
template: `
|
|
46
46
|
<val-text
|
|
@@ -57,7 +57,141 @@ export class YourComponent {
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
## 🌍 Reactive Internationalization (i18n)
|
|
61
|
+
|
|
62
|
+
The library includes a powerful reactive internationalization system with **ContentService** that automatically updates content when the language changes. It supports both **global content** (reusable across components) and **component-specific content**.
|
|
63
|
+
|
|
64
|
+
### Key Features
|
|
65
|
+
|
|
66
|
+
- **Global Content**: Reusable texts like buttons ("Save", "Cancel"), states ("Loading", "Error"), and confirmations
|
|
67
|
+
- **Component-Specific Content**: Custom texts for individual components
|
|
68
|
+
- **Reactive Updates**: Text automatically updates when language changes
|
|
69
|
+
- **Interpolation Support**: Dynamic values in text strings
|
|
70
|
+
- **Type-Safe**: Full TypeScript support with autocompletion
|
|
71
|
+
- **Simple API**: Clean, injectable service without complex setup
|
|
72
|
+
|
|
73
|
+
### Available Global Content
|
|
74
|
+
|
|
75
|
+
- **Buttons**: `ok`, `cancel`, `save`, `delete`, `edit`, `close`, `back`, `next`, `previous`
|
|
76
|
+
- **Actions**: `add`, `remove`, `search`, `filter`, `sort`, `refresh`
|
|
77
|
+
- **States**: `loading`, `error`, `success`, `warning`, `info`, `noData`
|
|
78
|
+
- **Forms**: `required`, `optional`, `searchPlaceholder`
|
|
79
|
+
- **Confirmations**: `areYouSure`, `deleteConfirmation`, `unsavedChanges`
|
|
80
|
+
|
|
81
|
+
### Basic Setup
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// main.ts
|
|
85
|
+
import { TextContent, ValtechConfig, ValtechConfigService } from 'valtech-components';
|
|
86
|
+
|
|
87
|
+
const appContent = new TextContent({
|
|
88
|
+
es: {
|
|
89
|
+
welcome: 'Bienvenido',
|
|
90
|
+
description: 'Esta es la descripción'
|
|
91
|
+
},
|
|
92
|
+
en: {
|
|
93
|
+
welcome: 'Welcome',
|
|
94
|
+
description: 'This is the description'
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const valtechConfig: ValtechConfig = {
|
|
99
|
+
content: { AppComponent: appContent }
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
bootstrapApplication(AppComponent, {
|
|
103
|
+
providers: [
|
|
104
|
+
{ provide: ValtechConfigService, useValue: valtechConfig },
|
|
105
|
+
// ... other providers
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Using ContentService (Recommended)
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// component.ts
|
|
114
|
+
import { inject } from '@angular/core';
|
|
115
|
+
import { ContentService } from 'valtech-components';
|
|
116
|
+
|
|
117
|
+
@Component({
|
|
118
|
+
template: `
|
|
119
|
+
<!-- Global content (no className needed) -->
|
|
120
|
+
<button>{{ saveButton$ | async }}</button>
|
|
121
|
+
<button>{{ cancelButton$ | async }}</button>
|
|
122
|
+
|
|
123
|
+
<!-- Global content with val-text -->
|
|
124
|
+
<val-text [props]="{
|
|
125
|
+
contentKey: 'ok',
|
|
126
|
+
color: 'primary',
|
|
127
|
+
size: 'large',
|
|
128
|
+
bold: true
|
|
129
|
+
}"></val-text>
|
|
130
|
+
|
|
131
|
+
<!-- Component-specific content with val-text -->
|
|
132
|
+
<val-text [props]="{
|
|
133
|
+
contentKey: 'welcome',
|
|
134
|
+
contentClass: 'AppComponent',
|
|
135
|
+
color: 'secondary',
|
|
136
|
+
size: 'medium',
|
|
137
|
+
bold: false
|
|
138
|
+
}"></val-text>
|
|
139
|
+
|
|
140
|
+
<!-- Direct observable binding -->
|
|
141
|
+
<h2>{{ title$ | async }}</h2>
|
|
142
|
+
`
|
|
143
|
+
})
|
|
144
|
+
export class MyComponent {
|
|
145
|
+
content = inject(ContentService);
|
|
146
|
+
componentContent = this.content.forComponent('AppComponent');
|
|
147
|
+
|
|
148
|
+
// Global content (automatically searches in global namespace)
|
|
149
|
+
saveButton$ = this.content.fromContent({ key: 'save' });
|
|
150
|
+
cancelButton$ = this.content.fromContent({ key: 'cancel' });
|
|
151
|
+
|
|
152
|
+
// Component-specific content
|
|
153
|
+
title$ = this.componentContent.get('welcome');
|
|
154
|
+
|
|
155
|
+
// Switch language
|
|
156
|
+
changeLanguage() {
|
|
157
|
+
this.content.setLang(this.content.currentLang === 'es' ? 'en' : 'es');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
constructor() {}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Content with Variables
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// Component with interpolation
|
|
168
|
+
export class UserComponent {
|
|
169
|
+
content = inject(ContentService);
|
|
170
|
+
componentContent = this.content.forComponent('UserComponent');
|
|
171
|
+
|
|
172
|
+
greeting$ = this.componentContent.getWithInterpolation('personalizedGreeting', {
|
|
173
|
+
name: 'John',
|
|
174
|
+
count: 5
|
|
175
|
+
});
|
|
176
|
+
// Results in: "Hello John, you have 5 messages"
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
See `REACTIVE_CONTENT_GUIDE.md` for complete documentation and migration guide.
|
|
181
|
+
|
|
182
|
+
## 📖 Documentation & Guides
|
|
183
|
+
|
|
184
|
+
### Content Management Guides
|
|
185
|
+
|
|
186
|
+
- **[ContentService Guide](./CONTENT_SERVICE_GUIDE.md)** - Complete API reference with examples and migration guide from old LangService approach
|
|
187
|
+
- **[Global Content Guide](./GLOBAL_CONTENT_GUIDE.md)** - How to use reusable global content for buttons, states, and confirmations
|
|
188
|
+
- **[Reactive Content Guide](./REACTIVE_CONTENT_GUIDE.md)** - Advanced patterns for reactive content management
|
|
189
|
+
|
|
190
|
+
### Component Implementation Guides
|
|
191
|
+
|
|
192
|
+
- **[Implementation Example](./IMPLEMENTATION_EXAMPLE.md)** - Step-by-step component implementation guide
|
|
193
|
+
|
|
194
|
+
The documentation includes practical examples, best practices, and migration guides to help you get the most out of the Valtech Tools component library.
|
|
61
195
|
|
|
62
196
|
## Project Structure
|
|
63
197
|
|
|
@@ -65,10 +199,19 @@ See the `src/lib/components/` directory for all available components and their p
|
|
|
65
199
|
- `src/lib/components/molecules/` – Compound components (e.g., input groups, cards)
|
|
66
200
|
- `src/lib/components/organisms/` – Complex components (e.g., forms, toolbars)
|
|
67
201
|
- `src/lib/components/templates/` – Page templates and layouts
|
|
202
|
+
- `src/lib/components/_examples/` – Example components demonstrating features
|
|
68
203
|
- `src/lib/components/styles/` – Shared SCSS variables, mixins, and utilities
|
|
69
|
-
- `src/lib/services/` – Utility and helper services (e.g., theme, navigation)
|
|
204
|
+
- `src/lib/services/` – Utility and helper services (e.g., theme, navigation, i18n)
|
|
70
205
|
- `src/lib/shared/` – Shared constants and utility functions
|
|
71
206
|
|
|
207
|
+
## 📚 Examples
|
|
208
|
+
|
|
209
|
+
The library includes example components that demonstrate best practices:
|
|
210
|
+
|
|
211
|
+
- `ReactiveContentExampleComponent` - Demonstrates the reactive content system with component-specific content
|
|
212
|
+
- `GlobalContentExampleComponent` - Comprehensive demonstration of global and mixed content usage
|
|
213
|
+
- Check the `_examples/` directory for more implementation examples
|
|
214
|
+
|
|
72
215
|
## License
|
|
73
216
|
|
|
74
217
|
[MIT](https://opensource.org/license/mit)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content configuration for the Global Content Example component.
|
|
3
|
+
*
|
|
4
|
+
* This demonstrates component-specific content that works alongside
|
|
5
|
+
* global content to create a comprehensive content management system.
|
|
6
|
+
*/
|
|
7
|
+
import { TextContent } from '../../services/lang-provider/types';
|
|
8
|
+
const globalContentExampleData = {
|
|
9
|
+
title: {
|
|
10
|
+
es: 'Ejemplo de Contenido Global',
|
|
11
|
+
en: 'Global Content Example',
|
|
12
|
+
},
|
|
13
|
+
languageLabel: {
|
|
14
|
+
es: 'Idioma:',
|
|
15
|
+
en: 'Language:',
|
|
16
|
+
},
|
|
17
|
+
description: {
|
|
18
|
+
es: 'Este ejemplo demuestra cómo usar contenido global y específico del componente de manera conjunta.',
|
|
19
|
+
en: 'This example shows how to use global and component-specific content together.',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export default new TextContent(globalContentExampleData);
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYmFsLWNvbnRlbnQtZXhhbXBsZS1jb250ZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvdmFsdGVjaC1jb21wb25lbnRzL3NyYy9saWIvY29tcG9uZW50cy9fZXhhbXBsZXMvZ2xvYmFsLWNvbnRlbnQtZXhhbXBsZS1jb250ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7OztHQUtHO0FBRUgsT0FBTyxFQUFvQixXQUFXLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQztBQUVuRixNQUFNLHdCQUF3QixHQUFxQjtJQUNqRCxLQUFLLEVBQUU7UUFDTCxFQUFFLEVBQUUsNkJBQTZCO1FBQ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