waibu-bootstrap 1.0.1

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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/bajo/.alias +1 -0
  4. package/bajo/config.json +6 -0
  5. package/bajo/hook/waibu-mpa.bootstrap@after-build-page.js +5 -0
  6. package/bajoI18N/resource/id.json +2 -0
  7. package/package.json +33 -0
  8. package/waibuMpa/theme/component/factory/_lib.js +140 -0
  9. package/waibuMpa/theme/component/factory/a.js +12 -0
  10. package/waibuMpa/theme/component/factory/accordion-item.js +34 -0
  11. package/waibuMpa/theme/component/factory/accordion.js +24 -0
  12. package/waibuMpa/theme/component/factory/alert.js +33 -0
  13. package/waibuMpa/theme/component/factory/app-launcher-trigger.js +37 -0
  14. package/waibuMpa/theme/component/factory/app-launcher.js +55 -0
  15. package/waibuMpa/theme/component/factory/badge.js +24 -0
  16. package/waibuMpa/theme/component/factory/blockquote.js +22 -0
  17. package/waibuMpa/theme/component/factory/breadcrumb-item.js +27 -0
  18. package/waibuMpa/theme/component/factory/breadcrumb.js +64 -0
  19. package/waibuMpa/theme/component/factory/btn-back-to-top.js +40 -0
  20. package/waibuMpa/theme/component/factory/btn-close.js +18 -0
  21. package/waibuMpa/theme/component/factory/btn-group.js +25 -0
  22. package/waibuMpa/theme/component/factory/btn-toolbar.js +13 -0
  23. package/waibuMpa/theme/component/factory/btn.js +40 -0
  24. package/waibuMpa/theme/component/factory/card-body.js +13 -0
  25. package/waibuMpa/theme/component/factory/card-footer.js +17 -0
  26. package/waibuMpa/theme/component/factory/card-group.js +13 -0
  27. package/waibuMpa/theme/component/factory/card-header.js +27 -0
  28. package/waibuMpa/theme/component/factory/card-link.js +14 -0
  29. package/waibuMpa/theme/component/factory/card-subtitle.js +13 -0
  30. package/waibuMpa/theme/component/factory/card-text.js +15 -0
  31. package/waibuMpa/theme/component/factory/card-title.js +13 -0
  32. package/waibuMpa/theme/component/factory/card.js +23 -0
  33. package/waibuMpa/theme/component/factory/carousel-item.js +25 -0
  34. package/waibuMpa/theme/component/factory/carousel.js +53 -0
  35. package/waibuMpa/theme/component/factory/collapse-item.js +14 -0
  36. package/waibuMpa/theme/component/factory/collapse.js +58 -0
  37. package/waibuMpa/theme/component/factory/container.js +22 -0
  38. package/waibuMpa/theme/component/factory/drawer-toolbar.js +6 -0
  39. package/waibuMpa/theme/component/factory/drawer.js +59 -0
  40. package/waibuMpa/theme/component/factory/dropdown-item.js +34 -0
  41. package/waibuMpa/theme/component/factory/dropdown.js +121 -0
  42. package/waibuMpa/theme/component/factory/fieldset.js +39 -0
  43. package/waibuMpa/theme/component/factory/figcaption.js +13 -0
  44. package/waibuMpa/theme/component/factory/figure.js +20 -0
  45. package/waibuMpa/theme/component/factory/form-check-toggle.js +33 -0
  46. package/waibuMpa/theme/component/factory/form-check.js +56 -0
  47. package/waibuMpa/theme/component/factory/form-color.js +12 -0
  48. package/waibuMpa/theme/component/factory/form-date.js +26 -0
  49. package/waibuMpa/theme/component/factory/form-datetime.js +83 -0
  50. package/waibuMpa/theme/component/factory/form-file.js +17 -0
  51. package/waibuMpa/theme/component/factory/form-input-addon.js +10 -0
  52. package/waibuMpa/theme/component/factory/form-input.js +132 -0
  53. package/waibuMpa/theme/component/factory/form-password.js +13 -0
  54. package/waibuMpa/theme/component/factory/form-plaintext.js +14 -0
  55. package/waibuMpa/theme/component/factory/form-radio-toggle.js +13 -0
  56. package/waibuMpa/theme/component/factory/form-radio.js +12 -0
  57. package/waibuMpa/theme/component/factory/form-range.js +14 -0
  58. package/waibuMpa/theme/component/factory/form-select-country.js +25 -0
  59. package/waibuMpa/theme/component/factory/form-select-ext.js +53 -0
  60. package/waibuMpa/theme/component/factory/form-select.js +34 -0
  61. package/waibuMpa/theme/component/factory/form-switch.js +18 -0
  62. package/waibuMpa/theme/component/factory/form-textarea.js +12 -0
  63. package/waibuMpa/theme/component/factory/form-time.js +22 -0
  64. package/waibuMpa/theme/component/factory/form.js +46 -0
  65. package/waibuMpa/theme/component/factory/grid-col.js +44 -0
  66. package/waibuMpa/theme/component/factory/grid-row.js +21 -0
  67. package/waibuMpa/theme/component/factory/heading.js +20 -0
  68. package/waibuMpa/theme/component/factory/img.js +20 -0
  69. package/waibuMpa/theme/component/factory/lead.js +15 -0
  70. package/waibuMpa/theme/component/factory/list-item.js +38 -0
  71. package/waibuMpa/theme/component/factory/list.js +62 -0
  72. package/waibuMpa/theme/component/factory/masonry.js +34 -0
  73. package/waibuMpa/theme/component/factory/modal-body.js +13 -0
  74. package/waibuMpa/theme/component/factory/modal-footer.js +13 -0
  75. package/waibuMpa/theme/component/factory/modal-header.js +13 -0
  76. package/waibuMpa/theme/component/factory/modal.js +60 -0
  77. package/waibuMpa/theme/component/factory/nav-divider.js +24 -0
  78. package/waibuMpa/theme/component/factory/nav-dropdown-darkmode.js +24 -0
  79. package/waibuMpa/theme/component/factory/nav-dropdown-language.js +26 -0
  80. package/waibuMpa/theme/component/factory/nav-dropdown-setting.js +84 -0
  81. package/waibuMpa/theme/component/factory/nav-dropdown-user.js +36 -0
  82. package/waibuMpa/theme/component/factory/nav-item-signout.js +26 -0
  83. package/waibuMpa/theme/component/factory/nav-item.js +55 -0
  84. package/waibuMpa/theme/component/factory/nav-toggle-fullscreen.js +47 -0
  85. package/waibuMpa/theme/component/factory/nav.js +30 -0
  86. package/waibuMpa/theme/component/factory/navbar-brand.js +16 -0
  87. package/waibuMpa/theme/component/factory/navbar-text.js +13 -0
  88. package/waibuMpa/theme/component/factory/navbar.js +65 -0
  89. package/waibuMpa/theme/component/factory/pagination-item.js +21 -0
  90. package/waibuMpa/theme/component/factory/pagination.js +22 -0
  91. package/waibuMpa/theme/component/factory/progress-stack.js +26 -0
  92. package/waibuMpa/theme/component/factory/progress.js +37 -0
  93. package/waibuMpa/theme/component/factory/scrollspy.js +25 -0
  94. package/waibuMpa/theme/component/factory/sidebar.js +74 -0
  95. package/waibuMpa/theme/component/factory/spinner.js +17 -0
  96. package/waibuMpa/theme/component/factory/table.js +40 -0
  97. package/waibuMpa/theme/component/factory/tbody.js +14 -0
  98. package/waibuMpa/theme/component/factory/td.js +15 -0
  99. package/waibuMpa/theme/component/factory/tfoot.js +14 -0
  100. package/waibuMpa/theme/component/factory/th.js +15 -0
  101. package/waibuMpa/theme/component/factory/thead.js +14 -0
  102. package/waibuMpa/theme/component/factory/toast-stack.js +15 -0
  103. package/waibuMpa/theme/component/factory/toast.js +33 -0
  104. package/waibuMpa/theme/component/factory/tr.js +15 -0
  105. package/waibuMpa/theme/component/method/after-build-tag/_lib.js +50 -0
  106. package/waibuMpa/theme/component/method/after-build-tag/active.js +7 -0
  107. package/waibuMpa/theme/component/method/after-build-tag/background.js +25 -0
  108. package/waibuMpa/theme/component/method/after-build-tag/border.js +26 -0
  109. package/waibuMpa/theme/component/method/after-build-tag/dim.js +23 -0
  110. package/waibuMpa/theme/component/method/after-build-tag/disabled.js +6 -0
  111. package/waibuMpa/theme/component/method/after-build-tag/display.js +34 -0
  112. package/waibuMpa/theme/component/method/after-build-tag/flex.js +69 -0
  113. package/waibuMpa/theme/component/method/after-build-tag/font.js +19 -0
  114. package/waibuMpa/theme/component/method/after-build-tag/gutter.js +23 -0
  115. package/waibuMpa/theme/component/method/after-build-tag/label.js +6 -0
  116. package/waibuMpa/theme/component/method/after-build-tag/link.js +24 -0
  117. package/waibuMpa/theme/component/method/after-build-tag/margin-padding.js +15 -0
  118. package/waibuMpa/theme/component/method/after-build-tag/popover.js +14 -0
  119. package/waibuMpa/theme/component/method/after-build-tag/position.js +52 -0
  120. package/waibuMpa/theme/component/method/after-build-tag/rounded.js +25 -0
  121. package/waibuMpa/theme/component/method/after-build-tag/text.js +32 -0
  122. package/waibuMpa/theme/component/method/after-build-tag/tooltip.js +14 -0
  123. package/waibuMpa/theme/component/method/after-build-tag.js +113 -0
  124. package/waibuMpa/theme.js +24 -0
  125. package/waibuStatic/asset/css/wbs.css +12 -0
  126. package/waibuStatic/asset/js/wbs.js +200 -0
  127. package/waibuStatic/virtual.json +7 -0
@@ -0,0 +1,25 @@
1
+ import { parseSimple, sizes } from '../method/after-build-tag/_lib.js'
2
+
3
+ const cls = 'btn-group'
4
+
5
+ async function btnGroup () {
6
+ return class BtnGroup extends this.baseFactory {
7
+ constructor (options) {
8
+ super(options)
9
+ this.selector = '.' + cls
10
+ this.component.normalizeAttr(this.params, { tag: 'div', cls, role: 'group' })
11
+ if (this.params.attr.size) this.params.attr.class.push(parseSimple.call(this, { cls, value: this.params.attr.size, values: sizes }))
12
+ }
13
+
14
+ async build () {
15
+ const { $ } = this.component
16
+ const html = []
17
+ $(`<div>${this.params.html}</div>`).children().each(function () {
18
+ html.push($(this).hasClass('dropdown') ? $(this).html() : $(this).prop('outerHTML'))
19
+ })
20
+ this.params.html = html.join('\n')
21
+ }
22
+ }
23
+ }
24
+
25
+ export default btnGroup
@@ -0,0 +1,13 @@
1
+ const cls = 'btn-toolbar'
2
+
3
+ async function btnToolbar () {
4
+ return class BtnToolbar extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'div', cls, role: 'toolbar' })
9
+ }
10
+ }
11
+ }
12
+
13
+ export default btnToolbar
@@ -0,0 +1,40 @@
1
+ import { parseVariant, parseSimple, sizes, colors, colorVariants } from '../method/after-build-tag/_lib.js'
2
+
3
+ const cls = 'btn'
4
+
5
+ async function btn () {
6
+ return class Btn extends this.baseFactory {
7
+ constructor (options) {
8
+ super(options)
9
+ this.selector = '.' + cls
10
+ this.component.normalizeAttr(this.params, { cls })
11
+ this.params.attr.class.push(cls)
12
+ }
13
+
14
+ async build () {
15
+ const { has, omit, isString } = this.plugin.app.bajo.lib._
16
+ // tag
17
+ this.params.tag = !!this.params.attr.href || this.params.attr.tag === 'a' ? 'a' : 'button'
18
+ if (this.params.tag === 'button' && this.params.attr.href) delete this.params.attr.href
19
+ if (this.params.tag === 'a' && this.params.attr.href === true) this.params.attr.href = '#'
20
+ if (this.params.tag === 'a') this.params.attr.role = 'button'
21
+ if (this.params.tag === 'button' && !has(this.params.attr, 'type')) this.params.attr.type = 'button'
22
+
23
+ if (this.params.attr.disabled && this.params.tag === 'a') {
24
+ this.params.attr.class.push('disabled')
25
+ this.params.attr.ariaDisabled = true
26
+ this.params.attr.tabIndex = -1
27
+ this.params.attr = omit(this.params.attr, ['disabled', 'href'])
28
+ }
29
+ if (this.params.attr.dismiss === 'drawer') this.params.attr.dismiss = 'offcanvas'
30
+ if (this.params.attr.toggle) this.params.attr.dataBsToggle = 'button'
31
+ if (this.params.attr.active) this.params.attr.ariaPressed = true
32
+ if (this.params.attr.color) this.params.attr.class.push(parseVariant.call(this, { cls, value: this.params.attr.color, values: colors, variants: colorVariants, prepend: true }))
33
+ if (this.params.attr.size) this.params.attr.class.push(parseSimple.call(this, { cls, value: this.params.attr.size, values: sizes }))
34
+ if (this.params.attr.dismiss) this.params.attr.dataBsDismiss = isString(this.params.attr.dismiss) ? this.params.attr.dismiss : 'modal'
35
+ if (this.params.html.includes('<i class="') && this.params.attr.href) this.params.attr.class.push('icon-link')
36
+ }
37
+ }
38
+ }
39
+
40
+ export default btn
@@ -0,0 +1,13 @@
1
+ const cls = 'card-body'
2
+
3
+ async function cardBody () {
4
+ return class CardBody extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'div', cls })
9
+ }
10
+ }
11
+ }
12
+
13
+ export default cardBody
@@ -0,0 +1,17 @@
1
+ import { handler } from './card-header.js'
2
+ const cls = 'card-footer'
3
+
4
+ async function cardFooter () {
5
+ return class CardFooter extends this.baseFactory {
6
+ constructor (options) {
7
+ super(options)
8
+ this.selector = '.' + cls
9
+ }
10
+
11
+ async build () {
12
+ await handler.call(this, cls, this.params)
13
+ }
14
+ }
15
+ }
16
+
17
+ export default cardFooter
@@ -0,0 +1,13 @@
1
+ const cls = 'card-group'
2
+
3
+ async function cardGroup () {
4
+ return class CardGroup extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'div', cls })
9
+ }
10
+ }
11
+ }
12
+
13
+ export default cardGroup
@@ -0,0 +1,27 @@
1
+ import { levels } from '../method/after-build-tag/_lib.js'
2
+ const cls = 'card-header'
3
+
4
+ export async function handler (cls, params = {}) {
5
+ const headings = levels.map(l => `h${l}`)
6
+ const { isString } = this.plugin.app.bajo.lib._
7
+ const { $ } = this.component
8
+ const tag = isString(this.params.attr.tag) && headings.includes(this.params.attr.tag) ? this.params.attr.tag : 'div'
9
+ this.component.normalizeAttr(this.params, { tag, cls })
10
+ const tabs = $(`<div>${this.params.html}</div>`).find('.nav-tabs')
11
+ if (tabs.length > 0) this.params.html = tabs.addClass('card-header-tabs').parent().prop('outerHTML')
12
+ }
13
+
14
+ async function cardHeader () {
15
+ return class CardHeader extends this.baseFactory {
16
+ constructor (options) {
17
+ super(options)
18
+ this.selector = '.' + cls
19
+ }
20
+
21
+ async build () {
22
+ await handler.call(this, cls, this.params)
23
+ }
24
+ }
25
+ }
26
+
27
+ export default cardHeader
@@ -0,0 +1,14 @@
1
+ const cls = 'card-link'
2
+
3
+ async function cardLink () {
4
+ return class CardLink extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'a', cls })
9
+ if (!this.params.attr.href) this.params.attr.href = '#'
10
+ }
11
+ }
12
+ }
13
+
14
+ export default cardLink
@@ -0,0 +1,13 @@
1
+ const cls = 'card-subtitle'
2
+
3
+ async function cardSubtitle () {
4
+ return class CardSubtitle extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'h6', cls: [cls, 'mb-2', 'text-body-secondary'] })
9
+ }
10
+ }
11
+ }
12
+
13
+ export default cardSubtitle
@@ -0,0 +1,15 @@
1
+ const cls = 'card-text'
2
+
3
+ async function cardBody () {
4
+ return class CardBody extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ const { isString } = this.plugin.app.bajo.lib._
9
+ const tag = isString(this.params.attr.tag) ? this.params.attr.tag : 'p'
10
+ this.component.normalizeAttr(this.params, { tag, cls })
11
+ }
12
+ }
13
+ }
14
+
15
+ export default cardBody
@@ -0,0 +1,13 @@
1
+ const cls = 'card-title'
2
+
3
+ async function cardTitle () {
4
+ return class CardTitle extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'h5', cls })
9
+ }
10
+ }
11
+ }
12
+
13
+ export default cardTitle
@@ -0,0 +1,23 @@
1
+ const cls = 'card'
2
+
3
+ async function card () {
4
+ return class Card extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'div', cls })
9
+ }
10
+
11
+ async build () {
12
+ const { $ } = this.component
13
+ const children = $(`<div>${this.params.html}</div>`).children()
14
+ this.params.html = children.each(function (idx) {
15
+ if (idx === 0 && this.name === 'img') $(this).addClass('card-img-top')
16
+ if ($(this).hasClass('list-group')) $(this).addClass('list-group-flush')
17
+ if (idx === (children.length - 1) && this.name === 'img') $(this).addClass('card-img-bottom')
18
+ }).parent().html()
19
+ }
20
+ }
21
+ }
22
+
23
+ export default card
@@ -0,0 +1,25 @@
1
+ const cls = 'carousel-item'
2
+
3
+ async function carouselItem () {
4
+ return class CarouselItem extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'div', cls, dataBsInterval: this.params.attr.interval })
9
+ }
10
+
11
+ async build () {
12
+ const { isString } = this.plugin.app.bajo.lib._
13
+ if (isString(this.params.attr.caption)) {
14
+ const captions = ['<div class="carousel-caption d-none d-md-block">']
15
+ captions.push(`<h5>${this.params.attr.caption}</h5>`)
16
+ if (isString(this.params.attr.description)) captions.push(`<p>${this.params.attr.description}</p>`)
17
+ captions.push('</div>')
18
+ this.params.html += `\n${captions.join('\n')}`
19
+ }
20
+ delete this.params.attr.caption
21
+ }
22
+ }
23
+ }
24
+
25
+ export default carouselItem
@@ -0,0 +1,53 @@
1
+ const cls = 'carousel'
2
+
3
+ async function carousel () {
4
+ return class Carousel extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ const { isEmpty } = this.plugin.app.bajo.lib._
8
+ this.selector = '.' + cls
9
+ this.component.normalizeAttr(this.params, { tag: 'div', cls: [cls, 'slide'], autoId: true })
10
+ if (this.params.attr.fade) this.params.attr.class.push(`${cls}-fade`)
11
+ if (this.params.attr.noTouch) this.params.attr.dataBsTouch = false
12
+ if (this.params.attr.autoPlay) this.params.attr.dataBsRide = isEmpty(this.params.attr.autoPlay) ? cls : this.params.attr.autoPlay
13
+ this.params.html = `<div class="${cls}-inner">${this.params.html}</div>`
14
+ }
15
+
16
+ async build () {
17
+ const { attrToArray } = this.plugin.app.waibuMpa
18
+ const { $ } = this.component
19
+ let activeItem = 0
20
+ $(this.params.html).children().each(function (idx) {
21
+ const classes = attrToArray(this.attribs.class)
22
+ if (classes.includes('active')) activeItem = idx
23
+ })
24
+ this.params.html = $(this.params.html).children().each(function (idx) {
25
+ if (idx === activeItem) $(this).addClass('active')
26
+ $(this).find('img').addClass('d-block w-100')
27
+ }).parent().prop('outerHTML')
28
+
29
+ if (this.params.attr.indicator) {
30
+ const count = $(this.params.html).children().length
31
+ const btns = []
32
+ for (let i = 0; i < count; i++) {
33
+ btns.push(`<button type="button" data-bs-target="#${this.params.attr.id}" data-bs-slide-to="${i}"`)
34
+ if (i === activeItem) btns.push('class="active" aria-current="true"')
35
+ btns.push(`aria-label="Slide ${i + 1}"></button>`)
36
+ }
37
+ this.params.html = `<div class="${cls}-indicators">${btns.join(' ')}</div>\n${this.params.html}`
38
+ }
39
+ if (!this.params.attr.noNavigation) {
40
+ const btns = []
41
+ const dirs = { prev: 'Previous', next: 'Next' }
42
+ for (const dir in dirs) {
43
+ btns.push(`<button class="${cls}-control-${dir}" type="button" data-bs-target="#${this.params.attr.id}" data-bs-slide="${dir}">`)
44
+ btns.push(`<span class="${cls}-control-${dir}-icon" aria-hidden="true"></span>`)
45
+ btns.push(`<span class="visually-hidden">${this.component.req.t(dirs[dir])}</span></button>`)
46
+ }
47
+ this.params.html += '\n' + btns.join('\n')
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ export default carousel
@@ -0,0 +1,14 @@
1
+ const cls = 'collapse'
2
+
3
+ async function collapseItem () {
4
+ return class CollapseItem extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'div', cls, autoId: true })
9
+ if (this.params.attr.showOnStart) this.params.attr.class.push('show')
10
+ }
11
+ }
12
+ }
13
+
14
+ export default collapseItem
@@ -0,0 +1,58 @@
1
+ function collectAttr (group, item) {
2
+ const { merge } = this.plugin.app.bajo.lib._
3
+ return merge(group.trigger, {
4
+ 'data-bs-toggle': 'collapse',
5
+ 'data-bs-target': item ? ('#' + item.id) : `.multi-collapse.${this.params.attr.toggleAll}`
6
+ })
7
+ }
8
+
9
+ async function collapse () {
10
+ return class Collapse extends this.baseFactory {
11
+ async build () {
12
+ const { generateId } = this.plugin.app.bajo
13
+ const { merge, isString } = this.plugin.app.bajo.lib._
14
+ const { attrToArray, groupAttrs } = this.plugin.app.waibuMpa
15
+ const items = []
16
+ const { $ } = this.component
17
+ const me = this
18
+ if (!this.params.attr.trigger) this.params.attr.triggerColor = 'primary'
19
+ const group = groupAttrs(this.params.attr, ['trigger'])
20
+ this.params.attr = group._
21
+ if (this.params.attr.toggleAll) this.params.attr.toggleAll = generateId('alpha')
22
+ const contents = $(`<div>${this.params.html}</div>`).children().each(function () {
23
+ const classes = attrToArray(this.attribs.class)
24
+ const icon = $(this).find('i').prop('outerHTML') ?? ''
25
+ items.push({
26
+ id: this.attribs.id,
27
+ label: isString(this.attribs.caption) ? this.attribs.caption : this.attribs.id,
28
+ show: classes.includes('show'),
29
+ icon
30
+ })
31
+ $(this).find('i').remove()
32
+ $(this).removeAttr('caption')
33
+ if (me.params.attr.toggleAll) $(this).addClass('multi-collapse').addClass(me.params.attr.toggleAll)
34
+ }).parent().html()
35
+ const tag = isString(this.params.attr.tag) ? this.params.attr.tag : 'div'
36
+ this.component.normalizeAttr(this.params, { tag })
37
+ this.params.html = []
38
+ for (const item of items) {
39
+ const attr = collectAttr.call(this, group, item)
40
+ const html = `${item.label} ${item.icon}`
41
+ this.params.html.push(await this.component.buildTag({ tag: attr.tag ?? 'btn', attr, html }))
42
+ }
43
+ if (this.params.attr.toggleAll) {
44
+ const attr = collectAttr.call(this, group)
45
+ this.params.html.push(await this.component.buildTag({ tag: attr.tag ?? 'btn', attr, html: this.component.req.t('Toggle All') }))
46
+ }
47
+ this.params.html = this.params.html.join('\n')
48
+ if (this.params.attr.group && !this.params.attr.tag) {
49
+ this.params.attr.label = !isString(this.params.attr.group) ? this.component.req.t('Collapse') : this.params.attr.group
50
+ this.params.html = await this.component.buildTag(merge({}, this.params, { tag: 'btnGroup' }))
51
+ this.params.noTag = true
52
+ }
53
+ this.params.append = contents
54
+ }
55
+ }
56
+ }
57
+
58
+ export default collapse
@@ -0,0 +1,22 @@
1
+ import { breakpoints, parseSimple } from '../method/after-build-tag/_lib.js'
2
+ const cls = 'container'
3
+
4
+ async function container () {
5
+ return class Container extends this.baseFactory {
6
+ constructor (options) {
7
+ super(options)
8
+ this.selector = '.' + cls
9
+ this.component.normalizeAttr(this.params, { tag: 'div' })
10
+ }
11
+
12
+ async build () {
13
+ const { has, omit } = this.plugin.app.bajo.lib._
14
+ if (has(this.params.attr, 'responsive')) this.params.attr.class.push(`${cls}-fluid`)
15
+ else if (has(this.params.attr, 'breakpoint')) this.params.attr.class.push(parseSimple({ cls, value: this.params.attr.breakpoint, values: breakpoints }))
16
+ else this.params.attr.class.push(cls)
17
+ this.params.attr = omit(this.params.attr, ['responsive', 'breakpoint'])
18
+ }
19
+ }
20
+ }
21
+
22
+ export default container
@@ -0,0 +1,6 @@
1
+ async function drawerToolbar () {
2
+ return class DrawerToolbar extends this.baseFactory {
3
+ }
4
+ }
5
+
6
+ export default drawerToolbar
@@ -0,0 +1,59 @@
1
+ import { aligns, breakpoints, parseVariant, parseSimple } from '../method/after-build-tag/_lib.js'
2
+ const cls = 'offcanvas'
3
+
4
+ async function drawer () {
5
+ return class Drawer extends this.baseFactory {
6
+ constructor (options) {
7
+ super(options)
8
+ this.selector = '.' + cls
9
+ this.component.normalizeAttr(this.params, { tag: 'div', autoId: true, tabIndex: -1 })
10
+ }
11
+
12
+ async build () {
13
+ const { isString, omit, trim } = this.plugin.app.bajo.lib._
14
+ const { groupAttrs } = this.plugin.app.waibuMpa
15
+ const { $ } = this.component
16
+ const group = groupAttrs(this.params.attr, ['launch'])
17
+ this.params.attr.responsive = this.params.attr.responsive ?? true
18
+ this.params.attr.class.push(parseVariant.call(this, { cls, value: this.params.attr.responsive, values: breakpoints }))
19
+ this.params.attr = group._
20
+ if (isString(this.params.attr.idLabel)) this.params.attr.ariaLabelledby = this.params.attr.idLabel
21
+ this.params.attr.class.push(parseSimple.call(this, { cls, value: this.params.attr.side ?? 'end', values: aligns }))
22
+ if (this.params.attr.scroll) this.params.attr.dataBsScroll = 'true'
23
+ if (this.params.attr.noDismiss) this.params.attr.dataBsBackdrop = 'static'
24
+ const buttons = []
25
+ const html = []
26
+ $(`<div>${this.params.html}</div>`).children().each(function () {
27
+ if (this.name === 'drawer-toolbar') buttons.push(trim($(this).prop('innerHTML')))
28
+ else html.push($(this).prop('outerHTML'))
29
+ })
30
+ this.params.html = html.join('\n')
31
+ const header = []
32
+ if (isString(this.params.attr.title) || !this.params.attr.noDismiss) {
33
+ header.push('<div class="offcanvas-header justify-content-between">')
34
+ if (isString(this.params.attr.title)) header.push(`<h5 class="offcanvas-title"${isString(this.params.attr.idLabel) ? ` id="${this.params.attr.idLabel}"` : ''}>${this.params.attr.title}</h5>`)
35
+ header.push('<ul class="nav d-flex align-items-center">')
36
+ header.push(...buttons)
37
+ if (!this.params.attr.noDismiss) header.push(await this.component.buildTag({ tag: 'btnClose', attr: { dataBsDismiss: 'offcanvas' } }))
38
+ header.push('</ul></div>')
39
+ }
40
+ if (this.params.attr.divider) header.push('<hr class="m-0" />')
41
+ this.params.html = `${header.join('\n')}<div${this.params.attr.noPadding ? '' : ' class="offcanvas-body"'}>${this.params.html}</div>`
42
+ if (group.launch) {
43
+ group.launch.dataBsTarget = `#${this.params.attr.id}`
44
+ group.launch.dataBsToggle = 'offcanvas'
45
+ group.launch.ariaControls = this.params.attr.id
46
+ if (this.params.attr.responsive) group.launch.display = `type:none-${this.params.attr.responsive}`
47
+ const btnParams = {
48
+ tag: 'btn',
49
+ attr: group.launch,
50
+ html: group._.launch
51
+ }
52
+ this.params.prepend = await this.component.buildTag(btnParams)
53
+ }
54
+ this.params.attr = omit(this.params.attr, ['title', 'noPadding'])
55
+ }
56
+ }
57
+ }
58
+
59
+ export default drawer
@@ -0,0 +1,34 @@
1
+ const cls = 'dropdown-item'
2
+
3
+ async function dropdownItem () {
4
+ return class DropdownItem extends this.baseFactory {
5
+ constructor (options) {
6
+ super(options)
7
+ this.selector = '.' + cls
8
+ this.component.normalizeAttr(this.params, { tag: 'a' })
9
+ }
10
+
11
+ async build () {
12
+ const { $ } = this.component
13
+ if ($(this.params.html).children().length === 0 && !this.params.attr.href) this.params.attr.href = '#'
14
+ if (this.params.attr.divider) {
15
+ this.params.tag = 'hr'
16
+ this.params.attr.class.push('dropdown-divider')
17
+ this.params.selfClosing = true
18
+ return
19
+ }
20
+ if (this.params.attr.header) {
21
+ this.params.tag = 'h6'
22
+ this.params.attr.class.push('dropdown-header')
23
+ return
24
+ }
25
+ if (this.params.attr.disabled) {
26
+ this.params.attr.class.push('disabled')
27
+ delete this.params.attr.disabled
28
+ }
29
+ this.params.attr.class.push(cls)
30
+ }
31
+ }
32
+ }
33
+
34
+ export default dropdownItem
@@ -0,0 +1,121 @@
1
+ import { dirs, breakpoints, parseSimple, parseVariant } from '../method/after-build-tag/_lib.js'
2
+
3
+ const cls = 'dropdown'
4
+ const variants = ['center']
5
+ export const autoCloses = ['true', 'false', 'inside', 'outside']
6
+
7
+ export async function buildMenu (params = {}) { // scope: component
8
+ const { numUnit } = this.plugin.app.bajo
9
+ const { isString } = this.plugin.app.bajo.lib._
10
+ const $ = this.$
11
+ let menuHtml = params.html
12
+ let style = params.attr.menuOnly ? 'display:block;' : ''
13
+ if (isString(params.attr.menuMax)) {
14
+ const max = parseInt(params.attr.menuMax)
15
+ if (max > 0) {
16
+ const items = []
17
+ $(`<div>${params.html}</div>`).children().each(function () {
18
+ items.push($(this).prop('outerHTML'))
19
+ })
20
+ const maxCols = Math.floor(items.length / max)
21
+ let els = ''
22
+ for (let i = 0; i < maxCols; i++) {
23
+ els += '<c:grid-col>'
24
+ for (let j = 0; j < parseInt(params.attr.menuMax); j++) {
25
+ els += items[max * i + j]
26
+ }
27
+ els += '</c:grid-col>'
28
+ }
29
+ menuHtml = await this.buildSentence(`<c:grid-row gutter="0">${els}</c:grid-row>`)
30
+ style = `min-width:${maxCols * 10}rem;`
31
+ }
32
+ } else if (params.attr.menuTag) {
33
+ const items = []
34
+ $(`<div>${params.html}</div>`).children().each(function () {
35
+ const children = $(this).children('form,div,p')
36
+ if (children.length > 0) {
37
+ children.each(function () {
38
+ items.push($(this).parent().html())
39
+ })
40
+ } else items.push($(this).prop('outerHTML'))
41
+ })
42
+ menuHtml = items.join('\n')
43
+ }
44
+
45
+ if (params.attr.menuScroll) {
46
+ const minHeight = isString(params.attr.menuScroll) ? numUnit(params.attr.menuScroll, 'px') : '80px'
47
+ style += `overflow:hidden;overflow-y:auto;max-height:calc(100vh - ${minHeight});`
48
+ }
49
+ const args = {
50
+ tag: isString(params.attr.menuTag) ? params.attr.menuTag : 'div',
51
+ attr: {
52
+ class: [
53
+ 'dropdown-menu',
54
+ parseVariant.call(this, { cls: 'dropdown-menu', value: params.attr.dir, values: dirs, variants: breakpoints, prepend: true })
55
+ ],
56
+ style
57
+ },
58
+ html: menuHtml
59
+ }
60
+ if (params.attr.id) args.attr.id = params.attr.id + '-menu'
61
+ return await this.buildTag(args)
62
+ }
63
+
64
+ async function dropdown () {
65
+ return class Dropdown extends this.baseFactory {
66
+ constructor (options) {
67
+ super(options)
68
+ const { isString } = this.plugin.app.bajo.lib._
69
+ this.selector = '.' + cls
70
+ const tag = isString(this.params.attr.tag) ? this.params.attr.tag : 'div'
71
+ this.component.normalizeAttr(this.params, { tag })
72
+ }
73
+
74
+ async build () {
75
+ const { merge, cloneDeep, omit } = this.plugin.app.bajo.lib._
76
+ const { groupAttrs } = this.plugin.app.waibuMpa
77
+ const alpinejs = this.plugin.app.waibuAlpinejs
78
+ const [dir, variant] = (this.params.attr.dir ?? 'down').split('-')
79
+ const xcls = ['drop' + parseSimple.call(this, { value: dir, values: dirs })]
80
+ if (variants.includes(variant)) xcls.push(`${xcls[0]}-${variant}`)
81
+ this.params.attr.class.push(...xcls)
82
+ const group = groupAttrs(this.params.attr, ['trigger'])
83
+ this.params.attr = group._
84
+ let button = ''
85
+ if (this.params.attr.menuOnly) this.params.attr.menuTag = 'div'
86
+ const btnParams = {
87
+ attr: merge(group.trigger, {
88
+ class: this.params.attr.noCaret ? [] : ['dropdown-toggle'],
89
+ type: 'button',
90
+ dataBsToggle: 'dropdown',
91
+ ariaExpanded: false
92
+ }),
93
+ html: this.params.attr.split ? '<span class="visually-hidden">Toggle Dropdown</span>' : this.params.attr.content
94
+ }
95
+ if (this.params.attr.offset) btnParams.attr['data-bs-offset'] = this.params.attr.offset
96
+ if (this.params.attr.autoClose && autoCloses.includes(this.params.attr.autoClose)) btnParams.attr.dataBsAutoClose = this.params.attr.autoClose
97
+ if (this.params.attr.split) {
98
+ btnParams.attr.class.push('dropdown-toggle-split')
99
+ const splitParams = cloneDeep(btnParams)
100
+ if (btnParams.attr.id) btnParams.attr.id += '-split'
101
+ splitParams.tag = 'btn'
102
+ splitParams.attr = omit(splitParams.attr, ['class', 'dataBsToggle', 'ariaExpanded', 'dataBsAutoClose', 'dataBsOffset'])
103
+ if (alpinejs) btnParams.attr = alpinejs.stripAttrKeys(btnParams.attr)
104
+ splitParams.html = this.params.attr.content
105
+ button = await this.component.buildTag(splitParams)
106
+ // xcls.shift()
107
+ this.params.attr.class = ['btn-group', ...xcls]
108
+ }
109
+ btnParams.tag = 'btn'
110
+ const btn = await this.component.buildTag(btnParams)
111
+ const menu = await buildMenu.call(this.component, this.params)
112
+ if (this.params.attr.menuOnly) {
113
+ this.params.html = menu
114
+ this.params.noTag = true
115
+ } else this.params.html = [button, btn, menu].join('\n')
116
+ this.params.attr = omit(this.params.attr, ['noCaret'])
117
+ }
118
+ }
119
+ }
120
+
121
+ export default dropdown