@majoo-ui/react 2.4.3 → 2.4.5

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 (50) hide show
  1. package/components/alertDialog/AlertDialog.esm.js +11 -1
  2. package/components/barChart/BarChart.esm.js +1 -1
  3. package/components/buttonGroup/ButtonGroup.esm.js +1 -0
  4. package/components/chart/lineChart/LineChart.esm.js +7 -10
  5. package/components/checkboxTable/CheckboxTable.esm.js +38 -38
  6. package/components/colorPicker/InputColorPicker.esm.js +5 -2
  7. package/components/datePicker/CustomDatePicker.esm.js +12 -3
  8. package/components/datePicker/InputDatePicker.esm.js +15 -6
  9. package/components/datePicker/InputDateRangePicker.esm.js +1 -1
  10. package/components/datePicker/timePicker/InputTimePicker.esm.js +6 -7
  11. package/components/datePicker/timePicker/TimePicker.esm.js +32 -38
  12. package/components/devicePreview/DevicePreview.esm.js +3 -3
  13. package/components/drawer/Drawer.esm.js +42 -6
  14. package/components/dropdownMenu/DropdownMenu.esm.js +15 -7
  15. package/components/editableTable/EditableTable.esm.js +22 -5
  16. package/components/form/components/FormHelper/Helper.esm.js +1 -1
  17. package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +6 -10
  18. package/components/form/components/InputCombobox/InputCombobox.esm.js +6 -3
  19. package/components/form/components/InputCreatable/InputCreatable.esm.js +5 -6
  20. package/components/form/components/InputGroup/InputGroup.esm.js +8 -9
  21. package/components/form/components/InputNumber/InputNumber.esm.js +1 -1
  22. package/components/form/components/InputRadio/InputRadio.esm.js +5 -2
  23. package/components/form/components/InputRadio/InputRadioGroup.esm.js +12 -5
  24. package/components/form/components/InputResourceList/InputResourceList.esm.js +13 -7
  25. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +9 -3
  26. package/components/form/components/InputSelect/InputSelect.esm.js +1 -1
  27. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +5 -2
  28. package/components/form/components/InputSwitch/InputSwitch.esm.js +9 -8
  29. package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +9 -8
  30. package/components/form/components/InputTags/InputTags.esm.js +12 -11
  31. package/components/loadingBar/LoadingBar.esm.js +14 -8
  32. package/components/mapPicker/InputMapPicker.esm.js +0 -1
  33. package/components/modalDialog/ModalDialog.esm.js +14 -6
  34. package/components/notificationBadge/NotificationBadge.esm.js +12 -7
  35. package/components/pageDialog/PageDialog.esm.js +13 -7
  36. package/components/pagination/PaginationButton.esm.js +1 -0
  37. package/components/pieChart/PieChart.esm.js +1 -1
  38. package/components/popover/Popover.esm.js +3 -2
  39. package/components/progressIndicator/ProgressIndicator.esm.js +1 -1
  40. package/components/stepWizard/StepWizard.esm.js +4 -4
  41. package/components/table/MobileTable.esm.js +4 -2
  42. package/components/tabs/Tabs.esm.js +21 -10
  43. package/components/tooltip/Tooltip.esm.js +9 -4
  44. package/components/upload/Upload.esm.js +34 -18
  45. package/index.esm.js +2 -2
  46. package/layout/grid/Grid.esm.js +32 -13
  47. package/layout/pageContainer/PageContainer.esm.js +1 -0
  48. package/package.json +2 -2
  49. package/src/components/editableTable/EditableTable.d.ts +3 -1
  50. package/utils/element.esm.js +0 -21
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useEffect } from 'react';
2
+ import { useState, useRef, useEffect } from 'react';
3
3
  import { styled } from '@stitches/react';
4
4
  import * as ProgressPrimitive from '@radix-ui/react-progress';
5
5
 
@@ -64,7 +64,6 @@ function PrimitiveLoadingBar({
64
64
  })]
65
65
  });
66
66
  }
67
- let interval;
68
67
  function LoadingBar(props) {
69
68
  const {
70
69
  show,
@@ -73,25 +72,32 @@ function LoadingBar(props) {
73
72
  } = props;
74
73
  const [progress, setProgress] = useState(0);
75
74
  const [visibility, setVisibility] = useState(false);
75
+ const intervalRef = useRef(null);
76
+ const hideTimeoutRef = useRef(null);
76
77
  useEffect(() => {
78
+ if (intervalRef.current) clearInterval(intervalRef.current);
79
+ if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
77
80
  if (show) {
81
+ setProgress(0);
78
82
  setVisibility(true);
79
- interval = setInterval(() => {
80
- setProgress(prev => prev < 100 && prev + 1);
83
+ intervalRef.current = setInterval(() => {
84
+ setProgress(prev => prev < 100 ? prev + 1 : prev);
81
85
  }, intervalTime);
82
86
  } else {
83
87
  setProgress(100);
84
- clearInterval(interval);
85
- setTimeout(() => {
88
+ hideTimeoutRef.current = setTimeout(() => {
86
89
  setVisibility(false);
87
90
  setProgress(0);
88
91
  }, 1000);
89
92
  }
90
- return () => setProgress(0);
93
+ return () => {
94
+ if (intervalRef.current) clearInterval(intervalRef.current);
95
+ if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
96
+ };
91
97
  }, [show, intervalTime]);
92
98
  useEffect(() => {
93
99
  if (progress === 100) {
94
- clearInterval(interval);
100
+ if (intervalRef.current) clearInterval(intervalRef.current);
95
101
  onCompleted === null || onCompleted === void 0 ? void 0 : onCompleted();
96
102
  }
97
103
  }, [progress, onCompleted]);
@@ -7,7 +7,6 @@ import { Image } from '../image/Image.esm.js';
7
7
  import 'core-js/modules/es.iterator.constructor.js';
8
8
  import 'core-js/modules/es.iterator.filter.js';
9
9
  import 'core-js/modules/es.iterator.reduce.js';
10
- import 'react-i18next';
11
10
  import 'core-js/modules/es.array.includes.js';
12
11
  import ModalDialog, { ModalDialogTrigger, ModalDialogTitle, ModalDialogContent } from '../modalDialog/ModalDialog.esm.js';
13
12
  import Paragraph from '../paragraph/Paragraph.esm.js';
@@ -6,7 +6,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
6
6
  import React__default, { useCallback } from 'react';
7
7
  import { styled } from '../../config/stitches.config.esm.js';
8
8
  import Box from '../../layout/box/Box.esm.js';
9
- import Dialog, { DialogContent, DialogTrigger, DialogPortal, DialogTitle, DialogClose } from '../dialog/Dialog.esm.js';
9
+ import Dialog, { DialogContent, DialogTrigger, DialogPortal, DialogTitle, DialogClose, DialogDescription } from '../dialog/Dialog.esm.js';
10
10
  import Heading from '../heading/Heading.esm.js';
11
11
  import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
12
12
  import { CloseOutline } from '@majoo-ui/icons';
@@ -16,6 +16,8 @@ const ModalDialogFooter = styled('div');
16
16
  ModalDialogFooter.displayName = 'ModalDialogFooter';
17
17
  const ModalDialogTitle = styled('div');
18
18
  ModalDialogTitle.displayName = 'ModalDialogTitle';
19
+ const ModalDialogDescription = styled('div');
20
+ ModalDialogDescription.displayName = 'ModalDialogDescription';
19
21
  const ModalDialogContent = styled('div');
20
22
  ModalDialogContent.displayName = 'ModalDialogContent';
21
23
  const ModalDialogTrigger = styled('div');
@@ -98,6 +100,7 @@ const findNodeChild = (array, displayName) => {
98
100
  * <ModalDialog>
99
101
  * <ModalDialogTrigger>Button Trigger</ModalDialogTrigger>
100
102
  * <ModalDialogTitle>Title</ModalDialogTitle>
103
+ * <ModalDialogDescription>Description</ModalDialogDescription>
101
104
  * <ModalDialogContent>Content</ModalDialogContent>
102
105
  * <ModalDialogFooter>Footer</ModalDialogFooter>
103
106
  * </ModalDialog>
@@ -121,6 +124,7 @@ const ModalDialog = props => {
121
124
  const childArray = React__default.Children.toArray(children);
122
125
  const modalDialogFooter = findNodeChild(childArray, 'ModalDialogFooter');
123
126
  const modalDialogTitle = findNodeChild(childArray, 'ModalDialogTitle');
127
+ const modalDialogDescription = findNodeChild(childArray, 'ModalDialogDescription');
124
128
  const modalDialogContent = findNodeChild(childArray, 'ModalDialogContent');
125
129
  const modalDialogTrigger = findNodeChild(childArray, 'ModalDialogTrigger');
126
130
  const themeProvider = useThemeProvider(theme);
@@ -140,7 +144,7 @@ const ModalDialog = props => {
140
144
  css: {
141
145
  zIndex: layer
142
146
  }
143
- }), jsx(StyledContent, {
147
+ }), jsx(StyledContent, Object.assign({
144
148
  className: (themeProvider === null || themeProvider === void 0 ? void 0 : themeProvider.theme) || '',
145
149
  size: size,
146
150
  css: Object.assign(Object.assign({}, css), {
@@ -149,7 +153,10 @@ const ModalDialog = props => {
149
153
  maxWidth: width && 'unset'
150
154
  }),
151
155
  ref: ref,
152
- isMobile: isMobile,
156
+ isMobile: isMobile
157
+ }, modalDialogDescription ? {} : {
158
+ 'aria-describedby': undefined
159
+ }, {
153
160
  onOpenAutoFocus: e => {
154
161
  if (!onOpenAutoFocus) {
155
162
  e.preventDefault();
@@ -216,7 +223,7 @@ const ModalDialog = props => {
216
223
  })
217
224
  })]
218
225
  })
219
- }), modalDialogContent && jsx(Box, Object.assign({}, modalDialogContent.props, {
226
+ }), modalDialogDescription && jsx(DialogDescription, Object.assign({}, modalDialogDescription.props)), modalDialogContent && jsx(Box, Object.assign({}, modalDialogContent.props, {
220
227
  css: Object.assign({
221
228
  flexGrow: 1,
222
229
  maxHeight: 'calc(100vh - 64px - 56px)',
@@ -231,12 +238,13 @@ const ModalDialog = props => {
231
238
  }, modalDialogFooter.props.css)
232
239
  }))]
233
240
  })
234
- })]
241
+ }))]
235
242
  })]
236
243
  }));
237
244
  };
238
245
  ModalDialog.Trigger = ModalDialogTrigger;
239
246
  ModalDialog.Title = ModalDialogTitle;
247
+ ModalDialog.Description = ModalDialogDescription;
240
248
  ModalDialog.Content = ModalDialogContent;
241
249
  ModalDialog.Footer = ModalDialogFooter;
242
250
  ModalDialog.defaultProps = {
@@ -244,4 +252,4 @@ ModalDialog.defaultProps = {
244
252
  layer: '$modal'
245
253
  };
246
254
 
247
- export { ModalDialogContent, ModalDialogFooter, ModalDialogTitle, ModalDialogTrigger, ModalDialog as default };
255
+ export { ModalDialogContent, ModalDialogDescription, ModalDialogFooter, ModalDialogTitle, ModalDialogTrigger, ModalDialog as default };
@@ -102,6 +102,9 @@ const NotificationBadgeStyle = styled('span', {
102
102
  const NotificationBadge = ({
103
103
  children,
104
104
  variantIcon,
105
+ variant,
106
+ value,
107
+ dot,
105
108
  ...props
106
109
  }) => {
107
110
  const getIcon = () => {
@@ -112,20 +115,22 @@ const NotificationBadge = ({
112
115
  };
113
116
  };
114
117
  const getValue = () => {
115
- let value = props?.value;
118
+ const badgeValue = value;
116
119
  const isTrailing = variantIcon === 'trailing';
117
- if (typeof value === 'number' || parseInt(value)) {
118
- if (Math.sign(value) === 1 || Math.sign(value) === 0) {
119
- return value > 99 ? getIcon().max : value;
120
+ if (typeof badgeValue === 'number' || parseInt(badgeValue)) {
121
+ if (Math.sign(badgeValue) === 1 || Math.sign(badgeValue) === 0) {
122
+ return badgeValue > 99 ? getIcon().max : badgeValue;
120
123
  } else {
121
- return value < -99 ? getIcon().min : isTrailing ? Math.abs(value) + '-' : value;
124
+ return badgeValue < -99 ? getIcon().min : isTrailing ? Math.abs(badgeValue) + '-' : badgeValue;
122
125
  }
123
126
  }
124
127
  };
125
128
  return /*#__PURE__*/jsxs(NotificationBadgeRootStyle, {
126
129
  children: [children, /*#__PURE__*/jsx(NotificationBadgeStyle, {
127
130
  ...props,
128
- children: props.value && getValue()
131
+ variant: variant === 'dot' ? 'important' : variant,
132
+ dot: dot || variant === 'dot',
133
+ children: value && getValue()
129
134
  })]
130
135
  });
131
136
  };
@@ -140,7 +145,7 @@ NotificationBadge.defaultProps = {
140
145
  NotificationBadge.propTypes = {
141
146
  anchorHorizontal: PropTypes.oneOf(['left', 'right']),
142
147
  anchorVertical: PropTypes.oneOf(['top', 'bottom']),
143
- variant: PropTypes.oneOf(['info', 'important', 'warning', 'success', 'alpha']),
148
+ variant: PropTypes.oneOf(['info', 'important', 'warning', 'success', 'alpha', 'dot']),
144
149
  variantIcon: PropTypes.oneOf(['leading', 'trailing']),
145
150
  value: PropTypes.number,
146
151
  dot: PropTypes.bool
@@ -6,12 +6,11 @@ import { jsxs, jsx } from 'react/jsx-runtime';
6
6
  import React__default, { useCallback } from 'react';
7
7
  import { styled } from '../../config/stitches.config.esm.js';
8
8
  import Box from '../../layout/box/Box.esm.js';
9
- import Dialog, { DialogTrigger, DialogContent, DialogClose, DialogTitle, DialogPortal } from '../dialog/Dialog.esm.js';
9
+ import Dialog, { DialogTrigger, DialogContent, DialogClose, DialogTitle, DialogDescription, DialogPortal } from '../dialog/Dialog.esm.js';
10
10
  import Heading from '../heading/Heading.esm.js';
11
11
  import { Image } from '../image/Image.esm.js';
12
12
  import 'core-js/modules/es.iterator.filter.js';
13
13
  import 'core-js/modules/es.iterator.reduce.js';
14
- import 'react-i18next';
15
14
  import 'core-js/modules/es.array.includes.js';
16
15
  import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
17
16
  import { CloseOutline } from '@majoo-ui/icons';
@@ -21,6 +20,8 @@ const PageDialogFooter = styled('div');
21
20
  PageDialogFooter.displayName = 'PageDialogFooter';
22
21
  const PageDialogTitle = styled('div');
23
22
  PageDialogTitle.displayName = 'PageDialogTitle';
23
+ const PageDialogDescription = styled('div');
24
+ PageDialogDescription.displayName = 'PageDialogDescription';
24
25
  const PageDialogContent = styled('div', {});
25
26
  PageDialogContent.displayName = 'PageDialogContent';
26
27
  const PageDialogTrigger = styled('div');
@@ -92,6 +93,7 @@ const PageDialog = props => {
92
93
  const childArray = React__default.Children.toArray(children);
93
94
  const footerChildren = findNodeChild(childArray, 'PageDialogFooter');
94
95
  const headerTitle = findNodeChild(childArray, 'PageDialogTitle');
96
+ const pageDialogDescription = findNodeChild(childArray, 'PageDialogDescription');
95
97
  const pageDialogChildren = findNodeChild(childArray, 'PageDialogContent');
96
98
  const pageDialogTrigger = findNodeChild(childArray, 'PageDialogTrigger');
97
99
  const autoQuery = useMediaQuery('(max-width: 767px)');
@@ -123,14 +125,17 @@ const PageDialog = props => {
123
125
  wrapper: _child => jsx(DialogPortal, {
124
126
  children: _child
125
127
  }),
126
- children: jsx(DialogContent, {
128
+ children: jsx(DialogContent, Object.assign({
127
129
  size: size,
128
130
  css: Object.assign(Object.assign({}, css), {
129
131
  height: '100%',
130
132
  minHeight: 'unset',
131
133
  zIndex: layer
132
134
  }),
133
- ref: ref,
135
+ ref: ref
136
+ }, pageDialogDescription ? {} : {
137
+ 'aria-describedby': undefined
138
+ }, {
134
139
  onOpenAutoFocus: e => {
135
140
  if (!onOpenAutoFocus) {
136
141
  e.preventDefault();
@@ -216,7 +221,7 @@ const PageDialog = props => {
216
221
  as: "p",
217
222
  heading: "pageTitle"
218
223
  }, headerTitle.props))
219
- }), isMobile && jsx(ConditionalWrapper, {
224
+ }), pageDialogDescription && jsx(DialogDescription, Object.assign({}, pageDialogDescription.props)), isMobile && jsx(ConditionalWrapper, {
220
225
  condition: !disabledCloseButton,
221
226
  wrapper: children => jsx(DialogClose, {
222
227
  asChild: true,
@@ -279,12 +284,13 @@ const PageDialog = props => {
279
284
  }, footerChildren.props.css)
280
285
  }))]
281
286
  })
282
- })
287
+ }))
283
288
  })]
284
289
  }));
285
290
  };
286
291
  PageDialog.Trigger = PageDialogTrigger;
287
292
  PageDialog.Title = PageDialogTitle;
293
+ PageDialog.Description = PageDialogDescription;
288
294
  PageDialog.Content = PageDialogContent;
289
295
  PageDialog.Footer = PageDialogFooter;
290
296
  PageDialog.defaultProps = {
@@ -292,4 +298,4 @@ PageDialog.defaultProps = {
292
298
  layer: '$modal'
293
299
  };
294
300
 
295
- export { PageDialog, PageDialogContent, PageDialogFooter, PageDialogTitle, PageDialogTrigger };
301
+ export { PageDialog, PageDialogContent, PageDialogDescription, PageDialogFooter, PageDialogTitle, PageDialogTrigger };
@@ -129,6 +129,7 @@ const PaginationButton = ({
129
129
  }
130
130
  }, [currentPage]);
131
131
  const debouncedGoToPage = useCallback(debounce(handleSelectPage, 1000), [totalPages]);
132
+ useEffect(() => () => debouncedGoToPage.cancel(), [debouncedGoToPage]);
132
133
  const generatePages = () => {
133
134
  const maxButtons = isLg ? currentPage < 3 ? 3 : currentPage >= 4 ? currentPage > totalPages - 2 ? 3 : 1 : 2 : 5;
134
135
  const pageButtons = [];
@@ -260,7 +260,7 @@ const PieChart = ({
260
260
  align: (legend === null || legend === void 0 ? void 0 : legend.position) || 'right',
261
261
  layout: 'vertical'
262
262
  }, {
263
- content: renderLegend(formattedData, legend, subtitle)
263
+ content: () => renderLegend(formattedData, legend, subtitle)
264
264
  }))]
265
265
  })
266
266
  })
@@ -1,4 +1,4 @@
1
- import { useFloating, autoUpdate, useInteractions, useClick, useDismiss, FloatingFocusManager, FloatingPortal } from '@floating-ui/react';
1
+ import { useFloating, autoUpdate, useInteractions, useClick, useDismiss, FloatingFocusManager, FloatingPortal, useMergeRefs } from '@floating-ui/react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useState, useEffect, useContext, cloneElement, createContext } from 'react';
4
4
  import Flex from '../../layout/flex/Flex.esm.js';
@@ -75,8 +75,9 @@ const PopoverTrigger = ({
75
75
  },
76
76
  getReferenceProps
77
77
  } = useContext(PopoverContext);
78
+ const mergedRef = useMergeRefs([refs.setReference, children.ref]);
78
79
  return disabled ? children : /*#__PURE__*/cloneElement(children, getReferenceProps({
79
- ref: refs.setReference,
80
+ ref: mergedRef,
80
81
  ...children.props
81
82
  }));
82
83
  };
@@ -49,7 +49,7 @@ const Status = styled('div', {
49
49
  }
50
50
  }
51
51
  });
52
- const Title = styled('p', {
52
+ const Title = styled('div', {
53
53
  fontStyle: 'normal',
54
54
  fontSize: 14,
55
55
  color: '$textPrimary',
@@ -9,7 +9,7 @@ import Box from '../../layout/box/Box.esm.js';
9
9
  import Flex from '../../layout/flex/Flex.esm.js';
10
10
  import { Card } from '../card/Card.esm.js';
11
11
  import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
+ import { jsx, jsxs } from 'react/jsx-runtime';
13
13
  import Tooltip from '../tooltip/Tooltip.esm.js';
14
14
  import { Tag } from '../tag/Tag.esm.js';
15
15
 
@@ -177,7 +177,7 @@ const Navigation = props => {
177
177
  children: "Coming Soon"
178
178
  })
179
179
  })]
180
- }, `step-${i}`)) : stepItems.push(/*#__PURE__*/jsxs(Fragment, {
180
+ }, `step-${i}`)) : stepItems.push(/*#__PURE__*/jsxs(React__default.Fragment, {
181
181
  children: [isActive && /*#__PURE__*/jsx(Box, {
182
182
  css: {
183
183
  position: 'absolute',
@@ -274,7 +274,7 @@ const Navigation = props => {
274
274
  active: isComplete && !hideCheckedIcon
275
275
  })]
276
276
  })]
277
- }));
277
+ }, `step-${i}`));
278
278
  }
279
279
  }
280
280
  return /*#__PURE__*/jsx(ConditionalWrapper, {
@@ -432,7 +432,7 @@ const Default = props => {
432
432
  children: /*#__PURE__*/jsx(Stepper, {
433
433
  ...props,
434
434
  transitions: transitions,
435
- className: !props.isMobile && 'stepperInstance',
435
+ className: !props.isMobile ? 'stepperInstance' : undefined,
436
436
  instance: setInstance,
437
437
  nav: /*#__PURE__*/jsx(Navigation, {
438
438
  onNavClicked: props.onNavClicked,
@@ -309,7 +309,7 @@ const MobileTable = /*#__PURE__*/React__default.forwardRef(({
309
309
  handleRowClick(row, i);
310
310
  }
311
311
  },
312
- children: jsx(Paragraph, {
312
+ children: jsx(Box, {
313
313
  css: {
314
314
  overflowX: 'hidden',
315
315
  textOverflow: 'ellipsis',
@@ -387,7 +387,9 @@ const MobileTable = /*#__PURE__*/React__default.forwardRef(({
387
387
  backgroundColor: '$bgGray',
388
388
  paddingRight: '$spacing-04'
389
389
  },
390
- children: actionCells.map(cell => cell.render('Cell'))
390
+ children: actionCells.map(cell => jsx(React__default.Fragment, {
391
+ children: cell.render('Cell')
392
+ }, cell.column.id))
391
393
  })]
392
394
  })
393
395
  }) : null]
@@ -1,7 +1,6 @@
1
- import React__default, { useState, useRef, useLayoutEffect } from 'react';
1
+ import React__default, { useState, useContext, useRef, useLayoutEffect } from 'react';
2
2
  import * as TabsPrimitive from '@radix-ui/react-tabs';
3
3
  import { colors, styled } from '../../config/stitches.config.esm.js';
4
- import { addPropsToChildren } from '../../utils/element.esm.js';
5
4
  import Box from '../../layout/box/Box.esm.js';
6
5
  import Flex from '../../layout/flex/Flex.esm.js';
7
6
  import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
@@ -154,19 +153,26 @@ const ScrollButtonContainer = styled(Box, {
154
153
  }
155
154
  }
156
155
  });
156
+
157
+ // The active value reaches TabsList and TabsTrigger through context rather than being cloned
158
+ // onto the direct children, so a TabsList may sit inside any wrapper and no element receives
159
+ // an `activeTabs` attribute it does not understand.
160
+ const ActiveTabsContext = /*#__PURE__*/React__default.createContext(undefined);
157
161
  const Tabs = ({
158
162
  children,
159
163
  ...props
160
164
  }) => {
161
- const [activeTabs, setActiveTabs] = useState(props.defaultValue || '');
165
+ const [uncontrolledActiveTabs, setActiveTabs] = useState(props.defaultValue || '');
166
+ const activeTabs = props.value !== undefined ? props.value : uncontrolledActiveTabs;
162
167
  return /*#__PURE__*/jsx(StyledTabs, {
163
168
  ...props,
164
169
  onValueChange: value => {
165
170
  setActiveTabs(value);
166
171
  if (props.onValueChange) props.onValueChange(value);
167
172
  },
168
- children: addPropsToChildren(children, {
169
- activeTabs
173
+ children: /*#__PURE__*/jsx(ActiveTabsContext.Provider, {
174
+ value: activeTabs,
175
+ children: children
170
176
  })
171
177
  });
172
178
  };
@@ -180,9 +186,11 @@ Tabs.propTypes = {
180
186
  };
181
187
  const TabsList = ({
182
188
  children,
183
- activeTabs,
189
+ activeTabs: activeTabsProp,
184
190
  ...props
185
191
  }) => {
192
+ const contextActiveTabs = useContext(ActiveTabsContext);
193
+ const activeTabs = activeTabsProp !== undefined ? activeTabsProp : contextActiveTabs;
186
194
  const [listContainerScrollPosition, setlistContainerScrollPosition] = useState(0);
187
195
  const [scrollAreaWidth, setScrollAreaWidth] = useState(0);
188
196
  const listContainerRef = useRef();
@@ -199,8 +207,9 @@ const TabsList = ({
199
207
  ...props,
200
208
  ref: listContainerRef,
201
209
  onScroll: e => setlistContainerScrollPosition(e.target.scrollLeft),
202
- children: addPropsToChildren(children, {
203
- activeTabs
210
+ children: /*#__PURE__*/jsx(ActiveTabsContext.Provider, {
211
+ value: activeTabs,
212
+ children: children
204
213
  })
205
214
  }), listContainerScrollPosition > 10 && /*#__PURE__*/jsx(ScrollButtonContainer, {
206
215
  position: "left",
@@ -234,10 +243,12 @@ const TabsList = ({
234
243
  const TabsTrigger = ({
235
244
  children,
236
245
  icon,
237
- activeTabs,
246
+ activeTabs: activeTabsProp,
238
247
  value,
239
248
  ...props
240
249
  }) => {
250
+ const contextActiveTabs = useContext(ActiveTabsContext);
251
+ const activeTabs = activeTabsProp !== undefined ? activeTabsProp : contextActiveTabs;
241
252
  const [isIconHovered, setIsIconHovered] = useState(false);
242
253
  return /*#__PURE__*/jsx(StyledTrigger, {
243
254
  value: value,
@@ -266,7 +277,7 @@ const TabsTrigger = ({
266
277
  };
267
278
  TabsTrigger.propTypes = {
268
279
  value: PropTypes.string,
269
- icon: PropTypes.func,
280
+ icon: PropTypes.element,
270
281
  size: PropTypes.oneOf(['sm', 'md', 'lg'])
271
282
  };
272
283
  const TabsContent = ({
@@ -1,4 +1,4 @@
1
- import { useState } from 'react';
1
+ import { useState, useRef, useEffect } from 'react';
2
2
  import { styled, keyframes } from '../../config/stitches.config.esm.js';
3
3
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
4
4
  import { foundations } from '@majoo-ui/core';
@@ -121,6 +121,8 @@ const Tooltip = ({
121
121
  ...rest
122
122
  }) => {
123
123
  const [open, setOpen] = useState(false);
124
+ const closeTimeoutRef = useRef(null);
125
+ useEffect(() => () => clearTimeout(closeTimeoutRef.current), []);
124
126
  return /*#__PURE__*/jsx(Provider, {
125
127
  children: /*#__PURE__*/jsxs(TooltipBase, {
126
128
  ...rest,
@@ -144,9 +146,12 @@ const Tooltip = ({
144
146
  ...ligth,
145
147
  ...css
146
148
  },
147
- onPointerDownOutside: () => setTimeout(() => {
148
- setOpen(false);
149
- }, 200),
149
+ onPointerDownOutside: () => {
150
+ clearTimeout(closeTimeoutRef.current);
151
+ closeTimeoutRef.current = setTimeout(() => {
152
+ setOpen(false);
153
+ }, 200);
154
+ },
150
155
  children: [label, /*#__PURE__*/jsx(StyledArrow, {
151
156
  offset: 10,
152
157
  css: color === 'dark' ? darkArrow : lightArrow
@@ -185,6 +185,9 @@ const Upload = ({
185
185
  const indexReplace = useRef(null);
186
186
  const modalTrigger = useRef(null);
187
187
  const hiddenFileInput = useRef(null);
188
+ const mountedRef = useRef(true);
189
+ const cropTimeoutRef = useRef(null);
190
+ const loadingTimeoutRef = useRef(null);
188
191
  const [dragActive, setDragActive] = useState(false);
189
192
  const [previewImage, setPreviewImage] = useState('');
190
193
  const [fileState, setFileState] = useState({});
@@ -194,6 +197,14 @@ const Upload = ({
194
197
  const [aspect, setAspect] = useState(isDefaultCustomRatio ? 0 : 1);
195
198
  const [isLoading, setIsLoading] = useState(false);
196
199
  const [cropperImgRatio, setCropperImgRatio] = useState(null);
200
+ useEffect(() => () => {
201
+ mountedRef.current = false;
202
+ clearTimeout(cropTimeoutRef.current);
203
+ clearTimeout(loadingTimeoutRef.current);
204
+ }, []);
205
+ const updateError = message => {
206
+ if (mountedRef.current) setError(message);
207
+ };
197
208
  const isMobile = useMediaQuery('(max-width: 767px)');
198
209
  useEffect(() => {
199
210
  if (loading) {
@@ -204,12 +215,7 @@ const Upload = ({
204
215
  }
205
216
  }, [loading, progress]);
206
217
  useEffect(() => {
207
- if (errorMessage && typeof errorMessage === 'string') {
208
- setError(errorMessage);
209
- }
210
- return () => {
211
- setError(null);
212
- };
218
+ setError(errorMessage && typeof errorMessage === 'string' ? errorMessage : null);
213
219
  }, [errorMessage]);
214
220
  const ContainerUpload = styled('div', {
215
221
  border: '2px dashed $gray300',
@@ -369,7 +375,7 @@ const Upload = ({
369
375
  file: fileProgress,
370
376
  indexReplace: indexReplace.current,
371
377
  isReplace: indexReplace.current !== null
372
- })?.then(() => setError(null))?.catch(error => setError(error.message));
378
+ })?.then(() => updateError(null))?.catch(error => updateError(error.message));
373
379
  }
374
380
  }).then(result => {
375
381
  let fileSuccess = {
@@ -394,7 +400,7 @@ const Upload = ({
394
400
  file: fileSuccess,
395
401
  indexReplace: indexReplace.current,
396
402
  isReplace: indexReplace.current !== null
397
- })?.then(() => setError(null))?.catch(error => setError(error.message));
403
+ })?.then(() => updateError(null))?.catch(error => updateError(error.message));
398
404
  }).catch(error => {
399
405
  let fileError = {
400
406
  ...newFile
@@ -418,7 +424,7 @@ const Upload = ({
418
424
  file: fileError,
419
425
  indexReplace: indexReplace.current,
420
426
  isReplace: indexReplace.current !== null
421
- })?.then(() => setError(null))?.catch(error => setError(error.message));
427
+ })?.then(() => updateError(null))?.catch(error => updateError(error.message));
422
428
  });
423
429
  } else {
424
430
  onChange?.({
@@ -426,7 +432,7 @@ const Upload = ({
426
432
  file: newFile,
427
433
  indexReplace: indexReplace.current,
428
434
  isReplace: indexReplace.current !== null
429
- })?.then(() => setError(null))?.catch(error => setError(error.message));
435
+ })?.then(() => updateError(null))?.catch(error => updateError(error.message));
430
436
  }
431
437
  if (indexReplace.current !== null) {
432
438
  arrFile[indexReplace.current] = newFile;
@@ -448,14 +454,17 @@ const Upload = ({
448
454
  img.size = files?.[0]?.size;
449
455
  img.type = files?.[0]?.type;
450
456
  img.onload = () => {
457
+ if (!mountedRef.current) return;
451
458
  const imgRatio = img.width / img.height;
452
459
  // setAspect(imgRatio);
453
460
  setCropperImgRatio(imgRatio);
454
461
  if (onBeforeCrop) {
455
462
  onBeforeCrop?.(img)?.then(() => {
456
- setError(null);
463
+ updateError(null);
457
464
  toggleModal();
458
- setTimeout(() => {
465
+ clearTimeout(cropTimeoutRef.current);
466
+ cropTimeoutRef.current = setTimeout(() => {
467
+ if (!mountedRef.current) return;
459
468
  if (imgRef.current) {
460
469
  const {
461
470
  width,
@@ -466,10 +475,12 @@ const Upload = ({
466
475
  }, 300);
467
476
  setFileState(files[0]);
468
477
  setPreviewImage(URL.createObjectURL(files[0]));
469
- })?.catch(error => setError(error?.message));
478
+ })?.catch(error => updateError(error?.message));
470
479
  } else {
471
480
  toggleModal();
472
- setTimeout(() => {
481
+ clearTimeout(cropTimeoutRef.current);
482
+ cropTimeoutRef.current = setTimeout(() => {
483
+ if (!mountedRef.current) return;
473
484
  if (imgRef.current) {
474
485
  const {
475
486
  width,
@@ -483,7 +494,8 @@ const Upload = ({
483
494
  }
484
495
  };
485
496
  img.onerror = error => {
486
- onBeforeCrop?.(img, error)?.then(() => setError(null))?.catch(error => setError(error?.message));
497
+ if (!mountedRef.current) return;
498
+ onBeforeCrop?.(img, error)?.then(() => updateError(null))?.catch(error => updateError(error?.message));
487
499
  };
488
500
  }
489
501
  }
@@ -621,7 +633,6 @@ const Upload = ({
621
633
  children: /*#__PURE__*/jsx(ButtonText, {
622
634
  type: "button",
623
635
  onClick: () => handleReplace(index),
624
- buttonType: "ghost",
625
636
  children: replaceLabel || 'Ubah Berkas'
626
637
  })
627
638
  });
@@ -772,7 +783,12 @@ const Upload = ({
772
783
  progress: progress,
773
784
  isAuto: !progress,
774
785
  show: loading,
775
- onCompleted: () => setTimeout(() => setIsLoading(false), 1000)
786
+ onCompleted: () => {
787
+ clearTimeout(loadingTimeoutRef.current);
788
+ loadingTimeoutRef.current = setTimeout(() => {
789
+ if (mountedRef.current) setIsLoading(false);
790
+ }, 1000);
791
+ }
776
792
  }), /*#__PURE__*/jsx(Text, {
777
793
  hidden: !progress,
778
794
  children: `${progress <= 100 ? progress : 100}%`
@@ -976,7 +992,7 @@ Upload.propTypes = {
976
992
  /**
977
993
  A custom element inside upload container.
978
994
  */
979
- children: PropTypes.element,
995
+ children: PropTypes.node,
980
996
  /**
981
997
  Limit the number of uploaded files.
982
998
  */
package/index.esm.js CHANGED
@@ -40,7 +40,7 @@ export { InputSignature } from './components/form/components/InputSignature/Inpu
40
40
  export { defaultInputSignatureLocaleText } from './components/form/components/InputSignature/locale.esm.js';
41
41
  export { Separator } from './components/separator/Separator.esm.js';
42
42
  export { default as Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from './components/dialog/Dialog.esm.js';
43
- export { default as ModalDialog, ModalDialogContent, ModalDialogFooter, ModalDialogTitle, ModalDialogTrigger } from './components/modalDialog/ModalDialog.esm.js';
43
+ export { default as ModalDialog, ModalDialogContent, ModalDialogDescription, ModalDialogFooter, ModalDialogTitle, ModalDialogTrigger } from './components/modalDialog/ModalDialog.esm.js';
44
44
  export { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from './components/accordion/Accordion.esm.js';
45
45
  export { InputDatePicker } from './components/datePicker/InputDatePicker.esm.js';
46
46
  export { ADVANCE_PICKER, DATE_RANGE_PICKER, DEFAULT, DatePicker, MONTHLY, RANGE_CONTROL, RANGE_PICKER, SINGLE_PICKER, WEEKLY } from './components/datePicker/DatePicker.esm.js';
@@ -54,7 +54,7 @@ export { defaultDatePickerLocaleText } from './components/datePicker/locale.esm.
54
54
  export { Cell, Table, TableBody, TableCell, TableColumn, TableContent, TableFoot, TableFootCell, TableFootRow, TableHead, TableHeadCellContent, TableHeaderCellContainer, TableRow, addOnCellStyle, defaultEmptyDataProps, defaultFetchDataParams } from './components/table/Table.esm.js';
55
55
  export { defaultTableLocaleText } from './components/table/locale.esm.js';
56
56
  export { default as MobileTable } from './components/table/MobileTable.esm.js';
57
- export { PageDialog, PageDialogContent, PageDialogFooter, PageDialogTitle, PageDialogTrigger } from './components/pageDialog/PageDialog.esm.js';
57
+ export { PageDialog, PageDialogContent, PageDialogDescription, PageDialogFooter, PageDialogTitle, PageDialogTrigger } from './components/pageDialog/PageDialog.esm.js';
58
58
  export { default as DevicePreview, ImageDevicePreview } from './components/devicePreview/DevicePreview.esm.js';
59
59
  export { StepWizard } from './components/stepWizard/index.esm.js';
60
60
  export { TableOfContentPage } from './components/tableOfContent/index.esm.js';