@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.
Files changed (34) hide show
  1. package/dist/bundle.js +251 -302
  2. package/esm/core/BoxedTable/TableRow/index.js +10 -9
  3. package/esm/core/BoxedTable/TableRow/styles.js +10 -11
  4. package/esm/core/BoxedTable/styles.js +9 -9
  5. package/esm/core/Calendar/index.js +18 -19
  6. package/esm/core/Calendar/styles.js +15 -16
  7. package/esm/core/Datepicker/index.js +114 -48
  8. package/esm/core/Datepicker/styles.js +12 -12
  9. package/esm/core/DatepickerRange/index.js +66 -108
  10. package/esm/core/NoticeCard/privateComponents/NoticeMetaInfo/index.js +1 -1
  11. package/lib/core/BoxedTable/TableRow/index.d.ts.map +1 -1
  12. package/lib/core/BoxedTable/TableRow/index.js +10 -9
  13. package/lib/core/BoxedTable/TableRow/styles.d.ts +6 -36
  14. package/lib/core/BoxedTable/TableRow/styles.d.ts.map +1 -1
  15. package/lib/core/BoxedTable/TableRow/styles.js +10 -11
  16. package/lib/core/BoxedTable/styles.js +9 -9
  17. package/lib/core/Calendar/index.d.ts.map +1 -1
  18. package/lib/core/Calendar/index.js +18 -19
  19. package/lib/core/Calendar/styles.d.ts +10 -2
  20. package/lib/core/Calendar/styles.d.ts.map +1 -1
  21. package/lib/core/Calendar/styles.js +15 -16
  22. package/lib/core/Datepicker/index.d.ts +1 -1
  23. package/lib/core/Datepicker/index.d.ts.map +1 -1
  24. package/lib/core/Datepicker/index.js +114 -48
  25. package/lib/core/Datepicker/styles.d.ts.map +1 -1
  26. package/lib/core/Datepicker/styles.js +12 -12
  27. package/lib/core/DatepickerRange/index.js +66 -108
  28. package/lib/core/NoticeCard/privateComponents/NoticeMetaInfo/index.js +1 -1
  29. package/lib/hooks/useScreenOrientation.d.ts +1 -1
  30. package/package.json +4 -2
  31. package/esm/core/DatepickerRange/YearMonthForm.js +0 -56
  32. package/lib/core/DatepickerRange/YearMonthForm.d.ts +0 -10
  33. package/lib/core/DatepickerRange/YearMonthForm.d.ts.map +0 -1
  34. 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 DayPickerInput from 'react-day-picker/DayPickerInput';
4
- import { useIsMobile } from '../..';
5
- import IconErrorOutline from '../../icons/General/IconErrorOutline';
6
- import { formatDate, MONTHS, parseDate, WEEKDAYS_LONG, WEEKDAYS_SHORT } from '../../utils/dates';
7
- import { Input, Wrapper, styles, Label, ErrorMessage, DividerLine } from './styles';
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 ? new Date(maxDate) : new Date(currentYear + 5, 11, 31);
32
- const [dates, setDates] = useState({
33
- to: undefined,
34
- from: undefined
35
- });
36
- useEffect(() => {
37
- if (isMobile && fromPickerRef) fromPickerRef.current.input.readOnly = true;
38
- }, [isMobile, fromPickerRef]);
39
- useEffect(() => {
40
- if (isMobile && toPickerRef) toPickerRef.current.input.readOnly = true;
41
- }, [isMobile, toPickerRef]);
42
- const modifiers = {
43
- start: dates.from,
44
- end: dates.to
45
- };
46
- const pickerPropsDefault = {
47
- locale: 'no',
48
- months: MONTHS,
49
- weekdaysLong: WEEKDAYS_LONG,
50
- weekdaysShort: WEEKDAYS_SHORT,
51
- firstDayOfWeek: 1,
52
- // custom
53
- modifiers,
54
- numberOfMonths: 2,
55
- selectedDays: [dates.from, {
56
- from: dates.from,
57
- to: dates.to
58
- }]
59
- };
60
- const toDayProps = { ...pickerPropsDefault,
61
- disabledDays: {
62
- before: dates.from
63
- },
64
- month: dates.from,
65
- fromMonth: dates.from
66
- };
67
- const fromDayProps = { ...pickerPropsDefault,
68
- disabledDays: {
69
- after: dates.to
70
- },
71
- toMonth: dates.to,
72
- onDayClick: () => toPickerRef.current?.getInput().focus()
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: [_jsxs(Input, {
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: () => "portrait-primary" | "landscape-primary" | "landscape-secondary" | "portrait-secondary";
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.24",
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": "^7.4.8",
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,10 +0,0 @@
1
- import React from 'react';
2
- interface IProps {
3
- date: Date;
4
- onChange: (e: Date) => void;
5
- fromDate: Date;
6
- toDate: Date;
7
- }
8
- declare const YearMonthForm: React.FC<IProps>;
9
- export default YearMonthForm;
10
- //# sourceMappingURL=YearMonthForm.d.ts.map
@@ -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;