@majoo-ui/react 2.4.4 → 2.4.6
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/datePicker/InputDatePicker.esm.js +1 -1
- package/components/datePicker/locale.esm.js +2 -0
- package/components/dropdownMenu/DropdownMenu.esm.js +15 -7
- package/components/tabs/Tabs.esm.js +20 -9
- package/index.esm.css +4 -4
- package/package.json +1 -1
- package/src/components/datePicker/locale.d.ts +2 -0
- package/utils/element.esm.js +0 -21
|
@@ -22,6 +22,7 @@ const defaultDatePickerLocaleText = {
|
|
|
22
22
|
maxRange
|
|
23
23
|
}) => `Maksimal range adalah ${maxRange} hari`,
|
|
24
24
|
selectRangeToggle: 'Pilih Rentang Waktu',
|
|
25
|
+
drawerTitle: 'Pilih tanggal',
|
|
25
26
|
dateLabel: 'Tanggal',
|
|
26
27
|
timeLabel: 'Waktu',
|
|
27
28
|
dateFromLabel: 'Dari Tanggal',
|
|
@@ -54,6 +55,7 @@ const i18nDatePickerLocaleText = (t, locale) => {
|
|
|
54
55
|
maxRange
|
|
55
56
|
}),
|
|
56
57
|
selectRangeToggle: t('selectTimeRangeText', d.selectRangeToggle),
|
|
58
|
+
drawerTitle: t('label.selectDate', d.drawerTitle),
|
|
57
59
|
dateLabel: t('label.date', d.dateLabel),
|
|
58
60
|
timeLabel: t('time', d.timeLabel),
|
|
59
61
|
dateFromLabel: t('dateFromLabel', d.dateFromLabel),
|
|
@@ -253,10 +253,16 @@ DropdownMenuContext.propTypes = {
|
|
|
253
253
|
side: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
|
254
254
|
align: PropTypes.oneOf(['start', 'center', 'end'])
|
|
255
255
|
};
|
|
256
|
-
const
|
|
256
|
+
const setRef = (ref, node) => {
|
|
257
|
+
if (typeof ref === 'function') ref(node);else if (ref) ref.current = node;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// forwardRef because DropdownMenuPortal renders its child through Radix's `Portal asChild`,
|
|
261
|
+
// which hands that child a ref; a plain function component would drop it with a warning.
|
|
262
|
+
const DropdownMenuContentContext = /*#__PURE__*/React__default.forwardRef(({
|
|
257
263
|
theme = 'default',
|
|
258
264
|
...props
|
|
259
|
-
}) => {
|
|
265
|
+
}, forwardedRef) => {
|
|
260
266
|
const {
|
|
261
267
|
side,
|
|
262
268
|
align
|
|
@@ -271,7 +277,8 @@ const DropdownMenuContentContext = ({
|
|
|
271
277
|
appElement.classList.remove('noscroll');
|
|
272
278
|
}
|
|
273
279
|
}
|
|
274
|
-
|
|
280
|
+
setRef(forwardedRef, node);
|
|
281
|
+
}, [forwardedRef]);
|
|
275
282
|
return /*#__PURE__*/jsx(StyledContent, {
|
|
276
283
|
className: `dropdown-content ${themeProvider?.theme || ''}`,
|
|
277
284
|
side: side,
|
|
@@ -280,7 +287,7 @@ const DropdownMenuContentContext = ({
|
|
|
280
287
|
...props,
|
|
281
288
|
children: props.children
|
|
282
289
|
});
|
|
283
|
-
};
|
|
290
|
+
});
|
|
284
291
|
DropdownMenuContentContext.propTypes = {
|
|
285
292
|
sideOffset: PropTypes.number,
|
|
286
293
|
alignOffset: PropTypes.number,
|
|
@@ -288,18 +295,19 @@ DropdownMenuContentContext.propTypes = {
|
|
|
288
295
|
};
|
|
289
296
|
|
|
290
297
|
// Radix positions submenus itself, so this only carries the theme class across the portal.
|
|
291
|
-
const DropdownMenuSubContentContext = ({
|
|
298
|
+
const DropdownMenuSubContentContext = /*#__PURE__*/React__default.forwardRef(({
|
|
292
299
|
theme = 'default',
|
|
293
300
|
children,
|
|
294
301
|
...props
|
|
295
|
-
}) => {
|
|
302
|
+
}, ref) => {
|
|
296
303
|
const themeProvider = useThemeProvider(theme);
|
|
297
304
|
return /*#__PURE__*/jsx(StyledSubContent, {
|
|
298
305
|
className: `dropdown-content ${themeProvider?.theme || ''}`,
|
|
306
|
+
ref: ref,
|
|
299
307
|
...props,
|
|
300
308
|
children: children
|
|
301
309
|
});
|
|
302
|
-
};
|
|
310
|
+
});
|
|
303
311
|
DropdownMenuSubContentContext.propTypes = {
|
|
304
312
|
sideOffset: PropTypes.number,
|
|
305
313
|
alignOffset: PropTypes.number,
|
|
@@ -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 [
|
|
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:
|
|
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:
|
|
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,
|
package/index.esm.css
CHANGED
|
@@ -1045,6 +1045,10 @@
|
|
|
1045
1045
|
counter-reset: ol4;
|
|
1046
1046
|
}
|
|
1047
1047
|
|
|
1048
|
+
.recharts-pie-sector {
|
|
1049
|
+
outline: none;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1048
1052
|
.ReactCrop {
|
|
1049
1053
|
position: relative;
|
|
1050
1054
|
display: inline-block;
|
|
@@ -1289,7 +1293,3 @@
|
|
|
1289
1293
|
height: 24px;
|
|
1290
1294
|
}
|
|
1291
1295
|
}
|
|
1292
|
-
|
|
1293
|
-
.recharts-pie-sector {
|
|
1294
|
-
outline: none;
|
|
1295
|
-
}
|
package/package.json
CHANGED
|
@@ -16,6 +16,8 @@ export interface DatePickerLocaleText {
|
|
|
16
16
|
}) => string;
|
|
17
17
|
/** Mobile toggle that shows the quick range options. */
|
|
18
18
|
selectRangeToggle: string;
|
|
19
|
+
/** Title of the mobile drawer, read by screen readers only. */
|
|
20
|
+
drawerTitle: string;
|
|
19
21
|
/** Time picker labels of a single picker. */
|
|
20
22
|
dateLabel: string;
|
|
21
23
|
timeLabel: string;
|
package/utils/element.esm.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
-
import 'core-js/modules/es.iterator.map.js';
|
|
3
|
-
import React__default from 'react';
|
|
4
|
-
|
|
5
|
-
function addPropsToReactElement(element, props) {
|
|
6
|
-
if (/*#__PURE__*/React__default.isValidElement(element)) {
|
|
7
|
-
return /*#__PURE__*/React__default.cloneElement(element, props);
|
|
8
|
-
}
|
|
9
|
-
return element;
|
|
10
|
-
}
|
|
11
|
-
function addPropsToChildren(children, props) {
|
|
12
|
-
if (!Array.isArray(children)) {
|
|
13
|
-
return addPropsToReactElement(children, props);
|
|
14
|
-
}
|
|
15
|
-
return children.map((childElement, index) => addPropsToReactElement(childElement, {
|
|
16
|
-
key: index,
|
|
17
|
-
...props
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { addPropsToChildren, addPropsToReactElement };
|