@roadtrip/components 3.41.2 → 3.42.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/loader.cjs.js +1 -1
- package/dist/cjs/road-badge_14.cjs.entry.js +1612 -12
- package/dist/cjs/road-badge_14.cjs.entry.js.map +1 -1
- package/dist/cjs/road-card.cjs.entry.js +46 -16
- package/dist/cjs/road-card.cjs.entry.js.map +1 -1
- package/dist/cjs/road-navbar-v2.cjs.entry.js.map +1 -1
- package/dist/cjs/roadtrip.cjs.js +1 -1
- package/dist/collection/components/button/button.css +76 -5
- package/dist/collection/components/button/button.js +26 -1
- package/dist/collection/components/button/button.js.map +1 -1
- package/dist/collection/components/button/button.stories.js +67 -0
- package/dist/collection/components/card/card.css +58 -11
- package/dist/collection/components/card/card.js +90 -20
- package/dist/collection/components/card/card.js.map +1 -1
- package/dist/collection/components/card/card.stories.js +330 -75
- package/dist/collection/components/drawer/drawer.js +31 -10
- package/dist/collection/components/drawer/drawer.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/road-badge_14.entry.js +1612 -12
- package/dist/esm/road-badge_14.entry.js.map +1 -1
- package/dist/esm/road-card.entry.js +46 -16
- package/dist/esm/road-card.entry.js.map +1 -1
- package/dist/esm/road-navbar-v2.entry.js.map +1 -1
- package/dist/esm/roadtrip.js +1 -1
- package/dist/html.html-data.json +12 -0
- package/dist/roadtrip/p-d89d49b2.entry.js +2 -0
- package/dist/roadtrip/p-d89d49b2.entry.js.map +1 -0
- package/dist/roadtrip/p-f46b6488.entry.js +18 -0
- package/dist/roadtrip/p-f46b6488.entry.js.map +1 -0
- package/dist/roadtrip/p-fdcebcc3.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/button/button.d.ts +4 -0
- package/dist/types/components/card/card.d.ts +15 -5
- package/dist/types/components/drawer/drawer.d.ts +9 -4
- package/dist/types/components.d.ts +28 -4
- package/hydrate/index.js +1663 -29
- package/hydrate/index.mjs +1663 -29
- package/package.json +2 -1
- package/dist/roadtrip/p-36f8563a.entry.js +0 -2
- package/dist/roadtrip/p-36f8563a.entry.js.map +0 -1
- package/dist/roadtrip/p-d8dd3342.entry.js +0 -10
- package/dist/roadtrip/p-d8dd3342.entry.js.map +0 -1
|
@@ -1,104 +1,359 @@
|
|
|
1
|
-
import { html } from
|
|
2
|
-
import { ifDefined } from
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
title:
|
|
6
|
-
component:
|
|
5
|
+
title: "Listing/Card",
|
|
6
|
+
component: "road-card",
|
|
7
7
|
parameters: {
|
|
8
8
|
backgrounds: {
|
|
9
|
-
default:
|
|
9
|
+
default: "grey",
|
|
10
10
|
},
|
|
11
11
|
actions: {
|
|
12
|
-
handles: [
|
|
12
|
+
handles: ["roadcardclick"],
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
argTypes: {
|
|
16
16
|
elevation: {
|
|
17
|
-
options: [
|
|
18
|
-
control: { type:
|
|
19
|
-
description:
|
|
17
|
+
options: ["none", "lowest", "average"],
|
|
18
|
+
control: { type: "select" },
|
|
19
|
+
description: "Defines the elevation (shadow effect) of the card.",
|
|
20
20
|
table: {
|
|
21
|
-
defaultValue: { summary:
|
|
21
|
+
defaultValue: { summary: "none" },
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
|
+
button: {
|
|
25
|
+
control: "boolean",
|
|
26
|
+
description:
|
|
27
|
+
"If `true`, a button tag will be rendered and the card will be tappable.",
|
|
28
|
+
table: {
|
|
29
|
+
defaultValue: { summary: "true" },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: "boolean",
|
|
34
|
+
description:
|
|
35
|
+
"If `true`, the card is disabled and cannot be clicked. * Only applies when in button mode (button=true and no href).",
|
|
36
|
+
},
|
|
24
37
|
},
|
|
25
38
|
args: {
|
|
26
|
-
elevation:
|
|
39
|
+
elevation: "none",
|
|
40
|
+
button: true,
|
|
41
|
+
disabled: false,
|
|
27
42
|
},
|
|
28
43
|
};
|
|
29
44
|
|
|
30
45
|
const Template = (args) => html`
|
|
31
|
-
<road-grid>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<road-
|
|
45
|
-
<road-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</road-
|
|
46
|
+
<road-grid>
|
|
47
|
+
<road-row>
|
|
48
|
+
<road-col class="col-4 col-md-3 col-lg-2">
|
|
49
|
+
<road-card
|
|
50
|
+
button="${ifDefined(args.button)}"
|
|
51
|
+
disabled="${ifDefined(args.disabled)}"
|
|
52
|
+
value="125"
|
|
53
|
+
elevation="${ifDefined(args.elevation)}"
|
|
54
|
+
@roadcardclick=${args.roadcardclick}
|
|
55
|
+
>
|
|
56
|
+
<road-label>125</road-label>
|
|
57
|
+
</road-card>
|
|
58
|
+
</road-col>
|
|
59
|
+
<road-col class="col-4 col-md-3 col-lg-2">
|
|
60
|
+
<road-card
|
|
61
|
+
button="${ifDefined(args.button)}"
|
|
62
|
+
disabled="${ifDefined(args.disabled)}"
|
|
63
|
+
value="135"
|
|
64
|
+
elevation="${ifDefined(args.elevation)}"
|
|
65
|
+
@roadcardclick=${args.roadcardclick}
|
|
66
|
+
>
|
|
67
|
+
<road-label>135</road-label>
|
|
68
|
+
</road-card>
|
|
69
|
+
</road-col>
|
|
70
|
+
<road-col class="col-4 col-md-3 col-lg-2">
|
|
71
|
+
<road-card
|
|
72
|
+
button="${ifDefined(args.button)}"
|
|
73
|
+
disabled="${ifDefined(args.disabled)}"
|
|
74
|
+
value="145"
|
|
75
|
+
elevation="${ifDefined(args.elevation)}"
|
|
76
|
+
@roadcardclick=${args.roadcardclick}
|
|
77
|
+
>
|
|
78
|
+
<road-label>145</road-label>
|
|
79
|
+
</road-card>
|
|
80
|
+
</road-col>
|
|
81
|
+
<road-col class="col-4 col-md-3 col-lg-2">
|
|
82
|
+
<road-card
|
|
83
|
+
button="${ifDefined(args.button)}"
|
|
84
|
+
disabled="${ifDefined(args.disabled)}"
|
|
85
|
+
value="155"
|
|
86
|
+
elevation="${ifDefined(args.elevation)}"
|
|
87
|
+
@roadcardclick=${args.roadcardclick}
|
|
88
|
+
>
|
|
89
|
+
<road-label>155</road-label>
|
|
90
|
+
</road-card>
|
|
91
|
+
</road-col>
|
|
92
|
+
<road-col class="col-4 col-md-3 col-lg-2">
|
|
93
|
+
<road-card
|
|
94
|
+
button="${ifDefined(args.button)}"
|
|
95
|
+
disabled="${ifDefined(args.disabled)}"
|
|
96
|
+
value="165"
|
|
97
|
+
elevation="${ifDefined(args.elevation)}"
|
|
98
|
+
@roadcardclick=${args.roadcardclick}
|
|
99
|
+
>
|
|
100
|
+
<road-label>165</road-label>
|
|
101
|
+
</road-card>
|
|
102
|
+
</road-col>
|
|
103
|
+
<road-col class="col-4 col-md-3 col-lg-2">
|
|
104
|
+
<road-card
|
|
105
|
+
button="${ifDefined(args.button)}"
|
|
106
|
+
disabled="${ifDefined(args.disabled)}"
|
|
107
|
+
value="175"
|
|
108
|
+
elevation="${ifDefined(args.elevation)}"
|
|
109
|
+
@roadcardclick=${args.roadcardclick}
|
|
110
|
+
>
|
|
111
|
+
<road-label>175</road-label>
|
|
112
|
+
</road-card>
|
|
113
|
+
</road-col>
|
|
114
|
+
</road-row>
|
|
115
|
+
</road-grid>
|
|
65
116
|
`;
|
|
66
117
|
|
|
67
118
|
export const Value = Template.bind({});
|
|
68
119
|
Value.args = {
|
|
69
|
-
elevation:
|
|
120
|
+
elevation: "average",
|
|
121
|
+
button: true,
|
|
122
|
+
disabled: false,
|
|
70
123
|
};
|
|
71
124
|
|
|
72
125
|
export const Vehicle = (args) => html`
|
|
73
|
-
<road-grid>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
126
|
+
<road-grid>
|
|
127
|
+
<road-row>
|
|
128
|
+
<road-col class="col-6 col-md-4 col-lg-3">
|
|
129
|
+
<road-card
|
|
130
|
+
button="${ifDefined(args.button)}"
|
|
131
|
+
disabled="${ifDefined(args.disabled)}"
|
|
132
|
+
value="car"
|
|
133
|
+
elevation="${ifDefined(args.elevation)}"
|
|
134
|
+
@roadcardclick=${args.roadcardclick}
|
|
135
|
+
>
|
|
136
|
+
<road-icon name="vehicle-car" size="3x" role="img"></road-icon>
|
|
137
|
+
<road-label>Car</road-label>
|
|
138
|
+
</road-card>
|
|
139
|
+
</road-col>
|
|
140
|
+
<road-col class="col-6 col-md-4 col-lg-3">
|
|
141
|
+
<road-card
|
|
142
|
+
button="${ifDefined(args.button)}"
|
|
143
|
+
disabled="${ifDefined(args.disabled)}"
|
|
144
|
+
value="4x4"
|
|
145
|
+
elevation="${ifDefined(args.elevation)}"
|
|
146
|
+
@roadcardclick=${args.roadcardclick}
|
|
147
|
+
>
|
|
148
|
+
<road-icon name="vehicle-suv" size="3x" role="img"></road-icon>
|
|
149
|
+
<road-label>4x4</road-label>
|
|
150
|
+
</road-card>
|
|
151
|
+
</road-col>
|
|
152
|
+
<road-col class="col-6 col-md-4 col-lg-3">
|
|
153
|
+
<road-card
|
|
154
|
+
button="${ifDefined(args.button)}"
|
|
155
|
+
disabled="${ifDefined(args.disabled)}"
|
|
156
|
+
value="truck"
|
|
157
|
+
elevation="${ifDefined(args.elevation)}"
|
|
158
|
+
@roadcardclick=${args.roadcardclick}
|
|
159
|
+
>
|
|
160
|
+
<road-icon name="vehicle-pickup-van" size="3x" role="img"></road-icon>
|
|
161
|
+
<road-label>Truck</road-label>
|
|
162
|
+
</road-card>
|
|
163
|
+
</road-col>
|
|
164
|
+
<road-col class="col-6 col-md-4 col-lg-3">
|
|
165
|
+
<road-card
|
|
166
|
+
button="${ifDefined(args.button)}"
|
|
167
|
+
disabled="${ifDefined(args.disabled)}"
|
|
168
|
+
value="bike"
|
|
169
|
+
elevation="${ifDefined(args.elevation)}"
|
|
170
|
+
@roadcardclick=${args.roadcardclick}
|
|
171
|
+
>
|
|
172
|
+
<road-icon name="vehicle-moto" size="3x" role="img"></road-icon>
|
|
173
|
+
<road-label>Bike</road-label>
|
|
174
|
+
</road-card>
|
|
175
|
+
</road-col>
|
|
176
|
+
</road-row>
|
|
177
|
+
</road-grid>
|
|
101
178
|
`;
|
|
102
179
|
Vehicle.args = {
|
|
103
|
-
elevation:
|
|
180
|
+
elevation: "average",
|
|
181
|
+
button: true,
|
|
182
|
+
disabled: false,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const SelectTyreBrand = (args) => html`
|
|
186
|
+
<div class="container-max mb-24">
|
|
187
|
+
<road-grid>
|
|
188
|
+
<road-row>
|
|
189
|
+
Just a card:
|
|
190
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
191
|
+
<road-card
|
|
192
|
+
id="221"
|
|
193
|
+
elevation="${ifDefined(args.elevation)}"
|
|
194
|
+
@roadcardclick=${args.roadcardclick}
|
|
195
|
+
>
|
|
196
|
+
<road-label>GOODYEAR</road-label>
|
|
197
|
+
</road-card>
|
|
198
|
+
</road-col>
|
|
199
|
+
A card button disabled (not selected)
|
|
200
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
201
|
+
<road-card
|
|
202
|
+
button
|
|
203
|
+
disabled
|
|
204
|
+
id="178"
|
|
205
|
+
elevation="${ifDefined(args.elevation)}"
|
|
206
|
+
@roadcardclick=${args.roadcardclick}
|
|
207
|
+
>
|
|
208
|
+
<road-label>CONTINENTAL</road-label>
|
|
209
|
+
</road-card>
|
|
210
|
+
</road-col>
|
|
211
|
+
A card button disabled (selected)
|
|
212
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
213
|
+
<road-card
|
|
214
|
+
button
|
|
215
|
+
selected
|
|
216
|
+
disabled
|
|
217
|
+
id="200"
|
|
218
|
+
elevation="${ifDefined(args.elevation)}"
|
|
219
|
+
@roadcardclick=${args.roadcardclick}
|
|
220
|
+
>
|
|
221
|
+
<road-label>HANKOOK</road-label>
|
|
222
|
+
</road-card>
|
|
223
|
+
</road-col>
|
|
224
|
+
Test the different states (hover, focus, selected):
|
|
225
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
226
|
+
<road-card
|
|
227
|
+
button="${ifDefined(args.button)}"
|
|
228
|
+
disabled="${ifDefined(args.disabled)}"
|
|
229
|
+
id="344"
|
|
230
|
+
elevation="${ifDefined(args.elevation)}"
|
|
231
|
+
@roadcardclick=${args.roadcardclick}
|
|
232
|
+
>
|
|
233
|
+
<img
|
|
234
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-kumho.png?com=refresh"
|
|
235
|
+
alt="kumho"
|
|
236
|
+
/>
|
|
237
|
+
</road-card>
|
|
238
|
+
</road-col>
|
|
239
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
240
|
+
<road-card
|
|
241
|
+
button="${ifDefined(args.button)}"
|
|
242
|
+
disabled="${ifDefined(args.disabled)}"
|
|
243
|
+
id="5bd"
|
|
244
|
+
elevation="${ifDefined(args.elevation)}"
|
|
245
|
+
@roadcardclick=${args.roadcardclick}
|
|
246
|
+
>
|
|
247
|
+
<img
|
|
248
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-fortuna.png?com=refresh"
|
|
249
|
+
alt="fortuna"
|
|
250
|
+
/>
|
|
251
|
+
</road-card>
|
|
252
|
+
</road-col>
|
|
253
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
254
|
+
<road-card
|
|
255
|
+
button="${ifDefined(args.button)}"
|
|
256
|
+
disabled="${ifDefined(args.disabled)}"
|
|
257
|
+
id="a24"
|
|
258
|
+
elevation="${ifDefined(args.elevation)}"
|
|
259
|
+
@roadcardclick=${args.roadcardclick}
|
|
260
|
+
>
|
|
261
|
+
<img
|
|
262
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-barum.png?com=refresh"
|
|
263
|
+
alt="barum"
|
|
264
|
+
/>
|
|
265
|
+
</road-card>
|
|
266
|
+
</road-col>
|
|
267
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
268
|
+
<road-card
|
|
269
|
+
button="${ifDefined(args.button)}"
|
|
270
|
+
disabled="${ifDefined(args.disabled)}"
|
|
271
|
+
id="0eg"
|
|
272
|
+
elevation="${ifDefined(args.elevation)}"
|
|
273
|
+
@roadcardclick=${args.roadcardclick}
|
|
274
|
+
>
|
|
275
|
+
<img
|
|
276
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-minerva.png?com=refresh"
|
|
277
|
+
alt="minerva"
|
|
278
|
+
/>
|
|
279
|
+
</road-card>
|
|
280
|
+
</road-col>
|
|
281
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
282
|
+
<road-card
|
|
283
|
+
button="${ifDefined(args.button)}"
|
|
284
|
+
disabled="${ifDefined(args.disabled)}"
|
|
285
|
+
id="a66"
|
|
286
|
+
elevation="${ifDefined(args.elevation)}"
|
|
287
|
+
@roadcardclick=${args.roadcardclick}
|
|
288
|
+
>
|
|
289
|
+
<img
|
|
290
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-nexen.png?com=refresh"
|
|
291
|
+
alt="nexen"
|
|
292
|
+
/>
|
|
293
|
+
</road-card>
|
|
294
|
+
</road-col>
|
|
295
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
296
|
+
<road-card
|
|
297
|
+
button="${ifDefined(args.button)}"
|
|
298
|
+
disabled="${ifDefined(args.disabled)}"
|
|
299
|
+
id="ce1"
|
|
300
|
+
elevation="${ifDefined(args.elevation)}"
|
|
301
|
+
@roadcardclick=${args.roadcardclick}
|
|
302
|
+
>
|
|
303
|
+
<img
|
|
304
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-superia.png?com=refresh"
|
|
305
|
+
alt="superia"
|
|
306
|
+
/>
|
|
307
|
+
</road-card>
|
|
308
|
+
</road-col>
|
|
309
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
310
|
+
<road-card
|
|
311
|
+
button="${ifDefined(args.button)}"
|
|
312
|
+
disabled="${ifDefined(args.disabled)}"
|
|
313
|
+
id="176"
|
|
314
|
+
elevation="${ifDefined(args.elevation)}"
|
|
315
|
+
@roadcardclick=${args.roadcardclick}
|
|
316
|
+
>
|
|
317
|
+
<img
|
|
318
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-uniroyal.png?com=refresh"
|
|
319
|
+
alt="uniroyal"
|
|
320
|
+
/>
|
|
321
|
+
</road-card>
|
|
322
|
+
</road-col>
|
|
323
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
324
|
+
<road-card
|
|
325
|
+
button="${ifDefined(args.button)}"
|
|
326
|
+
disabled="${ifDefined(args.disabled)}"
|
|
327
|
+
id="38c"
|
|
328
|
+
elevation="${ifDefined(args.elevation)}"
|
|
329
|
+
@roadcardclick=${args.roadcardclick}
|
|
330
|
+
>
|
|
331
|
+
<img
|
|
332
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-vredestein.png?com=refresh"
|
|
333
|
+
alt="vredestein"
|
|
334
|
+
/>
|
|
335
|
+
</road-card>
|
|
336
|
+
</road-col>
|
|
337
|
+
<road-col class="col-12 col-md-6 col-lg-4">
|
|
338
|
+
<road-card
|
|
339
|
+
button="${ifDefined(args.button)}"
|
|
340
|
+
disabled="${ifDefined(args.disabled)}"
|
|
341
|
+
id="282"
|
|
342
|
+
elevation="${ifDefined(args.elevation)}"
|
|
343
|
+
@roadcardclick=${args.roadcardclick}
|
|
344
|
+
>
|
|
345
|
+
<img
|
|
346
|
+
src="https://cdn.dam.norauto.fr/sg-tyre-yokohama.png?com=refresh"
|
|
347
|
+
alt="yokohama"
|
|
348
|
+
/>
|
|
349
|
+
</road-card>
|
|
350
|
+
</road-col>
|
|
351
|
+
</road-row>
|
|
352
|
+
</road-grid>
|
|
353
|
+
</div>
|
|
354
|
+
`;
|
|
355
|
+
SelectTyreBrand.args = {
|
|
356
|
+
elevation: "none",
|
|
357
|
+
button: true,
|
|
358
|
+
disabled: false,
|
|
104
359
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import { navigationClose, navigationChevron } from "../../../icons";
|
|
3
|
+
import { createFocusTrap } from "focus-trap";
|
|
3
4
|
/**
|
|
4
5
|
* @slot - Content of the drawer.
|
|
5
6
|
* @slot title - replace the title with a custom title section when `'drawerTitle'` is not set
|
|
@@ -16,8 +17,8 @@ export class Drawer {
|
|
|
16
17
|
*/
|
|
17
18
|
this.isOpen = false;
|
|
18
19
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
* Set removePadding property to true to remove padding for drawer body
|
|
21
|
+
*/
|
|
21
22
|
this.removePadding = false;
|
|
22
23
|
/**
|
|
23
24
|
* position of the drawer. e.g. left, right, bottom
|
|
@@ -88,24 +89,30 @@ export class Drawer {
|
|
|
88
89
|
handleOpen(openValue) {
|
|
89
90
|
if (openValue === true) {
|
|
90
91
|
this.onOpen.emit();
|
|
91
|
-
// Focus the first button element after the drawer is opened
|
|
92
|
-
setTimeout(() =>
|
|
92
|
+
// Focus the first button element after the drawer is opened then focus trap
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
var _a;
|
|
95
|
+
this.focusFirstElement();
|
|
96
|
+
(_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.activate();
|
|
97
|
+
}, 50); // Add a slight delay to ensure the element is rendered
|
|
93
98
|
}
|
|
94
99
|
else {
|
|
95
100
|
this.el.addEventListener('transitionend', () => {
|
|
101
|
+
var _a;
|
|
102
|
+
(_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.deactivate();
|
|
96
103
|
this.onClose.emit();
|
|
97
104
|
this.el.shadowRoot && (this.el.shadowRoot.querySelector('.drawer-body').scrollTop = 0);
|
|
98
105
|
}, { once: true });
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
102
|
-
* Find and focus the first
|
|
109
|
+
* Find and focus the first element in the drawer
|
|
103
110
|
*/
|
|
104
|
-
|
|
111
|
+
focusFirstElement() {
|
|
105
112
|
var _a;
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
|
|
113
|
+
const firstElement = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], [tabindex]:not([tabindex="-1"])')[0];
|
|
114
|
+
if (firstElement) {
|
|
115
|
+
firstElement.focus();
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
/**
|
|
@@ -120,9 +127,18 @@ export class Drawer {
|
|
|
120
127
|
* Call close function when clicking an element with data-dismiss="modal" attribute
|
|
121
128
|
*/
|
|
122
129
|
componentDidLoad() {
|
|
130
|
+
var _a;
|
|
123
131
|
this.el.querySelectorAll('[data-dismiss="modal"]').forEach(item => {
|
|
124
132
|
item.addEventListener('click', () => this.close());
|
|
125
133
|
});
|
|
134
|
+
const drawerContent = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".drawer-dialog");
|
|
135
|
+
this.focusTrap = createFocusTrap(drawerContent, {
|
|
136
|
+
onActivate: () => drawerContent === null || drawerContent === void 0 ? void 0 : drawerContent.classList.add("focus-trapped"),
|
|
137
|
+
onDeactivate: () => drawerContent === null || drawerContent === void 0 ? void 0 : drawerContent.classList.remove("focus-trapped"),
|
|
138
|
+
tabbableOptions: {
|
|
139
|
+
getShadowRoot: true,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
126
142
|
}
|
|
127
143
|
render() {
|
|
128
144
|
var _a, _b, _c, _d;
|
|
@@ -138,7 +154,7 @@ export class Drawer {
|
|
|
138
154
|
const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;
|
|
139
155
|
const footerSlotElement = (_d = this.el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('slot[name="footer"]');
|
|
140
156
|
const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;
|
|
141
|
-
return (h(Host, { key: '
|
|
157
|
+
return (h(Host, { key: 'a2f62ec1ecc2d5452041c1aef21c219dfb7d37e5', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, h("div", { key: '483e792abee343f79a36594eb391203521dac055', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), h("div", { key: 'b0692ac024a6f402915f482177b867f1d3fa5144', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document", tabindex: "0" }, h("div", { key: '6afd92780745fe0f6817adb5fba8649a9de0cdd9', class: "drawer-content" }, h("header", { key: '5248706c77aeaa4ce3332acfe7f3b605cbe7fd54', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (h("h2", { class: "drawer-title" }, this.drawerTitle)) : (h("div", { class: "drawer-title" }, h("slot", { name: "title" }))), closeIconElement), h("div", { key: '42ade4a899a1f381af1463ac5217c245de22c241', class: `drawer-body ${removePaddingClass}` }, h("slot", { key: 'adb1a893b61941e6488ba3bc233540ca18d90252' })), h("footer", { key: '7fb54e5564e98777a3fbf3474d323f7fe1eb0e07', class: `drawer-footer ${removePaddingClass}`, style: { display: hasFooterContent ? 'block' : 'none' } }, h("slot", { key: '37f2d0ec86cccc74795bc9a8fb509c5ded347f92', name: "footer" }))))));
|
|
142
158
|
}
|
|
143
159
|
static get is() { return "road-drawer"; }
|
|
144
160
|
static get encapsulation() { return "shadow"; }
|
|
@@ -391,6 +407,11 @@ export class Drawer {
|
|
|
391
407
|
}
|
|
392
408
|
};
|
|
393
409
|
}
|
|
410
|
+
static get states() {
|
|
411
|
+
return {
|
|
412
|
+
"focusTrap": {}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
394
415
|
static get events() {
|
|
395
416
|
return [{
|
|
396
417
|
"method": "onOpen",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE;;;;;;;;GAQG;AAQH,MAAM,OAAO,MAAM;IALnB;QAYE;;WAEG;QACsB,WAAM,GAAY,KAAK,CAAC;QAE/C;;SAEC;QACwB,kBAAa,GAAY,KAAK,CAAC;QAE1D;;WAEG;QACK,aAAQ,GAAW,MAAM,CAAC;QAElC;;WAEG;QACK,gBAAW,GAAW,GAAG,CAAC;QAElC;;WAEG;QACK,qBAAgB,GAAY,KAAK,CAAC;QAE1C;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QA2BrC;;WAEG;QACK,i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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Element, Event, EventEmitter, Listen, Method, Prop, h, Host, Watch } from '@stencil/core';\nimport { navigationClose, navigationChevron } from '../../../icons';\n\n/**\n * @slot - Content of the drawer.\n * @slot title - replace the title with a custom title section when `'drawerTitle'` is not set\n * @slot footer - footer of the drawer\n * `<div slot=\"footer\">`\n `<road-button color=\"primary\" outline=\"true\" expand=\"true\">Annuler</road-button>`\n `<road-button color=\"primary\" expand=\"true\" class=\"mb-0\">Valider</road-button>`\n ` </div>`\n */\n\n\n@Component({\n tag: 'road-drawer',\n styleUrl: 'drawer.css',\n shadow: true,\n})\nexport class Drawer {\n\n /**\n * Current reference of the drawer\n */\n @Element() el!: HTMLRoadDrawerElement;\n\n /**\n * Set isOpen property to true to open the drawer\n */\n @Prop({ mutable: true }) isOpen: boolean = false;\n\n /**\n * Set removePadding property to true to remove padding for drawer body\n */\n @Prop({ mutable: true }) removePadding: boolean = false;\n\n /**\n * position of the drawer. e.g. left, right, bottom\n */\n @Prop() position: string = 'left';\n\n /**\n * Width of the drawer\n */\n @Prop() drawerWidth: number = 480;\n\n /**\n * Inverse header colors\n */\n @Prop() hasInverseHeader: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() hasBackIcon: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() backText?: string;\n\n /**\n * Title of the drawer in the header bar\n */\n @Prop() drawerTitle?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabel?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelBack?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelClose?: string;\n\n /**\n * Show / hide close icon\n */\n @Prop() hasCloseIcon: boolean = true;\n\n /**\n * Indicate when opening the drawer\n */\n @Event({ eventName: 'open' }) onOpen!: EventEmitter<void>;\n\n /**\n * Indicate when closing the drawer\n */\n @Event({ eventName: 'close' }) onClose!: EventEmitter<void>;\n\n /**\n * Indicate when return to previous state of the drawer content\n */\n @Event({ eventName: 'back' }) onBack!: EventEmitter<void>;\n\n /**\n * Open the drawer\n */\n @Method()\n async open() {\n this.isOpen = true;\n }\n\n /**\n * Close the drawer\n */\n @Method()\n async close() {\n this.isOpen = false;\n }\n\n /**\n * Return to previous state of the drawer content\n */\n @Method()\n async back() {\n this.onBack.emit();\n }\n\n // @Watch('isOpen')\n // handleOpen(openValue: boolean) {\n // if(openValue === true) {\n // this.onOpen.emit();\n // } else {\n // this.el.addEventListener('transitionend', () => {\n // this.onClose.emit();\n // this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n // }, { once: true});\n // }\n // }\n\n\n @Watch('isOpen')\n handleOpen(openValue: boolean) {\n if(openValue === true) {\n this.onOpen.emit();\n // Focus the first button element after the drawer is opened\n setTimeout(() => this.focusFirstButton(), 50); // Add a slight delay to ensure the element is rendered\n } else {\n this.el.addEventListener('transitionend', () => {\n this.onClose.emit();\n this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n }, { once: true });\n }\n }\n \n /**\n * Find and focus the first button element in the drawer\n */\n private focusFirstButton() {\n const buttonElement = this.el.shadowRoot?.querySelector('button') as HTMLElement;\n \n if (buttonElement) {\n buttonElement.focus(); // Focus the first button element\n }\n }\n \n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClick = (ev: UIEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n\n this.close();\n };\n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClickBack = (event: MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\n this.back();\n };\n\n /**\n * Close the dialog when press Escape key\n */\n @Listen('keyup', { target: 'document' })\n onEscape(event: KeyboardEvent) {\n if (event.key === 'Escape' || event.key === \"Esc\") {\n this.close();\n }\n }\n\n /**\n * Call close function when clicking an element with data-dismiss=\"modal\" attribute\n */\n componentDidLoad() {\n this.el.querySelectorAll('[data-dismiss=\"modal\"]').forEach(item => {\n item.addEventListener('click', () => this.close());\n });\n }\n\n render() {\n const drawerIsOpenClass = this.isOpen ? 'drawer-open' : '';\n const removePaddingClass = this.removePadding ? 'remove-padding' : '';\n const inverseHeaderClass = this.hasInverseHeader ? 'drawer-header-inverse' : '';\n const ariaLabel = this.ariaLabel ?? 'drawer';\n const ariaLabelBack = this.ariaLabelBack ?? 'Back';\n const ariaLabelClose = this.ariaLabelClose ?? 'Close';\n const drawerDelimiterClass = this.drawerTitle && !this.hasInverseHeader ? 'drawer-delimiter' : '';\n const backIconElement = this.hasBackIcon ? (\n <button type=\"button\" class=\"drawer-action\" aria-label={ariaLabelBack} onClick={this.onClickBack}>\n <road-icon icon={navigationChevron} rotate=\"180\"></road-icon>\n {this.backText}\n </button>\n ) : null;\n const closeIconElement = this.hasCloseIcon ? (\n <button type=\"button\" class=\"drawer-close\" onClick={this.onClick} aria-label={ariaLabelClose}>\n <road-icon icon={navigationClose} aria-hidden=\"true\"></road-icon>\n </button>\n ) : null;\n const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;\n \n const footerSlotElement = this.el.shadowRoot?.querySelector('slot[name=\"footer\"]');\n const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;\n \n return (\n <Host class={`${drawerIsOpenClass} drawer-${this.position}`} tabindex=\"0\" role=\"dialog\" aria-label={ariaLabel}>\n <div class=\"drawer-overlay\" onClick={this.onClick} tabindex=\"-1\"></div>\n <div class=\"drawer-dialog\" style={{ maxWidth: drawerWidthValue }} role=\"document\" tabindex=\"0\">\n <div class=\"drawer-content\">\n <header class={`drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}`}>\n {backIconElement}\n {this.drawerTitle ? (\n <h2 class=\"drawer-title\">{this.drawerTitle}</h2>\n ) : (\n <div class=\"drawer-title\">\n <slot name=\"title\" />\n </div>\n )}\n {closeIconElement}\n </header>\n <div class={`drawer-body ${removePaddingClass}`}>\n <slot />\n </div>\n <footer class={`drawer-footer ${removePaddingClass}`} style={{ display: hasFooterContent ? 'block' : 'none' }}>\n <slot name=\"footer\" />\n </footer>\n </div>\n </div>\n </Host>\n );\n }\n \n}"]}
|
|
1
|
+
{"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAExD;;;;;;;;GAQG;AAQH,MAAM,OAAO,MAAM;IALnB;QAYE;;WAEG;QACsB,WAAM,GAAY,KAAK,CAAC;QAEjD;;WAEG;QACsB,kBAAa,GAAY,KAAK,CAAC;QAExD;;WAEG;QACK,aAAQ,GAAW,MAAM,CAAC;QAElC;;WAEG;QACK,gBAAW,GAAW,GAAG,CAAC;QAElC;;WAEG;QACK,qBAAgB,GAAY,KAAK,CAAC;QAE1C;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QA2BrC;;WAEG;QACK,iBAAY,GAAY,IAAI,CAAC;QAyFrC;;WAEG;QACK,YAAO,GAAG,CAAC,EAAW,EAAE,EAAE;YAChC,EAAE,CAAC,eAAe,EAAE,CAAC;YACrB,EAAE,CAAC,cAAc,EAAE,CAAC;YAEpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC;QAEF;;WAEG;QACK,g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AAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE;wBAC3G,6DAAM,IAAI,EAAC,QAAQ,GAAG,CACf,CACL,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Element, Event, EventEmitter, Listen, Method, Prop, h, Host, Watch, State } from '@stencil/core';\nimport { navigationClose, navigationChevron } from '../../../icons';\nimport { createFocusTrap, FocusTrap } from 'focus-trap';\n\n/**\n * @slot - Content of the drawer.\n * @slot title - replace the title with a custom title section when `'drawerTitle'` is not set\n * @slot footer - footer of the drawer\n * `<div slot=\"footer\">`\n `<road-button color=\"primary\" outline=\"true\" expand=\"true\">Annuler</road-button>`\n `<road-button color=\"primary\" expand=\"true\" class=\"mb-0\">Valider</road-button>`\n ` </div>`\n */\n\n\n@Component({\n tag: 'road-drawer',\n styleUrl: 'drawer.css',\n shadow: true,\n})\nexport class Drawer {\n\n /**\n * Current reference of the drawer\n */\n @Element() el!: HTMLRoadDrawerElement;\n\n /**\n * Set isOpen property to true to open the drawer\n */\n @Prop({ mutable: true }) isOpen: boolean = false;\n\n /**\n * Set removePadding property to true to remove padding for drawer body\n */\n @Prop({ mutable: true }) removePadding: boolean = false;\n\n /**\n * position of the drawer. e.g. left, right, bottom\n */\n @Prop() position: string = 'left';\n\n /**\n * Width of the drawer\n */\n @Prop() drawerWidth: number = 480;\n\n /**\n * Inverse header colors\n */\n @Prop() hasInverseHeader: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() hasBackIcon: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() backText?: string;\n\n /**\n * Title of the drawer in the header bar\n */\n @Prop() drawerTitle?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabel?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelBack?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelClose?: string;\n\n /**\n * Show / hide close icon\n */\n @Prop() hasCloseIcon: boolean = true;\n\n /**\n * Indicate when opening the drawer\n */\n @Event({ eventName: 'open' }) onOpen!: EventEmitter<void>;\n\n /**\n * Indicate when closing the drawer\n */\n @Event({ eventName: 'close' }) onClose!: EventEmitter<void>;\n\n /**\n * Indicate when return to previous state of the drawer content\n */\n @Event({ eventName: 'back' }) onBack!: EventEmitter<void>;\n\n /**\n * Focus trap state\n */\n @State() focusTrap?: FocusTrap;\n\n /**\n * Open the drawer\n */\n @Method()\n async open() {\n this.isOpen = true;\n }\n\n /**\n * Close the drawer\n */\n @Method()\n async close() {\n this.isOpen = false;\n }\n\n /**\n * Return to previous state of the drawer content\n */\n @Method()\n async back() {\n this.onBack.emit();\n }\n\n // @Watch('isOpen')\n // handleOpen(openValue: boolean) {\n // if(openValue === true) {\n // this.onOpen.emit();\n // } else {\n // this.el.addEventListener('transitionend', () => {\n // this.onClose.emit();\n // this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n // }, { once: true});\n // }\n // }\n\n\n @Watch('isOpen')\n handleOpen(openValue: boolean) {\n if(openValue === true) {\n this.onOpen.emit();\n // Focus the first button element after the drawer is opened then focus trap\n setTimeout(() => {\n this.focusFirstElement();\n this.focusTrap?.activate();\n }, 50); // Add a slight delay to ensure the element is rendered\n } else {\n this.el.addEventListener('transitionend', () => {\n this.focusTrap?.deactivate();\n this.onClose.emit();\n this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n }, { once: true });\n }\n }\n \n /**\n * Find and focus the first element in the drawer\n */\n private focusFirstElement() {\n const firstElement = this.el.shadowRoot?.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], [tabindex]:not([tabindex=\"-1\"])')[0] as HTMLElement;\n \n if (firstElement) {\n firstElement.focus();\n }\n }\n \n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClick = (ev: UIEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n\n this.close();\n };\n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClickBack = (event: MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\n this.back();\n };\n\n /**\n * Close the dialog when press Escape key\n */\n @Listen('keyup', { target: 'document' })\n onEscape(event: KeyboardEvent) {\n if (event.key === 'Escape' || event.key === \"Esc\") {\n this.close();\n }\n }\n\n /**\n * Call close function when clicking an element with data-dismiss=\"modal\" attribute\n */\n componentDidLoad() {\n this.el.querySelectorAll('[data-dismiss=\"modal\"]').forEach(item => {\n item.addEventListener('click', () => this.close());\n });\n\n const drawerContent = this.el.shadowRoot?.querySelector(\".drawer-dialog\");\n this.focusTrap = createFocusTrap(drawerContent as HTMLElement, {\n onActivate: () => drawerContent?.classList.add(\"focus-trapped\"),\n onDeactivate: () => drawerContent?.classList.remove(\"focus-trapped\"),\n tabbableOptions: {\n getShadowRoot: true,\n },\n });\n }\n\n render() {\n const drawerIsOpenClass = this.isOpen ? 'drawer-open' : '';\n const removePaddingClass = this.removePadding ? 'remove-padding' : '';\n const inverseHeaderClass = this.hasInverseHeader ? 'drawer-header-inverse' : '';\n const ariaLabel = this.ariaLabel ?? 'drawer';\n const ariaLabelBack = this.ariaLabelBack ?? 'Back';\n const ariaLabelClose = this.ariaLabelClose ?? 'Close';\n const drawerDelimiterClass = this.drawerTitle && !this.hasInverseHeader ? 'drawer-delimiter' : '';\n const backIconElement = this.hasBackIcon ? (\n <button type=\"button\" class=\"drawer-action\" aria-label={ariaLabelBack} onClick={this.onClickBack}>\n <road-icon icon={navigationChevron} rotate=\"180\"></road-icon>\n {this.backText}\n </button>\n ) : null;\n const closeIconElement = this.hasCloseIcon ? (\n <button type=\"button\" class=\"drawer-close\" onClick={this.onClick} aria-label={ariaLabelClose}>\n <road-icon icon={navigationClose} aria-hidden=\"true\"></road-icon>\n </button>\n ) : null;\n const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;\n \n const footerSlotElement = this.el.shadowRoot?.querySelector('slot[name=\"footer\"]');\n const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;\n \n return (\n <Host class={`${drawerIsOpenClass} drawer-${this.position}`} tabindex=\"0\" role=\"dialog\" aria-label={ariaLabel}>\n <div class=\"drawer-overlay\" onClick={this.onClick} tabindex=\"-1\"></div>\n <div class=\"drawer-dialog\" style={{ maxWidth: drawerWidthValue }} role=\"document\" tabindex=\"0\">\n <div class=\"drawer-content\">\n <header class={`drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}`}>\n {backIconElement}\n {this.drawerTitle ? (\n <h2 class=\"drawer-title\">{this.drawerTitle}</h2>\n ) : (\n <div class=\"drawer-title\">\n <slot name=\"title\" />\n </div>\n )}\n {closeIconElement}\n </header>\n <div class={`drawer-body ${removePaddingClass}`}>\n <slot />\n </div>\n <footer class={`drawer-footer ${removePaddingClass}`} style={{ display: hasFooterContent ? 'block' : 'none' }}>\n <slot name=\"footer\" />\n </footer>\n </div>\n </div>\n </Host>\n );\n }\n \n}"]}
|