commons-shared-web-ui 0.0.14 → 0.0.16

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnInit, OnDestroy, EventEmitter, OnChanges, SimpleChanges, ElementRef, AfterViewInit, QueryList, ChangeDetectorRef, NgZone } from '@angular/core';
2
+ import { OnInit, OnDestroy, EventEmitter, OnChanges, SimpleChanges, ElementRef, PipeTransform, AfterViewInit, QueryList, ChangeDetectorRef, NgZone } from '@angular/core';
3
3
  import * as i2$1 from '@angular/common';
4
4
  import * as i1 from '@angular/material/card';
5
5
  import * as i2 from '@angular/material/snack-bar';
@@ -40,7 +40,8 @@ import * as i11$1 from '@angular/cdk/scrolling';
40
40
  import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
41
41
  import { HttpClient, HttpHeaders } from '@angular/common/http';
42
42
  import { Observable, Subject } from 'rxjs';
43
- import * as i9$1 from 'ngx-quill';
43
+ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
44
+ import * as i10$1 from 'ngx-quill';
44
45
 
45
46
  declare class MaterialModule {
46
47
  static ɵfac: i0.ɵɵFactoryDeclaration<MaterialModule, never>;
@@ -1615,6 +1616,7 @@ interface TextConfig {
1615
1616
  * the check on the field that carries matchField config.
1616
1617
  */
1617
1618
  matchField?: string;
1619
+ showCharCount?: boolean;
1618
1620
  }
1619
1621
  interface LengthConstraint {
1620
1622
  min?: number;
@@ -1700,11 +1702,80 @@ interface AttachmentConfig {
1700
1702
  * Only relevant when uploadUrl is set.
1701
1703
  */
1702
1704
  entityType?: string;
1705
+ /**
1706
+ * API endpoint to delete the file. Called when an uploaded file with an ID != 0 is removed.
1707
+ */
1708
+ deleteUrl?: string;
1709
+ /** API endpoint to GET the default library images list */
1710
+ libraryApiUrl?: string;
1711
+ /** Dot-notation path to the image array in the library API response (e.g. 'data.items') */
1712
+ libraryDataPath?: string;
1713
+ /** Dot-notation path to the image URL within each library item (e.g. 'url') */
1714
+ libraryUrlPath?: string;
1715
+ /** Dot-notation path to the image ID within each library item */
1716
+ libraryIdPath?: string;
1717
+ /** Optional description shown in the left info panel for media upload */
1718
+ description?: string;
1719
+ /** Optional bullet-point feature lines shown in the left info panel for media upload */
1720
+ features?: string[];
1703
1721
  }
1704
1722
  interface LocationConfig {
1723
+ /** Default active tab: 'VENUE' | 'ONLINE' | 'TBA'. Defaults to 'VENUE'. */
1724
+ defaultTab?: 'VENUE' | 'ONLINE' | 'TBA';
1725
+ /** Allow multiple locations. Replaces the need for maxLocations. */
1726
+ allowMulti?: boolean;
1727
+ /** Maximum number of venue locations allowed. Defaults to 5 if allowMulti is true. */
1728
+ maxLocations?: number;
1729
+ /** Placeholder for the venue search input */
1730
+ venuePlaceholder?: string;
1731
+ /** Google Maps API Key – required for map rendering and autocomplete */
1732
+ googleMapsApiKey?: string;
1733
+ /** Height of the embedded Google Map. Defaults to '300px'. */
1734
+ mapHeight?: string;
1735
+ /** Default map center latitude when no locations are added (e.g., India: 20.5937) */
1736
+ defaultLat?: number;
1737
+ /** Default map center longitude when no locations are added (e.g., India: 78.9629) */
1738
+ defaultLng?: number;
1739
+ /** Default zoom level when no locations are added (e.g., 4) */
1740
+ defaultZoom?: number;
1741
+ /** Placeholder for the online event URL input */
1742
+ onlinePlaceholder?: string;
1743
+ /** Show map preview after locations are added (default: true) */
1744
+ showMap?: boolean;
1745
+ /** Whether the current location button is enabled inside venue tab */
1705
1746
  enableCurrentLocation?: boolean;
1747
+ /** @deprecated Use showMap instead */
1706
1748
  enableMapPicker?: boolean;
1707
1749
  }
1750
+ /** A single venue location picked from Google Places autocomplete. */
1751
+ interface LocationItem {
1752
+ uuid?: string;
1753
+ isActive?: boolean;
1754
+ id?: number;
1755
+ locationCode?: string;
1756
+ latitude?: number;
1757
+ longitude?: number;
1758
+ address?: string;
1759
+ name?: string;
1760
+ cityLabel?: string;
1761
+ stateLabel?: string;
1762
+ countryLabel?: string;
1763
+ placeId?: string;
1764
+ type?: string;
1765
+ /** Legacy field for UI binding */
1766
+ description?: string;
1767
+ }
1768
+ /**
1769
+ * Value shape stored in the FormControl for a LOCATION field.
1770
+ * `tab` indicates which mode is active.
1771
+ */
1772
+ interface LocationFieldValue {
1773
+ tab: 'VENUE' | 'ONLINE' | 'TBA';
1774
+ /** Array of venue locations (only valid when tab === 'VENUE') */
1775
+ venues?: LocationItem[];
1776
+ /** Event URL (only valid when tab === 'ONLINE') */
1777
+ onlineUrl?: string;
1778
+ }
1708
1779
  interface RatingConfig {
1709
1780
  maxRating?: number;
1710
1781
  allowHalf?: boolean;
@@ -1712,6 +1783,8 @@ interface RatingConfig {
1712
1783
  interface RichTextConfig {
1713
1784
  height?: string;
1714
1785
  placeholder?: string;
1786
+ maxLength?: number;
1787
+ showCharCount?: boolean;
1715
1788
  }
1716
1789
  interface ValidationResult {
1717
1790
  isValid: boolean;
@@ -1720,6 +1793,26 @@ interface ValidationResult {
1720
1793
  [key: string]: string;
1721
1794
  };
1722
1795
  }
1796
+ /**
1797
+ * A single media item stored in the MEDIA_UPLOAD field value array.
1798
+ * Can represent an uploaded image (from device or library) or a YouTube video.
1799
+ */
1800
+ interface MediaItem {
1801
+ /** Server-assigned ID (for pre-filled items) */
1802
+ id?: number;
1803
+ /** 'image' | 'youtube' */
1804
+ mediaType: 'image' | 'youtube';
1805
+ /** Remote URL of the image returned by the upload API, or the YouTube embed URL */
1806
+ url: string;
1807
+ /** Thumbnail URL (for YouTube previews) */
1808
+ thumbnailUrl?: string;
1809
+ /** MIME type returned by the upload API (e.g. 'image/png') */
1810
+ mimeType?: string;
1811
+ /** File name returned by the upload API */
1812
+ fileName?: string;
1813
+ /** True while the file is being uploaded */
1814
+ isUploading?: boolean;
1815
+ }
1723
1816
 
1724
1817
  declare class SmartFormController {
1725
1818
  private formData;
@@ -1910,6 +2003,34 @@ declare class FormFieldComponent implements OnInit, OnDestroy {
1910
2003
  fileUploadError: string;
1911
2004
  multiSaveError: string;
1912
2005
  private destroy$;
2006
+ mediaDeviceInput: ElementRef<HTMLInputElement>;
2007
+ showMediaMenu: boolean;
2008
+ showYoutubeInput: boolean;
2009
+ youtubeUrlInput: string;
2010
+ youtubeUrlError: string;
2011
+ mediaCarouselIndex: number;
2012
+ showLibraryModal: boolean;
2013
+ libraryImages: any[];
2014
+ librarySelectedIds: Set<any>;
2015
+ libraryLoading: boolean;
2016
+ libraryError: string;
2017
+ mediaUploadError: string;
2018
+ /** Active tab: VENUE | ONLINE | TBA */
2019
+ locationActiveTab: 'VENUE' | 'ONLINE' | 'TBA';
2020
+ /** Current text in the venue search box */
2021
+ locationSearchText: string;
2022
+ /** Google Places autocomplete suggestions */
2023
+ locationSuggestions: any[];
2024
+ /** Show the suggestions dropdown */
2025
+ locationShowSuggestions: boolean;
2026
+ /** Cached Google AutocompleteService instance */
2027
+ private _googleAcService;
2028
+ /** Whether Google Maps is loaded */
2029
+ locationMapLoaded: boolean;
2030
+ /** Map instance */
2031
+ private _googleMap;
2032
+ /** Map markers */
2033
+ private _mapMarkers;
1913
2034
  /** FormControl used ONLY for the autocomplete text-input display value */
1914
2035
  autocompleteInputCtrl: FormControl<string>;
1915
2036
  /** Filtered option list shown in the mat-autocomplete panel */
@@ -1992,6 +2113,8 @@ declare class FormFieldComponent implements OnInit, OnDestroy {
1992
2113
  onCheckboxListChange(code: string, checked: boolean): void;
1993
2114
  isChecked(code: string): boolean;
1994
2115
  get errorMessage(): string;
2116
+ get showCharCount(): boolean;
2117
+ get remainingCharacters(): number | null;
1995
2118
  get isTextField(): boolean;
1996
2119
  get isNumberField(): boolean;
1997
2120
  get isDateField(): boolean;
@@ -1999,6 +2122,7 @@ declare class FormFieldComponent implements OnInit, OnDestroy {
1999
2122
  get isDropdown(): boolean;
2000
2123
  get isAutocomplete(): boolean;
2001
2124
  get isFileUpload(): boolean;
2125
+ get isMediaUpload(): boolean;
2002
2126
  get isRadio(): boolean;
2003
2127
  get isCheckbox(): boolean;
2004
2128
  get isChip(): boolean;
@@ -2008,6 +2132,7 @@ declare class FormFieldComponent implements OnInit, OnDestroy {
2008
2132
  get isGenerated(): boolean;
2009
2133
  get isRow(): boolean;
2010
2134
  get isGroup(): boolean;
2135
+ get isLocation(): boolean;
2011
2136
  /**
2012
2137
  * Initialise the separate display-control that drives the mat-autocomplete
2013
2138
  * text input. The real form control always stores the *code* value.
@@ -2044,13 +2169,66 @@ declare class FormFieldComponent implements OnInit, OnDestroy {
2044
2169
  formatFileSize(bytes: number): string;
2045
2170
  get addLabel(): string;
2046
2171
  get removeLabel(): string;
2172
+ get mediaItems(): MediaItem[];
2173
+ /** Number of active items (used to clamp carousel index) */
2174
+ get mediaCount(): number;
2175
+ /** The currently visible carousel item */
2176
+ get activeMediaItem(): MediaItem | null;
2177
+ /** Thumbnail strip items */
2178
+ get mediaThumbnails(): MediaItem[];
2179
+ mediaCarouselPrev(): void;
2180
+ mediaCarouselNext(): void;
2181
+ mediaGoTo(index: number): void;
2182
+ onMediaMenuVideo(): void;
2183
+ addYoutubeMedia(): void;
2184
+ private _extractYoutubeId;
2185
+ onMediaMenuDevice(): void;
2186
+ onMediaFileSelected(event: Event): void;
2187
+ onMediaMenuLibrary(): void;
2188
+ private _loadLibraryImages;
2189
+ getLibraryItemUrl(item: any): string;
2190
+ getLibraryItemId(item: any): any;
2191
+ isLibraryItemSelected(item: any): boolean;
2192
+ toggleLibraryItem(item: any): void;
2193
+ closeLibraryModal(): void;
2194
+ confirmLibrarySelection(): void;
2195
+ removeMediaItem(index: number): void;
2196
+ private _appendMediaItem;
2197
+ private showMediaError;
2198
+ private initLocationField;
2199
+ private _ensureGoogleMapsScript;
2200
+ onLocationTabChange(tab: 'VENUE' | 'ONLINE' | 'TBA'): void;
2201
+ get locationValue(): LocationFieldValue;
2202
+ get locationVenues(): LocationItem[];
2203
+ get locationOnlineUrl(): string;
2204
+ get locationMaxReached(): boolean;
2205
+ handleLocationSearchInput(event: Event): void;
2206
+ onLocationSuggestionSelect(prediction: any): void;
2207
+ private _addVenueAndUpdate;
2208
+ removeLocationVenue(index: number): void;
2209
+ onLocationUrlChange(url: string): void;
2210
+ hideLocationSuggestions(): void;
2211
+ getLocationMapEmbedUrl(): string;
2212
+ private _renderMap;
2047
2213
  static ɵfac: i0.ɵɵFactoryDeclaration<FormFieldComponent, never>;
2048
2214
  static ɵcmp: i0.ɵɵComponentDeclaration<FormFieldComponent, "lib-form-field", never, { "config": { "alias": "config"; "required": false; }; "controller": { "alias": "controller"; "required": false; }; "formGroup": { "alias": "formGroup"; "required": false; }; "allowMulti": { "alias": "allowMulti"; "required": false; }; }, {}, never, never, false, never>;
2049
2215
  }
2050
2216
 
2217
+ /**
2218
+ * Bypasses Angular's DomSanitizer for resource URLs (e.g. YouTube embed iframes).
2219
+ * Used only for trusted URLs such as YouTube embed links derived from user-provided video IDs.
2220
+ */
2221
+ declare class TrustedUrlPipe implements PipeTransform {
2222
+ private sanitizer;
2223
+ constructor(sanitizer: DomSanitizer);
2224
+ transform(url: string): SafeResourceUrl | null;
2225
+ static ɵfac: i0.ɵɵFactoryDeclaration<TrustedUrlPipe, never>;
2226
+ static ɵpipe: i0.ɵɵPipeDeclaration<TrustedUrlPipe, "trustedUrl", false>;
2227
+ }
2228
+
2051
2229
  declare class SmartFormModule {
2052
2230
  static ɵfac: i0.ɵɵFactoryDeclaration<SmartFormModule, never>;
2053
- static ɵmod: i0.ɵɵNgModuleDeclaration<SmartFormModule, [typeof SmartFormComponent, typeof FormSectionComponent, typeof FormFieldComponent], [typeof i2$1.CommonModule, typeof i3$1.ReactiveFormsModule, typeof i3$1.FormsModule, typeof MaterialModule, typeof ButtonModule, typeof AlertModule, typeof i9$1.QuillModule], [typeof SmartFormComponent]>;
2231
+ static ɵmod: i0.ɵɵNgModuleDeclaration<SmartFormModule, [typeof SmartFormComponent, typeof FormSectionComponent, typeof FormFieldComponent, typeof TrustedUrlPipe], [typeof i2$1.CommonModule, typeof i3$1.ReactiveFormsModule, typeof i3$1.FormsModule, typeof MaterialModule, typeof ButtonModule, typeof AlertModule, typeof i10$1.QuillModule], [typeof SmartFormComponent]>;
2054
2232
  static ɵinj: i0.ɵɵInjectorDeclaration<SmartFormModule>;
2055
2233
  }
2056
2234
 
@@ -2527,6 +2705,7 @@ declare const SAMPLE_FORMS: {
2527
2705
  demandDefinitionForm: string;
2528
2706
  projectInfoForm: string;
2529
2707
  faqForm: string;
2708
+ locationForm: string;
2530
2709
  };
2531
2710
 
2532
2711
  declare const smartForm_examples_d_SAMPLE_FORMS: typeof SAMPLE_FORMS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commons-shared-web-ui",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "20.3.15",
6
6
  "@angular/cdk": "20.2.14",
@@ -119,7 +119,7 @@ $default-smart-form-config: (
119
119
  generated-padding: 0.625rem 0.875rem,
120
120
 
121
121
  // ── File upload drop-zone ───────────────────────────────────────────────────
122
- dropzone-bg: #F8FAFC,
122
+ dropzone-bg: #FFFAF1,
123
123
  dropzone-border: 1.5px dashed #CBD5E1,
124
124
  dropzone-radius: 12px,
125
125
  dropzone-hover-bg: #EFF6FF,