aio-card 2.0.1 → 2.1.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/index.css +1 -1
- package/index.d.ts +68 -166
- package/index.js +80 -33
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
display: flex;
|
|
29
29
|
align-items: center;
|
|
30
30
|
overflow: hidden;
|
|
31
|
-
gap: 0.4em;
|
|
32
31
|
flex-shrink: 0;
|
|
33
32
|
}
|
|
34
33
|
.aio-card-text{
|
|
@@ -49,6 +48,7 @@
|
|
|
49
48
|
justify-content: center;
|
|
50
49
|
box-sizing: border-box;
|
|
51
50
|
gap:0.4em;
|
|
51
|
+
padding:0 0.4em;
|
|
52
52
|
height:100%;
|
|
53
53
|
}
|
|
54
54
|
.aio-card.disabled{
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { type FC, type ReactNode } from "react";
|
|
2
2
|
import './index.css';
|
|
3
|
-
export type I_CardPopoverRef =
|
|
4
|
-
open: () => void;
|
|
3
|
+
export type I_CardPopoverRef = {
|
|
5
4
|
close: () => void;
|
|
5
|
+
open: () => void;
|
|
6
6
|
isOpen: () => boolean;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type I_cardsOptionFn<T, R> = (row: T, p: {
|
|
9
|
+
index: number;
|
|
10
|
+
value: any;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
row: any;
|
|
13
|
+
}) => R;
|
|
14
|
+
export type I_cardLabel = {
|
|
15
|
+
text?: string;
|
|
16
|
+
online?: boolean;
|
|
17
|
+
attrs?: any;
|
|
18
|
+
};
|
|
8
19
|
export type I_Cards<T> = {
|
|
9
20
|
attrs?: any;
|
|
10
21
|
rtl?: boolean;
|
|
@@ -15,180 +26,71 @@ export type I_Cards<T> = {
|
|
|
15
26
|
items: T[];
|
|
16
27
|
disabled?: boolean;
|
|
17
28
|
placeholder?: ReactNode;
|
|
18
|
-
option
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}) =>
|
|
55
|
-
header?: (row: T, p: {
|
|
56
|
-
index: number;
|
|
57
|
-
value: any;
|
|
58
|
-
disabled: boolean;
|
|
59
|
-
row: any;
|
|
60
|
-
}) => ReactNode | undefined;
|
|
61
|
-
footer?: (row: T, p: {
|
|
62
|
-
index: number;
|
|
63
|
-
value: any;
|
|
64
|
-
disabled: boolean;
|
|
65
|
-
row: any;
|
|
66
|
-
}) => ReactNode | undefined;
|
|
67
|
-
layoutAttrs?: (row: T, p: {
|
|
68
|
-
index: number;
|
|
69
|
-
value: any;
|
|
70
|
-
disabled: boolean;
|
|
71
|
-
row: any;
|
|
72
|
-
}) => any;
|
|
73
|
-
attrs?: (row: T, p: {
|
|
74
|
-
index: number;
|
|
75
|
-
value: any;
|
|
76
|
-
disabled: boolean;
|
|
77
|
-
row: any;
|
|
78
|
-
}) => any;
|
|
79
|
-
footerAttrs?: (row: T, p: {
|
|
80
|
-
index: number;
|
|
81
|
-
value: any;
|
|
82
|
-
disabled: boolean;
|
|
83
|
-
row: any;
|
|
84
|
-
}) => any;
|
|
85
|
-
className?: (row: T, p: {
|
|
86
|
-
index: number;
|
|
87
|
-
value: any;
|
|
88
|
-
disabled: boolean;
|
|
89
|
-
row: any;
|
|
90
|
-
}) => (string | undefined)[] | undefined;
|
|
91
|
-
style?: (row: T, p: {
|
|
92
|
-
index: number;
|
|
93
|
-
value: any;
|
|
94
|
-
disabled: boolean;
|
|
95
|
-
row: any;
|
|
96
|
-
}) => any;
|
|
97
|
-
html?: (row: T, p: {
|
|
98
|
-
index: number;
|
|
99
|
-
value: any;
|
|
100
|
-
disabled: boolean;
|
|
101
|
-
row: any;
|
|
102
|
-
}) => ReactNode;
|
|
103
|
-
showFooter?: (row: T, p: {
|
|
104
|
-
index: number;
|
|
105
|
-
value: any;
|
|
106
|
-
disabled: boolean;
|
|
107
|
-
row: any;
|
|
108
|
-
}) => boolean | undefined;
|
|
109
|
-
close?: (row: T, p: {
|
|
110
|
-
index: number;
|
|
111
|
-
value: any;
|
|
112
|
-
disabled: boolean;
|
|
113
|
-
row: any;
|
|
114
|
-
}) => boolean;
|
|
115
|
-
justify?: (row: T, p: {
|
|
116
|
-
index: number;
|
|
117
|
-
value: any;
|
|
118
|
-
disabled: boolean;
|
|
119
|
-
row: any;
|
|
120
|
-
}) => boolean;
|
|
29
|
+
option?: {
|
|
30
|
+
[key in keyof I_Card]?: I_cardsOptionFn<T, I_Card[key]>;
|
|
31
|
+
};
|
|
32
|
+
cardProps?: (props: I_Card, p: {
|
|
33
|
+
row: T;
|
|
34
|
+
index: number;
|
|
35
|
+
}) => I_Card | undefined;
|
|
36
|
+
};
|
|
37
|
+
export type I_cardPopover = {
|
|
38
|
+
ref?: I_CardPopoverRef;
|
|
39
|
+
onToggle?: (open: boolean) => void;
|
|
40
|
+
focus?: boolean | string;
|
|
41
|
+
portal?: boolean;
|
|
42
|
+
body?: ReactNode;
|
|
43
|
+
fitHorizontal?: boolean;
|
|
44
|
+
backdropAttrs?: any;
|
|
45
|
+
modalAttrs?: any;
|
|
46
|
+
headerAttrs?: any;
|
|
47
|
+
bodyAttrs?: any;
|
|
48
|
+
footerAttrs?: any;
|
|
49
|
+
footer?: any;
|
|
50
|
+
position?: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'fullscreen';
|
|
51
|
+
limitTo?: string;
|
|
52
|
+
header?: {
|
|
53
|
+
html?: ((p: {
|
|
54
|
+
removeModal: () => void;
|
|
55
|
+
state: any;
|
|
56
|
+
setState: any;
|
|
57
|
+
}) => ReactNode);
|
|
58
|
+
title?: string;
|
|
59
|
+
subtitle?: string;
|
|
60
|
+
before?: ReactNode;
|
|
61
|
+
after?: ReactNode;
|
|
62
|
+
onClose?: boolean | ((p: {
|
|
63
|
+
state: any;
|
|
64
|
+
setState: (state: any) => void;
|
|
65
|
+
}) => void);
|
|
121
66
|
};
|
|
122
67
|
};
|
|
123
68
|
export type I_Card = {
|
|
124
|
-
|
|
69
|
+
text?: ReactNode;
|
|
125
70
|
before?: ReactNode[];
|
|
126
71
|
after?: ReactNode[];
|
|
127
|
-
text: ReactNode;
|
|
128
72
|
rtl?: boolean;
|
|
129
|
-
layoutAttrs?: any;
|
|
130
|
-
disabled?: boolean;
|
|
131
73
|
attrs?: any;
|
|
132
74
|
style?: any;
|
|
133
75
|
className?: (string | undefined)[];
|
|
134
|
-
|
|
135
|
-
header?: ReactNode;
|
|
136
|
-
open?: boolean;
|
|
137
|
-
direction?: 'horizontal' | 'vertical';
|
|
138
|
-
show?: boolean;
|
|
139
|
-
draggable?: boolean;
|
|
140
|
-
index?: number;
|
|
141
|
-
tabIndex?: number;
|
|
76
|
+
disabled?: boolean;
|
|
142
77
|
placeholder?: ReactNode;
|
|
143
|
-
|
|
144
|
-
openByCaret?: boolean;
|
|
145
|
-
showFooter?: boolean;
|
|
146
|
-
popoverActions?: I_CardPopoverActions;
|
|
147
|
-
label?: {
|
|
148
|
-
text?: string;
|
|
149
|
-
online?: boolean;
|
|
150
|
-
attrs?: any;
|
|
151
|
-
};
|
|
152
|
-
errorMessage?: string;
|
|
153
|
-
required?: boolean;
|
|
154
|
-
footerAttrs?: any;
|
|
78
|
+
show?: boolean;
|
|
155
79
|
justify?: boolean;
|
|
80
|
+
label?: I_cardLabel;
|
|
81
|
+
required?: boolean;
|
|
82
|
+
errorMessage?: string;
|
|
83
|
+
showError?: boolean;
|
|
156
84
|
close?: boolean;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
footerAttrs?: any;
|
|
167
|
-
footer?: any;
|
|
168
|
-
position?: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'fullscreen';
|
|
169
|
-
limitTo?: string;
|
|
170
|
-
draggable?: boolean;
|
|
171
|
-
header?: {
|
|
172
|
-
html?: ((p: {
|
|
173
|
-
removeModal: () => void;
|
|
174
|
-
state: any;
|
|
175
|
-
setState: any;
|
|
176
|
-
}) => ReactNode);
|
|
177
|
-
title?: string;
|
|
178
|
-
subtitle?: string;
|
|
179
|
-
before?: ReactNode;
|
|
180
|
-
after?: ReactNode;
|
|
181
|
-
onClose?: boolean | ((p: {
|
|
182
|
-
state: any;
|
|
183
|
-
setState: (state: any) => void;
|
|
184
|
-
}) => void);
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
export declare const Cards: <T>({ items, attrs, option, direction, className, style, onSwap, rtl, placeholder, disabled }: I_Cards<T>) => import("react/jsx-runtime").JSX.Element;
|
|
189
|
-
export type I_CardPopoverActions = {
|
|
190
|
-
close: () => void;
|
|
191
|
-
open: () => void;
|
|
192
|
-
isOpen: () => boolean;
|
|
85
|
+
draggable?: boolean;
|
|
86
|
+
footer?: ReactNode;
|
|
87
|
+
header?: ReactNode;
|
|
88
|
+
layoutAttrs?: any;
|
|
89
|
+
caret?: ReactNode | boolean;
|
|
90
|
+
openByCaret?: boolean;
|
|
91
|
+
index?: number;
|
|
92
|
+
popover?: I_cardPopover;
|
|
93
|
+
value?: any;
|
|
193
94
|
};
|
|
95
|
+
export declare const Cards: <T>(props: I_Cards<T>) => import("react/jsx-runtime").JSX.Element;
|
|
194
96
|
export declare const Card: FC<I_Card>;
|
package/index.js
CHANGED
|
@@ -5,7 +5,8 @@ import { DragAndDrop } from "aio-utils";
|
|
|
5
5
|
import { AddToAttrs } from "aio-class";
|
|
6
6
|
import { Mdie, $ } from "aio-deps";
|
|
7
7
|
import './index.css';
|
|
8
|
-
export const Cards = (
|
|
8
|
+
export const Cards = (props) => {
|
|
9
|
+
const { items, attrs, option, direction, className = [], style, onSwap, rtl = false, placeholder } = props;
|
|
9
10
|
const ref = useRef(createRef());
|
|
10
11
|
const kn = useKeyboardNav({
|
|
11
12
|
getContainer: () => ref.current,
|
|
@@ -30,6 +31,50 @@ export const Cards = ({ items, attrs, option, direction, className = [], style,
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
});
|
|
34
|
+
const getCardProps = (row, index) => {
|
|
35
|
+
const show = getByOption({ field: 'show', row, option, index, def: true });
|
|
36
|
+
if (!show) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const _cardProps = {
|
|
40
|
+
show, index,
|
|
41
|
+
value: getByOption({ field: 'value', row, option, index }),
|
|
42
|
+
text: getByOption({ field: 'text', row, option, index, def: '' }),
|
|
43
|
+
before: getByOption({ field: 'before', row, option, index, def: [] }),
|
|
44
|
+
after: getByOption({ field: 'after', row, option, index, def: [] }),
|
|
45
|
+
rtl: getByOption({ field: 'rtl', row, option, index, def: false }),
|
|
46
|
+
attrs: getByOption({ field: 'attrs', row, option, index, def: {} }),
|
|
47
|
+
style: getByOption({ field: 'style', row, option, index, def: {} }),
|
|
48
|
+
className: getByOption({ field: 'className', row, option, index, def: [] }),
|
|
49
|
+
disabled: getByOption({ field: 'disabled', row, option, index, def: !!props.disabled }),
|
|
50
|
+
placeholder: getByOption({ field: 'placeholder', row, option, index, def: undefined }),
|
|
51
|
+
justify: getByOption({ field: 'justify', row, option, index }),
|
|
52
|
+
label: getByOption({ field: 'label', row, option, index }),
|
|
53
|
+
required: getByOption({ field: 'required', row, option, index }),
|
|
54
|
+
errorMessage: getByOption({ field: 'errorMessage', row, option, index }),
|
|
55
|
+
showError: getByOption({ field: 'showError', row, option, index, def: true }),
|
|
56
|
+
close: getByOption({ field: 'close', row, option, index }),
|
|
57
|
+
draggable: !!props.onSwap && getByOption({ field: 'draggable', row, option, index, def: true }),
|
|
58
|
+
footer: getByOption({ field: 'footer', row, option, index }),
|
|
59
|
+
header: getByOption({ field: 'header', row, option, index }),
|
|
60
|
+
layoutAttrs: getByOption({ field: 'layoutAttrs', row, option, index }),
|
|
61
|
+
caret: getByOption({ field: 'caret', row, option, index }),
|
|
62
|
+
openByCaret: getByOption({ field: 'openByCaret', row, option, index }),
|
|
63
|
+
popover: getByOption({ field: 'popover', row, option, index })
|
|
64
|
+
};
|
|
65
|
+
if (props.cardProps) {
|
|
66
|
+
const res = props.cardProps(_cardProps, { row, index });
|
|
67
|
+
if (res === undefined) {
|
|
68
|
+
return _cardProps;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return Object.assign(Object.assign({}, _cardProps), res);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return _cardProps;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
33
78
|
const Attrs = AddToAttrs(Object.assign(Object.assign({ tabIndex: 0 }, attrs), { onKeyDown: kn.keyDown, ref }), {
|
|
34
79
|
className: ['aio-cards', direction === 'horizontal' ? 'aio-cards-horizontal' : undefined, ...className],
|
|
35
80
|
style
|
|
@@ -39,12 +84,19 @@ export const Cards = ({ items, attrs, option, direction, className = [], style,
|
|
|
39
84
|
}
|
|
40
85
|
if (onSwap) {
|
|
41
86
|
return (_jsx(DragAndDrop, { attrs: Attrs, handle: '.aio-card-drag-icon', data: items, getId: (row, { index }) => getByOption({ field: 'value', row, option, index, def: '' }), getContent: (row, { id, index }) => {
|
|
42
|
-
|
|
87
|
+
const cardProps = getCardProps(row, index);
|
|
88
|
+
if (!cardProps) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return _jsx(Card, Object.assign({}, cardProps), id);
|
|
43
92
|
}, onChange: (newOptions, fromIndex, toIndex) => onSwap(newOptions, fromIndex, toIndex) }));
|
|
44
93
|
}
|
|
45
94
|
return (_jsx("div", Object.assign({}, Attrs, { children: items.map((item, i) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
95
|
+
const cardProps = getCardProps(item, i);
|
|
96
|
+
if (!cardProps) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return _jsx(Card, Object.assign({}, cardProps), cardProps.value);
|
|
48
100
|
}) })));
|
|
49
101
|
};
|
|
50
102
|
const getByOption = (p) => {
|
|
@@ -55,7 +107,7 @@ const getByOption = (p) => {
|
|
|
55
107
|
disabled = getByOption(Object.assign(Object.assign({}, p), { def: undefined, field: 'disabled' }));
|
|
56
108
|
}
|
|
57
109
|
}
|
|
58
|
-
const { field, option, row, index, def } = p;
|
|
110
|
+
const { field, option = {}, row, index, def } = p;
|
|
59
111
|
const res = option[field] ? option[field](row, { index, value, disabled: !!disabled, row }) : undefined;
|
|
60
112
|
if (res !== undefined) {
|
|
61
113
|
return res;
|
|
@@ -65,51 +117,40 @@ const getByOption = (p) => {
|
|
|
65
117
|
}
|
|
66
118
|
return def;
|
|
67
119
|
};
|
|
68
|
-
const CardsItem = ({ row, option, index, direction, draggable, disabled }) => {
|
|
69
|
-
const popoverActions = {
|
|
70
|
-
open: () => { },
|
|
71
|
-
close: () => { },
|
|
72
|
-
isOpen: () => false
|
|
73
|
-
};
|
|
74
|
-
const show = getByOption({ field: 'show', row, option, index, def: true });
|
|
75
|
-
if (!show) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
return (_jsx(Card, { popoverActions: popoverActions, index: index, direction: direction, draggable: draggable, showFooter: getByOption({ field: 'showFooter', row, option, index, def: true }), disabled: !!disabled ? true : getByOption({ field: 'disabled', row, option, index, def: false }), close: getByOption({ field: 'close', row, option, index }), footerAttrs: getByOption({ field: 'footerAttrs', row, option, index }), className: getByOption({ field: 'className', row, option, index, def: [] }), style: getByOption({ field: 'style', row, option, index, def: {} }), before: getByOption({ field: 'before', row, option, index, def: [] }), after: getByOption({ field: 'after', row, option, index, def: [] }), text: getByOption({ field: 'text', row, option, index, def: '' }), header: getByOption({ field: 'header', row, option, index }), justify: getByOption({ field: 'justify', row, option, index }), footer: getByOption({ field: 'footer', row, option, index }), layoutAttrs: getByOption({ field: 'layoutAttrs', row, option, index }), attrs: getByOption({ field: 'attrs', row, option, index, def: {} }) }, index));
|
|
79
|
-
};
|
|
80
120
|
const Context = createContext({});
|
|
81
121
|
const Provider = ({ value, children }) => {
|
|
82
122
|
return _jsx(Context.Provider, { value: value, children: children });
|
|
83
123
|
};
|
|
84
124
|
const useProvider = () => useContext(Context);
|
|
85
125
|
export const Card = (props) => {
|
|
86
|
-
const { text, footer, header, layoutAttrs,
|
|
126
|
+
const { text, footer, header, layoutAttrs, show = true, placeholder, errorMessage, label, required, popover, showError } = props;
|
|
87
127
|
const mainRef = useRef(null);
|
|
88
128
|
const popup = usePopup();
|
|
89
129
|
const cardClass = CardClass(mainRef, popup);
|
|
90
130
|
if (!show) {
|
|
91
131
|
return null;
|
|
92
132
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
133
|
+
if (popover === null || popover === void 0 ? void 0 : popover.ref) {
|
|
134
|
+
popover.ref.open = () => cardClass.openPopover(props);
|
|
135
|
+
popover.ref.close = () => cardClass.closePopover(props);
|
|
136
|
+
popover.ref.isOpen = () => !!popup.getModals().length;
|
|
97
137
|
}
|
|
98
138
|
const { beforeNodes, afterNodes } = cardClass.getSideNodes(props);
|
|
99
|
-
const card =
|
|
139
|
+
const card = (_jsxs(_Fragment, { children: [_jsxs("div", Object.assign({}, cardClass.getCardAttrs(props), { children: [_jsx(CardBefore, { befores: beforeNodes }), text !== undefined && text !== null && _jsx(CardText, { text: text, placeholder: placeholder, justify: props.justify }), _jsx(CardAfter, { afters: afterNodes })] })), !(popover === null || popover === void 0 ? void 0 : popover.portal) && popup.render(), !!(popover === null || popover === void 0 ? void 0 : popover.portal) && popup.portal()] }));
|
|
100
140
|
let result = card;
|
|
101
141
|
if (errorMessage || label || header || footer || layoutAttrs) {
|
|
102
142
|
const attrs = AddToAttrs(layoutAttrs, { className: ["aio-card-layout"] });
|
|
103
|
-
result = (_jsxs("div", Object.assign({}, attrs, { children: [!!label && _jsx(CardLabel, { required: required, label: label,
|
|
104
|
-
_jsx("div", Object.assign({}, AddToAttrs(
|
|
143
|
+
result = (_jsxs("div", Object.assign({}, attrs, { children: [!!label && _jsx(CardLabel, { required: required, label: label, errorMessage: errorMessage }), header !== undefined && _jsx("div", { className: "aio-card-header", children: header }), _jsx("div", { className: "aio-card-body", children: card }), footer !== undefined &&
|
|
144
|
+
_jsx("div", Object.assign({}, AddToAttrs({}, { className: ['aio-card-footer'] }), { children: footer })), !!errorMessage && showError !== false && _jsx("div", { className: "aio-card-error", children: errorMessage })] })));
|
|
105
145
|
}
|
|
106
146
|
return (_jsx(Provider, { value: { rootProps: props, cardClass }, children: result }));
|
|
107
147
|
};
|
|
108
|
-
const CardLabel = ({ label, required,
|
|
148
|
+
const CardLabel = ({ label, required, errorMessage }) => {
|
|
109
149
|
if (!label === undefined || !(label === null || label === void 0 ? void 0 : label.text)) {
|
|
110
150
|
return null;
|
|
111
151
|
}
|
|
112
|
-
|
|
152
|
+
const attrs = AddToAttrs(label.attrs, { className: ['aio-card-label', !!errorMessage ? 'has-error' : undefined], attrs: { title: errorMessage } });
|
|
153
|
+
let labelContent = (_jsxs("label", Object.assign({}, attrs, { children: [required ? _jsx("div", { className: "aio-card-required", children: "*" }) : null, label.text] })));
|
|
113
154
|
if (label.online) {
|
|
114
155
|
return _jsx("div", { className: "aio-card-online-label", children: labelContent });
|
|
115
156
|
}
|
|
@@ -137,9 +178,6 @@ const CardCaret = () => {
|
|
|
137
178
|
if (caret === true) {
|
|
138
179
|
return Mdie('mdiChevronDown', .8);
|
|
139
180
|
}
|
|
140
|
-
if (typeof caret === 'function') {
|
|
141
|
-
return caret(cardClass.isPopoverOpen());
|
|
142
|
-
}
|
|
143
181
|
if (caret) {
|
|
144
182
|
return caret;
|
|
145
183
|
}
|
|
@@ -179,7 +217,8 @@ function CardClass(mainRef, popup) {
|
|
|
179
217
|
return false;
|
|
180
218
|
};
|
|
181
219
|
const cardClick = (mainProps, e) => {
|
|
182
|
-
|
|
220
|
+
var _a;
|
|
221
|
+
const { disabled, attrs, popover, openByCaret, close } = mainProps;
|
|
183
222
|
if (disabled) {
|
|
184
223
|
return;
|
|
185
224
|
}
|
|
@@ -189,7 +228,7 @@ function CardClass(mainRef, popup) {
|
|
|
189
228
|
else if (attrs === null || attrs === void 0 ? void 0 : attrs.onClick) {
|
|
190
229
|
attrs.onClick(e);
|
|
191
230
|
if (close) {
|
|
192
|
-
|
|
231
|
+
(_a = popover === null || popover === void 0 ? void 0 : popover.ref) === null || _a === void 0 ? void 0 : _a.close();
|
|
193
232
|
}
|
|
194
233
|
}
|
|
195
234
|
};
|
|
@@ -223,6 +262,7 @@ function CardClass(mainRef, popup) {
|
|
|
223
262
|
return obj;
|
|
224
263
|
};
|
|
225
264
|
const openPopover = (mainProps) => {
|
|
265
|
+
var _a;
|
|
226
266
|
let open = !!popup.getModals().length;
|
|
227
267
|
if (open) {
|
|
228
268
|
return;
|
|
@@ -232,9 +272,16 @@ function CardClass(mainRef, popup) {
|
|
|
232
272
|
return;
|
|
233
273
|
}
|
|
234
274
|
popup.addModal(popover);
|
|
275
|
+
if ((_a = mainProps.popover) === null || _a === void 0 ? void 0 : _a.onToggle) {
|
|
276
|
+
mainProps.popover.onToggle(true);
|
|
277
|
+
}
|
|
235
278
|
};
|
|
236
|
-
const closePopover = () => {
|
|
279
|
+
const closePopover = (mainProps) => {
|
|
280
|
+
var _a;
|
|
237
281
|
popup.removeModal();
|
|
282
|
+
if ((_a = mainProps.popover) === null || _a === void 0 ? void 0 : _a.onToggle) {
|
|
283
|
+
mainProps.popover.onToggle(false);
|
|
284
|
+
}
|
|
238
285
|
};
|
|
239
286
|
return {
|
|
240
287
|
getSideNodes, getCardAttrs, openPopover, closePopover, isPopoverOpen
|