funuicss 2.6.20 → 2.7.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.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Video = exports.SideBar = exports.ChartPie = exports.Lines = exports.Bars = exports.FullCenteredPage = exports.CircleGroup = exports.Circle = exports.Hr = exports.Section = exports.RowFlex = exports.Tip = exports.AppBar = exports.ToolTip = exports.Notification = exports.FunLoader = exports.ProgressBar = exports.DropMenu = exports.DropItem = exports.Dropdown = exports.DropDown = exports.DropUp = exports.UnAuthorized = exports.NotFound = exports.StepLine = exports.StepHeader = exports.Step = exports.StepContainer = exports.Div = exports.Text = exports.List = exports.Table = exports.Modal = exports.Loader = exports.Input = exports.Col = exports.Grid = exports.Container = exports.BreadCrumb = exports.Card = exports.Button = exports.ThemeProvider = exports.Alert = void 0;
6
+ exports.FunGet = exports.Cookie = exports.Video = exports.SideBar = exports.ChartPie = exports.Lines = exports.Bars = exports.FullCenteredPage = exports.CircleGroup = exports.Circle = exports.Hr = exports.Section = exports.RowFlex = exports.Tip = exports.AppBar = exports.ToolTip = exports.Notification = exports.FunLoader = exports.ProgressBar = exports.DropMenu = exports.DropItem = exports.Dropdown = exports.DropDown = exports.DropUp = exports.UnAuthorized = exports.NotFound = exports.StepLine = exports.StepHeader = exports.Step = exports.StepContainer = exports.Div = exports.Text = exports.List = exports.Table = exports.Modal = exports.Loader = exports.Input = exports.Col = exports.Grid = exports.Container = exports.BreadCrumb = exports.Card = exports.Button = exports.ThemeProvider = exports.Alert = void 0;
7
7
  var Alert_1 = require("./ui/alert/Alert");
8
8
  Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
9
9
  var theme_1 = require("./ui/theme/theme");
@@ -90,3 +90,8 @@ var SideBar_1 = require("./ui/sidebar/SideBar");
90
90
  Object.defineProperty(exports, "SideBar", { enumerable: true, get: function () { return __importDefault(SideBar_1).default; } });
91
91
  var Video_1 = require("./ui/video/Video");
92
92
  Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return __importDefault(Video_1).default; } });
93
+ // js
94
+ var Cookie_1 = require("./js/Cookie");
95
+ Object.defineProperty(exports, "Cookie", { enumerable: true, get: function () { return __importDefault(Cookie_1).default; } });
96
+ var Fun_1 = require("./js/Fun");
97
+ Object.defineProperty(exports, "FunGet", { enumerable: true, get: function () { return Fun_1.FunGet; } });
package/index.tsx CHANGED
@@ -40,4 +40,8 @@ export { default as Bars } from "./ui/chart/Bar"
40
40
  export { default as Lines } from "./ui/chart/Line"
41
41
  export { default as ChartPie } from "./ui/chart/Pie"
42
42
  export { default as SideBar } from "./ui/sidebar/SideBar"
43
- export { default as Video } from "./ui/video/Video"
43
+ export { default as Video } from "./ui/video/Video"
44
+
45
+ // js
46
+ export { default as Cookie } from "./js/Cookie"
47
+ export { FunGet } from "./js/Fun"
package/js/Cookie.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ interface ExpirationDuration {
2
+ years?: number;
3
+ months?: number;
4
+ days?: number;
5
+ }
6
+ interface CookieOptions {
7
+ duration?: ExpirationDuration;
8
+ path?: string;
9
+ secure?: boolean;
10
+ sameSite?: 'Strict' | 'Lax' | 'None';
11
+ }
12
+ declare const Cookie: (name: string) => {
13
+ /**
14
+ * Save a value as a cookie
15
+ * @param value - Any JSON-serializable object
16
+ * @param options - Expiration and cookie settings
17
+ */
18
+ save: (value: any, options?: CookieOptions) => Promise<void>;
19
+ /**
20
+ * Get and parse the cookie
21
+ */
22
+ get: () => Promise<any>;
23
+ /**
24
+ * Remove the cookie by setting its expiration to the past
25
+ */
26
+ remove: () => Promise<void>;
27
+ };
28
+ export default Cookie;
package/js/Cookie.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Cookie = function (name) {
4
+ return {
5
+ /**
6
+ * Save a value as a cookie
7
+ * @param value - Any JSON-serializable object
8
+ * @param options - Expiration and cookie settings
9
+ */
10
+ save: function (value, options) {
11
+ if (options === void 0) { options = {}; }
12
+ return new Promise(function (resolve, reject) {
13
+ try {
14
+ var stringValue = JSON.stringify(value);
15
+ var _a = options.duration, duration = _a === void 0 ? { days: 30 } : _a, _b = options.path, path = _b === void 0 ? '/' : _b, _c = options.secure, secure = _c === void 0 ? false : _c, _d = options.sameSite, sameSite = _d === void 0 ? 'Lax' : _d;
16
+ // Create expiration date
17
+ var expirationDate = new Date();
18
+ if (duration.years)
19
+ expirationDate.setFullYear(expirationDate.getFullYear() + duration.years);
20
+ if (duration.months)
21
+ expirationDate.setMonth(expirationDate.getMonth() + duration.months);
22
+ if (duration.days)
23
+ expirationDate.setDate(expirationDate.getDate() + duration.days);
24
+ // Build cookie string
25
+ var cookieString = "".concat(name, "=").concat(encodeURIComponent(stringValue), "; expires=").concat(expirationDate.toUTCString(), "; path=").concat(path, "; SameSite=").concat(sameSite);
26
+ if (secure)
27
+ cookieString += '; Secure';
28
+ document.cookie = cookieString;
29
+ resolve();
30
+ }
31
+ catch (error) {
32
+ reject({ status: 'error', message: error });
33
+ }
34
+ });
35
+ },
36
+ /**
37
+ * Get and parse the cookie
38
+ */
39
+ get: function () {
40
+ return new Promise(function (resolve, reject) {
41
+ try {
42
+ var cookies = document.cookie.split(';');
43
+ for (var i = 0; i < cookies.length; i++) {
44
+ var cookie = cookies[i].trim();
45
+ if (cookie.startsWith(name + '=')) {
46
+ var value = decodeURIComponent(cookie.substring(name.length + 1));
47
+ return resolve(JSON.parse(value));
48
+ }
49
+ }
50
+ reject("".concat(name, " cookie not found or has expired."));
51
+ }
52
+ catch (error) {
53
+ reject({ status: 'error', message: error });
54
+ }
55
+ });
56
+ },
57
+ /**
58
+ * Remove the cookie by setting its expiration to the past
59
+ */
60
+ remove: function () {
61
+ return new Promise(function (resolve, reject) {
62
+ try {
63
+ document.cookie = "".concat(name, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;");
64
+ resolve();
65
+ }
66
+ catch (error) {
67
+ reject({ status: 'error', message: error });
68
+ }
69
+ });
70
+ },
71
+ };
72
+ };
73
+ exports.default = Cookie;
package/js/Cookie.tsx ADDED
@@ -0,0 +1,91 @@
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.d.ts CHANGED
@@ -9,9 +9,9 @@ export declare const FunVisible: {
9
9
  toggle: (selector?: string) => void;
10
10
  };
11
11
  export declare const FunGet: {
12
- text: (selector?: string, data?: string) => string;
13
- html: (selector?: string, data?: string) => string;
14
- val: (selector?: string, data?: string) => string;
12
+ text: (selector?: string, data?: string) => string | undefined;
13
+ html: (selector?: string, data?: string) => string | undefined;
14
+ val: (selector?: string, data?: string) => string | undefined;
15
15
  };
16
16
  export declare const FunStyle: {
17
17
  css: (selector?: string, css?: {}) => void;
@@ -33,6 +33,10 @@ export declare const FunRequest: {
33
33
  patch: (url: string, body?: any, headers?: HeadersInit) => Promise<unknown>;
34
34
  delete: (url: string, headers?: HeadersInit) => Promise<unknown>;
35
35
  };
36
+ interface QueryFields {
37
+ [key: string]: any;
38
+ }
36
39
  export declare const FunQuery: {
37
- query: (data: any, fields?: {}) => Promise<unknown>;
40
+ query: (data: any, fields?: QueryFields) => Promise<unknown>;
38
41
  };
42
+ export {};
package/js/Fun.js CHANGED
@@ -14,18 +14,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.FunQuery = exports.FunRequest = exports.FunAdd = exports.FunClass = exports.FunEvent = exports.FunStyle = exports.FunGet = exports.FunVisible = exports.FunHide = void 0;
15
15
  exports.FunHide = {
16
16
  hide: function (selector) {
17
+ if (selector === void 0) { selector = ""; }
17
18
  var element = document.querySelector(selector);
18
19
  if (element) {
19
20
  element.style.display = "none";
20
21
  }
21
22
  },
22
23
  show: function (selector) {
24
+ if (selector === void 0) { selector = ""; }
23
25
  var element = document.querySelector(selector);
24
26
  if (element) {
25
27
  element.style.display = "inline-block";
26
28
  }
27
29
  },
28
30
  toggle: function (selector) {
31
+ if (selector === void 0) { selector = ""; }
29
32
  var element = document.querySelector(selector);
30
33
  if (element) {
31
34
  var style = element.style.display;
@@ -35,18 +38,21 @@ exports.FunHide = {
35
38
  };
36
39
  exports.FunVisible = {
37
40
  hide: function (selector) {
41
+ if (selector === void 0) { selector = ""; }
38
42
  var element = document.querySelector(selector);
39
43
  if (element) {
40
44
  element.style.visibility = "hidden";
41
45
  }
42
46
  },
43
47
  show: function (selector) {
48
+ if (selector === void 0) { selector = ""; }
44
49
  var element = document.querySelector(selector);
45
50
  if (element) {
46
51
  element.style.visibility = "visible";
47
52
  }
48
53
  },
49
54
  toggle: function (selector) {
55
+ if (selector === void 0) { selector = ""; }
50
56
  var element = document.querySelector(selector);
51
57
  if (element) {
52
58
  var style = element.style.visibility;
@@ -56,6 +62,7 @@ exports.FunVisible = {
56
62
  };
57
63
  exports.FunGet = {
58
64
  text: function (selector, data) {
65
+ if (selector === void 0) { selector = ""; }
59
66
  var element = document.querySelector(selector);
60
67
  if (element) {
61
68
  var text = element.textContent;
@@ -68,6 +75,7 @@ exports.FunGet = {
68
75
  }
69
76
  },
70
77
  html: function (selector, data) {
78
+ if (selector === void 0) { selector = ""; }
71
79
  var element = document.querySelector(selector);
72
80
  if (element) {
73
81
  var text = element.innerHTML;
@@ -80,6 +88,7 @@ exports.FunGet = {
80
88
  }
81
89
  },
82
90
  val: function (selector, data) {
91
+ if (selector === void 0) { selector = ""; }
83
92
  var element = document.querySelector(selector);
84
93
  if (element) {
85
94
  var text = element.value;
@@ -94,6 +103,7 @@ exports.FunGet = {
94
103
  };
95
104
  exports.FunStyle = {
96
105
  css: function (selector, css) {
106
+ if (selector === void 0) { selector = ""; }
97
107
  var element = document.querySelector(selector);
98
108
  if (element) {
99
109
  Object.assign(element.style, css);
@@ -102,6 +112,7 @@ exports.FunStyle = {
102
112
  };
103
113
  exports.FunEvent = {
104
114
  event: function (selector, eventType, callBack) {
115
+ if (selector === void 0) { selector = ""; }
105
116
  var element = document.querySelector(selector);
106
117
  if (element && eventType && callBack) {
107
118
  element.addEventListener(eventType, callBack);
@@ -110,12 +121,14 @@ exports.FunEvent = {
110
121
  };
111
122
  exports.FunClass = {
112
123
  add: function (selector, newClass) {
124
+ if (selector === void 0) { selector = ""; }
113
125
  var element = document.querySelector(selector);
114
126
  if (element && newClass) {
115
127
  element.classList.add(newClass);
116
128
  }
117
129
  },
118
130
  remove: function (selector, newClass) {
131
+ if (selector === void 0) { selector = ""; }
119
132
  var element = document.querySelector(selector);
120
133
  if (element && newClass) {
121
134
  element.classList.remove(newClass);
@@ -124,12 +137,14 @@ exports.FunClass = {
124
137
  };
125
138
  exports.FunAdd = {
126
139
  append: function (selector, child) {
140
+ if (selector === void 0) { selector = ''; }
127
141
  var element = document.querySelector(selector);
128
142
  if (element && child) {
129
143
  element.append(child);
130
144
  }
131
145
  },
132
146
  prepend: function (selector, child) {
147
+ if (selector === void 0) { selector = ""; }
133
148
  var element = document.querySelector(selector);
134
149
  if (element && child) {
135
150
  element.prepend(child);
@@ -203,33 +218,41 @@ exports.FunRequest = {
203
218
  };
204
219
  exports.FunQuery = {
205
220
  query: function (data, fields) {
221
+ if (fields === void 0) { fields = {}; }
206
222
  return new Promise(function (resolve, reject) {
207
- if (Array.isArray(data)) {
208
- resolve(data.filter(function (item) { return applyFilter(item, fields); }));
223
+ // Validate input
224
+ if (typeof fields !== 'object' || fields === null) {
225
+ return reject('Invalid filter criteria. Expected an object.');
209
226
  }
210
- else if (typeof data === 'object') {
211
- var filteredData = {};
212
- for (var key in data) {
213
- if (applyFilter(data[key], fields)) {
214
- filteredData[key] = data[key];
227
+ var applyFilter = function (item, filters) {
228
+ for (var key in filters) {
229
+ if (item[key] !== filters[key]) {
230
+ return false;
215
231
  }
216
232
  }
217
- resolve(filteredData);
218
- }
219
- else {
220
- reject('Invalid data type. Expected an array or object.');
221
- }
222
- function applyFilter(item, fields) {
223
- if (typeof fields !== 'object') {
224
- reject('Invalid filter criteria. Expected an object.');
233
+ return true;
234
+ };
235
+ try {
236
+ if (Array.isArray(data)) {
237
+ var result = data.filter(function (item) { return applyFilter(item, fields); });
238
+ resolve(result);
225
239
  }
226
- for (var key in fields) {
227
- if (item[key] !== fields[key]) {
228
- return false;
240
+ else if (typeof data === 'object' && data !== null) {
241
+ var filteredObject = {};
242
+ for (var key in data) {
243
+ if (applyFilter(data[key], fields)) {
244
+ filteredObject[key] = data[key];
245
+ }
229
246
  }
247
+ resolve(filteredObject);
230
248
  }
231
- return true;
249
+ else {
250
+ reject('Invalid data type. Expected an array or object.');
251
+ }
252
+ }
253
+ catch (error) {
254
+ reject(error);
232
255
  }
233
256
  });
234
- },
257
+ }
235
258
  };
package/js/Fun.tsx CHANGED
@@ -1,17 +1,17 @@
1
1
  export const FunHide = {
2
- hide: (selector?: string) => {
2
+ hide: (selector = "") => {
3
3
  var element: HTMLElement | null = document.querySelector(selector);
4
4
  if (element) {
5
5
  element.style.display = "none";
6
6
  }
7
7
  },
8
- show: (selector?: string) => {
8
+ show: (selector = "") => {
9
9
  var element: HTMLElement | null = document.querySelector(selector);
10
10
  if (element) {
11
11
  element.style.display = "inline-block";
12
12
  }
13
13
  },
14
- toggle: (selector?: string) => {
14
+ toggle: (selector = "") => {
15
15
  var element: HTMLElement | null = document.querySelector(selector);
16
16
  if (element) {
17
17
  var style = element.style.display;
@@ -20,19 +20,19 @@ export const FunHide = {
20
20
  }
21
21
  };
22
22
  export const FunVisible = {
23
- hide: (selector?: string) => {
23
+ hide: (selector = "") => {
24
24
  var element: HTMLElement | null = document.querySelector(selector);
25
25
  if (element) {
26
26
  element.style.visibility = "hidden";
27
27
  }
28
28
  },
29
- show: (selector?: string) => {
29
+ show: (selector = "") => {
30
30
  var element: HTMLElement | null = document.querySelector(selector);
31
31
  if (element) {
32
32
  element.style.visibility = "visible";
33
33
  }
34
34
  },
35
- toggle: (selector?: string) => {
35
+ toggle: (selector = "") => {
36
36
  var element: HTMLElement | null = document.querySelector(selector);
37
37
  if (element) {
38
38
  var style = element.style.visibility;
@@ -41,7 +41,7 @@ export const FunVisible = {
41
41
  }
42
42
  };
43
43
  export const FunGet = {
44
- text: (selector?: string, data?: string) => {
44
+ text: (selector = "", data?: string) => {
45
45
  var element: HTMLElement | null = document.querySelector(selector);
46
46
  if (element) {
47
47
  var text = element.textContent;
@@ -52,7 +52,7 @@ export const FunGet = {
52
52
  }
53
53
  }
54
54
  },
55
- html: (selector?: string, data?: string) => {
55
+ html: (selector = "", data?: string) => {
56
56
  var element: HTMLElement | null = document.querySelector(selector);
57
57
  if (element) {
58
58
  var text = element.innerHTML;
@@ -63,7 +63,7 @@ export const FunGet = {
63
63
  }
64
64
  }
65
65
  },
66
- val: (selector?: string, data?: string) => {
66
+ val: (selector = "", data?: string) => {
67
67
  var element: HTMLInputElement | null = document.querySelector(selector);
68
68
  if (element) {
69
69
  var text = element.value;
@@ -78,7 +78,7 @@ export const FunGet = {
78
78
  };
79
79
 
80
80
  export const FunStyle = {
81
- css: (selector?: string, css?: {}) => {
81
+ css: (selector = "", css?: {}) => {
82
82
  const element: HTMLElement | null = document.querySelector(selector);
83
83
  if (element) {
84
84
  Object.assign(element.style, css);
@@ -88,7 +88,7 @@ export const FunStyle = {
88
88
 
89
89
 
90
90
  export const FunEvent = {
91
- event: (selector?: string, eventType?: string, callBack?: EventListenerOrEventListenerObject | null) => {
91
+ event: (selector = "", eventType?: string, callBack?: EventListenerOrEventListenerObject | null) => {
92
92
  const element = document.querySelector(selector);
93
93
  if (element && eventType && callBack) {
94
94
  element.addEventListener(eventType, callBack);
@@ -97,13 +97,13 @@ export const FunEvent = {
97
97
  };
98
98
 
99
99
  export const FunClass = {
100
- add: (selector?: string, newClass?: string) => {
100
+ add: (selector = "", newClass?: string) => {
101
101
  const element = document.querySelector(selector);
102
102
  if (element && newClass) {
103
103
  element.classList.add(newClass);
104
104
  }
105
105
  },
106
- remove: (selector?: string, newClass?: string) => {
106
+ remove: (selector = "", newClass?: string) => {
107
107
  const element = document.querySelector(selector);
108
108
  if (element && newClass) {
109
109
  element.classList.remove(newClass);
@@ -112,13 +112,13 @@ export const FunClass = {
112
112
  };
113
113
 
114
114
  export const FunAdd = {
115
- append: (selector?: string, child?: Node | null) => {
115
+ append: (selector = '', child?: Node | null) => {
116
116
  const element = document.querySelector(selector);
117
117
  if (element && child) {
118
118
  element.append(child);
119
119
  }
120
120
  },
121
- prepend: (selector?: string, child?: Node | null) => {
121
+ prepend: (selector = "", child?: Node | null) => {
122
122
  const element = document.querySelector(selector);
123
123
  if (element && child) {
124
124
  element.prepend(child);
@@ -192,36 +192,48 @@ export const FunRequest = {
192
192
  },
193
193
  };
194
194
 
195
- export const FunQuery = {
196
- query: (data: any, fields?: {}) => {
197
- return new Promise((resolve, reject) => {
198
- if (Array.isArray(data)) {
199
- resolve(data.filter((item) => applyFilter(item, fields)));
200
- } else if (typeof data === 'object') {
201
- const filteredData = {};
202
- for (let key in data) {
203
- if (applyFilter(data[key], fields)) {
204
- filteredData[key] = data[key];
205
- }
206
- }
207
- resolve(filteredData);
208
- } else {
209
- reject('Invalid data type. Expected an array or object.');
210
- }
195
+ interface QueryFields {
196
+ [key: string]: any;
197
+ }
211
198
 
212
- function applyFilter(item: any, fields: {}) {
213
- if (typeof fields !== 'object') {
214
- reject('Invalid filter criteria. Expected an object.');
215
- }
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
+ }
216
206
 
217
- for (let key in fields) {
218
- if (item[key] !== fields[key]) {
219
- return false;
220
- }
221
- }
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
+ };
222
215
 
223
- return true;
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
+ }
224
226
  }
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
+ }
227
236
  };
237
+
238
+
239
+
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.6.20",
2
+ "version": "2.7.0",
3
3
  "name": "funuicss",
4
4
  "description": "React and Next.js component UI Library for creating Easy and good looking websites with fewer lines of code. Elevate your web development experience with our cutting-edge React/Next.js component UI Library. Craft stunning websites effortlessly, boasting both seamless functionality and aesthetic appeal—all achieved with minimal lines of code. Unleash the power of simplicity and style in your projects!",
5
5
  "main": "index.js",
package/tsconfig.json CHANGED
@@ -15,6 +15,6 @@
15
15
  "incremental": true,
16
16
  "composite": true
17
17
  },
18
- "include": ["ui/**/*", "types/**/*", "next-env.d.ts" , "index.tsx" , "utils/**/*" , "hooks/**/*" ],
18
+ "include": ["ui/**/*", "types/**/*", "next-env.d.ts" , "index.tsx" , "utils/**/*" , "hooks/**/*" , "js/**/*" ],
19
19
  "exclude": ["node_modules"]
20
20
  }