File size: 2,185 Bytes
285e056
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256ba3e
285e056
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256ba3e
285e056
256ba3e
285e056
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256ba3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
101
102
103
104
105
106
<script lang="ts">
	import { BlockTitle } from "@gradio/atoms";
	import { Block } from "@gradio/atoms";

	import type { Gradio } from "@gradio/utils";

	export let value: string | null = null;
	export let value_is_output = false;
	export let label: string;
	export let visible = true;
	export let elem_classes;
	export let elem_id;
	export let scale;
	export let info;
	export let min_width;
	export let show_label = true;
	export let container = true;
	export let interactive = true;
	export let gradio: Gradio<{
		change: never;
		input: never;
		submit: never;
	}>;

	$: if (value === null) value = new Date().toISOString().split('T')[0];

	let el: HTMLInputElement

	function handle_change(): void {
		gradio.dispatch("change");
		if (!value_is_output) {
			gradio.dispatch("submit");
			gradio.dispatch("input");
		}
	}
 
	$: value, handle_change();


</script>


<Block
	{visible}
	{elem_id}
	{elem_classes}
	{scale}
	{min_width}
	allow_overflow={false}
	padding={true}
>
	<label class:container>
		<BlockTitle {show_label} {info}>{label}</BlockTitle>
		<input type="date" bind:this={el} bind:value={value} on:change={handle_change} disabled={!interactive}/>
	</label>
</Block>

<style>
	label {
		display: block;
		width: 100%;
	}

	input {
		display: block;
		position: relative;
		outline: none !important;
		box-shadow: var(--input-shadow);
		background: var(--input-background-fill);
		padding: var(--input-padding);
		width: 100%;
		color: var(--body-text-color);
		font-weight: var(--input-text-weight);
		font-size: var(--input-text-size);
		line-height: var(--line-sm);
		border: none;
	}

	input[type="date"]::-webkit-calendar-picker-indicator {
		cursor: pointer;
	}

	label:not(.container),
	label:not(.container) > input {
		height: 100%;
	}
	.container > input{
		border: var(--input-border-width) solid var(--input-border-color);
		border-radius: var(--input-radius);
	}
	input:disabled {
		-webkit-text-fill-color: var(--body-text-color);
		-webkit-opacity: 1;
		opacity: 1;
	}

	input:focus {
		box-shadow: var(--input-shadow-focus);
		border-color: var(--input-border-color-focus);
	}

	input::placeholder {
		color: var(--input-placeholder-color);
	}

</style>