@base-framework/ui 1.2.15 → 1.2.17

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.
@@ -1,404 +0,0 @@
1
- import { Span as m, Div as s, Legend as h, Fieldset as p, H4 as y, P as k, UseParent as x, Input as w } from "@base-framework/atoms";
2
- import { Atom as n, Html as $ } from "@base-framework/base";
3
- import { U as v } from "./buttons-C-_NH7ie.js";
4
- import { f as C, g as P, h as S, i as B } from "./image-XjAp5NjV.js";
5
- const d = {
6
- gray: {
7
- backgroundColor: "bg-gray-50",
8
- textColor: "text-gray-600",
9
- ringColor: "ring-gray-500/10"
10
- },
11
- red: {
12
- backgroundColor: "bg-red-50",
13
- textColor: "text-red-700",
14
- ringColor: "ring-red-600/10"
15
- },
16
- yellow: {
17
- backgroundColor: "bg-yellow-50",
18
- textColor: "text-yellow-800",
19
- ringColor: "ring-yellow-600/20"
20
- },
21
- green: {
22
- backgroundColor: "bg-green-50",
23
- textColor: "text-green-700",
24
- ringColor: "ring-green-600/20"
25
- },
26
- blue: {
27
- backgroundColor: "bg-blue-50",
28
- textColor: "text-blue-700",
29
- ringColor: "ring-blue-700/10"
30
- },
31
- indigo: {
32
- backgroundColor: "bg-indigo-50",
33
- textColor: "text-indigo-700",
34
- ringColor: "ring-indigo-700/10"
35
- },
36
- purple: {
37
- backgroundColor: "bg-purple-50",
38
- textColor: "text-purple-700",
39
- ringColor: "ring-purple-700/10"
40
- },
41
- pink: {
42
- backgroundColor: "bg-pink-50",
43
- textColor: "text-pink-700",
44
- ringColor: "ring-pink-700/10"
45
- },
46
- primary: {
47
- backgroundColor: "bg-primary",
48
- textColor: "text-primary-foreground",
49
- ringColor: "ring-primary/10"
50
- },
51
- secondary: {
52
- backgroundColor: "bg-secondary",
53
- textColor: "text-secondary-foreground",
54
- ringColor: "ring-secondary/10"
55
- },
56
- destructive: {
57
- backgroundColor: "bg-destructive",
58
- textColor: "text-destructive-foreground",
59
- ringColor: "ring-destructive/10"
60
- },
61
- warning: {
62
- backgroundColor: "bg-warning",
63
- textColor: "text-warning-foreground",
64
- ringColor: "ring-warning/10"
65
- },
66
- outline: {
67
- backgroundColor: "bg-background",
68
- textColor: "text-primary",
69
- ringColor: "ring-input"
70
- },
71
- ghost: {
72
- backgroundColor: "bg-background",
73
- textColor: "text-primary",
74
- ringColor: "ring-background"
75
- },
76
- link: {
77
- backgroundColor: "bg-background",
78
- textColor: "text-primary",
79
- ringColor: "ring-background"
80
- },
81
- blur: {
82
- backgroundColor: "bg-background/40 backdrop-blur-sm",
83
- textColor: "text-foreground",
84
- ringColor: "ring-white/10"
85
- }
86
- }, N = (r) => d[r] || d.gray, E = (r, e = {}) => {
87
- const t = N(r), o = e.backgroundColor ?? t.backgroundColor, l = e.textColor ?? t.textColor, a = e.ringColor ?? t.ringColor;
88
- return `inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors ${o} ${l} ${a}`;
89
- }, O = n((r, e) => {
90
- const { type: t, icon: o, size: l = "xs", backgroundColor: a, textColor: i, ringColor: c, ...g } = r, u = E(t, { backgroundColor: a, textColor: i, ringColor: c });
91
- return m({ ...g, class: u }, [
92
- o ? v({ size: l, class: "mr-1" }, o) : null,
93
- ...e || []
94
- ]);
95
- }), U = n((r, e) => {
96
- const t = r.margin ?? "my-5 mx-5", o = r.padding ?? "p-4", l = r.border ?? "border-border";
97
- return r.hover && (r.class += " hover:shadow-lg hover:bg-muted/50"), s({
98
- ...r,
99
- // @ts-ignore
100
- class: `rounded-lg ${l} bg-card text-card-foreground shadow-md min-w-[120px] min-h-[80px] ${t} ${o} ${r.class || ""}`
101
- }, e);
102
- }), F = n((r, e) => h({
103
- ...r,
104
- // @ts-ignore
105
- class: ` font-medium -mt-4 -mx-1 px-2 py-2 ${r.class || ""}`
106
- }, e)), V = n((r, e) => {
107
- const t = r.border === "full" ? "border rounded-md" : "border-t";
108
- return p({
109
- ...r,
110
- // @ts-ignore
111
- class: `p-6 ${t} ${r.class || ""}`
112
- }, [
113
- // @ts-ignore
114
- r.legend && F(r.legend),
115
- s({ class: "flex flex-auto flex-col gap-y-6" }, e)
116
- ]);
117
- }), _ = n((r, e) => {
118
- const t = r.border === !0 ? "border-t" : "";
119
- return s({
120
- ...r,
121
- // @ts-ignore
122
- class: `grid grid-cols-1 gap-y-4 sm:grid-cols-[1fr_2fr] sm:gap-x-6 pt-8 ${t} ${r.class || ""}`
123
- }, [
124
- // @ts-ignore
125
- r.label && s({
126
- // @ts-ignore
127
- ...r.labelProps,
128
- // @ts-ignore
129
- class: `flex flex-auto flex-col gap-y-1 ${r.labelProps?.class || ""}`
130
- }, [
131
- // @ts-ignore
132
- y({ class: "text-base" }, r.label),
133
- // @ts-ignore
134
- r.description && k({ class: "text-sm text-muted-foreground" }, r.description)
135
- ]),
136
- // Controls container: grows to fill remaining space, spacing between items
137
- s({ class: "flex flex-col gap-y-4" }, e)
138
- ]);
139
- }), j = C(
140
- {
141
- /**
142
- * This will create the initial state of the RangeSlider.
143
- *
144
- * @returns {object}
145
- */
146
- state() {
147
- return {
148
- value: this.value ?? 0,
149
- min: this.min ?? 0,
150
- max: this.max ?? 100,
151
- filledPercentage: this.getFillPercentage(this.value)
152
- };
153
- },
154
- /**
155
- * This will get the fill percentage of the range slider.
156
- *
157
- * @param {number} value
158
- * @returns {number}
159
- */
160
- getFillPercentage(r) {
161
- return (r - this.min) / (this.max - this.min) * 100;
162
- },
163
- /**
164
- * This will render the RangeSlider component.
165
- *
166
- * @returns {object}
167
- */
168
- render() {
169
- return s({ class: "relative w-full h-4 flex items-center" }, [
170
- // Track
171
- s({ class: "absolute h-2 w-full rounded-full bg-muted" }),
172
- x(({ state: r }) => [
173
- // Filled Track
174
- s({
175
- class: "absolute h-2 bg-primary rounded-full",
176
- style: ["width: [[filledPercentage]]%", r]
177
- }),
178
- // Thumb
179
- s({
180
- class: `
181
- absolute block h-5 w-5 rounded-full border-2 border-primary bg-background
182
- ring-offset-background transition-colors focus-visible:outline-none
183
- focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
184
- disabled:pointer-events-none disabled:opacity-50 transform -translate-x-1/2
185
- `.trim(),
186
- style: ["left: [[filledPercentage]]%", r]
187
- }),
188
- // Hidden Range Input
189
- w({
190
- type: "range",
191
- min: ["[[min]]", r],
192
- max: ["[[max]]", r],
193
- value: ["[[value]]", r],
194
- // Incorporate your new classes here
195
- class: `
196
- absolute w-full h-full opacity-0 cursor-pointer
197
- ${P}
198
- ${S}
199
- ${this.class || ""}
200
- `.trim(),
201
- bind: this.bind,
202
- input: (e) => {
203
- const t = Number(e.target.value);
204
- this.state.value = t, this.state.filledPercentage = this.getFillPercentage(t), typeof this.change == "function" && this.change(t);
205
- }
206
- })
207
- ])
208
- ]);
209
- }
210
- }
211
- ), D = n((r) => ({
212
- tag: "select",
213
- onCreated(e) {
214
- r.options && $.setupSelectOptions(e, r.options);
215
- },
216
- ...r,
217
- // @ts-ignore
218
- class: `${B} ${r.class || ""}`.trim()
219
- })), I = (r) => !r || isNaN(r) ? null : r, b = (r, e) => {
220
- const t = r, o = 16, l = 2 * Math.PI * o, a = t / 100 * l, i = `
221
- <svg class="w-40 h-40 mx-auto" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
222
- <!-- Background Circle -->
223
- <circle
224
- cx="18"
225
- cy="18"
226
- r="${o}"
227
- fill="none"
228
- stroke="currentColor"
229
- stroke-width="4"
230
- class="bg-muted"
231
- stroke-opacity="0.2"
232
- />
233
- <!-- Progress Circle -->
234
- <circle
235
- cx="18"
236
- cy="18"
237
- r="${o}"
238
- fill="none"
239
- stroke="currentColor"
240
- stroke-width="4"
241
- class="stroke-primary"
242
- stroke-dasharray="${l}"
243
- stroke-dashoffset="${l - a}"
244
- stroke-linecap="round"
245
- class="${e}"
246
- />
247
- <!-- Percentage Text -->
248
- <text
249
- x="18"
250
- y="20"
251
- class="text-[0.25em] font-medium fill-primary"
252
- text-anchor="middle"
253
- dominant-baseline="middle">
254
- ${t}%
255
- </text>
256
- </svg>
257
- `;
258
- return s({
259
- class: "circle-graph text-inherit",
260
- html: i
261
- });
262
- }, H = n((r) => {
263
- const e = r.progress || 0, t = r.class || "", o = b(e, t);
264
- return s({
265
- class: "circle-graph-wrap",
266
- onSet: [
267
- // @ts-ignore
268
- r.prop,
269
- (l) => (l = I(l), l ? b(l, t) : o)
270
- ]
271
- }, [o]);
272
- }), T = () => x(({ state: r }) => s({
273
- class: "absolute h-full rounded-full bg-primary transition-all duration-300",
274
- style: ["width: [[progress]]%;", r]
275
- })), M = C(
276
- {
277
- /**
278
- * This will render the progress bar component.
279
- *
280
- * @returns {object}
281
- */
282
- render() {
283
- return s({ class: "relative w-full h-4 rounded-full bg-muted" }, [
284
- T()
285
- ]);
286
- },
287
- /**
288
- * This will initialize the state.
289
- *
290
- * @returns {object}
291
- */
292
- state() {
293
- return {
294
- progress: this.progress ?? 0
295
- };
296
- },
297
- /**
298
- * This will reset the progress bar.
299
- *
300
- * @returns {void}
301
- */
302
- reset() {
303
- this.state.progress = 0;
304
- },
305
- /**
306
- * This will update the progress bar from a file upload.
307
- *
308
- * @param {object} evt
309
- * @returns {void}
310
- */
311
- uploadProgress(r) {
312
- if (r.lengthComputable) {
313
- const t = Math.round(r.loaded * 100 / r.total);
314
- this.set(t);
315
- }
316
- },
317
- /**
318
- * This will set the progress of the progress bar.
319
- *
320
- * @param {number} progress
321
- * @returns {void}
322
- */
323
- set(r) {
324
- r < 0 && (r = 0), r > 100 && (r = 100), this.state.progress = r;
325
- }
326
- }
327
- ), Z = n((r = {}) => {
328
- const {
329
- class: e = "",
330
- background: t = !0,
331
- blur: o = !0,
332
- backgroundClass: l = "bg-background/95",
333
- blurClass: a = "backdrop-blur",
334
- zIndexClass: i = "z-9999",
335
- style: c = ""
336
- } = r, g = [
337
- "sticky bottom-0 left-0 right-0 w-full",
338
- i,
339
- t ? l : "",
340
- o ? a : "",
341
- e
342
- ].filter(Boolean).join(" "), u = `height: env(safe-area-inset-bottom, 0px);${c ? ` ${c}` : ""}`;
343
- return s({
344
- class: g,
345
- style: u,
346
- "aria-hidden": "true"
347
- });
348
- }), J = n((r = {}) => {
349
- const {
350
- class: e = "",
351
- background: t = !0,
352
- blur: o = !0,
353
- backgroundClass: l = "bg-background/95",
354
- blurClass: a = "backdrop-blur",
355
- zIndexClass: i = "z-9999",
356
- style: c = ""
357
- } = r, g = [
358
- "fixed top-0 left-0 right-0 w-full",
359
- i,
360
- t ? l : "",
361
- o ? a : "",
362
- e
363
- ].filter(Boolean).join(" "), u = `height: env(safe-area-inset-top, 0px);${c ? ` ${c}` : ""}`;
364
- return s({
365
- class: g,
366
- style: u,
367
- "aria-hidden": "true"
368
- });
369
- }), f = {
370
- top: "bottom-full left-1/2 transform -translate-x-1/2 mb-2",
371
- "top-right": "bottom-full left-full transform -translate-x-1 mb-2",
372
- "top-left": "bottom-full right-full transform translate-x-1 mb-2",
373
- bottom: "top-full left-1/2 transform -translate-x-1/2 mt-2",
374
- "bottom-right": "top-full left-full transform -translate-x-1 mt-2",
375
- "bottom-left": "top-full right-full transform translate-x-1 mt-2",
376
- left: "top-1/2 right-full transform -translate-y-1/2 mr-2",
377
- right: "top-1/2 left-full transform -translate-y-1/2 ml-2"
378
- }, A = (r) => f[String(r)] || f.top, Y = n(({ position: r = "top", content: e }, t) => {
379
- const o = A(r);
380
- return Array.isArray(t) === !1 && (t = [t]), s({ class: "relative group inline-block" }, [
381
- ...t,
382
- // Tooltip box
383
- m({
384
- class: `
385
- absolute z-20 px-2 py-1 border text-sm bg-background rounded shadow-md opacity-0 whitespace-nowrap
386
- group-hover:opacity-100 transition-opacity duration-200 ${o} pointer-events-none
387
- `
388
- }, e)
389
- ]);
390
- });
391
- export {
392
- O as B,
393
- U as C,
394
- V as F,
395
- F as L,
396
- M as P,
397
- j as R,
398
- Z as S,
399
- Y as T,
400
- H as a,
401
- _ as b,
402
- J as c,
403
- D as d
404
- };