@dvrd/dvr-controls 1.0.76 → 1.0.77
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/package.json
CHANGED
|
@@ -41,6 +41,7 @@ interface Props {
|
|
|
41
41
|
id?: string;
|
|
42
42
|
max?: IDate | string;
|
|
43
43
|
min?: IDate | string;
|
|
44
|
+
pickersOnly?: boolean;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export type DVRDDatePickerRef = { onOpen: VoidFunction; onClose: VoidFunction; }
|
|
@@ -48,7 +49,7 @@ export type DVRDDatePickerRef = { onOpen: VoidFunction; onClose: VoidFunction; }
|
|
|
48
49
|
function DvrdDatePicker(props: Props, ref: ForwardedRef<DVRDDatePickerRef>) {
|
|
49
50
|
const {
|
|
50
51
|
onChange, className, closeOnChange, error, label, value, placeholder, disabled, alwaysShowArrows,
|
|
51
|
-
useMobileNative, max, min, timeMode
|
|
52
|
+
useMobileNative, max, min, timeMode, pickersOnly
|
|
52
53
|
} = props;
|
|
53
54
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
54
55
|
const [timePickerOpen, setTimePickerOpen] = useState(false);
|
|
@@ -107,19 +108,21 @@ function DvrdDatePicker(props: Props, ref: ForwardedRef<DVRDDatePickerRef>) {
|
|
|
107
108
|
|
|
108
109
|
return (
|
|
109
110
|
<div className={classNames('dvrd-date-picker', className, error && 'error', disabled && 'disabled')}>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
{!pickersOnly && <>
|
|
112
|
+
<label className='field-label'>{label}</label>
|
|
113
|
+
{renderMobilePicker()}
|
|
114
|
+
<div className={classNames('value-container', useMobileNative && 'no-mob')} onClick={onClickContainer}>
|
|
115
|
+
<label className={classNames('value', !value && 'placeholder')}>{value?.format(dateFormat) ??
|
|
116
|
+
placeholder ?? ''}</label>
|
|
117
|
+
<AwesomeIcon name='calendar-alt' className='calendar-icon'/>
|
|
118
|
+
</div>
|
|
119
|
+
</>}
|
|
117
120
|
<DatePicker onClose={onClosePicker} onChange={onChangePicker} open={pickerOpen} value={value}
|
|
118
121
|
alwaysShowArrows={alwaysShowArrows} max={max} min={min}/>
|
|
119
122
|
{!!timeMode &&
|
|
120
123
|
<TimePicker onChange={onChangeTimePicker} onClose={onClosePicker} value={value}
|
|
121
124
|
open={timePickerOpen} timeMode={timeMode} closeOnChange={closeOnChange}/>}
|
|
122
|
-
<label className='error-label'>{error}</label>
|
|
125
|
+
{!pickersOnly && <label className='error-label'>{error}</label>}
|
|
123
126
|
</div>
|
|
124
127
|
)
|
|
125
128
|
}
|
|
@@ -361,7 +364,8 @@ function DatePicker(props: DatePickerProps) {
|
|
|
361
364
|
}
|
|
362
365
|
}, [open]);
|
|
363
366
|
|
|
364
|
-
function renderDay(day: number, index: number, onClick: MouseEventHandler, className?: string,
|
|
367
|
+
function renderDay(day: number, index: number, onClick: MouseEventHandler, className?: string,
|
|
368
|
+
type?: 'prev' | 'next') {
|
|
365
369
|
let pickValue = pickerValue.clone();
|
|
366
370
|
if (type === 'prev')
|
|
367
371
|
pickValue = pickValue.subtract(1, 'month');
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
.switcher {
|
|
67
67
|
display: grid;
|
|
68
68
|
justify-content: center;
|
|
69
|
-
background-color:
|
|
70
|
-
color:
|
|
69
|
+
background-color: var(--base-color);
|
|
70
|
+
color: var(--contrast-color);
|
|
71
71
|
align-items: center;
|
|
72
72
|
grid-column-gap: .5rem;
|
|
73
73
|
|
|
@@ -247,12 +247,12 @@
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
&.selected {
|
|
250
|
-
background-color:
|
|
251
|
-
color:
|
|
250
|
+
background-color: var(--base-color);
|
|
251
|
+
color: var(--contrast-color);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
&:hover {
|
|
255
|
-
background-color: rgba(
|
|
255
|
+
background-color: rgba(var(--base-color-rgb), .2);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
&.disabled {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import React, {Context, PropsWithChildren, useEffect} from 'react';
|
|
6
6
|
import {ControlVariant} from "./interfaces";
|
|
7
7
|
import defer from 'lodash.defer';
|
|
8
|
+
import {convertColor, hexToRgb} from "./colorUtil";
|
|
8
9
|
|
|
9
10
|
// noinspection JSUnusedGlobalSymbols
|
|
10
11
|
export interface ThemeContextShape {
|
|
@@ -34,8 +35,12 @@ export default function ThemeContextProvider(props: PropsWithChildren<ProviderPr
|
|
|
34
35
|
useEffect(() => {
|
|
35
36
|
defer(() => {
|
|
36
37
|
const root = document.documentElement;
|
|
38
|
+
const baseRgb = hexToRgb(convertColor(theme.baseColor));
|
|
39
|
+
const contrastRgb = hexToRgb(convertColor(theme.contrastColor));
|
|
37
40
|
root.style.setProperty('--base-color', theme.baseColor);
|
|
41
|
+
root.style.setProperty('--base-color-rgb', `${baseRgb.r}, ${baseRgb.g}, ${baseRgb.b}`);
|
|
38
42
|
root.style.setProperty('--contrast-color', theme.contrastColor);
|
|
43
|
+
root.style.setProperty('--contrast-color-rgb', `${contrastRgb.r}, ${contrastRgb.g}, ${contrastRgb.b}`);
|
|
39
44
|
});
|
|
40
45
|
}, [theme]);
|
|
41
46
|
|