@dvrd/dvr-controls 1.1.13 → 1.1.15

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.
Files changed (79) hide show
  1. package/index.ts +1 -0
  2. package/package.json +14 -24
  3. package/src/js/button/style/button.scss +5 -4
  4. package/src/js/button/style/closeButton.scss +0 -2
  5. package/src/js/button/style/dvrdButton.scss +2 -2
  6. package/src/js/button/style/outlinedButton.scss +5 -5
  7. package/src/js/button/style/simpleButton.scss +3 -5
  8. package/src/js/carousel/DVRCarousel.tsx +18 -16
  9. package/src/js/carousel/style/DVRCarousel.scss +2 -3
  10. package/src/js/checkbox/style/checkbox.scss +8 -7
  11. package/src/js/colorPicker/style/colorPicker.scss +0 -2
  12. package/src/js/date/dvrdDatePicker.tsx +1 -2
  13. package/src/js/date/style/dvrdDatePicker.scss +21 -19
  14. package/src/js/dialog/style/dialog.scss +15 -12
  15. package/src/js/fileUpload/style/fileUpload.scss +2 -2
  16. package/src/js/header/style/header.scss +16 -14
  17. package/src/js/image/style/imageUpload.scss +0 -2
  18. package/src/js/info/style/info.scss +3 -3
  19. package/src/js/input/date/dateField.tsx +38 -31
  20. package/src/js/input/date/dateFieldController.tsx +2 -2
  21. package/src/js/input/date/datePicker/style/datePicker.scss +5 -5
  22. package/src/js/input/date/style/dateField.scss +5 -4
  23. package/src/js/input/date/timePicker/style/timePicker.scss +5 -4
  24. package/src/js/input/password/style/passwordInput.scss +3 -3
  25. package/src/js/input/password/style/passwordRules.scss +4 -4
  26. package/src/js/input/simple/style/simpleInput.scss +2 -2
  27. package/src/js/input/style/input.scss +6 -5
  28. package/src/js/label/label.tsx +1 -2
  29. package/src/js/link/link.tsx +3 -1
  30. package/src/js/link/style/link.scss +4 -4
  31. package/src/js/loader/style/loader.scss +6 -5
  32. package/src/js/navigation/mobileNavigation.tsx +1 -2
  33. package/src/js/navigation/style/mobileNavigation.scss +31 -24
  34. package/src/js/optionsList/style/dvrdOptionsList.scss +6 -5
  35. package/src/js/optionsMenu/style/optionsMenu.scss +6 -5
  36. package/src/js/pdf/element/style/pdfElement.scss +8 -7
  37. package/src/js/pdf/image/pdfImage.tsx +4 -4
  38. package/src/js/pdf/image/style/pdfImage.scss +3 -3
  39. package/src/js/pdf/invoiceTable/pdfInvoiceTable.tsx +3 -3
  40. package/src/js/pdf/invoiceTable/style/pdfInvoiceTable.scss +2 -2
  41. package/src/js/pdf/settings/buttons/style/iconButton.scss +5 -5
  42. package/src/js/pdf/settings/image/pdfImageSettings.tsx +4 -6
  43. package/src/js/pdf/settings/invoiceTable/style/pdfInvoiceTableSettings.scss +4 -3
  44. package/src/js/pdf/settings/style/pdfElementSettings.scss +3 -3
  45. package/src/js/pdf/settings/text/style/pdfTextSettings.scss +5 -4
  46. package/src/js/pdf/style/pdfTemplateCreator.scss +12 -11
  47. package/src/js/pdf/text/pdfText.tsx +3 -3
  48. package/src/js/pdf/text/style/pdfText.scss +0 -2
  49. package/src/js/pdf/v2/pdfElement/pdfDraggableElement.tsx +4 -6
  50. package/src/js/popup/style/withBackground.scss +3 -3
  51. package/src/js/radio/style/dvrdRadio.scss +6 -5
  52. package/src/js/select/async/style/asyncSelect.scss +0 -2
  53. package/src/js/select/dvrdGroupedSelect.tsx +1 -2
  54. package/src/js/select/dvrdMultiSelect.tsx +2 -3
  55. package/src/js/select/dvrdSelect.tsx +12 -11
  56. package/src/js/select/dvrdSelectController.tsx +10 -11
  57. package/src/js/select/style/dvrdGroupedSelect.scss +12 -11
  58. package/src/js/select/style/dvrdSelect.scss +9 -8
  59. package/src/js/select/style/select.scss +16 -24
  60. package/src/js/sidebarMenu/sidebarMenu.tsx +22 -13
  61. package/src/js/sidebarMenu/style/sidebarMenu.scss +7 -6
  62. package/src/js/slider/style/DVRSlider.scss +2 -2
  63. package/src/js/snackbar/snackbarController.tsx +3 -5
  64. package/src/js/snackbar/style/snackbar.scss +7 -6
  65. package/src/js/switch/style/dvrdSwitch.scss +2 -2
  66. package/src/js/switch/style/switch.scss +8 -8
  67. package/src/js/textField/dvrdPasswordInput.tsx +0 -1
  68. package/src/js/textField/style/dvrdInput.scss +4 -4
  69. package/src/js/textField/style/dvrdPassword.scss +3 -3
  70. package/src/js/topButton/style/topButton.scss +3 -3
  71. package/src/js/util/controlContext.tsx +1 -2
  72. package/src/js/util/interfaces.ts +3 -3
  73. package/src/style/_colors.scss +44 -0
  74. package/src/style/{common-variables.scss → _common-variables.scss} +16 -62
  75. package/src/style/common-icons.scss +141 -142
  76. package/src/style/{variables.scss → main.scss} +2 -3
  77. package/src/js/label/style/label.scss +0 -4
  78. package/src/js/pdf/settings/image/style/pdfImageSettings.scss +0 -9
  79. /package/src/style/{display-breakpoints.scss → _display-breakpoints.scss} +0 -0
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../style/variables';
5
+ @use '../../../style/common-variables' as commons;
6
+ @use '../../../style/colors';
6
7
 
7
8
  .dvrd-radio-button {
8
9
  cursor: pointer;
@@ -12,14 +13,14 @@
12
13
 
13
14
  .dvrd-radio-button-label {
14
15
  font-size: .9rem;
15
- color: $color-blue-text;
16
+ color: colors.$color-blue-text;
16
17
  cursor: inherit;
17
18
  user-select: none;
18
19
  transition: color .2s ease;
19
20
  }
20
21
 
21
22
  .dvrd-radio-bullet-container {
22
- @include backgroundShadow2;
23
+ @include commons.backgroundShadow2;
23
24
  width: 22px;
24
25
  height: 22px;
25
26
  position: relative;
@@ -46,8 +47,8 @@
46
47
  }
47
48
 
48
49
  .ripple {
49
- @include centerXY;
50
- @include borderRadius(50%);
50
+ @include commons.centerXY;
51
+ border-radius: 50%;
51
52
  opacity: 1;
52
53
  width: 8px;
53
54
  height: 8px;
@@ -2,8 +2,6 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../../style/variables';
6
-
7
5
  .dvr-async-select {
8
6
  display: inline-block;
9
7
  position: relative;
@@ -7,7 +7,6 @@ import React, {ForwardedRef, forwardRef, useEffect, useImperativeHandle, useMemo
7
7
  import {ErrorType, GroupedSelectItem, SelectValueType} from "../util/interfaces";
8
8
  import classNames from 'classnames';
9
9
  import AwesomeIcon from "../icon/awesomeIcon";
10
- import defer from 'lodash.defer';
11
10
  import {stopPropagation} from "../util/controlUtil";
12
11
 
13
12
 
@@ -267,7 +266,7 @@ function DVRDGroupedSelect(props: Props, ref: ForwardedRef<GroupedSelectRef>) {
267
266
  useEffect(() => {
268
267
  if (open) {
269
268
  document.body.addEventListener('click', clickListener);
270
- defer(scrollSelectedInView);
269
+ window.setTimeout(scrollSelectedInView);
271
270
  } else document.body.removeEventListener('click', clickListener);
272
271
  }, [open]);
273
272
 
@@ -8,13 +8,12 @@ import classNames from 'classnames';
8
8
  import {ChangeFunction, ErrorType, SelectItemShape} from '../util/interfaces';
9
9
  import {hasHover, stopPropagation} from '../util/controlUtil';
10
10
  import AwesomeIcon from '../icon/awesomeIcon';
11
- import delay from 'lodash.delay';
12
11
 
13
12
  interface Props {
14
13
  onChange: (selected: Array<string | number>, submit: boolean) => VoidFunction;
15
14
  onChangeSearch: ChangeFunction;
16
15
  selected: Array<string | number>;
17
- items: SelectItemShape[];
16
+ items: Array<SelectItemShape<number | string>>;
18
17
  disabled?: boolean;
19
18
  error?: ErrorType;
20
19
  label?: string;
@@ -83,7 +82,7 @@ export default function DvrdMultiSelect(props: Props) {
83
82
  }
84
83
 
85
84
  function onBlurInput() {
86
- delay(() => {
85
+ window.setTimeout(() => {
87
86
  setSearchFocused(false);
88
87
  onChangeSearch({target: {value: ''}});
89
88
  }, transitionDuration);
@@ -9,11 +9,11 @@ import {ChangeFunction, ErrorType, SelectItemShape} from '../util/interfaces';
9
9
  import {hasHover, stopPropagation} from '../util/controlUtil';
10
10
  import AwesomeIcon from '../icon/awesomeIcon';
11
11
 
12
- interface Props {
13
- onChange: (value: string | number) => MouseEventHandler;
12
+ interface Props<ValueType = string | number> {
13
+ onChange: (value: ValueType) => MouseEventHandler;
14
14
  onChangeSearch: ChangeFunction;
15
- value: string | number;
16
- items: SelectItemShape[];
15
+ value: ValueType;
16
+ items: Array<SelectItemShape<ValueType>>;
17
17
  disabled?: boolean;
18
18
  error?: ErrorType;
19
19
  label?: string;
@@ -35,7 +35,7 @@ interface State {
35
35
  searchFocused: boolean;
36
36
  }
37
37
 
38
- export default class DvrdSelect extends PureComponent<Props, State> {
38
+ export default class DvrdSelect<ValueType = string | number> extends PureComponent<Props<ValueType>, State> {
39
39
  private container: HTMLDivElement;
40
40
  state: State = {
41
41
  open: false,
@@ -50,7 +50,7 @@ export default class DvrdSelect extends PureComponent<Props, State> {
50
50
  this.setState({open: !this.state.open});
51
51
  };
52
52
 
53
- onClickItem = (value: string | number) => (evt: React.MouseEvent) => {
53
+ onClickItem = (value: ValueType) => (evt: React.MouseEvent) => {
54
54
  evt.stopPropagation();
55
55
  this.props.onChange(value)(evt);
56
56
  this.setState({open: false});
@@ -86,11 +86,12 @@ export default class DvrdSelect extends PureComponent<Props, State> {
86
86
  return '';
87
87
  }
88
88
 
89
- getItemLabel = (item: SelectItemShape): string | number => {
89
+ getItemLabel = (item: SelectItemShape<ValueType>): string | number => {
90
90
  const {label} = item;
91
91
  if (['string', 'number'].includes(typeof label)) return label as string | number;
92
92
  else if (!!item.valueLabel) return item.valueLabel;
93
- return item.value;
93
+ // We are not sure what the actual type is, we assume it is something React can render
94
+ return item.value as string;
94
95
  }
95
96
 
96
97
  getItemsContainerStyle = (): CSSProperties => {
@@ -130,7 +131,7 @@ export default class DvrdSelect extends PureComponent<Props, State> {
130
131
 
131
132
  renderItems = () => {
132
133
  const {disabled, itemContainerClassName, itemsPosition} = this.props, {open} = this.state;
133
- const items = this.props.items.filter((item: SelectItemShape) => {
134
+ const items = this.props.items.filter((item: SelectItemShape<ValueType>) => {
134
135
  if (item.selectable === false) return false;
135
136
  if (typeof item.label === 'string') return item.label.length > 0;
136
137
  return true;
@@ -144,7 +145,7 @@ export default class DvrdSelect extends PureComponent<Props, State> {
144
145
  )
145
146
  };
146
147
 
147
- renderItem = (item: SelectItemShape, index: number) => {
148
+ renderItem = (item: SelectItemShape<ValueType>, index: number) => {
148
149
  const {value, selectableItemLabel} = item;
149
150
  const label = selectableItemLabel ?? item.label;
150
151
  const {itemClassName} = this.props;
@@ -183,7 +184,7 @@ export default class DvrdSelect extends PureComponent<Props, State> {
183
184
  if (!hasHover(this.container)) this.setState({open: false});
184
185
  };
185
186
 
186
- componentDidUpdate = (props: Props, prevState: State) => {
187
+ componentDidUpdate = (props: Props<ValueType>, prevState: State) => {
187
188
  const {open} = this.state, prevOpen = prevState.open;
188
189
  if (open && !prevOpen) this.addClickListener();
189
190
  else if (!open && prevOpen) this.removeClickListener();
@@ -8,12 +8,10 @@ import {ChangeFunction, ErrorType, SelectItemShape} from "../util/interfaces";
8
8
  import {stringContains} from '../util/controlUtil';
9
9
  import DvrdMultiSelect from "./dvrdMultiSelect";
10
10
 
11
- type ValueType = string | number | Array<string | number>;
12
-
13
- interface Props {
11
+ interface Props<ValueType = string | number | Array<string | number>> {
14
12
  onChange: ChangeFunction<ValueType>;
15
13
  value: ValueType;
16
- items: SelectItemShape[];
14
+ items: Array<SelectItemShape<ValueType>>;
17
15
  disabled?: boolean;
18
16
  label?: string;
19
17
  error?: ErrorType;
@@ -33,21 +31,21 @@ interface Props {
33
31
  submitOnClose?: boolean;
34
32
  }
35
33
 
36
- export default function DvrdSelectController(props: Props) {
34
+ export default function DvrdSelectController<ValueType = string | number | Array<string | number>>(props: Props<ValueType>) {
37
35
  const {
38
36
  value, multi, unControlled, onChange, items, error, className, labelClassName, valueClassName,
39
37
  itemContainerClassName, arrowClassName, errorClassName, itemClassName, label, disabled, placeholder,
40
38
  submitOnClose
41
39
  } = props;
42
40
  const [search, setSearch] = useState('');
43
- const [internalValue, setInternalValue] = useState<ValueType>('');
41
+ const [internalValue, setInternalValue] = useState<ValueType>('' as ValueType);
44
42
  const _items = useMemo(() => {
45
43
  if (!search) return items;
46
44
  return items.filter((item) => stringContains(item.label.toString(), search));
47
45
  }, [items, search]);
48
46
 
49
47
  function _onChange(value: ValueType, submit: boolean = true) {
50
- return function () {
48
+ return function() {
51
49
  if (submit) onChange(value);
52
50
  setInternalValue(value);
53
51
  }
@@ -70,8 +68,9 @@ export default function DvrdSelectController(props: Props) {
70
68
  const optionsContainerHeight = props.optionsContainerHeight ?? '15rem';
71
69
  const selectOnly = props.selectOnly !== false;
72
70
  if (multi) return (
73
- <DvrdMultiSelect onChange={_onChange} onChangeSearch={onChangeSearch}
74
- selected={internalValue as Array<string | number>} items={_items} itemsPosition={itemsPosition}
71
+ <DvrdMultiSelect onChange={_onChange as any} onChangeSearch={onChangeSearch}
72
+ selected={internalValue as Array<string | number>}
73
+ items={_items as Array<SelectItemShape<number | string>>} itemsPosition={itemsPosition}
75
74
  selectOnly={selectOnly} searchValue={search} optionsContainerHeight={optionsContainerHeight}
76
75
  className={className} error={error} label={label} arrowClassName={arrowClassName}
77
76
  errorClassName={errorClassName} itemClassName={itemClassName} submitOnClose={submitOnClose}
@@ -79,8 +78,8 @@ export default function DvrdSelectController(props: Props) {
79
78
  labelClassName={labelClassName} disabled={disabled} placeholder={placeholder}/>
80
79
  );
81
80
  return (
82
- <DvrdSelect onChange={_onChange} onChangeSearch={onChangeSearch} value={internalValue as number | string}
83
- items={_items} itemsPosition={itemsPosition} selectOnly={selectOnly} searchValue={search}
81
+ <DvrdSelect onChange={_onChange} onChangeSearch={onChangeSearch} value={internalValue} items={_items}
82
+ itemsPosition={itemsPosition} selectOnly={selectOnly} searchValue={search}
84
83
  optionsContainerHeight={optionsContainerHeight} className={className} error={error} label={label}
85
84
  arrowClassName={arrowClassName} errorClassName={errorClassName} itemClassName={itemClassName}
86
85
  itemContainerClassName={itemContainerClassName} valueClassName={valueClassName}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../style/variables';
5
+ @use '../../../style/common-variables' as commons;
6
+ @use '../../../style/colors';
6
7
 
7
8
  .dvrd-grouped-select {
8
9
  display: grid;
@@ -10,7 +11,7 @@
10
11
  position: relative;
11
12
 
12
13
  .grouped-select-label {
13
- color: $color-blue-text;
14
+ color: colors.$color-blue-text;
14
15
  font-size: .9rem;
15
16
  transition: color .2s ease-in-out;
16
17
  cursor: pointer;
@@ -48,7 +49,7 @@
48
49
  }
49
50
 
50
51
  .grouped-select-placeholder {
51
- color: $color-gray-2;
52
+ color: colors.$color-gray-2;
52
53
 
53
54
  &.hidden {
54
55
  visibility: hidden;
@@ -56,13 +57,13 @@
56
57
  }
57
58
 
58
59
  .grouped-select-value {
59
- color: $color-blue-text;
60
+ color: colors.$color-blue-text;
60
61
  }
61
62
 
62
63
  .chev-icon {
63
64
  font-size: .9rem;
64
65
  transition: transform .2s ease-in-out;
65
- color: $color-gray-3;
66
+ color: colors.$color-gray-3;
66
67
  }
67
68
 
68
69
  &.searchable {
@@ -71,7 +72,7 @@
71
72
  }
72
73
 
73
74
  .grouped-select-items {
74
- @include backgroundShadow3($borderRadius: 0);
75
+ @include commons.backgroundShadow3($borderRadius: 0);
75
76
  background-color: white;
76
77
  position: absolute;
77
78
  left: 1px;
@@ -89,18 +90,18 @@
89
90
  transition: background-color .2s ease-in-out;
90
91
  cursor: default;
91
92
  user-select: none;
92
- color: $color-blue-text;
93
+ color: colors.$color-blue-text;
93
94
 
94
95
  &.selectable {
95
96
  cursor: pointer;
96
97
 
97
98
  &:not(&.selected):hover {
98
- background-color: rgba($color-blue-1, .2);
99
+ background-color: rgba(colors.$color-blue-1, .2);
99
100
  }
100
101
  }
101
102
 
102
103
  &.selected {
103
- background-color: rgba($color-blue-1, .3);
104
+ background-color: rgba(colors.$color-blue-1, .3);
104
105
  }
105
106
 
106
107
  &.group-head {
@@ -137,13 +138,13 @@
137
138
 
138
139
  &.open, &:hover:not(&.disabled):not(&.error) {
139
140
  .grouped-select-value-container {
140
- border-color: $color-blue-1;
141
+ border-color: colors.$color-blue-1;
141
142
  }
142
143
  }
143
144
 
144
145
  &.open {
145
146
  .grouped-select-label {
146
- color: $color-blue-1;
147
+ color: colors.$color-blue-1;
147
148
  }
148
149
 
149
150
  .grouped-select-value-container .chev-icon {
@@ -2,14 +2,15 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../style/variables';
5
+ @use '../../../style/common-variables' as commons;
6
+ @use '../../../style/colors';
6
7
 
7
8
  .dvrd-select-container {
8
9
  transition: margin-bottom .2s ease-in-out;
9
10
  position: relative;
10
11
 
11
12
  .dvrd-select-label {
12
- color: $color-blue-text;
13
+ color: colors.$color-blue-text;
13
14
  font-size: .9rem;
14
15
  margin-bottom: .25rem;
15
16
  display: block;
@@ -29,7 +30,7 @@
29
30
  background-color: white;
30
31
 
31
32
  .dvrd-select-value {
32
- color: $color-blue-text;
33
+ color: colors.$color-blue-text;
33
34
  }
34
35
 
35
36
  .dvrd-select-search {
@@ -55,7 +56,7 @@
55
56
  background-color: white;
56
57
  position: absolute;
57
58
  left: 0;
58
- z-index: $z-index-high;
59
+ z-index: commons.$z-index-high;
59
60
  visibility: hidden;
60
61
  opacity: 0;
61
62
  transition: visibility .1s ease-in-out, opacity .1s ease-in-out, box-shadow .1s ease-in-out;
@@ -67,7 +68,7 @@
67
68
 
68
69
  .dvrd-select-item {
69
70
  padding: .75rem;
70
- color: $color-blue-text;
71
+ color: colors.$color-blue-text;
71
72
  background-color: white;
72
73
  transition: background-color .2s ease-in-out;
73
74
  cursor: pointer;
@@ -89,7 +90,7 @@
89
90
  }
90
91
 
91
92
  &.open {
92
- @include backgroundShadow;
93
+ @include commons.backgroundShadow;
93
94
  visibility: visible;
94
95
  opacity: 1;
95
96
  }
@@ -143,10 +144,10 @@
143
144
  }
144
145
 
145
146
  &.selected {
146
- background-color: rgba($color-green-whatsapp, .2);
147
+ background-color: rgba(colors.$color-green-whatsapp, .2);
147
148
 
148
149
  .check-icon {
149
- color: $color-green-whatsapp;
150
+ color: colors.$color-green-whatsapp;
150
151
  }
151
152
  }
152
153
  }
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../style/variables';
5
+ @use '../../../style/common-variables' as commons;
6
+ @use '../../../style/colors';
6
7
 
7
8
  .selectContainer {
8
9
  position: relative;
@@ -33,12 +34,12 @@
33
34
  cursor: pointer;
34
35
 
35
36
  &:hover {
36
- color: $color-red-1;
37
+ color: colors.$color-red-1;
37
38
  }
38
39
  }
39
40
 
40
41
  .valueLabelContainer {
41
- @include borderRadius(.2rem);
42
+ border-radius: .2rem;
42
43
  border-width: 2px;
43
44
  border-style: solid;
44
45
  padding: .7rem .6rem;
@@ -51,21 +52,21 @@
51
52
  min-height: 2.8rem;
52
53
 
53
54
  .selectLabel {
54
- @include centerY;
55
+ @include commons.centerY;
55
56
  position: absolute;
56
57
  left: .2rem;
57
58
  font-size: .8rem;
58
59
  transition: top .2s ease-in-out, transform .2s ease-in-out, font-size .2s ease-in-out, left .2s ease-in-out;
59
60
  background-color: white;
60
61
  padding: .2rem;
61
- color: $color-gray-4;
62
+ color: colors.$color-gray-4;
62
63
 
63
64
  &.up {
64
- @include borderRadius(.2rem);
65
+ border-radius: .2rem;
65
66
  transform: none;
66
67
  top: -.8rem;
67
68
  font-size: .7rem;
68
- color: $color-gray-3;
69
+ color: colors.$color-gray-3;
69
70
  }
70
71
  }
71
72
 
@@ -76,11 +77,11 @@
76
77
 
77
78
  .valueLabel {
78
79
  font-size: 1rem;
79
- color: $color-gray-5;
80
+ color: colors.$color-gray-5;
80
81
  user-select: none;
81
82
 
82
83
  &.disabled, &.readOnly {
83
- color: $color-gray-4;
84
+ color: colors.$color-gray-4;
84
85
  }
85
86
  }
86
87
  }
@@ -101,7 +102,7 @@
101
102
 
102
103
  .searchIcon {
103
104
  font-size: 1.2rem;
104
- color: $color-gray-5;
105
+ color: colors.$color-gray-5;
105
106
  padding: 0;
106
107
  }
107
108
  }
@@ -114,24 +115,15 @@
114
115
  transform: rotate(180deg);
115
116
  }
116
117
  }
117
-
118
- //.error {
119
- // position: absolute;
120
- // bottom: -1.4rem;
121
- // left: .4rem;
122
- // color: red;
123
- // font-size: .9rem;
124
- //}
125
118
  }
126
119
 
127
120
  .itemsContainer {
128
- @include borderRadius(.5rem);
129
121
  box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
130
122
  background-color: white;
131
123
  box-sizing: border-box;
132
- border-top-left-radius: 0;
133
- border: 1px solid $color-gray-7;
134
- z-index: $z-index-high;
124
+ border-radius: 0 .5rem .5rem .5rem;
125
+ border: 1px solid colors.$color-gray-7;
126
+ z-index: commons.$z-index-high;
135
127
  visibility: hidden;
136
128
  opacity: 0;
137
129
  transition: visibility .15s ease-in-out, opacity .15s ease-in-out;
@@ -149,7 +141,7 @@
149
141
  &.readOnly {
150
142
  cursor: not-allowed;
151
143
  .itemLabel {
152
- color: $color-gray-3;
144
+ color: colors.$color-gray-3;
153
145
  }
154
146
  }
155
147
 
@@ -159,7 +151,7 @@
159
151
  align-items: center;
160
152
 
161
153
  .selectedCheck {
162
- color: $color-green-whatsapp;
154
+ color: colors.$color-green-whatsapp;
163
155
  font-size: 1rem;
164
156
  }
165
157
  }
@@ -2,15 +2,14 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
  import './style/sidebarMenu.scss';
5
+ import {IconName} from '@fortawesome/fontawesome-svg-core';
6
+ import classNames from 'classnames';
5
7
 
6
8
  import React, {MouseEventHandler, ReactNode, useContext, useEffect, useRef, useState} from 'react';
7
9
  import {NavLink, useLocation} from 'react-router';
8
- import {SidebarItem, SideMenuMode} from '../util/interfaces';
9
- import classNames from 'classnames';
10
10
  import {AwesomeIcon, generateComponentId, isAbsoluteLink} from '../../../index';
11
11
  import {ControlContext} from '../util/controlContext';
12
- import defer from 'lodash.defer';
13
- import {IconName} from '@fortawesome/fontawesome-svg-core';
12
+ import {SidebarItem, SideMenuMode} from '../util/interfaces';
14
13
 
15
14
  interface Props {
16
15
  onClickItem: (item: SidebarItem) => MouseEventHandler;
@@ -58,13 +57,22 @@ function itemHasActiveId(item: SidebarItem, activeId: string): boolean {
58
57
  }
59
58
 
60
59
  export default function SidebarMenu(props: Props) {
61
- const context = useContext(ControlContext),
62
- location = useLocation(),
63
- {className, contrastColor, baseColor, items, onClickItem} = props,
64
- mode = props.mode ?? SideMenuMode.COMPACT,
65
- [activeItem, setActiveItem] = useState(props.activeItem ?? ''),
66
- sideBar = useRef<HTMLDivElement>(null),
67
- componentId = useRef(generateComponentId(props.id));
60
+ const context = useContext(ControlContext);
61
+ const location = useLocation();
62
+ const {className, contrastColor, baseColor, items, onClickItem} = props;
63
+ const mode = props.mode ?? SideMenuMode.COMPACT;
64
+ const [activeItem, setActiveItem] = useState(props.activeItem ?? '');
65
+ const sideBar = useRef<HTMLDivElement>(null);
66
+ const componentId = useRef(generateComponentId(props.id));
67
+
68
+ function onClickNavLink(item: SidebarItem) {
69
+ return function (evt: React.MouseEvent) {
70
+ if (!!onClickItem) {
71
+ onClickItem(item)(evt);
72
+ evt.preventDefault();
73
+ }
74
+ };
75
+ }
68
76
 
69
77
  function _onClickItem(item: SidebarItem) {
70
78
  return function (evt: React.MouseEvent) {
@@ -104,7 +112,8 @@ export default function SidebarMenu(props: Props) {
104
112
  );
105
113
 
106
114
  if (asNavLink) return (
107
- <NavLink key={id} to={item.route as string} className={cls} id={id}>
115
+ <NavLink key={id} to={item.route as string} className={cls} id={id}
116
+ onClick={onClickNavLink(item)}>
108
117
  {({isActive}) => content(isActive)}
109
118
  </NavLink>
110
119
  );
@@ -160,7 +169,7 @@ export default function SidebarMenu(props: Props) {
160
169
 
161
170
  useEffect(() => {
162
171
  setColors();
163
- defer(_setActiveItem);
172
+ window.setTimeout(_setActiveItem);
164
173
  }, []);
165
174
 
166
175
  useEffect(() => {
@@ -2,10 +2,11 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../style/variables';
5
+ @use '../../../style/common-variables' as commons;
6
+ @use '../../../style/colors';
6
7
 
7
8
  .dvr-side-bar-menu {
8
- @include backgroundShadow;
9
+ @include commons.backgroundShadow;
9
10
  display: flex;
10
11
  flex-direction: column;
11
12
  justify-content: space-between;
@@ -14,10 +15,10 @@
14
15
  background-color: var(--contrast-color);
15
16
  height: calc(100vh - 4rem);
16
17
  width: 4rem;
17
- z-index: $z-index-popup-4;
18
+ z-index: commons.$z-index-popup-4;
18
19
 
19
20
  .side-bar-item {
20
- border-bottom: 1px solid $color-gray-7;
21
+ border-bottom: 1px solid colors.$color-gray-7;
21
22
  height: 4rem;
22
23
  width: 4rem;
23
24
  display: flex;
@@ -31,7 +32,7 @@
31
32
  text-decoration: none;
32
33
 
33
34
  .item-icon {
34
- color: $color-gray-4;
35
+ color: colors.$color-gray-4;
35
36
  font-size: 1.5rem;
36
37
  transition: color .2s ease-in-out;
37
38
 
@@ -41,7 +42,7 @@
41
42
  }
42
43
 
43
44
  .item-label {
44
- @include centerY;
45
+ @include commons.centerY;
45
46
  border-radius: .5rem;
46
47
  position: absolute;
47
48
  padding: 4px 6px;
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- @import '../../../style/variables';
5
+ @use '../../../style/common-variables' as commons;
6
6
 
7
7
  .dvr-slider-container {
8
8
  .dvr-slider-label {
@@ -20,7 +20,7 @@
20
20
  cursor: pointer;
21
21
 
22
22
  &::-webkit-slider-thumb {
23
- @include backgroundShadow;
23
+ @include commons.backgroundShadow;
24
24
  -webkit-appearance: none;
25
25
  appearance: none;
26
26
  width: .75rem;
@@ -5,8 +5,6 @@
5
5
  import React, {useEffect, useRef, useState} from 'react';
6
6
  import Snackbar from "./snackbar";
7
7
  import {Snack} from "../util/interfaces";
8
- import delay from 'lodash.delay';
9
- import defer from 'lodash.defer';
10
8
  import {useEvent} from "../util/componentUtil";
11
9
 
12
10
  interface Props {
@@ -50,16 +48,16 @@ export default function SnackbarController(props: Props) {
50
48
  if (!snack) return;
51
49
  const _activeTime = snack.config?.duration ?? activeTime ?? 3000;
52
50
  setSnack(snack);
53
- defer(() => setActive(true));
51
+ window.setTimeout(() => setActive(true));
54
52
  timeoutID.current = window.setTimeout(deactivate, _activeTime);
55
53
  }
56
54
 
57
55
  function deactivate() {
58
56
  setActive(false);
59
57
  // Clear snack after 200ms (css transition)
60
- delay(() => {
58
+ window.setTimeout(() => {
61
59
  setSnack(null);
62
- defer(() => {
60
+ window.setTimeout(() => {
63
61
  if (snackQueue.current.length)
64
62
  // Open next
65
63
  timeoutID.current = window.setTimeout(activate, 500);