@api-client/ui 0.5.6 → 0.5.7
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/.cursor/rules/html-and-css-best-practices.mdc +63 -0
- package/.cursor/rules/lit-best-practices.mdc +78 -0
- package/.github/instructions/html-and-css-best-practices.instructions.md +70 -0
- package/.github/instructions/lit-best-practices.instructions.md +86 -0
- package/build/src/elements/currency/currency-picker.d.ts +10 -0
- package/build/src/elements/currency/currency-picker.d.ts.map +1 -0
- package/build/src/elements/currency/currency-picker.js +27 -0
- package/build/src/elements/currency/currency-picker.js.map +1 -0
- package/build/src/elements/currency/internals/Picker.d.ts +311 -0
- package/build/src/elements/currency/internals/Picker.d.ts.map +1 -0
- package/build/src/elements/currency/internals/Picker.js +857 -0
- package/build/src/elements/currency/internals/Picker.js.map +1 -0
- package/build/src/elements/currency/internals/Picker.styles.d.ts +3 -0
- package/build/src/elements/currency/internals/Picker.styles.d.ts.map +1 -0
- package/build/src/elements/currency/internals/Picker.styles.js +58 -0
- package/build/src/elements/currency/internals/Picker.styles.js.map +1 -0
- package/build/src/md/button/internals/base.d.ts +1 -0
- package/build/src/md/button/internals/base.d.ts.map +1 -1
- package/build/src/md/button/internals/base.js +7 -0
- package/build/src/md/button/internals/base.js.map +1 -1
- package/build/src/md/date-picker/internals/DatePicker.styles.d.ts.map +1 -1
- package/build/src/md/date-picker/internals/DatePicker.styles.js +73 -0
- package/build/src/md/date-picker/internals/DatePicker.styles.js.map +1 -1
- package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts +164 -51
- package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts.map +1 -1
- package/build/src/md/date-picker/internals/DatePickerCalendar.js +660 -368
- package/build/src/md/date-picker/internals/DatePickerCalendar.js.map +1 -1
- package/build/src/md/date-picker/ui-date-picker-input.d.ts +65 -13
- package/build/src/md/date-picker/ui-date-picker-input.d.ts.map +1 -1
- package/build/src/md/date-picker/ui-date-picker-input.js +143 -76
- package/build/src/md/date-picker/ui-date-picker-input.js.map +1 -1
- package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts +76 -17
- package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts.map +1 -1
- package/build/src/md/date-picker/ui-date-picker-modal-input.js +192 -127
- package/build/src/md/date-picker/ui-date-picker-modal-input.js.map +1 -1
- package/build/src/md/date-picker/ui-date-picker-modal.d.ts +63 -15
- package/build/src/md/date-picker/ui-date-picker-modal.d.ts.map +1 -1
- package/build/src/md/date-picker/ui-date-picker-modal.js +143 -64
- package/build/src/md/date-picker/ui-date-picker-modal.js.map +1 -1
- package/demo/elements/currency/index.html +91 -0
- package/demo/elements/currency/index.ts +272 -0
- package/demo/elements/index.html +3 -0
- package/demo/md/date-picker/date-picker.ts +138 -103
- package/package.json +1 -1
- package/src/elements/currency/currency-picker.ts +14 -0
- package/src/elements/currency/internals/Picker.styles.ts +58 -0
- package/src/elements/currency/internals/Picker.ts +846 -0
- package/src/md/button/internals/base.ts +7 -0
- package/src/md/date-picker/internals/DatePicker.styles.ts +73 -0
- package/src/md/date-picker/internals/DatePickerCalendar.ts +643 -309
- package/src/md/date-picker/ui-date-picker-input.ts +110 -49
- package/src/md/date-picker/ui-date-picker-modal-input.ts +168 -99
- package/src/md/date-picker/ui-date-picker-modal.ts +136 -53
- package/test/README.md +3 -2
- package/test/elements/currency/CurrencyPicker.accessibility.test.ts +328 -0
- package/test/elements/currency/CurrencyPicker.core.test.ts +318 -0
- package/test/elements/currency/CurrencyPicker.integration.test.ts +482 -0
- package/test/elements/currency/CurrencyPicker.test.ts +486 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { html, TemplateResult } from 'lit'
|
|
2
|
+
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
3
|
+
import reactive from '../../../src/decorators/reactive.js'
|
|
4
|
+
import type { Currency, CurrencyPickerError } from '../../../src/elements/currency/internals/Picker.js'
|
|
5
|
+
|
|
6
|
+
import '../../../src/elements/currency/currency-picker.js'
|
|
7
|
+
import '../../../src/md/button/ui-button.js'
|
|
8
|
+
import '../../../src/md/checkbox/ui-checkbox.js'
|
|
9
|
+
|
|
10
|
+
class CurrencyPickerDemoPage extends DemoPage {
|
|
11
|
+
override accessor componentName = 'Currency Picker'
|
|
12
|
+
|
|
13
|
+
@reactive() accessor singleSelected: string[] = []
|
|
14
|
+
@reactive() accessor multiSelected: string[] = ['USD', 'EUR']
|
|
15
|
+
@reactive() accessor limitedSelected: string[] = []
|
|
16
|
+
@reactive() accessor formSelected: string[] = []
|
|
17
|
+
@reactive() accessor disabledSelected: string[] = ['GBP']
|
|
18
|
+
|
|
19
|
+
@reactive() accessor lastChangeEvent = 'No changes yet'
|
|
20
|
+
@reactive() accessor lastErrorEvent = 'No errors yet'
|
|
21
|
+
|
|
22
|
+
private readonly allowedCurrencies = ['USD', 'EUR', 'GBP', 'JPY', 'CAD']
|
|
23
|
+
|
|
24
|
+
handleSingleChange(event: CustomEvent<{ currencies: Currency[]; codes: string[] }>): void {
|
|
25
|
+
this.singleSelected = event.detail.codes
|
|
26
|
+
this.lastChangeEvent = `Single Select: ${JSON.stringify(event.detail, null, 2)}`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
handleMultiChange(event: CustomEvent<{ currencies: Currency[]; codes: string[] }>): void {
|
|
30
|
+
this.multiSelected = event.detail.codes
|
|
31
|
+
this.lastChangeEvent = `Multi Select: ${JSON.stringify(event.detail, null, 2)}`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handleLimitedChange(event: CustomEvent<{ currencies: Currency[]; codes: string[] }>): void {
|
|
35
|
+
this.limitedSelected = event.detail.codes
|
|
36
|
+
this.lastChangeEvent = `Limited Currencies: ${JSON.stringify(event.detail, null, 2)}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleFormChange(event: CustomEvent<{ currencies: Currency[]; codes: string[] }>): void {
|
|
40
|
+
this.formSelected = event.detail.codes
|
|
41
|
+
this.lastChangeEvent = `Form Element: ${JSON.stringify(event.detail, null, 2)}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
handleError(event: CustomEvent<{ error: CurrencyPickerError }>): void {
|
|
45
|
+
this.lastErrorEvent = `Error: ${JSON.stringify(event.detail, null, 2)}`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
handleClearSingle(): void {
|
|
49
|
+
const picker = document.querySelector('#single-picker') as HTMLElement & { clearSelection(): void }
|
|
50
|
+
picker?.clearSelection()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
handleClearMulti(): void {
|
|
54
|
+
const picker = document.querySelector('#multi-picker') as HTMLElement & { clearSelection(): void }
|
|
55
|
+
picker?.clearSelection()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
handleClearLimited(): void {
|
|
59
|
+
const picker = document.querySelector('#limited-picker') as HTMLElement & { clearSelection(): void }
|
|
60
|
+
picker?.clearSelection()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
handleTriggerValidationError(): void {
|
|
64
|
+
const picker = document.querySelector('#error-demo-picker') as HTMLElement & { selected: string[] }
|
|
65
|
+
if (picker) {
|
|
66
|
+
// Try to set invalid currency codes
|
|
67
|
+
picker.selected = ['INVALID', 'FAKE', 'USD']
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
handleTriggerSelectionError(): void {
|
|
72
|
+
const picker = document.querySelector('#single-error-picker') as HTMLElement & { selected: string[] }
|
|
73
|
+
if (picker) {
|
|
74
|
+
// Try to set multiple currencies on single-select picker
|
|
75
|
+
picker.selected = ['USD', 'EUR', 'GBP']
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override contentTemplate(): TemplateResult {
|
|
80
|
+
return html`
|
|
81
|
+
<section class="demo-section">
|
|
82
|
+
<h3>Single Currency Selection</h3>
|
|
83
|
+
<p>Select one currency at a time. When a new currency is selected, it replaces the previous selection.</p>
|
|
84
|
+
|
|
85
|
+
<div class="demo-controls">
|
|
86
|
+
<currency-picker
|
|
87
|
+
id="single-picker"
|
|
88
|
+
label="Select Currency"
|
|
89
|
+
.selected="${this.singleSelected}"
|
|
90
|
+
@change="${this.handleSingleChange}"
|
|
91
|
+
@error="${this.handleError}"
|
|
92
|
+
></currency-picker>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<ui-button @click="${this.handleClearSingle}">Clear Selection</ui-button>
|
|
96
|
+
|
|
97
|
+
<div class="output-section">
|
|
98
|
+
<h4>Selected Currency</h4>
|
|
99
|
+
<div class="output-content">${this.singleSelected.join(', ') || 'None'}</div>
|
|
100
|
+
</div>
|
|
101
|
+
</section>
|
|
102
|
+
|
|
103
|
+
<section class="demo-section">
|
|
104
|
+
<h3>Multiple Currency Selection</h3>
|
|
105
|
+
<p>Select multiple currencies. Selected currencies appear as chips that can be removed individually.</p>
|
|
106
|
+
|
|
107
|
+
<div class="demo-controls">
|
|
108
|
+
<currency-picker
|
|
109
|
+
id="multi-picker"
|
|
110
|
+
label="Add Currency"
|
|
111
|
+
multi
|
|
112
|
+
.selected="${this.multiSelected}"
|
|
113
|
+
@change="${this.handleMultiChange}"
|
|
114
|
+
@error="${this.handleError}"
|
|
115
|
+
></currency-picker>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<ui-button @click="${this.handleClearMulti}">Clear All</ui-button>
|
|
119
|
+
|
|
120
|
+
<div class="output-section">
|
|
121
|
+
<h4>Selected Currencies</h4>
|
|
122
|
+
<div class="output-content">${this.multiSelected.join(', ') || 'None'}</div>
|
|
123
|
+
</div>
|
|
124
|
+
</section>
|
|
125
|
+
|
|
126
|
+
<section class="demo-section">
|
|
127
|
+
<h3>Limited Currency Options</h3>
|
|
128
|
+
<p>Restrict available currencies to a specific subset using the allowedCurrencies property.</p>
|
|
129
|
+
|
|
130
|
+
<div class="demo-controls">
|
|
131
|
+
<currency-picker
|
|
132
|
+
id="limited-picker"
|
|
133
|
+
label="Select from Limited Options"
|
|
134
|
+
multi
|
|
135
|
+
.selected="${this.limitedSelected}"
|
|
136
|
+
.allowedCurrencies="${this.allowedCurrencies}"
|
|
137
|
+
supportingText="Only major currencies available"
|
|
138
|
+
@change="${this.handleLimitedChange}"
|
|
139
|
+
@error="${this.handleError}"
|
|
140
|
+
></currency-picker>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<ui-button @click="${this.handleClearLimited}">Clear Selection</ui-button>
|
|
144
|
+
|
|
145
|
+
<div class="output-section">
|
|
146
|
+
<h4>Available Currencies</h4>
|
|
147
|
+
<div class="output-content">${this.allowedCurrencies.join(', ')}</div>
|
|
148
|
+
<h4>Selected Currencies</h4>
|
|
149
|
+
<div class="output-content">${this.limitedSelected.join(', ') || 'None'}</div>
|
|
150
|
+
</div>
|
|
151
|
+
</section>
|
|
152
|
+
|
|
153
|
+
<section class="demo-section">
|
|
154
|
+
<h3>Form Integration</h3>
|
|
155
|
+
<p>Use the currency picker in forms with proper name and required attributes.</p>
|
|
156
|
+
|
|
157
|
+
<form @submit="${this.handleFormSubmit}">
|
|
158
|
+
<div class="demo-controls">
|
|
159
|
+
<currency-picker
|
|
160
|
+
label="Required Currency"
|
|
161
|
+
name="currency"
|
|
162
|
+
required
|
|
163
|
+
.selected="${this.formSelected}"
|
|
164
|
+
supportingText="This field is required"
|
|
165
|
+
@change="${this.handleFormChange}"
|
|
166
|
+
@error="${this.handleError}"
|
|
167
|
+
></currency-picker>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<ui-button type="submit">Submit Form</ui-button>
|
|
171
|
+
<ui-button color="text" type="reset">Reset Form</ui-button>
|
|
172
|
+
</form>
|
|
173
|
+
|
|
174
|
+
<div class="output-section">
|
|
175
|
+
<h4>Form Value</h4>
|
|
176
|
+
<div class="output-content">${this.formSelected.join(', ') || 'None'}</div>
|
|
177
|
+
</div>
|
|
178
|
+
</section>
|
|
179
|
+
|
|
180
|
+
<section class="demo-section">
|
|
181
|
+
<h3>Disabled State</h3>
|
|
182
|
+
<p>Currency picker in disabled state with pre-selected currencies.</p>
|
|
183
|
+
|
|
184
|
+
<div class="demo-controls">
|
|
185
|
+
<currency-picker
|
|
186
|
+
label="Disabled Picker"
|
|
187
|
+
disabled
|
|
188
|
+
.selected="${this.disabledSelected}"
|
|
189
|
+
supportingText="This picker is disabled"
|
|
190
|
+
></currency-picker>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<div class="output-section">
|
|
194
|
+
<h4>Disabled Selection</h4>
|
|
195
|
+
<div class="output-content">${this.disabledSelected.join(', ')}</div>
|
|
196
|
+
</div>
|
|
197
|
+
</section>
|
|
198
|
+
|
|
199
|
+
<section class="demo-section">
|
|
200
|
+
<h3>Error Handling Demonstration</h3>
|
|
201
|
+
<p>Test various error scenarios to see how the component handles and displays errors.</p>
|
|
202
|
+
|
|
203
|
+
<h4>Validation Errors</h4>
|
|
204
|
+
<p>This picker demonstrates validation errors when invalid currency codes are set programmatically.</p>
|
|
205
|
+
|
|
206
|
+
<div class="demo-controls">
|
|
207
|
+
<currency-picker
|
|
208
|
+
id="error-demo-picker"
|
|
209
|
+
label="Validation Error Demo"
|
|
210
|
+
multi
|
|
211
|
+
@error="${this.handleError}"
|
|
212
|
+
></currency-picker>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<ui-button @click="${this.handleTriggerValidationError}">Trigger Validation Error</ui-button>
|
|
216
|
+
|
|
217
|
+
<h4>Selection Constraint Errors</h4>
|
|
218
|
+
<p>This single-select picker demonstrates selection constraint errors.</p>
|
|
219
|
+
|
|
220
|
+
<div class="demo-controls">
|
|
221
|
+
<currency-picker
|
|
222
|
+
id="single-error-picker"
|
|
223
|
+
label="Single Select Error Demo"
|
|
224
|
+
@error="${this.handleError}"
|
|
225
|
+
></currency-picker>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<ui-button @click="${this.handleTriggerSelectionError}">Trigger Selection Error</ui-button>
|
|
229
|
+
|
|
230
|
+
<div class="output-section">
|
|
231
|
+
<h4>Error Event Output</h4>
|
|
232
|
+
<div class="output-content">${this.lastErrorEvent}</div>
|
|
233
|
+
</div>
|
|
234
|
+
</section>
|
|
235
|
+
|
|
236
|
+
<section class="demo-section">
|
|
237
|
+
<h3>Event Output</h3>
|
|
238
|
+
<p>View the latest change event data in real-time.</p>
|
|
239
|
+
|
|
240
|
+
<div class="output-section">
|
|
241
|
+
<h4>Last Change Event</h4>
|
|
242
|
+
<div class="output-content">${this.lastChangeEvent}</div>
|
|
243
|
+
</div>
|
|
244
|
+
</section>
|
|
245
|
+
|
|
246
|
+
<section class="demo-section">
|
|
247
|
+
<h3>Error Handling</h3>
|
|
248
|
+
<p>View the latest error event data in real-time.</p>
|
|
249
|
+
|
|
250
|
+
<div class="output-section">
|
|
251
|
+
<h4>Last Error Event</h4>
|
|
252
|
+
<div class="output-content">${this.lastErrorEvent}</div>
|
|
253
|
+
</div>
|
|
254
|
+
</section>
|
|
255
|
+
`
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private handleFormSubmit(event: Event): void {
|
|
259
|
+
event.preventDefault()
|
|
260
|
+
const formData = new FormData(event.target as HTMLFormElement)
|
|
261
|
+
console.log('Form submitted:', Object.fromEntries(formData.entries()))
|
|
262
|
+
|
|
263
|
+
if (this.formSelected.length === 0) {
|
|
264
|
+
alert('Please select a currency before submitting the form.')
|
|
265
|
+
} else {
|
|
266
|
+
alert(`Form submitted with currency: ${this.formSelected.join(', ')}`)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const instance = new CurrencyPickerDemoPage()
|
|
272
|
+
instance.render()
|
package/demo/elements/index.html
CHANGED
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
|
|
28
28
|
<dt><a href="context-menu/index.html">Context menu</a></dt>
|
|
29
29
|
<dd>An element that render a context menu.</dd>
|
|
30
|
+
|
|
31
|
+
<dt><a href="currency/index.html">Currency picker</a></dt>
|
|
32
|
+
<dd>A component for selecting currencies with chips display.</dd>
|
|
30
33
|
|
|
31
34
|
<dt><a href="environment/index.html">Environment</a></dt>
|
|
32
35
|
<dd>The environment elements library.</dd>
|
|
@@ -8,12 +8,11 @@ import '../../../src/md/button/ui-button.js'
|
|
|
8
8
|
class DatePickerDemoPage extends DemoPage {
|
|
9
9
|
override accessor componentName = 'Date Picker'
|
|
10
10
|
|
|
11
|
-
@reactive() accessor rangeMode = false
|
|
12
|
-
@reactive() accessor showConstraints = false
|
|
13
11
|
@reactive() accessor selectedDate: Date | null = null
|
|
14
12
|
@reactive() accessor selectedRange: { start: Date | null; end: Date | null } = { start: null, end: null }
|
|
15
13
|
@reactive() accessor modalOpen = false
|
|
16
14
|
@reactive() accessor modalInputOpen = false
|
|
15
|
+
@reactive() accessor modalInputRangeOpen = false
|
|
17
16
|
@reactive() accessor formValues: string | undefined
|
|
18
17
|
|
|
19
18
|
private get today(): Date {
|
|
@@ -32,16 +31,6 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
32
31
|
return date
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
handleRangeModeChange(e: Event): void {
|
|
36
|
-
const checkbox = e.target as HTMLInputElement
|
|
37
|
-
this.rangeMode = checkbox.checked
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
handleConstraintsChange(e: Event): void {
|
|
41
|
-
const checkbox = e.target as HTMLInputElement
|
|
42
|
-
this.showConstraints = checkbox.checked
|
|
43
|
-
}
|
|
44
|
-
|
|
45
34
|
handleDateChange(e: CustomEvent): void {
|
|
46
35
|
this.selectedDate = e.detail.value
|
|
47
36
|
}
|
|
@@ -70,6 +59,10 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
70
59
|
this.modalInputOpen = true
|
|
71
60
|
}
|
|
72
61
|
|
|
62
|
+
openModalInputRange(): void {
|
|
63
|
+
this.modalInputRangeOpen = true
|
|
64
|
+
}
|
|
65
|
+
|
|
73
66
|
handleModalClose(e: CustomEvent): void {
|
|
74
67
|
this.modalOpen = false
|
|
75
68
|
if (e.detail.confirmed && e.detail.range) {
|
|
@@ -79,15 +72,27 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
79
72
|
|
|
80
73
|
handleModalInputClose(e: CustomEvent): void {
|
|
81
74
|
this.modalInputOpen = false
|
|
82
|
-
if (e.detail.confirmed) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
if (e.detail.confirmed && e.detail.date) {
|
|
76
|
+
this.selectedDate = e.detail.date
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
handleModalInputRangeClose(e: CustomEvent): void {
|
|
81
|
+
this.modalInputRangeOpen = false
|
|
82
|
+
if (e.detail.confirmed && e.detail.range) {
|
|
83
|
+
this.selectedRange = e.detail.range
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
86
|
|
|
87
|
+
private formatDateRange(start: Date | null, end: Date | null, defaultMessage = 'No range selected'): string {
|
|
88
|
+
if (!start || !end) return defaultMessage
|
|
89
|
+
return `${start.toDateString()} - ${end.toDateString()}`
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private formatSingleDate(date: Date | null, defaultMessage = 'No date selected'): string {
|
|
93
|
+
return date ? date.toDateString() : defaultMessage
|
|
94
|
+
}
|
|
95
|
+
|
|
91
96
|
handleFormSubmit(e: SubmitEvent): void {
|
|
92
97
|
e.preventDefault()
|
|
93
98
|
const form = e.target as HTMLFormElement
|
|
@@ -98,14 +103,16 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
98
103
|
|
|
99
104
|
contentTemplate(): TemplateResult {
|
|
100
105
|
return html`
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
<nav>
|
|
107
|
+
<a href="../" class="back-link">← Back to Components</a>
|
|
108
|
+
</nav>
|
|
109
|
+
${this.renderInputs()} ${this.renderCalendars()} ${this.renderModalDatePickers()} ${this.renderFormIntegration()}
|
|
110
|
+
${this.renderModalComponents()}
|
|
104
111
|
${this.formValues
|
|
105
112
|
? html`
|
|
106
113
|
<section class="demo-section">
|
|
107
114
|
<h3 class="headline-medium">Form Output</h3>
|
|
108
|
-
<output>
|
|
115
|
+
<output role="status" aria-live="polite" aria-label="Form submission result">
|
|
109
116
|
<code><pre>${this.formValues}</pre></code>
|
|
110
117
|
</output>
|
|
111
118
|
</section>
|
|
@@ -115,10 +122,9 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
renderInputs(): TemplateResult {
|
|
118
|
-
const { showConstraints: sc } = this
|
|
119
125
|
return html`<section class="demo-section">
|
|
120
126
|
<h2 class="display-large">Date Picker Input</h2>
|
|
121
|
-
<div class="variant-grid">
|
|
127
|
+
<div class="variant-grid" role="group" aria-labelledby="input-variants-heading">
|
|
122
128
|
<span> </span>
|
|
123
129
|
<span class="legend-marker">1</span>
|
|
124
130
|
<span class="legend-marker">2</span>
|
|
@@ -128,24 +134,40 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
128
134
|
<ui-date-picker-input
|
|
129
135
|
label="Basic input"
|
|
130
136
|
placeholder="Select date"
|
|
137
|
+
name="basic-date-picker"
|
|
131
138
|
.value="${this.selectedDate}"
|
|
132
139
|
@change="${this.handleDateChange}"
|
|
140
|
+
aria-describedby="basic-input-help"
|
|
133
141
|
></ui-date-picker-input>
|
|
134
142
|
<ui-date-picker-input
|
|
135
|
-
label="
|
|
143
|
+
label="With constraints"
|
|
136
144
|
placeholder="Select date"
|
|
137
|
-
|
|
138
|
-
.
|
|
145
|
+
name="constrained-date-picker"
|
|
146
|
+
.minDate="${this.today}"
|
|
147
|
+
.maxDate="${this.oneMonthFromNow}"
|
|
139
148
|
.value="${this.selectedDate}"
|
|
140
149
|
@change="${this.handleDateChange}"
|
|
150
|
+
aria-describedby="constrained-input-help"
|
|
151
|
+
></ui-date-picker-input>
|
|
152
|
+
<ui-date-picker-input
|
|
153
|
+
label="Disabled input"
|
|
154
|
+
placeholder="Select date"
|
|
155
|
+
disabled
|
|
156
|
+
name="disabled-date-picker"
|
|
157
|
+
aria-describedby="disabled-input-help"
|
|
141
158
|
></ui-date-picker-input>
|
|
142
|
-
<ui-date-picker-input label="Disabled input" placeholder="Select date" disabled></ui-date-picker-input>
|
|
143
159
|
</div>
|
|
160
|
+
<div id="input-variants-heading" class="visually-hidden">Date input variants demonstration</div>
|
|
161
|
+
<div id="basic-input-help" class="visually-hidden">Basic date picker with no restrictions</div>
|
|
162
|
+
<div id="constrained-input-help" class="visually-hidden">
|
|
163
|
+
Date picker with date constraints applied (today to one month from now)
|
|
164
|
+
</div>
|
|
165
|
+
<div id="disabled-input-help" class="visually-hidden">Disabled date picker for demonstration</div>
|
|
144
166
|
<p class="body-medium">A. Input variants</p>
|
|
145
167
|
<ol class="decimal body-medium">
|
|
146
|
-
<li>Basic</li>
|
|
147
|
-
<li>With constraints</li>
|
|
148
|
-
<li>Disabled
|
|
168
|
+
<li>Basic input</li>
|
|
169
|
+
<li>With date constraints</li>
|
|
170
|
+
<li>Disabled state</li>
|
|
149
171
|
</ol>
|
|
150
172
|
</section>`
|
|
151
173
|
}
|
|
@@ -153,7 +175,7 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
153
175
|
renderCalendars(): TemplateResult {
|
|
154
176
|
return html`<section class="demo-section xl">
|
|
155
177
|
<h2 class="display-large">Date Picker Calendar</h2>
|
|
156
|
-
<div class="variant-grid">
|
|
178
|
+
<div class="variant-grid" role="group" aria-labelledby="calendar-variants-heading">
|
|
157
179
|
<span> </span>
|
|
158
180
|
<span class="legend-marker">1</span>
|
|
159
181
|
<span class="legend-marker">2</span>
|
|
@@ -163,65 +185,82 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
163
185
|
<ui-date-picker-calendar
|
|
164
186
|
showActions
|
|
165
187
|
.selectedDate="${this.selectedDate}"
|
|
166
|
-
@date-
|
|
188
|
+
@date-select="${this.handleDateConfirm}"
|
|
167
189
|
@date-cancel="${this.handleDateCancel}"
|
|
190
|
+
aria-describedby="basic-calendar-help"
|
|
168
191
|
></ui-date-picker-calendar>
|
|
169
192
|
<ui-date-picker-calendar
|
|
170
193
|
showActions
|
|
171
|
-
|
|
172
|
-
.
|
|
194
|
+
rangeSelection
|
|
195
|
+
.rangeStart="${this.selectedRange.start}"
|
|
196
|
+
.rangeEnd="${this.selectedRange.end}"
|
|
173
197
|
@date-range-confirm="${this.handleRangeConfirm}"
|
|
174
198
|
@date-cancel="${this.handleDateCancel}"
|
|
199
|
+
aria-describedby="range-calendar-help"
|
|
175
200
|
></ui-date-picker-calendar>
|
|
176
201
|
<ui-date-picker-calendar
|
|
177
202
|
showActions
|
|
178
203
|
.minDate="${this.today}"
|
|
179
204
|
.maxDate="${this.oneMonthFromNow}"
|
|
180
205
|
.selectedDate="${this.selectedDate}"
|
|
181
|
-
@date-
|
|
206
|
+
@date-select="${this.handleDateConfirm}"
|
|
182
207
|
@date-cancel="${this.handleDateCancel}"
|
|
208
|
+
aria-describedby="constrained-calendar-help"
|
|
183
209
|
></ui-date-picker-calendar>
|
|
184
210
|
</div>
|
|
211
|
+
<div id="calendar-variants-heading" class="visually-hidden">Calendar variants demonstration</div>
|
|
212
|
+
<div id="basic-calendar-help" class="visually-hidden">Basic calendar for single date selection</div>
|
|
213
|
+
<div id="range-calendar-help" class="visually-hidden">Calendar configured for date range selection</div>
|
|
214
|
+
<div id="constrained-calendar-help" class="visually-hidden">
|
|
215
|
+
Calendar with date constraints limiting selectable dates
|
|
216
|
+
</div>
|
|
185
217
|
<p class="body-medium">B. Calendar variants</p>
|
|
186
218
|
<ol class="decimal body-medium">
|
|
187
|
-
<li>
|
|
188
|
-
<li>
|
|
189
|
-
<li>
|
|
219
|
+
<li>Single date selection</li>
|
|
220
|
+
<li>Range selection</li>
|
|
221
|
+
<li>With date constraints</li>
|
|
190
222
|
</ol>
|
|
191
223
|
</section>`
|
|
192
224
|
}
|
|
193
225
|
|
|
194
226
|
renderModalDatePickers(): TemplateResult {
|
|
195
|
-
const { rangeMode: rm } = this
|
|
196
227
|
return html`
|
|
197
228
|
<section class="demo-section">
|
|
198
229
|
<h2 class="display-large">Modal Date Pickers</h2>
|
|
199
230
|
<div class="modal-demo-grid">
|
|
200
|
-
<
|
|
231
|
+
<article class="modal-demo-item">
|
|
201
232
|
<h3 class="headline-small">Range Selection Modal</h3>
|
|
202
|
-
<
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
233
|
+
<p class="body-medium">Full-screen modal for selecting date ranges</p>
|
|
234
|
+
<ui-button @click="${this.openModal}" color="filled" aria-describedby="range-modal-output">
|
|
235
|
+
Open Date Range Picker
|
|
236
|
+
</ui-button>
|
|
237
|
+
<div id="range-modal-output" class="demo-output" role="status" aria-live="polite">
|
|
238
|
+
Selected range: ${this.formatDateRange(this.selectedRange.start, this.selectedRange.end)}
|
|
207
239
|
</div>
|
|
208
|
-
</
|
|
240
|
+
</article>
|
|
209
241
|
|
|
210
|
-
<
|
|
211
|
-
<h3 class="headline-small">Input Modal</h3>
|
|
212
|
-
<
|
|
213
|
-
|
|
242
|
+
<article class="modal-demo-item">
|
|
243
|
+
<h3 class="headline-small">Single Date Input Modal</h3>
|
|
244
|
+
<p class="body-medium">Modal with single date input field</p>
|
|
245
|
+
<ui-button @click="${this.openModalInput}" color="filled" aria-describedby="input-modal-output">
|
|
246
|
+
Open Single Date Input
|
|
214
247
|
</ui-button>
|
|
215
|
-
<div class="demo-output">
|
|
216
|
-
${
|
|
217
|
-
? this.selectedRange.start && this.selectedRange.end
|
|
218
|
-
? html`Range: ${this.selectedRange.start.toDateString()} - ${this.selectedRange.end.toDateString()}`
|
|
219
|
-
: 'No range entered'
|
|
220
|
-
: this.selectedDate
|
|
221
|
-
? html`Date: ${this.selectedDate.toDateString()}`
|
|
222
|
-
: 'No date entered'}
|
|
248
|
+
<div id="input-modal-output" class="demo-output" role="status" aria-live="polite">
|
|
249
|
+
Selected date: ${this.formatSingleDate(this.selectedDate, 'No date entered')}
|
|
223
250
|
</div>
|
|
224
|
-
</
|
|
251
|
+
</article>
|
|
252
|
+
|
|
253
|
+
<article class="modal-demo-item">
|
|
254
|
+
<h3 class="headline-small">Range Input Modal</h3>
|
|
255
|
+
<p class="body-medium">Modal with date range input fields</p>
|
|
256
|
+
<ui-button @click="${this.openModalInputRange}" color="filled" aria-describedby="input-range-modal-output">
|
|
257
|
+
Open Range Date Input
|
|
258
|
+
</ui-button>
|
|
259
|
+
<div id="input-range-modal-output" class="demo-output" role="status" aria-live="polite">
|
|
260
|
+
Selected range:
|
|
261
|
+
${this.formatDateRange(this.selectedRange.start, this.selectedRange.end, 'No range entered')}
|
|
262
|
+
</div>
|
|
263
|
+
</article>
|
|
225
264
|
</div>
|
|
226
265
|
</section>
|
|
227
266
|
`
|
|
@@ -231,21 +270,33 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
231
270
|
return html`<section class="demo-section">
|
|
232
271
|
<h2 class="display-large">Form Integration</h2>
|
|
233
272
|
<div class="frame">
|
|
234
|
-
<form @submit="${this.handleFormSubmit}">
|
|
235
|
-
<
|
|
236
|
-
<
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<
|
|
248
|
-
|
|
273
|
+
<form @submit="${this.handleFormSubmit}" novalidate>
|
|
274
|
+
<fieldset>
|
|
275
|
+
<legend class="visually-hidden">Event scheduling form</legend>
|
|
276
|
+
<div class="form-row">
|
|
277
|
+
<ui-date-picker-input
|
|
278
|
+
required
|
|
279
|
+
label="Event date"
|
|
280
|
+
placeholder="Select event date"
|
|
281
|
+
name="event-date"
|
|
282
|
+
aria-describedby="event-date-help"
|
|
283
|
+
></ui-date-picker-input>
|
|
284
|
+
<div id="event-date-help" class="form-help">Choose the date when the event will take place</div>
|
|
285
|
+
</div>
|
|
286
|
+
<div class="form-row">
|
|
287
|
+
<ui-date-picker-input
|
|
288
|
+
label="Deadline (optional)"
|
|
289
|
+
placeholder="Select deadline"
|
|
290
|
+
name="deadline"
|
|
291
|
+
.minDate="${this.today}"
|
|
292
|
+
aria-describedby="deadline-help"
|
|
293
|
+
></ui-date-picker-input>
|
|
294
|
+
<div id="deadline-help" class="form-help">Optional deadline for event preparation</div>
|
|
295
|
+
</div>
|
|
296
|
+
</fieldset>
|
|
297
|
+
<div class="form-actions" role="group" aria-label="Form actions">
|
|
298
|
+
<ui-button type="submit" color="filled">Submit Form</ui-button>
|
|
299
|
+
<ui-button type="reset" color="outlined">Reset</ui-button>
|
|
249
300
|
</div>
|
|
250
301
|
</form>
|
|
251
302
|
</div>
|
|
@@ -253,7 +304,6 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
253
304
|
}
|
|
254
305
|
|
|
255
306
|
renderModalComponents(): TemplateResult {
|
|
256
|
-
const { rangeMode: rm } = this
|
|
257
307
|
return html`<!-- Modal Components -->
|
|
258
308
|
<ui-date-picker-modal
|
|
259
309
|
?open="${this.modalOpen}"
|
|
@@ -265,35 +315,20 @@ class DatePickerDemoPage extends DemoPage {
|
|
|
265
315
|
|
|
266
316
|
<ui-date-picker-modal-input
|
|
267
317
|
?open="${this.modalInputOpen}"
|
|
268
|
-
title="
|
|
269
|
-
.rangeMode="${
|
|
270
|
-
startLabel="
|
|
271
|
-
endLabel="${rm ? 'End date' : ''}"
|
|
318
|
+
title="Enter date"
|
|
319
|
+
.rangeMode="${false}"
|
|
320
|
+
startLabel="Date"
|
|
272
321
|
@modal-input-close="${this.handleModalInputClose}"
|
|
273
|
-
></ui-date-picker-modal-input
|
|
274
|
-
}
|
|
322
|
+
></ui-date-picker-modal-input>
|
|
275
323
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
<input type="checkbox" .checked="${rm}" @change="${this.handleRangeModeChange}" />
|
|
285
|
-
Range selection mode
|
|
286
|
-
</label>
|
|
287
|
-
</div>
|
|
288
|
-
<div class="config-item">
|
|
289
|
-
<label class="checkbox-label">
|
|
290
|
-
<input type="checkbox" .checked="${sc}" @change="${this.handleConstraintsChange}" />
|
|
291
|
-
Show date constraints
|
|
292
|
-
</label>
|
|
293
|
-
</div>
|
|
294
|
-
</div>
|
|
295
|
-
</section>
|
|
296
|
-
`
|
|
324
|
+
<ui-date-picker-modal-input
|
|
325
|
+
?open="${this.modalInputRangeOpen}"
|
|
326
|
+
title="Enter date range"
|
|
327
|
+
.rangeMode="${true}"
|
|
328
|
+
startLabel="Start date"
|
|
329
|
+
endLabel="End date"
|
|
330
|
+
@modal-input-close="${this.handleModalInputRangeClose}"
|
|
331
|
+
></ui-date-picker-modal-input>`
|
|
297
332
|
}
|
|
298
333
|
}
|
|
299
334
|
|