@laser-ui/components 0.6.6 → 1.0.0
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/CHANGELOG.md +16 -0
- package/package.json +2 -2
- package/root/Root.js +12 -27
- package/table/TableFilter.js +4 -3
- package/table/types.d.ts +1 -0
- package/utils/position/getVerticalSidePosition.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
# [1.0.0](https://github.com/laser-ui/laser-ui/compare/v0.6.7...v1.0.0) (2024-07-11)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **components:** fix getVerticalSidePosition ([9b37254](https://github.com/laser-ui/laser-ui/commit/9b37254d5f2d36da1b024949852147fc85936787))
|
|
10
|
+
|
|
11
|
+
## [0.6.7](https://github.com/laser-ui/laser-ui/compare/v0.6.6...v0.6.7) (2024-07-10)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **components:** fix get window size ([5f20aa9](https://github.com/laser-ui/laser-ui/commit/5f20aa9b5c8fb4e0dd40c9516847461e18ab5b65))
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- **components:** table-filter support custom footer ([31faf0a](https://github.com/laser-ui/laser-ui/commit/31faf0a9488744d83c3e9f9276bfac225ea4514b))
|
|
20
|
+
|
|
5
21
|
## [0.6.6](https://github.com/laser-ui/laser-ui/compare/v0.6.5...v0.6.6) (2024-06-14)
|
|
6
22
|
|
|
7
23
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"access": "public",
|
|
41
41
|
"directory": "../../dist/libs/components"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "032c558af574de9c626912f34a2872b2317c0d7f"
|
|
44
44
|
}
|
package/root/Root.js
CHANGED
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEvent, useRefExtra } from '@laser-ui/hooks';
|
|
3
3
|
import { isString, set } from 'lodash';
|
|
4
4
|
import { useStore } from 'rcl-store';
|
|
5
|
-
import { useEffect, useMemo
|
|
5
|
+
import { useEffect, useMemo } from 'react';
|
|
6
6
|
import { ROOT_DATA, RootContext, Store } from './vars';
|
|
7
7
|
import dayjs from '../dayjs';
|
|
8
|
-
import { Portal } from '../internal/portal';
|
|
9
8
|
import resources from '../resources.json';
|
|
10
|
-
function WindowSize() {
|
|
11
|
-
const windowSizeRef = useRef(null);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (windowSizeRef.current) {
|
|
14
|
-
const observer = new ResizeObserver((entries) => {
|
|
15
|
-
const entry = entries[0];
|
|
16
|
-
ROOT_DATA.windowSize = { width: entry.contentRect.width, height: entry.contentRect.height };
|
|
17
|
-
});
|
|
18
|
-
observer.observe(windowSizeRef.current);
|
|
19
|
-
return () => {
|
|
20
|
-
observer.disconnect();
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return (_jsx("div", { ref: windowSizeRef, style: {
|
|
25
|
-
position: 'fixed',
|
|
26
|
-
top: 0,
|
|
27
|
-
right: 0,
|
|
28
|
-
bottom: 0,
|
|
29
|
-
left: 0,
|
|
30
|
-
pointerEvents: 'none',
|
|
31
|
-
} }));
|
|
32
|
-
}
|
|
33
9
|
export function Root(props) {
|
|
34
10
|
const { context: contextProp, children } = props;
|
|
35
11
|
const windowRef = useRefExtra(() => window);
|
|
36
12
|
const [{ dialogs }] = useStore(Store, ['dialogs']);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const handleResize = () => {
|
|
15
|
+
ROOT_DATA.windowSize = { width: window.innerWidth, height: window.innerHeight };
|
|
16
|
+
};
|
|
17
|
+
window.addEventListener('resize', handleResize);
|
|
18
|
+
return () => {
|
|
19
|
+
window.removeEventListener('resize', handleResize);
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
37
22
|
useEvent(windowRef, 'click', (e) => {
|
|
38
23
|
// Check if click by keydown
|
|
39
24
|
if (!(e.clientX === 0 && e.clientY === 0)) {
|
|
@@ -84,5 +69,5 @@ export function Root(props) {
|
|
|
84
69
|
default:
|
|
85
70
|
break;
|
|
86
71
|
}
|
|
87
|
-
return (_jsxs(
|
|
72
|
+
return (_jsxs(RootContext.Provider, { value: context, children: [children, dialogs.map(({ node }) => node)] }));
|
|
88
73
|
}
|
package/table/TableFilter.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import SearchOutlined from '@material-design-icons/svg/outlined/search.svg?react';
|
|
4
|
+
import { isUndefined } from 'lodash';
|
|
4
5
|
import { CLASSES } from './vars';
|
|
5
6
|
import { Button } from '../button';
|
|
6
7
|
import { useComponentProps, useStyled, useTranslation } from '../hooks';
|
|
@@ -8,15 +9,15 @@ import { Icon } from '../icon';
|
|
|
8
9
|
import { Input } from '../input';
|
|
9
10
|
import { Popover } from '../popover';
|
|
10
11
|
export function TableFilter(props) {
|
|
11
|
-
const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = true, zIndex, scrolling, onVisibleChange, onSearch, onReset, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "visible", "placement", "placementFixed", "escClosable", "gap", "inWindow", "searchable", "searchValue", "modal", "destroyAfterClose", "zIndex", "scrolling", "onVisibleChange", "onSearch", "onReset", "afterVisibleChange"]);
|
|
12
|
+
const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = true, zIndex, scrolling, onVisibleChange, onSearch, onReset, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "footer", "visible", "placement", "placementFixed", "escClosable", "gap", "inWindow", "searchable", "searchValue", "modal", "destroyAfterClose", "zIndex", "scrolling", "onVisibleChange", "onSearch", "onReset", "afterVisibleChange"]);
|
|
12
13
|
const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
|
|
13
14
|
const { t } = useTranslation();
|
|
14
15
|
return (_jsx(Popover, Object.assign({}, restProps, { children: children, content: _jsxs("div", Object.assign({}, styled('table__filter'), { children: [searchable && (_jsx(Input, { style: { display: 'flex' }, model: searchValue, prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), placeholder: t('Search'), clearable: true, onModelChange: (value) => {
|
|
15
16
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch(value);
|
|
16
|
-
} })), content] })), footer: _jsx(Popover.Footer, { styleOverrides: { popover__footer: { style: { justifyContent: 'space-between' } } }, actions: [
|
|
17
|
+
} })), content] })), footer: isUndefined(footer) ? (_jsx(Popover.Footer, { styleOverrides: { popover__footer: { style: { justifyContent: 'space-between' } } }, actions: [
|
|
17
18
|
_jsx(Button, { pattern: "link", onClick: () => {
|
|
18
19
|
onReset === null || onReset === void 0 ? void 0 : onReset();
|
|
19
20
|
}, children: t('Table', 'Reset') }),
|
|
20
21
|
'ok',
|
|
21
|
-
] }), visible: visible, trigger: "click", placement: placement, placementFixed: placementFixed, arrow: false, escClosable: escClosable, gap: gap, inWindow: inWindow, modal: modal, destroyAfterClose: destroyAfterClose, zIndex: zIndex, scrolling: scrolling, onVisibleChange: onVisibleChange, afterVisibleChange: afterVisibleChange })));
|
|
22
|
+
] })) : footer === false ? undefined : (footer), visible: visible, trigger: "click", placement: placement, placementFixed: placementFixed, arrow: false, escClosable: escClosable, gap: gap, inWindow: inWindow, modal: modal, destroyAfterClose: destroyAfterClose, zIndex: zIndex, scrolling: scrolling, onVisibleChange: onVisibleChange, afterVisibleChange: afterVisibleChange })));
|
|
22
23
|
}
|
package/table/types.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export interface TableTdProps extends BaseProps<'table', typeof CLASSES>, React.
|
|
|
43
43
|
export interface TableFilterProps extends BaseProps<'table', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'content'> {
|
|
44
44
|
children: React.ReactElement | ((render: CloneHTMLElement) => React.ReactNode);
|
|
45
45
|
content?: React.ReactNode;
|
|
46
|
+
footer?: React.ReactElement | false;
|
|
46
47
|
visible?: boolean;
|
|
47
48
|
placement?: PopupPlacement;
|
|
48
49
|
placementFixed?: boolean;
|
|
@@ -18,7 +18,7 @@ export function getVerticalSidePosition(targetEl, popupSize, config) {
|
|
|
18
18
|
top = Math.min(Math.max(top, inWindow), ROOT_DATA.windowSize.height - height - inWindow);
|
|
19
19
|
}
|
|
20
20
|
if (inWindow !== false) {
|
|
21
|
-
left = Math.min(Math.max(left, inWindow),
|
|
21
|
+
left = Math.min(Math.max(left, inWindow), ROOT_DATA.windowSize.width - width - inWindow);
|
|
22
22
|
}
|
|
23
23
|
const transformOrigin = placement === 'top' || placement === 'top-left' || placement === 'top-right' ? 'center bottom' : 'center top';
|
|
24
24
|
const position = {
|