vlite3 0.1.10 → 0.2.2

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.
Files changed (55) hide show
  1. package/README.md +226 -150
  2. package/components/Button.vue.js +1 -1
  3. package/components/Chip/Chip.vue.js +15 -15
  4. package/components/DataTable/DataTable.vue.js +2 -2
  5. package/components/DataTable/DataTable.vue2.js +41 -39
  6. package/components/DataTable/types.d.ts +1 -0
  7. package/components/DatePicker.vue.d.ts +12 -3
  8. package/components/DatePicker.vue.js +80 -39
  9. package/components/Dropdown/DropdownMenu.vue.js +48 -47
  10. package/components/Form/Form.vue.d.ts +2 -0
  11. package/components/Form/Form.vue.js +2 -2
  12. package/components/Form/Form.vue2.js +104 -101
  13. package/components/Form/FormField.vue.d.ts +4 -0
  14. package/components/Form/FormField.vue.js +248 -148
  15. package/components/Form/FormFields.vue.d.ts +2 -0
  16. package/components/Form/FormFields.vue.js +2 -2
  17. package/components/Form/FormFields.vue2.js +45 -39
  18. package/components/Form/types.d.ts +24 -4
  19. package/components/Form/utils/form.utils.d.ts +5 -1
  20. package/components/Form/utils/form.utils.js +69 -60
  21. package/components/GoogleLogin.vue.d.ts +41 -0
  22. package/components/GoogleLogin.vue.js +60 -0
  23. package/components/GoogleLogin.vue2.js +4 -0
  24. package/components/Input.vue.js +120 -111
  25. package/components/NumberInput.vue.d.ts +38 -0
  26. package/components/NumberInput.vue.js +7 -0
  27. package/components/NumberInput.vue2.js +191 -0
  28. package/components/Pagination/Pagination.vue.d.ts +1 -0
  29. package/components/Pagination/Pagination.vue.js +60 -46
  30. package/components/ProgressBar/ProgressBar.vue.d.ts +12 -0
  31. package/components/ProgressBar/ProgressBar.vue.js +7 -0
  32. package/components/ProgressBar/ProgressBar.vue2.js +158 -0
  33. package/components/ProgressBar/index.d.ts +3 -0
  34. package/components/Spinner/Spinner.vue.d.ts +8 -0
  35. package/components/Spinner/Spinner.vue.js +89 -0
  36. package/components/Spinner/Spinner.vue2.js +4 -0
  37. package/components/Spinner/index.d.ts +2 -0
  38. package/components/Spinner/types.d.ts +9 -0
  39. package/components/Tabes/Tabes.vue.d.ts +3 -1
  40. package/components/Tabes/Tabes.vue.js +103 -44
  41. package/directives/vScrollReveal.d.ts +2 -0
  42. package/directives/vScrollReveal.js +48 -0
  43. package/index.d.ts +8 -0
  44. package/index.js +180 -147
  45. package/package.json +6 -3
  46. package/style.css +56 -4
  47. package/types/form.type.d.ts +2 -2
  48. package/types/progressbar.d.ts +75 -0
  49. package/utils/env.d.ts +14 -0
  50. package/utils/env.js +4 -0
  51. package/utils/functions.d.ts +99 -0
  52. package/utils/functions.js +91 -7
  53. package/utils/index.d.ts +2 -0
  54. package/utils/search.util.d.ts +127 -0
  55. package/utils/search.util.js +363 -0
@@ -7,3 +7,102 @@
7
7
  * @returns A new debounced function
8
8
  */
9
9
  export declare const debounce: (fn: Function, delay: number) => (...args: any[]) => void;
10
+ export declare function getUniqueId(): string;
11
+ export declare const isAppleDevice: () => boolean;
12
+ export declare const downloadFile: (fileUrl?: string, fileName?: string) => Promise<void>;
13
+ export declare const isEmpty: (value: any) => boolean;
14
+ export declare function removeExtraProperties(data: any, propertiesToRemove: string[]): any;
15
+ export declare function flattenArray(arr: any[]): any[];
16
+ export declare const capitalize: (str: any) => any;
17
+ export declare const camelCase: (str: any) => string;
18
+ export declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
19
+ /**
20
+ * Converts a string into a URL-friendly slug.
21
+ * Handles Unicode characters via NFD normalization, strips diacritics,
22
+ * collapses whitespace and special characters into single hyphens,
23
+ * and trims leading/trailing hyphens.
24
+ *
25
+ * @param input The string to slugify
26
+ * @returns A lowercase, hyphen-separated slug
27
+ *
28
+ * @example
29
+ * slugify('Hello World!') // 'hello-world'
30
+ * slugify('Crème Brûlée') // 'creme-brulee'
31
+ * slugify(' --foo bar-- ') // 'foo-bar'
32
+ */
33
+ export declare const slugify: (input: string) => string;
34
+ /**
35
+ * Generates a random integer between `min` and `max` (inclusive).
36
+ * Uses `Math.random()` — not suitable for cryptographic purposes.
37
+ *
38
+ * @param min The lower bound (inclusive)
39
+ * @param max The upper bound (inclusive)
40
+ * @returns A random integer in the range [min, max]
41
+ * @throws {TypeError} If `min` or `max` is not a finite number
42
+ * @throws {RangeError} If `min` is greater than `max`
43
+ *
44
+ * @example
45
+ * randomNumber(1, 10) // e.g. 7
46
+ * randomNumber(-5, 5) // e.g. -2
47
+ */
48
+ export declare const randomNumber: (min: number, max: number) => number;
49
+ /**
50
+ * Truncates text to a given length, breaking at the last word boundary
51
+ * to avoid mid-word cuts.
52
+ *
53
+ * @param text The string to truncate
54
+ * @param length Maximum character length (must be ≥ 0)
55
+ * @param ellipsis The suffix appended when truncated (default: `'…'`)
56
+ * @returns The truncated string, or the original if already within the limit
57
+ *
58
+ * @example
59
+ * truncate('Hello, beautiful world!', 13) // 'Hello,…'
60
+ * truncate('Hello, beautiful world!', 13, '...') // 'Hello,...'
61
+ * truncate('Short', 100) // 'Short'
62
+ */
63
+ export declare const truncate: (text: string, length: number, ellipsis?: string) => string;
64
+ /**
65
+ * Formats a numeric amount as a locale-aware currency string
66
+ * using the `Intl.NumberFormat` API.
67
+ *
68
+ * @param amount The numeric value to format
69
+ * @param locale A BCP 47 locale string (default: `'en-US'`)
70
+ * @param currency An ISO 4217 currency code (default: `'USD'`)
71
+ * @returns The formatted currency string
72
+ *
73
+ * @example
74
+ * formatCurrency(1234.5) // '$1,234.50'
75
+ * formatCurrency(1234.5, 'de-DE', 'EUR') // '1.234,50 €'
76
+ * formatCurrency(0) // '$0.00'
77
+ */
78
+ export declare const formatCurrency: (amount: number, locale?: string, currency?: string) => string;
79
+ /**
80
+ * Returns a Promise that resolves after the specified number of milliseconds.
81
+ * Useful for artificial delays, polling intervals, or animation timing.
82
+ *
83
+ * @param ms Delay duration in milliseconds (must be ≥ 0)
84
+ * @returns A Promise that resolves to `void` after the delay
85
+ *
86
+ * @example
87
+ * await delay(1000) // waits 1 second
88
+ *
89
+ * // Sequential polling
90
+ * while (polling) {
91
+ * const data = await fetchData()
92
+ * await delay(5000)
93
+ * }
94
+ */
95
+ export declare const delay: (ms: number) => Promise<void>;
96
+ /**
97
+ * Copies the given text to the system clipboard.
98
+ * Uses the modern `navigator.clipboard` API when available,
99
+ * with a `document.execCommand('copy')` fallback for older browsers.
100
+ *
101
+ * @param text The string to copy to the clipboard
102
+ * @returns A Promise that resolves to `true` on success, `false` on failure
103
+ *
104
+ * @example
105
+ * const ok = await copyToClipboard('Hello!')
106
+ * if (ok) showToast('Copied!')
107
+ */
108
+ export declare const copyToClipboard: (text: string) => Promise<boolean>;
@@ -1,11 +1,95 @@
1
- const r = (t, o) => {
2
- let e;
3
- return (...u) => {
4
- clearTimeout(e), e = setTimeout(() => {
5
- t(...u);
6
- }, o);
1
+ const f = (e, t) => {
2
+ let r;
3
+ return (...n) => {
4
+ clearTimeout(r), r = setTimeout(() => {
5
+ e(...n);
6
+ }, t);
7
7
  };
8
8
  };
9
+ function p() {
10
+ const e = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), t = Array.from(crypto.getRandomValues(new Uint8Array(5))).map((n) => n.toString(16).padStart(2, "0")).join(""), r = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
11
+ return e + t + r;
12
+ }
13
+ const d = () => {
14
+ const e = /Mac|MacIntel|MacPPC/.test(navigator.platform) && !/iPad|iPhone|iPod/.test(navigator.platform), t = /iPhone/.test(navigator.platform) || /iPhone/.test(navigator.userAgent), r = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
15
+ return e || t || r;
16
+ }, y = async (e = "", t = "file") => {
17
+ try {
18
+ const r = t || "file", n = e?.includes(".application/") ? `${r}.${e?.split("/").pop()}` : `${r}.${e?.split(".").pop()}`, i = await (await fetch(e)).blob(), a = window.URL.createObjectURL(i), c = document.createElement("a");
19
+ c.href = a, c.setAttribute("download", n), document.body.appendChild(c), c.click(), document.body.removeChild(c), window.URL.revokeObjectURL(a);
20
+ } catch (r) {
21
+ console.error("Download error:", r);
22
+ }
23
+ }, l = (e) => e == null || e === "" || typeof e == "number" && e === 0 || Array.isArray(e) && e.length === 0 ? !0 : typeof e == "object" && !Array.isArray(e) ? Object.keys(e).length === 0 || Object.values(e).every(l) : !1;
24
+ function s(e, t) {
25
+ return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map((r) => s(r, t)) : Object.entries(e).reduce(
26
+ (r, [n, o]) => (t.includes(n) || (r[n] = s(o, t)), r),
27
+ {}
28
+ );
29
+ }
30
+ function u(e) {
31
+ return e.reduce((t, r) => Array.isArray(r) ? t.concat(u(r)) : r && typeof r == "object" ? t.concat(
32
+ Object?.values(r)?.flatMap?.((n) => typeof n == "object" ? u([n]) : [n])
33
+ ) : t.concat(r), []);
34
+ }
35
+ const m = (e) => typeof e == "string" ? e?.replace(/(^\w|[.!?]\s+\w)/g, (t) => t.toUpperCase()) : e, b = (e) => !e || typeof e != "string" ? "" : e[0].toLowerCase() + e.slice(1);
36
+ function g(e, t) {
37
+ let r = null, n = null, o = null;
38
+ const i = () => {
39
+ n && o ? (e.apply(o, n), n = null, o = null, r = setTimeout(i, t)) : r = null;
40
+ };
41
+ return (...a) => {
42
+ r ? (n = a, o = this) : (e.apply(this, a), r = setTimeout(i, t));
43
+ };
44
+ }
45
+ const h = (e) => typeof e != "string" ? "" : e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/[\s-]+/g, "-").replace(/^-+|-+$/g, ""), w = (e, t) => {
46
+ if (!Number.isFinite(e) || !Number.isFinite(t))
47
+ throw new TypeError("Both min and max must be finite numbers");
48
+ if (e > t)
49
+ throw new RangeError(`min (${e}) must not be greater than max (${t})`);
50
+ const r = Math.ceil(e), n = Math.floor(t);
51
+ return Math.floor(Math.random() * (n - r + 1)) + r;
52
+ }, A = (e, t, r = "…") => {
53
+ if (typeof e != "string") return "";
54
+ if (!Number.isFinite(t) || t < 0 || e.length <= t) return e;
55
+ const n = t - r.length;
56
+ if (n <= 0) return r.slice(0, t);
57
+ const o = e.slice(0, n), i = o.lastIndexOf(" ");
58
+ return (i > 0 ? o.slice(0, i) : o) + r;
59
+ }, j = (e, t = "en-US", r = "USD") => Number.isFinite(e) ? new Intl.NumberFormat(t, {
60
+ style: "currency",
61
+ currency: r
62
+ }).format(e) : "", C = (e) => !Number.isFinite(e) || e < 0 ? Promise.reject(new RangeError("Delay must be a non-negative finite number")) : new Promise((t) => setTimeout(t, e)), M = async (e) => {
63
+ if (typeof e != "string") return !1;
64
+ if (navigator?.clipboard?.writeText)
65
+ try {
66
+ return await navigator.clipboard.writeText(e), !0;
67
+ } catch {
68
+ }
69
+ try {
70
+ const t = document.createElement("textarea");
71
+ t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.left = "-9999px", t.style.opacity = "0", document.body.appendChild(t), t.select();
72
+ const r = document.execCommand("copy");
73
+ return document.body.removeChild(t), r;
74
+ } catch {
75
+ return !1;
76
+ }
77
+ };
9
78
  export {
10
- r as debounce
79
+ b as camelCase,
80
+ m as capitalize,
81
+ M as copyToClipboard,
82
+ f as debounce,
83
+ C as delay,
84
+ y as downloadFile,
85
+ u as flattenArray,
86
+ j as formatCurrency,
87
+ p as getUniqueId,
88
+ d as isAppleDevice,
89
+ l as isEmpty,
90
+ w as randomNumber,
91
+ s as removeExtraProperties,
92
+ h as slugify,
93
+ g as throttle,
94
+ A as truncate
11
95
  };
package/utils/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './object';
2
2
  export * from './functions';
3
+ export * from './search.util';
4
+ export * from './env';
@@ -0,0 +1,127 @@
1
+ /** Comparison operators for numeric/string range and equality checks */
2
+ export interface SearchOperators<V = any> {
3
+ /** Exact equality */
4
+ $eq?: V;
5
+ /** Not equal */
6
+ $ne?: V;
7
+ /** Greater than (numeric) */
8
+ $gt?: number;
9
+ /** Greater than or equal (numeric) */
10
+ $gte?: number;
11
+ /** Less than (numeric) */
12
+ $lt?: number;
13
+ /** Less than or equal (numeric) */
14
+ $lte?: number;
15
+ /** Case-insensitive substring match */
16
+ $in?: string;
17
+ /** NOT case-insensitive substring match */
18
+ $nin?: string;
19
+ /** Regex test */
20
+ $regex?: string | RegExp;
21
+ /** Field existence check: true = must exist & not be null/undefined, false = must NOT exist */
22
+ $exists?: boolean;
23
+ }
24
+ /** A query value for a single field: direct value or operator object */
25
+ export type QueryValue<V = any> = V | SearchOperators<V>;
26
+ /** A query object: partial map of field names to query values */
27
+ export type QueryObject<T = Record<string, any>> = {
28
+ [K in keyof T]?: QueryValue<T[K]>;
29
+ };
30
+ /** The full query input: string (for primitive arrays), single query, or OR-array of queries */
31
+ export type SearchQuery<T = any> = T extends string ? string | QueryObject<T> | QueryObject<T>[] : string | QueryObject<T> | QueryObject<T>[];
32
+ /** Returned from `search()` */
33
+ export interface SearchResult<T> {
34
+ /** Matching items */
35
+ results: T[];
36
+ /** Clears the cached index for the associated model key */
37
+ reset: () => void;
38
+ /** Whether the search engine is still building indexes (always false for sync `search()`) */
39
+ loading: boolean;
40
+ }
41
+ /** Returned from `lazySearch()` — a pre-configured, reusable search instance */
42
+ export interface LazySearchResult<T> {
43
+ /** Execute a search query against the pre-indexed dataset */
44
+ search: (query: string) => T[];
45
+ /** Clear the cached index and rebuild on next search */
46
+ reset: () => void;
47
+ /** Whether the index is currently being built */
48
+ loading: boolean;
49
+ }
50
+ /**
51
+ * Reset cached indexes.
52
+ * @param modelKey — If provided, only that model's cache is cleared.
53
+ * If omitted, ALL caches are cleared.
54
+ */
55
+ export declare function resetSearchIndex(modelKey?: string): void;
56
+ /**
57
+ * High-performance search engine with indexing and caching.
58
+ *
59
+ * Supports primitive arrays (string search), object arrays with exact/substring match,
60
+ * query operators ($in, $gte, $lte, etc.), OR queries (array of query objects),
61
+ * and AND queries (multiple rest-parameter query objects).
62
+ *
63
+ * @param data — The dataset to search (array of primitives or objects)
64
+ * @param queries — One or more queries. Last argument may be a `modelKey` string.
65
+ * - `string` — substring search on primitive arrays
66
+ * - `QueryObject` — AND of all field conditions
67
+ * - `QueryObject[]` — OR across the array (union)
68
+ * - Multiple `QueryObject` args — AND across queries (intersection)
69
+ * @param modelKey — Optional cache key (like a Mongoose model name). Pass as the
70
+ * last argument. When reused, indexes are cached and not rebuilt.
71
+ *
72
+ * @returns `{ results, reset }` — `results` is the matched items in original order;
73
+ * `reset()` clears the cached index for this model key.
74
+ *
75
+ * @example
76
+ * // Primitive search
77
+ * const { results } = search(['apple', 'banana', 'cherry'], 'an')
78
+ * // results: ['banana']
79
+ *
80
+ * @example
81
+ * // Object search with exact match
82
+ * const { results } = search(users, { name: 'Jane' }, 'User')
83
+ *
84
+ * @example
85
+ * // Multiple AND queries
86
+ * const { results } = search(products, { category: 'clothes' }, { price: { $gte: 200 } }, 'Product')
87
+ *
88
+ * @example
89
+ * // OR query (array)
90
+ * const { results } = search(users, [{ name: 'John' }, { age: 25 }], 'User')
91
+ */
92
+ export declare function search<T>(data: T[], ...args: any[]): SearchResult<T>;
93
+ /**
94
+ * Creates a pre-configured, reusable search instance.
95
+ *
96
+ * Unlike `search()`, which takes a full query each time, `lazySearch()` accepts
97
+ * the dataset and a list of searchable fields upfront, builds the index once,
98
+ * and returns a lightweight `search(query)` function for fast repeated lookups.
99
+ *
100
+ * Think of it like creating a Fuse.js instance — you configure once, search many times.
101
+ *
102
+ * @param data — The dataset to search (array of objects or primitives)
103
+ * @param keys — Array of field paths (dot-notation supported) to search across.
104
+ * For primitive arrays, this is optional.
105
+ * @param modelKey — Optional cache key for index persistence across calls
106
+ *
107
+ * @returns `{ search, reset, loading }`
108
+ * - `search(query)` — returns matching items for a string query
109
+ * - `reset()` — clears the cached index
110
+ * - `loading` — whether the index is being built
111
+ *
112
+ * @example
113
+ * const people = [
114
+ * { name: { firstName: 'Jesse', lastName: 'Bowen' }, state: 'Seattle' },
115
+ * { name: { firstName: 'Jane', lastName: 'Doe' }, state: 'London' },
116
+ * ]
117
+ *
118
+ * const { search, reset, loading } = lazySearch(people, ['name.firstName', 'state'])
119
+ * const results = search('ess')
120
+ * // results: [{ name: { firstName: 'Jesse', lastName: 'Bowen' }, state: 'Seattle' }]
121
+ *
122
+ * @example
123
+ * // Primitive array — keys not needed
124
+ * const { search } = lazySearch(['apple', 'banana', 'cherry'])
125
+ * search('an') // ['banana']
126
+ */
127
+ export declare function lazySearch<T>(data: T[], keys?: string[], modelKey?: string): LazySearchResult<T>;