<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic calcite-input-number with leading zero in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1606718#M86961</link>
    <description>&lt;P&gt;Using the&amp;nbsp;&lt;SPAN&gt;calcite-input-number I would like to achieve leading zeros.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the specific case the input ranges from 0 to 360 degrees.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So the following input should automatically show the exprected result within the input&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" width="15.894018967178559%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;0&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;10&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;100&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;360&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;360&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My input currently looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;calcite-input-number
            [min]="courseRange.min" [max]="courseRange.max" step="1"
            label="Course (in Degrees)"
            [value]="course()"
(calciteInputNumberChange)="refreshNumberChanged($event, course)"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;refreshNumberChanged is used to write back the value into a signal. This replaces former ngModel syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Apr 2025 21:55:17 GMT</pubDate>
    <dc:creator>SebastianKrings</dc:creator>
    <dc:date>2025-04-16T21:55:17Z</dc:date>
    <item>
      <title>calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1606718#M86961</link>
      <description>&lt;P&gt;Using the&amp;nbsp;&lt;SPAN&gt;calcite-input-number I would like to achieve leading zeros.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the specific case the input ranges from 0 to 360 degrees.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So the following input should automatically show the exprected result within the input&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" width="15.894018967178559%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;0&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;10&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;100&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="7.947434292866085%" height="24px"&gt;360&lt;/TD&gt;&lt;TD width="7.947434292866092%" height="24px"&gt;360&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My input currently looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;calcite-input-number
            [min]="courseRange.min" [max]="courseRange.max" step="1"
            label="Course (in Degrees)"
            [value]="course()"
(calciteInputNumberChange)="refreshNumberChanged($event, course)"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;refreshNumberChanged is used to write back the value into a signal. This replaces former ngModel syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 21:55:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1606718#M86961</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2025-04-16T21:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607291#M86968</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It is not possible to set leading 0s with either calcite-input-number or calcite-input of type="number". We have an enhancement request for this. Will update you once it is supported.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Would you mind giving your use case for needing 3 leading 0s? Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 15:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607291#M86968</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-04-18T15:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607374#M86969</link>
      <description>&lt;P&gt;sure.&lt;/P&gt;&lt;P&gt;According to the experts in nautical navigation degrees are always given as three digit number with leading rows.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 17:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607374#M86969</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2025-04-18T17:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607388#M86970</link>
      <description>&lt;P&gt;Ah gotcha! Thanks for responding.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 18:23:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607388#M86970</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-04-18T18:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607454#M86972</link>
      <description>&lt;P&gt;Is there any bug number or sth else to track on?&lt;BR /&gt;I would take this link into our documentation for the future.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 22:48:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607454#M86972</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2025-04-18T22:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607455#M86973</link>
      <description>&lt;P&gt;Can you please submit an issue via Support Servces? We then will attach our internal issue to the support issue. This way, you will have a link to connect to. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 22:53:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607455#M86973</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-04-18T22:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607456#M86974</link>
      <description>&lt;P&gt;Now I created a workaround solution for me by using a simple calcite-input and doing some key-event-handling.&lt;BR /&gt;I already have achieved most of what I want except the small arrow-icons on the right of a typical calcite-input-number to increase/decrease the value. I didnt want to use dom-related code, I am still unsure if there is any other way being more preferrable. So if anyone has an idea on that too or can help with some code, she is very welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So heres my code so far, consisting of:&lt;BR /&gt;- a component (ts part)with glue-code&lt;BR /&gt;- a component (html part) with just an inner calcite-input&lt;BR /&gt;- an other component integrating/calling my dedicated component&lt;/P&gt;&lt;P&gt;TS Part&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { Component, EventEmitter, input, Output } from "@angular/core";
import { CalciteComponentsModule } from "@esri/calcite-components-angular";
import { CalciteInputValidityStatus } from "../../calcite-input-validity-status.enum";

@Component({
    selector: 'my-leading-zero-input',
    templateUrl: './leading-zero-input.component.html',
    imports: [CalciteComponentsModule],
})
export class LeadingZeroInputComponent {
    /**
     * Event emitter to write back changes of the input-components value.
     */
    @Output() calciteInputNumberChange = new EventEmitter&amp;lt;any&amp;gt;();

    /**
     * If true, any inputs outside min and max will automatically overwritten by the exceeded limit.
     */
    fillLimitsOnExceed = input&amp;lt;boolean | undefined&amp;gt;();

    /**
     * Lower limit of the course.
     * Only applies if {@link fillLimitsOnExceed} is true.
     */
    courseMin = input&amp;lt;number | undefined&amp;gt;();

    /**
     * Lower limit of the course.
     * May applies if {@link fillLimitsOnExceed} is true.
     * Also applies for automatically filling/trimming up/down to leading zeros based on the max digit count.
     */
    courseMax = input&amp;lt;number | undefined&amp;gt;();

    /**
     * Programatically setting the value, e.g. initially.
     */
    courseInput = input&amp;lt;number | undefined&amp;gt;();

    /**
     * Validation status for the course field. If invalid shows the error message defined with {@link validityCourseMessage}
     */
    validityCourse = input&amp;lt;CalciteInputValidityStatus&amp;gt;(CalciteInputValidityStatus.idle);

    /**
     * Validation message shown if {@link validityCourse} has status invalid.
     */
    validityCourseMessage = input&amp;lt;string&amp;gt;();

    /**
     * Event happening before any input is printed into the component.
     * In contrast to onKeyDown this works on actual resulting content
     *  which includes dead-key-combinations like [^]+[f]
     * Only Digit input is allowed.
     * Does not affect other non-input interactions like copy/paste.
     * &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/891663"&gt;@Param&lt;/a&gt; event containing the actual input
     */
    onBeforeInput(event: InputEvent) {
        const bla = this.validityCourse();
        console.log(bla);
        if (event.inputType === 'insertText' &amp;amp;&amp;amp; !/^\d+$/.test(event.data ?? '')) {
            event.preventDefault();
        }
    }

    /**
     * Event happening on pasting from clipboard.
     * Prevents whole pasting if it contains any non digit char.
     * &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/891663"&gt;@Param&lt;/a&gt; event containing the pasting input
     */
    onPaste(event: ClipboardEvent) {
        const text = event.clipboardData?.getData('text') ?? '';
        if (!/^\d+$/.test(text)) {
            event.preventDefault();
        }
    }

    /**
     * Event happening right after any input is printed into the component.
     * In contrast to onKeyUp this works on actual resulting content
     *  which includes dead-key-combinations like [^]+[f]
     * Does not affect other non-input interactions like copy/paste.
     * 
     * Removes any non-digit from the input by replacing with an empty string.
     * Basically this works like a fallback especially for usage of other browsers
     *  in case the onBeforeInput did not work.
     * 
     * if {@link fillLimitsOnExceed} is true:
     * - Checks if the current value exceeds min or max limits if defined and
     *  automatically sets the value to the specific limit if exceeded.
     * - Excepts for an input of only zero(s):
     *  In case there is a minimum higher than zero,
     *  zero stil is allowed as input to support leading zeros.
     * 
     * &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/891663"&gt;@Param&lt;/a&gt; event containing the actual value
     */
    onInput(event: Event) {
        const input = event.target as HTMLInputElement;
        input.value = input.value.replace(/\D+/g, '');

        // if filling and trimming is not desired, return
        if (!this.fillLimitsOnExceed()) {
            return;
        }

        const asNumber = Number.parseInt(input.value);

        // set as min if value is lower
        // nevertheless allow leading zero in case min is greater than 0 (for some reason)
        const courseMin = this.courseMin();
        if (courseMin &amp;amp;&amp;amp; asNumber &amp;lt; courseMin &amp;amp;&amp;amp; asNumber !== 0) {
            input.value = courseMin.toString();
        }
        // set as max if value is higher
        const courseMax = this.courseMax();
        if (courseMax &amp;amp;&amp;amp; asNumber &amp;gt; courseMax) {
            input.value = courseMax.toString();
        }
    }

    /**
     * Event happening when any key is pressed down.
     * Checks for Esc or Enter has been hit.
     * If so causes a blur.
     * &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/891663"&gt;@Param&lt;/a&gt; event containing the pressed key
     */
    onKeyDown(event: KeyboardEvent) {
        if (event.key === 'Escape' || event.key === 'Enter') {
            (event.target as HTMLElement).blur();
        }
    }

    /**
     * Event happening when focus gets lost.
     * 
     * In case a max limit is defined leading zeros may be add or trimmed.
     * The desired digit-count is based on the max value if defined.
     * If so checks if leading zeros are missing and automatically adds them.
     * If there are already leading zeros and they are too many, they will be cut.
     * &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/891663"&gt;@Param&lt;/a&gt; event containing the pressed key
     */
    onBlur(event: FocusEvent) {
        const courseMax = this.courseMax();
        if (courseMax) {
            // add leading zeros, fill til length of max
            const input = event.target as HTMLInputElement;
            input.value = input.value.replace(/^0+/, '');
            input.value = input.value.padStart(courseMax.toString().length, '0');
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;HTML Part&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;calcite-input
    label="Kurs (in Grad)"
    i18n-label="...course"
    title="Kurs (in Grad)" i18n-title="...course"
    [value]="courseInput()" (calciteInputChange)="calciteInputNumberChange.emit($event)"
    (beforeinput)="onBeforeInput($event)"
    (paste)="onPaste($event)"
    (input)="onInput($event)"
    (keydown)="onKeyDown($event)"
    (blur)="onBlur($event)"
    [status] = "validityCourse()" [validationMessage]="validityCourseMessage()"
    validationIcon = "exclamation-mark-triangle" /&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Integrating/Calling&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;my-leading-zero-input
	[courseInput]="course()" [courseMin]="courseRange.min" [courseMax]="courseRange.max"
	[validityCourse] = "validityCourse()" [validityCourseMessage]="validityCourseMessage()"
	(calciteInputNumberChange)="refreshNumberChanged($event, course)"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 22:57:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607456#M86974</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2025-04-18T22:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607457#M86975</link>
      <description>&lt;P&gt;can you describe me how to do so and share a link?&lt;BR /&gt;Hope this will not take too much time and data to submit.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 22:59:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1607457#M86975</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2025-04-18T22:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1608134#M86989</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can contact esri support services through one of the means on their page -&amp;nbsp;&lt;A href="https://support.esri.com/en-us/contact" target="_blank"&gt;https://support.esri.com/en-us/contact&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2025 15:26:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1608134#M86989</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-04-22T15:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1608219#M86991</link>
      <description>&lt;P&gt;unfortunately this does not work&lt;BR /&gt;&lt;BR /&gt;"Sorry, only Authorized Callers can chat and create a support case"&lt;/P&gt;&lt;P&gt;So, may you can do yourself.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2025 18:12:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1608219#M86991</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2025-04-22T18:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: calcite-input-number with leading zero</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1608225#M86992</link>
      <description>&lt;P&gt;&lt;A href="https://github.com/Esri/calcite-design-system/issues/11987" target="_blank"&gt;https://github.com/Esri/calcite-design-system/issues/11987&lt;/A&gt;&amp;nbsp;- you should have access to this issue as long as you have github account&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2025 18:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calcite-input-number-with-leading-zero/m-p/1608225#M86992</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-04-22T18:41:23Z</dc:date>
    </item>
  </channel>
</rss>

