You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/4.1/forms/date-picker.md
+276-7Lines changed: 276 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,48 @@
1
1
---
2
2
layout: docs
3
3
title: Date Picker
4
-
description: Give your forms some structure—from inline to horizontal to custom grid implementations—with our form layout options.
4
+
description: Create consistent cross-browser and cross-device time picker.
5
5
group: forms
6
6
toc: true
7
7
---
8
8
9
+
## Installation
10
+
11
+
This component is part of the CoreUI LAB. If you want to use Date Picker component you have to install **next** version of the `@coreui/coreui-pro@next` package. The LAB is the place where we release components that are actively developed and will be included in future releases of `@coreui/coreui-pro`.
Set heights using `size`property like `size="lg"` and `size="sm"`.
45
+
Set heights using `data-coreui-size`attribute like `data-coreui-size="lg"` and `data-coreui-size="sm"`.
32
46
33
47
{{< example >}}
34
48
<divclass="row mb-4">
@@ -45,7 +59,7 @@ Set heights using `size` property like `size="lg"` and `size="sm"`.
45
59
46
60
## Disabled
47
61
48
-
Add the `disabled` boolean attribute on an input to give it a grayed out appearance and remove pointer events.
62
+
Add the `data-coreui-disabled="true"` attribute on an input to give it a grayed out appearance and remove pointer events.
49
63
50
64
{{< example >}}
51
65
<divclass="row">
@@ -57,7 +71,7 @@ Add the `disabled` boolean attribute on an input to give it a grayed out appeara
57
71
58
72
## Readonly
59
73
60
-
Add the `inputReadOnly` boolean attribute to prevent modification of the input's value.
74
+
Add the `data-coreui-input-read-only="true"` boolean attribute to prevent modification of the input's value.
61
75
62
76
{{< example >}}
63
77
<divclass="row">
@@ -160,3 +174,258 @@ RTL support is built-in and can be explicitly controlled through the `$enable-rt
160
174
</div>
161
175
{{< /example >}}
162
176
177
+
## Usage
178
+
179
+
### Via data attributes
180
+
181
+
Add `data-coreui-toggle="date-picker"` to a `div` element.
182
+
183
+
```html
184
+
<divdata-coreui-toggle="date-picker"></div>
185
+
```
186
+
187
+
### Via JavaScript
188
+
189
+
Call the time picker via JavaScript:
190
+
191
+
```html
192
+
<divclass="date-picker"></div>
193
+
```
194
+
195
+
```js
196
+
var datePickerElementList =Array.prototype.slice.call(document.querySelectorAll('.date-picker'))
197
+
var datePickerList =datePickerElementList.map(function (datePickerEl) {
198
+
returnnewcoreui.DatePicker(datePickerEl)
199
+
})
200
+
```
201
+
202
+
### Options
203
+
204
+
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-coreui-`, as in `data-coreui-cleaner=""`. Make sure to change the case type of the option name from camelCase to kebab-case when passing the options via data attributes. For example, instead of using `data-coreui-inputReadOnly="false"`, use `data-coreui-input-read-only="false"`.
205
+
206
+
<tableclass="table">
207
+
<thead>
208
+
<tr>
209
+
<th style="width: 100px;">Name</th>
210
+
<th style="width: 100px;">Type</th>
211
+
<th style="width: 50px;">Default</th>
212
+
<th>Description</th>
213
+
</tr>
214
+
</thead>
215
+
<tbody>
216
+
<tr>
217
+
<td><code>calendarDate</code></td>
218
+
<td>date | string | null</td>
219
+
<td><code>null</code></td>
220
+
<td>Default date of the component.</td>
221
+
</tr>
222
+
<tr>
223
+
<td><code>cancelButtonText</code></td>
224
+
<td>string</td>
225
+
<td><code>'Cancel'</code></td>
226
+
<td>Cancel button text.</td>
227
+
</tr>
228
+
<tr>
229
+
<td><code>cleaner</code></td>
230
+
<td>boolean</td>
231
+
<td><code>true</code></td>
232
+
<td>Enables selection cleaner element.</td>
233
+
</tr>
234
+
<tr>
235
+
<td><code>date</code></td>
236
+
<td>date | string | null</td>
237
+
<td><code>null</code></td>
238
+
<td>Initial selected date.</td>
239
+
</tr>
240
+
<tr>
241
+
<td><code>disabled</code></td>
242
+
<td>boolean</td>
243
+
<td><code>false</code></td>
244
+
<td>Toggle the disabled state for the component.</td>
245
+
</tr>
246
+
<tr>
247
+
<td><code>disabledDates</code></td>
248
+
<td>array | null</td>
249
+
<td><code>null</code></td>
250
+
<td>Specify the list of dates that cannot be selected.</td>
251
+
</tr>
252
+
<tr>
253
+
<td><code>firstDayOfWeek</code></td>
254
+
<td>number</td>
255
+
<td><code>1</code></td>
256
+
<td>
257
+
<p>Sets the day of start week.</p>
258
+
<ul>
259
+
<li><code>0</code> - Sunday</li>
260
+
<li><code>1</code> - Monday</li>
261
+
<li><code>2</code> - Tuesday</li>
262
+
<li><code>3</code> - Wednesday</li>
263
+
<li><code>4</code> - Thursday</li>
264
+
<li><code>5</code> - Friday</li>
265
+
<li><code>6</code> - Saturday</li>
266
+
</ul>
267
+
</td>
268
+
</tr>
269
+
<tr>
270
+
<td><code>inputReadOnly</code></td>
271
+
<td>boolean</td>
272
+
<td><code>false</code></td>
273
+
<td>Toggle the readonly state for the component.</td>
274
+
</tr>
275
+
<tr>
276
+
<td><code>footer</code></td>
277
+
<td>boolean</td>
278
+
<td><code>false</code></td>
279
+
<td>Toggle visibility of footer element.</td>
280
+
</tr>
281
+
<tr>
282
+
<td><code>locale</code></td>
283
+
<td>string</td>
284
+
<td><code>navigator.language</code></td>
285
+
<td>Sets the default locale for components. If not set, it is inherited from the navigator.language.</td>
286
+
</tr>
287
+
<tr>
288
+
<td><code>maxDate</code></td>
289
+
<td>date | string | null</td>
290
+
<td><code>null</code></td>
291
+
<td>Max selectable date.</td>
292
+
</tr>
293
+
<tr>
294
+
<td><code>minDate</code></td>
295
+
<td>date | string | null</td>
296
+
<td><code>null</code></td>
297
+
<td>Min selectable date.</td>
298
+
</tr>
299
+
<tr>
300
+
<td><code>okButtonText</code></td>
301
+
<td>string</td>
302
+
<td><code>'OK'</code></td>
303
+
<td>Ok button text.</td>
304
+
</tr>
305
+
<tr>
306
+
<td><code>placeholder</code></td>
307
+
<td>string</td>
308
+
<td><code>'Select time'</code></td>
309
+
<td>Specifies a short hint that is visible in the input.</td>
310
+
</tr>
311
+
<tr>
312
+
<td><code>size</code></td>
313
+
<td><code>'sm'</code> | <code>'lg'</code></td>
314
+
<td><code>null</code></td>
315
+
<td>Size the component small or large.</td>
316
+
</tr>
317
+
<tr>
318
+
<td><code>timepicker</code></td>
319
+
<td>boolean</td>
320
+
<td><code>false</code></td>
321
+
<td>Provide an additional time selection by adding select boxes to choose times.</td>
Destroys an element's dropdown. (Removes stored data on the DOM element)
372
+
</td>
373
+
</tr>
374
+
<tr>
375
+
<td>
376
+
<code>getInstance</code>
377
+
</td>
378
+
<td>
379
+
Static method which allows you to get the dropdown instance associated to a DOM element, you can use it like this: <code>coreui.DatePicker.getInstance(element)</code>
380
+
</td>
381
+
</tr>
382
+
<tr>
383
+
<td>
384
+
<code>getOrCreateInstance</code>
385
+
</td>
386
+
<td>
387
+
Static method which returns a dropdown instance associated to a DOM element or create a new one in case it wasn't initialized.
388
+
You can use it like this: <code>coreui.DatePicker.getOrCreateInstance(element)</code>
389
+
</td>
390
+
</tr>
391
+
</tbody>
392
+
</table>
393
+
394
+
### Events
395
+
396
+
<tableclass="table">
397
+
<thead>
398
+
<tr>
399
+
<th>Method</th>
400
+
<th>Description</th>
401
+
</tr>
402
+
</thead>
403
+
<tbody>
404
+
<tr>
405
+
<td>
406
+
<code>dateChange.coreui.date-picker</code>
407
+
</td>
408
+
<td>
409
+
Callback fired when the date changed.
410
+
</td>
411
+
</tr>
412
+
</tbody>
413
+
</table>
414
+
415
+
```js
416
+
var myDatePicker =document.getElementById('myDatePicker')
417
+
myDatePicker.addEventListener('dateChange.coreui.date-picker', function (date) {
0 commit comments