@bbl-digital/snorre 2.4.24 → 2.4.28
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +251 -302
- package/esm/core/BoxedTable/TableRow/index.js +10 -9
- package/esm/core/BoxedTable/TableRow/styles.js +10 -11
- package/esm/core/BoxedTable/styles.js +9 -9
- package/esm/core/Calendar/index.js +18 -19
- package/esm/core/Calendar/styles.js +15 -16
- package/esm/core/Datepicker/index.js +114 -48
- package/esm/core/Datepicker/styles.js +12 -12
- package/esm/core/DatepickerRange/index.js +66 -108
- package/esm/core/NoticeCard/privateComponents/NoticeMetaInfo/index.js +1 -1
- package/lib/core/BoxedTable/TableRow/index.d.ts.map +1 -1
- package/lib/core/BoxedTable/TableRow/index.js +10 -9
- package/lib/core/BoxedTable/TableRow/styles.d.ts +6 -36
- package/lib/core/BoxedTable/TableRow/styles.d.ts.map +1 -1
- package/lib/core/BoxedTable/TableRow/styles.js +10 -11
- package/lib/core/BoxedTable/styles.js +9 -9
- package/lib/core/Calendar/index.d.ts.map +1 -1
- package/lib/core/Calendar/index.js +18 -19
- package/lib/core/Calendar/styles.d.ts +10 -2
- package/lib/core/Calendar/styles.d.ts.map +1 -1
- package/lib/core/Calendar/styles.js +15 -16
- package/lib/core/Datepicker/index.d.ts +1 -1
- package/lib/core/Datepicker/index.d.ts.map +1 -1
- package/lib/core/Datepicker/index.js +114 -48
- package/lib/core/Datepicker/styles.d.ts.map +1 -1
- package/lib/core/Datepicker/styles.js +12 -12
- package/lib/core/DatepickerRange/index.js +66 -108
- package/lib/core/NoticeCard/privateComponents/NoticeMetaInfo/index.js +1 -1
- package/lib/hooks/useScreenOrientation.d.ts +1 -1
- package/package.json +4 -2
- package/esm/core/DatepickerRange/YearMonthForm.js +0 -56
- package/lib/core/DatepickerRange/YearMonthForm.d.ts +0 -10
- package/lib/core/DatepickerRange/YearMonthForm.d.ts.map +0 -1
- package/lib/core/DatepickerRange/YearMonthForm.js +0 -56
@@ -1,15 +1,23 @@
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
2
|
-
import { useRef, useState, useEffect } from 'react'
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
|
2
|
+
// import { useRef, useState, useEffect } from 'react'
|
3
|
+
// import { Modifier, Modifiers } from 'react-day-picker'
|
4
|
+
// import DayPickerInput from 'react-day-picker/DayPickerInput'
|
5
|
+
// import { useIsMobile } from '../..'
|
6
|
+
import IconErrorOutline from '../../icons/General/IconErrorOutline'; // import {
|
7
|
+
// formatDate,
|
8
|
+
// MONTHS,
|
9
|
+
// parseDate,
|
10
|
+
// WEEKDAYS_LONG,
|
11
|
+
// WEEKDAYS_SHORT,
|
12
|
+
// } from '../../utils/dates'
|
13
|
+
|
14
|
+
import { Input, Wrapper, styles, Label, ErrorMessage // DividerLine,
|
15
|
+
} from './styles';
|
8
16
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
9
17
|
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
10
|
-
const FORMAT = 'dd.MM.yyyy';
|
11
|
-
const PLACEHOLDER = 'dd.mm.åååå';
|
12
18
|
|
19
|
+
// const FORMAT = 'dd.MM.yyyy'
|
20
|
+
// const PLACEHOLDER = 'dd.mm.åååå'
|
13
21
|
const DatePickerRange = ({
|
14
22
|
value,
|
15
23
|
label,
|
@@ -24,117 +32,67 @@ const DatePickerRange = ({
|
|
24
32
|
maxWidth = 550,
|
25
33
|
minWidth = 550
|
26
34
|
}) => {
|
27
|
-
const isMobile = useIsMobile()
|
28
|
-
const fromPickerRef = useRef(null)
|
29
|
-
const toPickerRef = useRef(null)
|
30
|
-
const currentYear = new Date().getFullYear()
|
31
|
-
const maxDateAvailable = maxDate
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}, [isMobile,
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
46
|
-
const
|
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
|
-
const handleChange = key => date => {
|
76
|
-
setDates(prev => ({ ...prev,
|
77
|
-
[key]: date
|
78
|
-
}));
|
79
|
-
onChange({ ...dates,
|
80
|
-
[key]: date
|
81
|
-
});
|
82
|
-
};
|
83
|
-
|
84
|
-
return _jsxs(Wrapper, {
|
35
|
+
// const isMobile = useIsMobile()
|
36
|
+
// const fromPickerRef = useRef<DayPickerInput>(null)
|
37
|
+
// const toPickerRef = useRef<DayPickerInput>(null)
|
38
|
+
// const currentYear = new Date().getFullYear()
|
39
|
+
// const maxDateAvailable = maxDate
|
40
|
+
// ? new Date(maxDate)
|
41
|
+
// : new Date(currentYear + 5, 11, 31)
|
42
|
+
// const [dates, setDates] = useState<{ to?: Date; from?: Date }>({
|
43
|
+
// to: undefined,
|
44
|
+
// from: undefined,
|
45
|
+
// })
|
46
|
+
// useEffect(() => {
|
47
|
+
// if (isMobile && fromPickerRef)
|
48
|
+
// (fromPickerRef as any).current.input.readOnly = true
|
49
|
+
// }, [isMobile, fromPickerRef])
|
50
|
+
// useEffect(() => {
|
51
|
+
// if (isMobile && toPickerRef)
|
52
|
+
// (toPickerRef.current as any).input.readOnly = true
|
53
|
+
// }, [isMobile, toPickerRef])
|
54
|
+
// const modifiers: Partial<Modifiers> = { start: dates.from, end: dates.to }
|
55
|
+
// const pickerPropsDefault = {
|
56
|
+
// locale: 'no',
|
57
|
+
// months: MONTHS,
|
58
|
+
// weekdaysLong: WEEKDAYS_LONG,
|
59
|
+
// weekdaysShort: WEEKDAYS_SHORT,
|
60
|
+
// firstDayOfWeek: 1,
|
61
|
+
// // custom
|
62
|
+
// modifiers,
|
63
|
+
// numberOfMonths: 2,
|
64
|
+
// selected: [dates.from, { from: dates.from, to: dates.to }],
|
65
|
+
// }
|
66
|
+
// const toDayProps = {
|
67
|
+
// ...pickerPropsDefault,
|
68
|
+
// disabled: { before: dates.from } as Modifier,
|
69
|
+
// month: dates.from,
|
70
|
+
// fromMonth: dates.from,
|
71
|
+
// }
|
72
|
+
// const fromDayProps = {
|
73
|
+
// ...pickerPropsDefault,
|
74
|
+
// disabled: { after: dates.to } as Modifier,
|
75
|
+
// toMonth: dates.to,
|
76
|
+
// onDayClick: () => toPickerRef.current?.getInput().focus(),
|
77
|
+
// }
|
78
|
+
// const handleChange = (key: 'to' | 'from') => (date: Date) => {
|
79
|
+
// setDates((prev) => ({ ...prev, [key]: date }))
|
80
|
+
// onChange({ ...dates, [key]: date })
|
81
|
+
// }
|
82
|
+
return _jsx(Wrapper, {
|
85
83
|
css: () => [styles.wrapper(maxWidth, minWidth), css && css],
|
86
|
-
children:
|
84
|
+
children: _jsxs(Input, {
|
87
85
|
className: "InputFromTo",
|
88
86
|
title: disabled?.from && disabledTitle?.from ? disabledTitle?.from : undefined,
|
89
87
|
css: theme => [styles.default(theme), validation && styles.validation, invalidMessage && styles.invalid(theme)],
|
90
88
|
children: [label?.from && _jsx(Label, {
|
91
89
|
children: label.from
|
92
|
-
}), _jsx(DayPickerInput, {
|
93
|
-
ref: fromPickerRef,
|
94
|
-
keepFocus: false,
|
95
|
-
format: FORMAT,
|
96
|
-
formatDate: formatDate,
|
97
|
-
parseDate: (date, format, locale) => parseDate(date, format, locale, undefined, maxDateAvailable),
|
98
|
-
onDayChange: handleChange('from'),
|
99
|
-
dayPickerProps: fromDayProps,
|
100
|
-
placeholder: PLACEHOLDER,
|
101
|
-
onDayPickerHide: onBlur,
|
102
|
-
value: value?.from,
|
103
|
-
inputProps: {
|
104
|
-
disabled: disabled?.from
|
105
|
-
}
|
106
|
-
}), invalidMessage?.from && _jsx(IconErrorOutline, {
|
107
|
-
size: "16px"
|
108
|
-
}), invalidMessage && _jsx(ErrorMessage, {
|
109
|
-
children: invalidMessage.from
|
110
|
-
})]
|
111
|
-
}), _jsx(DividerLine, {
|
112
|
-
children: "-"
|
113
|
-
}), _jsxs(Input, {
|
114
|
-
className: "InputFromTo-to",
|
115
|
-
css: theme => [styles.default(theme), validation && styles.validation, invalidMessage && styles.invalid(theme)],
|
116
|
-
title: disabled?.to && disabledTitle?.to ? disabledTitle.to : undefined,
|
117
|
-
children: [label?.to && _jsx(Label, {
|
118
|
-
children: label.to
|
119
|
-
}), _jsx(DayPickerInput, {
|
120
|
-
ref: toPickerRef,
|
121
|
-
format: FORMAT,
|
122
|
-
formatDate: formatDate,
|
123
|
-
parseDate: (date, format, locale) => parseDate(date, format, locale, undefined, maxDate),
|
124
|
-
onDayChange: handleChange('to'),
|
125
|
-
dayPickerProps: toDayProps,
|
126
|
-
placeholder: PLACEHOLDER,
|
127
|
-
onDayPickerHide: onBlur,
|
128
|
-
value: value?.to,
|
129
|
-
inputProps: {
|
130
|
-
disabled: disabled?.to
|
131
|
-
}
|
132
90
|
}), invalidMessage?.to && _jsx(IconErrorOutline, {
|
133
91
|
size: "16px"
|
134
92
|
}), invalidMessage && _jsx(ErrorMessage, {
|
135
93
|
children: invalidMessage?.to
|
136
94
|
})]
|
137
|
-
})
|
95
|
+
})
|
138
96
|
});
|
139
97
|
};
|
140
98
|
|
@@ -30,7 +30,7 @@ const NoticeMetaInfo = ({
|
|
30
30
|
semibold: true,
|
31
31
|
size: "14px",
|
32
32
|
primary: true,
|
33
|
-
children: [created && getFormattedDate(created, ddmmyyyy), updated && updated !== created && ` (Oppdatert: ${getFormattedDate(updated, ddmmyyyy)}${updatedBy ? ` av ${updatedBy})` : ''} `]
|
33
|
+
children: [created && getFormattedDate(created, ddmmyyyy), updated && updated !== created && ` (Oppdatert: ${getFormattedDate(updated, ddmmyyyy)}${updatedBy ? ` av ${updatedBy})` : ')'} `]
|
34
34
|
})]
|
35
35
|
}), (hasAttachment || hasEvent) && /*#__PURE__*/_jsxs(Group, {
|
36
36
|
children: [hasAttachment && /*#__PURE__*/_jsx(Div, {
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export declare const useScreenOrientation: () => "
|
1
|
+
export declare const useScreenOrientation: () => "landscape-primary" | "landscape-secondary" | "portrait-primary" | "portrait-secondary";
|
2
2
|
export default useScreenOrientation;
|
3
3
|
//# sourceMappingURL=useScreenOrientation.d.ts.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bbl-digital/snorre",
|
3
|
-
"version": "2.4.
|
3
|
+
"version": "2.4.28",
|
4
4
|
"description": "Design library for BBL Digital",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "./lib/index.js",
|
@@ -20,8 +20,10 @@
|
|
20
20
|
"author": "bbl-digital",
|
21
21
|
"dependencies": {
|
22
22
|
"@tinymce/tinymce-react": "^3.14.0",
|
23
|
+
"date-fns": "^2.28.0",
|
23
24
|
"focus-trap-react": "^9.0.1",
|
24
|
-
"react-day-picker": "^
|
25
|
+
"react-day-picker": "^8.0.7",
|
26
|
+
"react-popper": "^2.3.0",
|
25
27
|
"recharts": "2.1.5"
|
26
28
|
},
|
27
29
|
"peerDependencies": {
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { MONTHS } from '../../utils/dates';
|
3
|
-
import { StyledSelect, Div } from './styles';
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
-
|
7
|
-
const YearMonthForm = ({
|
8
|
-
onChange,
|
9
|
-
date,
|
10
|
-
fromDate,
|
11
|
-
toDate
|
12
|
-
}) => {
|
13
|
-
const months = MONTHS;
|
14
|
-
const years = [];
|
15
|
-
|
16
|
-
for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
|
17
|
-
years.push(i);
|
18
|
-
}
|
19
|
-
|
20
|
-
const changeMonth = e => {
|
21
|
-
let newDate = date;
|
22
|
-
newDate.setMonth(e.target.value);
|
23
|
-
if (newDate > toDate) newDate = toDate;
|
24
|
-
onChange(newDate);
|
25
|
-
};
|
26
|
-
|
27
|
-
const changeYear = e => {
|
28
|
-
let newDate = date;
|
29
|
-
newDate.setFullYear(e.target.value);
|
30
|
-
if (newDate > toDate) newDate = toDate;
|
31
|
-
onChange(newDate);
|
32
|
-
};
|
33
|
-
|
34
|
-
return /*#__PURE__*/_jsxs(Div, {
|
35
|
-
className: "DayPicker-Caption",
|
36
|
-
children: [/*#__PURE__*/_jsx(StyledSelect, {
|
37
|
-
name: "month",
|
38
|
-
onChange: changeMonth,
|
39
|
-
value: date.getMonth(),
|
40
|
-
children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
|
41
|
-
value: i,
|
42
|
-
children: month
|
43
|
-
}, month))
|
44
|
-
}), /*#__PURE__*/_jsx(StyledSelect, {
|
45
|
-
name: "year",
|
46
|
-
onChange: changeYear,
|
47
|
-
value: date.getFullYear(),
|
48
|
-
children: years.map(year => /*#__PURE__*/_jsx("option", {
|
49
|
-
value: year,
|
50
|
-
children: year
|
51
|
-
}, year))
|
52
|
-
})]
|
53
|
-
});
|
54
|
-
};
|
55
|
-
|
56
|
-
export default YearMonthForm;
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"YearMonthForm.d.ts","sourceRoot":"","sources":["../../../src/packages/core/DatepickerRange/YearMonthForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,UAAU,MAAM;IACd,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAA;IAC3B,QAAQ,EAAE,IAAI,CAAA;IACd,MAAM,EAAE,IAAI,CAAA;CACb;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAmDnC,CAAA;AAED,eAAe,aAAa,CAAA"}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { MONTHS } from '../../utils/dates';
|
3
|
-
import { StyledSelect, Div } from './styles';
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
-
|
7
|
-
const YearMonthForm = ({
|
8
|
-
onChange,
|
9
|
-
date,
|
10
|
-
fromDate,
|
11
|
-
toDate
|
12
|
-
}) => {
|
13
|
-
const months = MONTHS;
|
14
|
-
const years = [];
|
15
|
-
|
16
|
-
for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
|
17
|
-
years.push(i);
|
18
|
-
}
|
19
|
-
|
20
|
-
const changeMonth = e => {
|
21
|
-
let newDate = date;
|
22
|
-
newDate.setMonth(e.target.value);
|
23
|
-
if (newDate > toDate) newDate = toDate;
|
24
|
-
onChange(newDate);
|
25
|
-
};
|
26
|
-
|
27
|
-
const changeYear = e => {
|
28
|
-
let newDate = date;
|
29
|
-
newDate.setFullYear(e.target.value);
|
30
|
-
if (newDate > toDate) newDate = toDate;
|
31
|
-
onChange(newDate);
|
32
|
-
};
|
33
|
-
|
34
|
-
return /*#__PURE__*/_jsxs(Div, {
|
35
|
-
className: "DayPicker-Caption",
|
36
|
-
children: [/*#__PURE__*/_jsx(StyledSelect, {
|
37
|
-
name: "month",
|
38
|
-
onChange: changeMonth,
|
39
|
-
value: date.getMonth(),
|
40
|
-
children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
|
41
|
-
value: i,
|
42
|
-
children: month
|
43
|
-
}, month))
|
44
|
-
}), /*#__PURE__*/_jsx(StyledSelect, {
|
45
|
-
name: "year",
|
46
|
-
onChange: changeYear,
|
47
|
-
value: date.getFullYear(),
|
48
|
-
children: years.map(year => /*#__PURE__*/_jsx("option", {
|
49
|
-
value: year,
|
50
|
-
children: year
|
51
|
-
}, year))
|
52
|
-
})]
|
53
|
-
});
|
54
|
-
};
|
55
|
-
|
56
|
-
export default YearMonthForm;
|