vaderjs 2.2.5 → 2.2.6
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/bun.lockb +0 -0
- package/index.ts +11 -42
- package/package.json +1 -1
package/bun.lockb
ADDED
|
Binary file
|
package/index.ts
CHANGED
|
@@ -58,36 +58,7 @@ if(isServer){
|
|
|
58
58
|
export const useFetch = (url: string, options: any) => {
|
|
59
59
|
return [null, true, null];
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
* @description - Bypasses this error when using state in a non parent function
|
|
63
|
-
* @param funct
|
|
64
|
-
* @param context
|
|
65
|
-
* @returns
|
|
66
|
-
* @example
|
|
67
|
-
* // - src/index.ts
|
|
68
|
-
*
|
|
69
|
-
* export default function useAuth(){
|
|
70
|
-
* let [isAuthenticated, setAuthenticated] = useState(false)
|
|
71
|
-
* }
|
|
72
|
-
*
|
|
73
|
-
* // app/index.jsx
|
|
74
|
-
*
|
|
75
|
-
* export default function(){
|
|
76
|
-
* // this will error because this is not present in the cild function
|
|
77
|
-
* const { isAuthenticated } = useAuth()
|
|
78
|
-
* // to declare this we need to use bound from vaderjs module
|
|
79
|
-
* const { isAuthenticated } = bound(useAuth)()
|
|
80
|
-
* return (
|
|
81
|
-
* <div></div>
|
|
82
|
-
*
|
|
83
|
-
* )
|
|
84
|
-
* }
|
|
85
|
-
*/
|
|
86
|
-
export function bound(funct: Function, context: any) {
|
|
87
|
-
return function() {
|
|
88
|
-
return funct.apply(context, arguments);
|
|
89
|
-
};
|
|
90
|
-
}
|
|
61
|
+
|
|
91
62
|
/**
|
|
92
63
|
* @description - useRef allows you to store a reference to a DOM element
|
|
93
64
|
* @param value
|
|
@@ -233,16 +204,6 @@ interface SwitchProps {
|
|
|
233
204
|
children: any[] | any;
|
|
234
205
|
}
|
|
235
206
|
|
|
236
|
-
const acceptedAttributes = [
|
|
237
|
-
// Global attributes
|
|
238
|
-
'accesskey', 'class', 'className', 'idKey', 'contenteditable', 'contextmenu', 'data', 'dir', 'hidden',
|
|
239
|
-
'id', 'lang', 'style', 'tabindex', 'title', 'translate', 'xml:lang', 'xml:space',
|
|
240
|
-
|
|
241
|
-
// SVG-specific attributes
|
|
242
|
-
'xmlns', 'fill', 'viewBox', 'stroke-width', 'stroke', 'd', 'stroke-linecap', 'stroke-linejoin', 'content', 'name'
|
|
243
|
-
];
|
|
244
|
-
|
|
245
|
-
|
|
246
207
|
// make children optional
|
|
247
208
|
export function Switch({ children = [] }: SwitchProps) {
|
|
248
209
|
for (let child of children) {
|
|
@@ -314,6 +275,15 @@ if (!isServer) {
|
|
|
314
275
|
} else {
|
|
315
276
|
globalThis.state = []
|
|
316
277
|
}
|
|
278
|
+
if (!crypto.randomUUID) {
|
|
279
|
+
crypto.randomUUID = function() {
|
|
280
|
+
const url = URL.createObjectURL(new Blob());
|
|
281
|
+
const uuid = url.toString();
|
|
282
|
+
URL.revokeObjectURL(url);
|
|
283
|
+
return uuid.slice(uuid.lastIndexOf('/') + 1);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
317
287
|
export class Component {
|
|
318
288
|
props;
|
|
319
289
|
state;
|
|
@@ -673,8 +643,7 @@ export class Component {
|
|
|
673
643
|
|
|
674
644
|
// Set attributes
|
|
675
645
|
let attributes = element.props || {};
|
|
676
|
-
for (let key in attributes) {
|
|
677
|
-
if(typeof attributes[key] !== "string" && !acceptedAttributes.includes(key) || !acceptedAttributes.includes(key)) continue;
|
|
646
|
+
for (let key in attributes) {
|
|
678
647
|
if(key === "ref") {
|
|
679
648
|
let _key = attributes[key].key;
|
|
680
649
|
// update the ref
|