@majoo-ui/react 2.4.3 → 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 +32 -38
- 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
|
@@ -446,7 +446,17 @@ const AlertDialogRoot = ADialog.Root;
|
|
|
446
446
|
const AlertDialogTrigger = ADialog.Trigger;
|
|
447
447
|
const AlertDialogContent = Content;
|
|
448
448
|
const AlertDialogTitle = StyledTitle;
|
|
449
|
-
const AlertDialogDescription =
|
|
449
|
+
const AlertDialogDescription = /*#__PURE__*/forwardRef(({
|
|
450
|
+
children,
|
|
451
|
+
...props
|
|
452
|
+
}, ref) => /*#__PURE__*/jsx(ADialog.Description, {
|
|
453
|
+
asChild: true,
|
|
454
|
+
children: /*#__PURE__*/jsx(StyledDescription, {
|
|
455
|
+
ref: ref,
|
|
456
|
+
...props,
|
|
457
|
+
children: children
|
|
458
|
+
})
|
|
459
|
+
}));
|
|
450
460
|
const AlertDialogCancel = ADialog.Cancel;
|
|
451
461
|
const AlertDialogConfirm = ADialog.Action;
|
|
452
462
|
|
|
@@ -174,7 +174,7 @@ function BarChartComponent({
|
|
|
174
174
|
},
|
|
175
175
|
content: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.render) ? (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.render) === null || _a === void 0 ? void 0 : _a.call(tooltip) : jsx(CustomTooltip, {})
|
|
176
176
|
}), (legend === null || legend === void 0 ? void 0 : legend.show) && jsx(Legend, {
|
|
177
|
-
content: renderLegend(formattedData, legend, subtitle, tickFormatter)
|
|
177
|
+
content: () => renderLegend(formattedData, legend, subtitle, tickFormatter)
|
|
178
178
|
}), jsxs(Bar, {
|
|
179
179
|
dataKey: "total",
|
|
180
180
|
barSize: 12,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.flat-map.js';
|
|
2
3
|
import 'core-js/modules/es.iterator.map.js';
|
|
3
4
|
import 'core-js/modules/es.iterator.some.js';
|
|
4
5
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
6
|
import { foundations } from '@majoo-ui/core';
|
|
6
|
-
import { useState, useEffect } from 'react';
|
|
7
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
7
8
|
import { ResponsiveContainer, LineChart as LineChart$1, XAxis, YAxis, CartesianGrid, Tooltip, Line } from 'recharts';
|
|
8
9
|
import { Image } from '../../image/Image.esm.js';
|
|
9
10
|
import 'core-js/modules/es.iterator.filter.js';
|
|
10
11
|
import 'core-js/modules/es.iterator.reduce.js';
|
|
11
|
-
import 'react-i18next';
|
|
12
12
|
import 'core-js/modules/es.array.includes.js';
|
|
13
13
|
import Text from '../../text/Text.esm.js';
|
|
14
14
|
import { styled } from '../../../config/stitches.config.esm.js';
|
|
@@ -142,16 +142,14 @@ function LineChart(props) {
|
|
|
142
142
|
onComparatorChange,
|
|
143
143
|
customTooltipDate
|
|
144
144
|
} = props;
|
|
145
|
-
const [isDividedByThousand, setIsDividedByThousand] = useState(false);
|
|
146
145
|
const [isComparator, setIsComparator] = useState(false);
|
|
147
146
|
const [hover, setHover] = useState(null);
|
|
148
147
|
const [filteredData, setFilteredData] = useState([]);
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}, [maxData]);
|
|
148
|
+
const maxData = useMemo(() => Math.max(0, ...data.flatMap(item => legendData.map(legend => {
|
|
149
|
+
const value = Number(item[legend.dataKey]);
|
|
150
|
+
return Number.isFinite(value) ? value : 0;
|
|
151
|
+
}))), [data, legendData]);
|
|
152
|
+
const isDividedByThousand = String(Math.round(maxData)).length > 10;
|
|
155
153
|
useEffect(() => {
|
|
156
154
|
setFilteredData(legendData.map(value => Object.assign(Object.assign({}, value), {
|
|
157
155
|
hide: false,
|
|
@@ -259,7 +257,6 @@ function LineChart(props) {
|
|
|
259
257
|
return compactCurrency(val);
|
|
260
258
|
},
|
|
261
259
|
domain: [dataMin => dataMin < 0 ? roundDown(dataMin) : 0, dataMax => {
|
|
262
|
-
setMaxData(dataMax);
|
|
263
260
|
return roundUpYAxis ? roundUp(dataMax) : dataMax;
|
|
264
261
|
}]
|
|
265
262
|
}), jsx(CartesianGrid, {
|
|
@@ -156,48 +156,48 @@ function CheckboxTable(props) {
|
|
|
156
156
|
})
|
|
157
157
|
}), jsx(TableBody, Object.assign({}, getTableBodyProps(), {
|
|
158
158
|
children: rows === null || rows === void 0 ? void 0 : rows.map((row, index) => {
|
|
159
|
-
var _a, _b, _c;
|
|
159
|
+
var _a, _b, _c, _d;
|
|
160
160
|
prepareRow(row);
|
|
161
161
|
const originalRow = row.original;
|
|
162
162
|
return jsxs(React__default.Fragment, {
|
|
163
|
-
children: [
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
maxWidth: column.maxWidth
|
|
174
|
-
}
|
|
175
|
-
}), {
|
|
176
|
-
key: index + indexCell + 'tb-cell',
|
|
177
|
-
css: {
|
|
178
|
-
'@md': {
|
|
179
|
-
height: rowHeight
|
|
163
|
+
children: [jsx(TableRow, Object.assign({}, row.getRowProps(), {
|
|
164
|
+
children: (_b = (_a = row === null || row === void 0 ? void 0 : row.cells) === null || _a === void 0 ? void 0 : _a.filter(cell => !cell.column.isSubRow)) === null || _b === void 0 ? void 0 : _b.map((cell, indexCell) => {
|
|
165
|
+
var _a;
|
|
166
|
+
const column = cell.column;
|
|
167
|
+
const originalCell = cell.row.original;
|
|
168
|
+
return /*#__PURE__*/createElement(TableCell, Object.assign({}, cell.getCellProps({
|
|
169
|
+
style: {
|
|
170
|
+
minWidth: column.minWidth,
|
|
171
|
+
width: column.width,
|
|
172
|
+
maxWidth: column.maxWidth
|
|
180
173
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
align: align,
|
|
184
|
-
children: [indexCell === 0 && jsx(Flex, {
|
|
185
|
-
justify: "center",
|
|
186
|
-
align: "center",
|
|
174
|
+
}), {
|
|
175
|
+
key: index + indexCell + 'tb-cell',
|
|
187
176
|
css: {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none !important'
|
|
191
|
-
},
|
|
192
|
-
onClick: () => {
|
|
193
|
-
if (!Object.keys(state.expanded).includes(row.id)) {
|
|
194
|
-
toggleAllRowsExpanded(false);
|
|
177
|
+
'@md': {
|
|
178
|
+
height: rowHeight
|
|
195
179
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
180
|
+
}
|
|
181
|
+
}), jsxs(TableCellContent, {
|
|
182
|
+
align: align,
|
|
183
|
+
children: [indexCell === 0 && jsx(Flex, {
|
|
184
|
+
justify: "center",
|
|
185
|
+
align: "center",
|
|
186
|
+
css: {
|
|
187
|
+
marginRight: 12,
|
|
188
|
+
cursor: 'pointer',
|
|
189
|
+
display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none !important'
|
|
190
|
+
},
|
|
191
|
+
onClick: () => {
|
|
192
|
+
if (!Object.keys(state.expanded).includes(row.id)) {
|
|
193
|
+
toggleAllRowsExpanded(false);
|
|
194
|
+
}
|
|
195
|
+
row.toggleRowExpanded(!row.isExpanded);
|
|
196
|
+
},
|
|
197
|
+
children: row.isExpanded ? jsx(ChevronUpOutline, {}) : jsx(ChevronDownOutline, {})
|
|
198
|
+
}), cell.render('Cell')]
|
|
199
|
+
}));
|
|
200
|
+
})
|
|
201
201
|
})), (_c = originalRow === null || originalRow === void 0 ? void 0 : originalRow.detail) === null || _c === void 0 ? void 0 : _c.map((cell, index) => {
|
|
202
202
|
const id_row = originalRow === null || originalRow === void 0 ? void 0 : originalRow.id;
|
|
203
203
|
const {
|
|
@@ -207,7 +207,7 @@ function CheckboxTable(props) {
|
|
|
207
207
|
} = cell;
|
|
208
208
|
const headerRender = name;
|
|
209
209
|
return /*#__PURE__*/createElement(TableRow, Object.assign({}, row.getRowProps(), {
|
|
210
|
-
key: `row_collapse_${index}`,
|
|
210
|
+
key: `row_collapse_${id_subrow !== null && id_subrow !== void 0 ? id_subrow : index}`,
|
|
211
211
|
css: {
|
|
212
212
|
display: row.isExpanded ? 'table-row' : 'none'
|
|
213
213
|
}
|
|
@@ -266,7 +266,7 @@ function CheckboxTable(props) {
|
|
|
266
266
|
}, index + indexSubRow + 'tb-cell-collapse');
|
|
267
267
|
}));
|
|
268
268
|
})]
|
|
269
|
-
});
|
|
269
|
+
}, (_d = originalRow.id) !== null && _d !== void 0 ? _d : row.id);
|
|
270
270
|
})
|
|
271
271
|
}))]
|
|
272
272
|
})), rows.length < 1 && jsx(Flex, {
|
|
@@ -43,7 +43,8 @@ function InputColorPicker(props) {
|
|
|
43
43
|
}), /*#__PURE__*/jsx(Separator, {}), /*#__PURE__*/jsx(InputText, {
|
|
44
44
|
isPicker: true,
|
|
45
45
|
placeholder: "Select color",
|
|
46
|
-
value: getColor()
|
|
46
|
+
value: getColor(),
|
|
47
|
+
readOnly: true
|
|
47
48
|
})]
|
|
48
49
|
});
|
|
49
50
|
}
|
|
@@ -58,7 +59,9 @@ function InputColorPicker(props) {
|
|
|
58
59
|
placement: props.placement,
|
|
59
60
|
children: [/*#__PURE__*/jsx(PopoverTrigger, {
|
|
60
61
|
disabled: props.disabled,
|
|
61
|
-
children:
|
|
62
|
+
children: /*#__PURE__*/jsx(Box, {
|
|
63
|
+
children: renderInputGroup()
|
|
64
|
+
})
|
|
62
65
|
}), /*#__PURE__*/jsx(PopoverContent, {
|
|
63
66
|
isMobile: props.isMobile,
|
|
64
67
|
style: props.popoverCss,
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useState, useEffect, useReducer } from 'react';
|
|
4
4
|
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
5
|
-
import { Drawer, DrawerContent } from '../drawer/Drawer.esm.js';
|
|
5
|
+
import { Drawer, DrawerContent, DrawerTitle } from '../drawer/Drawer.esm.js';
|
|
6
6
|
import { AdvancedOption } from './AdvancedOption.esm.js';
|
|
7
7
|
import { SINGLE_PICKER, DatePicker, ADVANCE_PICKER } from './DatePicker.esm.js';
|
|
8
8
|
import { pickerReducer, UPDATE_PICKER, advancePickerOptionsId, advancePickerDate } from './state/reducer.esm.js';
|
|
@@ -107,12 +107,21 @@ function CustomDatePicker({
|
|
|
107
107
|
open: openPicker,
|
|
108
108
|
onOpenChange: handleOpenChange,
|
|
109
109
|
side: "bottom",
|
|
110
|
-
children:
|
|
110
|
+
children: jsxs(DrawerContent, {
|
|
111
111
|
css: {
|
|
112
112
|
position: 'fixed',
|
|
113
113
|
left: 0
|
|
114
114
|
},
|
|
115
|
-
children:
|
|
115
|
+
children: [jsx(DrawerTitle, {
|
|
116
|
+
style: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
width: 1,
|
|
119
|
+
height: 1,
|
|
120
|
+
overflow: 'hidden',
|
|
121
|
+
clip: 'rect(0 0 0 0)'
|
|
122
|
+
},
|
|
123
|
+
children: "Pilih tanggal"
|
|
124
|
+
}), renderDatePicker()]
|
|
116
125
|
})
|
|
117
126
|
})]
|
|
118
127
|
});
|
|
@@ -3,7 +3,7 @@ import { useState, useEffect, useReducer } from 'react';
|
|
|
3
3
|
import { CalendarOutline } from '@majoo-ui/icons';
|
|
4
4
|
import Box from '../../layout/box/Box.esm.js';
|
|
5
5
|
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
6
|
-
import { Drawer, DrawerContent } from '../drawer/Drawer.esm.js';
|
|
6
|
+
import { Drawer, DrawerContent, DrawerTitle } from '../drawer/Drawer.esm.js';
|
|
7
7
|
import { InputGroup } from '../form/components/InputGroup/InputGroup.esm.js';
|
|
8
8
|
import { InputLeftElement } from '../form/components/InputElement/InputElement.esm.js';
|
|
9
9
|
import { InputText } from '../form/components/InputText/InputText.esm.js';
|
|
@@ -128,7 +128,7 @@ function InputDatePicker({
|
|
|
128
128
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
129
129
|
onChange: () => {},
|
|
130
130
|
isPicker: true,
|
|
131
|
-
autoComplete: "
|
|
131
|
+
autoComplete: "off"
|
|
132
132
|
})]
|
|
133
133
|
});
|
|
134
134
|
} else {
|
|
@@ -244,8 +244,8 @@ function InputDatePicker({
|
|
|
244
244
|
})
|
|
245
245
|
}),
|
|
246
246
|
children: jsx(PopoverTrigger, {
|
|
247
|
-
children:
|
|
248
|
-
css: css,
|
|
247
|
+
children: jsx(Box, {
|
|
248
|
+
css: showRangeControl ? undefined : css,
|
|
249
249
|
children: renderInputGroup()
|
|
250
250
|
})
|
|
251
251
|
})
|
|
@@ -278,12 +278,21 @@ function InputDatePicker({
|
|
|
278
278
|
side: "bottom",
|
|
279
279
|
portalled: portalledMobile,
|
|
280
280
|
css: drawerCss,
|
|
281
|
-
children:
|
|
281
|
+
children: jsxs(DrawerContent, {
|
|
282
282
|
size: "full",
|
|
283
283
|
css: Object.assign(Object.assign({}, drawerContentCss), {
|
|
284
284
|
height: 'unset !important'
|
|
285
285
|
}),
|
|
286
|
-
children:
|
|
286
|
+
children: [jsx(DrawerTitle, {
|
|
287
|
+
style: {
|
|
288
|
+
position: 'absolute',
|
|
289
|
+
width: 1,
|
|
290
|
+
height: 1,
|
|
291
|
+
overflow: 'hidden',
|
|
292
|
+
clip: 'rect(0 0 0 0)'
|
|
293
|
+
},
|
|
294
|
+
children: t('label.selectDate', 'Pilih tanggal')
|
|
295
|
+
}), renderDatePicker()]
|
|
287
296
|
})
|
|
288
297
|
})]
|
|
289
298
|
});
|
|
@@ -56,13 +56,12 @@ function InputTimePicker({
|
|
|
56
56
|
})
|
|
57
57
|
}), /*#__PURE__*/jsx(InputText, {
|
|
58
58
|
placeholder: placeholder,
|
|
59
|
-
value: getInputPickerValue(value),
|
|
60
|
-
defaultValue: defaultValue,
|
|
59
|
+
value: getInputPickerValue(value ?? defaultValue) ?? '',
|
|
61
60
|
onChange: () => {
|
|
62
61
|
/* noop: read-only picker input, value set via picker */
|
|
63
62
|
},
|
|
64
63
|
isPicker: true,
|
|
65
|
-
autoComplete: "
|
|
64
|
+
autoComplete: "off",
|
|
66
65
|
readOnly: true
|
|
67
66
|
// tabIndex="-1"
|
|
68
67
|
})]
|
|
@@ -162,11 +161,11 @@ InputTimePicker.propTypes = {
|
|
|
162
161
|
/**
|
|
163
162
|
Time picker default value, support moment format.
|
|
164
163
|
*/
|
|
165
|
-
defaultValue: PropTypes.instanceOf(Date),
|
|
164
|
+
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
166
165
|
/**
|
|
167
166
|
Time picker value, support moment format.
|
|
168
167
|
*/
|
|
169
|
-
value: PropTypes.instanceOf(Date),
|
|
168
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
170
169
|
/**
|
|
171
170
|
Change handler.
|
|
172
171
|
*/
|
|
@@ -178,11 +177,11 @@ InputTimePicker.propTypes = {
|
|
|
178
177
|
/**
|
|
179
178
|
Specify the minimum date.
|
|
180
179
|
*/
|
|
181
|
-
minDate: PropTypes.instanceOf(Date),
|
|
180
|
+
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
182
181
|
/**
|
|
183
182
|
Specify the maximum date.
|
|
184
183
|
*/
|
|
185
|
-
maxDate: PropTypes.instanceOf(Date),
|
|
184
|
+
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
186
185
|
/**
|
|
187
186
|
* Invalid state input.
|
|
188
187
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
import { styled } from '../../../config/stitches.config.esm.js';
|
|
3
3
|
import { ChevronUpOutline, ChevronDownOutline } from '@majoo-ui/icons';
|
|
4
4
|
import Box from '../../../layout/box/Box.esm.js';
|
|
@@ -165,7 +165,8 @@ const NativeTimePicker = ({
|
|
|
165
165
|
}) => {
|
|
166
166
|
const [date, setDate] = useState(value ? value : defaultValue ? defaultValue : moment());
|
|
167
167
|
const format = 'HH:mm';
|
|
168
|
-
|
|
168
|
+
// raw text of the field being typed in, so a half-typed value isn't reformatted mid-keystroke
|
|
169
|
+
const [draft, setDraft] = useState(null);
|
|
169
170
|
function handleChange(e) {
|
|
170
171
|
onChange(e, moment(e).format(format));
|
|
171
172
|
}
|
|
@@ -207,53 +208,51 @@ const NativeTimePicker = ({
|
|
|
207
208
|
const minLength = value?.length > 1;
|
|
208
209
|
const hourValue = params => moment(moment(`${moment(date).format('DD:MM:YYYY:mm')}:${params}`, 'DD:MM:YYYY:mm:HH').toDate());
|
|
209
210
|
const minuteValue = params => moment(moment(`${moment(date).format('DD:MM:YYYY:HH')}:${params}`, 'DD:MM:YYYY:HH:mm').toDate());
|
|
211
|
+
const clampDate = newDate => {
|
|
212
|
+
setDraft(null);
|
|
213
|
+
setNewDate(newDate);
|
|
214
|
+
};
|
|
210
215
|
if (!disabled) {
|
|
216
|
+
setDraft({
|
|
217
|
+
type,
|
|
218
|
+
value
|
|
219
|
+
});
|
|
211
220
|
if (type === 'hour') {
|
|
212
221
|
if (value < 0 && minLength) {
|
|
213
|
-
|
|
214
|
-
inputRef.current = false;
|
|
222
|
+
clampDate(minDate || hourValue(0));
|
|
215
223
|
return;
|
|
216
224
|
}
|
|
217
225
|
if (value > 23 && minLength) {
|
|
218
|
-
|
|
219
|
-
inputRef.current = false;
|
|
226
|
+
clampDate(maxDate || hourValue(23));
|
|
220
227
|
return;
|
|
221
228
|
}
|
|
222
229
|
if (minDate && hourValue(value) < moment(minDate) && minLength) {
|
|
223
|
-
|
|
224
|
-
inputRef.current = false;
|
|
230
|
+
clampDate(minDate);
|
|
225
231
|
return;
|
|
226
232
|
}
|
|
227
233
|
if (maxDate && hourValue(value) > moment(maxDate) && minLength) {
|
|
228
|
-
|
|
229
|
-
inputRef.current = false;
|
|
234
|
+
clampDate(maxDate);
|
|
230
235
|
return;
|
|
231
236
|
}
|
|
232
237
|
setNewDate(moment(moment(`${moment(date).format('DD:MM:YYYY')}:${value}:${moment(date).format('mm')}`, format).toDate()));
|
|
233
|
-
inputRef.current = true;
|
|
234
238
|
} else {
|
|
235
239
|
if (value < 0 && minLength) {
|
|
236
|
-
|
|
237
|
-
inputRef.current = false;
|
|
240
|
+
clampDate(minuteValue(0));
|
|
238
241
|
return;
|
|
239
242
|
}
|
|
240
243
|
if (value > 59 && minLength) {
|
|
241
|
-
|
|
242
|
-
inputRef.current = false;
|
|
244
|
+
clampDate(minuteValue(59));
|
|
243
245
|
return;
|
|
244
246
|
}
|
|
245
247
|
if (minDate && minuteValue(value) < moment(minDate) && minLength) {
|
|
246
|
-
|
|
247
|
-
inputRef.current = false;
|
|
248
|
+
clampDate(minDate);
|
|
248
249
|
return;
|
|
249
250
|
}
|
|
250
251
|
if (maxDate && minuteValue(value) > moment(maxDate) && minLength) {
|
|
251
|
-
|
|
252
|
-
inputRef.current = false;
|
|
252
|
+
clampDate(maxDate);
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
255
|
setNewDate(moment(moment(`${moment(date).format('DD:MM:YYYY:HH')}:${value}`, format).toDate()));
|
|
256
|
-
inputRef.current = true;
|
|
257
256
|
}
|
|
258
257
|
}
|
|
259
258
|
}
|
|
@@ -281,8 +280,7 @@ const NativeTimePicker = ({
|
|
|
281
280
|
})]
|
|
282
281
|
}), /*#__PURE__*/jsx(Input, {
|
|
283
282
|
type: "time",
|
|
284
|
-
|
|
285
|
-
value: value,
|
|
283
|
+
value: moment(date).format(format),
|
|
286
284
|
onChange: handleChange
|
|
287
285
|
}), /*#__PURE__*/jsxs(Flex, {
|
|
288
286
|
gap: 1,
|
|
@@ -291,11 +289,9 @@ const NativeTimePicker = ({
|
|
|
291
289
|
maxLength: 2,
|
|
292
290
|
disabled: disabled,
|
|
293
291
|
readOnly: disabledHourIncrease || disabledHourDecrease || disabledHour,
|
|
294
|
-
|
|
295
|
-
value: !inputRef.current ? hourValue : undefined,
|
|
292
|
+
value: draft?.type === 'hour' ? draft.value : hourValue,
|
|
296
293
|
onChange: e => handleInputChange('hour', e),
|
|
297
|
-
|
|
298
|
-
onBlur: () => inputRef.current = false
|
|
294
|
+
onBlur: () => setDraft(null)
|
|
299
295
|
}), /*#__PURE__*/jsx(Time, {
|
|
300
296
|
size: size,
|
|
301
297
|
children: ":"
|
|
@@ -304,11 +300,9 @@ const NativeTimePicker = ({
|
|
|
304
300
|
maxLength: 2,
|
|
305
301
|
disabled: disabled,
|
|
306
302
|
readOnly: disabledMinuteIncrease || disabledMinuteDecrease || disabledMinute,
|
|
307
|
-
|
|
308
|
-
value: !inputRef.current ? minuteValue : undefined,
|
|
303
|
+
value: draft?.type === 'minute' ? draft.value : minuteValue,
|
|
309
304
|
onChange: e => handleInputChange('minute', e),
|
|
310
|
-
|
|
311
|
-
onBlur: () => inputRef.current = false
|
|
305
|
+
onBlur: () => setDraft(null)
|
|
312
306
|
})]
|
|
313
307
|
}), /*#__PURE__*/jsxs(Flex, {
|
|
314
308
|
direction: "row",
|
|
@@ -337,11 +331,11 @@ NativeTimePicker.propTypes = {
|
|
|
337
331
|
/**
|
|
338
332
|
Time picker default value, support moment format.
|
|
339
333
|
*/
|
|
340
|
-
defaultValue: PropTypes.instanceOf(Date),
|
|
334
|
+
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
341
335
|
/**
|
|
342
336
|
Time picker value, support moment format.
|
|
343
337
|
*/
|
|
344
|
-
value: PropTypes.instanceOf(Date),
|
|
338
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
345
339
|
/**
|
|
346
340
|
Disabled state.
|
|
347
341
|
*/
|
|
@@ -373,11 +367,11 @@ NativeTimePicker.propTypes = {
|
|
|
373
367
|
/**
|
|
374
368
|
Specify the minimum date.
|
|
375
369
|
*/
|
|
376
|
-
minDate: PropTypes.instanceOf(Date),
|
|
370
|
+
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
377
371
|
/**
|
|
378
372
|
Specify the maximum date.
|
|
379
373
|
*/
|
|
380
|
-
maxDate: PropTypes.instanceOf(Date)
|
|
374
|
+
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object])
|
|
381
375
|
};
|
|
382
376
|
const TimePicker = ({
|
|
383
377
|
size,
|
|
@@ -436,11 +430,11 @@ TimePicker.propTypes = {
|
|
|
436
430
|
/**
|
|
437
431
|
Time picker default value, support moment format.
|
|
438
432
|
*/
|
|
439
|
-
defaultValue: PropTypes.instanceOf(Date),
|
|
433
|
+
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
440
434
|
/**
|
|
441
435
|
Time picker value, support moment format.
|
|
442
436
|
*/
|
|
443
|
-
value: PropTypes.instanceOf(Date),
|
|
437
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
444
438
|
/**
|
|
445
439
|
Disabled state.
|
|
446
440
|
*/
|
|
@@ -472,11 +466,11 @@ TimePicker.propTypes = {
|
|
|
472
466
|
/**
|
|
473
467
|
Specify the minimum date.
|
|
474
468
|
*/
|
|
475
|
-
minDate: PropTypes.instanceOf(Date),
|
|
469
|
+
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]),
|
|
476
470
|
/**
|
|
477
471
|
Specify the maximum date.
|
|
478
472
|
*/
|
|
479
|
-
maxDate: PropTypes.instanceOf(Date)
|
|
473
|
+
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object])
|
|
480
474
|
};
|
|
481
475
|
NativeTimePicker.displayName = 'NativeTimePicker';
|
|
482
476
|
|
|
@@ -11,7 +11,6 @@ import Flex from '../../layout/flex/Flex.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 Paragraph from '../paragraph/Paragraph.esm.js';
|
|
17
16
|
import Text from '../text/Text.esm.js';
|
|
@@ -182,9 +181,10 @@ const DevicePreview = props => {
|
|
|
182
181
|
};
|
|
183
182
|
React.useEffect(() => {
|
|
184
183
|
if (props.withComponent || (props === null || props === void 0 ? void 0 : props.variant)) {
|
|
185
|
-
setTimeout(() => {
|
|
184
|
+
const timeout = setTimeout(() => {
|
|
186
185
|
setRender(prev => prev + 1);
|
|
187
186
|
}, 100);
|
|
187
|
+
return () => clearTimeout(timeout);
|
|
188
188
|
}
|
|
189
189
|
}, [props.withComponent, props === null || props === void 0 ? void 0 : props.variant]);
|
|
190
190
|
const renderVariant = variant => {
|
|
@@ -565,7 +565,7 @@ const DevicePreview = props => {
|
|
|
565
565
|
};
|
|
566
566
|
return jsxs(Flex, {
|
|
567
567
|
align: "center",
|
|
568
|
-
gap:
|
|
568
|
+
gap: 6,
|
|
569
569
|
children: [props.carousel && jsx(IconStyled, {
|
|
570
570
|
type: "button",
|
|
571
571
|
onClick: prevSlide,
|
|
@@ -9,6 +9,8 @@ import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
|
|
|
9
9
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
10
|
|
|
11
11
|
const Context = /*#__PURE__*/React__default.createContext();
|
|
12
|
+
// lets a DrawerDescription at any depth tell its DrawerContent that a description exists
|
|
13
|
+
const DescriptionContext = /*#__PURE__*/React__default.createContext(null);
|
|
12
14
|
const {
|
|
13
15
|
sizes
|
|
14
16
|
} = foundations;
|
|
@@ -47,11 +49,24 @@ function Drawer({
|
|
|
47
49
|
children,
|
|
48
50
|
...props
|
|
49
51
|
}) {
|
|
52
|
+
const {
|
|
53
|
+
portalled,
|
|
54
|
+
side,
|
|
55
|
+
size,
|
|
56
|
+
css,
|
|
57
|
+
borderHeader,
|
|
58
|
+
borderFooter
|
|
59
|
+
} = props;
|
|
50
60
|
return /*#__PURE__*/jsx(DialogPrimitive.Root, {
|
|
51
61
|
...props,
|
|
52
62
|
children: /*#__PURE__*/jsx(Context.Provider, {
|
|
53
63
|
value: {
|
|
54
|
-
|
|
64
|
+
portalled,
|
|
65
|
+
side,
|
|
66
|
+
size,
|
|
67
|
+
css,
|
|
68
|
+
borderHeader,
|
|
69
|
+
borderFooter
|
|
55
70
|
},
|
|
56
71
|
children: children
|
|
57
72
|
})
|
|
@@ -219,6 +234,12 @@ const DrawerContent = ({
|
|
|
219
234
|
showOverlay,
|
|
220
235
|
...props
|
|
221
236
|
}) => {
|
|
237
|
+
const [descriptionCount, setDescriptionCount] = React__default.useState(0);
|
|
238
|
+
const registerDescription = React__default.useCallback(() => {
|
|
239
|
+
setDescriptionCount(count => count + 1);
|
|
240
|
+
return () => setDescriptionCount(count => count - 1);
|
|
241
|
+
}, []);
|
|
242
|
+
const hasDescription = descriptionCount > 0;
|
|
222
243
|
return /*#__PURE__*/jsx(Context.Consumer, {
|
|
223
244
|
children: value => /*#__PURE__*/jsxs(ConditionalWrapper, {
|
|
224
245
|
condition: value.portalled,
|
|
@@ -226,10 +247,18 @@ const DrawerContent = ({
|
|
|
226
247
|
children: child
|
|
227
248
|
}),
|
|
228
249
|
children: [showOverlay && /*#__PURE__*/jsx(StyledOverlay, {}), /*#__PURE__*/jsx(StyledContent, {
|
|
229
|
-
|
|
250
|
+
side: value.side,
|
|
251
|
+
size: value.size,
|
|
252
|
+
css: value.css,
|
|
253
|
+
...(hasDescription ? {} : {
|
|
254
|
+
'aria-describedby': undefined
|
|
255
|
+
}),
|
|
230
256
|
...props,
|
|
231
257
|
showOverlay: showOverlay,
|
|
232
|
-
children:
|
|
258
|
+
children: /*#__PURE__*/jsx(DescriptionContext.Provider, {
|
|
259
|
+
value: registerDescription,
|
|
260
|
+
children: children
|
|
261
|
+
})
|
|
233
262
|
})]
|
|
234
263
|
})
|
|
235
264
|
});
|
|
@@ -237,7 +266,7 @@ const DrawerContent = ({
|
|
|
237
266
|
const DrawerHeader = props => {
|
|
238
267
|
return /*#__PURE__*/jsx(Context.Consumer, {
|
|
239
268
|
children: value => /*#__PURE__*/jsx(Header, {
|
|
240
|
-
|
|
269
|
+
borderHeader: value.borderHeader,
|
|
241
270
|
children: props.children
|
|
242
271
|
})
|
|
243
272
|
});
|
|
@@ -245,7 +274,7 @@ const DrawerHeader = props => {
|
|
|
245
274
|
const DrawerFooter = props => {
|
|
246
275
|
return /*#__PURE__*/jsx(Context.Consumer, {
|
|
247
276
|
children: value => /*#__PURE__*/jsx(Footer, {
|
|
248
|
-
|
|
277
|
+
borderFooter: value.borderFooter,
|
|
249
278
|
children: props.children
|
|
250
279
|
})
|
|
251
280
|
});
|
|
@@ -253,7 +282,14 @@ const DrawerFooter = props => {
|
|
|
253
282
|
const DrawerTrigger = DialogPrimitive.Trigger;
|
|
254
283
|
const DrawerClose = StyledClose;
|
|
255
284
|
const DrawerTitle = DialogPrimitive.Title;
|
|
256
|
-
const DrawerDescription =
|
|
285
|
+
const DrawerDescription = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
286
|
+
const registerDescription = React__default.useContext(DescriptionContext);
|
|
287
|
+
React__default.useLayoutEffect(() => registerDescription?.(), [registerDescription]);
|
|
288
|
+
return /*#__PURE__*/jsx(DialogPrimitive.Description, {
|
|
289
|
+
ref: ref,
|
|
290
|
+
...props
|
|
291
|
+
});
|
|
292
|
+
});
|
|
257
293
|
const DrawerBody = Body;
|
|
258
294
|
const DrawerCloseButton = () => {
|
|
259
295
|
return /*#__PURE__*/jsx(CloseButton, {
|