@roadtrip/components 3.10.0 → 3.10.1
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/_commonjsHelpers-1fbbf0eb.js +23 -0
- package/dist/cjs/_commonjsHelpers-1fbbf0eb.js.map +1 -0
- package/dist/cjs/{focus-visible-a5d1ccf9.js → focus-visible-6771892b.js} +6 -20
- package/dist/cjs/focus-visible-6771892b.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{polyfill-c7a0fa22.js → polyfill-9453e116.js} +2 -2
- package/dist/cjs/{polyfill-c7a0fa22.js.map → polyfill-9453e116.js.map} +1 -1
- package/dist/cjs/road-accordion.cjs.entry.js +1 -1
- package/dist/cjs/road-area-code.cjs.entry.js +23 -2
- package/dist/cjs/road-area-code.cjs.entry.js.map +1 -1
- package/dist/cjs/road-badge_14.cjs.entry.js +5 -3
- package/dist/cjs/road-badge_14.cjs.entry.js.map +1 -1
- package/dist/cjs/road-button-floating.cjs.entry.js +1 -1
- package/dist/cjs/road-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/road-chip.cjs.entry.js +1 -1
- package/dist/cjs/road-global-navigation.cjs.entry.js +1 -1
- package/dist/cjs/road-illustration.cjs.entry.js +4 -71
- package/dist/cjs/road-illustration.cjs.entry.js.map +1 -1
- package/dist/cjs/road-navbar.cjs.entry.js +1 -1
- package/dist/cjs/road-phone-number-input.cjs.entry.js +1269 -5692
- package/dist/cjs/road-phone-number-input.cjs.entry.js.map +1 -1
- package/dist/cjs/road-radio.cjs.entry.js +1 -1
- package/dist/cjs/road-segmented-button-bar.cjs.entry.js +1 -1
- package/dist/cjs/road-switch.cjs.entry.js +1 -1
- package/dist/cjs/road-tab-bar.cjs.entry.js +1 -1
- package/dist/cjs/road-tag.cjs.entry.js +1 -1
- package/dist/cjs/road-toggle.cjs.entry.js +1 -1
- package/dist/cjs/roadtrip.cjs.js +1 -1
- package/dist/cjs/utils-5203d152.js +82 -0
- package/dist/cjs/utils-5203d152.js.map +1 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/area-code/area-code.css +64 -40
- package/dist/collection/components/area-code/area-code.js +65 -4
- package/dist/collection/components/area-code/area-code.js.map +1 -1
- package/dist/collection/components/button/button.css +36 -1
- package/dist/collection/components/button/button.js +22 -1
- package/dist/collection/components/button/button.js.map +1 -1
- package/dist/collection/components/button/button.stories.js +13 -0
- package/dist/collection/components/phone-number-input/phone-number-input.css +0 -5
- package/dist/collection/components/phone-number-input/phone-number-input.js +128 -62
- package/dist/collection/components/phone-number-input/phone-number-input.js.map +1 -1
- package/dist/collection/components/phone-number-input/phone-number-input.stories.js +11 -5
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/esm/_commonjsHelpers-8a9f3b18.js +19 -0
- package/dist/esm/_commonjsHelpers-8a9f3b18.js.map +1 -0
- package/dist/esm/{focus-visible-0fc6119c.js → focus-visible-75a2ea2a.js} +3 -17
- package/dist/esm/focus-visible-75a2ea2a.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/polyfill-ab80527b.js +7 -0
- package/dist/esm/{polyfill-2b159e86.js.map → polyfill-ab80527b.js.map} +1 -1
- package/dist/esm/road-accordion.entry.js +1 -1
- package/dist/esm/road-area-code.entry.js +23 -2
- package/dist/esm/road-area-code.entry.js.map +1 -1
- package/dist/esm/road-badge_14.entry.js +5 -3
- package/dist/esm/road-badge_14.entry.js.map +1 -1
- package/dist/esm/road-button-floating.entry.js +1 -1
- package/dist/esm/road-checkbox.entry.js +1 -1
- package/dist/esm/road-chip.entry.js +1 -1
- package/dist/esm/road-global-navigation.entry.js +1 -1
- package/dist/esm/road-illustration.entry.js +2 -69
- package/dist/esm/road-illustration.entry.js.map +1 -1
- package/dist/esm/road-navbar.entry.js +1 -1
- package/dist/esm/road-phone-number-input.entry.js +1269 -5692
- package/dist/esm/road-phone-number-input.entry.js.map +1 -1
- package/dist/esm/road-radio.entry.js +1 -1
- package/dist/esm/road-segmented-button-bar.entry.js +1 -1
- package/dist/esm/road-switch.entry.js +1 -1
- package/dist/esm/road-tab-bar.entry.js +1 -1
- package/dist/esm/road-tag.entry.js +1 -1
- package/dist/esm/road-toggle.entry.js +1 -1
- package/dist/esm/roadtrip.js +1 -1
- package/dist/esm/utils-ff713b72.js +77 -0
- package/dist/esm/utils-ff713b72.js.map +1 -0
- package/dist/html.html-data.json +18 -2
- package/dist/roadtrip/index.esm.js +1 -1
- package/dist/roadtrip/{p-f0e8feac.entry.js → p-093973f5.entry.js} +2 -2
- package/dist/roadtrip/{p-3237c0d8.entry.js → p-0bcf6d63.entry.js} +2 -2
- package/dist/roadtrip/{p-9077915a.entry.js → p-198f586b.entry.js} +2 -2
- package/dist/roadtrip/{p-c784a407.entry.js → p-439e1124.entry.js} +2 -2
- package/dist/roadtrip/{p-4b54f8e8.entry.js → p-4fd8c4db.entry.js} +2 -2
- package/dist/roadtrip/{p-10856fef.entry.js → p-564f4f31.entry.js} +2 -2
- package/dist/roadtrip/p-5f9e6c1c.entry.js +2 -0
- package/dist/roadtrip/p-5f9e6c1c.entry.js.map +1 -0
- package/dist/roadtrip/p-6598e293.entry.js +2 -0
- package/dist/roadtrip/p-6598e293.entry.js.map +1 -0
- package/dist/roadtrip/p-74980317.entry.js +2 -0
- package/dist/roadtrip/p-74980317.entry.js.map +1 -0
- package/dist/roadtrip/{p-c709f80e.entry.js → p-7c4b331c.entry.js} +2 -2
- package/dist/roadtrip/p-7d5dbd9a.js +2 -0
- package/dist/roadtrip/p-7d5dbd9a.js.map +1 -0
- package/dist/roadtrip/p-7ec2d494.js +2 -0
- package/dist/roadtrip/p-7ec2d494.js.map +1 -0
- package/dist/roadtrip/p-a484102a.entry.js +2 -0
- package/dist/roadtrip/p-a484102a.entry.js.map +1 -0
- package/dist/roadtrip/{p-7390ad20.entry.js → p-b5727aae.entry.js} +2 -2
- package/dist/roadtrip/p-c259efd7.js +2 -0
- package/dist/roadtrip/{p-4f31338d.js.map → p-c259efd7.js.map} +1 -1
- package/dist/roadtrip/{p-91070a4d.entry.js → p-c8e9807b.entry.js} +2 -2
- package/dist/roadtrip/p-e8c090a5.js +2 -0
- package/dist/roadtrip/{p-3f7c8122.entry.js → p-ebe3c26a.entry.js} +2 -2
- package/dist/roadtrip/{p-a1a25a51.entry.js → p-ee0196ea.entry.js} +2 -2
- package/dist/roadtrip/{p-c0c088c1.entry.js → p-f671758f.entry.js} +2 -2
- package/dist/roadtrip/roadtrip.css +1 -1
- package/dist/roadtrip/roadtrip.esm.js +1 -1
- package/dist/roadtrip/roadtrip.esm.js.map +1 -1
- package/dist/types/components/area-code/area-code.d.ts +4 -0
- package/dist/types/components/button/button.d.ts +5 -0
- package/dist/types/components/phone-number-input/phone-number-input.d.ts +21 -10
- package/dist/types/components.d.ts +33 -18
- package/dist/types/index.d.ts +1 -0
- package/hydrate/index.js +1379 -5773
- package/illustrations/illustrations.svg +1 -0
- package/illustrations/index.d.ts +11 -0
- package/illustrations/index.js +11 -0
- package/package.json +4 -2
- package/dist/cjs/focus-visible-a5d1ccf9.js.map +0 -1
- package/dist/esm/focus-visible-0fc6119c.js.map +0 -1
- package/dist/esm/polyfill-2b159e86.js +0 -7
- package/dist/roadtrip/p-0ffe42f9.entry.js +0 -2
- package/dist/roadtrip/p-0ffe42f9.entry.js.map +0 -1
- package/dist/roadtrip/p-12fd8791.js +0 -2
- package/dist/roadtrip/p-4f31338d.js +0 -2
- package/dist/roadtrip/p-6fb0d348.entry.js +0 -2
- package/dist/roadtrip/p-6fb0d348.entry.js.map +0 -1
- package/dist/roadtrip/p-80560610.entry.js +0 -2
- package/dist/roadtrip/p-80560610.entry.js.map +0 -1
- package/dist/roadtrip/p-c9a1dd14.entry.js +0 -2
- package/dist/roadtrip/p-c9a1dd14.entry.js.map +0 -1
- /package/dist/roadtrip/{p-f0e8feac.entry.js.map → p-093973f5.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-3237c0d8.entry.js.map → p-0bcf6d63.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-9077915a.entry.js.map → p-198f586b.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-c784a407.entry.js.map → p-439e1124.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-4b54f8e8.entry.js.map → p-4fd8c4db.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-10856fef.entry.js.map → p-564f4f31.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-c709f80e.entry.js.map → p-7c4b331c.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-7390ad20.entry.js.map → p-b5727aae.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-91070a4d.entry.js.map → p-c8e9807b.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-12fd8791.js.map → p-e8c090a5.js.map} +0 -0
- /package/dist/roadtrip/{p-3f7c8122.entry.js.map → p-ebe3c26a.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-a1a25a51.entry.js.map → p-ee0196ea.entry.js.map} +0 -0
- /package/dist/roadtrip/{p-c0c088c1.entry.js.map → p-f671758f.entry.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-code.js","sourceRoot":"","sources":["../../../src/components/area-code/area-code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"area-code.js","sourceRoot":"","sources":["../../../src/components/area-code/area-code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAO5F,M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,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,MAAM,IAElB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAC1C,cAAQ,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAG,MAAM,CAAC,KAAK,CAAU,CAChF,CAAC,CACK;MACT,aAAO,KAAK,EAAC,wBAAwB,EAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAG,IAAI,CAAC,KAAK,CAAS;MAC/F,aAAO,KAAK,EAAC,wBAAwB,EAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ;;QAAI,IAAI,CAAC,aAAa,CAAS;MACvG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,EAAE,IAAI,SAAG,KAAK,EAAC,kBAAkB,IAAE,IAAI,CAAC,KAAK,CAAK,CAC3E,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,SAAS,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h, State } from '@stencil/core';\n\n@Component({\n tag: 'road-area-code',\n styleUrl: 'area-code.css', // Mettez à jour le nom du fichier de style si nécessaire\n scoped: true,\n})\nexport class RoadAreaCode {\n\n @Prop() selectId: string = `road-select-${selectIds++}`;\n @State() selectedValue: string | number = '';\n\n\n @Prop() options: Array<{\n value: string | number;\n label: string;\n selected?: boolean;\n }> = [];\n\n @Prop() autofocus: boolean = false;\n\n @Prop() disabled: boolean = false;\n\n\n @Prop() name: string = this.selectId;\n\n @Prop() required: boolean = false;\n\n @Prop() size: number = 0;\n\n @Prop() sizes: 'lg' | 'xl' = 'lg';\n\n @Prop() label: string = 'Country';\n\n @Prop() error?: string;\n\n @Prop({ mutable: true }) value?: any | null;\n\n @Prop() areaValue?: number;\n\n @Event() roadchange!: EventEmitter<{\n value: string | undefined | null\n }>;\n /** @internal */\n @Event() roadChange!: EventEmitter<{\n value: string | undefined | null\n }>;\n\n /**\n* Emitted when the select has focus.\n*/\n\n @Event() roadfocus!: EventEmitter<void>;\n /** @internal */\n @Event() roadFocus!: EventEmitter<void>;\n\n /**\n* Emitted when the select loses focus.\n*/\n\n @Event() roadblur!: EventEmitter<void>;\n /** @internal */\n @Event() roadBlur!: EventEmitter<void>;\n\n @Watch('value')\n valueChanged() {\n this.roadchange.emit({\n value: this.value,\n });\n this.roadChange.emit({\n value: this.value,\n });\n this.selectedValue = this.value;\n }\n\n @Prop({ mutable: true }) triggerRender: number = 0;\n\n componentWillLoad() {\n if (!this.value && this.options.length > 0) {\n this.selectedValue = this.options[0].value;\n } else {\n const matchedOption = this.options.find(option => option.value === this.value);\n if (matchedOption) {\n this.selectedValue = matchedOption.value;\n }\n }\n }\n\n private onChange = (ev: Event) => {\n const select = ev.target as HTMLSelectElement | null;\n if (select) {\n this.value = select.value || '';\n const matchedOption = this.options.find(option => option.value === this.value);\n if (matchedOption) {\n this.selectedValue = matchedOption.value;\n }\n }\n return this.selectedValue;\n };\n\n private onBlur = () => {\n this.roadblur.emit();\n this.roadBlur.emit();\n };\n\n private onFocus = () => {\n this.roadfocus.emit();\n this.roadFocus.emit();\n };\n\n render() {\n const labelId = this.selectId + '-label';\n const valueId = this.selectId + '-value';\n\n const isInvalidClass = this.error !== undefined && this.error !== '' ? 'is-invalid' : '';\n\n return (\n <Host class={this.sizes && `select-${this.sizes}`}>\n <select\n class={`form-select-area has-value ${isInvalidClass}`} // Appliquez la classe has-value par défaut ici\n id={this.selectId}\n aria-disabled={this.disabled ? 'true' : null}\n autoFocus={this.autofocus}\n disabled={this.disabled}\n name={this.name}\n required={this.required}\n size={this.size}\n onChange={this.onChange}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n >\n {this.options && this.options.map(option => (\n <option value={option.value} selected={option.selected}>{option.label}</option>\n ))}\n </select>\n <label class=\"form-select-area-label\" id={labelId} htmlFor={this.selectId}>{this.label}</label>\n <label class=\"form-select-area-value\" id={valueId} htmlFor={this.selectId}>+{this.selectedValue}</label>\n {this.error && this.error !== '' && <p class=\"invalid-feedback\">{this.error}</p>}\n </Host>\n );\n }\n}\n\nlet selectIds = 0;\n"]}
|
|
@@ -120,7 +120,6 @@
|
|
|
120
120
|
:host(.btn-primary) {
|
|
121
121
|
color: var(--road-on-button-primary);
|
|
122
122
|
background: var(--road-button-primary);
|
|
123
|
-
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
:host(.btn-primary) ::slotted(road-icon) {
|
|
@@ -285,6 +284,29 @@
|
|
|
285
284
|
height: 2rem;
|
|
286
285
|
}
|
|
287
286
|
|
|
287
|
+
:host(.btn-icon.btn-xl) {
|
|
288
|
+
width: 56px;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Large
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
:host(.btn-lg) {
|
|
297
|
+
height: 3rem;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
:host(.btn-lg) ::slotted(road-icon) {
|
|
301
|
+
width: 2rem;
|
|
302
|
+
height: 2rem;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
:host(.btn-icon.btn-lg) {
|
|
307
|
+
width: 48px;
|
|
308
|
+
}
|
|
309
|
+
|
|
288
310
|
/**
|
|
289
311
|
* Medium
|
|
290
312
|
*/
|
|
@@ -300,6 +322,10 @@
|
|
|
300
322
|
height: 1.5rem;
|
|
301
323
|
}
|
|
302
324
|
|
|
325
|
+
:host(.btn-icon.btn-md) {
|
|
326
|
+
width: 40px;
|
|
327
|
+
}
|
|
328
|
+
|
|
303
329
|
/**
|
|
304
330
|
* Small
|
|
305
331
|
*/
|
|
@@ -315,6 +341,10 @@
|
|
|
315
341
|
height: 1.25rem;
|
|
316
342
|
}
|
|
317
343
|
|
|
344
|
+
:host(.btn-icon.btn-sm) {
|
|
345
|
+
width: 32px;
|
|
346
|
+
}
|
|
347
|
+
|
|
318
348
|
/**
|
|
319
349
|
* Button block
|
|
320
350
|
*/
|
|
@@ -323,6 +353,11 @@
|
|
|
323
353
|
width: 100%;
|
|
324
354
|
}
|
|
325
355
|
|
|
356
|
+
:host(.btn-icon) .button-native{
|
|
357
|
+
padding: 0;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
|
|
326
361
|
/* BADGE
|
|
327
362
|
-------------------- */
|
|
328
363
|
|
|
@@ -2,6 +2,7 @@ import { Host, h } from '@stencil/core';
|
|
|
2
2
|
import './../../utils/polyfill';
|
|
3
3
|
/**
|
|
4
4
|
* @slot - Content of the button.
|
|
5
|
+
* ex if onlyIcon `<road-icon name="shopping-cart-add"></road-icon>`
|
|
5
6
|
* @slot start - Left content of the button text, usually for icon.
|
|
6
7
|
* @slot end - Right content of the button text, usually icon.
|
|
7
8
|
*
|
|
@@ -37,6 +38,7 @@ export class Button {
|
|
|
37
38
|
this.color = 'default';
|
|
38
39
|
this.size = 'lg';
|
|
39
40
|
this.buttonType = 'button';
|
|
41
|
+
this.iconOnly = false;
|
|
40
42
|
this.disabled = false;
|
|
41
43
|
this.expand = false;
|
|
42
44
|
this.download = undefined;
|
|
@@ -59,7 +61,8 @@ export class Button {
|
|
|
59
61
|
const colorClass = this.outline ? `btn-outline-${color}` : `btn-${color}`;
|
|
60
62
|
const sizeClass = this.size !== undefined ? `btn-${this.size}` : '';
|
|
61
63
|
const expandClass = this.expand ? 'btn-block' : '';
|
|
62
|
-
|
|
64
|
+
const iconOnlyClass = this.iconOnly ? 'btn-icon' : '';
|
|
65
|
+
return (h(Host, { class: `${colorClass} ${sizeClass} ${expandClass} ${iconOnlyClass}`, onClick: this.onClick, "aria-disabled": disabled ? 'true' : null }, h(TagType, Object.assign({}, attrs, { class: "button-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur }), h("slot", { name: "start" }), h("slot", null), h("slot", { name: "end" }))));
|
|
63
66
|
}
|
|
64
67
|
static get is() { return "road-button"; }
|
|
65
68
|
static get encapsulation() { return "shadow"; }
|
|
@@ -129,6 +132,24 @@ export class Button {
|
|
|
129
132
|
"reflect": false,
|
|
130
133
|
"defaultValue": "'button'"
|
|
131
134
|
},
|
|
135
|
+
"iconOnly": {
|
|
136
|
+
"type": "boolean",
|
|
137
|
+
"mutable": false,
|
|
138
|
+
"complexType": {
|
|
139
|
+
"original": "boolean",
|
|
140
|
+
"resolved": "boolean",
|
|
141
|
+
"references": {}
|
|
142
|
+
},
|
|
143
|
+
"required": false,
|
|
144
|
+
"optional": false,
|
|
145
|
+
"docs": {
|
|
146
|
+
"tags": [],
|
|
147
|
+
"text": "If `true`, display only an icon in the button."
|
|
148
|
+
},
|
|
149
|
+
"attribute": "icon-only",
|
|
150
|
+
"reflect": true,
|
|
151
|
+
"defaultValue": "false"
|
|
152
|
+
},
|
|
132
153
|
"disabled": {
|
|
133
154
|
"type": "boolean",
|
|
134
155
|
"mutable": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,E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AO,oBACF,KAAK,IACT,KAAK,EAAC,eAAe,EACrB,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,MAAM;QAEnB,YAAM,IAAI,EAAC,OAAO,GAAE;QACpB,eAAO;QACP,YAAM,IAAI,EAAC,KAAK,GAAE,CACV,CACL,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, Host, Prop, h } from '@stencil/core';\n\nimport './../../utils/polyfill';\n\n/**\n * @slot - Content of the button.\n * ex if onlyIcon `<road-icon name=\"shopping-cart-add\"></road-icon>`\n * @slot start - Left content of the button text, usually for icon.\n * @slot end - Right content of the button text, usually icon.\n *\n * @part native - The native HTML button or anchor element that wraps all child elements.\n */\n\n@Component({\n tag: 'road-button',\n styleUrl: 'button.css',\n shadow: true,\n})\nexport class Button {\n\n @Element() el!: HTMLRoadButtonElement;\n\n /**\n * The color to use from your application's color palette.\n */\n @Prop() color?: 'primary' | 'secondary' | 'ghost' |'default' = 'default';\n\n /**\n * The button size.\n */\n @Prop({ reflect: true }) size?: 'sm' | 'md' | 'lg' | 'xl' = 'lg';\n\n /**\n * The type of the button.\n */\n @Prop() buttonType: 'submit' | 'reset' | 'button' = 'button';\n\n /**\n * If `true`, display only an icon in the button.\n */\n @Prop({ reflect: true }) iconOnly: boolean = false;\n\n /**\n * If `true`, the user cannot interact with the button.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * Set to `true` for a full-width button.\n */\n @Prop({ reflect: true }) expand: boolean = false;\n\n /**\n * This attribute instructs browsers to download a URL instead of navigating to\n * it, so the user will be prompted to save it as a local file. If the attribute\n * has a value, it is used as the pre-filled file name in the Save prompt\n * (the user can still change the file name if they want).\n */\n @Prop() download: string | undefined;\n\n /**\n * Contains a URL or a URL fragment that the hyperlink points to.\n * If this property is set, an anchor tag will be rendered.\n */\n @Prop() href?: string;\n\n /**\n * Specifies the relationship of the target object to the link object.\n * The value is a space-separated list of [link types](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types).\n */\n @Prop() rel?: string;\n\n /**\n * Specifies where to display the linked URL.\n * Only applies when an `href` is provided.\n * Special keywords: `\"_blank\"`, `\"_self\"`, `\"_parent\"`, `\"_top\"`.\n */\n @Prop() target?: string;\n\n /**\n * Set to `false` for a ghost button, set to `true` for a default outline button\n */\n @Prop() outline: boolean = false;\n\n /**\n * Emitted when the button has focus.\n */\n @Event() roadfocus!: EventEmitter<void>;\n /** @internal */\n @Event() roadFocus!: EventEmitter<void>;\n\n /**\n * Emitted when the button loses focus.\n */\n @Event() roadblur!: EventEmitter<void>;\n /** @internal */\n @Event() roadBlur!: EventEmitter<void>;\n\n private onClick = (ev: Event) => {\n if (this.el.shadowRoot && (this.el as any).attachShadow) {\n // this button wants to specifically submit a form\n // climb up the dom to see if we're in a <form>\n // and if so, then use JS to submit it\n const form = this.el.closest('form');\n if (form) {\n ev.preventDefault();\n\n const fakeButton = document.createElement('button');\n fakeButton.type = this.buttonType;\n fakeButton.style.display = 'none';\n form.appendChild(fakeButton);\n fakeButton.click();\n fakeButton.remove();\n }\n }\n };\n\n private onFocus = () => {\n this.roadfocus.emit();\n this.roadFocus.emit();\n };\n\n private onBlur = () => {\n this.roadblur.emit();\n this.roadBlur.emit();\n };\n\n render() {\n const { buttonType, disabled, href, rel, target, color } = this;\n const TagType = this.href === undefined ? 'button' : 'a' as any;\n const attrs = (TagType === 'button')\n ? { type: buttonType }\n : {\n download: this.download,\n href,\n rel,\n target,\n };\n const colorClass = this.outline ? `btn-outline-${color}` : `btn-${color}`;\n const sizeClass = this.size !== undefined ? `btn-${this.size}` : '';\n const expandClass = this.expand ? 'btn-block' : '';\n const iconOnlyClass = this.iconOnly ? 'btn-icon' : '';\n\n return (\n <Host\n class={`${colorClass} ${sizeClass} ${expandClass} ${iconOnlyClass}`}\n onClick={this.onClick}\n aria-disabled={disabled ? 'true' : null}\n >\n <TagType\n {...attrs}\n class=\"button-native\"\n part=\"native\"\n disabled={disabled}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n >\n <slot name=\"start\"/>\n <slot/>\n <slot name=\"end\"/>\n </TagType>\n </Host>\n );\n }\n}"]}
|
|
@@ -26,6 +26,9 @@ export default {
|
|
|
26
26
|
disabled: {
|
|
27
27
|
control: 'boolean',
|
|
28
28
|
},
|
|
29
|
+
'icon-only': {
|
|
30
|
+
control: 'boolean',
|
|
31
|
+
},
|
|
29
32
|
download: {
|
|
30
33
|
control: {
|
|
31
34
|
type: null,
|
|
@@ -125,6 +128,7 @@ export default {
|
|
|
125
128
|
},
|
|
126
129
|
args: {
|
|
127
130
|
'button-type': null,
|
|
131
|
+
'icon-only': null,
|
|
128
132
|
color: null,
|
|
129
133
|
disabled: null,
|
|
130
134
|
expand: null,
|
|
@@ -139,6 +143,7 @@ export default {
|
|
|
139
143
|
const Template = (args) => html`
|
|
140
144
|
<road-button
|
|
141
145
|
button-type="${ifDefined(args['button-type'])}"
|
|
146
|
+
icon-only="${ifDefined(args['icon-only'])}"
|
|
142
147
|
color="${ifDefined(args.color)}"
|
|
143
148
|
disabled="${ifDefined(args.disabled)}"
|
|
144
149
|
expand="${ifDefined(args.expand)}"
|
|
@@ -186,6 +191,14 @@ Disabled.args = {
|
|
|
186
191
|
disabled: true,
|
|
187
192
|
};
|
|
188
193
|
|
|
194
|
+
export const Icon = Template.bind({});
|
|
195
|
+
Icon.args = {
|
|
196
|
+
color: 'primary',
|
|
197
|
+
outline: true,
|
|
198
|
+
'icon-only': true,
|
|
199
|
+
' ': `<road-icon name="shopping-cart-add"></road-icon>`,
|
|
200
|
+
};
|
|
201
|
+
|
|
189
202
|
export const BackButton = Template.bind({});
|
|
190
203
|
BackButton.args = {
|
|
191
204
|
start: `<road-icon slot="start" name="navigation-chevron" rotate="180"></road-icon>`,
|
|
@@ -1,73 +1,104 @@
|
|
|
1
1
|
import { Host, h } from '@stencil/core';
|
|
2
|
-
import {
|
|
2
|
+
import { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil, } from 'google-libphonenumber';
|
|
3
3
|
export class RoadPhoneNumberInput {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.countryData = [];
|
|
6
6
|
this.language = 'fr';
|
|
7
7
|
this.areaLabel = 'Country';
|
|
8
|
+
this.areaValue = '';
|
|
8
9
|
this.inputLabel = 'Number';
|
|
10
|
+
this.inputValue = '';
|
|
9
11
|
this.required = false;
|
|
10
|
-
this.error = undefined;
|
|
11
12
|
this.selectedCountry = '';
|
|
12
13
|
this.phoneNumber = '';
|
|
14
|
+
this.inputError = '';
|
|
13
15
|
this.countryOptions = [];
|
|
14
16
|
}
|
|
15
17
|
languageChanged() {
|
|
16
|
-
// console.log('language changed from', oldValue, 'to', newValue);
|
|
17
18
|
this.updateCountryOptions();
|
|
18
19
|
}
|
|
19
20
|
updateCountryOptions() {
|
|
20
21
|
const validLanguage = this.language && this.countryData[0].translations[this.language] ? this.language : 'fr';
|
|
21
|
-
// console.log('Langue valide:', validLanguage);
|
|
22
22
|
this.countryOptions = this.countryData.map(country => {
|
|
23
|
-
// console.log('Option avant mise à jour:', country.translations[this.language], country.translations[validLanguage]);
|
|
24
23
|
return {
|
|
25
|
-
value:
|
|
24
|
+
value: country.phoneCode,
|
|
26
25
|
label: `${country.translations[validLanguage]} (+${country.phoneCode})`,
|
|
27
|
-
selected: country.countryCode === this.selectedCountry,
|
|
26
|
+
selected: country.countryCode === this.selectedCountry, // Ici, nous marquons l'option par défaut comme sélectionnée
|
|
28
27
|
};
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
|
-
getCountryOptions() {
|
|
32
|
-
return this.countryData.map(country => ({
|
|
33
|
-
value: `+${country.phoneCode}`,
|
|
34
|
-
label: `${country.translations[this.language]} (${country.phoneCode})`,
|
|
35
|
-
selected: country.countryCode === this.selectedCountry,
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
30
|
componentWillLoad() {
|
|
39
|
-
if (this.
|
|
40
|
-
this.
|
|
31
|
+
if (this.inputValue) {
|
|
32
|
+
this.phoneNumber = this.inputValue;
|
|
33
|
+
}
|
|
34
|
+
if (this.areaValue) {
|
|
35
|
+
this.selectedCountry = this.getPhoneCountryCode(this.areaValue);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (this.countryData && this.countryData.length > 0) {
|
|
39
|
+
this.selectedCountry = this.countryData[0].countryCode;
|
|
40
|
+
}
|
|
41
41
|
}
|
|
42
42
|
this.updateCountryOptions();
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
getPhoneCountryCode(phoneCode) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
return (_b = (_a = this.countryData.find((country) => country.phoneCode === phoneCode)) === null || _a === void 0 ? void 0 : _a.countryCode) !== null && _b !== void 0 ? _b : '';
|
|
47
|
+
}
|
|
48
|
+
handleSelect(event) {
|
|
49
|
+
const receivedPhoneCode = event.detail.value.replace('+', '');
|
|
50
|
+
const phoneCountryCode = this.getPhoneCountryCode(receivedPhoneCode);
|
|
51
|
+
this.selectedCountry = phoneCountryCode;
|
|
52
|
+
this.createReturnObject();
|
|
53
|
+
}
|
|
54
|
+
createReturnObject() {
|
|
55
|
+
var _a, _b, _c, _d;
|
|
56
|
+
const returnObject = {
|
|
57
|
+
isError: true,
|
|
58
|
+
phone: {
|
|
59
|
+
phoneNumberType: 'UNKNOWN',
|
|
60
|
+
countryCode: this.selectedCountry,
|
|
61
|
+
nationalNumber: this.phoneNumber,
|
|
62
|
+
phoneCode: (_b = (_a = this.countryData.find((country) => country.countryCode === this.selectedCountry)) === null || _a === void 0 ? void 0 : _a.phoneCode) !== null && _b !== void 0 ? _b : '',
|
|
63
|
+
internationalNumber: this.phoneNumber,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
// create instance
|
|
67
|
+
const phoneUtil = PhoneNumberUtil.getInstance();
|
|
68
|
+
const PNF = PhoneNumberFormat;
|
|
48
69
|
// Parse and verify the phone number
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
try {
|
|
71
|
+
const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber, this.selectedCountry);
|
|
72
|
+
const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber));
|
|
73
|
+
const phoneCode = parsedPhoneNumber.getCountryCode();
|
|
74
|
+
// get the phone's country code and updates the areaValue
|
|
75
|
+
if (phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)) {
|
|
76
|
+
this.selectedCountry = phoneUtil.getRegionCodeForNumber(parsedPhoneNumber);
|
|
77
|
+
const computedPhoneCode = (_d = (_c = this.countryData.find(country => country.countryCode == this.selectedCountry)) === null || _c === void 0 ? void 0 : _c.phoneCode) !== null && _d !== void 0 ? _d : '';
|
|
78
|
+
this.areaValue = computedPhoneCode;
|
|
79
|
+
}
|
|
80
|
+
if (parsedPhoneNumber && phoneUtil.isValidNumber(parsedPhoneNumber)) {
|
|
81
|
+
returnObject.isError = false;
|
|
82
|
+
returnObject.phone = {
|
|
83
|
+
phoneNumberType: phoneType ? phoneType[0] : 'UNKNOWN',
|
|
84
|
+
countryCode: phoneUtil.getRegionCodeForNumber(parsedPhoneNumber),
|
|
85
|
+
phoneCode,
|
|
86
|
+
nationalNumber: phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL),
|
|
87
|
+
internationalNumber: phoneUtil.format(parsedPhoneNumber, PNF.E164),
|
|
88
|
+
};
|
|
89
|
+
this.inputError = '';
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.inputError = 'Numéro de téléphone non valide';
|
|
93
|
+
}
|
|
70
94
|
}
|
|
95
|
+
catch (_e) { }
|
|
96
|
+
this.roadPhoneNumberInput.emit(returnObject);
|
|
97
|
+
}
|
|
98
|
+
handleInput(event) {
|
|
99
|
+
this.updateCountryOptions();
|
|
100
|
+
this.phoneNumber = event.detail.value;
|
|
101
|
+
this.createReturnObject();
|
|
71
102
|
}
|
|
72
103
|
extractCallingCode(countryString) {
|
|
73
104
|
const regex = /\(([^)]+)\)/;
|
|
@@ -77,14 +108,10 @@ export class RoadPhoneNumberInput {
|
|
|
77
108
|
selectCountry(event) {
|
|
78
109
|
const countryString = event.detail.value; // Get the value from the custom event
|
|
79
110
|
this.selectedCountry = this.extractCallingCode(countryString);
|
|
80
|
-
this.el.querySelector('
|
|
111
|
+
this.el.querySelector('.form-select-area-value').innerHTML = countryString;
|
|
81
112
|
}
|
|
82
113
|
render() {
|
|
83
|
-
|
|
84
|
-
// console.log('render called with language', this.language);
|
|
85
|
-
// const countryOptions = this.getCountryOptions();
|
|
86
|
-
// console.log((this.el.querySelector('road-area-code') as HTMLRoadAreaCodeElement).value);
|
|
87
|
-
return (h(Host, null, h("road-input-group", null, h("road-area-code", { slot: "prepend", class: `form-select has-value`, label: this.areaLabel, sizes: "xl", options: this.countryOptions, onRoadchange: this.selectCountry.bind(this) }), h("road-input", { id: "phone-number", sizes: "xl", label: this.inputLabel, onInput: (event) => this.handleInput(event), value: `+` + this.countryData[0].phoneCode, required: this.required, class: `${isInvalidClass}` })), this.error && this.error !== '' && h("p", { class: "invalid-feedback" }, this.error)));
|
|
114
|
+
return (h(Host, null, h("road-input-group", null, h("road-area-code", { slot: "prepend", class: `form-select has-value`, label: this.areaLabel, value: this.areaValue, sizes: "xl", options: this.countryOptions, onRoadchange: (event) => this.handleSelect(event) }), h("road-input", { id: "phone-number", sizes: "xl", label: this.inputLabel, value: this.inputValue, onRoadChange: (event) => this.handleInput(event), required: this.required, error: this.inputError }))));
|
|
88
115
|
}
|
|
89
116
|
static get is() { return "road-phone-number-input"; }
|
|
90
117
|
static get encapsulation() { return "scoped"; }
|
|
@@ -156,6 +183,24 @@ export class RoadPhoneNumberInput {
|
|
|
156
183
|
"reflect": false,
|
|
157
184
|
"defaultValue": "'Country'"
|
|
158
185
|
},
|
|
186
|
+
"areaValue": {
|
|
187
|
+
"type": "string",
|
|
188
|
+
"mutable": true,
|
|
189
|
+
"complexType": {
|
|
190
|
+
"original": "string",
|
|
191
|
+
"resolved": "string",
|
|
192
|
+
"references": {}
|
|
193
|
+
},
|
|
194
|
+
"required": false,
|
|
195
|
+
"optional": false,
|
|
196
|
+
"docs": {
|
|
197
|
+
"tags": [],
|
|
198
|
+
"text": ""
|
|
199
|
+
},
|
|
200
|
+
"attribute": "area-value",
|
|
201
|
+
"reflect": false,
|
|
202
|
+
"defaultValue": "''"
|
|
203
|
+
},
|
|
159
204
|
"inputLabel": {
|
|
160
205
|
"type": "string",
|
|
161
206
|
"mutable": false,
|
|
@@ -174,40 +219,41 @@ export class RoadPhoneNumberInput {
|
|
|
174
219
|
"reflect": false,
|
|
175
220
|
"defaultValue": "'Number'"
|
|
176
221
|
},
|
|
177
|
-
"
|
|
178
|
-
"type": "
|
|
222
|
+
"inputValue": {
|
|
223
|
+
"type": "string",
|
|
179
224
|
"mutable": false,
|
|
180
225
|
"complexType": {
|
|
181
|
-
"original": "
|
|
182
|
-
"resolved": "
|
|
226
|
+
"original": "string",
|
|
227
|
+
"resolved": "string",
|
|
183
228
|
"references": {}
|
|
184
229
|
},
|
|
185
230
|
"required": false,
|
|
186
231
|
"optional": false,
|
|
187
232
|
"docs": {
|
|
188
233
|
"tags": [],
|
|
189
|
-
"text": "
|
|
234
|
+
"text": ""
|
|
190
235
|
},
|
|
191
|
-
"attribute": "
|
|
236
|
+
"attribute": "input-value",
|
|
192
237
|
"reflect": false,
|
|
193
|
-
"defaultValue": "
|
|
238
|
+
"defaultValue": "''"
|
|
194
239
|
},
|
|
195
|
-
"
|
|
196
|
-
"type": "
|
|
240
|
+
"required": {
|
|
241
|
+
"type": "boolean",
|
|
197
242
|
"mutable": false,
|
|
198
243
|
"complexType": {
|
|
199
|
-
"original": "
|
|
200
|
-
"resolved": "
|
|
244
|
+
"original": "boolean",
|
|
245
|
+
"resolved": "boolean",
|
|
201
246
|
"references": {}
|
|
202
247
|
},
|
|
203
248
|
"required": false,
|
|
204
|
-
"optional":
|
|
249
|
+
"optional": false,
|
|
205
250
|
"docs": {
|
|
206
251
|
"tags": [],
|
|
207
|
-
"text": "
|
|
252
|
+
"text": "If `true`, the user must fill in a value before submitting a form."
|
|
208
253
|
},
|
|
209
|
-
"attribute": "
|
|
210
|
-
"reflect": false
|
|
254
|
+
"attribute": "required",
|
|
255
|
+
"reflect": false,
|
|
256
|
+
"defaultValue": "false"
|
|
211
257
|
}
|
|
212
258
|
};
|
|
213
259
|
}
|
|
@@ -215,11 +261,31 @@ export class RoadPhoneNumberInput {
|
|
|
215
261
|
return {
|
|
216
262
|
"selectedCountry": {},
|
|
217
263
|
"phoneNumber": {},
|
|
264
|
+
"inputError": {},
|
|
218
265
|
"countryOptions": {}
|
|
219
266
|
};
|
|
220
267
|
}
|
|
221
268
|
static get events() {
|
|
222
269
|
return [{
|
|
270
|
+
"method": "roadPhoneNumberInput",
|
|
271
|
+
"name": "roadPhoneNumberInput",
|
|
272
|
+
"bubbles": true,
|
|
273
|
+
"cancelable": true,
|
|
274
|
+
"composed": true,
|
|
275
|
+
"docs": {
|
|
276
|
+
"tags": [],
|
|
277
|
+
"text": "Emitt object data."
|
|
278
|
+
},
|
|
279
|
+
"complexType": {
|
|
280
|
+
"original": "{\n isError: boolean;\n phone: PhoneReturnType;\n }",
|
|
281
|
+
"resolved": "{ isError: boolean; phone: PhoneReturnType; }",
|
|
282
|
+
"references": {
|
|
283
|
+
"PhoneReturnType": {
|
|
284
|
+
"location": "global"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}, {
|
|
223
289
|
"method": "roadselected",
|
|
224
290
|
"name": "roadselected",
|
|
225
291
|
"bubbles": true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-number-input.js","sourceRoot":"","sources":["../../../src/components/phone-number-input/phone-number-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAa1E,MAAM,OAAO,oBAAoB;;uBAGM,EAAE;oBACZ,IAAI;qBACH,SAAS;sBACR,QAAQ;oBAKhB,KAAK;;2BAOS,EAAE;uBACN,EAAE;0BAEgD,EAAE;;EAInF,eAAe;IACb,kEAAkE;IAClE,IAAI,CAAC,oBAAoB,EAAE,CAAC;EAC9B,CAAC;EAEH,oBAAoB;IAClB,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9G,gDAAgD;IAChD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,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,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGF","sourcesContent":["import { Component, Prop, Element, Host, State, h, Watch, Event, EventEmitter } from '@stencil/core';\nimport { AsYouType, parsePhoneNumberFromString } from 'libphonenumber-js';\n\ntype CountryType = {\n translations: { [key: string]: string },\n countryCode: string,\n phoneCode: string\n};\n\n@Component({\n tag: 'road-phone-number-input',\n styleUrl: 'phone-number-input.css',\n scoped: true,\n})\nexport class RoadPhoneNumberInput {\n @Element() el!: HTMLRoadPhoneNumberInputElement;\n\n @Prop() countryData: CountryType[] = [];\n @Prop() language: string = 'fr'; \n @Prop() areaLabel: string = 'Country';\n @Prop() inputLabel: string = 'Number';\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * Error message for the field\n */\n @Prop() error?: string;\n\n @State() selectedCountry: string = '';\n @State() phoneNumber: string = '';\n\n @State() countryOptions: { value: string; label: string; selected: boolean }[] = [];\n\n @Watch('language')\n \n languageChanged() {\n // console.log('language changed from', oldValue, 'to', newValue);\n this.updateCountryOptions();\n }\n\nupdateCountryOptions() {\n const validLanguage = this.language && this.countryData[0].translations[this.language] ? this.language : 'fr';\n // console.log('Langue valide:', validLanguage);\n this.countryOptions = this.countryData.map(country => {\n // console.log('Option avant mise à jour:', country.translations[this.language], country.translations[validLanguage]);\n return {\n value: `+${country.phoneCode}`, // country.translations[validLanguage] pour mettre les nom des pays\n label: `${country.translations[validLanguage]} (+${country.phoneCode})`,\n selected: country.countryCode === this.selectedCountry,\n };\n });\n}\n\n\n\n getCountryOptions() {\n return this.countryData.map(country => ({\n value: `+${country.phoneCode}`,\n label: `${country.translations[this.language]} (${country.phoneCode})`, \n selected: country.countryCode === this.selectedCountry,\n }));\n }\n\n componentWillLoad() {\n if (this.countryData.length > 0) {\n this.selectedCountry = this.countryData[0].countryCode; // Set to country code instead of calling code\n\n }\n this.updateCountryOptions();\n }\n \n\n handleInput(event: Event) {\n const input = event.target as HTMLInputElement;\n const asYouType = new AsYouType(this.selectedCountry as any);\n this.phoneNumber = asYouType.input(input.value);\n\n // Parse and verify the phone number\n const parsedPhoneNumber = parsePhoneNumberFromString(input.value, this.selectedCountry as any);\n if (parsedPhoneNumber && parsedPhoneNumber.isValid() ) {\n const phoneNumberInput = (this.el as HTMLRoadPhoneNumberInputElement);\n const phoneNumberType = parsedPhoneNumber.getType() as string;\n const countryCode = parsedPhoneNumber.country as string;\n const phoneCode = parsedPhoneNumber.countryCallingCode as string;\n const national = parsedPhoneNumber.nationalNumber as string;\n const international = parsedPhoneNumber.number as string;\n phoneNumberInput.setAttribute(\"error\",\"\")\n phoneNumberInput.setAttribute(\"phoneNumberType\", phoneNumberType)\n phoneNumberInput.setAttribute(\"countryCode\", countryCode)\n phoneNumberInput.setAttribute(\"phoneCode\", phoneCode)\n phoneNumberInput.setAttribute(\"nationalnumber\", national)\n phoneNumberInput.setAttribute(\"internationalnumber\", international)\n\n\n } else {\n // ajoute le nouvel élément créé et son contenu dans le DOM\n const phoneNumberInput = (this.el as HTMLRoadPhoneNumberInputElement);\n const input = document.getElementById('phone-number') as any;\n input.classList.add(\"is-invalid\");\n phoneNumberInput.setAttribute(\"error\",\"Numéro de téléphone non valide\")\n } \n}\n\n /**\n * Emitted the value and label of the option selected.\n */\n @Event() roadselected!: EventEmitter<{\n value: string | undefined | null,\n label: string\n }>;\n /** @internal */\n @Event() roadSelected!: EventEmitter<{\n value: string | undefined | null,\n label: string\n }>;\n\n extractCallingCode(countryString: string) {\n const regex = /\\(([^)]+)\\)/;\n const found = countryString.match(regex);\n return found ? found[1] : '';\n }\n\n selectCountry(event: CustomEvent) {\n const countryString = event.detail.value; // Get the value from the custom event\n this.selectedCountry = this.extractCallingCode(countryString);\n (this.el.querySelector('road-input') as HTMLRoadInputElement).value = countryString;\n }\n\n render() {\n\n const isInvalidClass = this.error !== undefined && this.error !== '' ? 'is-invalid' : '';\n\n // console.log('render called with language', this.language);\n // const countryOptions = this.getCountryOptions();\n // console.log((this.el.querySelector('road-area-code') as HTMLRoadAreaCodeElement).value);\n \n\n return (\n <Host>\n <road-input-group>\n <road-area-code\n slot=\"prepend\"\n class={`form-select has-value`}\n label={this.areaLabel}\n sizes=\"xl\"\n options={this.countryOptions}\n onRoadchange={this.selectCountry.bind(this)}\n ></road-area-code>\n <road-input\n id=\"phone-number\"\n sizes=\"xl\" \n label={this.inputLabel} // Transmission du label au composant road-input\n onInput={(event) => this.handleInput(event)} \n value={`+` + this.countryData[0].phoneCode}\n required={this.required}\n class={`${isInvalidClass}`}\n ></road-input>\n </road-input-group>\n {this.error && this.error !== '' && <p class=\"invalid-feedback\">{this.error}</p>}\n </Host>\n );\n }\n\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"phone-number-input.js","sourceRoot":"","sources":["../../../src/components/phone-number-input/phone-number-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACrG,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAqB/B,MAAM,OAAO,oBAAoB;;uBAYM,EAAE;oBACZ,IAAI;qBACH,SAAS;qBACQ,EAAE;sBAClB,QAAQ;sBACR,EAAE;oBAKZ,KAAK;2BAEW,EAAE;uBACN,EAAE;sBAEH,EAAE;0BAEiD,EAAE;;EAGnF,eAAe;IACb,IAAI,CAAC,oBAAoB,EAAE,CAAC;EAC9B,CAAC;EAED,oBAAoB;IAClB,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Element, Host, State, h, Watch, Event, EventEmitter } from '@stencil/core';\nimport {\n PhoneNumberFormat,\n PhoneNumberType,\n PhoneNumberUtil,\n} from 'google-libphonenumber';\n\ntype CountryType = {\n translations: { [key: string]: string },\n countryCode: string,\n phoneCode: string\n};\n\ninterface PhoneReturnType {\n phoneNumberType: string;\n countryCode: string;\n nationalNumber: string;\n phoneCode: string;\n internationalNumber: string;\n}\n\n@Component({\n tag: 'road-phone-number-input',\n styleUrl: 'phone-number-input.css',\n scoped: true,\n})\nexport class RoadPhoneNumberInput {\n\n /**\n * Emitt object data.\n */\n @Event() roadPhoneNumberInput!: EventEmitter<{\n isError: boolean;\n phone: PhoneReturnType;\n }>;\n\n @Element() el!: HTMLRoadPhoneNumberInputElement;\n\n @Prop() countryData: CountryType[] = [];\n @Prop() language: string = 'fr';\n @Prop() areaLabel: string = 'Country';\n @Prop({ mutable: true }) areaValue: string = '';\n @Prop() inputLabel: string = 'Number';\n @Prop() inputValue: string = '';\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n @State() selectedCountry: string = '';\n @State() phoneNumber: string = '';\n\n @State() inputError: string = '';\n\n @State() countryOptions: { value: string; label: string; selected: boolean }[] = [];\n\n @Watch('language')\n languageChanged() {\n this.updateCountryOptions();\n }\n\n updateCountryOptions() {\n const validLanguage = this.language && this.countryData[0].translations[this.language] ? this.language : 'fr';\n this.countryOptions = this.countryData.map(country => {\n return {\n value: country.phoneCode,\n label: `${country.translations[validLanguage]} (+${country.phoneCode})`,\n selected: country.countryCode === this.selectedCountry, // Ici, nous marquons l'option par défaut comme sélectionnée\n };\n });\n }\n\n componentWillLoad() {\n if (this.inputValue) {\n this.phoneNumber = this.inputValue;\n }\n\n if (this.areaValue) {\n this.selectedCountry = this.getPhoneCountryCode(this.areaValue);\n } else {\n if (this.countryData && this.countryData.length > 0) {\n this.selectedCountry = this.countryData[0].countryCode;\n }\n }\n\n this.updateCountryOptions();\n }\n\n getPhoneCountryCode(phoneCode: string): string {\n return this.countryData.find((country) => country.phoneCode === phoneCode)?.countryCode ?? '';\n }\n\n handleSelect(event: any) {\n const receivedPhoneCode = event.detail.value.replace('+', '');\n const phoneCountryCode = this.getPhoneCountryCode(receivedPhoneCode);\n\n this.selectedCountry = phoneCountryCode;\n\n this.createReturnObject();\n }\n\n createReturnObject() {\n const returnObject = {\n isError: true,\n phone: {\n phoneNumberType: 'UNKNOWN',\n countryCode: this.selectedCountry,\n nationalNumber: this.phoneNumber,\n phoneCode: this.countryData.find((country) => country.countryCode === this.selectedCountry)?.phoneCode ?? '',\n internationalNumber: this.phoneNumber,\n },\n };\n\n // create instance\n const phoneUtil = PhoneNumberUtil.getInstance();\n const PNF = PhoneNumberFormat;\n\n // Parse and verify the phone number\n try {\n const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber, this.selectedCountry as any);\n\n const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber));\n const phoneCode = parsedPhoneNumber.getCountryCode() as any;\n\n // get the phone's country code and updates the areaValue \n if (phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)) {\n this.selectedCountry = phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)!;\n\n const computedPhoneCode = this.countryData.find(country => country.countryCode == this.selectedCountry)?.phoneCode ?? '';\n this.areaValue = computedPhoneCode;\n }\n\n if (parsedPhoneNumber && phoneUtil.isValidNumber(parsedPhoneNumber)) {\n returnObject.isError = false;\n returnObject.phone = {\n phoneNumberType: phoneType ? phoneType[0] : 'UNKNOWN',\n countryCode: phoneUtil.getRegionCodeForNumber(parsedPhoneNumber) as any,\n phoneCode,\n nationalNumber: phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL),\n internationalNumber: phoneUtil.format(parsedPhoneNumber, PNF.E164),\n };\n \n this.inputError = '';\n\n } else {\n this.inputError = 'Numéro de téléphone non valide';\n }\n } catch {}\n\n this.roadPhoneNumberInput.emit(returnObject);\n }\n\n\n handleInput(event: any) {\n this.updateCountryOptions();\n\n this.phoneNumber = event.detail.value;\n\n this.createReturnObject();\n }\n\n /**\n * Emitted the value and label of the option selected.\n */\n @Event() roadselected!: EventEmitter<{\n value: string | undefined | null,\n label: string\n }>;\n /** @internal */\n @Event() roadSelected!: EventEmitter<{\n value: string | undefined | null,\n label: string\n }>;\n\n extractCallingCode(countryString: string) {\n const regex = /\\(([^)]+)\\)/;\n const found = countryString.match(regex);\n return found ? found[1] : '';\n }\n\n selectCountry(event: CustomEvent) {\n const countryString = event.detail.value; // Get the value from the custom event\n this.selectedCountry = this.extractCallingCode(countryString);\n (this.el.querySelector('.form-select-area-value') as HTMLElement).innerHTML = countryString;\n }\n\n render() {\n return (\n <Host>\n <road-input-group>\n <road-area-code\n slot=\"prepend\"\n class={`form-select has-value`}\n label={this.areaLabel}\n value={this.areaValue}\n sizes=\"xl\"\n options={this.countryOptions}\n onRoadchange={(event) => this.handleSelect(event)}\n ></road-area-code>\n <road-input\n id=\"phone-number\"\n sizes=\"xl\"\n label={this.inputLabel}\n value={this.inputValue}\n onRoadChange={(event) => this.handleInput(event)}\n required={this.required}\n error={this.inputError}\n ></road-input>\n </road-input-group>\n </Host>\n );\n }\n}\n\n\n"]}
|
|
@@ -16,15 +16,18 @@ export default {
|
|
|
16
16
|
required: {
|
|
17
17
|
control: 'boolean',
|
|
18
18
|
},
|
|
19
|
-
error: {
|
|
20
|
-
control: 'text',
|
|
21
|
-
},
|
|
22
19
|
areaLabel: {
|
|
23
20
|
control: 'text',
|
|
24
21
|
},
|
|
25
22
|
inputLabel: {
|
|
26
23
|
control: 'text',
|
|
27
24
|
},
|
|
25
|
+
areaValue: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
},
|
|
28
|
+
inputValue: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
},
|
|
28
31
|
},
|
|
29
32
|
args: {
|
|
30
33
|
required: null,
|
|
@@ -538,19 +541,22 @@ export default {
|
|
|
538
541
|
}
|
|
539
542
|
],
|
|
540
543
|
areaLabel: 'Indicatif',
|
|
544
|
+
areaValue: '',
|
|
541
545
|
language: 'fr',
|
|
542
|
-
inputLabel: 'Phone Number'
|
|
546
|
+
inputLabel: 'Phone Number',
|
|
547
|
+
inputValue: '',
|
|
543
548
|
},
|
|
544
549
|
};
|
|
545
550
|
|
|
546
551
|
const Template = (args) => html`
|
|
547
552
|
<road-phone-number-input
|
|
548
553
|
required="${ifDefined(args.required)}"
|
|
549
|
-
error="${ifDefined(args.error)}"
|
|
550
554
|
.countryData=${args.countryData}
|
|
551
555
|
language=${args.language}
|
|
552
556
|
area-label=${args.areaLabel}
|
|
557
|
+
area-value=${args.areaValue}
|
|
553
558
|
.inputLabel=${args.inputLabel}
|
|
559
|
+
.inputValue=${args.inputValue}
|
|
554
560
|
>
|
|
555
561
|
</road-phone-number-input>
|
|
556
562
|
`;
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { addIcons } from './components/icon/utils';\nexport { Components, JSX } from './components';"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export { addIcons } from './components/icon/utils';\nexport { addIllustrations } from './components/illustration/utils';\nexport { Components, JSX } from './components';"]}
|