funuicss 2.7.16 → 3.0.1
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/css/fun.css +6663 -6653
- package/index.d.ts +2 -0
- package/index.js +5 -1
- package/js/google/AnalyticsHandler.d.ts +10 -0
- package/js/google/AnalyticsHandler.js +20 -0
- package/js/google/analytics.d.ts +6 -0
- package/js/google/analytics.js +53 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/ui/button/Button.js +1 -1
- package/ui/flex/Flex.d.ts +3 -3
- package/ui/flex/Flex.js +2 -2
- package/ui/notification/Notification.d.ts +7 -3
- package/ui/notification/Notification.js +18 -14
- package/ui/scrolltotop/ScrollToTop.d.ts +3 -0
- package/ui/scrolltotop/ScrollToTop.js +61 -0
- package/ui/view/View.d.ts +27 -38
- package/ui/view/View.js +10 -38
- package/ui/vista/Vista.d.ts +6 -1
- package/ui/vista/Vista.js +33 -4
- package/assets/colors/colors.d.ts +0 -347
- package/assets/colors/colors.js +0 -348
- package/assets/colors/colors.tsx +0 -697
- package/hooks/useHls.tsx +0 -69
- package/index.tsx +0 -58
- package/js/Cookie.tsx +0 -91
- package/js/Fun.jsx +0 -225
- package/js/Fun.tsx +0 -239
- package/tsconfig.json +0 -20
- package/types/react-easy-export.d.ts +0 -4
- package/ui/ScrollInView/ScrollInView.tsx +0 -69
- package/ui/accordion/Accordion.tsx +0 -125
- package/ui/alert/Alert.tsx +0 -106
- package/ui/aos/AOS.tsx +0 -24
- package/ui/appbar/AppBar.tsx +0 -115
- package/ui/appbar/Hamburger.tsx +0 -30
- package/ui/avatar/Avatar.tsx +0 -52
- package/ui/blob/Blob.tsx +0 -34
- package/ui/breadcrumb/BreadCrumb.tsx +0 -48
- package/ui/button/Button.tsx +0 -153
- package/ui/calendar/ActivityCard.tsx +0 -27
- package/ui/calendar/Calendar.tsx +0 -343
- package/ui/card/Card.tsx +0 -117
- package/ui/card/CardBody.tsx +0 -14
- package/ui/card/CardFab.tsx +0 -16
- package/ui/card/CardFooter.tsx +0 -14
- package/ui/card/CardHeader.tsx +0 -14
- package/ui/carousel/Carousel.tsx +0 -148
- package/ui/chart/Bar.tsx +0 -121
- package/ui/chart/Line.tsx +0 -186
- package/ui/chart/Pie.tsx +0 -127
- package/ui/container/Container.tsx +0 -38
- package/ui/datepicker/DatePicker.tsx +0 -148
- package/ui/div/Div.tsx +0 -61
- package/ui/drop/Action.tsx +0 -16
- package/ui/drop/Down.tsx +0 -18
- package/ui/drop/Dropdown.tsx +0 -117
- package/ui/drop/Item.tsx +0 -15
- package/ui/drop/Menu.tsx +0 -40
- package/ui/drop/Up.tsx +0 -18
- package/ui/flex/Flex.tsx +0 -97
- package/ui/flex/FlexItem.tsx +0 -64
- package/ui/grid/Col.tsx +0 -43
- package/ui/grid/Grid.tsx +0 -37
- package/ui/input/Iconic.tsx +0 -43
- package/ui/input/Input.tsx +0 -409
- package/ui/list/Item.tsx +0 -18
- package/ui/list/List.tsx +0 -45
- package/ui/loader/Loader.tsx +0 -47
- package/ui/modal/Action.tsx +0 -14
- package/ui/modal/Close.tsx +0 -14
- package/ui/modal/Content.tsx +0 -15
- package/ui/modal/Header.tsx +0 -19
- package/ui/modal/Modal.tsx +0 -140
- package/ui/notification/Content.tsx +0 -14
- package/ui/notification/Footer.tsx +0 -14
- package/ui/notification/Header.tsx +0 -14
- package/ui/notification/Notification.tsx +0 -62
- package/ui/page/NotFound.tsx +0 -67
- package/ui/page/UnAuthorized.tsx +0 -64
- package/ui/progress/Bar.tsx +0 -114
- package/ui/richtext/RichText.tsx +0 -156
- package/ui/sidebar/SideBar.tsx +0 -202
- package/ui/sidebar/SideContent.tsx +0 -16
- package/ui/slider/Slider.tsx +0 -75
- package/ui/snackbar/SnackBar.tsx +0 -56
- package/ui/specials/Circle.tsx +0 -49
- package/ui/specials/CircleGroup.tsx +0 -49
- package/ui/specials/FullCenteredPage.tsx +0 -25
- package/ui/specials/Hr.tsx +0 -16
- package/ui/specials/RowFlex.tsx +0 -56
- package/ui/specials/Section.tsx +0 -18
- package/ui/step/Container.tsx +0 -27
- package/ui/step/Header.tsx +0 -16
- package/ui/step/Line.tsx +0 -17
- package/ui/step/Step.tsx +0 -17
- package/ui/table/Body.tsx +0 -10
- package/ui/table/Data.tsx +0 -15
- package/ui/table/Head.tsx +0 -10
- package/ui/table/Row.tsx +0 -16
- package/ui/table/Table.tsx +0 -372
- package/ui/text/Text.tsx +0 -179
- package/ui/theme/dark.tsx +0 -45
- package/ui/theme/darkenUtils.ts +0 -15
- package/ui/theme/theme.tsx +0 -48
- package/ui/theme/themes.ts +0 -154
- package/ui/tooltip/Tip.tsx +0 -34
- package/ui/tooltip/ToolTip.tsx +0 -20
- package/ui/video/Video.tsx +0 -348
- package/ui/video/videoFunctions.tsx +0 -19
- package/ui/video/videoShortcuts.ts +0 -13
- package/ui/view/View.tsx +0 -157
- package/ui/vista/Vista.tsx +0 -165
- package/utils/Emojis.tsx +0 -59
- package/utils/Functions.tsx +0 -9
- package/utils/getCssVariable.tsx +0 -9
package/hooks/useHls.tsx
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// hooks/useHls.ts
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import Hls from 'hls.js';
|
|
4
|
-
|
|
5
|
-
interface UseHlsOptions {
|
|
6
|
-
videoRef: React.RefObject<HTMLVideoElement>;
|
|
7
|
-
src: string;
|
|
8
|
-
autoPlay?: boolean;
|
|
9
|
-
onLoaded?: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function useHls({ videoRef, src, autoPlay, onLoaded }: UseHlsOptions) {
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const video = videoRef.current;
|
|
15
|
-
if (!video || !src) return;
|
|
16
|
-
|
|
17
|
-
let hls: Hls | null = null;
|
|
18
|
-
const isHls = src.endsWith('.m3u8');
|
|
19
|
-
|
|
20
|
-
const setup = async () => {
|
|
21
|
-
if (isHls && Hls.isSupported()) {
|
|
22
|
-
hls = new Hls();
|
|
23
|
-
hls.loadSource(src);
|
|
24
|
-
hls.attachMedia(video);
|
|
25
|
-
|
|
26
|
-
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
|
27
|
-
onLoaded?.();
|
|
28
|
-
if (autoPlay) {
|
|
29
|
-
video
|
|
30
|
-
.play()
|
|
31
|
-
.then(() => console.log('HLS auto-play success'))
|
|
32
|
-
.catch((err) => console.warn('HLS auto-play error:', err));
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
hls.on(Hls.Events.ERROR, (event, data) => {
|
|
37
|
-
console.error('HLS.js error:', data);
|
|
38
|
-
});
|
|
39
|
-
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
|
40
|
-
video.src = src;
|
|
41
|
-
|
|
42
|
-
video.onloadedmetadata = () => {
|
|
43
|
-
onLoaded?.();
|
|
44
|
-
if (autoPlay) {
|
|
45
|
-
video
|
|
46
|
-
.play()
|
|
47
|
-
.then(() => console.log('Native HLS auto-play success'))
|
|
48
|
-
.catch((err) => console.warn('Native HLS auto-play error:', err));
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
} else {
|
|
52
|
-
video.src = src;
|
|
53
|
-
onLoaded?.();
|
|
54
|
-
if (autoPlay) {
|
|
55
|
-
video
|
|
56
|
-
.play()
|
|
57
|
-
.then(() => console.log('MP4 auto-play success'))
|
|
58
|
-
.catch((err) => console.warn('MP4 auto-play error:', err));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
setup();
|
|
64
|
-
|
|
65
|
-
return () => {
|
|
66
|
-
if (hls) hls.destroy();
|
|
67
|
-
};
|
|
68
|
-
}, [videoRef, src, autoPlay, onLoaded]);
|
|
69
|
-
}
|
package/index.tsx
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export { default as Alert } from "./ui/alert/Alert"
|
|
2
|
-
export { default as ThemeProvider } from "./ui/theme/theme"
|
|
3
|
-
export { default as Button } from "./ui/button/Button"
|
|
4
|
-
export { default as Card } from "./ui/card/Card"
|
|
5
|
-
export { default as BreadCrumb } from "./ui/breadcrumb/BreadCrumb"
|
|
6
|
-
export { default as Container } from "./ui/container/Container"
|
|
7
|
-
export { default as Grid } from "./ui/grid/Grid"
|
|
8
|
-
export { default as Col } from "./ui/grid/Col"
|
|
9
|
-
export { default as Input } from "./ui/input/Input"
|
|
10
|
-
export { default as Loader } from "./ui/loader/Loader"
|
|
11
|
-
export { default as Modal } from "./ui/modal/Modal"
|
|
12
|
-
export { default as Table } from "./ui/table/Table"
|
|
13
|
-
export { default as List } from "./ui/list/List"
|
|
14
|
-
export { default as Text } from "./ui/text/Text"
|
|
15
|
-
export { default as Div } from "./ui/div/Div"
|
|
16
|
-
export { default as StepContainer } from "./ui/step/Container"
|
|
17
|
-
export { default as Step } from "./ui/step/Step"
|
|
18
|
-
export { default as StepHeader } from "./ui/step/Header"
|
|
19
|
-
export { default as StepLine } from "./ui/step/Line"
|
|
20
|
-
export { default as NotFound } from "./ui/page/NotFound"
|
|
21
|
-
export { default as UnAuthorized } from "./ui/page/UnAuthorized"
|
|
22
|
-
export { default as DropUp } from "./ui/drop/Up"
|
|
23
|
-
export { default as DropDown } from "./ui/drop/Down"
|
|
24
|
-
export { default as Dropdown } from "./ui/drop/Dropdown"
|
|
25
|
-
export { default as DropItem } from "./ui/drop/Item"
|
|
26
|
-
export { default as DropMenu } from "./ui/drop/Menu"
|
|
27
|
-
export { default as ProgressBar } from "./ui/progress/Bar"
|
|
28
|
-
export { default as FunLoader } from "./ui/loader/Loader";
|
|
29
|
-
export { default as Notification } from "./ui/notification/Notification"
|
|
30
|
-
export { default as ToolTip } from "./ui/tooltip/ToolTip"
|
|
31
|
-
export { default as AppBar } from "./ui/appbar/AppBar"
|
|
32
|
-
export { default as Tip } from "./ui/tooltip/Tip"
|
|
33
|
-
export { default as RowFlex } from "./ui/specials/RowFlex"
|
|
34
|
-
export { default as Section } from "./ui/specials/Section"
|
|
35
|
-
export { default as Hr } from "./ui/specials/Hr"
|
|
36
|
-
export { default as Circle } from "./ui/specials/Circle"
|
|
37
|
-
export { default as CircleGroup } from "./ui/specials/CircleGroup"
|
|
38
|
-
export { default as FullCenteredPage } from "./ui/specials/FullCenteredPage"
|
|
39
|
-
export { default as Bars } from "./ui/chart/Bar"
|
|
40
|
-
export { default as Lines } from "./ui/chart/Line"
|
|
41
|
-
export { default as ChartPie } from "./ui/chart/Pie"
|
|
42
|
-
export { default as SideBar } from "./ui/sidebar/SideBar"
|
|
43
|
-
export { default as Video } from "./ui/video/Video"
|
|
44
|
-
export { default as Carousel } from "./ui/carousel/Carousel"
|
|
45
|
-
export { default as RichText } from "./ui/richtext/RichText"
|
|
46
|
-
export { default as Flex } from "./ui/flex/Flex"
|
|
47
|
-
export { default as Accordion} from "./ui/accordion/Accordion"
|
|
48
|
-
export { default as ScrollInView } from "./ui/ScrollInView/ScrollInView"
|
|
49
|
-
export { default as View } from "./ui/view/View"
|
|
50
|
-
export { default as DatePicker } from "./ui/datepicker/DatePicker"
|
|
51
|
-
export { default as Calendar } from "./ui/calendar/Calendar"
|
|
52
|
-
export { default as Vista } from "./ui/vista/Vista"
|
|
53
|
-
export { default as Slider } from "./ui/slider/Slider"
|
|
54
|
-
export { default as FlexItem } from "./ui/flex/FlexItem"
|
|
55
|
-
|
|
56
|
-
// js
|
|
57
|
-
export { default as Cookie } from "./js/Cookie"
|
|
58
|
-
export { FunGet } from "./js/Fun"
|
package/js/Cookie.tsx
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
interface ExpirationDuration {
|
|
2
|
-
years?: number;
|
|
3
|
-
months?: number;
|
|
4
|
-
days?: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface CookieOptions {
|
|
8
|
-
duration?: ExpirationDuration; // Expiration duration
|
|
9
|
-
path?: string;
|
|
10
|
-
secure?: boolean;
|
|
11
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const Cookie = (name: string) => {
|
|
15
|
-
return {
|
|
16
|
-
/**
|
|
17
|
-
* Save a value as a cookie
|
|
18
|
-
* @param value - Any JSON-serializable object
|
|
19
|
-
* @param options - Expiration and cookie settings
|
|
20
|
-
*/
|
|
21
|
-
save: (value: any, options: CookieOptions = {}) => {
|
|
22
|
-
return new Promise<void>((resolve, reject) => {
|
|
23
|
-
try {
|
|
24
|
-
const stringValue = JSON.stringify(value);
|
|
25
|
-
const {
|
|
26
|
-
duration = { days: 30 },
|
|
27
|
-
path = '/',
|
|
28
|
-
secure = false,
|
|
29
|
-
sameSite = 'Lax',
|
|
30
|
-
} = options;
|
|
31
|
-
|
|
32
|
-
// Create expiration date
|
|
33
|
-
const expirationDate = new Date();
|
|
34
|
-
if (duration.years) expirationDate.setFullYear(expirationDate.getFullYear() + duration.years);
|
|
35
|
-
if (duration.months) expirationDate.setMonth(expirationDate.getMonth() + duration.months);
|
|
36
|
-
if (duration.days) expirationDate.setDate(expirationDate.getDate() + duration.days);
|
|
37
|
-
|
|
38
|
-
// Build cookie string
|
|
39
|
-
let cookieString = `${name}=${encodeURIComponent(stringValue)}; expires=${expirationDate.toUTCString()}; path=${path}; SameSite=${sameSite}`;
|
|
40
|
-
if (secure) cookieString += '; Secure';
|
|
41
|
-
|
|
42
|
-
document.cookie = cookieString;
|
|
43
|
-
|
|
44
|
-
resolve();
|
|
45
|
-
} catch (error) {
|
|
46
|
-
reject({ status: 'error', message: error });
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Get and parse the cookie
|
|
53
|
-
*/
|
|
54
|
-
get: (): Promise<any> => {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
try {
|
|
57
|
-
const cookies = document.cookie.split(';');
|
|
58
|
-
for (let i = 0; i < cookies.length; i++) {
|
|
59
|
-
const cookie = cookies[i].trim();
|
|
60
|
-
if (cookie.startsWith(name + '=')) {
|
|
61
|
-
const value = decodeURIComponent(cookie.substring(name.length + 1));
|
|
62
|
-
return resolve(JSON.parse(value));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
reject(`${name} cookie not found or has expired.`);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
reject({ status: 'error', message: error });
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Remove the cookie by setting its expiration to the past
|
|
74
|
-
*/
|
|
75
|
-
remove: (): Promise<void> => {
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
try {
|
|
78
|
-
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
79
|
-
resolve();
|
|
80
|
-
} catch (error) {
|
|
81
|
-
reject({ status: 'error', message: error });
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export default Cookie;
|
package/js/Fun.jsx
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
export const FunHide = {
|
|
2
|
-
hide: (selector) => {
|
|
3
|
-
var element = document.querySelector(selector)
|
|
4
|
-
element.style.display = "none"
|
|
5
|
-
}
|
|
6
|
-
,
|
|
7
|
-
show:(selector) => {
|
|
8
|
-
var element = document.querySelector(selector)
|
|
9
|
-
element.style.display = "inline-block"
|
|
10
|
-
}
|
|
11
|
-
,
|
|
12
|
-
toggle: (selector) => {
|
|
13
|
-
var element = document.querySelector(selector)
|
|
14
|
-
var style = element.style.display
|
|
15
|
-
if (style == "none") {
|
|
16
|
-
element.style.display = "inline-block"
|
|
17
|
-
}else{
|
|
18
|
-
element.style.display = "none"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export const FunGet = {
|
|
26
|
-
text : (selector, data)=>{
|
|
27
|
-
var element = document.querySelector(selector)
|
|
28
|
-
if(typeof(element) != 'undefined' && element != null){
|
|
29
|
-
var text = element.textContent
|
|
30
|
-
if(data){
|
|
31
|
-
element.textContent = data
|
|
32
|
-
}else{
|
|
33
|
-
return text ? text : ''
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
html: (selector , data)=> {
|
|
39
|
-
var element = document.querySelector(selector)
|
|
40
|
-
if(typeof(element) != 'undefined' && element != null){
|
|
41
|
-
var text = element.innerHTML
|
|
42
|
-
if(data){
|
|
43
|
-
element.innerHTML = data
|
|
44
|
-
}else{
|
|
45
|
-
return text ? text : ""
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
val: (selector , data)=> {
|
|
51
|
-
var element = document.querySelector(selector)
|
|
52
|
-
if(typeof(element) != 'undefined' && element != null){
|
|
53
|
-
var text = element.value
|
|
54
|
-
if(data){
|
|
55
|
-
element.value = data
|
|
56
|
-
}else{
|
|
57
|
-
return text
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const FunStyle = {
|
|
64
|
-
css: (selector , css)=>{
|
|
65
|
-
// Get the element you want to style
|
|
66
|
-
const element = document.querySelector(selector);
|
|
67
|
-
|
|
68
|
-
// Define multiple styles using JavaScript objects
|
|
69
|
-
const styles = css
|
|
70
|
-
|
|
71
|
-
// Apply the styles to the element
|
|
72
|
-
Object.assign(element.style, styles);
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export const FunEvent = {
|
|
79
|
-
event : (selector , eventType, callBack) =>{
|
|
80
|
-
const element = document.querySelector(selector);
|
|
81
|
-
if(selector && eventType && callBack){
|
|
82
|
-
if(typeof(element) != 'undefined' && element != null){
|
|
83
|
-
document.querySelector(selector).addEventListener(eventType , callBack)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
export const FunClass = {
|
|
89
|
-
add : (selector , newClass) =>{
|
|
90
|
-
const element = document.querySelector(selector);
|
|
91
|
-
if(typeof(element) != 'undefined' && element != null && newClass){
|
|
92
|
-
element.classList.add(newClass);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
remove : (selector , newClass) =>{
|
|
96
|
-
const element = document.querySelector(selector);
|
|
97
|
-
if(typeof(element) != 'undefined' && element != null && newClass){
|
|
98
|
-
element.classList.remove(newClass);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export const FunAdd = {
|
|
104
|
-
append: (selector , child) =>{
|
|
105
|
-
const element = document.querySelector(selector);
|
|
106
|
-
if(typeof(element) != 'undefined' && element != null && child){
|
|
107
|
-
element.append(child)
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
prepend: (selector , child) =>{
|
|
111
|
-
const element = document.querySelector(selector);
|
|
112
|
-
if(typeof(element) != 'undefined' && element != null && child){
|
|
113
|
-
element.prepend(child)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
export const FunRequest = {
|
|
120
|
-
get: (url, headers) => {
|
|
121
|
-
return new Promise((resolve, reject) => {
|
|
122
|
-
fetch(url, headers ? { headers: headers } : {})
|
|
123
|
-
.then(response => response.json())
|
|
124
|
-
.then(data => {
|
|
125
|
-
// Handle the received data
|
|
126
|
-
resolve(data);
|
|
127
|
-
})
|
|
128
|
-
.catch(error => {
|
|
129
|
-
// Handle any errors that occur during the request
|
|
130
|
-
reject(error);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
post: (url, body, headers) => {
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
fetch(url, {
|
|
137
|
-
method: 'POST',
|
|
138
|
-
headers: headers ? { ...headers, 'Content-Type': 'application/json' } : { 'Content-Type': 'application/json' },
|
|
139
|
-
body: JSON.stringify(body)
|
|
140
|
-
})
|
|
141
|
-
.then(response => response.json())
|
|
142
|
-
.then(data => {
|
|
143
|
-
// Handle the received data
|
|
144
|
-
resolve(data);
|
|
145
|
-
})
|
|
146
|
-
.catch(error => {
|
|
147
|
-
// Handle any errors that occur during the request
|
|
148
|
-
reject(error);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
patch: (url, body, headers) => {
|
|
153
|
-
return new Promise((resolve, reject) => {
|
|
154
|
-
fetch(url, {
|
|
155
|
-
method: 'PATCH',
|
|
156
|
-
headers: headers ? { ...headers, 'Content-Type': 'application/json' } : { 'Content-Type': 'application/json' },
|
|
157
|
-
body: JSON.stringify(body)
|
|
158
|
-
})
|
|
159
|
-
.then(response => response.json())
|
|
160
|
-
.then(data => {
|
|
161
|
-
// Handle the received data
|
|
162
|
-
resolve(data);
|
|
163
|
-
})
|
|
164
|
-
.catch(error => {
|
|
165
|
-
// Handle any errors that occur during the request
|
|
166
|
-
reject(error);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
delete: (url, headers) => {
|
|
172
|
-
return new Promise((resolve, reject) => {
|
|
173
|
-
fetch(url, {
|
|
174
|
-
method: 'DELETE',
|
|
175
|
-
headers: headers ? headers : {}
|
|
176
|
-
})
|
|
177
|
-
.then(response => {
|
|
178
|
-
if (response.ok) {
|
|
179
|
-
resolve(); // Resolve with no data for successful DELETE requests
|
|
180
|
-
} else {
|
|
181
|
-
reject(`Error: ${response.status} ${response.statusText}`);
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
.catch(error => {
|
|
185
|
-
// Handle any errors that occur during the request
|
|
186
|
-
reject(error);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const FunQuery = {
|
|
193
|
-
query: (data , fields)=>{
|
|
194
|
-
return new Promise((resolve, reject) => {
|
|
195
|
-
if (Array.isArray(data)) {
|
|
196
|
-
resolve(data.filter(item => applyFilter(item, fields)))
|
|
197
|
-
} else if (typeof data === 'object') {
|
|
198
|
-
const filteredData = {};
|
|
199
|
-
for (let key in data) {
|
|
200
|
-
if (applyFilter(data[key], fields)) {
|
|
201
|
-
filteredData[key] = data[key];
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
resolve(filteredData)
|
|
205
|
-
} else {
|
|
206
|
-
reject('Invalid data type. Expected an array or object.');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function applyFilter(item, fields) {
|
|
210
|
-
if (typeof fields !== 'object') {
|
|
211
|
-
reject('Invalid filter criteria. Expected an object.');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
for (let key in fields) {
|
|
215
|
-
if (item[key] !== fields[key]) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
})
|
|
224
|
-
}
|
|
225
|
-
}
|
package/js/Fun.tsx
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
export const FunHide = {
|
|
2
|
-
hide: (selector = "") => {
|
|
3
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
4
|
-
if (element) {
|
|
5
|
-
element.style.display = "none";
|
|
6
|
-
}
|
|
7
|
-
},
|
|
8
|
-
show: (selector = "") => {
|
|
9
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
10
|
-
if (element) {
|
|
11
|
-
element.style.display = "inline-block";
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
toggle: (selector = "") => {
|
|
15
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
16
|
-
if (element) {
|
|
17
|
-
var style = element.style.display;
|
|
18
|
-
element.style.display = style === "none" ? "inline-block" : "none";
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export const FunVisible = {
|
|
23
|
-
hide: (selector = "") => {
|
|
24
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
25
|
-
if (element) {
|
|
26
|
-
element.style.visibility = "hidden";
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
show: (selector = "") => {
|
|
30
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
31
|
-
if (element) {
|
|
32
|
-
element.style.visibility = "visible";
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
toggle: (selector = "") => {
|
|
36
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
37
|
-
if (element) {
|
|
38
|
-
var style = element.style.visibility;
|
|
39
|
-
element.style.visibility = style === "hidden" ? "visible" : "hidden";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
export const FunGet = {
|
|
44
|
-
text: (selector = "", data?: string) => {
|
|
45
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
46
|
-
if (element) {
|
|
47
|
-
var text = element.textContent;
|
|
48
|
-
if (data) {
|
|
49
|
-
element.textContent = data;
|
|
50
|
-
} else {
|
|
51
|
-
return text ? text : "";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
html: (selector = "", data?: string) => {
|
|
56
|
-
var element: HTMLElement | null = document.querySelector(selector);
|
|
57
|
-
if (element) {
|
|
58
|
-
var text = element.innerHTML;
|
|
59
|
-
if (data) {
|
|
60
|
-
element.innerHTML = data;
|
|
61
|
-
} else {
|
|
62
|
-
return text ? text : "";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
val: (selector = "", data?: string) => {
|
|
67
|
-
var element: HTMLInputElement | null = document.querySelector(selector);
|
|
68
|
-
if (element) {
|
|
69
|
-
var text = element.value;
|
|
70
|
-
if (data !== undefined && data !== null) {
|
|
71
|
-
element.value = data === '' ? '' : data;
|
|
72
|
-
} else {
|
|
73
|
-
return text;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const FunStyle = {
|
|
81
|
-
css: (selector = "", css?: {}) => {
|
|
82
|
-
const element: HTMLElement | null = document.querySelector(selector);
|
|
83
|
-
if (element) {
|
|
84
|
-
Object.assign(element.style, css);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export const FunEvent = {
|
|
91
|
-
event: (selector = "", eventType?: string, callBack?: EventListenerOrEventListenerObject | null) => {
|
|
92
|
-
const element = document.querySelector(selector);
|
|
93
|
-
if (element && eventType && callBack) {
|
|
94
|
-
element.addEventListener(eventType, callBack);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const FunClass = {
|
|
100
|
-
add: (selector = "", newClass?: string) => {
|
|
101
|
-
const element = document.querySelector(selector);
|
|
102
|
-
if (element && newClass) {
|
|
103
|
-
element.classList.add(newClass);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
remove: (selector = "", newClass?: string) => {
|
|
107
|
-
const element = document.querySelector(selector);
|
|
108
|
-
if (element && newClass) {
|
|
109
|
-
element.classList.remove(newClass);
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const FunAdd = {
|
|
115
|
-
append: (selector = '', child?: Node | null) => {
|
|
116
|
-
const element = document.querySelector(selector);
|
|
117
|
-
if (element && child) {
|
|
118
|
-
element.append(child);
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
prepend: (selector = "", child?: Node | null) => {
|
|
122
|
-
const element = document.querySelector(selector);
|
|
123
|
-
if (element && child) {
|
|
124
|
-
element.prepend(child);
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export const FunRequest = {
|
|
130
|
-
get: (url: string, headers?: HeadersInit) => {
|
|
131
|
-
return new Promise((resolve, reject) => {
|
|
132
|
-
fetch(url, headers ? { headers: headers } : {})
|
|
133
|
-
.then((response) => response.json())
|
|
134
|
-
.then((data) => {
|
|
135
|
-
resolve(data);
|
|
136
|
-
})
|
|
137
|
-
.catch((error) => {
|
|
138
|
-
reject(error);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
post: (url: string, body?: any, headers?: HeadersInit) => {
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
fetch(url, {
|
|
145
|
-
method: 'POST',
|
|
146
|
-
headers: headers ? { ...headers, 'Content-Type': 'application/json' } : { 'Content-Type': 'application/json' },
|
|
147
|
-
body: JSON.stringify(body),
|
|
148
|
-
})
|
|
149
|
-
.then((response) => response.json())
|
|
150
|
-
.then((data) => {
|
|
151
|
-
resolve(data);
|
|
152
|
-
})
|
|
153
|
-
.catch((error) => {
|
|
154
|
-
reject(error);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
patch: (url: string, body?: any, headers?: HeadersInit) => {
|
|
159
|
-
return new Promise((resolve, reject) => {
|
|
160
|
-
fetch(url, {
|
|
161
|
-
method: 'PATCH',
|
|
162
|
-
headers: headers ? { ...headers, 'Content-Type': 'application/json' } : { 'Content-Type': 'application/json' },
|
|
163
|
-
body: JSON.stringify(body),
|
|
164
|
-
})
|
|
165
|
-
.then((response) => response.json())
|
|
166
|
-
.then((data) => {
|
|
167
|
-
resolve(data);
|
|
168
|
-
})
|
|
169
|
-
.catch((error) => {
|
|
170
|
-
reject(error);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
delete: (url: string, headers?: HeadersInit) => {
|
|
176
|
-
return new Promise((resolve, reject) => {
|
|
177
|
-
fetch(url, {
|
|
178
|
-
method: 'DELETE',
|
|
179
|
-
headers: headers ? headers : {},
|
|
180
|
-
})
|
|
181
|
-
.then((response) => {
|
|
182
|
-
if (response.ok) {
|
|
183
|
-
resolve("");
|
|
184
|
-
} else {
|
|
185
|
-
reject(`Error: ${response.status} ${response.statusText}`);
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
.catch((error) => {
|
|
189
|
-
reject(error);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
interface QueryFields {
|
|
196
|
-
[key: string]: any;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export const FunQuery = {
|
|
200
|
-
query: (data: any, fields: QueryFields = {}) => {
|
|
201
|
-
return new Promise((resolve, reject) => {
|
|
202
|
-
// Validate input
|
|
203
|
-
if (typeof fields !== 'object' || fields === null) {
|
|
204
|
-
return reject('Invalid filter criteria. Expected an object.');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const applyFilter = (item: any, filters: QueryFields) => {
|
|
208
|
-
for (let key in filters) {
|
|
209
|
-
if (item[key] !== filters[key]) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return true;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
try {
|
|
217
|
-
if (Array.isArray(data)) {
|
|
218
|
-
const result = data.filter(item => applyFilter(item, fields));
|
|
219
|
-
resolve(result);
|
|
220
|
-
} else if (typeof data === 'object' && data !== null) {
|
|
221
|
-
const filteredObject: Record<string, any> = {};
|
|
222
|
-
for (let key in data) {
|
|
223
|
-
if (applyFilter(data[key], fields)) {
|
|
224
|
-
filteredObject[key] = data[key];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
resolve(filteredObject);
|
|
228
|
-
} else {
|
|
229
|
-
reject('Invalid data type. Expected an array or object.');
|
|
230
|
-
}
|
|
231
|
-
} catch (error) {
|
|
232
|
-
reject(error);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"jsx": "react",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"allowJs": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"incremental": true,
|
|
16
|
-
"composite": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["ui/**/*", "types/**/*", "next-env.d.ts" , "index.tsx" , "utils/**/*" , "hooks/**/*" , "js/**/*" ],
|
|
19
|
-
"exclude": ["node_modules"]
|
|
20
|
-
}
|