@base-framework/ui 1.2.14 → 1.2.16

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