commons-shared-web-ui 0.0.18 → 0.0.19

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
@@ -1469,6 +1469,12 @@ interface FormSchema {
1469
1469
  sectionConfig?: SectionConfig;
1470
1470
  stepperConfig?: StepperConfig;
1471
1471
  submitConfig?: SubmitConfig;
1472
+ /**
1473
+ * Configures the action bar shown at the bottom of the form.
1474
+ * Supports Cancel, Save as Draft, and Submit buttons with flexible layout.
1475
+ * If omitted, the default Submit (and stepper Prev/Next) behaviour is unchanged.
1476
+ */
1477
+ actionBarConfig?: ActionBarConfig;
1472
1478
  showActions?: boolean;
1473
1479
  /** Full token string passed to all library API calls (e.g. "Bearer eyJ…") */
1474
1480
  token?: string;
@@ -1502,6 +1508,71 @@ interface SubmitConfig {
1502
1508
  showCloseButton?: boolean;
1503
1509
  };
1504
1510
  }
1511
+ /**
1512
+ * Describes what happens when an action bar button is clicked.
1513
+ * One ActionConfig shape works for every button.
1514
+ */
1515
+ interface ActionConfig {
1516
+ /**
1517
+ * Action kind.
1518
+ * 'submit' -> Validates and submits form using submitConfig/editConfig.
1519
+ * 'draft' -> Saves form data without full validation.
1520
+ * 'navigate' -> Navigates to redirectUrl.
1521
+ * 'api' -> Fires an API call then optionally navigates.
1522
+ * 'emit' -> Emits actionClick event for custom handling.
1523
+ * 'next' -> Advances to next step (stepper only).
1524
+ * 'prev' -> Goes back to previous step (stepper only).
1525
+ */
1526
+ kind: 'submit' | 'draft' | 'navigate' | 'api' | 'emit' | 'next' | 'prev';
1527
+ /** URL for 'navigate' or 'api' callbacks. */
1528
+ redirectUrl?: string;
1529
+ /** API endpoint for 'api' actions. */
1530
+ apiUrl?: string;
1531
+ /** HTTP method for 'api' actions. @default 'POST' */
1532
+ method?: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1533
+ /** Static extra payload merged into 'api' or 'draft' requests. */
1534
+ extraPayload?: {
1535
+ [key: string]: any;
1536
+ };
1537
+ /** Snackbar messages for 'api' or 'submit'/'draft' actions. */
1538
+ successMessage?: string;
1539
+ errorMessage?: string;
1540
+ snackbarConfig?: {
1541
+ duration?: number;
1542
+ horizontalPosition?: 'start' | 'center' | 'end' | 'left' | 'right';
1543
+ verticalPosition?: 'top' | 'bottom';
1544
+ showCloseButton?: boolean;
1545
+ };
1546
+ }
1547
+ /**
1548
+ * Button configuration focusing on visuals and layout.
1549
+ * All logic is delegated to the 'action' property.
1550
+ */
1551
+ interface ActionButtonConfig {
1552
+ /** Unique identifier for the button. */
1553
+ id: string;
1554
+ /** Label (i18n key or text). */
1555
+ label?: string;
1556
+ /** Button style variant. */
1557
+ variant?: ButtonVariant | string;
1558
+ /** Bar alignment. @default 'right' */
1559
+ alignment?: 'left' | 'right';
1560
+ /** Display order (lower = first). */
1561
+ order?: number;
1562
+ /** Visibility. @default false */
1563
+ hidden?: boolean;
1564
+ /** State. @default false */
1565
+ disabled?: boolean;
1566
+ /** Action logic. */
1567
+ action: ActionConfig;
1568
+ }
1569
+ /**
1570
+ * Action bar configuration.
1571
+ */
1572
+ interface ActionBarConfig {
1573
+ /** Flexibly ordered list of action buttons. */
1574
+ buttons: ActionButtonConfig[];
1575
+ }
1505
1576
  interface EditConfig {
1506
1577
  loadApiUrl: string;
1507
1578
  submitApiUrl: string;
@@ -1884,6 +1955,7 @@ declare class SmartFormComponent implements OnInit, OnChanges, OnDestroy {
1884
1955
  private expressionService;
1885
1956
  private http;
1886
1957
  private snackbarService;
1958
+ private router;
1887
1959
  formJson: string;
1888
1960
  initialValues?: {
1889
1961
  [key: string]: any;
@@ -1900,13 +1972,25 @@ declare class SmartFormComponent implements OnInit, OnChanges, OnDestroy {
1900
1972
  [key: string]: any;
1901
1973
  }>;
1902
1974
  draftSave: EventEmitter<string>;
1975
+ /**
1976
+ * Emitted when a button with a custom `type` (not 'cancel', 'draft', or
1977
+ * 'submit') is clicked. Payload contains the button `id` and the current
1978
+ * form data snapshot.
1979
+ */
1980
+ actionClick: EventEmitter<{
1981
+ id: string;
1982
+ formData: {
1983
+ [key: string]: any;
1984
+ };
1985
+ }>;
1903
1986
  formSchema: FormSchema;
1904
1987
  formGroup: FormGroup;
1905
1988
  fieldList: FieldConfig[];
1906
1989
  isStepper: boolean;
1907
1990
  currentStep: number;
1908
1991
  isLoading: boolean;
1909
- constructor(fb: FormBuilder, controller: SmartFormController, expressionService: ExpressionService, http: HttpClient, snackbarService: SnackbarService);
1992
+ isDraftLoading: boolean;
1993
+ constructor(fb: FormBuilder, controller: SmartFormController, expressionService: ExpressionService, http: HttpClient, snackbarService: SnackbarService, router: Router);
1910
1994
  ngOnInit(): void;
1911
1995
  loadEditData(): void;
1912
1996
  ngOnChanges(changes: SimpleChanges): void;
@@ -1915,6 +1999,12 @@ declare class SmartFormComponent implements OnInit, OnChanges, OnDestroy {
1915
1999
  initializeForm(): void;
1916
2000
  collectFields(fields: FieldConfig[]): void;
1917
2001
  handleSubmit(): void;
2002
+ /**
2003
+ * Universal action handler for any button click.
2004
+ * One handler decides how to process based on action.kind.
2005
+ */
2006
+ handleButtonClick(btn: ActionButtonConfig): void;
2007
+ private fireActionApiCall;
1918
2008
  /**
1919
2009
  * Constructs nested payload by checking field properties on form controls.
1920
2010
  */
@@ -1930,7 +2020,7 @@ declare class SmartFormComponent implements OnInit, OnChanges, OnDestroy {
1930
2020
  private extractGroupValue;
1931
2021
  validate(): boolean;
1932
2022
  scrollToFirstInvalidControl(): void;
1933
- submitToApi(formData: any): void;
2023
+ submitToApi(formData: any, actionType?: 'submit' | 'draft', btn?: ActionButtonConfig): void;
1934
2024
  showAlert(type: 'success' | 'error' | 'warning' | 'info', message: string, customConfig?: any): void;
1935
2025
  /** Builds HttpHeaders from the token stored in the controller (sourced from configJSON). */
1936
2026
  getHeaders(): HttpHeaders;
@@ -1942,8 +2032,17 @@ declare class SmartFormComponent implements OnInit, OnChanges, OnDestroy {
1942
2032
  get nextLabel(): string;
1943
2033
  get submitLabel(): string;
1944
2034
  get previousLabel(): string;
2035
+ get actionBarConfig(): ActionBarConfig | undefined;
2036
+ /**
2037
+ * Returns buttons for a given alignment, sorted by `order` (stable).
2038
+ */
2039
+ getButtonsForAlignment(alignment: 'left' | 'right'): ActionButtonConfig[];
2040
+ getButtonLabel(btn: ActionButtonConfig): string;
2041
+ isButtonDisabled(btn: ActionButtonConfig): boolean;
2042
+ private getButtonByActionKind;
2043
+ private navigateTo;
1945
2044
  static ɵfac: i0.ɵɵFactoryDeclaration<SmartFormComponent, never>;
1946
- static ɵcmp: i0.ɵɵComponentDeclaration<SmartFormComponent, "lib-smart-form", never, { "formJson": { "alias": "formJson"; "required": false; }; "initialValues": { "alias": "initialValues"; "required": false; }; "enableDraftAutoSave": { "alias": "enableDraftAutoSave"; "required": false; }; "labels": { "alias": "labels"; "required": false; }; "mode": { "alias": "mode"; "required": false; }; }, { "submit": "submit"; "draftSave": "draftSave"; }, never, never, false, never>;
2045
+ static ɵcmp: i0.ɵɵComponentDeclaration<SmartFormComponent, "lib-smart-form", never, { "formJson": { "alias": "formJson"; "required": false; }; "initialValues": { "alias": "initialValues"; "required": false; }; "enableDraftAutoSave": { "alias": "enableDraftAutoSave"; "required": false; }; "labels": { "alias": "labels"; "required": false; }; "mode": { "alias": "mode"; "required": false; }; }, { "submit": "submit"; "draftSave": "draftSave"; "actionClick": "actionClick"; }, never, never, false, never>;
1947
2046
  }
1948
2047
 
1949
2048
  declare class FormSectionComponent implements OnInit, OnDestroy {
@@ -2278,6 +2377,10 @@ declare class SideNavComponent implements OnChanges {
2278
2377
  showTooltips: boolean;
2279
2378
  /** Position of the tooltip */
2280
2379
  tooltipPosition: TooltipPosition;
2380
+ /** Optional dictionary for label translation */
2381
+ labels?: {
2382
+ [key: string]: string;
2383
+ };
2281
2384
  itemClicked: EventEmitter<SideNavItem>;
2282
2385
  /** Emits whenever the collapsed state changes (supports two-way binding via [(collapsed)]) */
2283
2386
  collapsedChange: EventEmitter<boolean>;
@@ -2285,14 +2388,14 @@ declare class SideNavComponent implements OnChanges {
2285
2388
  get isHostCollapsed(): boolean;
2286
2389
  filteredSections: SideNavSection[];
2287
2390
  ngOnChanges(changes: SimpleChanges): void;
2288
- private filterSections;
2391
+ private filterAndMapSections;
2289
2392
  onItemClick(item: SideNavItem, event: Event): void;
2290
2393
  toggleCollapse(): void;
2291
2394
  get customStyles(): {
2292
2395
  [key: string]: string;
2293
2396
  };
2294
2397
  static ɵfac: i0.ɵɵFactoryDeclaration<SideNavComponent, never>;
2295
- static ɵcmp: i0.ɵɵComponentDeclaration<SideNavComponent, "lib-side-nav", never, { "sections": { "alias": "sections"; "required": false; }; "userRoles": { "alias": "userRoles"; "required": false; }; "activeId": { "alias": "activeId"; "required": false; }; "styleConfig": { "alias": "styleConfig"; "required": false; }; "collapsed": { "alias": "collapsed"; "required": false; }; "width": { "alias": "width"; "required": false; }; "collapsedWidth": { "alias": "collapsedWidth"; "required": false; }; "showCollapseToggle": { "alias": "showCollapseToggle"; "required": false; }; "hideIconsWhenExpanded": { "alias": "hideIconsWhenExpanded"; "required": false; }; "showTooltips": { "alias": "showTooltips"; "required": false; }; "tooltipPosition": { "alias": "tooltipPosition"; "required": false; }; }, { "itemClicked": "itemClicked"; "collapsedChange": "collapsedChange"; }, never, never, false, never>;
2398
+ static ɵcmp: i0.ɵɵComponentDeclaration<SideNavComponent, "lib-side-nav", never, { "sections": { "alias": "sections"; "required": false; }; "userRoles": { "alias": "userRoles"; "required": false; }; "activeId": { "alias": "activeId"; "required": false; }; "styleConfig": { "alias": "styleConfig"; "required": false; }; "collapsed": { "alias": "collapsed"; "required": false; }; "width": { "alias": "width"; "required": false; }; "collapsedWidth": { "alias": "collapsedWidth"; "required": false; }; "showCollapseToggle": { "alias": "showCollapseToggle"; "required": false; }; "hideIconsWhenExpanded": { "alias": "hideIconsWhenExpanded"; "required": false; }; "showTooltips": { "alias": "showTooltips"; "required": false; }; "tooltipPosition": { "alias": "tooltipPosition"; "required": false; }; "labels": { "alias": "labels"; "required": false; }; }, { "itemClicked": "itemClicked"; "collapsedChange": "collapsedChange"; }, never, never, false, never>;
2296
2399
  }
2297
2400
 
2298
2401
  declare class SideNavModule {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commons-shared-web-ui",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "20.3.15",
6
6
  "@angular/cdk": "20.2.14",