@bbl-digital/snorre 3.1.21 → 3.1.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
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,6 +1,6 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import React, { useState } from 'react';
3
- import { styles, ErrorMessage } from './styles';
3
+ import { styles } from './styles';
4
4
  import IconSearch from '../../icons/General/IconSearch';
5
5
  import { useEffect } from 'react';
6
6
  import { useDebounce } from '../utils/debounce';
@@ -62,38 +62,41 @@ const Input = /*#__PURE__*/React.forwardRef(({
62
62
 
63
63
  handleDebounceChange(debouncedValue); // eslint-disable-next-line react-hooks/exhaustive-deps
64
64
  }, [debouncedValue]);
65
- return _jsxs("label", {
66
- css: theme => [styles.default(theme), props.highlight && styles.highligted(height), type === 'search' && styles.searchLabel(theme), props.validation && styles.validation, (props.invalid || props.invalidMessage) && styles.invalid(theme), height && styles.height(height)],
67
- children: [props.label && _jsx("span", {
68
- css: info && styles.pr4,
69
- children: props.label
70
- }), _jsx("input", {
71
- type: type,
72
- ...(type !== 'password' && {
73
- value
74
- }),
75
- placeholder: props.placeholder,
76
- disabled: props.disabled,
77
- autoFocus: props.focus,
78
- onBlur: props.onBlur,
79
- onFocus: props.onFocus,
80
- onChange: onInputChange,
81
- maxLength: maxlength,
82
- ref: ref,
83
- name: props.name,
84
- css: theme => [type === 'text' && styles.text(theme), type === 'search' && styles.search(theme), type === 'password' && styles.password(theme), type === 'number' && styles.number(theme), type === 'file' && styles.file, props.disabled && styles.disabled(theme), props.cardInput && styles.cardInput],
85
- children: React.Children.map(props.children, child => {
86
- if (!child) {
87
- return null;
88
- }
65
+ return _jsxs("div", {
66
+ css: styles.relative,
67
+ children: [_jsxs("label", {
68
+ css: theme => [styles.default(theme), props.highlight && styles.highligted(height), type === 'search' && styles.searchLabel(theme), (props.invalid || props.invalidMessage) && styles.invalid(theme), height && styles.height(height)],
69
+ children: [props.label && _jsx("span", {
70
+ css: info && styles.pr4,
71
+ children: props.label
72
+ }), _jsx("input", {
73
+ type: type,
74
+ ...(type !== 'password' && {
75
+ value
76
+ }),
77
+ placeholder: props.placeholder,
78
+ disabled: props.disabled,
79
+ autoFocus: props.focus,
80
+ onBlur: props.onBlur,
81
+ onFocus: props.onFocus,
82
+ onChange: onInputChange,
83
+ maxLength: maxlength,
84
+ ref: ref,
85
+ name: props.name,
86
+ css: theme => [type === 'text' && styles.text(theme), type === 'search' && styles.search(theme), type === 'password' && styles.password(theme), type === 'number' && styles.number(theme), type === 'file' && styles.file, props.disabled && styles.disabled(theme), props.cardInput && styles.cardInput],
87
+ children: React.Children.map(props.children, child => {
88
+ if (!child) {
89
+ return null;
90
+ }
89
91
 
90
- return child;
91
- })
92
- }), type === 'search' && _jsx(IconSearch, {}), props.invalidMessage && _jsx(IconErrorOutline, {
93
- size: "16px"
94
- }), props.invalidMessage && _jsx("span", {
95
- css: theme => [ErrorMessage(theme)],
96
- children: props.invalidMessage
92
+ return child;
93
+ })
94
+ }), type === 'search' && _jsx(IconSearch, {}), props.invalidMessage && _jsx(IconErrorOutline, {
95
+ size: "16px"
96
+ }), props.invalidMessage && _jsx("span", {
97
+ css: styles.errorMessage,
98
+ children: props.invalidMessage
99
+ })]
97
100
  }), info && _jsx("span", {
98
101
  css: styles.infoButton,
99
102
  children: _jsx(InfoButton, {