waibu-bootstrap 2.2.2 → 2.3.0
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.
- package/extend/waibuMpa/theme/component/method/after-build-tag/rounded.js +2 -1
- package/extend/waibuMpa/theme/component/widget/_lib.js +1 -1
- package/extend/waibuMpa/theme/component/widget/form-select-country.js +1 -4
- package/extend/waibuMpa/theme/component/widget/form-select-ext.js +42 -48
- package/extend/waibuMpa/theme/component/widget/nav-item.js +3 -6
- package/extend/waibuStatic/asset/css/widget.css +34 -0
- package/package.json +1 -1
- package/wiki/CHANGES.md +11 -0
|
@@ -13,8 +13,9 @@ function rounded ({ key, params }) {
|
|
|
13
13
|
const [item, val] = attr.split(':')
|
|
14
14
|
if (item === 'type') hasType = true
|
|
15
15
|
for (const value of uniq((val ?? '').split(' '))) {
|
|
16
|
+
const [main, alt] = value.split('-')
|
|
16
17
|
switch (item) {
|
|
17
|
-
case 'type': if (types.includes(
|
|
18
|
+
case 'type': if (types.includes(main)) params.attr.class.push(`rounded${main === 'all' ? '' : ('-' + main)}${alt ? ('-' + alt) : ''}`); break
|
|
18
19
|
case 'width': params.attr.class.push(parseSimple.call(this, { cls: 'rounded', value, values: widths })); break
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -156,7 +156,7 @@ export async function buildFormSelect (group, params) {
|
|
|
156
156
|
html = items.join('\n')
|
|
157
157
|
}
|
|
158
158
|
attr = omit(attr, ['size', 'type', 'options', 'value'])
|
|
159
|
-
return await this.component.buildTag({ tag: 'select', attr, html })
|
|
159
|
+
return await this.component.buildTag({ tag: attr.tag ?? 'select', attr, html })
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
export async function buildFormRange (group, params) {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css, scripts } from './form-select-ext.js'
|
|
2
2
|
|
|
3
3
|
async function formSelectCountry () {
|
|
4
4
|
return class FormSelectCountry extends this.app.baseClass.MpaWidget {
|
|
5
5
|
static css = [...super.css, css]
|
|
6
|
-
|
|
7
6
|
static scripts = [...super.scripts, scripts]
|
|
8
7
|
|
|
9
|
-
static inlineCss = inlineCss
|
|
10
|
-
|
|
11
8
|
constructor (options) {
|
|
12
9
|
super(options)
|
|
13
10
|
this.params.noTag = true
|
|
@@ -1,47 +1,16 @@
|
|
|
1
1
|
import { buildFormSelect } from './_lib.js'
|
|
2
2
|
import { build } from './form-input.js'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
.ts-control {
|
|
10
|
-
padding-top: 0px;
|
|
11
|
-
}
|
|
12
|
-
.ts-wrapper {
|
|
13
|
-
margin-left: calc(var(--bs-border-width) * -1) !important;
|
|
14
|
-
border-top-left-radius: var(--bs-border-radius) !important;
|
|
15
|
-
border-bottom-left-radius: var(--bs-border-radius) !important;
|
|
16
|
-
white-space: nowrap !important;
|
|
17
|
-
}
|
|
18
|
-
.ts-control, .ts-control input, .ts-dropdown {
|
|
19
|
-
color: inherit;
|
|
20
|
-
}
|
|
21
|
-
.form-floating > .ts-wrapper {
|
|
22
|
-
padding-top: 1.625rem !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.ts-wrapper.focus {
|
|
26
|
-
border-color: #86b7fe;
|
|
27
|
-
outline: 0;
|
|
28
|
-
box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.focus .ts-control {
|
|
32
|
-
box-shadow: none;
|
|
33
|
-
border: none;
|
|
34
|
-
box-shadow: none;
|
|
35
|
-
}
|
|
36
|
-
`
|
|
37
|
-
export const css = 'waibuExtra.virtual:/tom-select/css/tom-select.bootstrap5.min.css'
|
|
4
|
+
export const css = [
|
|
5
|
+
'waibuExtra.virtual:/tom-select/css/tom-select.bootstrap5.min.css',
|
|
6
|
+
'waibuBootstrap.asset:/css/widget.css'
|
|
7
|
+
]
|
|
38
8
|
export const scripts = 'waibuExtra.virtual:/tom-select/js/tom-select.complete.min.js'
|
|
39
9
|
|
|
40
10
|
async function formSelectExt () {
|
|
41
11
|
return class FormSelectExt extends this.app.baseClass.MpaWidget {
|
|
42
12
|
static css = [...super.css, css]
|
|
43
13
|
static scripts = [...super.scripts, scripts]
|
|
44
|
-
static inlineCss = inlineCss
|
|
45
14
|
|
|
46
15
|
build = async () => {
|
|
47
16
|
const { generateId } = this.app.lib.aneka
|
|
@@ -54,14 +23,13 @@ async function formSelectExt () {
|
|
|
54
23
|
const xref = this.params.attr['x-ref'] ?? 'select'
|
|
55
24
|
this.params.attr.id = this.params.attr.id ?? generateId('alpha')
|
|
56
25
|
this.params.attr['x-ref'] = xref
|
|
57
|
-
|
|
58
|
-
instance: null
|
|
59
|
-
}`
|
|
26
|
+
const xData = ['instance: null', 'value: null']
|
|
60
27
|
const plugins = ['drag_drop']
|
|
61
28
|
if (!this.params.attr.noDropdownInput) plugins.push('dropdown_input')
|
|
62
29
|
if (this.params.attr.removeBtn) plugins.push('remove_button')
|
|
63
30
|
if (this.params.attr.clearBtn) plugins.push('clear_button')
|
|
64
31
|
if (this.params.attr.optgroupColumns) plugins.push('optgroup_columns')
|
|
32
|
+
if (this.params.attr.noCaret) this.params.attr.class.push('no-caret') // TODO: no caret remove caret on ALL instances, need to make it instance specific
|
|
65
33
|
let options = []
|
|
66
34
|
if (this.params.attr.options) {
|
|
67
35
|
try {
|
|
@@ -92,7 +60,7 @@ async function formSelectExt () {
|
|
|
92
60
|
if (group.remote.apiKey === true) fetchOpts.headers.Authorization = `Bearer ${apiKey}` // TODO: get it from wmpa
|
|
93
61
|
else fetchOpts.headers.Authorization = `Bearer ${group.remote.apiKey}`
|
|
94
62
|
}
|
|
95
|
-
opts =
|
|
63
|
+
opts = opts.slice(0, -1) + `,
|
|
96
64
|
searchField: '${group.remote.searchField}',
|
|
97
65
|
labelField: '${group.remote.labelField}',
|
|
98
66
|
valueField: '${group.remote.valueField}',
|
|
@@ -117,26 +85,52 @@ async function formSelectExt () {
|
|
|
117
85
|
}
|
|
118
86
|
}`
|
|
119
87
|
}
|
|
120
|
-
|
|
121
|
-
this.params.attr['@load.window'] = `
|
|
88
|
+
let text = `onLoad () {
|
|
122
89
|
const opts = ${opts}
|
|
123
|
-
instance = new TomSelect($refs.${xref}, opts)
|
|
90
|
+
this.instance = new TomSelect($refs.${xref}, opts)
|
|
124
91
|
const val = $refs.${xref}.dataset.value
|
|
92
|
+
if (!_.isEmpty(val)) {
|
|
93
|
+
this.value = val.split('|')
|
|
94
|
+
}
|
|
125
95
|
`
|
|
96
|
+
if (this.params.attr.valueStore) {
|
|
97
|
+
const [store, key] = this.params.attr.valueStore.split(':')
|
|
98
|
+
text += `
|
|
99
|
+
this.value = Alpine.store('${store}').${key}
|
|
100
|
+
this.instance.on('change', value => {
|
|
101
|
+
this.value = _.cloneDeep(value)
|
|
102
|
+
Alpine.store('${store}').${key} = this.value
|
|
103
|
+
})
|
|
104
|
+
`
|
|
105
|
+
}
|
|
126
106
|
if (group.remote) {
|
|
127
|
-
|
|
128
|
-
if (!_.isEmpty(
|
|
129
|
-
|
|
107
|
+
text += `
|
|
108
|
+
if (!_.isEmpty(this.value)) {
|
|
109
|
+
if (!_.isArray(this.value)) this.value = [this.value]
|
|
110
|
+
let query = '${group.remote.valueField}:['
|
|
111
|
+
let q = ''
|
|
112
|
+
for (const v of this.value) {
|
|
113
|
+
q += ',' + v
|
|
114
|
+
}
|
|
115
|
+
query += q.slice(1) + ']'
|
|
116
|
+
fetch('${group.remote.url}?query=' + query, ${jsonStringify(fetchOpts, true)})
|
|
130
117
|
.then(resp => resp.json())
|
|
131
118
|
.then(json => {
|
|
132
119
|
if (json.data.length === 0) return
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
for (const d of json.data) {
|
|
121
|
+
const opt = _.pick(d, ['${group.remote.valueField}', '${group.remote.labelField}'])
|
|
122
|
+
this.instance.addOption(opt)
|
|
123
|
+
}
|
|
124
|
+
this.instance.setValue(json.data.map(item => item.${group.remote.valueField}))
|
|
136
125
|
})
|
|
137
126
|
}
|
|
138
127
|
`
|
|
139
128
|
}
|
|
129
|
+
text += '}'
|
|
130
|
+
xData.push(text)
|
|
131
|
+
this.params.attr['x-data'] = `{ ${xData.join(',\n')} }`
|
|
132
|
+
// this.params.attr['@load.window'] = 'onLoad()'
|
|
133
|
+
this.params.attr['x-init'] = 'onLoad()'
|
|
140
134
|
this.params.attr.options = options
|
|
141
135
|
this.params.attr = omit(this.params.attr, ['noDropdownInput', 'removeBtn', 'clearBtn', 'c-opts', 'remoteUrl', 'remoteSearchField', 'remoteLabelField', 'remoteValueField'])
|
|
142
136
|
await build.call(this, buildFormSelect, this.params)
|
|
@@ -25,13 +25,10 @@ async function navItem () {
|
|
|
25
25
|
!this.params.attr.href.startsWith('http://') &&
|
|
26
26
|
!this.params.attr.href.startsWith('https://')) {
|
|
27
27
|
const route = findRoute(this.params.attr.ohref)
|
|
28
|
-
if (
|
|
29
|
-
this.params.
|
|
30
|
-
this.params.
|
|
31
|
-
return
|
|
28
|
+
if (route) {
|
|
29
|
+
const { ns, subNs, subSubNs, realFullPath } = breakNsPath(this.params.attr.ohref)
|
|
30
|
+
this.params.attr.href = routePath(buildNsPath({ ns, subNs, subSubNs, path: realFullPath }))
|
|
32
31
|
}
|
|
33
|
-
const { ns, subNs, subSubNs, realFullPath } = breakNsPath(this.params.attr.ohref)
|
|
34
|
-
this.params.attr.href = routePath(buildNsPath({ ns, subNs, subSubNs, path: realFullPath }))
|
|
35
32
|
}
|
|
36
33
|
if (group.dropdown) {
|
|
37
34
|
this.params.attr.class.push('dropdown-toggle')
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.ts-dropdown {
|
|
2
|
+
min-width: 242px;
|
|
3
|
+
}
|
|
4
|
+
.ts-control {
|
|
5
|
+
padding-top: 0px;
|
|
6
|
+
}
|
|
7
|
+
.ts-wrapper {
|
|
8
|
+
margin-left: calc(var(--bs-border-width) * -1) !important;
|
|
9
|
+
border-top-left-radius: var(--bs-border-radius) !important;
|
|
10
|
+
border-bottom-left-radius: var(--bs-border-radius) !important;
|
|
11
|
+
white-space: nowrap !important;
|
|
12
|
+
}
|
|
13
|
+
.ts-control, .ts-control input, .ts-dropdown {
|
|
14
|
+
color: inherit;
|
|
15
|
+
}
|
|
16
|
+
.form-floating > .ts-wrapper {
|
|
17
|
+
padding-top: 1.625rem !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ts-wrapper.focus {
|
|
21
|
+
border-color: #86b7fe;
|
|
22
|
+
outline: 0;
|
|
23
|
+
box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.focus .ts-control {
|
|
27
|
+
box-shadow: none;
|
|
28
|
+
border: none;
|
|
29
|
+
box-shadow: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.form-select.no-caret {
|
|
33
|
+
--bs-form-select-bg-img: none !important;
|
|
34
|
+
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-02-15
|
|
4
|
+
|
|
5
|
+
- [2.3.0] Add capability to use custom tag on ```select```
|
|
6
|
+
- [2.3.0] Now you can hide caret on ```<c:form-select-ext />``` with ```no-caret``` attribute
|
|
7
|
+
- [2.3.0] Add ```value-store="name:key"``` to read/write value to Alpine's store
|
|
8
|
+
|
|
9
|
+
## 2026-02-11
|
|
10
|
+
|
|
11
|
+
- [2.2.3] Bug fix on widget attribute ```rounded```
|
|
12
|
+
- [2.2.3] Bug fix on widget ```<c:nav-item />```
|
|
13
|
+
|
|
3
14
|
## 2026-02-09
|
|
4
15
|
|
|
5
16
|
- [2.2.0] Start using simplified ```webAppCtx```
|