@roadtrip/components 3.27.0 → 3.29.0
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/loader.cjs.js +1 -1
- package/dist/cjs/road-badge_14.cjs.entry.js +44 -13
- package/dist/cjs/road-badge_14.cjs.entry.js.map +1 -1
- package/dist/cjs/road-phone-number-input.cjs.entry.js +1 -1
- package/dist/cjs/road-phone-number-input.cjs.entry.js.map +1 -1
- package/dist/cjs/road-tab-button.cjs.entry.js +6 -4
- package/dist/cjs/road-tab-button.cjs.entry.js.map +1 -1
- package/dist/cjs/road-toggle.cjs.entry.js +3 -2
- package/dist/cjs/road-toggle.cjs.entry.js.map +1 -1
- package/dist/cjs/roadtrip.cjs.js +1 -1
- package/dist/collection/components/button/button.css +42 -2
- package/dist/collection/components/button/button.stories.js +13 -1
- package/dist/collection/components/drawer/drawer.css +8 -0
- package/dist/collection/components/input/input.js +13 -2
- package/dist/collection/components/input/input.js.map +1 -1
- package/dist/collection/components/input-group/input-group.css +67 -12
- package/dist/collection/components/input-group/input-group.js +55 -8
- package/dist/collection/components/input-group/input-group.js.map +1 -1
- package/dist/collection/components/input-group/input-group.stories.js +25 -15
- package/dist/collection/components/phone-number-input/phone-number-input.js +1 -1
- package/dist/collection/components/phone-number-input/phone-number-input.js.map +1 -1
- package/dist/collection/components/tab-button/tab-button.css +19 -2
- package/dist/collection/components/tab-button/tab-button.js +23 -3
- package/dist/collection/components/tab-button/tab-button.js.map +1 -1
- package/dist/collection/components/toggle/toggle.css +4 -0
- package/dist/collection/components/toggle/toggle.js +2 -1
- package/dist/collection/components/toggle/toggle.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/road-badge_14.entry.js +44 -13
- package/dist/esm/road-badge_14.entry.js.map +1 -1
- package/dist/esm/road-phone-number-input.entry.js +1 -1
- package/dist/esm/road-phone-number-input.entry.js.map +1 -1
- package/dist/esm/road-tab-button.entry.js +6 -4
- package/dist/esm/road-tab-button.entry.js.map +1 -1
- package/dist/esm/road-toggle.entry.js +3 -2
- package/dist/esm/road-toggle.entry.js.map +1 -1
- package/dist/esm/roadtrip.js +1 -1
- package/dist/html.html-data.json +10 -1
- package/dist/roadtrip/p-1115f970.entry.js +2 -0
- package/dist/roadtrip/p-1115f970.entry.js.map +1 -0
- package/dist/roadtrip/p-2e7d3440.entry.js +2 -0
- package/dist/roadtrip/p-2e7d3440.entry.js.map +1 -0
- package/dist/roadtrip/p-37563bb6.entry.js +2 -0
- package/dist/roadtrip/p-37563bb6.entry.js.map +1 -0
- package/dist/roadtrip/{p-026e28b6.entry.js → p-8ac960ce.entry.js} +2 -2
- package/dist/roadtrip/{p-026e28b6.entry.js.map → p-8ac960ce.entry.js.map} +1 -1
- 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/input/input.d.ts +1 -0
- package/dist/types/components/input-group/input-group.d.ts +7 -1
- package/dist/types/components/tab-button/tab-button.d.ts +4 -0
- package/dist/types/components.d.ts +16 -0
- package/hydrate/index.js +58 -21
- package/package.json +1 -1
- package/dist/roadtrip/p-0dbf612d.entry.js +0 -2
- package/dist/roadtrip/p-0dbf612d.entry.js.map +0 -1
- package/dist/roadtrip/p-430e6759.entry.js +0 -2
- package/dist/roadtrip/p-430e6759.entry.js.map +0 -1
- package/dist/roadtrip/p-c1dca3cc.entry.js +0 -2
- package/dist/roadtrip/p-c1dca3cc.entry.js.map +0 -1
|
@@ -83,22 +83,36 @@
|
|
|
83
83
|
/**
|
|
84
84
|
* Focus state
|
|
85
85
|
*/
|
|
86
|
+
/* Pour les éléments slottés [slot="prepend"] */
|
|
86
87
|
|
|
87
|
-
.input-group:focus-within ::slotted([slot="prepend"])
|
|
88
|
-
border-color: var(--road-input-outline-variant);
|
|
89
|
-
border-right-color: transparent;
|
|
90
|
-
}
|
|
91
|
-
|
|
88
|
+
.input-group:focus-within ::slotted([slot="prepend"]),
|
|
92
89
|
:host(.phone-number-group) .input-group:focus-within ::slotted([slot="prepend"]) {
|
|
93
|
-
border-color: var(--road-
|
|
90
|
+
border-color: var(--road-grey-0);
|
|
91
|
+
border-width: 2px;
|
|
94
92
|
border-right-color: transparent;
|
|
93
|
+
outline: none; /* Affiche l'outline par défaut au focus */
|
|
95
94
|
}
|
|
96
95
|
|
|
96
|
+
/* Pour les éléments slottés [slot="append"] */
|
|
97
|
+
|
|
97
98
|
.input-group:focus-within ::slotted([slot="append"]) {
|
|
98
|
-
border-color: var(--road-
|
|
99
|
+
border-color: var(--road-grey-0);
|
|
100
|
+
border-width: 2px;
|
|
99
101
|
border-left-color: transparent;
|
|
102
|
+
outline: none; /* Affiche l'outline par défaut au focus */
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Pour le champ principal dans road-input */
|
|
106
|
+
|
|
107
|
+
.input-group:focus-within ::slotted(road-input):focus-visible {
|
|
108
|
+
border-color: var(--road-grey-0);
|
|
109
|
+
border-width: 2px;
|
|
110
|
+
outline: none; /* Active le contour d'accessibilité par défaut */
|
|
100
111
|
}
|
|
101
112
|
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
102
116
|
/* PREPEND - APPEND
|
|
103
117
|
-------------------- */
|
|
104
118
|
|
|
@@ -119,6 +133,10 @@
|
|
|
119
133
|
font-size: var(--road-font-size-14);
|
|
120
134
|
}
|
|
121
135
|
|
|
136
|
+
::slotted(road-button):hover {
|
|
137
|
+
background-color: var(--road-button-ghost-variant);
|
|
138
|
+
}
|
|
139
|
+
|
|
122
140
|
.input-group-prepend {
|
|
123
141
|
z-index: 1;
|
|
124
142
|
order: -1;
|
|
@@ -152,6 +170,21 @@
|
|
|
152
170
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
153
171
|
}
|
|
154
172
|
|
|
173
|
+
::slotted(road-label) {
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
padding: 0 0.5rem;
|
|
177
|
+
margin-bottom: 0;
|
|
178
|
+
color: var(--road-on-surface);
|
|
179
|
+
text-align: center;
|
|
180
|
+
white-space: nowrap;
|
|
181
|
+
cursor: text;
|
|
182
|
+
background: var(--road-surface);
|
|
183
|
+
border: 1px solid var(--road-input-outline);
|
|
184
|
+
border-radius: 0.25rem;
|
|
185
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
186
|
+
}
|
|
187
|
+
|
|
155
188
|
/* ROUND CORNERS
|
|
156
189
|
-------------------- */
|
|
157
190
|
|
|
@@ -186,6 +219,11 @@
|
|
|
186
219
|
background-color: var(--road-surface);
|
|
187
220
|
}
|
|
188
221
|
|
|
222
|
+
.input-group-append:hover ::slotted(road-button) {
|
|
223
|
+
background-color: var(--road-button-ghost-variant);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
189
227
|
/* SIZES
|
|
190
228
|
-------------------- */
|
|
191
229
|
|
|
@@ -211,14 +249,31 @@
|
|
|
211
249
|
}
|
|
212
250
|
|
|
213
251
|
/* DISABLED
|
|
214
|
-
|
|
252
|
+
-------------------- */
|
|
215
253
|
|
|
216
|
-
|
|
217
|
-
|
|
254
|
+
:host([disabled]) {
|
|
255
|
+
cursor: not-allowed;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
:host([disabled]) .input-group {
|
|
259
|
+
pointer-events: none; /* Désactive les interactions avec l'ensemble du groupe */
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
:host([disabled]) ::slotted([slot="append"]),
|
|
263
|
+
:host([disabled]) ::slotted([slot="prepend"]) {
|
|
264
|
+
color: var(--road-on-surface-disabled);
|
|
218
265
|
cursor: not-allowed;
|
|
219
266
|
background: #e4e5e9;
|
|
220
267
|
}
|
|
221
268
|
|
|
222
|
-
|
|
223
|
-
|
|
269
|
+
:host([disabled]) ::slotted([slot="append"] road-icon),
|
|
270
|
+
:host([disabled]) ::slotted([slot="prepend"] road-icon) {
|
|
271
|
+
color: var(--road-on-surface-disabled);
|
|
224
272
|
}
|
|
273
|
+
|
|
274
|
+
:host([disabled]) road-icon {
|
|
275
|
+
color: var(--road-on-surface-disabled);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
@@ -5,16 +5,35 @@ import { h } from "@stencil/core";
|
|
|
5
5
|
* @slot append - Add icon or button after the field.
|
|
6
6
|
*/
|
|
7
7
|
export class InputGroup {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
this.disabled = false;
|
|
10
|
+
}
|
|
11
|
+
/** Watches for changes in the `disabled` prop and updates child elements. */
|
|
12
|
+
handleDisabledChange(newValue) {
|
|
13
|
+
this.updateDisabledState(newValue);
|
|
14
|
+
}
|
|
15
|
+
/** Applies or removes the `disabled` attribute to/from children. */
|
|
16
|
+
updateDisabledState(isDisabled) {
|
|
17
|
+
const children = this.el.querySelectorAll('road-input, road-button, road-select');
|
|
18
|
+
children.forEach(child => {
|
|
19
|
+
if (isDisabled) {
|
|
20
|
+
child.setAttribute('disabled', '');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
child.removeAttribute('disabled');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
componentWillLoad() {
|
|
28
|
+
// Ensure the initial state of `disabled` is applied before render.
|
|
29
|
+
this.updateDisabledState(this.disabled);
|
|
13
30
|
}
|
|
14
31
|
render() {
|
|
15
|
-
const errorClass = this.el.querySelector(
|
|
16
|
-
const
|
|
17
|
-
|
|
32
|
+
const errorClass = this.el.querySelector('road-input[error]') ? 'is-invalid' : '';
|
|
33
|
+
const sizeClass = this.el.querySelector('road-input[sizes]')
|
|
34
|
+
? `size-${this.el.querySelector('road-input').sizes}`
|
|
35
|
+
: '';
|
|
36
|
+
const disabledClass = this.disabled ? 'is-disabled' : '';
|
|
18
37
|
return (h("div", { class: `input-group ${errorClass} ${disabledClass} ${sizeClass}` }, h("div", { class: "input-group-prepend" }, h("slot", { name: "prepend" })), h("slot", null), h("div", { class: "input-group-append" }, h("slot", { name: "append" }))));
|
|
19
38
|
}
|
|
20
39
|
static get is() { return "road-input-group"; }
|
|
@@ -29,6 +48,34 @@ export class InputGroup {
|
|
|
29
48
|
"$": ["input-group.css"]
|
|
30
49
|
};
|
|
31
50
|
}
|
|
51
|
+
static get properties() {
|
|
52
|
+
return {
|
|
53
|
+
"disabled": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"mutable": false,
|
|
56
|
+
"complexType": {
|
|
57
|
+
"original": "boolean",
|
|
58
|
+
"resolved": "boolean",
|
|
59
|
+
"references": {}
|
|
60
|
+
},
|
|
61
|
+
"required": false,
|
|
62
|
+
"optional": false,
|
|
63
|
+
"docs": {
|
|
64
|
+
"tags": [],
|
|
65
|
+
"text": "Disables the entire input group and propagates the state to children."
|
|
66
|
+
},
|
|
67
|
+
"attribute": "disabled",
|
|
68
|
+
"reflect": false,
|
|
69
|
+
"defaultValue": "false"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
32
73
|
static get elementRef() { return "el"; }
|
|
74
|
+
static get watchers() {
|
|
75
|
+
return [{
|
|
76
|
+
"propName": "disabled",
|
|
77
|
+
"methodName": "handleDisabledChange"
|
|
78
|
+
}];
|
|
79
|
+
}
|
|
33
80
|
}
|
|
34
81
|
//# sourceMappingURL=input-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.js","sourceRoot":"","sources":["../../../src/components/input-group/input-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"input-group.js","sourceRoot":"","sources":["../../../src/components/input-group/input-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EA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AAS,GAAG,CACnB;MACN,eAAQ;MACR,WAAK,KAAK,EAAC,oBAAoB;QAC7B,YAAM,IAAI,EAAC,QAAQ,GAAG,CAClB,CACF,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Prop, Watch } from '@stencil/core';\n\n/**\n * @slot prepend - Add icon or button before the field.\n * @slot - Add the road-input or road-select here.\n * @slot append - Add icon or button after the field.\n */\n\n@Component({\n tag: 'road-input-group',\n styleUrl: 'input-group.css',\n shadow: true,\n})\nexport class InputGroup {\n @Element() el!: HTMLRoadInputGroupElement;\n\n /** Disables the entire input group and propagates the state to children. */\n @Prop() disabled: boolean = false;\n\n /** Watches for changes in the `disabled` prop and updates child elements. */\n @Watch('disabled')\n handleDisabledChange(newValue: boolean) {\n this.updateDisabledState(newValue);\n }\n\n /** Applies or removes the `disabled` attribute to/from children. */\n private updateDisabledState(isDisabled: boolean) {\n const children = this.el.querySelectorAll('road-input, road-button, road-select');\n children.forEach(child => {\n if (isDisabled) {\n child.setAttribute('disabled', '');\n } else {\n child.removeAttribute('disabled');\n }\n });\n }\n\n componentWillLoad() {\n // Ensure the initial state of `disabled` is applied before render.\n this.updateDisabledState(this.disabled);\n }\n\n render() {\n const errorClass = this.el.querySelector('road-input[error]') ? 'is-invalid' : '';\n const sizeClass = this.el.querySelector('road-input[sizes]') \n ? `size-${(this.el.querySelector('road-input') as HTMLRoadInputElement).sizes}` \n : '';\n const disabledClass = this.disabled ? 'is-disabled' : '';\n\n return (\n <div class={`input-group ${errorClass} ${disabledClass} ${sizeClass}`}>\n <div class=\"input-group-prepend\">\n <slot name=\"prepend\" />\n </div>\n <slot />\n <div class=\"input-group-append\">\n <slot name=\"append\" />\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -14,14 +14,20 @@ export default {
|
|
|
14
14
|
append: {
|
|
15
15
|
control: 'text',
|
|
16
16
|
},
|
|
17
|
+
disabled: {
|
|
18
|
+
control: 'boolean',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
disabled: false, // Défaut : non désactivé
|
|
17
23
|
},
|
|
18
24
|
};
|
|
19
25
|
|
|
20
26
|
const Template = (args) => html`
|
|
21
|
-
<road-input-group>
|
|
22
|
-
${unsafeHTML(args
|
|
23
|
-
${unsafeHTML(args
|
|
24
|
-
${unsafeHTML(args.append)}
|
|
27
|
+
<road-input-group ?disabled=${args.disabled}>
|
|
28
|
+
${unsafeHTML(args.prepend || '')}
|
|
29
|
+
${unsafeHTML(args[' '] || '')}
|
|
30
|
+
${unsafeHTML(args.append || '')}
|
|
25
31
|
</road-input-group>
|
|
26
32
|
`;
|
|
27
33
|
|
|
@@ -36,31 +42,35 @@ Playground.args = {
|
|
|
36
42
|
export const Button = Template.bind({});
|
|
37
43
|
Button.args = {
|
|
38
44
|
' ': `<road-input input-id="newsletter" sizes="xl" label="Newsletter"></road-input>`,
|
|
39
|
-
append: `<road-button slot="append"
|
|
40
|
-
|
|
41
|
-
</road-button>`,
|
|
45
|
+
append: `<road-button slot="append" color="ghost">
|
|
46
|
+
OK
|
|
47
|
+
</road-button>`,
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
export const Disabled = Template.bind({});
|
|
45
51
|
Disabled.args = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
disabled: true, // Désactive tout le groupe
|
|
53
|
+
' ': `<road-input input-id="inputGroupDisabled" sizes="xl" label="Label" disabled></road-input>`,
|
|
54
|
+
prepend: `<road-button slot="prepend" outline="true" disabled>
|
|
55
|
+
<road-icon color="secondary" name="alert-info-outline"></road-icon>
|
|
56
|
+
</road-button>`,
|
|
57
|
+
append: `<road-button slot="append" outline="true" disabled>
|
|
58
|
+
<road-icon color="secondary" name="alert-info-outline"></road-icon>
|
|
59
|
+
</road-button>`,
|
|
50
60
|
};
|
|
51
61
|
|
|
52
62
|
export const Error = Template.bind({});
|
|
53
63
|
Error.args = {
|
|
54
64
|
' ': `<road-input input-id="inputGroupError" sizes="xl" label="Label" error="error message here"></road-input>`,
|
|
55
65
|
append: `<label slot="append">
|
|
56
|
-
|
|
57
|
-
</label>`,
|
|
66
|
+
<road-icon name="payment-card" role="img"></road-icon>
|
|
67
|
+
</label>`,
|
|
58
68
|
};
|
|
59
69
|
|
|
60
70
|
export const Password = Template.bind({});
|
|
61
71
|
Password.args = {
|
|
62
72
|
' ': `<road-input input-id="password" sizes="xl" label="password" type="password"></road-input>`,
|
|
63
73
|
append: `<road-button slot="append" outline="true">
|
|
64
|
-
|
|
65
|
-
</road-button>`,
|
|
74
|
+
<road-icon name="visibility-off-outline" role="button"></road-icon>
|
|
75
|
+
</road-button>`,
|
|
66
76
|
};
|
|
@@ -190,7 +190,7 @@ export class RoadPhoneNumberInput {
|
|
|
190
190
|
const valueId = selectId + '-value';
|
|
191
191
|
const isInvalidClass = this.errorMessage.length ? 'is-invalid' : '';
|
|
192
192
|
const isErrorClass = this.errorMessage.length ? 'is-error' : '';
|
|
193
|
-
return (h(Host, null, h("road-input-group", null, h("div", { class: `road-phone-input-select ${isErrorClass}`, slot: "prepend" }, h("select", { id: 'phone-number-input', class: `form-select-area has-value ${isInvalidClass}`, "aria-disabled": this.disabled ? 'true' : null, disabled: this.disabled, onChange: (event) => this.handleSelect(event), "aria-label": this.codeLabel, tabIndex: this.disabled ? -1 : 0 }, this.countryOptions && this.countryOptions.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.selected }, option.label)))), h("label", { class: "form-select-area-label", id: labelId, htmlFor: selectId }, this.codeLabel), h("label", { class: "form-select-area-value", id: valueId, htmlFor: selectId }, "+", this.selectedCountryCode)), h("road-input", { id: "phone-number", sizes: "xl", label: this.phoneLabel, value: this.phoneValue, onRoadChange: (event) => this.handleInput(event), required: this.required, error: this.errorMessage, onKeyDown: (event) => this.handleKeyDown(event), tabIndex: 0 }))));
|
|
193
|
+
return (h(Host, null, h("road-input-group", null, h("div", { class: `road-phone-input-select ${isErrorClass}`, slot: "prepend" }, h("select", { id: 'phone-number-input', class: `form-select-area has-value ${isInvalidClass}`, "aria-disabled": this.disabled ? 'true' : null, disabled: this.disabled, onChange: (event) => this.handleSelect(event), "aria-label": this.codeLabel, tabIndex: this.disabled ? -1 : 0 }, this.countryOptions && this.countryOptions.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.selected }, option.label)))), h("label", { class: "form-select-area-label", id: labelId, htmlFor: selectId }, this.codeLabel), h("label", { class: "form-select-area-value", id: valueId, htmlFor: selectId }, "+", this.selectedCountryCode)), h("road-input", { type: "tel", id: "phone-number", sizes: "xl", label: this.phoneLabel, value: this.phoneValue, onRoadChange: (event) => this.handleInput(event), required: this.required, error: this.errorMessage, onKeyDown: (event) => this.handleKeyDown(event), tabIndex: 0 }))));
|
|
194
194
|
}
|
|
195
195
|
static get is() { return "road-phone-number-input"; }
|
|
196
196
|
static get encapsulation() { return "scoped"; }
|
|
@@ -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,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI5F,IAAI,SAAS,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,oBAAoB;;oBAiBH,KAAK;uBAGI,EAAE;oBAGZ,IAAI;qBAGH,EAAE;sBAGD,EAAE;;;wBASA,EAAE;oBAGd,KAAK;2BAEW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW;+BAC3B,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;uBACrC,EAAE;0BACU,EAAE;wBACP;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OAAO,EAAE,OAAO,EAAE,QAAQ,IAAG,IAAI,CAAC,SAAS,CAAS;UAC9F,aAAO,KAAK,EAAC,wBAAwB,EAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ;;YAAI,IAAI,CAAC,mBAAmB,CAAS,CACrG;QACN,kBACE,EAAE,EAAC,cAAc,EACjB,KAAK,EAAC,IAAI,EACV,KAAK,EAAE,IAAI,CAAC,UAAU,EACtB,KAAK,EAAE,IAAI,CAAC,UAAU,EACtB,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,YAAY,EACxB,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAC/C,QAAQ,EAAE,CAAC,GAEA,CACI,CACd,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Element, Host, State, h, Event, EventEmitter, Watch } from '@stencil/core';\nimport { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil } from 'google-libphonenumber';\nimport { CountryOption, CountryType, PhoneReturnType, ReturnObject } from './interfaces';\nimport { RoadInputCustomEvent } from '../../components';\n\nlet selectIds = 0;\n\n@Component({\n tag: 'road-phone-number-input',\n styleUrl: 'phone-number-input.css',\n scoped: true,\n})\nexport class RoadPhoneNumberInput {\n\n /** Computed phone data */\n @Event() roadPhoneNumberInput!: EventEmitter<{\n isError: boolean;\n phone: {\n numberType: string;\n countryCode: string;\n nationalNumber: string;\n code: string;\n internationalNumber: string;\n };\n }>;\n\n @Element() el!: HTMLRoadPhoneNumberInputElement;\n\n /** Disable both fields */\n @Prop() disabled: boolean = false;\n\n /** List of countries displayed in the country selection. Countries will be automatically sorted by alphabetical order (see format in example) */\n @Prop() countryData: CountryType[] = [];\n\n /** Used to display countries with the right language */\n @Prop() language: string = 'fr';\n\n /** Country selection placeHolder */\n @Prop() codeLabel: string = '';\n\n /** Phone input placeHolder */\n @Prop() phoneLabel: string = '';\n\n /** Value displayed in the phone input */\n @Prop() phoneValue?: string;\n\n /** Selected country code */\n @Prop() countryCode?: string;\n\n /** Error message (displayed only if ther is a message) */\n @Prop() errorMessage: string = '';\n\n /** Add a star in the phone input */\n @Prop() required = false;\n\n @State() selectedCountry: string = this.countryData[0].countryCode;\n @State() selectedCountryCode: string = this.countryData[0].phoneCode;\n @State() phoneNumber: string = '';\n @State() countryOptions: CountryOption[] = [];\n @State() returnObject: ReturnObject = {\n isError: false,\n phone: this.resetPhoneUtilData(),\n };\n\n @Watch('errorMessage')\n updateMessagePosition() {\n this.placeErrorMessage();\n }\n\n // On component load\n componentWillLoad() {\n this.placeErrorMessage();\n let fromSelect = false;\n\n if (this.phoneValue) {\n this.phoneNumber = this.phoneValue;\n }\n\n if (this.countryCode) {\n this.selectedCountry = this.countryCode;\n if (this.getPhoneCodeFromCountryCode(this.countryCode)) {\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.countryCode)!);\n fromSelect = true;\n }\n }\n\n this.updateCountryOptions();\n this.createAndDispatchPhoneData(fromSelect);\n }\n\n // On user input\n handleInput(event: RoadInputCustomEvent<{\n value: string | null | undefined;\n }>) {\n this.phoneNumber = event.detail.value!;\n this.createAndDispatchPhoneData();\n }\n \n\n // On user key down\n handleKeyDown(event: KeyboardEvent) {\n // Liste des caractères interdits\n const caracteresInterdits = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '=', '[', ']', '{', '}', '|', ';', ':', \"'\", '\"', ',', '.', '<', '>', '/', '?'];\n \n // Vérifier si la touche pressée est dans la liste des caractères interdits\n if (caracteresInterdits.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n // On user key up\n handleKeyUp(event: KeyboardEvent) {\n // Récupérer la valeur saisie\n const inputValue = (event.target as HTMLInputElement).value || '';\n\n // Vérifier si la valeur contient uniquement des chiffres ou le symbole \"+\"\n const containsOnlyNumbersAndPlus = /^[0-9+]*$/.test(inputValue);\n\n // Si la valeur ne contient pas uniquement des chiffres ou le symbole \"+\", réinitialiser le champ de saisie à son état précédent\n if (!containsOnlyNumbersAndPlus) {\n // Réinitialiser la valeur du champ de saisie à son état précédent\n (event.target as HTMLInputElement).value = this.phoneNumber;\n } else {\n // Si la valeur contient uniquement des chiffres ou le symbole \"+\", mettre à jour la valeur du numéro de téléphone\n this.phoneNumber = inputValue;\n this.createAndDispatchPhoneData();\n }\n }\n\n // On user select\n handleSelect(event: Event) {\n const select = event.target as HTMLSelectElement | null;\n if (select) {\n this.updateSelectedCountry(select.value);\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.selectedCountry)!);\n }\n this.createAndDispatchPhoneData(true);\n this.updateCountryOptions();\n }\n\n createAndDispatchPhoneData(fromSelect?: boolean) {\n // Init phone util\n const phoneUtil = PhoneNumberUtil.getInstance();\n const PNF = PhoneNumberFormat;\n\n // Reset the return object data\n this.returnObject.phone = this.resetPhoneUtilData();\n\n const tmpCountry = this.selectedCountry.length ? this.selectedCountry : this.countryData[0].countryCode;\n\n try {\n const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber, tmpCountry);\n this.returnObject.isError = !phoneUtil.isValidNumber(parsedPhoneNumber) && !this.isEmptyPhoneNumber();\n this.returnObject.phone.nationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL);\n this.returnObject.phone.internationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.INTERNATIONAL);\n\n // Set the country code values depending on the event origin\n if (phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)) {\n if (fromSelect) {\n this.returnObject.isError = !(\n phoneUtil.isValidNumber(parsedPhoneNumber) &&\n phoneUtil.isValidNumberForRegion(parsedPhoneNumber, this.selectedCountry) &&\n !this.isEmptyPhoneNumber()\n );\n } else {\n this.updateSelectedCountryCode(parsedPhoneNumber.getCountryCode()!.toString());\n this.updateSelectedCountry(phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)!);\n\n this.returnObject.phone.countryCode = this.selectedCountry;\n this.returnObject.phone.code = this.selectedCountryCode;\n }\n this.updateCountryOptions();\n }\n\n const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber))!;\n this.returnObject.phone.numberType = phoneType[0];\n } catch {} finally {\n this.roadPhoneNumberInput.emit(this.returnObject);\n }\n }\n\n // utils\n\n updateSelectedCountryCode(countryCode: string) {\n this.selectedCountryCode = countryCode;\n }\n\n updateSelectedCountry(value: string) {\n this.selectedCountry = value;\n }\n\n resetPhoneUtilData(): PhoneReturnType {\n return {\n numberType: 'UNKNOWN',\n countryCode: this.selectedCountry,\n code: this.selectedCountryCode,\n nationalNumber: this.phoneNumber,\n internationalNumber: this.phoneNumber,\n };\n }\n\n isEmptyPhoneNumber(): boolean {\n return !this.phoneNumber.length;\n }\n\n getPhoneCodeFromCountryCode(countryCode: string): string | undefined {\n return this.countryData.find(country => country.countryCode === countryCode)?.phoneCode;\n }\n\n updateCountryOptions() {\n const validLanguage = this.countryData[0].translations[this.language] ? this.language : 'fr';\n this.countryOptions = [\n ...this.countryData\n .sort((a, b) => a.translations[validLanguage].localeCompare(b.translations[validLanguage]))\n .map(country => ({\n value: country.countryCode,\n label: `${country.translations[validLanguage]} (+${country.phoneCode})`,\n selected: country.countryCode === this.selectedCountry,\n disabled: false,\n })\n ),\n {\n value: '',\n label: '--',\n selected: this.countryData.every((country) => country.countryCode !== this.selectedCountry),\n disabled: true,\n },\n ];\n }\n\n placeErrorMessage() {\n this.waitForElementToExist('.invalid-feedback').then((messError: HTMLElement) => {\n messError.style.display = \"flex\";\n messError.style.marginTop = \"-0.5rem\";\n const phoneNumberInput = (this.el as HTMLRoadPhoneNumberInputElement);\n phoneNumberInput.appendChild(messError);\n });\n }\n\n waitForElementToExist(selector: string): Promise<HTMLElement> {\n return new Promise(resolve => {\n if (document.querySelector(selector)) {\n return resolve(document.querySelector(selector) as HTMLElement);\n }\n\n const observer = new MutationObserver(() => {\n if (document.querySelector(selector)) {\n resolve(document.querySelector(selector) as HTMLElement);\n observer.disconnect();\n }\n });\n\n observer.observe(document.body, {\n subtree: true,\n childList: true,\n });\n });\n }\n\n render() {\n const selectId = `road-select-${selectIds++}`;\n const labelId = selectId + '-label';\n const valueId = selectId + '-value';\n const isInvalidClass = this.errorMessage.length ? 'is-invalid' : '';\n const isErrorClass = this.errorMessage.length ? 'is-error' : '';\n\n return (\n <Host>\n <road-input-group>\n <div class={`road-phone-input-select ${isErrorClass}`} slot=\"prepend\">\n <select\n id='phone-number-input'\n class={`form-select-area has-value ${isInvalidClass}`}\n aria-disabled={this.disabled ? 'true' : null}\n disabled={this.disabled}\n onChange={(event) => this.handleSelect(event)}\n aria-label={this.codeLabel}\n tabIndex={this.disabled ? -1 : 0}\n >\n {this.countryOptions && this.countryOptions.map(option => (\n <option value={option.value} disabled={option.disabled} selected={option.selected}>{option.label}</option>\n ))}\n </select>\n <label class=\"form-select-area-label\" id={labelId} htmlFor={selectId}>{this.codeLabel}</label>\n <label class=\"form-select-area-value\" id={valueId} htmlFor={selectId}>+{this.selectedCountryCode}</label>\n </div>\n <road-input\n id=\"phone-number\"\n sizes=\"xl\"\n label={this.phoneLabel}\n value={this.phoneValue}\n onRoadChange={(event) => this.handleInput(event)}\n required={this.required}\n error={this.errorMessage}\n onKeyDown={(event) => this.handleKeyDown(event)} // Lier la fonction handleKeyDown à l'événement onKeyDown\n tabIndex={0}\n >\n </road-input>\n </road-input-group>\n </Host>\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,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI5F,IAAI,SAAS,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,oBAAoB;;oBAiBH,KAAK;uBAGI,EAAE;oBAGZ,IAAI;qBAGH,EAAE;sBAGD,EAAE;;;wBASA,EAAE;oBAGd,KAAK;2BAEW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW;+BAC3B,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;uBACrC,EAAE;0BACU,EAAE;wBACP;MACpC,OAAO,EAAE,KAAK;MACd,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE;KACjC;;EAGD,qBAAqB;IACnB,IAAI,CAAC,iBAAiB,EAAE,CAAC;EAC3B,CAAC;EAED,oBAAoB;EACpB,iBAAiB;IACf,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzB,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,IAAI,IAAI,CAAC,UAAU,EAAE;MACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC;KACpC;IAED,IAAI,IAAI,CAAC,WAAW,EAAE;MACpB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IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,YAAY,EACxB,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAC/C,QAAQ,EAAE,CAAC,GAEA,CACI,CACd,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Element, Host, State, h, Event, EventEmitter, Watch } from '@stencil/core';\nimport { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil } from 'google-libphonenumber';\nimport { CountryOption, CountryType, PhoneReturnType, ReturnObject } from './interfaces';\nimport { RoadInputCustomEvent } from '../../components';\n\nlet selectIds = 0;\n\n@Component({\n tag: 'road-phone-number-input',\n styleUrl: 'phone-number-input.css',\n scoped: true,\n})\nexport class RoadPhoneNumberInput {\n\n /** Computed phone data */\n @Event() roadPhoneNumberInput!: EventEmitter<{\n isError: boolean;\n phone: {\n numberType: string;\n countryCode: string;\n nationalNumber: string;\n code: string;\n internationalNumber: string;\n };\n }>;\n\n @Element() el!: HTMLRoadPhoneNumberInputElement;\n\n /** Disable both fields */\n @Prop() disabled: boolean = false;\n\n /** List of countries displayed in the country selection. Countries will be automatically sorted by alphabetical order (see format in example) */\n @Prop() countryData: CountryType[] = [];\n\n /** Used to display countries with the right language */\n @Prop() language: string = 'fr';\n\n /** Country selection placeHolder */\n @Prop() codeLabel: string = '';\n\n /** Phone input placeHolder */\n @Prop() phoneLabel: string = '';\n\n /** Value displayed in the phone input */\n @Prop() phoneValue?: string;\n\n /** Selected country code */\n @Prop() countryCode?: string;\n\n /** Error message (displayed only if ther is a message) */\n @Prop() errorMessage: string = '';\n\n /** Add a star in the phone input */\n @Prop() required = false;\n\n @State() selectedCountry: string = this.countryData[0].countryCode;\n @State() selectedCountryCode: string = this.countryData[0].phoneCode;\n @State() phoneNumber: string = '';\n @State() countryOptions: CountryOption[] = [];\n @State() returnObject: ReturnObject = {\n isError: false,\n phone: this.resetPhoneUtilData(),\n };\n\n @Watch('errorMessage')\n updateMessagePosition() {\n this.placeErrorMessage();\n }\n\n // On component load\n componentWillLoad() {\n this.placeErrorMessage();\n let fromSelect = false;\n\n if (this.phoneValue) {\n this.phoneNumber = this.phoneValue;\n }\n\n if (this.countryCode) {\n this.selectedCountry = this.countryCode;\n if (this.getPhoneCodeFromCountryCode(this.countryCode)) {\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.countryCode)!);\n fromSelect = true;\n }\n }\n\n this.updateCountryOptions();\n this.createAndDispatchPhoneData(fromSelect);\n }\n\n // On user input\n handleInput(event: RoadInputCustomEvent<{\n value: string | null | undefined;\n }>) {\n this.phoneNumber = event.detail.value!;\n this.createAndDispatchPhoneData();\n }\n \n\n // On user key down\n handleKeyDown(event: KeyboardEvent) {\n // Liste des caractères interdits\n const caracteresInterdits = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '=', '[', ']', '{', '}', '|', ';', ':', \"'\", '\"', ',', '.', '<', '>', '/', '?'];\n \n // Vérifier si la touche pressée est dans la liste des caractères interdits\n if (caracteresInterdits.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n // On user key up\n handleKeyUp(event: KeyboardEvent) {\n // Récupérer la valeur saisie\n const inputValue = (event.target as HTMLInputElement).value || '';\n\n // Vérifier si la valeur contient uniquement des chiffres ou le symbole \"+\"\n const containsOnlyNumbersAndPlus = /^[0-9+]*$/.test(inputValue);\n\n // Si la valeur ne contient pas uniquement des chiffres ou le symbole \"+\", réinitialiser le champ de saisie à son état précédent\n if (!containsOnlyNumbersAndPlus) {\n // Réinitialiser la valeur du champ de saisie à son état précédent\n (event.target as HTMLInputElement).value = this.phoneNumber;\n } else {\n // Si la valeur contient uniquement des chiffres ou le symbole \"+\", mettre à jour la valeur du numéro de téléphone\n this.phoneNumber = inputValue;\n this.createAndDispatchPhoneData();\n }\n }\n\n // On user select\n handleSelect(event: Event) {\n const select = event.target as HTMLSelectElement | null;\n if (select) {\n this.updateSelectedCountry(select.value);\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.selectedCountry)!);\n }\n this.createAndDispatchPhoneData(true);\n this.updateCountryOptions();\n }\n\n createAndDispatchPhoneData(fromSelect?: boolean) {\n // Init phone util\n const phoneUtil = PhoneNumberUtil.getInstance();\n const PNF = PhoneNumberFormat;\n\n // Reset the return object data\n this.returnObject.phone = this.resetPhoneUtilData();\n\n const tmpCountry = this.selectedCountry.length ? this.selectedCountry : this.countryData[0].countryCode;\n\n try {\n const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber, tmpCountry);\n this.returnObject.isError = !phoneUtil.isValidNumber(parsedPhoneNumber) && !this.isEmptyPhoneNumber();\n this.returnObject.phone.nationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL);\n this.returnObject.phone.internationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.INTERNATIONAL);\n\n // Set the country code values depending on the event origin\n if (phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)) {\n if (fromSelect) {\n this.returnObject.isError = !(\n phoneUtil.isValidNumber(parsedPhoneNumber) &&\n phoneUtil.isValidNumberForRegion(parsedPhoneNumber, this.selectedCountry) &&\n !this.isEmptyPhoneNumber()\n );\n } else {\n this.updateSelectedCountryCode(parsedPhoneNumber.getCountryCode()!.toString());\n this.updateSelectedCountry(phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)!);\n\n this.returnObject.phone.countryCode = this.selectedCountry;\n this.returnObject.phone.code = this.selectedCountryCode;\n }\n this.updateCountryOptions();\n }\n\n const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber))!;\n this.returnObject.phone.numberType = phoneType[0];\n } catch {} finally {\n this.roadPhoneNumberInput.emit(this.returnObject);\n }\n }\n\n // utils\n\n updateSelectedCountryCode(countryCode: string) {\n this.selectedCountryCode = countryCode;\n }\n\n updateSelectedCountry(value: string) {\n this.selectedCountry = value;\n }\n\n resetPhoneUtilData(): PhoneReturnType {\n return {\n numberType: 'UNKNOWN',\n countryCode: this.selectedCountry,\n code: this.selectedCountryCode,\n nationalNumber: this.phoneNumber,\n internationalNumber: this.phoneNumber,\n };\n }\n\n isEmptyPhoneNumber(): boolean {\n return !this.phoneNumber.length;\n }\n\n getPhoneCodeFromCountryCode(countryCode: string): string | undefined {\n return this.countryData.find(country => country.countryCode === countryCode)?.phoneCode;\n }\n\n updateCountryOptions() {\n const validLanguage = this.countryData[0].translations[this.language] ? this.language : 'fr';\n this.countryOptions = [\n ...this.countryData\n .sort((a, b) => a.translations[validLanguage].localeCompare(b.translations[validLanguage]))\n .map(country => ({\n value: country.countryCode,\n label: `${country.translations[validLanguage]} (+${country.phoneCode})`,\n selected: country.countryCode === this.selectedCountry,\n disabled: false,\n })\n ),\n {\n value: '',\n label: '--',\n selected: this.countryData.every((country) => country.countryCode !== this.selectedCountry),\n disabled: true,\n },\n ];\n }\n\n placeErrorMessage() {\n this.waitForElementToExist('.invalid-feedback').then((messError: HTMLElement) => {\n messError.style.display = \"flex\";\n messError.style.marginTop = \"-0.5rem\";\n const phoneNumberInput = (this.el as HTMLRoadPhoneNumberInputElement);\n phoneNumberInput.appendChild(messError);\n });\n }\n\n waitForElementToExist(selector: string): Promise<HTMLElement> {\n return new Promise(resolve => {\n if (document.querySelector(selector)) {\n return resolve(document.querySelector(selector) as HTMLElement);\n }\n\n const observer = new MutationObserver(() => {\n if (document.querySelector(selector)) {\n resolve(document.querySelector(selector) as HTMLElement);\n observer.disconnect();\n }\n });\n\n observer.observe(document.body, {\n subtree: true,\n childList: true,\n });\n });\n }\n\n render() {\n const selectId = `road-select-${selectIds++}`;\n const labelId = selectId + '-label';\n const valueId = selectId + '-value';\n const isInvalidClass = this.errorMessage.length ? 'is-invalid' : '';\n const isErrorClass = this.errorMessage.length ? 'is-error' : '';\n\n return (\n <Host>\n <road-input-group>\n <div class={`road-phone-input-select ${isErrorClass}`} slot=\"prepend\">\n <select\n id='phone-number-input'\n class={`form-select-area has-value ${isInvalidClass}`}\n aria-disabled={this.disabled ? 'true' : null}\n disabled={this.disabled}\n onChange={(event) => this.handleSelect(event)}\n aria-label={this.codeLabel}\n tabIndex={this.disabled ? -1 : 0}\n >\n {this.countryOptions && this.countryOptions.map(option => (\n <option value={option.value} disabled={option.disabled} selected={option.selected}>{option.label}</option>\n ))}\n </select>\n <label class=\"form-select-area-label\" id={labelId} htmlFor={selectId}>{this.codeLabel}</label>\n <label class=\"form-select-area-value\" id={valueId} htmlFor={selectId}>+{this.selectedCountryCode}</label>\n </div>\n <road-input\n type=\"tel\"\n id=\"phone-number\"\n sizes=\"xl\"\n label={this.phoneLabel}\n value={this.phoneValue}\n onRoadChange={(event) => this.handleInput(event)}\n required={this.required}\n error={this.errorMessage}\n onKeyDown={(event) => this.handleKeyDown(event)} // Lier la fonction handleKeyDown à l'événement onKeyDown\n tabIndex={0}\n >\n </road-input>\n </road-input-group>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -72,6 +72,22 @@
|
|
|
72
72
|
outline: auto;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Disabled
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
:host(.tab-disabled) {
|
|
80
|
+
background: var(--road-surface-disabled);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host(.tab-disabled) .button-native{
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host(.tab-disabled) ::slotted(road-label) {
|
|
88
|
+
color: var(--road-on-surface-disabled);
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
|
|
76
92
|
/* NATIVE
|
|
77
93
|
-------------------- */
|
|
@@ -124,9 +140,10 @@
|
|
|
124
140
|
width: 100%;
|
|
125
141
|
height: 2px;
|
|
126
142
|
content: "";
|
|
127
|
-
|
|
143
|
+
background-color: var(--road-input-outline);
|
|
144
|
+
opacity: 1;
|
|
128
145
|
transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
129
|
-
transform:
|
|
146
|
+
transform: none;
|
|
130
147
|
transform-origin: center;
|
|
131
148
|
}
|
|
132
149
|
|
|
@@ -19,6 +19,7 @@ export class TabButton {
|
|
|
19
19
|
this.rel = undefined;
|
|
20
20
|
this.layout = 'icon-start';
|
|
21
21
|
this.selected = false;
|
|
22
|
+
this.disabled = false;
|
|
22
23
|
this.tab = undefined;
|
|
23
24
|
this.target = undefined;
|
|
24
25
|
}
|
|
@@ -58,20 +59,21 @@ export class TabButton {
|
|
|
58
59
|
return 0;
|
|
59
60
|
}
|
|
60
61
|
render() {
|
|
61
|
-
const { hasIcon, hasLabel, tabIndex, href, rel, target, layout, selected, tab } = this;
|
|
62
|
+
const { hasIcon, hasLabel, tabIndex, href, rel, target, layout, selected, tab, disabled } = this;
|
|
62
63
|
const attrs = {
|
|
63
64
|
download: this.download,
|
|
64
|
-
href,
|
|
65
|
+
href: !disabled ? href : undefined,
|
|
65
66
|
rel,
|
|
66
67
|
target,
|
|
67
68
|
};
|
|
68
|
-
return (h(Host, { onClick: this.onClick, onKeyup: this.onKeyUp, role: "tab", tabindex: tabIndex, "aria-selected": selected ? 'true' : 'false', id: tab !== undefined ? `tab-button-${tab}` : null, class: {
|
|
69
|
+
return (h(Host, { onClick: (ev) => !disabled && this.onClick(ev), onKeyup: (ev) => !disabled && this.onKeyUp(ev), role: "tab", tabindex: disabled ? -1 : tabIndex, "aria-selected": selected ? 'true' : 'false', "aria-disabled": disabled ? 'true' : null, id: tab !== undefined ? `tab-button-${tab}` : null, class: {
|
|
69
70
|
'tab-selected': selected,
|
|
70
71
|
'tab-has-label': hasLabel,
|
|
71
72
|
'tab-has-icon': hasIcon,
|
|
72
73
|
'tab-has-label-only': hasLabel && !hasIcon,
|
|
73
74
|
'tab-has-icon-only': hasIcon && !hasLabel,
|
|
74
75
|
[`tab-layout-${layout}`]: true,
|
|
76
|
+
'tab-disabled': disabled, // Classe CSS pour les styles désactivés
|
|
75
77
|
} }, h("a", Object.assign({}, attrs, { tabIndex: -1, class: "button-native", part: "native" }), h("span", { class: "button-inner" }, h("slot", null)))));
|
|
76
78
|
}
|
|
77
79
|
static get is() { return "road-tab-button"; }
|
|
@@ -175,6 +177,24 @@ export class TabButton {
|
|
|
175
177
|
"reflect": false,
|
|
176
178
|
"defaultValue": "false"
|
|
177
179
|
},
|
|
180
|
+
"disabled": {
|
|
181
|
+
"type": "boolean",
|
|
182
|
+
"mutable": true,
|
|
183
|
+
"complexType": {
|
|
184
|
+
"original": "boolean",
|
|
185
|
+
"resolved": "boolean",
|
|
186
|
+
"references": {}
|
|
187
|
+
},
|
|
188
|
+
"required": false,
|
|
189
|
+
"optional": false,
|
|
190
|
+
"docs": {
|
|
191
|
+
"tags": [],
|
|
192
|
+
"text": "The disabled tab"
|
|
193
|
+
},
|
|
194
|
+
"attribute": "disabled",
|
|
195
|
+
"reflect": false,
|
|
196
|
+
"defaultValue": "false"
|
|
197
|
+
},
|
|
178
198
|
"tab": {
|
|
179
199
|
"type": "string",
|
|
180
200
|
"mutable": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-button.js","sourceRoot":"","sources":["../../../src/components/tab-button/tab-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE/F;;;;GAIG;AAOH,MAAM,OAAO,SAAS;;
|
|
1
|
+
{"version":3,"file":"tab-button.js","sourceRoot":"","sources":["../../../src/components/tab-button/tab-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE/F;;;;GAIG;AAOH,MAAM,OAAO,SAAS;;IA0GZ,YAAO,GAAG,CAAC,EAAiB,EAAE,EAAE;MACtC,IAAI,EAAE,CAAC,GAAG,KAAK,OAAO,IAAI,EAAE,CAAC,GAAG,KAAK,GAAG,EAAE;QACxC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;OACpB;IACH,CAAC,CAAC;IAEM,YAAO,GAAG,CAAC,EAAS,EAAE,EAAE;MAC9B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC,CAAC;;;;kBAtF2C,YAAY;oBAKrB,KAAK;oBAKH,KAAK;;;;EAwB3C,eAAe,CAAC,EAAe;IAC7B,MAAM,cAAc,GAAG,EAAE,CAAC,MAAqB,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,aAA4B,CAAC;IAEpD,IAAI,CAAC,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE;MACnH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, Host, Listen, Prop, h } from '@stencil/core';\n\n/**\n * @slot - Content of the tab-button, it should be road-icon and road-label elements.\n *\n * @part native - The native HTML anchor element that wraps all child elements.\n */\n\n@Component({\n tag: 'road-tab-button',\n styleUrl: 'tab-button.css',\n shadow: true,\n})\nexport class TabButton {\n\n @Element() el!: HTMLRoadTabButtonElement;\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 | undefined;\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 | undefined;\n\n /**\n * Set the layout of the text and icon in the tab bar.\n * It defaults to `'icon-start'`.\n */\n @Prop() layout?: 'icon-start' | 'icon-top' = 'icon-start';\n\n /**\n * The selected tab component\n */\n @Prop({ mutable: true }) selected = false;\n\n /**\n * The disabled tab \n */\n @Prop({ mutable: true }) disabled = false;\n\n /**\n * A tab id must be provided for each `road-tab`. It's used internally to reference\n */\n @Prop() tab?: 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 | undefined;\n\n /**\n * Emitted when the tab bar is clicked\n * @internal\n */\n @Event() roadtabbuttonclick!: EventEmitter;\n /** @internal */\n @Event() roadTabButtonClick!: EventEmitter;\n\n @Listen('roadTabBarChanged', { target: 'window' })\n @Listen('roadTabbarchanged', { target: 'window' })\n onTabBarChanged(ev: CustomEvent) {\n const dispatchedFrom = ev.target as HTMLElement;\n const parent = this.el.parentElement as EventTarget;\n\n if ((ev.composedPath && ev.composedPath().includes(parent)) || (dispatchedFrom && dispatchedFrom.contains(this.el))) {\n this.selected = this.tab === ev.detail.tab;\n }\n }\n\n private selectTab(ev: Event | KeyboardEvent) {\n if (this.tab !== undefined) {\n this.roadtabbuttonclick.emit({\n tab: this.tab,\n href: this.href,\n selected: this.selected,\n });\n this.roadTabButtonClick.emit({\n tab: this.tab,\n href: this.href,\n selected: this.selected,\n });\n\n ev.preventDefault();\n }\n }\n\n private get hasLabel() {\n return !!this.el.querySelector('road-label');\n }\n\n private get hasIcon() {\n return !!this.el.querySelector('road-icon');\n }\n\n private get tabIndex() {\n const hasTabIndex = this.el.hasAttribute('tabindex');\n\n if (hasTabIndex) {\n return this.el.getAttribute('tabindex');\n }\n\n return 0;\n }\n\n private onKeyUp = (ev: KeyboardEvent) => {\n if (ev.key === 'Enter' || ev.key === ' ') {\n this.selectTab(ev);\n }\n };\n\n private onClick = (ev: Event) => {\n this.selectTab(ev);\n };\n\n render() {\n const { hasIcon, hasLabel, tabIndex, href, rel, target, layout, selected, tab, disabled } = this;\n const attrs = {\n download: this.download,\n href: !disabled ? href : undefined, // Ne pas inclure le lien si désactivé\n rel,\n target,\n };\n \n return (\n <Host\n onClick={(ev: Event) => !disabled && this.onClick(ev)} // Bloquer les clics si désactivé\n onKeyup={(ev: KeyboardEvent) => !disabled && this.onKeyUp(ev)} // Bloquer les interactions clavier si désactivé\n role=\"tab\"\n tabindex={disabled ? -1 : tabIndex} // Désactiver le focus si désactivé\n aria-selected={selected ? 'true' : 'false'}\n aria-disabled={disabled ? 'true' : null} // Ajout pour l'accessibilité\n id={tab !== undefined ? `tab-button-${tab}` : null}\n class={{\n 'tab-selected': selected,\n 'tab-has-label': hasLabel,\n 'tab-has-icon': hasIcon,\n 'tab-has-label-only': hasLabel && !hasIcon,\n 'tab-has-icon-only': hasIcon && !hasLabel,\n [`tab-layout-${layout}`]: true,\n 'tab-disabled': disabled, // Classe CSS pour les styles désactivés\n }}\n >\n <a {...attrs} tabIndex={-1} class=\"button-native\" part=\"native\">\n <span class=\"button-inner\">\n <slot/>\n </span>\n </a>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -39,7 +39,8 @@ export class toggle {
|
|
|
39
39
|
const textLabel = h("label", { class: "form-toggle-label", id: labelId, htmlFor: this.toggleId }, this.label);
|
|
40
40
|
const isSpacedClass = this.isSpaced && 'form-toggle-spaced';
|
|
41
41
|
const righttoggleClass = this.hasLeftLabel ? 'form-toggle-right' : '';
|
|
42
|
-
|
|
42
|
+
const disabledClass = this.disabled ? 'disabled' : '';
|
|
43
|
+
return (h(Host, null, h("input", { class: "form-toggle-input", type: "checkbox", id: this.toggleId, name: this.name, checked: this.checked, disabled: this.disabled, value: this.value, "aria-checked": `${this.checked}`, "aria-disabled": this.disabled ? 'true' : null, "aria-labelledby": labelId, onClick: this.onClick, onFocus: this.onFocus, onBlur: this.onBlur }), h("label", { class: `form-toggle-label ${isSpacedClass} ${disabledClass}`, htmlFor: this.toggleId }, this.hasLeftLabel && textLabel, h("div", { class: `form-toggle-lever ${righttoggleClass}`, "data-off": this.off, "data-on": this.on }), this.hasLeftLabel ? '' : textLabel)));
|
|
43
44
|
}
|
|
44
45
|
static get is() { return "road-toggle"; }
|
|
45
46
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../../src/components/toggle/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,sBAAsB,CAAC;AAO9B,MAAM,OAAO,MAAM;;IA2FT,YAAO,GAAG,GAAG,EAAE;MACrB,IAAI,CAAC,OAAO,GAAG,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,SAAS,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\nimport '../../utils/polyfill';\n\n@Component({\n tag: 'road-toggle',\n styleUrl: 'toggle.css',\n scoped: true,\n})\nexport class toggle {\n\n /**\n * The id of toggle\n */\n @Prop() toggleId: string = `road-toggle-${toggleIds++}`;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.toggleId;\n\n /**\n * If `true`, the toggle is checked.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * If `true`, the user cannot interact with the toggle.\n */\n @Prop() disabled = false;\n\n /**\n * Label for the field\n */\n @Prop() label: string = `${this.toggleId}-label`;\n\n /**\n * If `true`, the label is at left of the toggle\n */\n @Prop() hasLeftLabel: boolean = false;\n\n /**\n * Add space between label and toggle element\n */\n @Prop() isSpaced: boolean = false;\n\n /**\n * Value the form will get\n */\n @Prop() value: string = 'on';\n\n /**\n * Text display for \"`on`\" state in the toggle lever\n */\n @Prop() on: string = \"yes\";\n\n /**\n * Text display for \"`off`\" state in the toggle lever\n */\n @Prop() off: string = \"no\";\n\n /**\n * Emitted when the checked property has changed.\n */\n @Event() roadchange!: EventEmitter<{\n checked: boolean;\n value: string | undefined | null\n }>;\n /** @internal */\n @Event() roadChange!: EventEmitter<{\n checked: boolean;\n value: string | undefined | null\n }>;\n\n /**\n * Emitted when the toggle has focus.\n */\n @Event() roadfocus!: EventEmitter<void>;\n /** @internal */\n @Event() roadFocus!: EventEmitter<void>;\n\n /**\n * Emitted when the toggle loses focus.\n */\n @Event() roadblur!: EventEmitter<void>;\n /** @internal */\n @Event() roadBlur!: EventEmitter<void>;\n\n @Watch('checked')\n checkedChanged(isChecked: boolean) {\n this.roadchange.emit({\n checked: isChecked,\n value: this.value,\n });\n this.roadChange.emit({\n checked: isChecked,\n value: this.value,\n });\n }\n\n private onClick = () => {\n this.checked = !this.checked;\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 labelId = this.toggleId + '-label';\n const textLabel = <label class=\"form-toggle-label\" id={labelId} htmlFor={this.toggleId}>{this.label}</label>;\n const isSpacedClass = this.isSpaced && 'form-toggle-spaced';\n const righttoggleClass = this.hasLeftLabel ? 'form-toggle-right' : '';\n const disabledClass = this.disabled ? 'disabled' : '';\n\n return (\n <Host>\n <input\n class=\"form-toggle-input\"\n type=\"checkbox\"\n id={this.toggleId}\n name={this.name}\n checked={this.checked}\n disabled={this.disabled}\n value={this.value}\n aria-checked={`${this.checked}`}\n aria-disabled={this.disabled ? 'true' : null}\n aria-labelledby={labelId}\n onClick={this.onClick}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n />\n <label class={`form-toggle-label ${isSpacedClass} ${disabledClass}`} htmlFor={this.toggleId}>\n {this.hasLeftLabel && textLabel}\n <div class={`form-toggle-lever ${righttoggleClass}`} data-off={this.off} data-on={this.on}></div>\n {this.hasLeftLabel ? '' : textLabel}\n </label>\n </Host>\n );\n }\n}\n\nlet toggleIds = 0;\n"]}
|