form-js icon indicating copy to clipboard operation
form-js copied to clipboard

feat: add jalali calendar

Open mohammad-moa opened this issue 5 months ago • 3 comments

In this PR, Jalali calendar has been added using a side library related to flatpickr called flatpickr-jalali-support.

To use it, you must use locale: 'fa' in the Datetime.js file in the path packages/form-js-viewer/src/render/components/form-fields/Datetime.js

Similarly, in the Datepicker.js component in the path packages/form-js-viewer/src/render/components/form-fields/parts/Datepicker.js import Persian

import { Persian } from 'flatpickr-jalali-support/dist/l10n/fa';

the config variable must be used as follows

    let config = {
      allowInput: true,
      dateFormat: getLocaleDateFlatpickrConfig('fa'),
      static: true,
      clickOpens: false,
      locale: Persian,
      // TODO: support dates prior to 1900 (https://github.com/bpmn-io/form-js/issues/533)
      minDate: disallowPassedDates ? 'today' : '01/01/1900',
      errorHandler: () => {
        /* do nothing, we expect the values to sometimes be erroneous and we don't want warnings polluting the console */
      },
    };

Also to display the input placeholder, you should use

getLocaleReadableDateFormat('fa')

Related to issue

mohammad-moa avatar Jul 04 '25 14:07 mohammad-moa

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 04 '25 14:07 CLAassistant

@mohammad-moa could you follow the instructions and sign the CLA in the comment above?

vsgoulart avatar Jul 21 '25 08:07 vsgoulart

Yeah @vsgoulart , thanks for your attention I'll read and sign the CLA.

mohammad-moa avatar Jul 25 '25 07:07 mohammad-moa