Pick a time of day. el_time_picker() takes any time, or a range of them
with is_range = TRUE; el_time_select() offers fixed times at a set
interval, such as every half hour between nine and six.
Usage
el_time_picker(
id = NULL,
value = NULL,
is_range = FALSE,
value_format = "HH:mm:ss",
arrow_control = NULL,
placeholder = NULL,
start_placeholder = NULL,
end_placeholder = NULL,
range_separator = NULL,
clearable = NULL,
disabled = NULL,
editable = NULL,
readonly = NULL,
size = NULL,
popper_class = NULL,
default_value = NULL,
prefix_icon = NULL,
clear_icon = NULL,
label = NULL,
label_position = c("top", "left", "right"),
label_width = NULL,
label_suffix = NULL,
required = FALSE,
error = NULL,
show_message = TRUE,
inline_message = FALSE,
format = NULL,
popper_style = NULL,
popper_options = NULL,
placement = NULL,
fallback_placements = NULL,
disabled_hours = NULL,
disabled_minutes = NULL,
disabled_seconds = NULL,
teleported = NULL,
tabindex = NULL,
aria_label = NULL,
empty_values = NULL,
value_on_clear = NULL,
save_on_blur = NULL,
width = NULL,
slots = NULL,
events = NULL,
on = NULL,
session = NULL
)
el_time_select(
id = NULL,
value = NULL,
placeholder = NULL,
clearable = NULL,
disabled = NULL,
editable = NULL,
size = NULL,
popper_class = NULL,
prefix_icon = NULL,
clear_icon = NULL,
label = NULL,
label_position = c("top", "left", "right"),
label_width = NULL,
label_suffix = NULL,
required = FALSE,
error = NULL,
show_message = TRUE,
inline_message = FALSE,
start = NULL,
end = NULL,
step = NULL,
min_time = NULL,
max_time = NULL,
include_end_time = NULL,
format = NULL,
effect = NULL,
popper_style = NULL,
empty_values = NULL,
value_on_clear = NULL,
width = NULL,
slots = NULL,
events = NULL,
on = NULL,
session = NULL
)
update_el_time_picker(
session = shiny::getDefaultReactiveDomain(),
id,
value = NULL,
disabled = NULL,
label = NULL,
error = NULL,
is_range = NULL,
value_format = NULL,
arrow_control = NULL,
placeholder = NULL,
start_placeholder = NULL,
end_placeholder = NULL,
range_separator = NULL,
clearable = NULL,
editable = NULL,
readonly = NULL,
size = NULL,
popper_class = NULL,
prefix_icon = NULL,
clear_icon = NULL,
format = NULL,
popper_style = NULL,
popper_options = NULL,
placement = NULL,
fallback_placements = NULL,
disabled_hours = NULL,
disabled_minutes = NULL,
disabled_seconds = NULL,
teleported = NULL,
tabindex = NULL,
aria_label = NULL,
empty_values = NULL,
value_on_clear = NULL,
save_on_blur = NULL
)
update_el_time_select(
session = shiny::getDefaultReactiveDomain(),
id,
value = NULL,
disabled = NULL,
label = NULL,
error = NULL,
placeholder = NULL,
clearable = NULL,
editable = NULL,
size = NULL,
popper_class = NULL,
prefix_icon = NULL,
clear_icon = NULL,
start = NULL,
end = NULL,
step = NULL,
min_time = NULL,
max_time = NULL,
include_end_time = NULL,
format = NULL,
effect = NULL,
popper_style = NULL,
empty_values = NULL,
value_on_clear = NULL
)Arguments
- id
Picker ID. Auto-generated if
NULL.- value
Initial time, as
"HH:mm:ss"text – two of them for a range.- is_range
Pick a start and an end rather than a single time.
- value_format
Format of the value reported to Shiny, in day.js's tokens. Default
"HH:mm:ss".- arrow_control
Whether hours, minutes and seconds are changed with arrow buttons rather than by scrolling.
- placeholder, start_placeholder, end_placeholder
Placeholder text, the latter two for a range.
- range_separator
Text between the two times of a range. Default
"-".- clearable, disabled, editable, readonly
As for an input.
- size
Size:
"large","default"or"small";NULLfollows the form or the page.- popper_class, popper_style
Extra class name and style for the panel.
- default_value
Time the panel opens on when nothing is picked.
- prefix_icon, clear_icon
Icons, by name:
"Clock","CircleClose".- label
A label shown with the component, as Shiny's inputs have: text or a tag.
NULL, the default, shows none. It is the component's accessible name too – tied to it withforwhere the component has a native input that takes the id<id>-input, else witharia-labelledby.- label_position
Where the label sits, as
el_form()'slabel_position:"top"(the default, as Shiny's labels sit), or beside the component, its text aligned"left"or"right"– which shows oncelabel_widthgives the labels a common width.- label_width
Width of a label beside the component, as a CSS unit, so that several line up. Element's
label-width.- label_suffix
Text after the label, such as
":". Element'slabel-suffix.- required
Draw Element's red asterisk before the label. It marks the field; it does not check it – shinyvalidate or
el_form()does that.- error
An error message shown under the component in Element's style, the field framed in red. Element's
error.- show_message, inline_message
Whether
error's message is shown, and whether beside the component rather than under it. Element'sshow-messageandinline-message.- format
Format of the time shown in the input, in day.js's tokens.
- popper_options, placement, fallback_placements
Where the panel opens, as Element Plus's tooltip takes them.
- disabled_hours, disabled_minutes, disabled_seconds
JS()functions returning the hours, minutes or seconds that cannot be picked – what Element UI'sselectableRangedid.- teleported
Whether the panel is moved to
<body>.- tabindex, aria_label
Native attributes of the input.
- empty_values, value_on_clear
What counts as empty, and the value a cleared picker reports. See Element Plus's config provider;
nullasJS("null"), whileNULLleaves Element's default.- save_on_blur
Whether the time typed is kept when the input loses focus.
- width
Component width, as a CSS unit.
- slots
Named list of Element slot contents.
- events
Element's events to report besides those reported unasked, by name:
events = "node_drop"reportsinput$<id>_node_drop. The component's are listed under "Shiny inputs", and byel_events(); a name it does not have is an error.- on
Handlers of your own, for an event not reported or to send something else: a named list of
JS()functions, one per event – Element's, or a DOM event with Vue's modifiers ("keyup.enter"). Each is called withreportand the event's arguments;report(name, value)setsinput$<id>_<name>. Seeel_widget().- session
In
el_time_picker(), deprecated: inside a module, wrapidinns(), as for any Shiny input; a session given here namespacesidonce more, with a warning. Inupdate_el_time_picker(), the Shiny session, the current one by default, as forshiny::updateTextInput().- include_end_time, start, end, step, min_time, max_time
For
el_time_select(): the first and last time offered, the interval, whetherenditself is offered, and the bounds of what can be picked.- effect
"light"(default) or"dark"panel, forel_time_select().
Shiny inputs
| Input | Reported | Value |
input$<id> | unasked | the time, two for a range |
input$<id>_blur | events = "blur" | triggers when Input blurs |
input$<id>_focus | events = "focus" | triggers when Input focuses |
input$<id>_clear | events = "clear" | triggers when the clear icon is clicked in a clearable TimePicker |
input$<id>_visible_change | events = "visible_change" | triggers when the TimePicker's dropdown appears/disappears |
The same list as el_events("el_time_picker"), which says how an event's arguments travel.
el_time_select():
| Input | Reported | Value |
input$<id> | unasked | the time |
input$<id>_blur | events = "blur" | triggers when Input blurs |
input$<id>_focus | events = "focus" | triggers when Input focuses |
input$<id>_clear | events = "clear" | triggers when the clear icon is clicked in a clearable TimeSelect |
The same list as el_events("el_time_select"), which says how an event's arguments travel.
Element methods
Callable with call_el(): focus(), blur(); and for el_time_picker(),
handleOpen() and handleClose().
Binding
Every argument can follow v_bind() or v_model() except label, label_position, label_width, label_suffix, required, error, show_message, inline_message (the form item around the component, drawn by R); width (the mount point's style).
Updating from the server
Server-side update for el_time_picker() and el_time_select();
update_el_time_select() is the time select's, with its own arguments.
Every other argument of el_time_picker() that can change once it is
drawn is an argument here too, under the same name. One left NULL
stays as it is; NA returns it to Element's default.
update_el_time_picker() is called for its side effect and returns NULL invisibly.
Updating a time select
update_el_time_select() changes the time select from the server: every
argument of el_time_select() that can change once it is drawn, under the
same name. One left NULL stays as it is; NA returns it to Element's
default.
update_el_time_select() is called for its side effect and returns NULL invisibly.
Examples
el_time_picker("start", value = "09:30:00")
#> <div id="start" data-shiny-vue style="display: contents">
#> <script type="text/x-template" data-shiny-vue-template><div id="start_container" style="display: contents">
#> <el-time-picker v-bind="$optional('time-picker')" v-model="value" @change="handleChange"></el-time-picker>
#> </div></script>
#> <script type="application/json" data-shiny-vue-options>{"options":{"data":{"value":"09:30:00","isRange":false,"valueFormat":"HH:mm:ss","format":null,"arrowControl":null,"placeholder":null,"startPlaceholder":null,"endPlaceholder":null,"rangeSeparator":null,"clearable":null,"disabled":null,"editable":null,"readonly":null,"size":null,"popperClass":null,"popperStyle":null,"popperOptions":null,"placement":null,"fallbackPlacements":null,"defaultValue":null,"disabledHours":null,"disabledMinutes":null,"disabledSeconds":null,"prefixIcon":null,"clearIcon":null,"teleported":null,"tabindex":null,"ariaLabel":null,"emptyValues":null,"valueOnClear":null,"saveOnBlur":null},"methods":{"handleChange":"function(v) { }"}},"input":"value","rate":null,"type":null,"use":["shinyElement.plugin"],"optional":{"time-picker":{"is-range":"isRange","value-format":"valueFormat","format":"format","arrow-control":"arrowControl","placeholder":"placeholder","start-placeholder":"startPlaceholder","end-placeholder":"endPlaceholder","range-separator":"rangeSeparator","clearable":"clearable","disabled":"disabled","editable":"editable","readonly":"readonly","size":"size","popper-class":"popperClass","popper-style":"popperStyle","popper-options":"popperOptions","placement":"placement","fallback-placements":"fallbackPlacements","default-value":{"field":"defaultValue","wrap":"elDate"},"disabled-hours":"disabledHours","disabled-minutes":"disabledMinutes","disabled-seconds":"disabledSeconds","prefix-icon":"prefixIcon","clear-icon":"clearIcon","teleported":"teleported","tabindex":"tabindex","aria-label":"ariaLabel","empty-values":"emptyValues","value-on-clear":"valueOnClear","save-on-blur":"saveOnBlur"}},"evals":["options.methods.handleChange"]}</script>
#> </div>
# Only office hours
el_time_picker(
"start",
disabled_hours = JS(
"function() {",
" var h = [];",
" for (var i = 0; i < 24; i++) if (i < 9 || i > 18) h.push(i);",
" return h;",
"}"
)
)
#> <div id="start" data-shiny-vue style="display: contents">
#> <script type="text/x-template" data-shiny-vue-template><div id="start_container" style="display: contents">
#> <el-time-picker v-bind="$optional('time-picker')" v-model="value" @change="handleChange"></el-time-picker>
#> </div></script>
#> <script type="application/json" data-shiny-vue-options>{"options":{"data":{"value":"","isRange":false,"valueFormat":"HH:mm:ss","format":null,"arrowControl":null,"placeholder":null,"startPlaceholder":null,"endPlaceholder":null,"rangeSeparator":null,"clearable":null,"disabled":null,"editable":null,"readonly":null,"size":null,"popperClass":null,"popperStyle":null,"popperOptions":null,"placement":null,"fallbackPlacements":null,"defaultValue":null,"disabledHours":"function() {\n var h = [];\n for (var i = 0; i < 24; i++) if (i < 9 || i > 18) h.push(i);\n return h;\n}","disabledMinutes":null,"disabledSeconds":null,"prefixIcon":null,"clearIcon":null,"teleported":null,"tabindex":null,"ariaLabel":null,"emptyValues":null,"valueOnClear":null,"saveOnBlur":null},"methods":{"handleChange":"function(v) { }"}},"input":"value","rate":null,"type":null,"use":["shinyElement.plugin"],"optional":{"time-picker":{"is-range":"isRange","value-format":"valueFormat","format":"format","arrow-control":"arrowControl","placeholder":"placeholder","start-placeholder":"startPlaceholder","end-placeholder":"endPlaceholder","range-separator":"rangeSeparator","clearable":"clearable","disabled":"disabled","editable":"editable","readonly":"readonly","size":"size","popper-class":"popperClass","popper-style":"popperStyle","popper-options":"popperOptions","placement":"placement","fallback-placements":"fallbackPlacements","default-value":{"field":"defaultValue","wrap":"elDate"},"disabled-hours":"disabledHours","disabled-minutes":"disabledMinutes","disabled-seconds":"disabledSeconds","prefix-icon":"prefixIcon","clear-icon":"clearIcon","teleported":"teleported","tabindex":"tabindex","aria-label":"ariaLabel","empty-values":"emptyValues","value-on-clear":"valueOnClear","save-on-blur":"saveOnBlur"}},"evals":["options.data.disabledHours","options.methods.handleChange"]}</script>
#> </div>
# A range
el_time_picker("shift", is_range = TRUE, value = c("09:00:00", "17:30:00"))
#> <div id="shift" data-shiny-vue style="display: contents">
#> <script type="text/x-template" data-shiny-vue-template><div id="shift_container" style="display: contents">
#> <el-time-picker v-bind="$optional('time-picker')" v-model="value" @change="handleChange"></el-time-picker>
#> </div></script>
#> <script type="application/json" data-shiny-vue-options>{"options":{"data":{"value":["09:00:00","17:30:00"],"isRange":true,"valueFormat":"HH:mm:ss","format":null,"arrowControl":null,"placeholder":null,"startPlaceholder":null,"endPlaceholder":null,"rangeSeparator":null,"clearable":null,"disabled":null,"editable":null,"readonly":null,"size":null,"popperClass":null,"popperStyle":null,"popperOptions":null,"placement":null,"fallbackPlacements":null,"defaultValue":null,"disabledHours":null,"disabledMinutes":null,"disabledSeconds":null,"prefixIcon":null,"clearIcon":null,"teleported":null,"tabindex":null,"ariaLabel":null,"emptyValues":null,"valueOnClear":null,"saveOnBlur":null},"methods":{"handleChange":"function(v) { }"}},"input":"value","rate":null,"type":null,"use":["shinyElement.plugin"],"optional":{"time-picker":{"is-range":"isRange","value-format":"valueFormat","format":"format","arrow-control":"arrowControl","placeholder":"placeholder","start-placeholder":"startPlaceholder","end-placeholder":"endPlaceholder","range-separator":"rangeSeparator","clearable":"clearable","disabled":"disabled","editable":"editable","readonly":"readonly","size":"size","popper-class":"popperClass","popper-style":"popperStyle","popper-options":"popperOptions","placement":"placement","fallback-placements":"fallbackPlacements","default-value":{"field":"defaultValue","wrap":"elDate"},"disabled-hours":"disabledHours","disabled-minutes":"disabledMinutes","disabled-seconds":"disabledSeconds","prefix-icon":"prefixIcon","clear-icon":"clearIcon","teleported":"teleported","tabindex":"tabindex","aria-label":"ariaLabel","empty-values":"emptyValues","value-on-clear":"valueOnClear","save-on-blur":"saveOnBlur"}},"evals":["options.methods.handleChange"]}</script>
#> </div>
# Every half hour between nine and six
el_time_select("slot", start = "09:00", step = "00:30", end = "18:00")
#> <div id="slot" data-shiny-vue style="display: contents">
#> <script type="text/x-template" data-shiny-vue-template><div id="slot_container" style="display: contents">
#> <el-time-select v-bind="$optional('time-select')" v-model="value" @change="handleChange"></el-time-select>
#> </div></script>
#> <script type="application/json" data-shiny-vue-options>{"options":{"data":{"value":"","start":"09:00","end":"18:00","step":"00:30","minTime":null,"maxTime":null,"includeEndTime":null,"format":null,"placeholder":null,"clearable":null,"disabled":null,"editable":null,"size":null,"effect":null,"popperClass":null,"popperStyle":null,"prefixIcon":null,"clearIcon":null,"emptyValues":null,"valueOnClear":null},"methods":{"handleChange":"function(v) { }"}},"input":"value","rate":null,"type":null,"use":["shinyElement.plugin"],"optional":{"time-select":{"start":"start","end":"end","step":"step","min-time":"minTime","max-time":"maxTime","include-end-time":"includeEndTime","format":"format","placeholder":"placeholder","clearable":"clearable","disabled":"disabled","editable":"editable","size":"size","effect":"effect","popper-class":"popperClass","popper-style":"popperStyle","prefix-icon":"prefixIcon","clear-icon":"clearIcon","empty-values":"emptyValues","value-on-clear":"valueOnClear"}},"evals":["options.methods.handleChange"]}</script>
#> </div>
if (interactive()) {
# inside a server function
observeEvent(
input$reset,
update_el_time_picker(session, "start", value = "09:00:00")
)
}