@roadtrip/components 3.33.2 → 3.33.4
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/dist/cjs/road-badge_14.cjs.entry.js +60 -44
- package/dist/cjs/road-badge_14.cjs.entry.js.map +1 -1
- package/dist/cjs/road-spinner.cjs.entry.js +1 -1
- package/dist/cjs/road-spinner.cjs.entry.js.map +1 -1
- package/dist/collection/components/counter/counter.css +1 -0
- package/dist/collection/components/counter/counter.js +17 -1
- package/dist/collection/components/counter/counter.js.map +1 -1
- package/dist/collection/components/drawer/drawer.css +1 -0
- package/dist/collection/components/input/input.js +41 -45
- package/dist/collection/components/input/input.js.map +1 -1
- package/dist/collection/components/spinner/spinner.css +1 -1
- package/dist/esm/road-badge_14.entry.js +60 -44
- package/dist/esm/road-badge_14.entry.js.map +1 -1
- package/dist/esm/road-spinner.entry.js +1 -1
- package/dist/esm/road-spinner.entry.js.map +1 -1
- package/dist/roadtrip/{p-55897254.entry.js → p-678b1218.entry.js} +3 -3
- package/dist/roadtrip/p-678b1218.entry.js.map +1 -0
- package/dist/roadtrip/p-6d3d947e.entry.js +2 -0
- package/dist/roadtrip/p-6d3d947e.entry.js.map +1 -0
- package/dist/roadtrip/roadtrip.esm.js +1 -1
- package/dist/types/components/counter/counter.d.ts +2 -0
- package/dist/types/components/input/input.d.ts +1 -1
- package/hydrate/index.js +61 -45
- package/hydrate/index.mjs +61 -45
- package/package.json +1 -1
- package/dist/roadtrip/p-04913d58.entry.js +0 -2
- package/dist/roadtrip/p-04913d58.entry.js.map +0 -1
- package/dist/roadtrip/p-55897254.entry.js.map +0 -1
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-fee0103c.js');
|
|
6
6
|
|
|
7
|
-
const spinnerCss = ":host{display:
|
|
7
|
+
const spinnerCss = ":host{display:flex}.spinner{transform-origin:center;animation:road-rotate 2s linear infinite}.spinner.spinner--small{width:1rem;height:1rem}.spinner.spinner--medium{width:2rem;height:2rem}.spinner.spinner--large{width:3rem;height:3rem}.spinner.spinner--xl{width:8rem;height:8rem}.spinner-circle{animation:road-dash 1.5s ease-in-out infinite;fill:none;stroke:var(--road-primary);stroke-width:3;stroke-dasharray:1, 200;stroke-dashoffset:0;stroke-linecap:round}.spinner-circle.spinner-circle--dark{stroke:var(--road-grey-0)}.spinner-circle.spinner-circle--light{stroke:var(--road-grey-90)}@keyframes road-rotate{100%{transform:rotate(360deg)}}@keyframes road-dash{0%{stroke-dasharray:1, 200;stroke-dashoffset:0}50%{stroke-dasharray:90, 200;stroke-dashoffset:-35px}100%{stroke-dashoffset:-125px}}";
|
|
8
8
|
const RoadSpinnerStyle0 = spinnerCss;
|
|
9
9
|
|
|
10
10
|
const Spinner = class {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"road-spinner.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,UAAU,GAAG,
|
|
1
|
+
{"file":"road-spinner.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,UAAU,GAAG,0xBAA0xB,CAAC;AAC9yB,0BAAe,UAAU;;MCMZ,OAAO;IALpB;;;;;QAU4B,SAAI,GAAyC,OAAO,CAAC;;;;QAKpD,UAAK,GAAkC,SAAS,CAAC;KAc7E;IAZG,MAAM;QACJ,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,GAAG,oBAAoB,IAAI,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC;QACxF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,GAAG,kCAAkC,IAAI,CAAC,KAAK,EAAE,GAAG,gBAAgB,CAAC;QAG/G,QACEA,kEAAK,KAAK,EAAE,GAAG,SAAS,EAAE,EAAE,OAAO,EAAC,aAAa,IAC/CA,qEAAQ,KAAK,EAAE,GAAG,UAAU,EAAE,EAAE,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,GAAU,CAC5D,EACN;KACH;;;;;;","names":["h"],"sources":["src/components/spinner/spinner.css?tag=road-spinner&encapsulation=shadow","src/components/spinner/spinner.tsx"],"sourcesContent":["/*\n * Spinner\n *\n * Index\n * - Spinner\n * - Circle\n * - Animation\n */\n\n:host {\n display: flex;\n}\n\n/* SPINNER\n -------------------- */\n\n.spinner {\n transform-origin: center;\n animation: road-rotate 2s linear infinite;\n}\n\n.spinner.spinner--small{\n width: 1rem;\n height: 1rem;\n}\n\n.spinner.spinner--medium{\n width: 2rem;\n height: 2rem;\n}\n\n.spinner.spinner--large {\n width: 3rem;\n height: 3rem;\n}\n\n.spinner.spinner--xl {\n width: 8rem;\n height: 8rem;\n}\n\n/* CIRCLE\n -------------------- */\n\n.spinner-circle {\n animation: road-dash 1.5s ease-in-out infinite;\n fill: none;\n stroke: var(--road-primary);\n stroke-width: 3;\n stroke-dasharray: 1, 200;\n stroke-dashoffset: 0;\n stroke-linecap: round;\n}\n\n.spinner-circle.spinner-circle--dark {\n stroke: var(--road-grey-0);\n}\n\n.spinner-circle.spinner-circle--light {\n stroke: var(--road-grey-90);\n}\n\n/* ANIMATION\n -------------------- */\n\n@keyframes road-rotate {\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n@keyframes road-dash {\n\n 0% {\n stroke-dasharray: 1, 200;\n stroke-dashoffset: 0;\n }\n\n 50% {\n stroke-dasharray: 90, 200;\n stroke-dashoffset: -35px;\n }\n\n 100% {\n stroke-dashoffset: -125px;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n@Component({\n tag: 'road-spinner',\n styleUrl: 'spinner.css',\n shadow: true,\n})\nexport class Spinner {\n\n /**\n * The button size.\n */\n @Prop({ reflect: true }) size?: 'small' | 'medium' | 'large' | 'xl' = 'large';\n\n /**\n * The color spinner.\n */\n @Prop({ reflect: true }) color?: 'default' | 'light' | 'dark' = 'default';\n\n render() {\n const sizeClass = this.size !== undefined ? `spinner spinner--${this.size}` : 'spinner';\n const colorClass = this.size !== undefined ? `spinner-circle spinner-circle--${this.color}` : 'spinner-circle';\n\n\n return (\n <svg class={`${sizeClass}`} viewBox=\"25 25 50 50\">\n <circle class={`${colorClass}`} cx=\"50\" cy=\"50\" r=\"20\"></circle>\n </svg>\n );\n }\n\n}\n"],"version":3}
|
|
@@ -108,8 +108,24 @@ export class Counter {
|
|
|
108
108
|
componentWillLoad() {
|
|
109
109
|
this.onValueChange(this.value);
|
|
110
110
|
}
|
|
111
|
+
/** Vérifie et applique le `text-indent` si `prepend` est présent */
|
|
112
|
+
updateIndentation() {
|
|
113
|
+
const hasPrepend = !!this.el.querySelector('[slot="prepend"]');
|
|
114
|
+
const formControl = this.el.querySelector('.form-control');
|
|
115
|
+
const formLabel = this.el.querySelector('.form-label');
|
|
116
|
+
if (formControl) {
|
|
117
|
+
formControl.style.textIndent = hasPrepend ? '' : '';
|
|
118
|
+
}
|
|
119
|
+
if (formLabel) {
|
|
120
|
+
formLabel.style.textIndent = hasPrepend ? '' : '';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
111
123
|
componentDidLoad() {
|
|
112
124
|
const buttons = this.el.querySelectorAll('road-button');
|
|
125
|
+
this.updateIndentation(); // Appliquer les styles au montage
|
|
126
|
+
// Observer les mutations (au cas où des éléments sont ajoutés dynamiquement)
|
|
127
|
+
const observer = new MutationObserver(() => this.updateIndentation());
|
|
128
|
+
observer.observe(this.el, { childList: true, subtree: true });
|
|
113
129
|
// Ajouter les événements pour chaque road-button
|
|
114
130
|
buttons.forEach((btn) => {
|
|
115
131
|
btn.addEventListener('touchstart', () => {
|
|
@@ -138,7 +154,7 @@ export class Counter {
|
|
|
138
154
|
}
|
|
139
155
|
render() {
|
|
140
156
|
const dataCi = this.isDustbinVisible ? "road-dustbin" : "";
|
|
141
|
-
return (h("road-input-group", { key: '
|
|
157
|
+
return (h("road-input-group", { key: '0f8b1b0a35803e52ba57c371654f65069ee24eb1', class: this.size && `counter-${this.size}` }, h("road-button", { key: '769528d0e5b027e1b28cb9ef04b3c8f8c26f34d5', slot: "prepend", size: this.size, onClick: this.decrease, class: this.leftIconClasses, "data-cy": "road-decrease" }, h("road-icon", { key: 'fe666f6455a7dfd2f944df71fdac8fb858dc9d56', name: this.isDustbinVisible ? "delete-forever" : "navigation-add-less", ref: (el) => this.iconCounterLess = el, size: this.size, "data-cy": dataCi, role: "button" })), h("road-input", { key: '315b93bf129f7ae04138f584f060b1c9d5eac6c9', ref: (el) => this.inputElement = el, type: "number", min: this.min.toString(), max: (this.max && this.max.toString()), step: this.step, value: this.value, onRoadChange: this.onRoadChange, onKeyUp: this.checkValue, "data-cy": "road-input-counter", readonly: this.readonly, label: "Quantit\u00E9" }), h("road-button", { key: 'e17851794c015e99c34c8d04bccce046b57bad05', slot: "append", size: this.size, onClick: this.increase, class: this.rightIconClasses, "data-cy": "road-increase" }, h("road-icon", { key: 'e0b4898bdb9bab9f48acf38a4a6a2b31520c955d', name: "navigation-add-more", size: this.size, role: "button" }))));
|
|
142
158
|
}
|
|
143
159
|
static get is() { return "road-counter"; }
|
|
144
160
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../../../src/components/counter/counter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAO/F,MAAM,OAAO,OAAO;IALpB;QAYW,oBAAe,GAAW,EAAE,CAAC;QAC7B,qBAAgB,GAAW,EAAE,CAAC;QAC9B,qBAAgB,GAAY,KAAK,CAAC;QAE3C;;WAEG;QACK,YAAO,GAAW,gBAAgB,UAAU,EAAE,EAAE,CAAC;QAEzD;;WAEG;QACK,QAAG,GAAW,CAAC,CAAC;QAaxB;;WAEG;QACK,UAAK,GAAW,CAAC,CAAC;QAE1B;;WAEG;QACK,SAAI,GAAwB,IA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EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAC,eAAU,GAChB;YACF,oEACE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,KAAK,EAAE,IAAI,CAAC,gBAAgB,aACpB,eAAe;gBAEvB,kEACE,IAAI,EAAC,qBAAqB,EAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAC,QAAQ,GACb,CACU,CACG,CACpB,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,UAAU,GAAG,CAAC,CAAC","sourcesContent":["import { Component, h, Prop, Element, Event, EventEmitter, State, Watch } from '@stencil/core';\n\n@Component({\n tag: 'road-counter',\n styleUrl: 'counter.css',\n scoped: true,\n})\nexport class Counter {\n\n @Element() el!: HTMLRoadCounterElement;\n\n iconCounterLess!: HTMLRoadIconElement;\n inputElement!: HTMLRoadInputElement;\n\n @State() leftIconClasses: string = \"\";\n @State() rightIconClasses: string = \"\";\n @State() isDustbinVisible: boolean = false;\n\n /**\n * The id of counter\n */\n @Prop() inputId: string = `road-counter-${counterIds++}`;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min: number = 0;\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: number;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The value of the counter.\n */\n @Prop() value: number = 1;\n\n /**\n * The size of the counter.\n */\n @Prop() size?: 'sm' | 'md' | 'lg' = \"lg\";\n\n /**\n * Set to `true` to add the dustbin icon if the value is equal to the min.\n */\n @Prop() dustbin: boolean = false;\n\n /**\n * Set to `true` to not modify the input field\n */\n @Prop() readonly: boolean = false;\n\n /**\n * Emitted when the plus button is clicked\n */\n @Event() roadIncrease!: EventEmitter<{\n value: number | undefined | null;\n }>;\n\n /**\n * Emitted when the minus button is clicked\n */\n @Event() roadDecrease!: EventEmitter<{\n value: number | undefined | null;\n }>;\n\n /**\n * Emitted when the minus button is clicked\n */\n @Event() roadChange!: EventEmitter<{\n value: number | undefined | null;\n }>;\n\n /**\n * Emitted when the dustbin is clicked\n */\n @Event() roadDustbinClick!: EventEmitter<void>;\n\n @Watch('value')\n private onValueChange(valueInput: number) {\n this.setIsDustbinVisible(valueInput);\n this.setIconsClasses(valueInput);\n }\n\n private setIconsClasses(valueInput?: number) {\n valueInput = valueInput ?? parseInt(this.inputElement.querySelector('input')!.value as string);\n\n this.leftIconClasses = valueInput <= this.min && !this.dustbin ? \"disabled\" : \"\";\n this.rightIconClasses = this.max && valueInput >= this.max ? \"disabled\" : \"\";\n }\n\n private setIsDustbinVisible = (valueInput: number) => {\n if (valueInput > this.min) {\n this.isDustbinVisible = false;\n } else if (this.dustbin) {\n this.isDustbinVisible = true;\n }\n else {\n this.isDustbinVisible = false;\n }\n }\n\n private increase = () => {\n (this.inputElement as unknown as HTMLInputElement).querySelector('input')!.stepUp();\n let valueInput = parseInt(this.inputElement.querySelector('input')!.value as string);\n if(!valueInput) {\n valueInput = this.min\n };\n this.onValueChange(valueInput);\n this.roadIncrease.emit({ value: valueInput });\n };\n\n private decrease = () => {\n if(this.isDustbinVisible){\n this.roadDustbinClick.emit();\n return;\n }\n\n (this.inputElement as unknown as HTMLInputElement).querySelector('input')!.stepDown();\n\n let valueInput = parseInt(this.inputElement.querySelector('input')!.value as string);\n if(!valueInput) {\n valueInput = this.min\n };\n this.onValueChange(valueInput);\n\n this.roadDecrease.emit({ value: valueInput });\n };\n\n private checkValue = (ev: Event) => {\n const input = ev.target as HTMLInputElement;\n const value = input.value && parseInt(input.value)\n\n if (value == null || value === \"\") return;\n\n if (value < this.min) {\n input.value = this.min.toString()\n }\n else if (this.max && value > this.max) {\n input.value = this.max.toString()\n }\n\n this.onValueChange(parseInt(input.value));\n }\n\n private onRoadChange = (ev: Event) => {\n ev.stopPropagation();\n const input = ev.target as HTMLInputElement;\n const value = input.value && parseInt(input.value)\n if (value !== null && value !== \"\") {\n if (value < this.min) {\n this.roadChange.emit({ value: this.min });\n }\n else if (this.max && value > this.max) {\n this.roadChange.emit({ value: this.max });\n }\n else {\n this.roadChange.emit({ value: parseInt(input.value) });\n }\n }\n else {\n this.roadChange.emit({ value: null });\n }\n };\n\n componentWillLoad() {\n this.onValueChange(this.value);\n }\n\n componentDidLoad() {\n const buttons = this.el.querySelectorAll('road-button') as NodeListOf<HTMLRoadButtonElement>;\n\n // Ajouter les événements pour chaque road-button\n buttons.forEach((btn) => {\n btn.addEventListener('touchstart', () => {\n btn.style.backgroundColor = 'var(--road-button-tertiary-variant)'; // Appliquer le style hover\n });\n \n btn.addEventListener('touchend', () => {\n btn.style.backgroundColor = 'var(--road-surface)'; // Supprimer le style hover après touchend\n });\n });\n\n // Accessibilité : Cacher le label\n const label = this.el.querySelector('.form-label') as HTMLElement;\n const input = this.el.querySelector('.form-control.sc-road-input') as HTMLElement;\n if (label) {\n label.style.clip = 'rect(0 0 0 0)';\n label.style.border = '0';\n label.style.height = '1px';\n label.style.left = '0';\n label.style.margin = '-1px';\n label.style.overflow = 'hidden';\n label.style.padding = '0';\n label.style.position = 'absolute';\n label.style.top = '0';\n label.style.width = '1px';\n\n input.style.padding = '0 1rem 0';\n \n }\n }\n\n render() {\n\n const dataCi = this.isDustbinVisible ? \"road-dustbin\" : \"\";\n\n return (\n <road-input-group\n class={this.size && `counter-${this.size}`}\n >\n <road-button\n slot=\"prepend\"\n size={this.size}\n onClick={this.decrease}\n class={this.leftIconClasses}\n data-cy=\"road-decrease\"\n >\n <road-icon\n name={this.isDustbinVisible ? \"delete-forever\" : \"navigation-add-less\"}\n ref={(el) => this.iconCounterLess = el as HTMLRoadIconElement}\n size={this.size}\n data-cy={dataCi}\n role=\"button\"\n />\n </road-button>\n <road-input\n ref={(el) => this.inputElement = el as HTMLRoadInputElement}\n type=\"number\"\n min={this.min.toString()}\n max={(this.max && this.max.toString()) as string}\n step={this.step}\n value={this.value}\n onRoadChange={this.onRoadChange}\n onKeyUp={this.checkValue}\n data-cy=\"road-input-counter\"\n readonly={this.readonly}\n label=\"Quantité\"\n />\n <road-button\n slot=\"append\"\n size={this.size}\n onClick={this.increase}\n class={this.rightIconClasses}\n data-cy=\"road-increase\"\n >\n <road-icon\n name=\"navigation-add-more\"\n size={this.size}\n role=\"button\"\n />\n </road-button>\n </road-input-group>\n );\n }\n}\n\nlet counterIds = 0;\n"]}
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../../../src/components/counter/counter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAO/F,MAAM,OAAO,OAAO;IALpB;QAYW,oBAAe,GAAW,EAAE,CAAC;QAC7B,qBAAgB,GAAW,EAAE,CAAC;QAC9B,qBAAgB,GAAY,KAAK,CAAC;QAE3C;;WAEG;QACK,YAAO,GAAW,gBAAgB,UAAU,EAAE,EAAE,CAAC;QAEzD;;WAEG;QACK,QAAG,GAAW,CAAC,CAAC;QAaxB;;WAEG;QACK,UAAK,GAAW,CAAC,CAAC;QAE1B;;WAEG;QACK,SAAI,GAAwB,IAAI,CAAC;QAEzC;;UAEE;QACM,YAAO,GAAY,KAAK,CAAC;QAE/B;;QAEA;QACM,aAAQ,GAAY,KAAK,CAAC;QAyC1B,wBAAmB,GAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,UAAU,GAAG,CAAC,CAAC","sourcesContent":["import { Component, h, Prop, Element, Event, EventEmitter, State, Watch } from '@stencil/core';\n\n@Component({\n tag: 'road-counter',\n styleUrl: 'counter.css',\n scoped: true,\n})\nexport class Counter {\n\n @Element() el!: HTMLRoadCounterElement;\n\n iconCounterLess!: HTMLRoadIconElement;\n inputElement!: HTMLRoadInputElement;\n\n @State() leftIconClasses: string = \"\";\n @State() rightIconClasses: string = \"\";\n @State() isDustbinVisible: boolean = false;\n\n /**\n * The id of counter\n */\n @Prop() inputId: string = `road-counter-${counterIds++}`;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min: number = 0;\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: number;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The value of the counter.\n */\n @Prop() value: number = 1;\n\n /**\n * The size of the counter.\n */\n @Prop() size?: 'sm' | 'md' | 'lg' = \"lg\";\n\n /**\n * Set to `true` to add the dustbin icon if the value is equal to the min.\n */\n @Prop() dustbin: boolean = false;\n\n /**\n * Set to `true` to not modify the input field\n */\n @Prop() readonly: boolean = false;\n\n /**\n * Emitted when the plus button is clicked\n */\n @Event() roadIncrease!: EventEmitter<{\n value: number | undefined | null;\n }>;\n\n /**\n * Emitted when the minus button is clicked\n */\n @Event() roadDecrease!: EventEmitter<{\n value: number | undefined | null;\n }>;\n\n /**\n * Emitted when the minus button is clicked\n */\n @Event() roadChange!: EventEmitter<{\n value: number | undefined | null;\n }>;\n\n /**\n * Emitted when the dustbin is clicked\n */\n @Event() roadDustbinClick!: EventEmitter<void>;\n\n @Watch('value')\n private onValueChange(valueInput: number) {\n this.setIsDustbinVisible(valueInput);\n this.setIconsClasses(valueInput);\n }\n\n private setIconsClasses(valueInput?: number) {\n valueInput = valueInput ?? parseInt(this.inputElement.querySelector('input')!.value as string);\n\n this.leftIconClasses = valueInput <= this.min && !this.dustbin ? \"disabled\" : \"\";\n this.rightIconClasses = this.max && valueInput >= this.max ? \"disabled\" : \"\";\n }\n\n private setIsDustbinVisible = (valueInput: number) => {\n if (valueInput > this.min) {\n this.isDustbinVisible = false;\n } else if (this.dustbin) {\n this.isDustbinVisible = true;\n }\n else {\n this.isDustbinVisible = false;\n }\n }\n\n private increase = () => {\n (this.inputElement as unknown as HTMLInputElement).querySelector('input')!.stepUp();\n let valueInput = parseInt(this.inputElement.querySelector('input')!.value as string);\n if(!valueInput) {\n valueInput = this.min\n };\n this.onValueChange(valueInput);\n this.roadIncrease.emit({ value: valueInput });\n };\n\n private decrease = () => {\n if(this.isDustbinVisible){\n this.roadDustbinClick.emit();\n return;\n }\n\n (this.inputElement as unknown as HTMLInputElement).querySelector('input')!.stepDown();\n\n let valueInput = parseInt(this.inputElement.querySelector('input')!.value as string);\n if(!valueInput) {\n valueInput = this.min\n };\n this.onValueChange(valueInput);\n\n this.roadDecrease.emit({ value: valueInput });\n };\n\n private checkValue = (ev: Event) => {\n const input = ev.target as HTMLInputElement;\n const value = input.value && parseInt(input.value)\n\n if (value == null || value === \"\") return;\n\n if (value < this.min) {\n input.value = this.min.toString()\n }\n else if (this.max && value > this.max) {\n input.value = this.max.toString()\n }\n\n this.onValueChange(parseInt(input.value));\n }\n\n private onRoadChange = (ev: Event) => {\n ev.stopPropagation();\n const input = ev.target as HTMLInputElement;\n const value = input.value && parseInt(input.value)\n if (value !== null && value !== \"\") {\n if (value < this.min) {\n this.roadChange.emit({ value: this.min });\n }\n else if (this.max && value > this.max) {\n this.roadChange.emit({ value: this.max });\n }\n else {\n this.roadChange.emit({ value: parseInt(input.value) });\n }\n }\n else {\n this.roadChange.emit({ value: null });\n }\n };\n\n componentWillLoad() {\n this.onValueChange(this.value);\n }\n\n /** Vérifie et applique le `text-indent` si `prepend` est présent */\n private updateIndentation() {\n const hasPrepend = !!this.el.querySelector('[slot=\"prepend\"]');\n const formControl = this.el.querySelector('.form-control') as HTMLElement;\n const formLabel = this.el.querySelector('.form-label') as HTMLElement;\n \n if (formControl) {\n formControl.style.textIndent = hasPrepend ? '' : '';\n }\n if (formLabel) {\n formLabel.style.textIndent = hasPrepend ? '' : '';\n }\n }\n\n componentDidLoad() {\n const buttons = this.el.querySelectorAll('road-button') as NodeListOf<HTMLRoadButtonElement>;\n this.updateIndentation(); // Appliquer les styles au montage\n // Observer les mutations (au cas où des éléments sont ajoutés dynamiquement)\n const observer = new MutationObserver(() => this.updateIndentation());\n observer.observe(this.el, { childList: true, subtree: true });\n\n // Ajouter les événements pour chaque road-button\n buttons.forEach((btn) => {\n btn.addEventListener('touchstart', () => {\n btn.style.backgroundColor = 'var(--road-button-tertiary-variant)'; // Appliquer le style hover\n });\n \n btn.addEventListener('touchend', () => {\n btn.style.backgroundColor = 'var(--road-surface)'; // Supprimer le style hover après touchend\n });\n });\n\n // Accessibilité : Cacher le label\n const label = this.el.querySelector('.form-label') as HTMLElement;\n const input = this.el.querySelector('.form-control.sc-road-input') as HTMLElement;\n if (label) {\n label.style.clip = 'rect(0 0 0 0)';\n label.style.border = '0';\n label.style.height = '1px';\n label.style.left = '0';\n label.style.margin = '-1px';\n label.style.overflow = 'hidden';\n label.style.padding = '0';\n label.style.position = 'absolute';\n label.style.top = '0';\n label.style.width = '1px';\n\n input.style.padding = '0 1rem 0';\n \n }\n }\n\n render() {\n\n const dataCi = this.isDustbinVisible ? \"road-dustbin\" : \"\";\n\n return (\n <road-input-group\n class={this.size && `counter-${this.size}`}\n >\n <road-button\n slot=\"prepend\"\n size={this.size}\n onClick={this.decrease}\n class={this.leftIconClasses}\n data-cy=\"road-decrease\"\n >\n <road-icon\n name={this.isDustbinVisible ? \"delete-forever\" : \"navigation-add-less\"}\n ref={(el) => this.iconCounterLess = el as HTMLRoadIconElement}\n size={this.size}\n data-cy={dataCi}\n role=\"button\"\n />\n </road-button>\n <road-input\n ref={(el) => this.inputElement = el as HTMLRoadInputElement}\n type=\"number\"\n min={this.min.toString()}\n max={(this.max && this.max.toString()) as string}\n step={this.step}\n value={this.value}\n onRoadChange={this.onRoadChange}\n onKeyUp={this.checkValue}\n data-cy=\"road-input-counter\"\n readonly={this.readonly}\n label=\"Quantité\"\n />\n <road-button\n slot=\"append\"\n size={this.size}\n onClick={this.increase}\n class={this.rightIconClasses}\n data-cy=\"road-increase\"\n >\n <road-icon\n name=\"navigation-add-more\"\n size={this.size}\n role=\"button\"\n />\n </road-button>\n </road-input-group>\n );\n }\n}\n\nlet counterIds = 0;\n"]}
|
|
@@ -86,54 +86,57 @@ export class Input {
|
|
|
86
86
|
if (this.type === 'number' && this.blockdecimal) {
|
|
87
87
|
newValue = newValue.replace(/[.,]/g, ''); // Supprime les décimales si `blockdecimal` est activé
|
|
88
88
|
}
|
|
89
|
-
// Convertir en nombre et ajuster selon min/max
|
|
90
|
-
let numericValue = parseFloat(newValue);
|
|
91
|
-
const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;
|
|
92
|
-
const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;
|
|
93
|
-
if (!isNaN(numericValue)) {
|
|
94
|
-
if (minValue !== undefined && numericValue < minValue) {
|
|
95
|
-
numericValue = minValue;
|
|
96
|
-
}
|
|
97
|
-
if (maxValue !== undefined && numericValue > maxValue) {
|
|
98
|
-
numericValue = maxValue;
|
|
99
|
-
}
|
|
100
|
-
newValue = numericValue.toString();
|
|
101
|
-
}
|
|
102
89
|
if (this.type === 'number') {
|
|
90
|
+
// Convertir en nombre et ajuster selon min/max
|
|
91
|
+
let numericValue = parseFloat(newValue);
|
|
92
|
+
const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;
|
|
93
|
+
const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;
|
|
94
|
+
if (!isNaN(numericValue)) {
|
|
95
|
+
if (minValue !== undefined && numericValue < minValue) {
|
|
96
|
+
numericValue = minValue;
|
|
97
|
+
}
|
|
98
|
+
if (maxValue !== undefined && numericValue > maxValue) {
|
|
99
|
+
numericValue = maxValue;
|
|
100
|
+
}
|
|
101
|
+
newValue = numericValue.toString();
|
|
102
|
+
input.value = newValue; // Force l'affichage de la valeur max
|
|
103
|
+
ev.preventDefault(); // Empêche la saisie supplémentaire
|
|
104
|
+
}
|
|
103
105
|
this.value = newValue;
|
|
104
|
-
input.value = newValue; // Mise à jour immédiate du champ
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
// Vérification si la valeur a réellement changé avant de la mettre à jour
|
|
108
|
+
if (this.value !== newValue) {
|
|
107
109
|
this.value = newValue;
|
|
110
|
+
this.roadInput.emit(ev);
|
|
108
111
|
}
|
|
109
|
-
this.roadInput.emit(ev);
|
|
110
|
-
this.roadChange.emit({ value: newValue });
|
|
111
112
|
// Appeler enforceMinMaxValue à chaque modification de la valeur
|
|
112
113
|
this.enforceMinMaxValue();
|
|
113
114
|
};
|
|
114
115
|
this.onBlur = () => {
|
|
115
116
|
let value = this.getValue();
|
|
116
|
-
const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;
|
|
117
|
-
const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;
|
|
118
|
-
let numericValue = parseFloat(value);
|
|
119
|
-
if (!isNaN(numericValue)) {
|
|
120
|
-
if (minValue !== undefined && numericValue < minValue) {
|
|
121
|
-
numericValue = minValue;
|
|
122
|
-
}
|
|
123
|
-
if (maxValue !== undefined && numericValue > maxValue) {
|
|
124
|
-
numericValue = maxValue;
|
|
125
|
-
}
|
|
126
|
-
value = numericValue.toString();
|
|
127
|
-
}
|
|
128
117
|
if (this.type === 'number') {
|
|
118
|
+
const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;
|
|
119
|
+
const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;
|
|
120
|
+
let numericValue = parseFloat(value);
|
|
121
|
+
if (!isNaN(numericValue)) {
|
|
122
|
+
if (minValue !== undefined && numericValue < minValue) {
|
|
123
|
+
numericValue = minValue;
|
|
124
|
+
}
|
|
125
|
+
if (maxValue !== undefined && numericValue > maxValue) {
|
|
126
|
+
numericValue = maxValue;
|
|
127
|
+
}
|
|
128
|
+
value = numericValue.toString();
|
|
129
|
+
}
|
|
129
130
|
this.value = value;
|
|
130
131
|
const input = document.getElementById(this.inputId);
|
|
131
132
|
input.value = value;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
+
// Vérification si la valeur a changé avant mise à jour
|
|
135
|
+
if (this.value !== value) {
|
|
134
136
|
this.value = value;
|
|
137
|
+
this.roadBlur.emit(value);
|
|
138
|
+
this.roadChange.emit({ value });
|
|
135
139
|
}
|
|
136
|
-
this.roadBlur.emit(value);
|
|
137
140
|
// Appeler enforceMinMaxValue lors de la perte de focus
|
|
138
141
|
this.enforceMinMaxValue();
|
|
139
142
|
};
|
|
@@ -161,10 +164,10 @@ export class Input {
|
|
|
161
164
|
/**
|
|
162
165
|
* Update the native input element when the value changes
|
|
163
166
|
*/
|
|
164
|
-
valueChanged() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
valueChanged(newValue, oldValue) {
|
|
168
|
+
if (newValue !== oldValue) {
|
|
169
|
+
this.debouncedRoadChange(newValue);
|
|
170
|
+
}
|
|
168
171
|
}
|
|
169
172
|
async enforceMinMaxValue() {
|
|
170
173
|
let value = this.getValue();
|
|
@@ -180,12 +183,9 @@ export class Input {
|
|
|
180
183
|
}
|
|
181
184
|
value = numericValue.toString();
|
|
182
185
|
}
|
|
183
|
-
if (this.type === 'number') {
|
|
184
|
-
this.value = value;
|
|
185
|
-
const input = document.getElementById(this.inputId);
|
|
186
|
-
input.value = value;
|
|
186
|
+
if (this.type === 'number' && this.value !== value) {
|
|
187
|
+
this.value = value; // Déclenche @Watch('value')
|
|
187
188
|
}
|
|
188
|
-
this.roadChange.emit({ value });
|
|
189
189
|
}
|
|
190
190
|
getValue() {
|
|
191
191
|
return typeof this.value === 'number'
|
|
@@ -201,7 +201,7 @@ export class Input {
|
|
|
201
201
|
const hasValueClass = this.value !== '' && this.value !== null ? 'has-value' : '';
|
|
202
202
|
const lessLabelClass = this.label !== '' ? '' : 'less-label';
|
|
203
203
|
const isInvalidClass = this.error !== undefined && this.error !== '' ? 'is-invalid' : '';
|
|
204
|
-
return (h(Host, { key: '
|
|
204
|
+
return (h(Host, { key: 'e8296b902967681ad3483560e720236c98dc4f9f', "aria-disabled": this.disabled ? 'true' : null, class: this.sizes && `input-${this.sizes}`, value: value, blockdecimal: this.blockdecimal }, h("input", { key: '8ad175738f8fca4ca345aff156e3124db00afbdf', class: `form-control ${hasValueClass} ${isInvalidClass} ${lessLabelClass}`, id: this.inputId, "aria-disabled": this.disabled ? 'true' : null, "aria-labelledby": labelId, disabled: this.disabled, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, enterKeyHint: this.enterkeyhint, autoFocus: this.autofocus, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, name: this.name, pattern: this.pattern, placeholder: this.placeholder, readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.type === 'number' ? (event) => this.handleKeyDown(event) : undefined, "data-cy": 'road-input' }), h("label", { key: 'f9e63512f533d2cf89a8bbfd6fffd8824a721211', class: "form-label", id: labelId, htmlFor: this.inputId }, this.label), this.error && this.error !== '' && h("p", { key: 'ec34468bc61c42943ee5b275081e02be859e45e2', class: "invalid-feedback" }, h("road-icon", { key: '83204d0fecc77eb3d8e8bc9697cd9bfc7ddb3be5', slot: "start", name: "alert-error-solid", "aria-hidden": "true", size: "sm" }), this.error), this.helper && this.helper !== '' && h("p", { key: 'b639735e1508e1aac0ba5800edf9649fb1847155', class: "helper" }, this.helper), this.type && this.type == 'password' && h("slot", { key: 'c33c73bc53ae22f3b3bd97021a5c4f320cff89f9', name: "checklistPassword" })));
|
|
205
205
|
}
|
|
206
206
|
static get is() { return "road-input"; }
|
|
207
207
|
static get encapsulation() { return "scoped"; }
|
|
@@ -869,10 +869,6 @@ export class Input {
|
|
|
869
869
|
"Promise": {
|
|
870
870
|
"location": "global",
|
|
871
871
|
"id": "global::Promise"
|
|
872
|
-
},
|
|
873
|
-
"HTMLInputElement": {
|
|
874
|
-
"location": "global",
|
|
875
|
-
"id": "global::HTMLInputElement"
|
|
876
872
|
}
|
|
877
873
|
},
|
|
878
874
|
"return": "Promise<void>"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGpD;;;;;;;;;;;;GAYG;AAOH,MAAM,OAAO,KAAK;IALlB;QAME;;WAEG;QACK,YAAO,GAAW,cAAc,QAAQ,EAAE,EAAE,CAAC;QAErD;;WAEG;QACK,mBAAc,GAAG,KAAK,CAAC;QAE/B;;WAEG;QACK,iBAAY,GAAsB,KAAK,CAAC;QAEhD;;WAEG;QACK,iBAAY,GAAG,KAAK,CAAC;QAG7B;;WAEG;QACK,gBAAW,GAAiB,KAAK,CAAC;QAE1C;;WAEG;QACK,cAAS,GAAG,KAAK,CAAC;QAE1B;;WAEG;QACK,aAAQ,GAAG,KAAK,CAAC;QAmCzB;;WAEG;QACK,SAAI,GAAW,IAAI,CAAC,OAAO,CAAC;QAYpC;;WAEG;QACK,aAAQ,GAAG,KAAK,CAAC;QAEzB;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,QAAQ,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h, Method } from '@stencil/core';\nimport { debounce as lodashDebounce } from 'lodash';\nimport { AutocompleteTypes, TextFieldTypes } from '../../interface';\n\n/**\n * @slot checklistPassword - Content the checklist Password exemple.\n * `<div class=\"checklist-password mt-16\" slot=\"checklistPassword\">`\n * `<span class=\"checklist-password-label\"><strong>Low Safety</strong></span>`\n * `<road-progress color=\"danger\" value=\"25\" class=\"mt-8 mb-16\"></road-progress>`\n * `<p class=\"text-medium mb-8\">For optimal safety your password must have at least :</p>`\n * `<ul class=\"m-0 pl-16\">`\n * `<li id=\"letter\" class=\"invalid mb-8\">1 lowercase and 1 uppercase</li>`\n * `<li id=\"number\" class=\"invalid mb-8\">1 digit</li>`\n * `<li id=\"length\" class=\"invalid\">8 characters minimum</li>`\n * `</ul>`\n * `</div>`\n */\n\n@Component({\n tag: 'road-input',\n styleUrl: 'input.css',\n scoped: true,\n})\nexport class Input {\n /**\n * The id of input\n */\n @Prop() inputId: string = `road-input-${inputIds++}`;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalize = 'off';\n\n /**\n * Indicates whether the value of the control can be automatically completed by the browser.\n */\n @Prop() autocomplete: AutocompleteTypes = 'off';\n\n /**\n * If `true`, block decimal.\n */\n @Prop() blockdecimal = false;\n\n\n /**\n * Whether auto correction should be enabled when the user is entering/editing the text value.\n */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, the user cannot interact with the input.\n */\n @Prop() disabled = false;\n\n /**\n * A hint to the browser for which enter key to display.\n * Possible values: `\"enter\"`, `\"done\"`, `\"go\"`, `\"next\"`,\n * `\"previous\"`, `\"search\"`, and `\"send\"`.\n */\n @Prop() enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n\n /**\n * A hint to the browser for which keyboard to display.\n * This attribute applies when the value of the type attribute is `\"text\"`, `\"password\"`, `\"email\"`, or `\"url\"`. Possible values are: `\"verbatim\"`, `\"latin\"`, `\"latin-name\"`, `\"latin-prose\"`, `\"full-width-latin\"`, `\"kana\"`, `\"katakana\"`, `\"numeric\"`, `\"tel\"`, `\"email\"`, `\"url\"`.\n */\n @Prop() inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * A regular expression that the value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() pattern?: string;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop() readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The initial size of the control. This value is in pixels unless the value of the type attribute is `\"text\"` or `\"password\"`, in which case it is an integer number of characters. This attribute applies only when the `type` attribute is set to `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() size?: number;\n\n /**\n * The sizes of the input.\n */\n @Prop() sizes: 'lg' | 'xl' = 'lg';\n\n /**\n * The type of control to display. The default type is text.\n */\n @Prop() type: TextFieldTypes = 'text';\n\n /**\n * The value of the input.(for dynamic use use v-model for vue instead)\n */\n @Prop({ mutable: true }) value?: string | number | null = '';\n\n /**\n * Label for the field\n */\n @Prop() label?: string = '';\n\n /**\n * Error message for the field\n */\n @Prop() error?: string;\n\n /**\n * Helper message for the field\n */\n @Prop() helper?: string;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `roadChange` event after each keystroke.\n */\n @Prop() debounce = 0;\n\n private handleKeyDown(event: KeyboardEvent) {\n if (this.type === 'number' && this.blockdecimal) {\n const forbiddenKeys = ['.', ',', 'e', '-', '¨', '^', '`', '+'];\n if (forbiddenKeys.includes(event.key)) {\n event.preventDefault();\n }\n }\n }\n\n\n private debouncedRoadChange = this.createDebouncedRoadChange();\n\n private createDebouncedRoadChange() {\n return lodashDebounce((value: any) => {\n this.roadChange.emit({ value: value == null ? value : value.toString() });\n }, this.debounce);\n }\n\n @Watch('debounce')\n debounceChanged() {\n // Créez une nouvelle fonction debouncedRoadChange avec la nouvelle valeur de debounce\n this.debouncedRoadChange = this.createDebouncedRoadChange();\n }\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n this.debouncedRoadChange(this.value);\n // Appeler enforceMinMaxValue après chaque changement de valeur\n this.enforceMinMaxValue();\n }\n\n @Method()\n async enforceMinMaxValue() {\n let value = this.getValue();\n\n const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;\n const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;\n let numericValue = parseFloat(value);\n\n if (!isNaN(numericValue)) {\n if (minValue !== undefined && numericValue < minValue) {\n numericValue = minValue;\n }\n if (maxValue !== undefined && numericValue > maxValue) {\n numericValue = maxValue;\n }\n value = numericValue.toString();\n }\n\n if (this.type === 'number') {\n this.value = value;\n const input = document.getElementById(this.inputId) as HTMLInputElement;\n input.value = value;\n }\n\n this.roadChange.emit({ value });\n }\n\n /**\n * Emitted when a keyboard input occurred.\n */\n\n /** @internal */\n @Event() roadInput!: EventEmitter<KeyboardEvent>;\n\n /**\n * Emitted when the value has changed.\n */\n\n /** @internal */\n @Event() roadChange!: EventEmitter<{\n value: string | undefined | null;\n }>;\n\n /**\n * Emitted when the input loses focus.\n */\n\n /** @internal */\n @Event() roadBlur!: EventEmitter<string | null>;\n\n /**\n * Emitted when the input has focus.\n */\n\n /** @internal */\n @Event() roadFocus!: EventEmitter<void>;\n\n\n\n\n\n private getValue(): string {\n return typeof this.value === 'number'\n ? this.value.toString()\n : (this.value || '').toString();\n }\n\n private onInput = (ev: Event) => {\n const input = ev.target as HTMLInputElement;\n let newValue = input.value;\n \n if (this.type === 'number' && this.blockdecimal) {\n newValue = newValue.replace(/[.,]/g, ''); // Supprime les décimales si `blockdecimal` est activé\n }\n \n // Convertir en nombre et ajuster selon min/max\n let numericValue = parseFloat(newValue);\n const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;\n const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;\n \n if (!isNaN(numericValue)) {\n if (minValue !== undefined && numericValue < minValue) {\n numericValue = minValue;\n }\n if (maxValue !== undefined && numericValue > maxValue) {\n numericValue = maxValue;\n }\n newValue = numericValue.toString();\n }\n \n if (this.type === 'number') {\n this.value = newValue;\n input.value = newValue; // Mise à jour immédiate du champ\n }\n else{\n this.value = newValue;\n }\n \n this.roadInput.emit(ev as KeyboardEvent);\n this.roadChange.emit({ value: newValue });\n\n // Appeler enforceMinMaxValue à chaque modification de la valeur\n this.enforceMinMaxValue();\n }; \n \n\n private onBlur = () => {\n let value = this.getValue();\n \n const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;\n const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;\n let numericValue = parseFloat(value);\n \n if (!isNaN(numericValue)) {\n if (minValue !== undefined && numericValue < minValue) {\n numericValue = minValue;\n }\n if (maxValue !== undefined && numericValue > maxValue) {\n numericValue = maxValue;\n }\n value = numericValue.toString();\n }\n \n if (this.type === 'number') {\n this.value = value;\n const input = document.getElementById(this.inputId) as HTMLInputElement;\n input.value = value;\n }else{\n this.value = value;\n }\n \n this.roadBlur.emit(value);\n \n // Appeler enforceMinMaxValue lors de la perte de focus\n this.enforceMinMaxValue();\n };\n \n\n private onFocus = () => {\n this.roadFocus.emit();\n };\n\n\n\n componentWillLoad() {\n this.debounceChanged(); // Initialize debounce on component load\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-label';\n const hasValueClass = this.value !== '' && this.value !== null ? 'has-value' : '';\n const lessLabelClass = this.label !== '' ? '' : 'less-label';\n const isInvalidClass = this.error !== undefined && this.error !== '' ? 'is-invalid' : '';\n\n return (\n <Host aria-disabled={this.disabled ? 'true' : null} class={this.sizes && `input-${this.sizes}`} value={value} blockdecimal={this.blockdecimal}>\n <input\n class={`form-control ${hasValueClass} ${isInvalidClass} ${lessLabelClass}`}\n id={this.inputId}\n aria-disabled={this.disabled ? 'true' : null}\n aria-labelledby={labelId}\n disabled={this.disabled}\n autoCapitalize={this.autocapitalize}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n enterKeyHint={this.enterkeyhint}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n min={this.min}\n max={this.max}\n minLength={this.minlength}\n maxLength={this.maxlength}\n name={this.name}\n pattern={this.pattern}\n placeholder={this.placeholder}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n step={this.step}\n size={this.size}\n type={this.type}\n value={value}\n onInput={this.onInput}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n onKeyDown={this.type === 'number' ? (event: KeyboardEvent) => this.handleKeyDown(event) : undefined}\n data-cy='road-input'\n />\n <label class=\"form-label\" id={labelId} htmlFor={this.inputId}>{this.label}</label>\n {this.error && this.error !== '' && <p class=\"invalid-feedback\"><road-icon slot=\"start\" name=\"alert-error-solid\" aria-hidden=\"true\" size=\"sm\"></road-icon>{this.error}</p>}\n {this.helper && this.helper !== '' && <p class=\"helper\">{this.helper}</p>}\n {this.type && this.type == 'password' && <slot name=\"checklistPassword\" />}\n </Host>\n );\n }\n}\n\nlet inputIds = 0;\n"]}
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGpD;;;;;;;;;;;;GAYG;AAOH,MAAM,OAAO,KAAK;IALlB;QAME;;WAEG;QACK,YAAO,GAAW,cAAc,QAAQ,EAAE,EAAE,CAAC;QAErD;;WAEG;QACK,mBAAc,GAAG,KAAK,CAAC;QAE/B;;WAEG;QACK,iBAAY,GAAsB,KAAK,CAAC;QAEhD;;WAEG;QACK,iBAAY,GAAG,KAAK,CAAC;QAG7B;;WAEG;QACK,gBAAW,GAAiB,KAAK,CAAC;QAE1C;;WAEG;QACK,cAAS,GAAG,KAAK,CAAC;QAE1B;;WAEG;QACK,aAAQ,GAAG,KAAK,CAAC;QAmCzB;;WAEG;QACK,SAAI,GAAW,IAAI,CAAC,OAAO,CAAC;Q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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,QAAQ,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h, Method } from '@stencil/core';\nimport { debounce as lodashDebounce } from 'lodash';\nimport { AutocompleteTypes, TextFieldTypes } from '../../interface';\n\n/**\n * @slot checklistPassword - Content the checklist Password exemple.\n * `<div class=\"checklist-password mt-16\" slot=\"checklistPassword\">`\n * `<span class=\"checklist-password-label\"><strong>Low Safety</strong></span>`\n * `<road-progress color=\"danger\" value=\"25\" class=\"mt-8 mb-16\"></road-progress>`\n * `<p class=\"text-medium mb-8\">For optimal safety your password must have at least :</p>`\n * `<ul class=\"m-0 pl-16\">`\n * `<li id=\"letter\" class=\"invalid mb-8\">1 lowercase and 1 uppercase</li>`\n * `<li id=\"number\" class=\"invalid mb-8\">1 digit</li>`\n * `<li id=\"length\" class=\"invalid\">8 characters minimum</li>`\n * `</ul>`\n * `</div>`\n */\n\n@Component({\n tag: 'road-input',\n styleUrl: 'input.css',\n scoped: true,\n})\nexport class Input {\n /**\n * The id of input\n */\n @Prop() inputId: string = `road-input-${inputIds++}`;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalize = 'off';\n\n /**\n * Indicates whether the value of the control can be automatically completed by the browser.\n */\n @Prop() autocomplete: AutocompleteTypes = 'off';\n\n /**\n * If `true`, block decimal.\n */\n @Prop() blockdecimal = false;\n\n\n /**\n * Whether auto correction should be enabled when the user is entering/editing the text value.\n */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, the user cannot interact with the input.\n */\n @Prop() disabled = false;\n\n /**\n * A hint to the browser for which enter key to display.\n * Possible values: `\"enter\"`, `\"done\"`, `\"go\"`, `\"next\"`,\n * `\"previous\"`, `\"search\"`, and `\"send\"`.\n */\n @Prop() enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n\n /**\n * A hint to the browser for which keyboard to display.\n * This attribute applies when the value of the type attribute is `\"text\"`, `\"password\"`, `\"email\"`, or `\"url\"`. Possible values are: `\"verbatim\"`, `\"latin\"`, `\"latin-name\"`, `\"latin-prose\"`, `\"full-width-latin\"`, `\"kana\"`, `\"katakana\"`, `\"numeric\"`, `\"tel\"`, `\"email\"`, `\"url\"`.\n */\n @Prop() inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * A regular expression that the value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() pattern?: string;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop() readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The initial size of the control. This value is in pixels unless the value of the type attribute is `\"text\"` or `\"password\"`, in which case it is an integer number of characters. This attribute applies only when the `type` attribute is set to `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() size?: number;\n\n /**\n * The sizes of the input.\n */\n @Prop() sizes: 'lg' | 'xl' = 'lg';\n\n /**\n * The type of control to display. The default type is text.\n */\n @Prop() type: TextFieldTypes = 'text';\n\n /**\n * The value of the input.(for dynamic use use v-model for vue instead)\n */\n @Prop({ mutable: true }) value?: string | number | null = '';\n\n /**\n * Label for the field\n */\n @Prop() label?: string = '';\n\n /**\n * Error message for the field\n */\n @Prop() error?: string;\n\n /**\n * Helper message for the field\n */\n @Prop() helper?: string;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `roadChange` event after each keystroke.\n */\n @Prop() debounce = 0;\n\n private handleKeyDown(event: KeyboardEvent) {\n if (this.type === 'number' && this.blockdecimal) {\n const forbiddenKeys = ['.', ',', 'e', '-', '¨', '^', '`', '+'];\n if (forbiddenKeys.includes(event.key)) {\n event.preventDefault();\n }\n }\n }\n\n\n private debouncedRoadChange = this.createDebouncedRoadChange();\n\n private createDebouncedRoadChange() {\n return lodashDebounce((value: any) => {\n this.roadChange.emit({ value: value == null ? value : value.toString() });\n }, this.debounce);\n }\n\n @Watch('debounce')\n debounceChanged() {\n // Créez une nouvelle fonction debouncedRoadChange avec la nouvelle valeur de debounce\n this.debouncedRoadChange = this.createDebouncedRoadChange();\n }\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged(newValue: string | number | null, oldValue: string | number | null) {\n if (newValue !== oldValue) {\n this.debouncedRoadChange(newValue);\n }\n }\n\n @Method()\n async enforceMinMaxValue() {\n let value = this.getValue();\n\n const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;\n const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;\n let numericValue = parseFloat(value);\n\n if (!isNaN(numericValue)) {\n if (minValue !== undefined && numericValue < minValue) {\n numericValue = minValue;\n }\n if (maxValue !== undefined && numericValue > maxValue) {\n numericValue = maxValue;\n }\n value = numericValue.toString();\n }\n\n if (this.type === 'number' && this.value !== value) {\n this.value = value; // Déclenche @Watch('value')\n }\n }\n\n /**\n * Emitted when a keyboard input occurred.\n */\n\n /** @internal */\n @Event() roadInput!: EventEmitter<KeyboardEvent>;\n\n /**\n * Emitted when the value has changed.\n */\n\n /** @internal */\n @Event() roadChange!: EventEmitter<{\n value: string | undefined | null;\n }>;\n\n /**\n * Emitted when the input loses focus.\n */\n\n /** @internal */\n @Event() roadBlur!: EventEmitter<string | null>;\n\n /**\n * Emitted when the input has focus.\n */\n\n /** @internal */\n @Event() roadFocus!: EventEmitter<void>;\n\n\n\n\n\n private getValue(): string {\n return typeof this.value === 'number'\n ? this.value.toString()\n : (this.value || '').toString();\n }\n\n private onInput = (ev: Event) => {\n const input = ev.target as HTMLInputElement;\n let newValue = input.value;\n \n if (this.type === 'number' && this.blockdecimal) {\n newValue = newValue.replace(/[.,]/g, ''); // Supprime les décimales si `blockdecimal` est activé\n }\n \n\n\n \n if (this.type === 'number') {\n // Convertir en nombre et ajuster selon min/max\n let numericValue = parseFloat(newValue);\n const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;\n const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;\n \n if (!isNaN(numericValue)) {\n if (minValue !== undefined && numericValue < minValue) {\n numericValue = minValue;\n }\n if (maxValue !== undefined && numericValue > maxValue) {\n numericValue = maxValue;\n }\n newValue = numericValue.toString();\n input.value = newValue; // Force l'affichage de la valeur max\n ev.preventDefault(); // Empêche la saisie supplémentaire\n }\n this.value = newValue;\n }\n \n // Vérification si la valeur a réellement changé avant de la mettre à jour\n if (this.value !== newValue) {\n this.value = newValue;\n this.roadInput.emit(ev as KeyboardEvent);\n }\n\n // Appeler enforceMinMaxValue à chaque modification de la valeur\n this.enforceMinMaxValue();\n }; \n \n\n private onBlur = () => {\n let value = this.getValue();\n \n \n \n if (this.type === 'number') {\n const minValue = this.min !== undefined ? parseFloat(this.min) : undefined;\n const maxValue = this.max !== undefined ? parseFloat(this.max) : undefined;\n let numericValue = parseFloat(value);\n \n if (!isNaN(numericValue)) {\n if (minValue !== undefined && numericValue < minValue) {\n numericValue = minValue;\n }\n if (maxValue !== undefined && numericValue > maxValue) {\n numericValue = maxValue;\n }\n value = numericValue.toString();\n }\n this.value = value;\n const input = document.getElementById(this.inputId) as HTMLInputElement;\n input.value = value;\n }\n \n // Vérification si la valeur a changé avant mise à jour\n if (this.value !== value) {\n this.value = value;\n this.roadBlur.emit(value);\n this.roadChange.emit({ value });\n }\n \n // Appeler enforceMinMaxValue lors de la perte de focus\n this.enforceMinMaxValue();\n };\n \n\n private onFocus = () => {\n this.roadFocus.emit();\n };\n\n\n\n componentWillLoad() {\n this.debounceChanged(); // Initialize debounce on component load\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-label';\n const hasValueClass = this.value !== '' && this.value !== null ? 'has-value' : '';\n const lessLabelClass = this.label !== '' ? '' : 'less-label';\n const isInvalidClass = this.error !== undefined && this.error !== '' ? 'is-invalid' : '';\n\n return (\n <Host aria-disabled={this.disabled ? 'true' : null} class={this.sizes && `input-${this.sizes}`} value={value} blockdecimal={this.blockdecimal}>\n <input\n class={`form-control ${hasValueClass} ${isInvalidClass} ${lessLabelClass}`}\n id={this.inputId}\n aria-disabled={this.disabled ? 'true' : null}\n aria-labelledby={labelId}\n disabled={this.disabled}\n autoCapitalize={this.autocapitalize}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n enterKeyHint={this.enterkeyhint}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n min={this.min}\n max={this.max}\n minLength={this.minlength}\n maxLength={this.maxlength}\n name={this.name}\n pattern={this.pattern}\n placeholder={this.placeholder}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n step={this.step}\n size={this.size}\n type={this.type}\n value={value}\n onInput={this.onInput}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n onKeyDown={this.type === 'number' ? (event: KeyboardEvent) => this.handleKeyDown(event) : undefined}\n data-cy='road-input'\n />\n <label class=\"form-label\" id={labelId} htmlFor={this.inputId}>{this.label}</label>\n {this.error && this.error !== '' && <p class=\"invalid-feedback\"><road-icon slot=\"start\" name=\"alert-error-solid\" aria-hidden=\"true\" size=\"sm\"></road-icon>{this.error}</p>}\n {this.helper && this.helper !== '' && <p class=\"helper\">{this.helper}</p>}\n {this.type && this.type == 'password' && <slot name=\"checklistPassword\" />}\n </Host>\n );\n }\n}\n\nlet inputIds = 0;\n"]}
|