draft-components 2.10.3 → 3.0.0
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/css/draft-components-utilities.css +6 -7
- package/css/draft-components-variables.css +437 -0
- package/css/draft-components.css +1199 -617
- package/dist/components/alert/alert.css +163 -0
- package/dist/components/avatar/avatar.css +91 -0
- package/dist/components/avatar/avatar.js +3 -1
- package/dist/components/badge/badge.css +28 -0
- package/dist/components/breadcrumbs/breadcrumbs.css +72 -0
- package/dist/components/button/button.css +241 -0
- package/dist/components/button/button.js +3 -1
- package/dist/components/button/icon-button.js +1 -1
- package/dist/components/button-group/button-group.css +27 -0
- package/dist/components/caption/caption.css +36 -0
- package/dist/components/checkbox/checkbox.css +90 -0
- package/dist/components/checkbox/checkbox.js +3 -1
- package/dist/components/color-picker/color-picker.css +86 -0
- package/dist/components/date-picker/calendar-grid.js +2 -2
- package/dist/components/date-picker/date-helpers.js +3 -3
- package/dist/components/date-picker/date-picker.css +203 -0
- package/dist/components/date-picker/date-range.js +4 -2
- package/dist/components/date-picker/parse-min-max-props.js +3 -3
- package/dist/components/date-picker-popover/date-picker-popover.css +8 -0
- package/dist/components/date-range-picker-popover/date-range-picker-popover.css +73 -0
- package/dist/components/date-range-picker-popover/helpers.js +2 -2
- package/dist/components/dialog/dialog.css +173 -0
- package/dist/components/empty-state/empty-state.css +52 -0
- package/dist/components/file-picker/file-picker.css +74 -0
- package/dist/components/filter-buttons/filter-buttons.css +60 -0
- package/dist/components/filter-buttons/filter-buttons.js +2 -2
- package/dist/components/filtered-search/filter-item.css +30 -0
- package/dist/components/filtered-search/filter-operator-select.css +6 -0
- package/dist/components/filtered-search/filter-token.css +63 -0
- package/dist/components/filtered-search/filter-value-list.css +17 -0
- package/dist/components/filtered-search/filtered-search.css +284 -0
- package/dist/components/filtered-search/model/string-filter.js +4 -2
- package/dist/components/filtered-search/model/string-set-filter.js +4 -2
- package/dist/components/filtered-search/string-filter-input.css +12 -0
- package/dist/components/filtered-search/string-filter-item.js +4 -2
- package/dist/components/filtered-search/string-set-filter-item.js +3 -1
- package/dist/components/form-field/form-field.css +21 -0
- package/dist/components/form-field/form-field.js +3 -1
- package/dist/components/label/label.css +23 -0
- package/dist/components/menu/menu.css +87 -0
- package/dist/components/menu/menu.d.ts +4 -4
- package/dist/components/menu/menu.js +4 -4
- package/dist/components/nav-list/nav-list-item.js +1 -1
- package/dist/components/nav-list/nav-list.css +89 -0
- package/dist/components/password-input/password-input.css +49 -0
- package/dist/components/popover/popover.css +98 -0
- package/dist/components/popover/popover.js +3 -3
- package/dist/components/positioner/calc-position.js +4 -4
- package/dist/components/radio/radio.css +88 -0
- package/dist/components/segmented-control/segmented-control.css +113 -0
- package/dist/components/select/select.css +121 -0
- package/dist/components/selection-control/selection-control.css +36 -0
- package/dist/components/selection-control/selection-control.js +3 -1
- package/dist/components/slide-over/slide-over-body.css +7 -0
- package/dist/components/slide-over/slide-over-header.css +29 -0
- package/dist/components/slide-over/slide-over-header.js +5 -1
- package/dist/components/slide-over/slide-over.css +85 -0
- package/dist/components/slider/get-offset-relative-to-thumb.js +5 -5
- package/dist/components/slider/range-slider.d.ts +21 -21
- package/dist/components/slider/range-slider.js +15 -15
- package/dist/components/slider/slider-thumb.d.ts +16 -17
- package/dist/components/slider/slider-thumb.js +3 -3
- package/dist/components/slider/slider-track.js +7 -7
- package/dist/components/slider/slider.css +261 -0
- package/dist/components/slider/slider.d.ts +17 -17
- package/dist/components/slider/slider.js +2 -2
- package/dist/components/spinner/spinner.css +42 -0
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/switch/switch.css +123 -0
- package/dist/components/table/table-head-cell.js +1 -1
- package/dist/components/table/table.css +176 -0
- package/dist/components/tabs/tab.js +1 -1
- package/dist/components/tabs/tabs.css +94 -0
- package/dist/components/tag/tag.css +390 -0
- package/dist/components/text-input/text-input.css +146 -0
- package/dist/components/textarea/textarea.css +82 -0
- package/dist/components/toast/toast.css +154 -0
- package/dist/components/toaster/toaster.css +95 -0
- package/dist/components/toaster/toaster.js +7 -3
- package/dist/components/tooltip/tooltip.css +34 -0
- package/dist/hooks/use-mount-transition.js +2 -2
- package/package.json +23 -18
- package/css/draft-components.dark.css +0 -609
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
.dc-checkbox {
|
|
2
|
+
--dc-checkbox-size: 20px;
|
|
3
|
+
--dc-checkbox-radius: 6px;
|
|
4
|
+
--dc-checkbox-bg: var(--dc-control-bg);
|
|
5
|
+
--dc-checkbox-bg-checked: var(--dc-control-primary-color);
|
|
6
|
+
--dc-checkbox-border-color: var(--dc-control-border-color);
|
|
7
|
+
--dc-checkbox-border-color-checked: var(--dc-control-primary-color);
|
|
8
|
+
--dc-checkbox-icon-color: var(--dc-control-on-primary-color);
|
|
9
|
+
--dc-checkbox-focus-ring-color: var(--dc-focus-ring-color);
|
|
10
|
+
|
|
11
|
+
position: relative;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
flex-shrink: 0;
|
|
14
|
+
width: var(--dc-checkbox-size);
|
|
15
|
+
height: var(--dc-checkbox-size);
|
|
16
|
+
line-height: 0;
|
|
17
|
+
text-align: left;
|
|
18
|
+
color-scheme: light;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dc-checkbox__input {
|
|
22
|
+
position: absolute;
|
|
23
|
+
width: 1px;
|
|
24
|
+
height: 1px;
|
|
25
|
+
padding: 0;
|
|
26
|
+
margin: -1px;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
clip: rect(0, 0, 0, 0);
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
border: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dc-checkbox__check {
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
display: inline-block;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
vertical-align: middle;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
background: var(--dc-checkbox-bg);
|
|
44
|
+
border: 1px solid var(--dc-checkbox-border-color);
|
|
45
|
+
border-radius: var(--dc-checkbox-radius);
|
|
46
|
+
transition: opacity 0.2s;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dc-checkbox__icon {
|
|
50
|
+
display: none;
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
color: var(--dc-checkbox-icon-color);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dc-checkbox__input:checked + .dc-checkbox__check {
|
|
57
|
+
background: var(--dc-checkbox-bg-checked);
|
|
58
|
+
border-color: var(--dc-checkbox-border-color-checked);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.dc-checkbox__input:checked + .dc-checkbox__check .dc-checkbox__icon {
|
|
62
|
+
display: initial;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.dc-checkbox__input:disabled + .dc-checkbox__check {
|
|
66
|
+
cursor: default;
|
|
67
|
+
opacity: var(--dc-disabled-state-opacity);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dc-checkbox__input:focus {
|
|
71
|
+
outline: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.dc-checkbox__input:focus + .dc-checkbox__check::after {
|
|
75
|
+
position: absolute;
|
|
76
|
+
inset: -3px;
|
|
77
|
+
pointer-events: none;
|
|
78
|
+
content: "";
|
|
79
|
+
border-radius: calc(3px + var(--dc-checkbox-radius));
|
|
80
|
+
box-shadow: 0 0 0 3px var(--dc-checkbox-focus-ring-color);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.dc-checkbox__input:focus:not(:focus-visible) + .dc-checkbox__check::after {
|
|
84
|
+
content: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.dark .dc-checkbox,
|
|
88
|
+
.dark.dc-checkbox {
|
|
89
|
+
color-scheme: dark;
|
|
90
|
+
}
|
|
@@ -5,7 +5,9 @@ export const Checkbox = forwardRef(function Checkbox({ hasMixedState = false, st
|
|
|
5
5
|
return (_jsxs("label", { style: style, className: classNames('dc-checkbox', className), children: [_jsx("input", { ...props, ref: ref, type: "checkbox", className: "dc-checkbox__input", onChange: (event) => {
|
|
6
6
|
onChange?.(event);
|
|
7
7
|
onToggle?.(event.target.checked);
|
|
8
|
-
} }), _jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState
|
|
8
|
+
} }), _jsx("span", { className: "dc-checkbox__check", "data-testid": "checkbox-check", "aria-hidden": true, children: hasMixedState
|
|
9
|
+
? (_jsx(DashIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-dash-icon" }))
|
|
10
|
+
: (_jsx(CheckIcon, { className: "dc-checkbox__icon", "data-testid": "checkbox-check-icon" })) })] }));
|
|
9
11
|
});
|
|
10
12
|
function CheckIcon(props) {
|
|
11
13
|
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: 20, height: 20, ...props, children: _jsx("path", { d: "M5 10.4444L9 14L15 6", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.dc-color-picker {
|
|
2
|
+
--dc-color-picker-btn-size: 24px;
|
|
3
|
+
--dc-color-picker-btn-color: var(--dc-control-on-primary-color);
|
|
4
|
+
--dc-color-picker-btn-check-color: white;
|
|
5
|
+
--dc-color-picker-btn-inner-border-color: rgb(var(--dc-black-rgb) / 5%);
|
|
6
|
+
--dc-color-picker-btn-focus-ring-color: var(--dc-focus-ring-color);
|
|
7
|
+
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
flex-wrap: wrap;
|
|
10
|
+
gap: 12px;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: flex-start;
|
|
13
|
+
padding: 0;
|
|
14
|
+
margin: 0;
|
|
15
|
+
color-scheme: light;
|
|
16
|
+
border: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.dc-color-picker_disabled {
|
|
20
|
+
opacity: var(--dc-disabled-state-opacity);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.dc-color-picker__btn {
|
|
24
|
+
position: relative;
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
flex: none;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
width: var(--dc-color-picker-btn-size);
|
|
30
|
+
height: var(--dc-color-picker-btn-size);
|
|
31
|
+
font-size: 0;
|
|
32
|
+
color: transparent;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
background: var(--dc-color-picker-btn-color);
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
box-shadow: inset 0 0 0 1px var(--dc-color-picker-btn-inner-border-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.dc-color-picker_disabled .dc-color-picker__btn {
|
|
40
|
+
cursor: default;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dc-color-picker__btn > input {
|
|
44
|
+
position: absolute;
|
|
45
|
+
width: 1px;
|
|
46
|
+
height: 1px;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
clip: rect(0 0 0 0);
|
|
49
|
+
-webkit-clip-path: inset(50%);
|
|
50
|
+
clip-path: inset(50%);
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.dc-color-picker__btn > input + .dc-color-picker__btn-check {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.dc-color-picker__btn > input:checked + .dc-color-picker__btn-check {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 50%;
|
|
61
|
+
left: 50%;
|
|
62
|
+
display: inline-block;
|
|
63
|
+
width: 38%;
|
|
64
|
+
height: 38%;
|
|
65
|
+
background: var(--dc-color-picker-btn-check-color);
|
|
66
|
+
border-radius: 50%;
|
|
67
|
+
box-shadow: 0 1px 2px 0 rgb(var(--dc-black-rgb) / 5%);
|
|
68
|
+
transform: translate(-50%, -50%);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dc-color-picker__btn:focus-within::before {
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: -2px;
|
|
74
|
+
z-index: -1;
|
|
75
|
+
display: inline-block;
|
|
76
|
+
content: "";
|
|
77
|
+
border-radius: 50%;
|
|
78
|
+
box-shadow: 0 0 0 3px var(--dc-color-picker-btn-focus-ring-color);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.dark .dc-color-picker,
|
|
82
|
+
.dark.dc-color-picker {
|
|
83
|
+
--dc-color-picker-btn-inner-border-color: rgb(255 255 255 / 10%);
|
|
84
|
+
|
|
85
|
+
color-scheme: dark;
|
|
86
|
+
}
|
|
@@ -24,8 +24,8 @@ export function CalendarGrid({ focusDay, minDate, maxDate, locale, weekStartsOn,
|
|
|
24
24
|
const inDisplayedMonth = date >= monthStart && date <= monthEnd;
|
|
25
25
|
let calendarDay = null;
|
|
26
26
|
if (inDisplayedMonth) {
|
|
27
|
-
calendarDay = _jsx(CalendarDay, { ...getDayProps?.(date), date: date, dateISO: dateISO, locale: locale, isToday: isSameDay(date, today), isWeekend: isWeekend(date), isFocusable: isSameDay(date, focusDay), isDisabled: (minDate != null && date < minDate)
|
|
28
|
-
(maxDate != null && date > maxDate), onClick: handleSelectDay(date), onMouseEnter: handleHoverDay(date) });
|
|
27
|
+
calendarDay = (_jsx(CalendarDay, { ...getDayProps?.(date), date: date, dateISO: dateISO, locale: locale, isToday: isSameDay(date, today), isWeekend: isWeekend(date), isFocusable: isSameDay(date, focusDay), isDisabled: (minDate != null && date < minDate)
|
|
28
|
+
|| (maxDate != null && date > maxDate), onClick: handleSelectDay(date), onMouseEnter: handleHoverDay(date) }));
|
|
29
29
|
}
|
|
30
30
|
columns.push(_jsx("td", { role: "gridcell", children: calendarDay }, dateISO));
|
|
31
31
|
date = addDays(date, 1);
|
|
@@ -64,9 +64,9 @@ export function isValidDateISO(value) {
|
|
|
64
64
|
return DATE_ISO_REGEX.test(value);
|
|
65
65
|
}
|
|
66
66
|
export function isSameDay(a, b) {
|
|
67
|
-
return (a.getFullYear() === b.getFullYear()
|
|
68
|
-
a.getMonth() === b.getMonth()
|
|
69
|
-
a.getDate() === b.getDate());
|
|
67
|
+
return (a.getFullYear() === b.getFullYear()
|
|
68
|
+
&& a.getMonth() === b.getMonth()
|
|
69
|
+
&& a.getDate() === b.getDate());
|
|
70
70
|
}
|
|
71
71
|
export function isWeekend(date) {
|
|
72
72
|
return date.getDay() === 6 || date.getDay() === 0;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
.dc-datepicker {
|
|
2
|
+
--dc-columnheader-text-color: var(--dc-control-secondary-text-color);
|
|
3
|
+
|
|
4
|
+
/* Day properties */
|
|
5
|
+
--dc-day-font-size: 14px;
|
|
6
|
+
--dc-day-text-color: var(--dc-control-primary-text-color);
|
|
7
|
+
--dc-day-text-color-today: var(--dc-control-primary-color);
|
|
8
|
+
--dc-day-text-color-weekend: var(--dc-control-secondary-text-color);
|
|
9
|
+
--dc-day-text-color-selected: var(--dc-control-on-primary-color);
|
|
10
|
+
--dc-day-size: 32px;
|
|
11
|
+
--dc-day-max-width: 40px;
|
|
12
|
+
--dc-day-radius: 16px;
|
|
13
|
+
--dc-day-border-color: transparent;
|
|
14
|
+
--dc-day-border-color-hover: var(--dc-control-primary-color);
|
|
15
|
+
--dc-day-bg-selected: var(--dc-control-primary-color);
|
|
16
|
+
--dc-day-bg-selected-hover: var(--dc-control-primary-color-hover);
|
|
17
|
+
--dc-day-bg-range: var(--dc-control-secondary-color);
|
|
18
|
+
--dc-day-focus-ring-color: var(--dc-control-primary-color);
|
|
19
|
+
|
|
20
|
+
display: inline-block;
|
|
21
|
+
color-scheme: light;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Calendar controls */
|
|
25
|
+
|
|
26
|
+
.dc-calendar-next-month,
|
|
27
|
+
.dc-calendar-prev-month {
|
|
28
|
+
--dc-button-height: 28px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dc-calendar-month-select {
|
|
32
|
+
--dc-select-height: 28px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.dc-calendar-year-input {
|
|
36
|
+
--dc-input-height: 28px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Calendar day */
|
|
40
|
+
|
|
41
|
+
.dc-calendar-day {
|
|
42
|
+
width: 100%;
|
|
43
|
+
padding: 0;
|
|
44
|
+
margin: 0;
|
|
45
|
+
font-family: var(--dc-primary-font);
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
font-weight: 500;
|
|
48
|
+
color: var(--dc-day-text-color);
|
|
49
|
+
-webkit-appearance: none;
|
|
50
|
+
-moz-appearance: none;
|
|
51
|
+
appearance: none;
|
|
52
|
+
background: none;
|
|
53
|
+
border: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dc-calendar-day__body {
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
width: var(--dc-day-size);
|
|
62
|
+
height: var(--dc-day-size);
|
|
63
|
+
border-radius: var(--dc-day-radius);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.dc-calendar-day_in-range {
|
|
67
|
+
position: relative;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dc-calendar-day_in-range::before {
|
|
71
|
+
position: absolute;
|
|
72
|
+
inset: 0;
|
|
73
|
+
z-index: -1;
|
|
74
|
+
content: "";
|
|
75
|
+
background: var(--dc-day-bg-range);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.dc-calendar-day_range-start::before {
|
|
79
|
+
left: calc(50% - var(--dc-day-size) / 2);
|
|
80
|
+
border-top-left-radius: var(--dc-day-radius);
|
|
81
|
+
border-bottom-left-radius: var(--dc-day-radius);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.dc-calendar-day_range-end::before {
|
|
85
|
+
right: calc(50% - var(--dc-day-size) / 2);
|
|
86
|
+
border-top-right-radius: var(--dc-day-radius);
|
|
87
|
+
border-bottom-right-radius: var(--dc-day-radius);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.dc-calendar-day_weekend > .dc-calendar-day__body {
|
|
91
|
+
color: var(--dc-day-text-color-weekend);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.dc-calendar-day_today > .dc-calendar-day__body {
|
|
95
|
+
color: var(--dc-day-text-color-today);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.dc-calendar-day_selected > .dc-calendar-day__body {
|
|
99
|
+
color: var(--dc-day-text-color-selected);
|
|
100
|
+
background: var(--dc-day-bg-selected);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.dc-calendar-day:hover {
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.dc-calendar-day:hover > .dc-calendar-day__body {
|
|
108
|
+
box-shadow: inset 0 0 0 2px var(--dc-day-border-color-hover);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.dc-calendar-day_selected:hover > .dc-calendar-day__body {
|
|
112
|
+
background: var(--dc-day-bg-selected-hover);
|
|
113
|
+
box-shadow: none;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.dc-calendar-day:disabled {
|
|
117
|
+
cursor: default;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.dc-calendar-day:disabled > .dc-calendar-day__body {
|
|
121
|
+
box-shadow: none;
|
|
122
|
+
opacity: var(--dc-disabled-state-opacity);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.dc-calendar-day:focus {
|
|
126
|
+
outline: none;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.dc-calendar-day:focus > .dc-calendar-day__body {
|
|
130
|
+
box-shadow: inset 0 0 0 2px var(--dc-day-border-color-hover);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.dc-calendar-day_selected:focus > .dc-calendar-day__body {
|
|
134
|
+
position: relative;
|
|
135
|
+
box-shadow: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.dc-calendar-day_selected:focus > .dc-calendar-day__body::after {
|
|
139
|
+
position: absolute;
|
|
140
|
+
inset: -2px;
|
|
141
|
+
content: "";
|
|
142
|
+
border-radius: 50%;
|
|
143
|
+
box-shadow: 0 0 0 2px var(--dc-day-focus-ring-color);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Calendar styles */
|
|
147
|
+
|
|
148
|
+
.dc-calendar {
|
|
149
|
+
display: inline-flex;
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
width: calc(7 * var(--dc-day-max-width));
|
|
152
|
+
min-width: calc(7 * var(--dc-day-size));
|
|
153
|
+
max-width: 100%;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.dc-calendar__header {
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: space-between;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.dc-calendar__header > * {
|
|
163
|
+
margin-right: 2px;
|
|
164
|
+
margin-left: 2px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.dc-calendar__header > *:first-child {
|
|
168
|
+
margin-right: auto;
|
|
169
|
+
margin-left: 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.dc-calendar__header > *:last-child {
|
|
173
|
+
margin-right: 0;
|
|
174
|
+
margin-left: auto;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.dc-calendar__grid {
|
|
178
|
+
margin-top: 16px;
|
|
179
|
+
border-spacing: 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.dc-calendar__grid th,
|
|
183
|
+
.dc-calendar__grid td {
|
|
184
|
+
padding: 0;
|
|
185
|
+
text-align: center;
|
|
186
|
+
vertical-align: middle;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.dc-calendar__grid th {
|
|
190
|
+
padding-bottom: 4px;
|
|
191
|
+
font-size: 14px;
|
|
192
|
+
font-weight: 400;
|
|
193
|
+
color: var(--dc-columnheader-text-color);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.dc-calendar__grid td {
|
|
197
|
+
padding-top: 4px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.dark .dc-datepicker,
|
|
201
|
+
.dark.dc-datepicker {
|
|
202
|
+
color-scheme: dark;
|
|
203
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isSameDay, toDateISO } from './date-helpers.js';
|
|
2
2
|
export class DateRange {
|
|
3
|
+
start;
|
|
4
|
+
end;
|
|
3
5
|
constructor(start, end) {
|
|
4
6
|
if (start > end) {
|
|
5
7
|
[start, end] = [end, start];
|
|
@@ -11,8 +13,8 @@ export class DateRange {
|
|
|
11
13
|
return new DateRange(start, end);
|
|
12
14
|
}
|
|
13
15
|
contains(date) {
|
|
14
|
-
return ((isSameDay(date, this.start) || date > this.start)
|
|
15
|
-
(isSameDay(date, this.end) || date < this.end));
|
|
16
|
+
return ((isSameDay(date, this.start) || date > this.start)
|
|
17
|
+
&& (isSameDay(date, this.end) || date < this.end));
|
|
16
18
|
}
|
|
17
19
|
toDateISORange() {
|
|
18
20
|
return {
|
|
@@ -3,13 +3,13 @@ export function parseMinMaxProps(props) {
|
|
|
3
3
|
const min = props.min;
|
|
4
4
|
const max = props.max;
|
|
5
5
|
const minDate = min
|
|
6
|
-
? parseDateISO(min,
|
|
6
|
+
? parseDateISO(min, 'The \'min\' property must be a date in the ISO format.')
|
|
7
7
|
: null;
|
|
8
8
|
const maxDate = max
|
|
9
|
-
? parseDateISO(max,
|
|
9
|
+
? parseDateISO(max, 'The \'max\' property must be a date in the ISO format.')
|
|
10
10
|
: null;
|
|
11
11
|
if (minDate != null && maxDate != null && minDate >= maxDate) {
|
|
12
|
-
throw new RangeError(
|
|
12
|
+
throw new RangeError('\'min\' property must be less than \'max\' property.');
|
|
13
13
|
}
|
|
14
14
|
return { minDate, maxDate };
|
|
15
15
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
.dc-date-range-picker-popover {
|
|
2
|
+
display: inline-grid;
|
|
3
|
+
grid-template-areas:
|
|
4
|
+
"presets calendar"
|
|
5
|
+
"footer footer";
|
|
6
|
+
grid-template-columns: auto 1fr;
|
|
7
|
+
grid-gap: 20px 24px;
|
|
8
|
+
max-width: none;
|
|
9
|
+
color-scheme: light;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.dc-date-range-picker-popover_compact {
|
|
13
|
+
grid-template-areas:
|
|
14
|
+
"presets"
|
|
15
|
+
"calendar"
|
|
16
|
+
"footer";
|
|
17
|
+
grid-template-columns: 100%;
|
|
18
|
+
max-width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dc-date-range-picker-popover__presets {
|
|
22
|
+
grid-area: presets;
|
|
23
|
+
padding: 0;
|
|
24
|
+
margin: 0;
|
|
25
|
+
list-style: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dc-date-range-picker-popover__presets > * {
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.dc-date-range-picker-popover__presets > * + * {
|
|
33
|
+
margin-top: 8px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.dc-date-range-picker-popover__calendar {
|
|
37
|
+
grid-area: calendar;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.dc-date-range-picker-popover__footer {
|
|
41
|
+
display: grid;
|
|
42
|
+
grid-area: footer;
|
|
43
|
+
grid-template-areas: "content cancel confirm";
|
|
44
|
+
grid-template-columns: 1fr auto auto;
|
|
45
|
+
grid-gap: 8px;
|
|
46
|
+
align-items: center;
|
|
47
|
+
font: var(--dc-text-xs);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.dc-date-range-picker-popover__footer-content {
|
|
51
|
+
grid-area: content;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.dc-date-range-picker-popover__footer-cancel {
|
|
55
|
+
grid-area: cancel;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.dc-date-range-picker-popover__footer-confirm {
|
|
59
|
+
grid-area: confirm;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.dc-date-range-picker-popover_compact .dc-date-range-picker-popover__footer {
|
|
63
|
+
grid-template-areas:
|
|
64
|
+
"content content"
|
|
65
|
+
"cancel confirm";
|
|
66
|
+
grid-template-columns: 1fr 1fr;
|
|
67
|
+
text-align: right;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dark .dc-date-range-picker-popover,
|
|
71
|
+
.dark.dc-date-range-picker-popover {
|
|
72
|
+
color-scheme: dark;
|
|
73
|
+
}
|
|
@@ -4,8 +4,8 @@ export function findSelectedOption(selection, options) {
|
|
|
4
4
|
}
|
|
5
5
|
const selectedOption = options.find((option) => {
|
|
6
6
|
const range = option.range;
|
|
7
|
-
return (range.start === selection.range.start
|
|
8
|
-
range.end === selection.range.end);
|
|
7
|
+
return (range.start === selection.range.start
|
|
8
|
+
&& range.end === selection.range.end);
|
|
9
9
|
});
|
|
10
10
|
return selectedOption || null;
|
|
11
11
|
}
|