@majoo-ui/react 2.4.2 → 2.4.4
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.
- package/components/alertDialog/AlertDialog.esm.js +11 -1
- package/components/barChart/BarChart.esm.js +1 -1
- package/components/buttonGroup/ButtonGroup.esm.js +1 -0
- package/components/chart/lineChart/LineChart.esm.js +7 -10
- package/components/checkboxTable/CheckboxTable.esm.js +38 -38
- package/components/colorPicker/InputColorPicker.esm.js +5 -2
- package/components/datePicker/CustomDatePicker.esm.js +12 -3
- package/components/datePicker/InputDatePicker.esm.js +15 -6
- package/components/datePicker/InputDateRangePicker.esm.js +1 -1
- package/components/datePicker/timePicker/InputTimePicker.esm.js +6 -7
- package/components/datePicker/timePicker/TimePicker.esm.js +36 -40
- package/components/devicePreview/DevicePreview.esm.js +3 -3
- package/components/drawer/Drawer.esm.js +42 -6
- package/components/editableTable/EditableTable.esm.js +22 -5
- package/components/form/components/FormHelper/Helper.esm.js +1 -1
- package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +6 -10
- package/components/form/components/InputCombobox/InputCombobox.esm.js +6 -3
- package/components/form/components/InputCreatable/InputCreatable.esm.js +5 -6
- package/components/form/components/InputGroup/InputGroup.esm.js +8 -9
- package/components/form/components/InputNumber/InputNumber.esm.js +1 -1
- package/components/form/components/InputRadio/InputRadio.esm.js +5 -2
- package/components/form/components/InputRadio/InputRadioGroup.esm.js +12 -5
- package/components/form/components/InputResourceList/InputResourceList.esm.js +13 -7
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +9 -3
- package/components/form/components/InputSelect/InputSelect.esm.js +1 -1
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +5 -2
- package/components/form/components/InputSwitch/InputSwitch.esm.js +9 -8
- package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +9 -8
- package/components/form/components/InputTags/InputTags.esm.js +12 -11
- package/components/loadingBar/LoadingBar.esm.js +14 -8
- package/components/mapPicker/InputMapPicker.esm.js +0 -1
- package/components/modalDialog/ModalDialog.esm.js +14 -6
- package/components/notificationBadge/NotificationBadge.esm.js +12 -7
- package/components/pageDialog/PageDialog.esm.js +13 -7
- package/components/pagination/PaginationButton.esm.js +1 -0
- package/components/pieChart/PieChart.esm.js +1 -1
- package/components/popover/Popover.esm.js +3 -2
- package/components/progressIndicator/ProgressIndicator.esm.js +1 -1
- package/components/stepWizard/StepWizard.esm.js +4 -4
- package/components/table/MobileTable.esm.js +4 -2
- package/components/tabs/Tabs.esm.js +1 -1
- package/components/tooltip/Tooltip.esm.js +9 -4
- package/components/upload/Upload.esm.js +34 -18
- package/index.esm.css +4 -4
- package/index.esm.js +2 -2
- package/layout/grid/Grid.esm.js +32 -13
- package/layout/pageContainer/PageContainer.esm.js +1 -0
- package/package.json +2 -2
- package/src/components/editableTable/EditableTable.d.ts +3 -1
|
@@ -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
|
-
|
|
118
|
+
const badgeValue = value;
|
|
116
119
|
const isTrailing = variantIcon === 'trailing';
|
|
117
|
-
if (typeof
|
|
118
|
-
if (Math.sign(
|
|
119
|
-
return
|
|
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
|
|
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
|
-
|
|
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:
|
|
80
|
+
ref: mergedRef,
|
|
80
81
|
...children.props
|
|
81
82
|
}));
|
|
82
83
|
};
|
|
@@ -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
|
|
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
|
|
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(
|
|
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 =>
|
|
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,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: () =>
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
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(() =>
|
|
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(() =>
|
|
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(() =>
|
|
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(() =>
|
|
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
|
-
|
|
463
|
+
updateError(null);
|
|
457
464
|
toggleModal();
|
|
458
|
-
|
|
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 =>
|
|
478
|
+
})?.catch(error => updateError(error?.message));
|
|
470
479
|
} else {
|
|
471
480
|
toggleModal();
|
|
472
|
-
|
|
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
|
-
|
|
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: () =>
|
|
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.
|
|
995
|
+
children: PropTypes.node,
|
|
980
996
|
/**
|
|
981
997
|
Limit the number of uploaded files.
|
|
982
998
|
*/
|
package/index.esm.css
CHANGED
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';
|
package/layout/grid/Grid.esm.js
CHANGED
|
@@ -193,14 +193,24 @@ const Grid = ({
|
|
|
193
193
|
children,
|
|
194
194
|
...props
|
|
195
195
|
}) => {
|
|
196
|
+
const {
|
|
197
|
+
autoColumns,
|
|
198
|
+
autoRows,
|
|
199
|
+
autoFlow,
|
|
200
|
+
templateColumns,
|
|
201
|
+
templateRows,
|
|
202
|
+
css,
|
|
203
|
+
...domProps
|
|
204
|
+
} = props;
|
|
196
205
|
return /*#__PURE__*/jsx(GridComponent, {
|
|
197
|
-
...
|
|
206
|
+
...domProps,
|
|
198
207
|
css: {
|
|
199
|
-
...
|
|
200
|
-
gridAutoColumns:
|
|
201
|
-
gridAutoRows:
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
...css,
|
|
209
|
+
gridAutoColumns: autoColumns,
|
|
210
|
+
gridAutoRows: autoRows,
|
|
211
|
+
gridAutoFlow: autoFlow,
|
|
212
|
+
gridTemplateColumns: templateColumns,
|
|
213
|
+
gridTemplateRows: templateRows
|
|
204
214
|
},
|
|
205
215
|
children: children
|
|
206
216
|
});
|
|
@@ -243,15 +253,24 @@ const GridItem = ({
|
|
|
243
253
|
children,
|
|
244
254
|
...props
|
|
245
255
|
}) => {
|
|
256
|
+
const {
|
|
257
|
+
area,
|
|
258
|
+
colStart,
|
|
259
|
+
colEnd,
|
|
260
|
+
rowStart,
|
|
261
|
+
rowEnd,
|
|
262
|
+
css,
|
|
263
|
+
...domProps
|
|
264
|
+
} = props;
|
|
246
265
|
return /*#__PURE__*/jsx(GridItemComponent, {
|
|
247
|
-
...
|
|
266
|
+
...domProps,
|
|
248
267
|
css: {
|
|
249
|
-
...
|
|
250
|
-
gridArea:
|
|
251
|
-
gridColumnStart:
|
|
252
|
-
gridColumnEnd:
|
|
253
|
-
gridRowStart:
|
|
254
|
-
gridRowEnd:
|
|
268
|
+
...css,
|
|
269
|
+
gridArea: area,
|
|
270
|
+
gridColumnStart: colStart,
|
|
271
|
+
gridColumnEnd: colEnd,
|
|
272
|
+
gridRowStart: rowStart,
|
|
273
|
+
gridRowEnd: rowEnd
|
|
255
274
|
},
|
|
256
275
|
children: children
|
|
257
276
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@majoo-ui/react",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"main": "./index.esm.js",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@floating-ui/react": "^0.19.2",
|
|
38
38
|
"@majoo-ui/core": "1.32.0",
|
|
39
39
|
"@majoo-ui/helpers": "1.30.9",
|
|
40
|
-
"@majoo-ui/icons": "1.40.
|
|
40
|
+
"@majoo-ui/icons": "1.40.5",
|
|
41
41
|
"@monsonjeremy/react-leaflet": "^3.2.2",
|
|
42
42
|
"@radix-ui/react-accordion": "^1.0.0",
|
|
43
43
|
"@radix-ui/react-alert-dialog": "^1.0.3",
|
|
@@ -210,7 +210,7 @@ declare namespace EditableTable {
|
|
|
210
210
|
backgroundColor: string;
|
|
211
211
|
};
|
|
212
212
|
}>>;
|
|
213
|
-
var Switch:
|
|
213
|
+
var Switch: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<HTMLButtonElement>>;
|
|
214
214
|
var Remove: (props: RemoveProps) => JSX.Element;
|
|
215
215
|
var TableRow: import("@stitches/react/types/styled-component").StyledComponent<"tr", {
|
|
216
216
|
subRow?: boolean | "true" | undefined;
|
|
@@ -319,6 +319,8 @@ declare namespace EditableTable {
|
|
|
319
319
|
};
|
|
320
320
|
}>>;
|
|
321
321
|
var TableCell: import("@stitches/react/types/styled-component").StyledComponent<"td", {
|
|
322
|
+
subCell?: boolean | "true" | undefined;
|
|
323
|
+
headerSubCell?: boolean | "true" | undefined;
|
|
322
324
|
verticalAlign?: "bottom" | "top" | "middle" | undefined;
|
|
323
325
|
}, {
|
|
324
326
|
sm: "(min-width: 359px)";
|