aio-card 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/index.css +143 -0
- package/index.d.ts +235 -0
- package/index.js +486 -0
- package/package.json +27 -0
package/index.css
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
.aio-cards {
|
|
2
|
+
width: 100%;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.aio-cards-horizontal{
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
flex-wrap:wrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.aio-cards-header {
|
|
14
|
+
padding: 0.4em 0.6em;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.aio-card-text{
|
|
18
|
+
height:100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.aio-card-footer{
|
|
22
|
+
overflow:hidden;
|
|
23
|
+
}
|
|
24
|
+
.aio-card {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
gap: 0.4em;
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
}
|
|
31
|
+
.aio-card-text{
|
|
32
|
+
flex:1;
|
|
33
|
+
display:flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
.aio-card-fit-content{
|
|
37
|
+
width: fit-content;
|
|
38
|
+
}
|
|
39
|
+
.aio-card-content{
|
|
40
|
+
display:flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}
|
|
43
|
+
.aio-card-before {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
gap:0.4em;
|
|
49
|
+
height:100%;
|
|
50
|
+
}
|
|
51
|
+
.aio-card.disabled{
|
|
52
|
+
cursor:not-allowed;
|
|
53
|
+
opacity:0.6
|
|
54
|
+
}
|
|
55
|
+
.aio-card-after {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
height:100%;
|
|
61
|
+
gap:0.4em;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
.aio-card-pointer{
|
|
65
|
+
cursor:pointer;
|
|
66
|
+
}
|
|
67
|
+
.aio-card-center {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
flex: 1;
|
|
73
|
+
}
|
|
74
|
+
.aio-input.aio-card-actions{
|
|
75
|
+
background:none;
|
|
76
|
+
border:none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.aio-cards-placeholder {
|
|
80
|
+
min-height: 1em;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
font-size: 0.8em;
|
|
85
|
+
opacity:0.6;
|
|
86
|
+
width:100%;
|
|
87
|
+
padding:0.8em;
|
|
88
|
+
}
|
|
89
|
+
.aio-card-placeholder{
|
|
90
|
+
opacity:0.6;
|
|
91
|
+
font-size:90%;
|
|
92
|
+
}
|
|
93
|
+
.ai-card:focus{
|
|
94
|
+
box-shadow:inset 0 0 1px 1px #0099ffaa;
|
|
95
|
+
}
|
|
96
|
+
.aio-card-error {
|
|
97
|
+
color: red;
|
|
98
|
+
font-size: 0.7em;
|
|
99
|
+
width: 100%;
|
|
100
|
+
bottom: -1em;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.aio-card-label.has-error .aio-card-required {
|
|
104
|
+
color: red;
|
|
105
|
+
}
|
|
106
|
+
.aio-card-label {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
width: 100%;
|
|
110
|
+
padding: 0 0.4em;
|
|
111
|
+
gap: 0.4em;
|
|
112
|
+
margin-bottom: 0.2em;
|
|
113
|
+
flex-shrink: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.aio-card-online-label {
|
|
117
|
+
position: absolute;
|
|
118
|
+
z-index: 10;
|
|
119
|
+
top: -2px;
|
|
120
|
+
padding: 0 .8em;
|
|
121
|
+
width: 100%;
|
|
122
|
+
height: 4px;
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.aio-card-online-label .aio-card-label {
|
|
128
|
+
background: #fff;
|
|
129
|
+
height: 4px;
|
|
130
|
+
width: fit-content;
|
|
131
|
+
margin-bottom: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.aio-card-layout{
|
|
135
|
+
position: relative;
|
|
136
|
+
display:flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
}
|
|
139
|
+
.aio-card-text-justify{
|
|
140
|
+
justify-content: center;
|
|
141
|
+
align-items: center;
|
|
142
|
+
text-align: center;
|
|
143
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { type FC, ReactNode } from "react";
|
|
2
|
+
import './index.css';
|
|
3
|
+
export type I_CardPopoverRef = React.RefObject<{
|
|
4
|
+
open: () => void;
|
|
5
|
+
close: () => void;
|
|
6
|
+
isOpen: () => boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export type I_Cards<T> = {
|
|
9
|
+
attrs?: any;
|
|
10
|
+
rtl?: boolean;
|
|
11
|
+
className?: string[];
|
|
12
|
+
style?: any;
|
|
13
|
+
onSwap?: ((newItems: T[], fromIndex: number, toIndex: number) => void);
|
|
14
|
+
direction?: 'horizontal' | 'vertical';
|
|
15
|
+
items: T[];
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
placeholder?: ReactNode;
|
|
18
|
+
option: {
|
|
19
|
+
text?: (p: {
|
|
20
|
+
row: T;
|
|
21
|
+
index: number;
|
|
22
|
+
}) => ReactNode;
|
|
23
|
+
value?: (p: {
|
|
24
|
+
row: T;
|
|
25
|
+
index: number;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
show?: (p: {
|
|
28
|
+
row: T;
|
|
29
|
+
index: number;
|
|
30
|
+
}) => boolean | undefined;
|
|
31
|
+
before?: (p: {
|
|
32
|
+
row: T;
|
|
33
|
+
index: number;
|
|
34
|
+
}) => ReactNode[] | undefined;
|
|
35
|
+
after?: (p: {
|
|
36
|
+
row: T;
|
|
37
|
+
index: number;
|
|
38
|
+
}) => ReactNode[] | undefined;
|
|
39
|
+
disabled?: (p: {
|
|
40
|
+
row: T;
|
|
41
|
+
index: number;
|
|
42
|
+
}) => boolean | undefined;
|
|
43
|
+
header?: (p: {
|
|
44
|
+
row: T;
|
|
45
|
+
index: number;
|
|
46
|
+
}) => ReactNode | undefined;
|
|
47
|
+
footer?: (p: {
|
|
48
|
+
row: T;
|
|
49
|
+
index: number;
|
|
50
|
+
}) => ReactNode | undefined;
|
|
51
|
+
layoutAttrs?: (p: {
|
|
52
|
+
row: T;
|
|
53
|
+
index: number;
|
|
54
|
+
}) => any;
|
|
55
|
+
attrs?: (p: {
|
|
56
|
+
row: T;
|
|
57
|
+
index: number;
|
|
58
|
+
}) => any;
|
|
59
|
+
footerAttrs?: (p: {
|
|
60
|
+
row: T;
|
|
61
|
+
index: number;
|
|
62
|
+
}) => any;
|
|
63
|
+
className?: (p: {
|
|
64
|
+
row: T;
|
|
65
|
+
index: number;
|
|
66
|
+
}) => (string | undefined)[] | undefined;
|
|
67
|
+
style?: (p: {
|
|
68
|
+
row: T;
|
|
69
|
+
index: number;
|
|
70
|
+
}) => any;
|
|
71
|
+
onClick?: (p: {
|
|
72
|
+
row: T;
|
|
73
|
+
index: number;
|
|
74
|
+
e?: React.MouseEvent<HTMLDivElement>;
|
|
75
|
+
}) => void;
|
|
76
|
+
actions?: (p: {
|
|
77
|
+
row: T;
|
|
78
|
+
index: number;
|
|
79
|
+
}) => {
|
|
80
|
+
text: ReactNode;
|
|
81
|
+
before?: ReactNode;
|
|
82
|
+
onClick?: () => void;
|
|
83
|
+
}[];
|
|
84
|
+
html?: (p: {
|
|
85
|
+
row: T;
|
|
86
|
+
index: number;
|
|
87
|
+
}) => ReactNode;
|
|
88
|
+
showFooter?: (p: {
|
|
89
|
+
row: T;
|
|
90
|
+
index: number;
|
|
91
|
+
}) => boolean | undefined;
|
|
92
|
+
close?: (p: {
|
|
93
|
+
row: T;
|
|
94
|
+
index: number;
|
|
95
|
+
}) => boolean;
|
|
96
|
+
justify?: (p: {
|
|
97
|
+
row: T;
|
|
98
|
+
index: number;
|
|
99
|
+
}) => boolean;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export type I_Card = {
|
|
103
|
+
before?: ReactNode[];
|
|
104
|
+
after?: ReactNode[];
|
|
105
|
+
text: ReactNode;
|
|
106
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
107
|
+
rtl?: boolean;
|
|
108
|
+
actions?: {
|
|
109
|
+
text: ReactNode;
|
|
110
|
+
before?: ReactNode;
|
|
111
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
112
|
+
}[];
|
|
113
|
+
layoutAttrs?: any;
|
|
114
|
+
disabled?: boolean;
|
|
115
|
+
attrs?: any;
|
|
116
|
+
style?: any;
|
|
117
|
+
className?: (string | undefined)[];
|
|
118
|
+
footer?: ReactNode;
|
|
119
|
+
header?: ReactNode;
|
|
120
|
+
open?: boolean;
|
|
121
|
+
direction?: 'horizontal' | 'vertical';
|
|
122
|
+
show?: boolean;
|
|
123
|
+
draggable?: boolean;
|
|
124
|
+
index?: number;
|
|
125
|
+
tabIndex?: number;
|
|
126
|
+
placeholder?: ReactNode;
|
|
127
|
+
caret?: ReactNode | boolean | ((isOpen: boolean) => ReactNode);
|
|
128
|
+
openByCaret?: boolean;
|
|
129
|
+
showFooter?: boolean;
|
|
130
|
+
popoverActions?: I_CardPopoverActions;
|
|
131
|
+
label?: {
|
|
132
|
+
text?: string;
|
|
133
|
+
online?: boolean;
|
|
134
|
+
attrs?: any;
|
|
135
|
+
};
|
|
136
|
+
errorMessage?: string;
|
|
137
|
+
required?: boolean;
|
|
138
|
+
footerAttrs?: any;
|
|
139
|
+
justify?: boolean;
|
|
140
|
+
popover?: {
|
|
141
|
+
focus?: boolean | string;
|
|
142
|
+
portal?: boolean;
|
|
143
|
+
body?: ReactNode;
|
|
144
|
+
fitHorizontal?: boolean;
|
|
145
|
+
backdropAttrs?: any;
|
|
146
|
+
modalAttrs?: any;
|
|
147
|
+
headerAttrs?: any;
|
|
148
|
+
bodyAttrs?: any;
|
|
149
|
+
footerAttrs?: any;
|
|
150
|
+
footer?: any;
|
|
151
|
+
position?: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'fullscreen';
|
|
152
|
+
limitTo?: string;
|
|
153
|
+
draggable?: boolean;
|
|
154
|
+
header?: {
|
|
155
|
+
html?: ((p: {
|
|
156
|
+
removeModal: () => void;
|
|
157
|
+
state: any;
|
|
158
|
+
setState: any;
|
|
159
|
+
}) => ReactNode);
|
|
160
|
+
title?: string;
|
|
161
|
+
subtitle?: string;
|
|
162
|
+
before?: ReactNode;
|
|
163
|
+
after?: ReactNode;
|
|
164
|
+
onClose?: boolean | ((p: {
|
|
165
|
+
state: any;
|
|
166
|
+
setState: (state: any) => void;
|
|
167
|
+
}) => void);
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
export declare const Cards: <T>({ items, attrs, option, direction, className, style, onSwap, rtl, placeholder, disabled }: I_Cards<T>) => import("react/jsx-runtime").JSX.Element;
|
|
172
|
+
export type I_CardPopoverActions = {
|
|
173
|
+
close: () => void;
|
|
174
|
+
open: () => void;
|
|
175
|
+
isOpen: () => boolean;
|
|
176
|
+
};
|
|
177
|
+
export declare const Card: FC<I_Card>;
|
|
178
|
+
export declare class GetSvg {
|
|
179
|
+
private unit;
|
|
180
|
+
constructor(unit?: 'rem' | 'em');
|
|
181
|
+
private getStyle;
|
|
182
|
+
private getSvgStyle;
|
|
183
|
+
private fixSvgContent;
|
|
184
|
+
getIcon: (path: string, size?: number, p?: {
|
|
185
|
+
spin?: number;
|
|
186
|
+
color?: string;
|
|
187
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
188
|
+
private getFileIconName;
|
|
189
|
+
getFileIcon: (file: File, size?: number, p?: {
|
|
190
|
+
spin?: number;
|
|
191
|
+
color?: string;
|
|
192
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
193
|
+
mdiArrowDown: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
194
|
+
mdiArrowUp: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
195
|
+
mdiAttachment: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
196
|
+
mdiChevronDown: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
197
|
+
mdiChevronUp: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
198
|
+
mdiChevronRight: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
199
|
+
mdiCircleSmall: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
200
|
+
mdiCheckBold: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
201
|
+
mdiCheckboxMarked: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
202
|
+
mdiChevronLeft: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
203
|
+
mdiCircleMedium: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
204
|
+
mdiClose: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
205
|
+
mdiDelete: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
206
|
+
mdiDotsHorizontal: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
207
|
+
mdiEye: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
208
|
+
mdiEyeOff: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
209
|
+
mdiFile: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
210
|
+
mdiFileExcel: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
211
|
+
mdiFilter: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
212
|
+
mdiImage: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
213
|
+
mdiLoading: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
214
|
+
mdiListBox: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
215
|
+
mdiMagnify: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
216
|
+
mdiMenu: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
217
|
+
mdiMicrophoneOutline: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
218
|
+
mdiPlusThick: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
219
|
+
mdiSaveContent: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
220
|
+
mdiSelect: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
221
|
+
mdiSort: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
222
|
+
mdiMusic: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
223
|
+
mdiFilePdfBox: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
224
|
+
mdiFileWordBox: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
225
|
+
mdiFileExcelBox: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
226
|
+
mdiFilePowerPointBox: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
227
|
+
mdiZipBox: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
228
|
+
mdiCamera: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
229
|
+
mdiArrowUpDownBold: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
230
|
+
mdiSortVariantOff: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
231
|
+
mdiDownload: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
232
|
+
mdiCalculator: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
233
|
+
mdiPencil: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
234
|
+
mdiUpload: (color?: string) => import("react/jsx-runtime").JSX.Element;
|
|
235
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, createRef, useContext, useRef } from "react";
|
|
3
|
+
import * as UT from './../aio-utils';
|
|
4
|
+
import usePopup from './../aio-popup';
|
|
5
|
+
import { AISelect } from "../aio-input";
|
|
6
|
+
import $ from 'jquery';
|
|
7
|
+
import './index.css';
|
|
8
|
+
export const Cards = ({ items, attrs, option, direction, className = [], style, onSwap, rtl = false, placeholder, disabled }) => {
|
|
9
|
+
const ref = useRef(createRef());
|
|
10
|
+
const kn = useKeyboardNav({
|
|
11
|
+
getContainer: () => ref.current,
|
|
12
|
+
rtl,
|
|
13
|
+
isActive: (index) => {
|
|
14
|
+
const disabled = getByOption({ option, field: 'disabled', row: items[index], index });
|
|
15
|
+
const show = getByOption({ option, field: 'show', row: items[index], index, def: true });
|
|
16
|
+
return !disabled && !!show;
|
|
17
|
+
},
|
|
18
|
+
itemClassName: 'aio-card',
|
|
19
|
+
getLength: () => items.length,
|
|
20
|
+
onEnter: (e, index) => {
|
|
21
|
+
const row = items[index];
|
|
22
|
+
if (option.onClick) {
|
|
23
|
+
option.onClick({ e, row, index });
|
|
24
|
+
}
|
|
25
|
+
else if (typeof row === 'object' && row.onClick) {
|
|
26
|
+
row.onClick({ e, row, index });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const Attrs = UT.AddToAttrs(Object.assign(Object.assign({ tabIndex: 0 }, attrs), { onKeyDown: kn.keyDown, ref }), {
|
|
31
|
+
className: ['aio-cards', direction === 'horizontal' ? 'aio-cards-horizontal' : undefined, ...className],
|
|
32
|
+
style
|
|
33
|
+
});
|
|
34
|
+
if (!items.length && placeholder) {
|
|
35
|
+
return (_jsx("div", { className: "aio-cards-placeholder", children: placeholder }));
|
|
36
|
+
}
|
|
37
|
+
if (onSwap) {
|
|
38
|
+
return (_jsx("div", Object.assign({}, Attrs, { children: _jsx(UT.DragAndDrop, { handle: '.aio-card-drag-icon', data: items, getId: (row, { index }) => getByOption({ field: 'value', row, option, index, def: '' }), getContent: (row, { id, index }) => {
|
|
39
|
+
return _jsx(CardsItem, { row: row, option: option, index: index, direction: direction, value: id, draggable: !!onSwap, disabled: disabled }, id);
|
|
40
|
+
}, onChange: (newOptions, fromIndex, toIndex) => onSwap(newOptions, fromIndex, toIndex) }) })));
|
|
41
|
+
}
|
|
42
|
+
return (_jsx("div", Object.assign({}, Attrs, { children: items.map((item, i) => {
|
|
43
|
+
const value = getByOption({ field: 'value', row: item, option, index: i, def: '' });
|
|
44
|
+
return _jsx(CardsItem, { row: item, option: option, index: i, direction: direction, value: value, draggable: !!onSwap, disabled: disabled }, value);
|
|
45
|
+
}) })));
|
|
46
|
+
};
|
|
47
|
+
const getByOption = (p) => {
|
|
48
|
+
const { field, option, row, index, def } = p;
|
|
49
|
+
const res = option[field] ? option[field]({ row, index }) : undefined;
|
|
50
|
+
if (res !== undefined) {
|
|
51
|
+
return res;
|
|
52
|
+
}
|
|
53
|
+
if (typeof row === 'object' && row[field] !== undefined) {
|
|
54
|
+
return row[field];
|
|
55
|
+
}
|
|
56
|
+
return def;
|
|
57
|
+
};
|
|
58
|
+
const CardsItem = ({ row, option, index, direction, draggable, disabled }) => {
|
|
59
|
+
const popoverActions = {
|
|
60
|
+
open: () => { },
|
|
61
|
+
close: () => { },
|
|
62
|
+
isOpen: () => false
|
|
63
|
+
};
|
|
64
|
+
const show = getByOption({ field: 'show', row, option, index, def: true });
|
|
65
|
+
if (!show) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
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 }), attrs: getByOption({ field: 'attrs', row, option, index, def: {} }), 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 }), actions: getByOption({ field: 'actions', row, option, index, def: [] }), onClick: (e) => {
|
|
69
|
+
if (option.onClick) {
|
|
70
|
+
option.onClick({ row, index, e });
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const attrs = getByOption({ field: 'attrs', row, option, index });
|
|
74
|
+
if (attrs === null || attrs === void 0 ? void 0 : attrs.onClick) {
|
|
75
|
+
attrs.onClick(e);
|
|
76
|
+
}
|
|
77
|
+
else if (typeof row === 'object' && row.onClick) {
|
|
78
|
+
row.onClick(e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (getByOption({ field: 'close', row, option, index })) {
|
|
82
|
+
popoverActions.close();
|
|
83
|
+
}
|
|
84
|
+
} }, index));
|
|
85
|
+
};
|
|
86
|
+
const Context = createContext({});
|
|
87
|
+
const Provider = ({ value, children }) => {
|
|
88
|
+
return _jsx(Context.Provider, { value: value, children: children });
|
|
89
|
+
};
|
|
90
|
+
const useProvider = () => useContext(Context);
|
|
91
|
+
export const Card = (props) => {
|
|
92
|
+
const { text, footer, header, layoutAttrs, showFooter, show = true, placeholder, popoverActions, errorMessage, label, required, footerAttrs, justify } = props;
|
|
93
|
+
const mainRef = useRef(null);
|
|
94
|
+
const popup = usePopup();
|
|
95
|
+
const cardClass = CardClass(mainRef, popup);
|
|
96
|
+
if (!show) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
if (popoverActions) {
|
|
100
|
+
popoverActions.open = () => cardClass.openPopover(props);
|
|
101
|
+
popoverActions.close = () => cardClass.closePopover();
|
|
102
|
+
popoverActions.isOpen = () => !!popup.getModals().length;
|
|
103
|
+
}
|
|
104
|
+
const { beforeNodes, afterNodes } = cardClass.getSideNodes(props);
|
|
105
|
+
const card = (_jsxs(_Fragment, { children: [_jsxs("div", Object.assign({}, cardClass.getCardAttrs(props), { children: [_jsx(CardBefore, { befores: beforeNodes }), _jsx(CardText, { text: text, placeholder: placeholder, justify: props.justify }), _jsx(CardAfter, { afters: afterNodes })] })), popup.render()] }));
|
|
106
|
+
let result = card;
|
|
107
|
+
if (errorMessage || label || header || footer || layoutAttrs) {
|
|
108
|
+
const attrs = UT.AddToAttrs(layoutAttrs, { className: ["aio-card-layout"] });
|
|
109
|
+
result = (_jsxs("div", Object.assign({}, attrs, { children: [!!label && _jsx(CardLabel, { required: required, label: label, error: errorMessage }), header !== undefined && _jsx("div", { className: "aio-card-header", children: header }), _jsx("div", { className: "aio-card-body", children: card }), footer !== undefined && showFooter !== false &&
|
|
110
|
+
_jsx("div", Object.assign({}, UT.AddToAttrs(footerAttrs, { className: ['aio-card-footer'] }), { children: footer })), !!errorMessage && _jsx("div", { className: "aio-card-error", children: errorMessage })] })));
|
|
111
|
+
}
|
|
112
|
+
return (_jsx(Provider, { value: { rootProps: props, cardClass }, children: result }));
|
|
113
|
+
};
|
|
114
|
+
const CardLabel = ({ label, required, error }) => {
|
|
115
|
+
if (!label === undefined || !(label === null || label === void 0 ? void 0 : label.text)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
let labelContent = (_jsxs("label", Object.assign({}, UT.AddToAttrs(label.attrs, { className: ['aio-card-label', !!error ? 'has-error' : undefined], attrs: { title: error } }), { children: [required ? _jsx("div", { className: "aio-card-required", children: "*" }) : null, label.text] })));
|
|
119
|
+
if (label.online) {
|
|
120
|
+
return _jsx("div", { className: "aio-card-online-label", children: labelContent });
|
|
121
|
+
}
|
|
122
|
+
return _jsx(_Fragment, { children: labelContent });
|
|
123
|
+
};
|
|
124
|
+
const CardText = ({ text, placeholder, justify }) => {
|
|
125
|
+
return (_jsxs("div", { className: `aio-card-text${justify ? ' aio-card-text-justify' : ''}`, children: [text !== undefined && text, text === undefined && placeholder !== undefined && (_jsx("div", { className: "aio-card-placeholder", children: placeholder }))] }));
|
|
126
|
+
};
|
|
127
|
+
const CardBefore = ({ befores }) => {
|
|
128
|
+
if (!befores.length) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return (_jsx("div", { className: `aio-card-before`, children: befores.map((o, i) => _jsx("div", { style: { display: 'contents' }, children: o }, i)) }));
|
|
132
|
+
};
|
|
133
|
+
const CardAfter = ({ afters }) => {
|
|
134
|
+
if (!afters.length) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return (_jsx("div", { className: `aio-card-after`, children: afters.map((o, i) => _jsx("div", { style: { display: 'contents' }, children: o }, i)) }));
|
|
138
|
+
};
|
|
139
|
+
const CardCaret = () => {
|
|
140
|
+
const { rootProps, cardClass } = useProvider();
|
|
141
|
+
const { caret = true, openByCaret } = rootProps;
|
|
142
|
+
const getContnet = () => {
|
|
143
|
+
if (caret === true) {
|
|
144
|
+
return new UT.GetSvg('em').getIcon('mdiChevronDown', .8);
|
|
145
|
+
}
|
|
146
|
+
if (typeof caret === 'function') {
|
|
147
|
+
return caret(cardClass.isPopoverOpen());
|
|
148
|
+
}
|
|
149
|
+
if (caret) {
|
|
150
|
+
return caret;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return (_jsx("div", { className: "aio-card-caret", onClick: openByCaret ? () => cardClass.openPopover(rootProps) : undefined, children: getContnet() }));
|
|
154
|
+
};
|
|
155
|
+
const CardActions = ({ actions }) => {
|
|
156
|
+
return (_jsx(AISelect, { className: 'aio-card-actions', text: new GetSvg().getIcon('mdiDotsHorizontal', 0.7), options: actions || [], option: {
|
|
157
|
+
text: (o) => o.text,
|
|
158
|
+
before: (o) => o.before,
|
|
159
|
+
onClick: (o) => o.onClick
|
|
160
|
+
}, popover: { portal: true }, caret: false }));
|
|
161
|
+
};
|
|
162
|
+
function CardClass(mainRef, popup) {
|
|
163
|
+
const isPopoverOpen = () => !!popup.getModals().length;
|
|
164
|
+
const _getSideNodes = (mainProps, type) => {
|
|
165
|
+
var _a;
|
|
166
|
+
const Nodes = mainProps[type] || [];
|
|
167
|
+
const nodes = Nodes.filter((o) => !!o && o !== null);
|
|
168
|
+
const hasCaret = !!mainProps.popover && mainProps.caret !== false && type === 'after';
|
|
169
|
+
if (((_a = mainProps.actions) === null || _a === void 0 ? void 0 : _a.length) && type === 'after') {
|
|
170
|
+
nodes.splice(0, 0, _jsx(CardActions, { actions: mainProps.actions }));
|
|
171
|
+
}
|
|
172
|
+
if (hasCaret) {
|
|
173
|
+
nodes.push(_jsx(CardCaret, {}));
|
|
174
|
+
}
|
|
175
|
+
if (mainProps.draggable && type === 'before') {
|
|
176
|
+
nodes.splice(0, 0, _jsx(DragIcon, {}));
|
|
177
|
+
}
|
|
178
|
+
return nodes;
|
|
179
|
+
};
|
|
180
|
+
const getSideNodes = (mainProps) => {
|
|
181
|
+
const beforeNodes = _getSideNodes(mainProps, 'before');
|
|
182
|
+
const afterNodes = _getSideNodes(mainProps, 'after');
|
|
183
|
+
return { beforeNodes, afterNodes };
|
|
184
|
+
};
|
|
185
|
+
const hasCardClick = (mainProps) => {
|
|
186
|
+
const { disabled, onClick, popover, openByCaret } = mainProps;
|
|
187
|
+
if (disabled) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (popover && !openByCaret) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
else if (onClick) {
|
|
194
|
+
true;
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
};
|
|
198
|
+
const cardClick = (mainProps, e) => {
|
|
199
|
+
const { disabled, onClick, popover, openByCaret } = mainProps;
|
|
200
|
+
if (disabled) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (popover && !openByCaret) {
|
|
204
|
+
openPopover(mainProps);
|
|
205
|
+
}
|
|
206
|
+
else if (onClick) {
|
|
207
|
+
onClick(e);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const getCardAttrs = (mainProps) => {
|
|
211
|
+
const { attrs, disabled, className = [], style, index = 0 } = mainProps;
|
|
212
|
+
const onKeyDown = (e) => {
|
|
213
|
+
const code = e.keyCode;
|
|
214
|
+
if (code === 13) {
|
|
215
|
+
cardClick(mainProps, e);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const defAttrs = Object.assign(Object.assign({ "data-index": index, onKeyDown }, attrs), { ref: mainRef, onClick: (e) => cardClick(mainProps, e) });
|
|
219
|
+
const Attrs = UT.AddToAttrs(defAttrs, { className: [...className, "aio-card"], style });
|
|
220
|
+
if (hasCardClick(mainProps)) {
|
|
221
|
+
Attrs.className += ' aio-card-pointer';
|
|
222
|
+
}
|
|
223
|
+
if (disabled) {
|
|
224
|
+
Attrs.className += ' disabled';
|
|
225
|
+
}
|
|
226
|
+
if (popup.getModals().length) {
|
|
227
|
+
Attrs.className += ' aio-card-open';
|
|
228
|
+
}
|
|
229
|
+
return Attrs;
|
|
230
|
+
};
|
|
231
|
+
const getPopover = (mainProps) => {
|
|
232
|
+
const { popover } = mainProps;
|
|
233
|
+
if (!popover) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
let obj = Object.assign(Object.assign({}, popover), { body: popover.body || null, isPopover: true, rtl: !!mainProps.rtl, position: popover.position || 'popover', getTarget: () => {
|
|
237
|
+
const res = $(mainRef.current);
|
|
238
|
+
return res;
|
|
239
|
+
} });
|
|
240
|
+
return obj;
|
|
241
|
+
};
|
|
242
|
+
const openPopover = (mainProps) => {
|
|
243
|
+
let open = !!popup.getModals().length;
|
|
244
|
+
if (open) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const popover = getPopover(mainProps);
|
|
248
|
+
if (!popover) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
popup.addModal(popover);
|
|
252
|
+
};
|
|
253
|
+
const closePopover = () => {
|
|
254
|
+
popup.removeModal();
|
|
255
|
+
};
|
|
256
|
+
return {
|
|
257
|
+
getSideNodes, getCardAttrs, openPopover, closePopover, isPopoverOpen
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const DragIcon = () => {
|
|
261
|
+
const d = "M9,3H11V5H9V3M13,3H15V5H13V3M9,7H11V9H9V7M13,7H15V9H13V7M9,11H11V13H9V11M13,11H15V13H13V11M9,15H11V17H9V15M13,15H15V17H13V15M9,19H11V21H9V19M13,19H15V21H13V19Z";
|
|
262
|
+
return _jsx("svg", { className: 'aio-card-drag-icon', viewBox: "8 4 10 13", role: "presentation", style: { width: 12, height: '1.8rem' }, children: _jsx("path", { d: d, style: { fill: 'currentcolor' } }) });
|
|
263
|
+
};
|
|
264
|
+
export class GetSvg {
|
|
265
|
+
constructor(unit) {
|
|
266
|
+
this.getStyle = (color) => ({ fill: color || "currentcolor" });
|
|
267
|
+
this.getSvgStyle = (size) => {
|
|
268
|
+
size = size || 1;
|
|
269
|
+
return { width: `${size * 1.5}${this.unit}`, height: `${size * 1.5}${this.unit}` };
|
|
270
|
+
};
|
|
271
|
+
this.fixSvgContent = (content, size, p) => {
|
|
272
|
+
const { spin } = p || {};
|
|
273
|
+
let res = null;
|
|
274
|
+
if (spin) {
|
|
275
|
+
res = (_jsxs(_Fragment, { children: [_jsx("style", { children: `@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }` }), _jsx("g", { style: { animation: `${spin}s linear 0s infinite normal none running spin`, transformOrigin: 'center center' }, children: content })] }));
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
res = content;
|
|
279
|
+
}
|
|
280
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: this.getSvgStyle(size), children: res }));
|
|
281
|
+
};
|
|
282
|
+
this.getIcon = (path, size, p) => {
|
|
283
|
+
const { color } = p || {};
|
|
284
|
+
const fn = this[path];
|
|
285
|
+
if (!fn) {
|
|
286
|
+
alert(`${path} is not valid`);
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
const content = fn(color);
|
|
290
|
+
return this.fixSvgContent(content, size, p);
|
|
291
|
+
};
|
|
292
|
+
this.getFileIconName = (file) => {
|
|
293
|
+
var _a;
|
|
294
|
+
const ext = (_a = file.name.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
295
|
+
switch (ext) {
|
|
296
|
+
case "png":
|
|
297
|
+
case "jpg":
|
|
298
|
+
case "jpeg":
|
|
299
|
+
case "gif":
|
|
300
|
+
case "webp": return "mdiImage";
|
|
301
|
+
case "mp4":
|
|
302
|
+
case "webm":
|
|
303
|
+
case "mov":
|
|
304
|
+
case "avi": return "video";
|
|
305
|
+
case "mp3":
|
|
306
|
+
case "wav":
|
|
307
|
+
case "ogg":
|
|
308
|
+
case "m4a": return "mdiMusic";
|
|
309
|
+
case "pdf": return "mdiFilePdfBox";
|
|
310
|
+
case "doc":
|
|
311
|
+
case "docx": return "mdiFileWordBox";
|
|
312
|
+
case "xls":
|
|
313
|
+
case "xlsx":
|
|
314
|
+
case "csv": return "mdiFileExcelBox";
|
|
315
|
+
case "ppt":
|
|
316
|
+
case "pptx": return "mdiFilePowerPointBox";
|
|
317
|
+
case "zip":
|
|
318
|
+
case "rar":
|
|
319
|
+
case "7z":
|
|
320
|
+
case "tar": return "mdiZipBox";
|
|
321
|
+
default: return "mdiFile";
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
this.getFileIcon = (file, size, p) => {
|
|
325
|
+
const path = this.getFileIconName(file);
|
|
326
|
+
return this.getIcon(path, size, p);
|
|
327
|
+
};
|
|
328
|
+
this.mdiArrowDown = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z", style: this.getStyle(color) }) }));
|
|
329
|
+
this.mdiArrowUp = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z", style: this.getStyle(color) }) }));
|
|
330
|
+
this.mdiAttachment = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M7.5,18A5.5,5.5 0 0,1 2,12.5A5.5,5.5 0 0,1 7.5,7H18A4,4 0 0,1 22,11A4,4 0 0,1 18,15H9.5A2.5,2.5 0 0,1 7,12.5A2.5,2.5 0 0,1 9.5,10H17V11.5H9.5A1,1 0 0,0 8.5,12.5A1,1 0 0,0 9.5,13.5H18A2.5,2.5 0 0,0 20.5,11A2.5,2.5 0 0,0 18,8.5H7.5A4,4 0 0,0 3.5,12.5A4,4 0 0,0 7.5,16.5H17V18H7.5Z", style: this.getStyle(color) }) }));
|
|
331
|
+
this.mdiChevronDown = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z", style: this.getStyle(color) }) }));
|
|
332
|
+
this.mdiChevronUp = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z", style: this.getStyle(color) }) }));
|
|
333
|
+
this.mdiChevronRight = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z", style: this.getStyle(color) }) }));
|
|
334
|
+
this.mdiCircleSmall = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M12,10A2,2 0 0,0 10,12C10,13.11 10.9,14 12,14C13.11,14 14,13.11 14,12A2,2 0 0,0 12,10Z", style: this.getStyle(color) }) }));
|
|
335
|
+
this.mdiCheckBold = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z", style: this.getStyle(color) }) }));
|
|
336
|
+
this.mdiCheckboxMarked = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z", style: this.getStyle(color) }) }));
|
|
337
|
+
this.mdiChevronLeft = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z", style: this.getStyle(color) }) }));
|
|
338
|
+
this.mdiCircleMedium = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M12,8A4,4 0 0,0 8,12A4,4 0 0,0 12,16A4,4 0 0,0 16,12A4,4 0 0,0 12,8Z", style: this.getStyle(color) }) }));
|
|
339
|
+
this.mdiClose = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z", style: this.getStyle(color) }) }));
|
|
340
|
+
this.mdiDelete = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z", style: this.getStyle(color) }) }));
|
|
341
|
+
this.mdiDotsHorizontal = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z", style: this.getStyle(color) }) }));
|
|
342
|
+
this.mdiEye = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z", style: this.getStyle(color) }) }));
|
|
343
|
+
this.mdiEyeOff = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z", style: this.getStyle(color) }) }));
|
|
344
|
+
this.mdiFile = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z", style: this.getStyle(color) }) }));
|
|
345
|
+
this.mdiFileExcel = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M15.8,20H14L12,16.6L10,20H8.2L11.1,15.5L8.2,11H10L12,14.4L14,11H15.8L12.9,15.5L15.8,20M13,9V3.5L18.5,9H13Z", style: this.getStyle(color) }) }));
|
|
346
|
+
this.mdiFilter = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z", style: this.getStyle(color) }) }));
|
|
347
|
+
this.mdiImage = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z", style: this.getStyle(color) }) }));
|
|
348
|
+
this.mdiLoading = (color) => _jsxs(_Fragment, { children: [_jsx("path", { d: "M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z", style: this.getStyle(color) }), _jsx("rect", { width: "24", height: "24", fill: "transparent" })] });
|
|
349
|
+
this.mdiListBox = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M7 7H9V9H7V7M7 11H9V13H7V11M7 15H9V17H7V15M17 17H11V15H17V17M17 13H11V11H17V13M17 9H11V7H17V9Z", style: this.getStyle(color) }) }));
|
|
350
|
+
this.mdiMagnify = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z", style: this.getStyle(color) }) }));
|
|
351
|
+
this.mdiMenu = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z", style: this.getStyle(color) }) }));
|
|
352
|
+
this.mdiMicrophoneOutline = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M17.3,11C17.3,14 14.76,16.1 12,16.1C9.24,16.1 6.7,14 6.7,11H5C5,14.41 7.72,17.23 11,17.72V21H13V17.72C16.28,17.23 19,14.41 19,11M10.8,4.9C10.8,4.24 11.34,3.7 12,3.7C12.66,3.7 13.2,4.24 13.2,4.9L13.19,11.1C13.19,11.76 12.66,12.3 12,12.3C11.34,12.3 10.8,11.76 10.8,11.1M12,14A3,3 0 0,0 15,11V5A3,3 0 0,0 12,2A3,3 0 0,0 9,5V11A3,3 0 0,0 12,14Z", style: this.getStyle(color) }) }));
|
|
353
|
+
this.mdiPlusThick = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M20 14H14V20H10V14H4V10H10V4H14V10H20V14Z", style: this.getStyle(color) }) }));
|
|
354
|
+
this.mdiSaveContent = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z", style: this.getStyle(color) }) }));
|
|
355
|
+
this.mdiSelect = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M4,3H5V5H3V4A1,1 0 0,1 4,3M20,3A1,1 0 0,1 21,4V5H19V3H20M15,5V3H17V5H15M11,5V3H13V5H11M7,5V3H9V5H7M21,20A1,1 0 0,1 20,21H19V19H21V20M15,21V19H17V21H15M11,21V19H13V21H11M7,21V19H9V21H7M4,21A1,1 0 0,1 3,20V19H5V21H4M3,15H5V17H3V15M21,15V17H19V15H21M3,11H5V13H3V11M21,11V13H19V11H21M3,7H5V9H3V7M21,7V9H19V7H21Z", style: this.getStyle(color) }) }));
|
|
356
|
+
this.mdiSort = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M18 21L14 17H17V7H14L18 3L22 7H19V17H22M2 19V17H12V19M2 13V11H9V13M2 7V5H6V7H2Z", style: this.getStyle(color) }) }));
|
|
357
|
+
this.mdiMusic = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M21,3V15.5A3.5,3.5 0 0,1 17.5,19A3.5,3.5 0 0,1 14,15.5A3.5,3.5 0 0,1 17.5,12C18.04,12 18.55,12.12 19,12.34V6.47L9,8.6V17.5A3.5,3.5 0 0,1 5.5,21A3.5,3.5 0 0,1 2,17.5A3.5,3.5 0 0,1 5.5,14C6.04,14 6.55,14.12 7,14.34V6L21,3Z", style: this.getStyle(color) }) }));
|
|
358
|
+
this.mdiFilePdfBox = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M9.5 11.5C9.5 12.3 8.8 13 8 13H7V15H5.5V9H8C8.8 9 9.5 9.7 9.5 10.5V11.5M14.5 13.5C14.5 14.3 13.8 15 13 15H10.5V9H13C13.8 9 14.5 9.7 14.5 10.5V13.5M18.5 10.5H17V11.5H18.5V13H17V15H15.5V9H18.5V10.5M12 10.5H13V13.5H12V10.5M7 10.5H8V11.5H7V10.5Z", style: this.getStyle(color) }) }));
|
|
359
|
+
this.mdiFileWordBox = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M15.5,17H14L12,9.5L10,17H8.5L6.1,7H7.8L9.34,14.5L11.3,7H12.7L14.67,14.5L16.2,7H17.9M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z", style: this.getStyle(color) }) }));
|
|
360
|
+
this.mdiFileExcelBox = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M16.2,17H14.2L12,13.2L9.8,17H7.8L11,12L7.8,7H9.8L12,10.8L14.2,7H16.2L13,12M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z", style: this.getStyle(color) }) }));
|
|
361
|
+
this.mdiFilePowerPointBox = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M9.8,13.4H12.3C13.8,13.4 14.46,13.12 15.1,12.58C15.74,12.03 16,11.25 16,10.23C16,9.26 15.75,8.5 15.1,7.88C14.45,7.29 13.83,7 12.3,7H8V17H9.8V13.4M19,3A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5C3,3.89 3.9,3 5,3H19M9.8,12V8.4H12.1C12.76,8.4 13.27,8.65 13.6,9C13.93,9.35 14.1,9.72 14.1,10.24C14.1,10.8 13.92,11.19 13.6,11.5C13.28,11.81 12.9,12 12.22,12H9.8Z", style: this.getStyle(color) }) }));
|
|
362
|
+
this.mdiZipBox = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M14,17H12V15H10V13H12V15H14M14,9H12V11H14V13H12V11H10V9H12V7H10V5H12V7H14M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z", style: this.getStyle(color) }) }));
|
|
363
|
+
this.mdiCamera = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M4,4H7L9,2H15L17,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4M12,7A5,5 0 0,0 7,12A5,5 0 0,0 12,17A5,5 0 0,0 17,12A5,5 0 0,0 12,7M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9Z", style: this.getStyle(color) }) }));
|
|
364
|
+
this.mdiArrowUpDownBold = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M10,8H6L12,2L18,8H14V16H18L12,22L6,16H10V8Z", style: this.getStyle(color) }) }));
|
|
365
|
+
this.mdiSortVariantOff = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M20.84 22.73L11.11 13H3V11H9.11L6.11 8H3V6H4.11L1.11 3L2.39 1.73L22.11 21.46L20.84 22.73M15 11H14.2L15 11.8V11M21 8V6H9.2L11.2 8H21M3 18H9V16H3V18Z", style: this.getStyle(color) }) }));
|
|
366
|
+
this.mdiDownload = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z", style: this.getStyle(color) }) }));
|
|
367
|
+
this.mdiCalculator = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M7,2H17A2,2 0 0,1 19,4V20A2,2 0 0,1 17,22H7A2,2 0 0,1 5,20V4A2,2 0 0,1 7,2M7,4V8H17V4H7M7,10V12H9V10H7M11,10V12H13V10H11M15,10V12H17V10H15M7,14V16H9V14H7M11,14V16H13V14H11M15,14V16H17V14H15M7,18V20H9V18H7M11,18V20H13V18H11M15,18V20H17V18H15Z", style: this.getStyle(color) }) }));
|
|
368
|
+
this.mdiPencil = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z", style: this.getStyle(color) }) }));
|
|
369
|
+
this.mdiUpload = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M9,16V10H5L12,3L19,10H15V16H9M5,20V18H19V20H5Z", style: this.getStyle(color) }) }));
|
|
370
|
+
this.unit = unit || 'rem';
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const useKeyboardNav = (p) => {
|
|
374
|
+
function getDomByIndex(index) {
|
|
375
|
+
const container = p.getContainer();
|
|
376
|
+
if (!container || container === null) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
const res = $(container).find(`.${p.itemClassName}[data-index=${index}]`);
|
|
380
|
+
try {
|
|
381
|
+
return res[0] || false;
|
|
382
|
+
}
|
|
383
|
+
catch (_a) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function optionFocus(index) {
|
|
388
|
+
try {
|
|
389
|
+
const res = getDomByIndex(index);
|
|
390
|
+
if (!res) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
res.focus();
|
|
394
|
+
}
|
|
395
|
+
catch (_a) { }
|
|
396
|
+
}
|
|
397
|
+
function getFocusedIndex() {
|
|
398
|
+
const container = p.getContainer();
|
|
399
|
+
if (!container || container === null)
|
|
400
|
+
return false;
|
|
401
|
+
const active = document.activeElement;
|
|
402
|
+
if (!(active instanceof HTMLElement))
|
|
403
|
+
return false;
|
|
404
|
+
if (!container.contains(active))
|
|
405
|
+
return false;
|
|
406
|
+
const option = active.classList.contains(p.itemClassName) ? active : active.closest(`.${p.itemClassName}`);
|
|
407
|
+
if (!option || option === null)
|
|
408
|
+
return false;
|
|
409
|
+
const indexAttr = option.getAttribute('data-index');
|
|
410
|
+
if (indexAttr === null)
|
|
411
|
+
return false;
|
|
412
|
+
const index = Number(indexAttr);
|
|
413
|
+
if (Number.isNaN(index)) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
return index;
|
|
417
|
+
}
|
|
418
|
+
function getNextOptionIndex(index, dir) {
|
|
419
|
+
const length = p.getLength();
|
|
420
|
+
if (!length) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
const currentIndex = index;
|
|
424
|
+
for (let i = 1; i <= p.getLength(); i++) {
|
|
425
|
+
const nextIndex = (currentIndex + (i * dir) + length) % length;
|
|
426
|
+
if (p.isActive(nextIndex)) {
|
|
427
|
+
return nextIndex;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
function nextFocus(dir) {
|
|
433
|
+
let nextIndex;
|
|
434
|
+
let index = getFocusedIndex();
|
|
435
|
+
if (index === false) {
|
|
436
|
+
nextIndex = 0;
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
const res = getNextOptionIndex(index, dir);
|
|
440
|
+
if (res === false) {
|
|
441
|
+
nextIndex = 0;
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
nextIndex = res;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
const length = p.getLength();
|
|
448
|
+
if (!length) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (nextIndex < 0 || nextIndex >= length) {
|
|
452
|
+
nextIndex = 0;
|
|
453
|
+
}
|
|
454
|
+
optionFocus(nextIndex);
|
|
455
|
+
}
|
|
456
|
+
const keyDown = (e) => {
|
|
457
|
+
const code = e.keyCode;
|
|
458
|
+
if (code === 13) {
|
|
459
|
+
const index = getFocusedIndex();
|
|
460
|
+
if (index === false) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
p.onEnter(e, index);
|
|
464
|
+
}
|
|
465
|
+
else if (p.getLength()) {
|
|
466
|
+
let dir = 0;
|
|
467
|
+
if (code === 37) {
|
|
468
|
+
dir = p.rtl ? 1 : -1;
|
|
469
|
+
}
|
|
470
|
+
else if (code === 39) {
|
|
471
|
+
dir = p.rtl ? -1 : 1;
|
|
472
|
+
}
|
|
473
|
+
else if (code === 38) {
|
|
474
|
+
dir = -1;
|
|
475
|
+
}
|
|
476
|
+
else if (code === 40) {
|
|
477
|
+
dir = 1;
|
|
478
|
+
}
|
|
479
|
+
if (dir === 1 || dir === -1) {
|
|
480
|
+
e.preventDefault();
|
|
481
|
+
nextFocus(dir);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
return { nextFocus, getFocusedIndex, keyDown };
|
|
486
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aio-card",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "all in one card",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"cards"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/mohammadFeiz/aio-card#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/mohammadFeiz/aio-card/issues"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"aio-input": "latest",
|
|
15
|
+
"aio-date":"latest"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/mohammadFeiz/aio-card.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"author": "feiz.ms@gmail.com\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D",
|
|
23
|
+
"main": "index.js",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
26
|
+
}
|
|
27
|
+
}
|