@base-framework/ui 1.0.231 → 1.0.233

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.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DateRangePicker Atom
3
+ *
4
+ * This will create a date picker component.
5
+ *
6
+ * @type {typeof Veil}
7
+ */
8
+ export const DateRangePicker: typeof Veil;
9
+ export default DateRangePicker;
10
+ import { Veil } from '../../atoms/veil.js';
@@ -24,6 +24,7 @@ export * from "./combobox/combobox.js";
24
24
  export * from "./counters/atoms.js";
25
25
  export * from "./counters/counter.js";
26
26
  export * from "./date-time/date-picker.js";
27
+ export * from "./date-time/date-range-picker.js";
27
28
  export * from "./date-time/time-frame.js";
28
29
  export * from "./date-time/time-picker.js";
29
30
  export * from "./dialogs/confirmation.js";
package/dist/utils.es.js CHANGED
@@ -1,6 +1,7 @@
1
- import { F as r, I as c, c as t } from "./image-scaler-BQ7WdtlV.js";
1
+ import { F as e, c } from "./format-BueUWxwT.js";
2
+ import { I as t } from "./image-scaler-DNyRgMye.js";
2
3
  export {
3
- r as Format,
4
- c as ImageScaler,
5
- t as createWatcherCallback
4
+ e as Format,
5
+ t as ImageScaler,
6
+ c as createWatcherCallback
6
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-framework/ui",
3
- "version": "1.0.231",
3
+ "version": "1.0.233",
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,510 +0,0 @@
1
- import { Div as l, Img as j, Span as $, Button as I, OnState as W } from "@base-framework/atoms";
2
- import { Component as N, Data as z, Atom as Y, DateTime as B } from "@base-framework/base";
3
- import { B as m } from "./buttons-Cm9etaEG.js";
4
- import { Icons as S } from "./icons.es.js";
5
- const H = (e, t) => {
6
- const n = e ? e.getBoundingClientRect() : { top: 0, bottom: 0, left: 0 }, s = t.getBoundingClientRect(), a = 10, r = globalThis.scrollX, i = globalThis.scrollY;
7
- let c = n.left + r, g = n.bottom + i;
8
- const d = globalThis.innerHeight - n.bottom, h = n.top;
9
- return c + s.width > globalThis.innerWidth && (c = globalThis.innerWidth - s.width - a), d < s.height && h > d ? g = n.top + i - s.height - a : d < s.height && (g = n.bottom + i - (s.height - d) - a), { x: c, y: g };
10
- };
11
- class ht extends N {
12
- /**
13
- * This will set up the data.
14
- *
15
- * @returns {object}
16
- */
17
- setData() {
18
- const t = this.parent.data || new z();
19
- return t.set({
20
- position: { x: 0, y: 0 }
21
- }), t;
22
- }
23
- /**
24
- * This will get the class size.
25
- *
26
- * @returns {string}
27
- */
28
- getSize() {
29
- switch (this.size || "lg") {
30
- // @ts-ignore
31
- case "sm":
32
- return "w-48";
33
- // @ts-ignore
34
- case "md":
35
- return "w-64";
36
- case "lg":
37
- return "w-[250px]";
38
- // @ts-ignore
39
- case "xl":
40
- return "w-96";
41
- // @ts-ignore
42
- case "2xl":
43
- return "w-[400px]";
44
- // @ts-ignore
45
- case "fit":
46
- return "w-fit";
47
- // @ts-ignore
48
- case "full":
49
- return "w-full";
50
- }
51
- }
52
- /**
53
- * This will render the modal component.
54
- *
55
- * @returns {object}
56
- */
57
- render() {
58
- const t = this.getSize();
59
- return l({
60
- class: `absolute inset-auto fadeIn mt-2 rounded-md p-0 shadow-lg bg-popover min-h-12 backdrop:bg-transparent text-inherit r z-30 ${t}`,
61
- popover: "manual",
62
- toggle: (n, { state: s }) => n.newState === "closed" ? s.open = !1 : null,
63
- style: "top: [[position.y]]px; left: [[position.x]]px"
64
- }, this.children);
65
- }
66
- /**
67
- * This will setup the states.
68
- *
69
- * @returns {object}
70
- */
71
- setupStates() {
72
- return {
73
- open: {
74
- id: this.parent.getId(),
75
- callBack: (s) => {
76
- this.state.open === !1 && this.destroy();
77
- }
78
- }
79
- };
80
- }
81
- /**
82
- * Updates the dropdown position.
83
- *
84
- * @returns {void}
85
- */
86
- updatePosition() {
87
- const t = this.button ?? null, n = this.panel, s = H(t, n);
88
- this.data.position = s;
89
- }
90
- /**
91
- * This will run after the setup.
92
- *
93
- * @returns {void}
94
- */
95
- afterSetup() {
96
- this.panel.showPopover(), this.updatePosition();
97
- }
98
- /**
99
- * This will check if the element clicked was in the
100
- * component of the button.
101
- *
102
- * @param {object} element
103
- * @returns {boolean}
104
- */
105
- isOutsideClick(t) {
106
- return !this.panel.contains(t) && this.button && !this.button.contains(t);
107
- }
108
- /**
109
- * This will set up the events.
110
- *
111
- * @returns {array}
112
- */
113
- setupEvents() {
114
- return [
115
- ["click", document, (t) => {
116
- this.isOutsideClick(t.target) && (this.state.open = !1);
117
- }],
118
- ["resize", globalThis, (t) => this.updatePosition()],
119
- ["scroll", document, (t) => this.updatePosition()]
120
- ];
121
- }
122
- /**
123
- * This will override the set up to use the app shell.
124
- *
125
- * @param {object} container
126
- */
127
- setContainer(t) {
128
- this.container = app.root;
129
- }
130
- /**
131
- * This will hide the popover before destroying.
132
- *
133
- * @returns {void}
134
- */
135
- beforeDestroy() {
136
- this.panel.hidePopover();
137
- }
138
- }
139
- const R = Y(({ src: e, alt: t }) => e ? j({
140
- class: "absolute w-full h-full rounded-full object-cover fadeIn",
141
- src: e,
142
- alt: t,
143
- /**
144
- * If there's an error loading the image, hide it.
145
- */
146
- error: (n) => n.target.style.display = "none"
147
- }) : null), X = (e) => e && (Array.isArray(e) && (e = e.join(" ")), typeof e != "string" && (e = String(e)), e.split(" ").map((t) => t.charAt(0)).join("").toUpperCase()), O = (e) => !e || e.length < 2 ? e : X(e), E = (e) => $([e, (t, n) => {
148
- n.textContent = O(t);
149
- }]), T = {
150
- xs: "h-6 w-6",
151
- sm: "h-8 w-8",
152
- md: "h-12 w-12",
153
- lg: "h-16 w-16",
154
- xl: "h-24 w-24",
155
- "2xl": "h-32 w-32",
156
- "3xl": "h-48 w-48",
157
- "4xl": "h-64 w-64",
158
- default: "h-12 w-12"
159
- }, k = {
160
- xs: "text-[7px]",
161
- sm: "text-xs",
162
- md: "text-base",
163
- lg: "text-xl",
164
- xl: "text-2xl",
165
- "2xl": "text-3xl",
166
- "3xl": "text-4xl",
167
- "4xl": "text-5xl",
168
- default: "text-base"
169
- }, G = (e) => T[e] || T.default, L = (e) => k[e] || k.default, U = (e, t = null, n = "md") => {
170
- const s = O(e), a = L(n);
171
- return l(
172
- {
173
- class: `
174
- flex items-center justify-center w-full h-full rounded-full
175
- bg-muted text-muted-foreground font-medium
176
- ${a}
177
- `
178
- },
179
- [
180
- t ? E(t) : $({ class: "uppercase" }, s)
181
- ]
182
- );
183
- }, dt = Y(({ src: e, alt: t, fallbackText: n, watcherFallback: s, size: a }) => {
184
- const r = G(a);
185
- return l(
186
- {
187
- class: `relative flex items-center justify-center ${r}`
188
- },
189
- [
190
- R({ src: e, alt: t }),
191
- U(n, s, a)
192
- ]
193
- );
194
- }), _ = ({ currentMonth: e, currentYear: t, onSelect: n }) => l(
195
- { class: "grid grid-cols-3 gap-2" },
196
- B.monthNames.map(
197
- (s, a) => m(
198
- {
199
- click: (r) => {
200
- r.preventDefault(), r.stopPropagation(), n(a);
201
- },
202
- variant: e === a ? "primary" : "ghost",
203
- "aria-label": `Select ${s} ${t}`
204
- },
205
- s.substring(0, 3)
206
- )
207
- )
208
- ), x = (e) => (e *= 1, e < 10 ? `0${e}` : String(e)), q = (e) => (e.indexOf("T") === -1 && e.indexOf(" ") === -1 && (e += "T00:00:01"), e.replace(" ", "T"), e), D = (e, t, n) => `${e}-${x(t + 1)}-${x(n)}`, J = (e) => e ? "bg-accent text-primary" : "", K = (e) => e ? "text-muted-foreground opacity-50" : "", Q = (e, t) => e === t, V = (e, t) => Q(e, t) ? "bg-primary text-primary-foreground" : "", Z = (e, t, n, s) => {
209
- const a = V(t, s);
210
- return a || (e ? J(e) : n ? K(n) : "text-foreground");
211
- }, C = (e) => {
212
- const {
213
- day: t,
214
- currentDate: n,
215
- date: s,
216
- isToday: a,
217
- isOutsideMonth: r,
218
- select: i,
219
- disabled: c
220
- } = e;
221
- return I(
222
- {
223
- class: `
224
- flex items-center justify-center h-9 w-auto p-0 font-normal text-sm rounded-md
225
- ${Z(a, n, r, s)}
226
- hover:bg-muted/50 hover:text-muted-foreground focus:z-10
227
- disabled:pointer-events-none disabled:opacity-50
228
- `,
229
- disabled: c || t === null,
230
- "aria-label": t ? `Day ${t}` : null,
231
- // Only call select if it's not disabled.
232
- click: () => !c && i(s)
233
- },
234
- t.toString()
235
- );
236
- }, M = (e, t, n, s) => e === s.date && t === s.month && n === s.year, tt = (e, t, n, s = !1) => {
237
- const { year: a, month: r } = e, i = D(a, r, e.date), c = new Date(a, r, 1).getDay(), g = new Date(a, r + 1, 0).getDate(), d = new Date(a, r, 0).getDate(), h = [], y = r === 0 ? 11 : r - 1, w = r === 0 ? a - 1 : a;
238
- for (let o = c - 1; o >= 0; o--) {
239
- const u = d - o, f = M(u, y, w, t), p = new Date(w, y, u) < new Date(t.year, t.month, t.date), F = s && p;
240
- h.push(
241
- C({
242
- day: u,
243
- currentDate: i,
244
- date: D(w, y, u),
245
- isToday: f,
246
- isOutsideMonth: !0,
247
- select: n,
248
- disabled: F
249
- })
250
- );
251
- }
252
- for (let o = 1; o <= g; o++) {
253
- const u = M(o, r, a, t), f = new Date(a, r, o) < new Date(t.year, t.month, t.date), p = s && f;
254
- h.push(
255
- C({
256
- day: o,
257
- currentDate: i,
258
- date: D(a, r, o),
259
- isToday: u,
260
- isOutsideMonth: !1,
261
- select: n,
262
- disabled: p
263
- })
264
- );
265
- }
266
- const v = r === 11 ? 0 : r + 1, b = r === 11 ? a + 1 : a, A = (7 - h.length % 7) % 7;
267
- for (let o = 1; o <= A; o++) {
268
- const u = M(o, v, b, t), f = new Date(b, v, o) < new Date(t.year, t.month, t.date), p = s && f;
269
- h.push(
270
- C({
271
- day: o,
272
- currentDate: i,
273
- date: D(b, v, o),
274
- isToday: u,
275
- isOutsideMonth: !0,
276
- select: n,
277
- disabled: p
278
- })
279
- );
280
- }
281
- return h;
282
- }, P = ({ label: e, click: t }) => m(
283
- {
284
- class: `
285
- inline-flex items-center justify-center h-7 w-7 bg-transparent p-0
286
- opacity-50 hover:opacity-100 text-muted-foreground absolute
287
- ${e === "Previous" ? "left-1" : "right-1"}
288
- focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
289
- `,
290
- click: t,
291
- "aria-label": `${e} month`,
292
- variant: "icon",
293
- icon: e === "Previous" ? S.chevron.single.left : S.chevron.single.right
294
- }
295
- ), et = ({ onMonthClick: e, onYearClick: t, next: n, previous: s }) => l({ class: "flex items-center justify-center space-x-2 relative min-h-12 text-sm font-medium" }, [
296
- m({ click: e, variant: "ghost", "aria-label": "Select month" }, "[[monthName]]"),
297
- m({ click: t, variant: "ghost", "aria-label": "Select year" }, "[[current.year]]"),
298
- P({ label: "Previous", click: s }),
299
- P({ label: "Next", click: n })
300
- ]), nt = (e) => l(
301
- { class: "flex items-center justify-center h-9 w-auto text-[0.8rem] font-normal text-muted-foreground" },
302
- e
303
- ), st = () => ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(nt), at = (e) => l({ class: "rdp w-full space-y-1" }, [
304
- et({
305
- onMonthClick: e.onMonthClick,
306
- onYearClick: e.onYearClick,
307
- next: e.next,
308
- previous: e.previous
309
- }),
310
- l({
311
- class: "flex flex-auto flex-col w-full",
312
- onSet: [
313
- "currentDate",
314
- () => [
315
- l({ class: "grid grid-cols-7" }, st()),
316
- l(
317
- { class: "grid grid-cols-7" },
318
- tt(
319
- e.current,
320
- e.today,
321
- e.select,
322
- e.blockPriorDates
323
- )
324
- )
325
- ]
326
- ]
327
- })
328
- ]), rt = ({ currentMonth: e, currentYear: t, onSelect: n }) => {
329
- const s = t - 50, a = Array.from({ length: 101 }, (r, i) => s + i);
330
- return l(
331
- { class: "grid grid-cols-4 gap-2 overflow-y-auto max-h-72" },
332
- a.map(
333
- (r) => m(
334
- {
335
- click: (i) => {
336
- i.preventDefault(), i.stopPropagation(), n(r);
337
- },
338
- variant: r === t ? "primary" : "ghost",
339
- "aria-label": `Select ${r}`
340
- },
341
- r.toString()
342
- )
343
- )
344
- );
345
- };
346
- class gt extends N {
347
- /**
348
- * This will declare the props for the compiler.
349
- *
350
- * @returns {void}
351
- */
352
- declareProps() {
353
- this.selectedDate = null, this.selectedCallBack = null, this.blockPriorDates = !1;
354
- }
355
- /**
356
- * This will get the selected data.
357
- *
358
- * @param {object} today
359
- * @returns {Date}
360
- */
361
- getSelectedDate(t) {
362
- const n = this.selectedDate ? new Date(q(this.selectedDate)) : t;
363
- return new Date(n.getFullYear(), n.getMonth(), n.getDate());
364
- }
365
- /**
366
- * This will set up the data for the calendar.
367
- *
368
- * @returns {Data}
369
- */
370
- setData() {
371
- const t = /* @__PURE__ */ new Date(), n = this.getSelectedDate(t), s = n.getMonth();
372
- return new z({
373
- monthName: this.getMonthName(s),
374
- currentDate: `${n.getFullYear()}-${s + 1}-${n.getDate()}`,
375
- current: {
376
- date: n.getDate(),
377
- year: n.getFullYear(),
378
- month: s
379
- },
380
- today: {
381
- date: t.getDate(),
382
- month: t.getMonth(),
383
- year: t.getFullYear()
384
- }
385
- });
386
- }
387
- /**
388
- * This will set up the states for the calendar.
389
- *
390
- * @return {object}
391
- */
392
- setupStates() {
393
- return {
394
- view: "calendar"
395
- // 'calendar' | 'months' | 'years'
396
- };
397
- }
398
- /**
399
- * This will get the name of the month.
400
- *
401
- * @param {number} month
402
- * @returns {string}
403
- */
404
- getMonthName(t) {
405
- return B.monthNames[t];
406
- }
407
- /**
408
- * This will go to the previous month.
409
- *
410
- * @returns {void}
411
- */
412
- goToPreviousMonth() {
413
- const t = this.data;
414
- let n = t.current.month, s = t.current.year;
415
- n === 0 ? (n = 11, s--) : n--, this.setCurrentDate(n, s);
416
- }
417
- /**
418
- * This will go to the next month.
419
- *
420
- * @returns {void}
421
- */
422
- goToNextMonth() {
423
- const t = this.data;
424
- let n = t.current.month, s = t.current.year;
425
- n === 11 ? (n = 0, s++) : n++, this.setCurrentDate(n, s);
426
- }
427
- /**
428
- * This will set the current month and year.
429
- *
430
- * @param {number} month
431
- * @param {number} year
432
- * @param {number} [date=null]
433
- * @returns {void}
434
- */
435
- setCurrentDate(t, n, s = null) {
436
- const a = this.data;
437
- a.current.month = t, a.current.year = n, typeof s == "number" && (a.current.date = x(s)), a.currentDate = `${n}-${x(t + 1)}-${a.current.date}`, a.monthName = this.getMonthName(t);
438
- }
439
- /**
440
- * This will select a date.
441
- *
442
- * @param {string} date
443
- * @returns {void}
444
- */
445
- selectDate(t) {
446
- const n = /* @__PURE__ */ new Date(t + "T00:00:00");
447
- this.setCurrentDate(n.getMonth(), n.getFullYear(), n.getDate()), typeof this.selectedCallBack == "function" && this.selectedCallBack(this.data.currentDate);
448
- }
449
- /**
450
- * This will render the calendar.
451
- *
452
- * @returns {object}
453
- */
454
- render() {
455
- return l({ class: "calendar-container p-3 rounded-md border min-w-80" }, [
456
- W("view", (t) => {
457
- switch (t) {
458
- case "months":
459
- return _(
460
- {
461
- currentMonth: this.data.current.month,
462
- currentYear: this.data.current.year,
463
- onSelect: (n) => {
464
- this.setCurrentDate(n, this.data.current.year), this.state.view = "calendar";
465
- }
466
- }
467
- );
468
- case "years":
469
- return rt(
470
- {
471
- currentMonth: this.data.current.month,
472
- currentYear: this.data.current.year,
473
- onSelect: (n) => {
474
- this.setCurrentDate(this.data.current.month, n), this.state.view = "calendar";
475
- }
476
- }
477
- );
478
- default:
479
- return at({
480
- current: this.data.current,
481
- today: this.data.today,
482
- select: (n) => this.selectDate(n),
483
- next: () => this.goToNextMonth(),
484
- previous: () => this.goToPreviousMonth(),
485
- blockPriorDates: this.blockPriorDates || !1,
486
- onMonthClick: (n) => {
487
- n.preventDefault(), n.stopPropagation(), this.state.view = "months";
488
- },
489
- onYearClick: (n) => {
490
- n.preventDefault(), n.stopPropagation(), this.state.view = "years";
491
- }
492
- });
493
- }
494
- })
495
- ]);
496
- }
497
- }
498
- export {
499
- dt as A,
500
- tt as C,
501
- C as D,
502
- D as F,
503
- at as M,
504
- ht as P,
505
- nt as a,
506
- gt as b,
507
- q as c,
508
- H as g,
509
- x as p
510
- };