@homecode/ui 5.3.10 → 5.3.12
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/dist/esm/src/components/Notifications/Notifications.js +71 -2
- package/dist/esm/src/components/Notifications/Notifications.styl.js +1 -1
- package/dist/esm/src/components/Table/Table.js +4 -4
- package/dist/esm/src/components/Table/Table.styl.js +2 -2
- package/dist/esm/types/src/components/Table/Table.d.ts +1 -1
- package/dist/esm/types/src/components/Table/Table.types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement, Component } from 'react';
|
|
1
|
+
import { createElement, Component, createRef } from 'react';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import { useStore } from 'justorm/react';
|
|
@@ -19,8 +19,69 @@ function getDeltaPos(p1, p2) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
const TOUCH_MOVE_TRESHOLD = 50;
|
|
22
|
+
const WHEEL_MOVE_THRESHOLD = 20;
|
|
23
|
+
const WHEEL_RESET_MS = 150;
|
|
24
|
+
const wheelGesture = {
|
|
25
|
+
itemId: null,
|
|
26
|
+
deltaX: 0,
|
|
27
|
+
deltaY: 0,
|
|
28
|
+
resetTimer: null,
|
|
29
|
+
};
|
|
30
|
+
function resetWheelGesture() {
|
|
31
|
+
wheelGesture.itemId = null;
|
|
32
|
+
wheelGesture.deltaX = 0;
|
|
33
|
+
wheelGesture.deltaY = 0;
|
|
34
|
+
if (wheelGesture.resetTimer) {
|
|
35
|
+
clearTimeout(wheelGesture.resetTimer);
|
|
36
|
+
wheelGesture.resetTimer = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function scheduleWheelGestureReset() {
|
|
40
|
+
if (wheelGesture.resetTimer) {
|
|
41
|
+
clearTimeout(wheelGesture.resetTimer);
|
|
42
|
+
}
|
|
43
|
+
wheelGesture.resetTimer = setTimeout(resetWheelGesture, WHEEL_RESET_MS);
|
|
44
|
+
}
|
|
45
|
+
function isHorizontalWheel(e, id) {
|
|
46
|
+
const absX = Math.abs(e.deltaX);
|
|
47
|
+
const absY = Math.abs(e.deltaY);
|
|
48
|
+
if (absX > absY)
|
|
49
|
+
return true;
|
|
50
|
+
return (wheelGesture.itemId === id && wheelGesture.deltaX >= wheelGesture.deltaY);
|
|
51
|
+
}
|
|
52
|
+
function handleNotificationWheel(id, e, unpause, close) {
|
|
53
|
+
scheduleWheelGestureReset();
|
|
54
|
+
if (wheelGesture.itemId !== null && wheelGesture.itemId !== id) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (wheelGesture.itemId === null) {
|
|
58
|
+
wheelGesture.itemId = id;
|
|
59
|
+
}
|
|
60
|
+
wheelGesture.deltaX += Math.abs(e.deltaX);
|
|
61
|
+
wheelGesture.deltaY += Math.abs(e.deltaY);
|
|
62
|
+
if (wheelGesture.deltaX > wheelGesture.deltaY &&
|
|
63
|
+
wheelGesture.deltaX > WHEEL_MOVE_THRESHOLD) {
|
|
64
|
+
const closingId = wheelGesture.itemId;
|
|
65
|
+
unpause();
|
|
66
|
+
wheelGesture.deltaX = 0;
|
|
67
|
+
wheelGesture.deltaY = 0;
|
|
68
|
+
close(closingId);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
22
71
|
class Item extends Component {
|
|
23
72
|
startPos = null;
|
|
73
|
+
itemRef = createRef();
|
|
74
|
+
componentDidMount() {
|
|
75
|
+
this.itemRef.current?.addEventListener('wheel', this.onWheelNative, {
|
|
76
|
+
passive: false,
|
|
77
|
+
capture: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
componentWillUnmount() {
|
|
81
|
+
this.itemRef.current?.removeEventListener('wheel', this.onWheelNative, {
|
|
82
|
+
capture: true,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
24
85
|
onTouchStart = e => {
|
|
25
86
|
this.startPos = getTouchPos(e);
|
|
26
87
|
};
|
|
@@ -43,6 +104,14 @@ class Item extends Component {
|
|
|
43
104
|
this.startPos = null;
|
|
44
105
|
};
|
|
45
106
|
onTouchCancel = () => (this.startPos = null);
|
|
107
|
+
onWheelNative = (e) => {
|
|
108
|
+
const { id, unpause, close } = this.props;
|
|
109
|
+
if (isHorizontalWheel(e, id)) {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
e.stopPropagation();
|
|
112
|
+
}
|
|
113
|
+
handleNotificationWheel(id, e, unpause, close);
|
|
114
|
+
};
|
|
46
115
|
closeMe = () => {
|
|
47
116
|
const { id, close } = this.props;
|
|
48
117
|
close(id);
|
|
@@ -50,7 +119,7 @@ class Item extends Component {
|
|
|
50
119
|
render() {
|
|
51
120
|
const { type = 'default', title, content, visible, pause, unpause, } = this.props;
|
|
52
121
|
const classes = cn(S.item, S[`type-${type}`], visible && S.visible);
|
|
53
|
-
return (jsx("div", { className: classes, onMouseOver: pause, onFocus: pause, onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove, onMouseOut: unpause, onBlur: unpause, onTouchEnd: this.onTouchEnd, onTouchCancel: this.onTouchCancel, children: jsxs("div", { className: S.itemInner, children: [(title || content) && (jsxs("div", { className: S.text, children: [title && jsx("div", { className: S.title, children: title }), content != null && (jsx("div", { className: S.content, children: typeof content === 'function' ? content() : content }))] })), jsx(Button, { className: S.close, variant: "clear", square: true, onClick: this.closeMe, children: jsx(Icon, { type: "close", size: "s" }) })] }) }));
|
|
122
|
+
return (jsx("div", { ref: this.itemRef, className: classes, onMouseOver: pause, onFocus: pause, onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove, onMouseOut: unpause, onBlur: unpause, onTouchEnd: this.onTouchEnd, onTouchCancel: this.onTouchCancel, children: jsxs("div", { className: S.itemInner, children: [(title || content) && (jsxs("div", { className: S.text, children: [title && jsx("div", { className: S.title, children: title }), content != null && (jsx("div", { className: S.content, children: typeof content === 'function' ? content() : content }))] })), jsx(Button, { className: S.close, variant: "clear", square: true, onClick: this.closeMe, children: jsx(Icon, { type: "close", size: "s" }) })] }) }));
|
|
54
123
|
}
|
|
55
124
|
}
|
|
56
125
|
const NotificationsStore = STORE;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".Notifications_root__S3ujN{max-height:calc(var(--vh)*100);overflow:hidden;position:fixed;right:0;top:0;transform:translateZ(0);transition:right .3s ease-out;width:320px;z-index:20}.Notifications_inner__6v9e3{padding:var(--p-5);padding-right:var(--p-3)}.Notifications_empty__zCpOA{pointer-events:none}.Notifications_itemInner__nEYAl,.Notifications_item__I3Up4{border-radius:var(--p-4)}.Notifications_item__I3Up4{-webkit-backface-visibility:hidden;backface-visibility:hidden;left:100%;max-height:0;max-width:100%;opacity:0;position:relative;transition:all .3s ease-out;width:300px}.Notifications_item__I3Up4:first-child{margin-top:calc(var(--p-2)*-1)}.Notifications_item__I3Up4+.Notifications_item__I3Up4{padding-top:var(--p-2)}.Notifications_item__I3Up4:hover{transform:translateX(-2px)}.Notifications_visible__ln4-n{left:0;max-height:500px;opacity:1}.Notifications_itemInner__nEYAl{align-items:center;-webkit-backdrop-filter:blur(30px);backdrop-filter:blur(30px);background-color:var(--decent-color-alpha-500);box-shadow:inset 0 0 1px var(--accent-color-alpha-300),0 0 20px var(--decent-color);box-sizing:border-box;display:flex;padding:var(--p-3);padding-right:var(--p-6);position:relative;transition:.3s ease-out;transition-property:transform}.Notifications_type-warning__Nxg6C .Notifications_itemInner__nEYAl{background-color:var(--warning-color-alpha-300)}.Notifications_type-danger__zeIMt .Notifications_itemInner__nEYAl{background-color:var(--danger-color-alpha-300)}.Notifications_itemInner__nEYAl button{margin-bottom:calc(var(--p-2)*-1);margin-top:calc(var(--p-2)*-1)}.Notifications_icon__nKs-X{background:no-repeat 50%;height:24px;margin-right:10px;min-width:24px;width:24px}.Notifications_type-loading__N4EE5 .Notifications_icon__nKs-X{transform:translateY(-20px)}.Notifications_text__7QZL6{display:flex;flex-direction:column;flex-grow:1;z-index:1}.Notifications_title__Gu9bs{font-size:16px;font-weight:700}.Notifications_content__Zrvw2{font-size:12px;margin-top:calc(var(--p-3)/2)}.Notifications_content__Zrvw2:first-child{margin-top:0}.Notifications_close__-IUH3{background-color:transparent;border-radius:50%;cursor:pointer;height:40px!important;max-height:40px!important;max-width:40px!important;opacity:0;position:absolute;right:-5px;top:2px;transform:scale(.8);transition:.1s ease-out;transition-property:opacity,transform;width:40px!important}.Notifications_close__-IUH3:before{background-color:var(--decent-color-alpha-400);border-radius:inherit;bottom:var(--p-2);content:\"\";left:var(--p-2);pointer-events:none;position:absolute;right:var(--p-2);top:var(--p-2);transition:background-color .1s ease-out}.Notifications_close__-IUH3 svg{transform:scale(.6)}.Notifications_item__I3Up4:hover .Notifications_close__-IUH3{opacity:.8}.Notifications_close__-IUH3:hover{background-color:transparent;background-color:initial;opacity:1}.Notifications_close__-IUH3:hover:before{background-color:var(--decent-color-alpha-800)}@media (max-width:700px){.Notifications_item__I3Up4,.Notifications_root__S3ujN{width:100%}.Notifications_title__Gu9bs{font-size:20px}.Notifications_content__Zrvw2{font-size:16px}.Notifications_close__-IUH3{transform:scale(1.2)}}";
|
|
3
|
+
var css_248z = ".Notifications_root__S3ujN{max-height:calc(var(--vh)*100);overflow:hidden;position:fixed;right:0;top:0;transform:translateZ(0);transition:right .3s ease-out;width:320px;z-index:20}.Notifications_inner__6v9e3{padding:var(--p-5);padding-right:var(--p-3)}.Notifications_empty__zCpOA{pointer-events:none}.Notifications_itemInner__nEYAl,.Notifications_item__I3Up4{border-radius:var(--p-4)}.Notifications_item__I3Up4{-webkit-backface-visibility:hidden;backface-visibility:hidden;left:100%;max-height:0;max-width:100%;opacity:0;overscroll-behavior-x:none;position:relative;touch-action:pan-y;transition:all .3s ease-out;width:300px}.Notifications_item__I3Up4:first-child{margin-top:calc(var(--p-2)*-1)}.Notifications_item__I3Up4+.Notifications_item__I3Up4{padding-top:var(--p-2)}.Notifications_item__I3Up4:hover{transform:translateX(-2px)}.Notifications_visible__ln4-n{left:0;max-height:500px;opacity:1}.Notifications_itemInner__nEYAl{align-items:center;-webkit-backdrop-filter:blur(30px);backdrop-filter:blur(30px);background-color:var(--decent-color-alpha-500);box-shadow:inset 0 0 1px var(--accent-color-alpha-300),0 0 20px var(--decent-color);box-sizing:border-box;display:flex;padding:var(--p-3);padding-right:var(--p-6);position:relative;transition:.3s ease-out;transition-property:transform}.Notifications_type-warning__Nxg6C .Notifications_itemInner__nEYAl{background-color:var(--warning-color-alpha-300)}.Notifications_type-danger__zeIMt .Notifications_itemInner__nEYAl{background-color:var(--danger-color-alpha-300)}.Notifications_itemInner__nEYAl button{margin-bottom:calc(var(--p-2)*-1);margin-top:calc(var(--p-2)*-1)}.Notifications_icon__nKs-X{background:no-repeat 50%;height:24px;margin-right:10px;min-width:24px;width:24px}.Notifications_type-loading__N4EE5 .Notifications_icon__nKs-X{transform:translateY(-20px)}.Notifications_text__7QZL6{display:flex;flex-direction:column;flex-grow:1;z-index:1}.Notifications_title__Gu9bs{font-size:16px;font-weight:700}.Notifications_content__Zrvw2{font-size:12px;margin-top:calc(var(--p-3)/2)}.Notifications_content__Zrvw2:first-child{margin-top:0}.Notifications_close__-IUH3{background-color:transparent;border-radius:50%;cursor:pointer;height:40px!important;max-height:40px!important;max-width:40px!important;opacity:0;position:absolute;right:-5px;top:2px;transform:scale(.8);transition:.1s ease-out;transition-property:opacity,transform;width:40px!important}.Notifications_close__-IUH3:before{background-color:var(--decent-color-alpha-400);border-radius:inherit;bottom:var(--p-2);content:\"\";left:var(--p-2);pointer-events:none;position:absolute;right:var(--p-2);top:var(--p-2);transition:background-color .1s ease-out}.Notifications_close__-IUH3 svg{transform:scale(.6)}.Notifications_item__I3Up4:hover .Notifications_close__-IUH3{opacity:.8}.Notifications_close__-IUH3:hover{background-color:transparent;background-color:initial;opacity:1}.Notifications_close__-IUH3:hover:before{background-color:var(--decent-color-alpha-800)}@media (max-width:700px){.Notifications_item__I3Up4,.Notifications_root__S3ujN{width:100%}.Notifications_title__Gu9bs{font-size:20px}.Notifications_content__Zrvw2{font-size:16px}.Notifications_close__-IUH3{transform:scale(1.2)}}";
|
|
4
4
|
var S = {"root":"Notifications_root__S3ujN","inner":"Notifications_inner__6v9e3","empty":"Notifications_empty__zCpOA","item":"Notifications_item__I3Up4","itemInner":"Notifications_itemInner__nEYAl","visible":"Notifications_visible__ln4-n","type-warning":"Notifications_type-warning__Nxg6C","type-danger":"Notifications_type-danger__zeIMt","icon":"Notifications_icon__nKs-X","type-loading":"Notifications_type-loading__N4EE5","text":"Notifications_text__7QZL6","title":"Notifications_title__Gu9bs","content":"Notifications_content__Zrvw2","close":"Notifications_close__-IUH3"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
-
import cn from 'classnames';
|
|
4
3
|
import { Paranja } from '../Paranja/Paranja.js';
|
|
4
|
+
import S from './Table.styl.js';
|
|
5
5
|
import { Scroll } from '../Scroll/Scroll.js';
|
|
6
6
|
import { Spinner } from '../Spinner/Spinner.js';
|
|
7
|
-
import
|
|
7
|
+
import cn from 'classnames';
|
|
8
8
|
|
|
9
9
|
class Table extends Component {
|
|
10
10
|
renderHeaderColumn = ({ id, label, sticky }) => (jsx("th", { className: cn(sticky && S.sticky), children: label }, id));
|
|
@@ -16,8 +16,8 @@ class Table extends Component {
|
|
|
16
16
|
return (jsx("td", { className: cn(sticky && S.sticky), children: render ? render(data) : data[dataField || id] }, id));
|
|
17
17
|
}
|
|
18
18
|
render() {
|
|
19
|
-
const { className, columns, isLoading = false, loadingText, blur, data, } = this.props;
|
|
20
|
-
return (jsxs("div", { className: cn(S.root, blur && S.blur, className), children: [jsx(Scroll, { x: true, y: true, offset: { x: { before: 10, after: 10 } }, className: S.scroll, xScrollbarClassName: S.xScrollbar, yScrollbarClassName: S.yScrollbar, children: jsxs("table", { children: [jsx("thead", { children: jsx("tr", { children: columns.map(this.renderHeaderColumn) }) }), jsx("tbody", { children: data.map(this.renderRow) })] }) }), jsx(Paranja, { inline: true, visible: isLoading, blur: blur, children: isLoading && (loadingText ?? jsx(Spinner, {})) })] }));
|
|
19
|
+
const { className, columns, isLoading = false, loadingText, blur, data, clear, size = 'm', } = this.props;
|
|
20
|
+
return (jsxs("div", { className: cn(S.root, S[`size-${size}`], clear && S.clear, blur && S.blur, className), children: [jsx(Scroll, { x: true, y: true, offset: { x: { before: 10, after: 10 } }, className: S.scroll, xScrollbarClassName: S.xScrollbar, yScrollbarClassName: S.yScrollbar, children: jsxs("table", { children: [jsx("thead", { children: jsx("tr", { children: columns.map(this.renderHeaderColumn) }) }), jsx("tbody", { children: data.map(this.renderRow) })] }) }), jsx(Paranja, { inline: true, visible: isLoading, blur: blur, children: isLoading && (loadingText ?? jsx(Spinner, {})) })] }));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".Table_root__PxLR-{--brad:var(--border-radius-l);border-radius:var(--border-radius-l);border-radius:var(--brad);
|
|
4
|
-
var S = {"root":"Table_root__PxLR-","scroll":"Table_scroll__a04XZ","xScrollbar":"Table_xScrollbar__FODoD","yScrollbar":"Table_yScrollbar__KwMOv","sticky":"Table_sticky__99lks","blur":"Table_blur__UwMAo"};
|
|
3
|
+
var css_248z = ".Table_root__PxLR-{--brad:var(--border-radius-l);border-radius:var(--border-radius-l);border-radius:var(--brad);max-height:100%;overflow:hidden;position:relative}.Table_root__PxLR- table{min-width:100%}.Table_root__PxLR- tbody{overflow-scrolling:touch;overflow:auto}.Table_root__PxLR- thead{position:sticky;top:0;z-index:1}.Table_root__PxLR- td,.Table_root__PxLR- th{min-width:5em;padding:var(--cell-padding);text-align:left}.Table_root__PxLR- td{vertical-align:top}.Table_root__PxLR- tr:last-child td{border-bottom-left-radius:var(--brad);border-bottom-right-radius:var(--brad);padding-bottom:var(--last-row-padding-bottom)}.Table_root__PxLR-:not(.Table_clear__pGt1B){box-shadow:0 0 0 2px var(--accent-color-alpha-100)}.Table_root__PxLR-:not(.Table_clear__pGt1B) th{background-color:var(--accent-color-alpha-100)}.Table_root__PxLR-:not(.Table_clear__pGt1B) td{box-shadow:inset 0 1px 0 0 var(--accent-color-alpha-100)}.Table_size-xs__z1E3a{--cell-padding:2px;--last-row-padding-bottom:var(--p-4)}.Table_size-s__9PBIX{--cell-padding:var(--p-1);--last-row-padding-bottom:var(--p-5)}.Table_size-m__wNH3x{--cell-padding:var(--p-2);--last-row-padding-bottom:var(--p-5)}.Table_size-l__lCN-O{--cell-padding:var(--p-5);--last-row-padding-bottom:var(--p-8)}.Table_size-xl__QS-V3{--cell-padding:var(--p-8);--last-row-padding-bottom:var(--p-8)}.Table_scroll__a04XZ{position:static}.Table_xScrollbar__FODoD{transform:translateY(4px)}.Table_yScrollbar__KwMOv{transform:translateX(4px)}.Table_sticky__99lks{background-color:var(--decent-color);left:0;position:sticky;z-index:1}th.Table_sticky__99lks{background-color:var(--accent-color);color:var(--decent-color)}.Table_blur__UwMAo .Table_sticky__99lks{-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);background-color:var(--decent-color-alpha-500)}.Table_blur__UwMAo th.Table_sticky__99lks{background-color:var(--accent-color-alpha-500);color:var(--decent-color-alpha-800)}";
|
|
4
|
+
var S = {"root":"Table_root__PxLR-","clear":"Table_clear__pGt1B","size-xs":"Table_size-xs__z1E3a","size-s":"Table_size-s__9PBIX","size-m":"Table_size-m__wNH3x","size-l":"Table_size-l__lCN-O","size-xl":"Table_size-xl__QS-V3","scroll":"Table_scroll__a04XZ","xScrollbar":"Table_xScrollbar__FODoD","yScrollbar":"Table_yScrollbar__KwMOv","sticky":"Table_sticky__99lks","blur":"Table_blur__UwMAo"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { S as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
1
|
import * as T from './Table.types';
|
|
2
|
+
import { Component } from 'react';
|
|
3
3
|
export declare class Table extends Component<T.Props> {
|
|
4
4
|
renderHeaderColumn: ({ id, label, sticky }: T.Column) => JSX.Element;
|
|
5
5
|
renderRow: (data: T.Data) => JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ComponentType, Size } from 'uilib/types';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
|
-
import { ComponentType } from 'uilib/types';
|
|
3
3
|
export type Column = {
|
|
4
4
|
id: string;
|
|
5
5
|
label: ReactNode;
|
|
@@ -12,9 +12,11 @@ export type Data = {
|
|
|
12
12
|
className?: string;
|
|
13
13
|
} & any;
|
|
14
14
|
export type Props = ComponentType & {
|
|
15
|
+
clear?: boolean;
|
|
15
16
|
columns: Column[];
|
|
16
17
|
data: Data[];
|
|
17
18
|
isLoading?: boolean;
|
|
18
19
|
loadingText?: ReactNode;
|
|
19
20
|
blur?: boolean;
|
|
21
|
+
size?: Size;
|
|
20
22
|
};
|