## ⚠️ Read Before Upgrading

- Update your project to **Angular 19** to avoid compatibility issues.  
- Review the [Changes Log](#changes-log) for breaking changes and apply necessary updates.

---

## Table of Contents

- [Recently Added Features](#recently-added-features)
  - [Load profile image directive](#load-profile-image-directive)
  - [BPM Core CLI](#bpm-core-cli)
  - [Input Mapping and Filtering](#input-mapping-and-filtering)  
  - [Time Picker](#time-picker)
  - [Summary Section](#summary-section)
- [Changes Log](#changes-log)

---

## Recently Added Features
- ### [Load profile image directive](#load-profile-image-directive)
  This directive loads and caches a profile image based on the provided email address. It automatically updates the `src` of an `img` element or the `image` property of a `ds-avatar` element with the loaded Base64 image.
  * Example usage:
    ```ts
    // First, import the directive and add it to your component imports
    import { ProfileImageByEmailDirective } from 'bpm-core';
    
    // Then, use it in your template with img element
    <img [profileImageByEmail]="'user@example.com'" />
    // or with ds-avatar element
    <ds-avatar [profileImageByEmail]="'user@example.com'"></ds-avatar>
    ```
- ### [BPM Core CLI](#bpm-core-cli)
  A command-line interface tool that provides helper scripts to speed up common tasks.

  Run the tool using the `bpm-core` command in your terminal.  
  To see all available commands, run:

  ```bash
  npx bpm-core --help
  ```

  The BPM Core CLI includes several helper scripts. You can run any script using its corresponding command.

  Below is the available commands:

  ---

  - `deploy` — *Supports only library services*.

    Use this command to deploy your service to one of the following environments: `dev`, `sit`, or `bat`.

    The deployment process includes:
    - Running the Angular build  
    - Syncing with the remote repository  
    - Triggering a Jenkins job

    **Example usage**  
    In your terminal, navigate to the service directory and run the following command:

    ```bash
    npx bpm-core deploy --env sit --repo-path D:\stc\build\sit --commit-msg "COW: correct typo in Arabic translation" --remote-dir "cow-new" --username jenkinsUserName --token jenkinsTokenOrPassword
    ```

    **For more details about available options**, run:

    ```bash
    npx bpm-core deploy --help
    ```
    ---
  - `generate` (alias: `g`) — *Supports only library services*.
  
    Provides the following subcommands:
    - `mock` (alias: `m`).
    
      Use this subcommand to generate mock data for your service. The generated mock data will be saved in your service root as a file named `mock-output.json`.

      **Example usage** 

      In your terminal, navigate to the service directory and run the following command:

      ```bash
      npx bpm-core generate mock
      # or using aliases
      npx bpm-core g m
      ```
      ---
    - `new` (alias: `n`)

      Use this subcommand to generate a new service, just like the form builder does.

      **Example usage** 

      First, create the service directory. Then, in your terminal, navigate to that directory and run the following command:

      ```bash
      npx bpm-core generate new --config config.json --service-code MSM
      # or using aliases
      npx bpm-core g n --config config.json --service-code MSM
      ```
      The required options are:
      - `--config` the generation config path (like a form builder config).
      - `--service-code` the service code.
      ---


  **Uploading file as formdata**
   ** "version": "0.0.144"**

  **Examples:**
  - Example 1: upload file using file-uploader component
 
    ```html
    <app-file-uploader [maxSize]="'20'" [sendAsFormdata]="true" 
      [multiple]="true"
     >
    </app-file-uploader>
    ```
     - Example 2: upload file using attachment-section component
 
    ```html
     <app-attachment-section  
     [sendAsFormdata]="true">
    </app-attachment-section>
    </app-file-uploader>
    ```
- ### [Input Mapping and Filtering](#input-mapping-and-filtering)
  The `app-input` component now supports two powerful inputs:

  - **`[mapFn]`** — A function that modifies the input value **before it's rendered**, allowing for transformations like uppercase conversion, formatting, or character replacement.
  - **`[filterFn]`** — A function that validates or restricts what characters can be typed, pasted, or dropped into the input.
  
  **Built-in Utility Classes Provided:**
  >
  > - `InputFilters`:
  >   - `InputFilters.arabicOnly`
  >   - `InputFilters.englishOnly`
  >   - `InputFilters.digitsOnly`
  >   - `InputFilters.buildPattern()`
  >
  > - `InputMappers`:
  >   - `InputMappers.toUpperCase`
  >   - `InputMappers.toLowerCase`

  **Examples:**
  - Example 1: Custom filter – Allow only numbers
    ```ts
    numbersOnlyFilter: InputFilterFn = (char, current, next, event) => {
      return /^[0-9]+$/.test(char);
    };
    ```
    ```html
    <app-input
      label="Phone Number"
      [filterFn]="numbersOnlyFilter"
    ></app-input>
    ```

  - Example 2: Built-in filter – Arabic-only characters
    ```ts
    import { InputFilters } from 'bpm-core';

    class MyComponent {
      InputFilters = InputFilters;
    }
    ```
    ```html
    <app-input
      label="الاسم بالعربية"
      [filterFn]="InputFilters.arabicOnly"
    ></app-input>
    ```
    > 💡 **Hint:** Use `InputFilters.buildPattern()` when you need to **customize exactly which characters are allowed** in an input.  
    > You can combine multiple character groups like Arabic letters, digits, symbols, and spaces then generate a custom filter function using `.build()`.

  - Example 3: Custom filter using `buildPattern()` — Allow English letters, digits, spaces, and symbols

    ```ts
    import { InputFilters } from 'bpm-core';

    class MyComponent {
      customEnglishFilter = InputFilters.buildPattern()
        .allowEnglishAlphabets()
        .allowDigits()
        .allowSpace()
        .allowSymbols()
        .build();
    }
    ```
    ```html
    <app-input
      label="Username"
      [filterFn]="customEnglishFilter"
    ></app-input>
    ```
  - Example 4: Custom map — Capitalize first letter of each word
    ```ts
    capitalizeWordsMapFn: InputMapFn = (char, current, next) => {
      return next.replace(/\b\w/g, (match) => match.toUpperCase());
    };
    ```
    ```html
    <app-input
      label="Full Name"
      [mapFn]="capitalizeWordsMapFn"
    ></app-input>
    ```

  - Example 5: Built-in map — Force lowercase
    ```ts
    import { InputMappers } from 'bpm-core';

    class MyComponent {
      InputMappers = InputMappers;
    }
    ```
    ```html
    <app-input
      label="Email"
      [mapFn]="InputMappers.toLowercase"
    ></app-input>
    ```

- ### [Time Picker](#time-picker) 
  To use it, import `TimepickerComponent` in your TypeScript file and add `<app-timepicker>` to your template. For more information, hover over the selector after adding it to your template.
- ### [Summary Section](#summary-section)  
  This is a stage that appears before the request stage.

  To enable this feature:
  - The summary section **must be the first item** in the `workflowSteps` list.
  - The `details` object for this step must include the following property:

    ```json
    "stage0": {
      "isStage0": "true"
    }
    ```

  **Example of a full payload:**

  <details>
    <summary>Click to expand full JSON payload</summary>

    ```json
    {
      "data": {
        "requester": { ... },
        "workflowSteps": [
          {
            "actor": {
              "recipient": {
                "role": "stage0"
              }
            },
            "details": {
              "litigantType": "",
              "other": "",
              "requestType": "",
              "reqSubject": "",
              "claimValue": "",
              "subClassification": "",
              "reqDetails": "",
              "plainName": "",
              "stage0": {
                "isStage0": "true"
              }
            }
          },
          {
            "actor": { ... },
            "date": "",
            "details": { ... }
          }
        ],
        "request": { ... },
        "form": { ... }
      },
      "meta": { ... }
    }
  ```
  </details> 

## Changes Log

<a id="bpm-core00132-2025-10-06"></a>
### [bpm-core@0.0.132 — 2025-10-06](#bpm-core00132-2025-10-06)
- fix(npm): resolve npm install issues.

<a id="bpm-core00130-2025-09-18"></a>
### [bpm-core@0.0.130 — 2025-09-18](#bpm-core00130-2025-09-18)
- feat(cli): add `generate new` command to generate an initial service from a config like the form builder.
- fix(cli/mock-data): restructure LOVs in payload and enhance logged path generation.
- **[BREAKING CHANGE]** fix(custom-searchable): update the default value of the `key` input property to 'value' (was 'description').
- feat(radio): activate and enhance radio component.
- refactor: remove ngx-translate package.
- **[BREAKING CHANGE]** refactor(input & textarea): remove 'enOnly' and 'arOnly' type values, use filterFn instead.
- fix(input-number): prevent dropping text into input number.
- **[BREAKING CHANGE]** refactor(attachment-section): replace `isRequired` input with `descriptionRequired` input and add `commentsRequired` input.
- fix(attachment-section): hide label in read-only mode if no attachments.
- fix(custom-searchable): add padding for search and clear icons in RTL.
- feat(input): add `maxLength` input property.
- feat(datepicker): support typed inputs for `minDate`, `maxDate`, `customMinDate`, and `customMaxDate`.
- feat(search-employee): add `selectedEmployee` output to emit the full details of the selected employee.

<a id="bpm-core00129-2025-09-01"></a>
### [bpm-core@0.0.129 — 2025-09-01](#bpm-core00129-2025-09-01)
- feat(cli): add generate command with mock subcommand to produce mock data
- fix(file-uploader): update max length error visibility when removing an attachment from multiple files.

<a id="bpm-core00128-2025-08-25"></a>
### [bpm-core@0.0.128 — 2025-08-25](#bpm-core00128-2025-08-25)
- feat(cli): implement BPM Core CLI with deploy command.
- refactor(app-input): remove keyType parameter from filter function.

<a id="bpm-core00127-2025-08-06"></a>
### [bpm-core@0.0.127 — 2025-08-06](#bpm-core00127-2025-08-06)
- feat(app-input): `app-input` now supports `filterFn` and `mapFn` inputs.
- feat(validation-errors): Added default error messages for `max` and `min` validators.

<a id="bpm-core00126-2025-07-30"></a>
### [bpm-core@0.0.126 — 2025-07-30](#bpm-core00126-2025-07-30)
- fix(file-uploader): avoid clearing attachments with multiple enabled.
- fix(file-uploader): activate "maxLength" input to specify maximum number of files
- fix(attachment-section): resolve _intl console error and translate MatPaginator labels to Arabic.

<a id="bpm-core00125-2025-07-23"></a>
### [bpm-core@0.0.125 — 2025-07-23](#bpm-core00125-2025-07-23)
- fix: resolve issue with downloading attachments from comments history.

<a id="bpm-core00124-2025-07-17"></a>
### [bpm-core@0.0.124 — 2025-07-17](#bpm-core00124-2025-07-17)
- Added default placeholders for all inputs.
- Ensured placeholders passed to inputs display correctly.

