@bbl-digital/snorre 3.1.18 → 3.1.20

Sign up to get free protection for your applications and to get access to all the features.
package/dist/bundle.js CHANGED
@@ -24389,7 +24389,7 @@
24389
24389
  const fuzzyOptions = {
24390
24390
  keys: props.fuzzyKeys
24391
24391
  };
24392
- return matchSorter.matchSorter(props.values, search ?? '', fuzzyOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
24392
+ return matchSorter.matchSorter(props.values, search || '', fuzzyOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
24393
24393
  }, [props.values, search]);
24394
24394
  return {
24395
24395
  open,
@@ -24552,7 +24552,7 @@
24552
24552
  children: jsxRuntime$1.jsx(List, {
24553
24553
  children: values.map(item => jsxRuntime$1.jsx(Option, {
24554
24554
  onChange: handleOnItemClick(item),
24555
- children: props.createLabelName?.(item) ?? item[props.labelName || 'label']
24555
+ children: props.createLabelName?.(item) || item[props.labelName || 'label']
24556
24556
  }, item[item.keyName || 'id']))
24557
24557
  })
24558
24558
  })]
@@ -32350,11 +32350,11 @@
32350
32350
  const useAutocomplete = props => {
32351
32351
  const [showValues, setShowValues] = React.useState(!!props.isOpen);
32352
32352
  const [highlightedIndex, setHighlightedIndex] = React.useState(null);
32353
- const [value, setValueChanged] = React.useState(props.value ?? '');
32353
+ const [value, setValueChanged] = React.useState(props.value || '');
32354
32354
  const [inputDirty, setInputDirty] = React.useState(false);
32355
- const debouncedValue = useDebounce(value, props.debounceDelay ?? 0);
32355
+ const debouncedValue = useDebounce(value, props.debounceDelay || 0);
32356
32356
  const [inputValues, setInputValues] = React.useState(props.values);
32357
- const labelKey = props.labelFromValues ?? 'label';
32357
+ const labelKey = props.labelFromValues || 'label';
32358
32358
 
32359
32359
  const handleValueClick = value => {
32360
32360
  props.onSelectItem?.(value);
@@ -32364,7 +32364,7 @@
32364
32364
 
32365
32365
  const clearSelectedItem = () => handleValueClick({
32366
32366
  [labelKey]: '',
32367
- [props.keyFromValues ?? 'key']: ''
32367
+ [props.keyFromValues || 'key']: ''
32368
32368
  });
32369
32369
 
32370
32370
  const onInputChange = e => {
@@ -32412,7 +32412,7 @@
32412
32412
  const fuzzyOptions = {
32413
32413
  keys: [labelKey]
32414
32414
  };
32415
- return matchSorter.matchSorter(props.values, value ?? '', fuzzyOptions);
32415
+ return matchSorter.matchSorter(props.values, value || '', fuzzyOptions);
32416
32416
  }
32417
32417
 
32418
32418
  return props.values;
@@ -32554,7 +32554,7 @@
32554
32554
  }, [props.values]); // Update local value if props.value changes
32555
32555
 
32556
32556
  React.useEffect(() => {
32557
- const value = props.value ?? '';
32557
+ const value = props.value || '';
32558
32558
  setValueChanged(value);
32559
32559
  }, [props.value]);
32560
32560
  React.useEffect(() => {
@@ -6,11 +6,11 @@ import { useDebounce } from '../../utils/debounce';
6
6
  const useAutocomplete = props => {
7
7
  const [showValues, setShowValues] = useState(!!props.isOpen);
8
8
  const [highlightedIndex, setHighlightedIndex] = useState(null);
9
- const [value, setValueChanged] = useState(props.value ?? '');
9
+ const [value, setValueChanged] = useState(props.value || '');
10
10
  const [inputDirty, setInputDirty] = useState(false);
11
- const debouncedValue = useDebounce(value, props.debounceDelay ?? 0);
11
+ const debouncedValue = useDebounce(value, props.debounceDelay || 0);
12
12
  const [inputValues, setInputValues] = useState(props.values);
13
- const labelKey = props.labelFromValues ?? 'label';
13
+ const labelKey = props.labelFromValues || 'label';
14
14
 
15
15
  const handleValueClick = value => {
16
16
  props.onSelectItem?.(value);
@@ -20,7 +20,7 @@ const useAutocomplete = props => {
20
20
 
21
21
  const clearSelectedItem = () => handleValueClick({
22
22
  [labelKey]: '',
23
- [props.keyFromValues ?? 'key']: ''
23
+ [props.keyFromValues || 'key']: ''
24
24
  });
25
25
 
26
26
  const onInputChange = e => {
@@ -68,7 +68,7 @@ const useAutocomplete = props => {
68
68
  const fuzzyOptions = {
69
69
  keys: [labelKey]
70
70
  };
71
- return matchSorter(props.values, value ?? '', fuzzyOptions);
71
+ return matchSorter(props.values, value || '', fuzzyOptions);
72
72
  }
73
73
 
74
74
  return props.values;
@@ -213,7 +213,7 @@ const useAutocomplete = props => {
213
213
  }, [props.values]); // Update local value if props.value changes
214
214
 
215
215
  useEffect(() => {
216
- const value = props.value ?? '';
216
+ const value = props.value || '';
217
217
  setValueChanged(value);
218
218
  }, [props.value]);
219
219
  useEffect(() => {
@@ -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;
@@ -8,7 +8,7 @@ const useSelectSearch = props => {
8
8
  const fuzzyOptions = {
9
9
  keys: props.fuzzyKeys
10
10
  };
11
- return matchSorter(props.values, search ?? '', fuzzyOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
11
+ return matchSorter(props.values, search || '', fuzzyOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
12
12
  }, [props.values, search]);
13
13
  return {
14
14
  open,
@@ -92,7 +92,7 @@ const SelectSearch = props => {
92
92
  children: _jsx(List, {
93
93
  children: values.map(item => _jsx(Option, {
94
94
  onChange: handleOnItemClick(item),
95
- children: props.createLabelName?.(item) ?? item[props.labelName || 'label']
95
+ children: props.createLabelName?.(item) || item[props.labelName || 'label']
96
96
  }, item[item.keyName || 'id']))
97
97
  })
98
98
  })]
@@ -6,11 +6,11 @@ import { useDebounce } from '../../utils/debounce';
6
6
  const useAutocomplete = props => {
7
7
  const [showValues, setShowValues] = useState(!!props.isOpen);
8
8
  const [highlightedIndex, setHighlightedIndex] = useState(null);
9
- const [value, setValueChanged] = useState(props.value ?? '');
9
+ const [value, setValueChanged] = useState(props.value || '');
10
10
  const [inputDirty, setInputDirty] = useState(false);
11
- const debouncedValue = useDebounce(value, props.debounceDelay ?? 0);
11
+ const debouncedValue = useDebounce(value, props.debounceDelay || 0);
12
12
  const [inputValues, setInputValues] = useState(props.values);
13
- const labelKey = props.labelFromValues ?? 'label';
13
+ const labelKey = props.labelFromValues || 'label';
14
14
 
15
15
  const handleValueClick = value => {
16
16
  props.onSelectItem?.(value);
@@ -20,7 +20,7 @@ const useAutocomplete = props => {
20
20
 
21
21
  const clearSelectedItem = () => handleValueClick({
22
22
  [labelKey]: '',
23
- [props.keyFromValues ?? 'key']: ''
23
+ [props.keyFromValues || 'key']: ''
24
24
  });
25
25
 
26
26
  const onInputChange = e => {
@@ -68,7 +68,7 @@ const useAutocomplete = props => {
68
68
  const fuzzyOptions = {
69
69
  keys: [labelKey]
70
70
  };
71
- return matchSorter(props.values, value ?? '', fuzzyOptions);
71
+ return matchSorter(props.values, value || '', fuzzyOptions);
72
72
  }
73
73
 
74
74
  return props.values;
@@ -213,7 +213,7 @@ const useAutocomplete = props => {
213
213
  }, [props.values]); // Update local value if props.value changes
214
214
 
215
215
  useEffect(() => {
216
- const value = props.value ?? '';
216
+ const value = props.value || '';
217
217
  setValueChanged(value);
218
218
  }, [props.value]);
219
219
  useEffect(() => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -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;
@@ -8,7 +8,7 @@ const useSelectSearch = props => {
8
8
  const fuzzyOptions = {
9
9
  keys: props.fuzzyKeys
10
10
  };
11
- return matchSorter(props.values, search ?? '', fuzzyOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
11
+ return matchSorter(props.values, search || '', fuzzyOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
12
12
  }, [props.values, search]);
13
13
  return {
14
14
  open,
@@ -92,7 +92,7 @@ const SelectSearch = props => {
92
92
  children: _jsx(List, {
93
93
  children: values.map(item => _jsx(Option, {
94
94
  onChange: handleOnItemClick(item),
95
- children: props.createLabelName?.(item) ?? item[props.labelName || 'label']
95
+ children: props.createLabelName?.(item) || item[props.labelName || 'label']
96
96
  }, item[item.keyName || 'id']))
97
97
  })
98
98
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbl-digital/snorre",
3
- "version": "3.1.18",
3
+ "version": "3.1.20",
4
4
  "description": "Design library for BBL Digital",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -1,13 +0,0 @@
1
- export let ModifierKey;
2
-
3
- (function (ModifierKey) {
4
- ModifierKey["enter"] = "Enter";
5
- ModifierKey["tab"] = "Tab";
6
- ModifierKey["space"] = " ";
7
- ModifierKey["escape"] = "Escape";
8
- ModifierKey["shift"] = "Shift";
9
- ModifierKey["right"] = "ArrowRight";
10
- ModifierKey["left"] = "ArrowLeft";
11
- ModifierKey["up"] = "ArrowUp";
12
- ModifierKey["down"] = "ArrowDown";
13
- })(ModifierKey || (ModifierKey = {}));
@@ -1,12 +0,0 @@
1
- export declare enum ModifierKey {
2
- enter = "Enter",
3
- tab = "Tab",
4
- space = " ",
5
- escape = "Escape",
6
- shift = "Shift",
7
- right = "ArrowRight",
8
- left = "ArrowLeft",
9
- up = "ArrowUp",
10
- down = "ArrowDown"
11
- }
12
- //# sourceMappingURL=ModifierKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModifierKey.d.ts","sourceRoot":"","sources":["../../src/packages/enums/ModifierKey.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,KAAK,MAAM;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,eAAe;IACpB,IAAI,cAAc;IAClB,EAAE,YAAY;IACd,IAAI,cAAc;CACnB"}
@@ -1,13 +0,0 @@
1
- export let ModifierKey;
2
-
3
- (function (ModifierKey) {
4
- ModifierKey["enter"] = "Enter";
5
- ModifierKey["tab"] = "Tab";
6
- ModifierKey["space"] = " ";
7
- ModifierKey["escape"] = "Escape";
8
- ModifierKey["shift"] = "Shift";
9
- ModifierKey["right"] = "ArrowRight";
10
- ModifierKey["left"] = "ArrowLeft";
11
- ModifierKey["up"] = "ArrowUp";
12
- ModifierKey["down"] = "ArrowDown";
13
- })(ModifierKey || (ModifierKey = {}));