@wonderflow/react-components 3.0.0-beta.12 → 3.0.0-beta.16
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/datetime/datetime.d.ts +7 -0
- package/datetime/datetime.js +16 -0
- package/datetime/index.d.ts +2 -0
- package/datetime/index.js +1 -0
- package/dropdown/dropdown.d.ts +2 -2
- package/dropdown/dropdown.js +10 -13
- package/dropdown/dropdown.module.css +1 -1
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export declare type DatetimeProps = HTMLAttributes<HTMLTimeElement> & {
|
|
3
|
+
date: string;
|
|
4
|
+
locale?: string | string[];
|
|
5
|
+
options?: Intl.DateTimeFormatOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare const Datetime: ({ date, locale, options, ...otherProps }: DatetimeProps) => JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export const Datetime = ({ date, locale = 'en-US', options, ...otherProps }) => {
|
|
4
|
+
const [datetime, setDateTime] = useState('');
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const timeDate = new Date(date);
|
|
7
|
+
const humanDate = new Intl.DateTimeFormat(locale, {
|
|
8
|
+
year: 'numeric',
|
|
9
|
+
month: 'long',
|
|
10
|
+
day: 'numeric',
|
|
11
|
+
...options
|
|
12
|
+
}).format(timeDate);
|
|
13
|
+
setDateTime(humanDate);
|
|
14
|
+
}, [date, locale, options]);
|
|
15
|
+
return (_jsx("time", { dateTime: date, ...otherProps, children: datetime }, void 0));
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Datetime } from './datetime';
|
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, ForwardRefExoticComponent } from 'react';
|
|
1
|
+
import { ReactNode, FC, ForwardRefExoticComponent } from 'react';
|
|
2
2
|
import { DropdownMenuProps } from './menu/dropdown-menu';
|
|
3
3
|
import { DropdownItemProps } from './item/dropdown-item';
|
|
4
4
|
import { DropdownItemCheckboxProps } from './item-checkbox/dropdown-item-checkbox';
|
|
@@ -27,7 +27,7 @@ export declare type DropdownProps = PropsWithClass & {
|
|
|
27
27
|
*/
|
|
28
28
|
placement?: AutoPlacement | BasePlacement | VariationPlacement;
|
|
29
29
|
};
|
|
30
|
-
declare type DropdownComponent =
|
|
30
|
+
declare type DropdownComponent = FC<DropdownProps> & {
|
|
31
31
|
Menu: ForwardRefExoticComponent<DropdownMenuProps>;
|
|
32
32
|
Item: ForwardRefExoticComponent<DropdownItemProps>;
|
|
33
33
|
ItemCheckbox: ForwardRefExoticComponent<DropdownItemCheckboxProps>;
|
package/dropdown/dropdown.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, Children, cloneElement } from 'react';
|
|
3
|
+
import { useKeyPress, useClickAway } from 'ahooks';
|
|
4
|
+
import { PopUp } from './dropdown.module.css';
|
|
6
5
|
import { useUIDSeed } from 'react-uid';
|
|
7
6
|
import { DropdownMenu } from './menu/dropdown-menu';
|
|
8
7
|
import { DropdownItem } from './item/dropdown-item';
|
|
@@ -27,14 +26,13 @@ const DropdownAnimation = {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
|
-
export const Dropdown =
|
|
29
|
+
export const Dropdown = ({ children, trigger, offset = 8, placement = 'auto-start' }) => {
|
|
31
30
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
32
31
|
const seedID = useUIDSeed();
|
|
33
|
-
const popupRef = useRef(forwardedRef);
|
|
34
32
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
|
-
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
33
|
+
const { getTooltipProps, setTooltipRef, setTriggerRef, tooltipRef, visible } = usePopperTooltip({
|
|
36
34
|
delayShow: 0,
|
|
37
|
-
delayHide:
|
|
35
|
+
delayHide: 0,
|
|
38
36
|
trigger: ['click'],
|
|
39
37
|
visible: isOpen,
|
|
40
38
|
closeOnTriggerHidden: true,
|
|
@@ -43,12 +41,11 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
43
41
|
offset: [0, offset],
|
|
44
42
|
closeOnOutsideClick: false
|
|
45
43
|
});
|
|
46
|
-
const isFocusWithin = useFocusWithin(popupRef);
|
|
47
44
|
useClickAway(() => {
|
|
48
45
|
setIsOpen(false);
|
|
49
|
-
},
|
|
46
|
+
}, tooltipRef);
|
|
50
47
|
useKeyPress('esc', () => setIsOpen(false));
|
|
51
|
-
return (_jsxs(
|
|
48
|
+
return (_jsxs(_Fragment, { children: [Children.map(trigger, (child) => cloneElement(child, {
|
|
52
49
|
ref: setTriggerRef,
|
|
53
50
|
id: seedID('dropdown-trigger'),
|
|
54
51
|
'aria-haspopup': 'true',
|
|
@@ -58,7 +55,7 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
58
55
|
id: seedID('dropdown-menu'),
|
|
59
56
|
'aria-labelledby': seedID('dropdown-trigger')
|
|
60
57
|
})) }, void 0) }, void 0)) }, void 0)] }, void 0));
|
|
61
|
-
}
|
|
58
|
+
};
|
|
62
59
|
Dropdown.displayName = 'Dropdown';
|
|
63
60
|
Dropdown.Menu = DropdownMenu;
|
|
64
61
|
Dropdown.Item = DropdownItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.PopUp{inline-size:max-content;z-index:2}
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { ClampText } from './clamp-text';
|
|
|
16
16
|
export type { ClampTextProps } from './clamp-text';
|
|
17
17
|
export { Container } from './container';
|
|
18
18
|
export type { ContainerProps } from './container';
|
|
19
|
+
export { Datetime } from './datetime';
|
|
20
|
+
export type { DatetimeProps } from './datetime';
|
|
19
21
|
export { Drawer } from './drawer';
|
|
20
22
|
export type { DrawerProps } from './drawer';
|
|
21
23
|
export { Table } from './table';
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { Chip } from './chip';
|
|
|
8
8
|
export { CircularProgress } from './circular-progress';
|
|
9
9
|
export { ClampText } from './clamp-text';
|
|
10
10
|
export { Container } from './container';
|
|
11
|
+
export { Datetime } from './datetime';
|
|
11
12
|
export { Drawer } from './drawer';
|
|
12
13
|
export { Table } from './table';
|
|
13
14
|
export { Disclosure } from './disclosure';
|
package/package.json
CHANGED
package/themes/dark.css
CHANGED