@base-framework/ui 0.0.5 → 0.0.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.
@@ -8,9 +8,11 @@
8
8
  */
9
9
  export class Panel extends Component {
10
10
  /**
11
+ * This will set the class.
11
12
  * @member {string} class
13
+ * @default ''
12
14
  */
13
- class: any;
15
+ class: string;
14
16
  /**
15
17
  * This will render the component.
16
18
  *
@@ -20,8 +20,8 @@ export class TabGroup extends Component {
20
20
  */
21
21
  class: string;
22
22
  /**
23
- * This will set the on select call back.
24
- * @member {function} onSelect
23
+ * This will set the select call back.
24
+ * @member {function} callBack
25
25
  */
26
26
  onSelect: any;
27
27
  /**
@@ -19,8 +19,8 @@ export class TabNavigation extends Component {
19
19
  */
20
20
  class: string;
21
21
  /**
22
- * This will set the on select call back.
23
- * @member {function} onSelect
22
+ * This will set the select call back.
23
+ * @member {function} callBack
24
24
  */
25
25
  onSelect: any;
26
26
  links: any[];
@@ -9,7 +9,9 @@
9
9
  */
10
10
  export class Page extends Component {
11
11
  /**
12
+ * This will set the class.
12
13
  * @member {string} class
14
+ * @default ''
13
15
  */
14
16
  class: string;
15
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-framework/ui",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
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,578 +0,0 @@
1
- var w = Object.defineProperty;
2
- var S = (t, s, e) => s in t ? w(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
3
- var l = (t, s, e) => S(t, typeof s != "symbol" ? s + "" : s, e);
4
- import { I as N, Label as B, Span as L, Ul as r, H4 as C, Nav as h, Div as o, Header as y, H1 as I, H3 as f, OnState as $ } from "@base-framework/atoms";
5
- import { Component as i, Atom as c, NavLink as H, router as p } from "@base-framework/base";
6
- import { I as x, B as m } from "./icon-B9QUT2NY.js";
7
- import { Icons as u } from "./icons.es.js";
8
- class M extends i {
9
- constructor() {
10
- super(...arguments);
11
- /**
12
- * This will set the class.
13
- * @member {string} class
14
- * @default ''
15
- */
16
- l(this, "class", "");
17
- /**
18
- * This will set the check callback.
19
- * @member {function} checkCallBack
20
- * @default null
21
- */
22
- l(this, "checkCallBack", null);
23
- }
24
- /**
25
- * This will render the component.
26
- *
27
- * @override
28
- * @returns {object}
29
- */
30
- render() {
31
- const e = this.state;
32
- return {
33
- class: this.class || "",
34
- onState: [
35
- ["selected", {
36
- selected: !0
37
- }],
38
- ["active", {
39
- active: !0
40
- }]
41
- ],
42
- click: () => {
43
- if (e.toggle("active"), !this.checkCallBack)
44
- return;
45
- const a = e.active ? this : null;
46
- this.checkCallBack(a);
47
- },
48
- children: this.children
49
- };
50
- }
51
- /**
52
- * This will set up the states.
53
- *
54
- * @override
55
- * @protected
56
- * @returns {object}
57
- */
58
- setupStates() {
59
- return {
60
- selected: !1,
61
- active: !1
62
- };
63
- }
64
- /**
65
- * This will update the states.
66
- *
67
- * @param {object} selected
68
- * @returns {void}
69
- */
70
- update(e) {
71
- this.state.set({
72
- selected: e,
73
- active: e
74
- });
75
- }
76
- }
77
- const O = c(({ options: t, click: s }, e) => ({
78
- tag: "li",
79
- ...{
80
- class: `relative flex flex-row w-auto text-left p-0 overflow-hidden transition-all cursor-pointer min-w-[48px] rounded-md option${t ? " sub" : ""}`,
81
- click: s
82
- },
83
- children: e
84
- })), z = (t, s = null, e = !1) => [
85
- s && N({
86
- class: "icon w-12 rounded-md flex items-center justify-center",
87
- onState: ["selected", {
88
- selected: !0
89
- }],
90
- html: s
91
- }),
92
- B({ class: "label flex flex-auto text-sm items-center cursor-pointer whitespace-nowrap" }, t),
93
- e && L(
94
- {
95
- class: "flex justify-center items-center px-1 transition-all text-muted-foreground mr-2",
96
- onState: [
97
- ["selected", {
98
- rotate: !0
99
- }],
100
- ["active", {
101
- rotate: !0
102
- }]
103
- ]
104
- },
105
- [
106
- x({ size: "xs" }, u.chevron.single.down)
107
- ]
108
- )
109
- ];
110
- class g extends i {
111
- constructor() {
112
- super(...arguments);
113
- /**
114
- * This will set the label.
115
- * @member {string} label
116
- * @default ''
117
- */
118
- l(this, "label", "");
119
- /**
120
- * This will set the icon.
121
- * @member {string} icon
122
- * @default null
123
- */
124
- l(this, "icon", null);
125
- /**
126
- * This will set the href.
127
- * @member {string} href
128
- * @default null
129
- */
130
- l(this, "href", null);
131
- /**
132
- * This will set the exact.
133
- * @member {boolean} exact
134
- * @default false
135
- */
136
- l(this, "exact", !1);
137
- /**
138
- * This will set the options.
139
- * @member {array} options
140
- */
141
- l(this, "options", []);
142
- /**
143
- * This will set the content.
144
- * @member {array} content
145
- * @default null
146
- */
147
- l(this, "content", null);
148
- /**
149
- * This will set the call back.
150
- * @member {function} callBack
151
- */
152
- l(this, "callBack", null);
153
- /**
154
- * This will set the check call back.
155
- * @member {function} checkCallBack
156
- */
157
- l(this, "checkCallBack", null);
158
- /**
159
- * This will set the link.
160
- * @member {object} link
161
- */
162
- l(this, "link", null);
163
- }
164
- /**
165
- * This will render the component.
166
- *
167
- * @override
168
- * @returns {object}
169
- */
170
- render() {
171
- const e = !this.options && this.callBack;
172
- return O(
173
- { options: this.options, click: e },
174
- [
175
- this.addLink()
176
- ]
177
- );
178
- }
179
- /**
180
- * This will add the link.
181
- *
182
- * @returns {object}
183
- * @protected
184
- */
185
- addLink() {
186
- const e = this.options && this.options.length > 0, a = this.content || z(this.label, this.icon, e);
187
- return this.href ? new H(
188
- {
189
- class: "flex flex-auto flex-row",
190
- cache: "link",
191
- href: this.href,
192
- activeClass: "selected",
193
- exact: this.exact || !1
194
- },
195
- a
196
- ) : new M({
197
- class: "flex flex-auto flex-row",
198
- cache: "link",
199
- checkCallBack: this.checkCallBack
200
- }, a);
201
- }
202
- /**
203
- * This will check if the link is selected.
204
- *
205
- * @returns {boolean}
206
- */
207
- isSelected() {
208
- return this.link.state.get("selected");
209
- }
210
- update(e) {
211
- this.link.update(e);
212
- }
213
- }
214
- const E = c(({ map: t }, s) => r({ class: "navigation-group flex flex-col gap-2 list-none m-0 py-2 px-0", map: t }, [
215
- C({ class: "text-muted-foreground text-sm py-0 px-4 whitespace-nowrap" }, s)
216
- ]));
217
- class P extends i {
218
- constructor() {
219
- super(...arguments);
220
- /**
221
- * This will set the options.
222
- * @member {array} options
223
- */
224
- l(this, "options", []);
225
- /**
226
- * This will set the class.
227
- * @member {string} class
228
- */
229
- l(this, "class", "");
230
- /**
231
- * This will set the mobile border.
232
- * @member {boolean} mobileBorder
233
- * @default false
234
- */
235
- l(this, "mobileBorder", !1);
236
- }
237
- /**
238
- * This will render the component.
239
- *
240
- * @returns {object}
241
- */
242
- render() {
243
- const e = this.mapOptions(this.options), a = this.class || "", n = this.mobileBorder ? "border md:border-0 rounded-md" : "";
244
- return h({ class: `navigation flex flex-auto flex-col ${a}` }, [
245
- r({
246
- class: `relative group flex flex-col gap-2 py-2 px-2 list-none m-0 ${n}`,
247
- map: e
248
- }),
249
- ...this.addSubs()
250
- ]);
251
- }
252
- /**
253
- * This will get the options.
254
- *
255
- * @param {array} options
256
- * @returns {array}
257
- */
258
- mapOptions(e = []) {
259
- return [e.map((n) => n.group ? this.addGroup(n) : this.addLink(n)), (n) => n];
260
- }
261
- /**
262
- * This will get the subs.
263
- *
264
- * @returns {array}
265
- */
266
- addSubs() {
267
- return [];
268
- }
269
- /**
270
- * This will add a group.
271
- *
272
- * @param {object} option
273
- * @returns {object}
274
- */
275
- addGroup(e) {
276
- const a = this.mapOptions(e.options);
277
- return E({ map: a }, e.group);
278
- }
279
- /**
280
- * This will add a link.
281
- *
282
- * @param {object} option
283
- * @returns {object}
284
- */
285
- addLink(e) {
286
- return new g(e);
287
- }
288
- }
289
- class d extends P {
290
- onCreated() {
291
- this.links = [];
292
- }
293
- /**
294
- * This will set up the sub nav.
295
- *
296
- * @param {object} link
297
- * @returns {object}
298
- */
299
- setupSubNav(s) {
300
- return new G(
301
- {
302
- parentLink: s,
303
- options: s.options
304
- }
305
- );
306
- }
307
- /**
308
- * This will add a sub navigation.
309
- *
310
- * @param {object} link
311
- * @returns {object}
312
- */
313
- addSubNav(s) {
314
- const e = this.setupSubNav(s);
315
- return s.sub = e, e;
316
- }
317
- /**
318
- * This will add a link.
319
- *
320
- * @param {object} option
321
- * @returns {object}
322
- */
323
- addLink(s) {
324
- const e = new g(s);
325
- if (this.links.push(e), !e.options)
326
- return e;
327
- const a = this.addSubNav(e);
328
- return {
329
- class: "child-group",
330
- link: e,
331
- sub: a
332
- };
333
- }
334
- }
335
- const T = (t, s) => new RegExp(`${t}($|/|\\.).*`).test(s), A = (t, s) => {
336
- const e = t.link.panel.pathname;
337
- return !e && t.isSelected() ? !0 : t.exact ? s === e : T(e, s);
338
- };
339
- class G extends d {
340
- constructor() {
341
- super(...arguments);
342
- /**
343
- * This will set the parent link.
344
- * @member {object} parentLink
345
- * @default null
346
- */
347
- l(this, "parentLink", null);
348
- /**
349
- * This will set the main class name.
350
- * @member {string} mainClassName
351
- * @default ''
352
- */
353
- l(this, "mainClassName", "");
354
- }
355
- /**
356
- * This will render the component.
357
- *
358
- * @returns {object}
359
- */
360
- render() {
361
- const e = `navigation flex flex-auto flex-col sub ${this.mainClassName || ""}`, a = this.mapOptions(this.options);
362
- return h({ class: e, onState: this.onState() }, [
363
- r({ class: "relative group flex flex-col gap-2 py-2 px-0 list-none m-0" }, [...a, ...this.addSubs(), this.addWatcher()])
364
- ]);
365
- }
366
- /**
367
- * This will add awatcher to update the links
368
- * when the path changes.
369
- *
370
- * @returns {object}
371
- */
372
- addWatcher() {
373
- return {
374
- watch: {
375
- value: ["[[path]]", p.data],
376
- callBack: this.updateLinks.bind(this)
377
- }
378
- };
379
- }
380
- /**
381
- * This will set up the on state.
382
- *
383
- * @returns {array}
384
- */
385
- onState() {
386
- return [
387
- ["selected", { active: !0 }],
388
- ["active", { active: !0 }]
389
- ];
390
- }
391
- /**
392
- * This will set up the states.
393
- *
394
- * @returns {object}
395
- */
396
- setupStates() {
397
- return {
398
- remotes: [
399
- {
400
- /**
401
- * This will link the state to the parent link.
402
- */
403
- id: this.parentLink.link.getId(),
404
- selected: null,
405
- active: null
406
- }
407
- ]
408
- };
409
- }
410
- /**
411
- * This will update the links after setup.
412
- *
413
- * @returns {void}
414
- */
415
- afterSetup() {
416
- const e = p.data.get("path");
417
- this.updateLinks(e);
418
- }
419
- /**
420
- * This will update the links.
421
- *
422
- * @param {string} value
423
- * @returns {void}
424
- */
425
- updateLinks(e) {
426
- let a = !1;
427
- for (const n of this.links)
428
- if (n.rendered && (a = A(n, e), a === !0))
429
- break;
430
- this.parentLink.update(a);
431
- }
432
- }
433
- const V = ({ title: t, options: s, class: e = "", mobileBorder: a = !1, sticky: n = !1 }) => o({ class: `pb-12 p-4 pt-0 lg:p-6 lg:border-r w-full lg:max-w-[300px] h-full ${e}` }, [
434
- t && y({ class: "pb-4 md:pb-2 px-6 flex flex-col" }, [
435
- I({ class: "scroll-m-20 text-3xl lg:text-2xl font-bold tracking-tight" }, t)
436
- ]),
437
- new d({ options: s, mobileBorder: a, class: n ? "sticky top-0" : "" })
438
- ]), W = (t) => f({ class: "text-lg ml-2" }, t), j = (t) => o({ class: "sticky flex flex-row items-center bg-popover lg:hidden top-0 z-10 border-0 border-b" }, [
439
- m({
440
- variant: "icon",
441
- class: "m-2",
442
- click: (s, { state: e }) => e.toggle("open"),
443
- icon: u.arrows.left
444
- }),
445
- t.title && W(t.title)
446
- ]), Y = () => o({
447
- class: `
448
- absolute inset-0 bg-black/40 z-[-1] fadeIn
449
- transition-opacity duration-200
450
- `,
451
- click: (t, { state: s }) => s.open = !1
452
- });
453
- class D extends i {
454
- constructor() {
455
- super(...arguments);
456
- /**
457
- * This will set the title.
458
- * @member {string} title
459
- */
460
- l(this, "title", "");
461
- }
462
- /**
463
- * This will render the modal component.
464
- *
465
- * @returns {object}
466
- */
467
- render() {
468
- return o({
469
- class: "fixed inset-0 z-50",
470
- style: "[[typeClass]]"
471
- }, [
472
- Y(),
473
- // Popover Content
474
- o({
475
- class: `
476
- absolute popIn w-auto p-0 bg-popover m-auto shadow-lg rounded-md top-0 bottom-0 left-2 right-2 max-h-[85vh] text-inherit block
477
- `,
478
- dataSet: ["open", ["expanded", !0, "true"]]
479
- }, [
480
- o({ class: "flex flex-auto flex-col w-full h-full overflow-y-auto max-h-[85vh] rounded-md bg-popover border" }, [
481
- j({ title: this.title }),
482
- o({ class: "flex flex-auto flex-col" }, this.children)
483
- ])
484
- ])
485
- ]);
486
- }
487
- /**
488
- * This will setup the states.
489
- *
490
- * @returns {object}
491
- */
492
- setupStates() {
493
- return {
494
- open: {
495
- id: this.parent.getId(),
496
- callBack: (n) => {
497
- n === !1 && (document.documentElement.style.overflowY = "auto", this.destroy());
498
- }
499
- }
500
- };
501
- }
502
- /**
503
- * This will add the body scroll lock.
504
- *
505
- * @returns {void}
506
- */
507
- afterSetup() {
508
- document.documentElement.style.overflowY = "hidden";
509
- }
510
- /**
511
- * This will override the set up to use the body.
512
- *
513
- * @param {object} container
514
- */
515
- setContainer(e) {
516
- this.container = app.root;
517
- }
518
- }
519
- const k = (t) => m({ class: "m-2", variant: "ghost", addState() {
520
- return {
521
- open: !1
522
- };
523
- }, click: (s, { state: e }) => e.toggle("open") }, [
524
- x(u.bar.three)
525
- ]), R = (t) => f({ class: "text-lg ml-2" }, t), U = (t) => o({ class: "flex flex-auto flex-row items-center lg:hidden" }, [
526
- k(),
527
- t.title && R(t.title)
528
- ]), v = (t, s) => {
529
- t.forEach((e) => {
530
- if (e.options) {
531
- v(e.options, s);
532
- return;
533
- }
534
- e.callBack = s;
535
- });
536
- }, b = (t) => {
537
- const s = (e, { parent: a }) => a.parent.state.open = !1;
538
- return v(t.options, s), o({ class: "bg-background flex flex-auto flex-col w-full relative" }, [
539
- $(
540
- "open",
541
- (e) => e ? [
542
- new D({ title: t.title }, [
543
- new d(
544
- {
545
- options: t.options
546
- }
547
- )
548
- ])
549
- ] : null
550
- )
551
- ]);
552
- }, X = c((t) => o({ cache: "mobileNav", class: "inline-flex relative lg:hidden" }, [
553
- o([
554
- k(),
555
- b(t)
556
- ])
557
- ])), Z = c((t) => o({ cache: "mobileNav", class: "flex flex-auto flex-col w-full relative lg:hidden" }, [
558
- o({ class: "flex flex-auto flex-col w-full" }, [
559
- U(t),
560
- b(t)
561
- ])
562
- ]));
563
- export {
564
- Y as B,
565
- d as I,
566
- g as M,
567
- M as N,
568
- j as P,
569
- G as S,
570
- U as T,
571
- E as a,
572
- P as b,
573
- V as c,
574
- X as d,
575
- Z as e,
576
- D as f,
577
- k as g
578
- };