@base-framework/ui 1.0.2011 → 1.0.2014

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.
@@ -6,7 +6,7 @@ import { B as h, I as g } from "./buttons-CHEs54Wl.js";
6
6
  import { Icons as u } from "./icons.es.js";
7
7
  import { Timer as de, List as he, DynamicTime as fe } from "@base-framework/organisms";
8
8
  import { a as C } from "./veil-CqnAmj-D.js";
9
- import { F as j } from "./format-BLolnx9j.js";
9
+ import { F as j } from "./format-BmrNQptv.js";
10
10
  const z = {
11
11
  info: {
12
12
  borderColor: "border-blue-500",
@@ -0,0 +1,227 @@
1
+ import { DateTime as i } from "@base-framework/base";
2
+ const s = (t, r) => (typeof t == "string" && (t = [t]), Array.isArray(t) ? (t.push(r), t) : {
3
+ ...t,
4
+ callBack: r
5
+ }), B = (t, r = "") => t != null && t !== "" ? t : r, p = {
6
+ /**
7
+ * Formats a number with commas.
8
+ *
9
+ * @param {string|number|object|array} watcher
10
+ * @param {string|null} defaultValue - Value if original is null or undefined.
11
+ * @returns {object|array}
12
+ */
13
+ number(t, r = null) {
14
+ return s(t, (n) => {
15
+ if (!isNaN(n)) {
16
+ const l = /\B(?=(\d{3})+(?!\d))/g;
17
+ return n.toString().replace(l, ",");
18
+ }
19
+ return r || "";
20
+ });
21
+ },
22
+ /**
23
+ * Formats a boolean value as a yes/no string.
24
+ *
25
+ * @param {string|number|object|array} watcher
26
+ * @param {string} yes - Text for true values.
27
+ * @param {string} no - Text for false values.
28
+ * @returns {object|array}
29
+ */
30
+ yesno(t, r = "Yes", c = "No") {
31
+ return s(t, (l) => l ? r : c);
32
+ },
33
+ /**
34
+ * Formats a value as money with two decimals.
35
+ *
36
+ * @param {string|number|object|array} watcher
37
+ * @param {string} currency - Currency symbol.
38
+ * @param {*} defaultValue - Value if original is invalid.
39
+ * @returns {object|array}
40
+ */
41
+ money(t, r = "$", c = null) {
42
+ return s(t, (l) => {
43
+ const e = parseFloat(l);
44
+ if (isNaN(e))
45
+ return r + c || "";
46
+ const a = /\B(?=(\d{3})+(?!\d))/g;
47
+ return r + e.toFixed(2).toString().replace(a, ",");
48
+ });
49
+ },
50
+ /**
51
+ * Formats a value as a US phone number (10 digits).
52
+ *
53
+ * @param {string|object|array} watcher
54
+ * @param {*} defaultValue - Value if original is invalid.
55
+ * @returns {object|array}
56
+ */
57
+ phone(t, r = null) {
58
+ return s(t, (n) => {
59
+ n = n || "";
60
+ const l = String(n.toString()).replace(/\D/g, "");
61
+ return l.length === 10 ? "(" + l.slice(0, 3) + ") " + l.slice(3, 6) + "-" + l.slice(6) : n || r;
62
+ });
63
+ },
64
+ /**
65
+ * Formats a value as an integer (rounds down).
66
+ *
67
+ * @param {string|number|object|array} watcher
68
+ * @param {*} defaultValue - Value if original is invalid.
69
+ * @returns {object|array}
70
+ */
71
+ integer(t, r = null) {
72
+ return s(t, (n) => {
73
+ n = B(n, r);
74
+ const l = parseInt(n, 10);
75
+ return isNaN(l) ? r : l.toString();
76
+ });
77
+ },
78
+ /**
79
+ * Formats a date value to a standard date format.
80
+ *
81
+ * @param {string|number|object|array} watcher
82
+ * @param {*} defaultValue - Value if original is invalid.
83
+ * @returns {object|array}
84
+ */
85
+ date(t, r = null) {
86
+ return s(t, (n) => n ? i.format("standard", n) : r || "");
87
+ },
88
+ /**
89
+ * Formats a date and time value to a standard date and time format.
90
+ *
91
+ * @param {string|number|object|array} watcher
92
+ * @param {*} defaultValue - Value if original is invalid.
93
+ * @returns {object|array}
94
+ */
95
+ dateTime(t, r = null) {
96
+ return s(t, (n) => n ? i.format("standard", n) + " " + i.formatTime(n, 12) : r || "");
97
+ },
98
+ /**
99
+ * Formats a time value to a standard time format.
100
+ *
101
+ * @param {string|number|object|array} watcher
102
+ * @param {*} defaultValue - Value if original is invalid.
103
+ * @returns {object|array}
104
+ */
105
+ time(t, r = null) {
106
+ return s(t, (n) => n ? i.formatTime(n, 12) : r || "");
107
+ },
108
+ /**
109
+ * Formats a value with a default value if null or undefined.
110
+ *
111
+ * @param {string|number|object|array} watcher
112
+ * @param {string|null} defaultValue - Value if original is null or undefined.
113
+ * @returns {object|array}
114
+ */
115
+ default(t, r = null) {
116
+ return s(t, (n) => B(n, r));
117
+ },
118
+ /**
119
+ * Formats a number as a percentage.
120
+ *
121
+ * @param {string|number|object|array} watcher
122
+ * @param {number} decimals - Number of decimal places (default: 0).
123
+ * @param {boolean} isDecimal - Whether input is decimal (0.85) or whole number (85).
124
+ * @param {*} defaultValue - Value if original is invalid.
125
+ * @returns {object|array}
126
+ */
127
+ percentage(t, r = 0, c = !1, n = null) {
128
+ return s(t, (e) => {
129
+ const a = parseFloat(e);
130
+ return isNaN(a) ? n || "" : (c ? a * 100 : a).toFixed(r) + "%";
131
+ });
132
+ },
133
+ /**
134
+ * Capitalizes the first letter of each word.
135
+ *
136
+ * @param {string|object|array} watcher
137
+ * @param {boolean} allWords - Capitalize all words (true) or just first word (false).
138
+ * @param {*} defaultValue - Value if original is invalid.
139
+ * @returns {object|array}
140
+ */
141
+ capitalize(t, r = !0, c = null) {
142
+ return s(t, (l) => {
143
+ if (!l)
144
+ return c || "";
145
+ const e = String(l);
146
+ return r ? e.replace(/\b\w/g, (a) => a.toUpperCase()) : e.charAt(0).toUpperCase() + e.slice(1);
147
+ });
148
+ },
149
+ /**
150
+ * Converts a string to uppercase.
151
+ *
152
+ * @param {string|object|array} watcher
153
+ * @param {*} defaultValue - Value if original is invalid.
154
+ * @returns {object|array}
155
+ */
156
+ uppercase(t, r = null) {
157
+ return s(t, (n) => n ? String(n).toUpperCase() : r || "");
158
+ },
159
+ /**
160
+ * Converts a string to lowercase.
161
+ *
162
+ * @param {string|object|array} watcher
163
+ * @param {*} defaultValue - Value if original is invalid.
164
+ * @returns {object|array}
165
+ */
166
+ lowercase(t, r = null) {
167
+ return s(t, (n) => n ? String(n).toLowerCase() : r || "");
168
+ },
169
+ /**
170
+ * Truncates a string to a maximum length with ellipsis.
171
+ *
172
+ * @param {string|object|array} watcher
173
+ * @param {number} maxLength - Maximum length before truncation.
174
+ * @param {string} suffix - Suffix to append (default: '...').
175
+ * @param {*} defaultValue - Value if original is invalid.
176
+ * @returns {object|array}
177
+ */
178
+ truncate(t, r = 50, c = "...", n = null) {
179
+ return s(t, (e) => {
180
+ if (!e)
181
+ return n || "";
182
+ const a = String(e);
183
+ return a.length <= r ? a : a.slice(0, r - c.length) + c;
184
+ });
185
+ },
186
+ /**
187
+ * Formats bytes to a human-readable file size.
188
+ *
189
+ * @param {string|number|object|array} watcher
190
+ * @param {number} decimals - Number of decimal places (default: 2).
191
+ * @param {*} defaultValue - Value if original is invalid.
192
+ * @returns {object|array}
193
+ */
194
+ fileSize(t, r = 2, c = null) {
195
+ return s(t, (l) => {
196
+ const e = parseFloat(l);
197
+ if (isNaN(e) || e < 0)
198
+ return c || "";
199
+ if (e === 0)
200
+ return "0 Bytes";
201
+ const a = 1024, o = ["Bytes", "KB", "MB", "GB", "TB", "PB"], u = Math.floor(Math.log(e) / Math.log(a));
202
+ return parseFloat((e / Math.pow(a, u)).toFixed(r)) + " " + o[u];
203
+ });
204
+ },
205
+ /**
206
+ * Handles pluralization of words based on count.
207
+ *
208
+ * @param {string|number|object|array} watcher
209
+ * @param {string} singular - Singular form of the word.
210
+ * @param {string} plural - Plural form of the word (optional, adds 's' by default).
211
+ * @param {boolean} includeCount - Whether to include the count in output.
212
+ * @returns {object|array}
213
+ */
214
+ plural(t, r, c = null, n = !0) {
215
+ return s(t, (e) => {
216
+ const a = parseInt(e, 10);
217
+ if (isNaN(a))
218
+ return "";
219
+ const o = a === 1 ? r : c || r + "s";
220
+ return n ? `${a} ${o}` : o;
221
+ });
222
+ }
223
+ };
224
+ export {
225
+ p as F,
226
+ s as c
227
+ };
package/dist/icons.es.js CHANGED
@@ -101,6 +101,14 @@ const o = {
101
101
  upDown: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
102
102
  <path stroke-linecap="round" stroke-linejoin="round" d="M3 7.5 7.5 3m0 0L12 7.5M7.5 3v13.5m13.5 0L16.5 21m0 0L12 16.5m4.5 4.5V7.5" />
103
103
  </svg>`,
104
+ trending: {
105
+ up: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
106
+ <path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18 9 11.25l4.306 4.306a11.95 11.95 0 0 1 5.814-5.518l2.74-1.22m0 0-5.94-2.281m5.94 2.28-2.28 5.941" />
107
+ </svg>`,
108
+ down: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
109
+ <path stroke-linecap="round" stroke-linejoin="round" d="M2.25 6 9 12.75l4.286-4.286a11.948 11.948 0 0 1 4.306 6.43l.776 2.898m0 0 3.182-5.511m-3.182 5.51-5.511-3.181" />
110
+ </svg>`
111
+ },
104
112
  uturn: {
105
113
  right: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
106
114
  <path stroke-linecap="round" stroke-linejoin="round" d="m15 15 6-6m0 0-6-6m6 6H9a6 6 0 0 0 0 12h3" />
package/dist/index.es.js CHANGED
@@ -4,14 +4,14 @@ import { C as T, F as b } from "./form-group-CJzpq9Us.js";
4
4
  import { C as I, d as S, D as F, c as B, E as P, F as k, H as M, I as x, M as f, N as v, P as N, R as y, T as h, a as U, b as L, U as W, W as H } from "./inputs-9udyzkHR.js";
5
5
  import { V as w, a as A } from "./veil-CqnAmj-D.js";
6
6
  import { Icons as O } from "./icons.es.js";
7
- import { A as V, B as j, C as q, w as J, K as z, y as K, z as Q, E as _, G as X, D as Y, m as Z, n as $, Q as aa, O as ea, v as sa, c as oa, a as ta, b as ra, R as na, l as la, g as ia, i as pa, h as da, j as ma, e as ua, k as ga, F as Ca, d as ca, f as Ta, I as ba, L as Da, x as Ia, M as Sa, o as Fa, N as Ba, P as Pa, s as ka, t as Ma, S as xa, q as fa, r as va, T as Na, H as ya, J as ha, p as Ua, u as La } from "./empty-state-DJncaDM9.js";
7
+ import { A as V, B as j, C as q, w as J, K as z, y as K, z as Q, E as _, G as X, D as Y, m as Z, n as $, Q as aa, O as ea, v as sa, c as oa, a as ta, b as ra, R as na, l as la, g as ia, i as pa, h as da, j as ma, e as ua, k as ga, F as Ca, d as ca, f as Ta, I as ba, L as Da, x as Ia, M as Sa, o as Fa, N as Ba, P as Pa, s as ka, t as Ma, S as xa, q as fa, r as va, T as Na, H as ya, J as ha, p as Ua, u as La } from "./empty-state-CkoAZpy0.js";
8
8
  import { A as Ha, b as Ra, C as wa, D as Aa, a as Ga, F as Oa, M as Ea, P as Va, R as ja, c as qa, g as Ja, p as za } from "./range-calendar-CCVC3e9d.js";
9
9
  import { B as Qa, p as _a, C as Xa, j as Ya, D as Za, m as $a, k as ae, H as ee, I as se, N as oe, O as te, P as re, S as ne, n as le, o as ie, x as pe, s as de, q as me, r as ue, T as ge, t as Ce, w as ce, u as Te, v as be, l as De, U as Ie, W as Se, f as Fe, h as Be, i as Pe, c as ke, d as Me, b as xe, e as fe, a as ve, g as Ne } from "./signature-panel-DIFmtS0f.js";
10
10
  import { B as he, I as Ue, M as Le, d as We, e as He, g as Re, N as we, b as Ae, a as Ge, f as Oe, P as Ee, c as Ve, S as je, T as qe } from "./mobile-nav-wrapper-Dm9DinRD.js";
11
11
  import { B as ze, a as Ke, C as Qe, F as _e, b as Xe, c as Ye, M as Ze, P as $e, S as as } from "./sidebar-menu-page-D4WMgz5U.js";
12
12
  import { A as ss, F as os, M as ts, a as rs, T as ns } from "./aside-template-sUm-F2f0.js";
13
13
  import { B as is } from "./bside-template-do_hXebn.js";
14
- import { F as ds, c as ms } from "./format-BLolnx9j.js";
14
+ import { F as ds, c as ms } from "./format-BmrNQptv.js";
15
15
  import { I as gs } from "./image-scaler-1G-JzJVG.js";
16
16
  export {
17
17
  V as Alert,
@@ -1,4 +1,4 @@
1
- import { A as s, B as t, C as e, w as r, K as i, y as n, z as m, E as l, G as d, D as C, m as p, n as S, Q as g, O as u, v as D, c, a as F, b as T, R as P, l as A, g as I, i as f, h as w, j as b, e as y, k as B, F as M, d as k, f as x, I as L, L as R, x as U, M as v, o as E, N, P as h, s as G, t as O, S as j, q, r as z, T as H, H as J, J as K, p as Q, u as _ } from "./empty-state-DJncaDM9.js";
1
+ import { A as s, B as t, C as e, w as r, K as i, y as n, z as m, E as l, G as d, D as C, m as p, n as S, Q as g, O as u, v as D, c, a as F, b as T, R as P, l as A, g as I, i as f, h as w, j as b, e as y, k as B, F as M, d as k, f as x, I as L, L as R, x as U, M as v, o as E, N, P as h, s as G, t as O, S as j, q, r as z, T as H, H as J, J as K, p as Q, u as _ } from "./empty-state-CkoAZpy0.js";
2
2
  import { A as W, P as X, g as Y } from "./range-calendar-CCVC3e9d.js";
3
3
  export {
4
4
  s as Alert,
@@ -75,4 +75,68 @@ export namespace Format {
75
75
  */
76
76
  function _default(watcher: string | number | object | any[], defaultValue?: string | null): object | any[];
77
77
  export { _default as default };
78
+ /**
79
+ * Formats a number as a percentage.
80
+ *
81
+ * @param {string|number|object|array} watcher
82
+ * @param {number} decimals - Number of decimal places (default: 0).
83
+ * @param {boolean} isDecimal - Whether input is decimal (0.85) or whole number (85).
84
+ * @param {*} defaultValue - Value if original is invalid.
85
+ * @returns {object|array}
86
+ */
87
+ export function percentage(watcher: string | number | object | any[], decimals?: number, isDecimal?: boolean, defaultValue?: any): object | any[];
88
+ /**
89
+ * Capitalizes the first letter of each word.
90
+ *
91
+ * @param {string|object|array} watcher
92
+ * @param {boolean} allWords - Capitalize all words (true) or just first word (false).
93
+ * @param {*} defaultValue - Value if original is invalid.
94
+ * @returns {object|array}
95
+ */
96
+ export function capitalize(watcher: string | object | any[], allWords?: boolean, defaultValue?: any): object | any[];
97
+ /**
98
+ * Converts a string to uppercase.
99
+ *
100
+ * @param {string|object|array} watcher
101
+ * @param {*} defaultValue - Value if original is invalid.
102
+ * @returns {object|array}
103
+ */
104
+ export function uppercase(watcher: string | object | any[], defaultValue?: any): object | any[];
105
+ /**
106
+ * Converts a string to lowercase.
107
+ *
108
+ * @param {string|object|array} watcher
109
+ * @param {*} defaultValue - Value if original is invalid.
110
+ * @returns {object|array}
111
+ */
112
+ export function lowercase(watcher: string | object | any[], defaultValue?: any): object | any[];
113
+ /**
114
+ * Truncates a string to a maximum length with ellipsis.
115
+ *
116
+ * @param {string|object|array} watcher
117
+ * @param {number} maxLength - Maximum length before truncation.
118
+ * @param {string} suffix - Suffix to append (default: '...').
119
+ * @param {*} defaultValue - Value if original is invalid.
120
+ * @returns {object|array}
121
+ */
122
+ export function truncate(watcher: string | object | any[], maxLength?: number, suffix?: string, defaultValue?: any): object | any[];
123
+ /**
124
+ * Formats bytes to a human-readable file size.
125
+ *
126
+ * @param {string|number|object|array} watcher
127
+ * @param {number} decimals - Number of decimal places (default: 2).
128
+ * @param {*} defaultValue - Value if original is invalid.
129
+ * @returns {object|array}
130
+ */
131
+ export function fileSize(watcher: string | number | object | any[], decimals?: number, defaultValue?: any): object | any[];
132
+ /**
133
+ * Handles pluralization of words based on count.
134
+ *
135
+ * @param {string|number|object|array} watcher
136
+ * @param {string} singular - Singular form of the word.
137
+ * @param {string} plural - Plural form of the word (optional, adds 's' by default).
138
+ * @param {boolean} includeCount - Whether to include the count in output.
139
+ * @returns {object|array}
140
+ */
141
+ export function plural(watcher: string | number | object | any[], singular: string, plural?: string, includeCount?: boolean): object | any[];
78
142
  }
package/dist/utils.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { F as e, c } from "./format-BLolnx9j.js";
1
+ import { F as e, c } from "./format-BmrNQptv.js";
2
2
  import { I as t } from "./image-scaler-1G-JzJVG.js";
3
3
  export {
4
4
  e as Format,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-framework/ui",
3
- "version": "1.0.2011",
3
+ "version": "1.0.2014",
4
4
  "description": "This is a UI package that adds components and atoms that use Tailwind CSS and a theme based on Shadcn.",
5
5
  "main": "./dist/index.es.js",
6
6
  "scripts": {
@@ -1,122 +0,0 @@
1
- import { DateTime as e } from "@base-framework/base";
2
- const a = (t, n) => (typeof t == "string" && (t = [t]), Array.isArray(t) ? (t.push(n), t) : {
3
- ...t,
4
- callBack: n
5
- }), s = (t, n = "") => t != null && t !== "" ? t : n, B = {
6
- /**
7
- * Formats a number with commas.
8
- *
9
- * @param {string|number|object|array} watcher
10
- * @param {string|null} defaultValue - Value if original is null or undefined.
11
- * @returns {object|array}
12
- */
13
- number(t, n = null) {
14
- return a(t, (r) => {
15
- if (!isNaN(r)) {
16
- const c = /\B(?=(\d{3})+(?!\d))/g;
17
- return r.toString().replace(c, ",");
18
- }
19
- return n || "";
20
- });
21
- },
22
- /**
23
- * Formats a boolean value as a yes/no string.
24
- *
25
- * @param {string|number|object|array} watcher
26
- * @param {string} yes - Text for true values.
27
- * @param {string} no - Text for false values.
28
- * @returns {object|array}
29
- */
30
- yesno(t, n = "Yes", l = "No") {
31
- return a(t, (c) => c ? n : l);
32
- },
33
- /**
34
- * Formats a value as money with two decimals.
35
- *
36
- * @param {string|number|object|array} watcher
37
- * @param {string} currency - Currency symbol.
38
- * @param {*} defaultValue - Value if original is invalid.
39
- * @returns {object|array}
40
- */
41
- money(t, n = "$", l = null) {
42
- return a(t, (c) => {
43
- const o = parseFloat(c);
44
- if (isNaN(o))
45
- return n + l || "";
46
- const i = /\B(?=(\d{3})+(?!\d))/g;
47
- return n + o.toFixed(2).toString().replace(i, ",");
48
- });
49
- },
50
- /**
51
- * Formats a value as a US phone number (10 digits).
52
- *
53
- * @param {string|object|array} watcher
54
- * @param {*} defaultValue - Value if original is invalid.
55
- * @returns {object|array}
56
- */
57
- phone(t, n = null) {
58
- return a(t, (r) => {
59
- r = r || "";
60
- const c = String(r.toString()).replace(/\D/g, "");
61
- return c.length === 10 ? "(" + c.slice(0, 3) + ") " + c.slice(3, 6) + "-" + c.slice(6) : r || n;
62
- });
63
- },
64
- /**
65
- * Formats a value as an integer (rounds down).
66
- *
67
- * @param {string|number|object|array} watcher
68
- * @param {*} defaultValue - Value if original is invalid.
69
- * @returns {object|array}
70
- */
71
- integer(t, n = null) {
72
- return a(t, (r) => {
73
- r = s(r, n);
74
- const c = parseInt(r, 10);
75
- return isNaN(c) ? n : c.toString();
76
- });
77
- },
78
- /**
79
- * Formats a date value to a standard date format.
80
- *
81
- * @param {string|number|object|array} watcher
82
- * @param {*} defaultValue - Value if original is invalid.
83
- * @returns {object|array}
84
- */
85
- date(t, n = null) {
86
- return a(t, (r) => r ? e.format("standard", r) : n || "");
87
- },
88
- /**
89
- * Formats a date and time value to a standard date and time format.
90
- *
91
- * @param {string|number|object|array} watcher
92
- * @param {*} defaultValue - Value if original is invalid.
93
- * @returns {object|array}
94
- */
95
- dateTime(t, n = null) {
96
- return a(t, (r) => r ? e.format("standard", r) + " " + e.formatTime(r, 12) : n || "");
97
- },
98
- /**
99
- * Formats a time value to a standard time format.
100
- *
101
- * @param {string|number|object|array} watcher
102
- * @param {*} defaultValue - Value if original is invalid.
103
- * @returns {object|array}
104
- */
105
- time(t, n = null) {
106
- return a(t, (r) => r ? e.formatTime(r, 12) : n || "");
107
- },
108
- /**
109
- * Formats a value with a default value if null or undefined.
110
- *
111
- * @param {string|number|object|array} watcher
112
- * @param {string|null} defaultValue - Value if original is null or undefined.
113
- * @returns {object|array}
114
- */
115
- default(t, n = null) {
116
- return a(t, (r) => s(r, n));
117
- }
118
- };
119
- export {
120
- B as F,
121
- a as c
122
- };