@pongrass/utils 1.0.2-v20 → 1.0.4-v20

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 CHANGED
@@ -81,6 +81,36 @@ export class YourModule { }
81
81
  - **DecimalInputDirective** - Restricts input to decimal values
82
82
  - **MultiSelectStylerDirective** - Applies custom styling to multi-select components
83
83
  - **ShowTooltipIfTruncatedDirective** - Shows a tooltip when text is truncated
84
+ - **BackgroundImageDirective** - Adds background images to elements with optional random selection
85
+
86
+ ### BackgroundImageDirective
87
+
88
+ Adds background images to elements with support for random image selection from a list.
89
+
90
+ #### Inputs
91
+
92
+ - `backgroundImage` (string | string[]) - Path to a single background image or array of image paths
93
+ - `random` (boolean) - Flag to enable random image selection from array (defaults to false)
94
+
95
+ #### Usage
96
+
97
+ ```html
98
+ <!-- Single background image -->
99
+ <div appBackgroundImage [backgroundImage]="'assets/background1.jpg'"></div>
100
+
101
+ <!-- Random background image from a list -->
102
+ <div appBackgroundImage
103
+ [random]="true"
104
+ [backgroundImage]="['assets/background1.jpg', 'assets/background2.jpg', 'assets/background3.jpg']">
105
+ </div>
106
+
107
+ <!-- First image from a list (random=false) -->
108
+ <div appBackgroundImage
109
+ [backgroundImage]="['assets/background1.jpg', 'assets/background2.jpg', 'assets/background3.jpg']">
110
+ </div>
111
+ ```
112
+
113
+ Place your background images in your application's assets folder and reference them using the directive.
84
114
 
85
115
  ## Available Services
86
116
 
@@ -257,7 +257,7 @@ class CheckboxCellRendererComponent {
257
257
  }
258
258
  // Return Cell Value
259
259
  refresh(params) {
260
- this.value = params.value === '1' ? true : false;
260
+ this.value = params.value === 'Y' || params.value === 1 ? true : false;
261
261
  return true;
262
262
  }
263
263
  onChangeCheckBox(event) {
@@ -380,7 +380,7 @@ class JsonrpcServiceLib {
380
380
  id: this.configService.generateUniqueId()
381
381
  };
382
382
  return this.httpService
383
- .post(window.config.apiBaseURLWebMaint, body, { headers })
383
+ .post(window.config?.apiBaseURLWebMaint, body, { headers })
384
384
  .pipe(map(response => ({ ...response, timestamp: new Date().toISOString() })));
385
385
  }
386
386
  // JSONRPC POST Request With promise
@@ -392,7 +392,7 @@ class JsonrpcServiceLib {
392
392
  params: params,
393
393
  id: this.configService.generateUniqueId()
394
394
  };
395
- const request$ = this.httpService.post(window.config.apiBaseURLWebMaint, body, { headers });
395
+ const request$ = this.httpService.post(window.config?.apiBaseURLWebMaint, body, { headers });
396
396
  const response = await lastValueFrom(request$);
397
397
  return { ...response, timestamp: new Date().toISOString() };
398
398
  }
@@ -2123,10 +2123,68 @@ class ITableGridConfiguration {
2123
2123
  class ITableGridPagination {
2124
2124
  configurationService = inject(ConfigurationServiceLib);
2125
2125
  enabled = true;
2126
- paginationPageSize = this.configurationService.allConfigValues()?.tableGridConfig.defaultPageSize || 20;
2127
- paginationPageSizeSelector = this.configurationService.allConfigValues()?.tableGridConfig.defaultPageSizeSelector || false;
2126
+ paginationPageSize = this.configurationService.allConfigValues()?.tableGridConfig?.defaultPageSize || 20;
2127
+ paginationPageSizeSelector = this.configurationService.allConfigValues()?.tableGridConfig?.defaultPageSizeSelector || false;
2128
2128
  }
2129
2129
 
2130
+ class BackgroundImageDirective {
2131
+ el = inject(ElementRef);
2132
+ /**
2133
+ * Flag to enable random background selection
2134
+ * Defaults to false
2135
+ */
2136
+ random = false;
2137
+ /**
2138
+ * Path to the background image (string) or images (string[])
2139
+ */
2140
+ backgroundImage = '';
2141
+ ngOnInit() {
2142
+ this.setBackgroundImage();
2143
+ }
2144
+ setBackgroundImage() {
2145
+ let imageUrl = '';
2146
+ if (typeof this.backgroundImage === 'string') {
2147
+ // Single image path
2148
+ imageUrl = this.backgroundImage;
2149
+ }
2150
+ else if (Array.isArray(this.backgroundImage) && this.backgroundImage.length > 0) {
2151
+ // Array of image paths
2152
+ if (this.random) {
2153
+ // Select a random image from the array
2154
+ const randomIndex = Math.floor(Math.random() * this.backgroundImage.length);
2155
+ imageUrl = this.backgroundImage[randomIndex];
2156
+ }
2157
+ else {
2158
+ // Use the first image in the array
2159
+ imageUrl = this.backgroundImage[0];
2160
+ }
2161
+ }
2162
+ if (imageUrl) {
2163
+ this.el.nativeElement.style.backgroundImage = `url('${imageUrl}')`;
2164
+ this.el.nativeElement.style.backgroundSize = 'cover';
2165
+ this.el.nativeElement.style.backgroundPosition = 'center';
2166
+ this.el.nativeElement.style.backgroundRepeat = 'no-repeat';
2167
+ this.el.nativeElement.style.minHeight = '100vh';
2168
+ this.el.nativeElement.style.width = '100%';
2169
+ this.el.nativeElement.style.margin = '0';
2170
+ this.el.nativeElement.style.display = 'block';
2171
+ }
2172
+ }
2173
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BackgroundImageDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2174
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.9", type: BackgroundImageDirective, isStandalone: true, selector: "[appBackgroundImage]", inputs: { random: "random", backgroundImage: "backgroundImage" }, ngImport: i0 });
2175
+ }
2176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: BackgroundImageDirective, decorators: [{
2177
+ type: Directive,
2178
+ args: [{
2179
+ selector: '[appBackgroundImage]',
2180
+ standalone: true
2181
+ }]
2182
+ }], propDecorators: { random: [{
2183
+ type: Input
2184
+ }], backgroundImage: [{
2185
+ type: Input
2186
+ }] } });
2187
+
2130
2188
  /* eslint-disable @typescript-eslint/no-explicit-any */
2131
2189
  // Output: "2024-10-02 15:43:58"
2132
2190
  function convertToISOnString(date) {
@@ -2456,5 +2514,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
2456
2514
  * Generated bundle index. Do not edit.
2457
2515
  */
2458
2516
 
2459
- export { CheckboxCellRendererComponent, CircularFocusDirective, ColorCellRendererComponent, CommentsButtonCellRendererComponent, ConfigurationServiceLib, CustomSelectFilterComponent, DecimalInputDirective, EditionListGroupedComponent, ExcelType, ExportToExcelNames, FormFieldType, GenericFilterModelComponent, ITableGridConfiguration, ITableGridPagination, IndustryUpdateListboxCellRendererComponent, MultiFormComponent, MultiFormModule, MultiSelectStylerDirective, PageStatusCellRendererComponent, ShowTooltipIfTruncatedDirective, StatusSelectCellRendererComponent, TableGridComponent, TableGridModule, UtilsService, convertDateShort, convertIsoToFormat, convertToISOnString, regionalDateFormat };
2517
+ export { BackgroundImageDirective, CheckboxCellRendererComponent, CircularFocusDirective, ColorCellRendererComponent, CommentsButtonCellRendererComponent, ConfigurationServiceLib, CustomSelectFilterComponent, DecimalInputDirective, EditionListGroupedComponent, ExcelType, ExportToExcelNames, FormFieldType, GenericFilterModelComponent, ITableGridConfiguration, ITableGridPagination, IndustryUpdateListboxCellRendererComponent, MultiFormComponent, MultiFormModule, MultiSelectStylerDirective, PageStatusCellRendererComponent, ShowTooltipIfTruncatedDirective, StatusSelectCellRendererComponent, TableGridComponent, TableGridModule, UtilsService, convertDateShort, convertIsoToFormat, convertToISOnString, regionalDateFormat };
2460
2518
  //# sourceMappingURL=pongrass-utils.mjs.map