IMPR: Select2 is optional now

This commit is contained in:
Tony Air 2021-01-15 01:13:57 +07:00
parent 88789fe5b1
commit 4deb6efa5d
5 changed files with 296 additions and 373 deletions

152
dist/records.json vendored
View File

@ -72,158 +72,6 @@
831
]
},
"mini-css-extract-plugin /mnt/data/srv/dist/repositories/webpack-bootstrap-ui-kit/node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/.pnpm/@a2nt/meta-lightbox@2.7.1/node_modules/@a2nt/meta-lightbox/src/scss/app.scss": [
{
"chunks": {
"byName": {
"mini-css-extract-plugin": 323
},
"bySource": {
"0 mini-css-extract-plugin": 323
},
"usedIds": [
323
]
},
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/runtime/api.js": 254,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/.pnpm/@a2nt/meta-lightbox@2.7.1/node_modules/@a2nt/meta-lightbox/src/scss/app.scss": 953
},
"usedIds": [
254,
953
]
}
}
],
"mini-css-extract-plugin /mnt/data/srv/dist/repositories/webpack-bootstrap-ui-kit/node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/_components/_ui.map.scss": [
{
"chunks": {
"byName": {
"mini-css-extract-plugin": 323
},
"bySource": {
"0 mini-css-extract-plugin": 323
},
"usedIds": [
323
]
},
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/runtime/api.js": 254,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/_components/_ui.map.scss": 140
},
"usedIds": [
140,
254
]
}
}
],
"mini-css-extract-plugin /mnt/data/srv/dist/repositories/webpack-bootstrap-ui-kit/node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/app.scss": [
{
"chunks": {
"byName": {
"mini-css-extract-plugin": 323
},
"bySource": {
"0 mini-css-extract-plugin": 323
},
"usedIds": [
323
]
},
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/runtime/api.js": 254,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/app.scss": 200,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/select2@4.0.13/node_modules/select2/dist/css/select2.css": 282
},
"usedIds": [
200,
254,
282
]
}
}
],
"mini-css-extract-plugin /mnt/data/srv/dist/repositories/webpack-bootstrap-ui-kit/node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/types/cms.scss": [
{
"chunks": {
"byName": {
"mini-css-extract-plugin": 323
},
"bySource": {
"0 mini-css-extract-plugin": 323
},
"usedIds": [
323
]
},
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/runtime/api.js": 254,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/types/cms.scss": 209
},
"usedIds": [
209,
254
]
}
}
],
"mini-css-extract-plugin /mnt/data/srv/dist/repositories/webpack-bootstrap-ui-kit/node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/types/editor.scss": [
{
"chunks": {
"byName": {
"mini-css-extract-plugin": 323
},
"bySource": {
"0 mini-css-extract-plugin": 323
},
"usedIds": [
323
]
},
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/runtime/api.js": 254,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/types/editor.scss": 98
},
"usedIds": [
98,
254
]
}
}
],
"mini-css-extract-plugin /mnt/data/srv/dist/repositories/webpack-bootstrap-ui-kit/node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/types/order.scss": [
{
"chunks": {
"byName": {
"mini-css-extract-plugin": 323
},
"bySource": {
"0 mini-css-extract-plugin": 323
},
"usedIds": [
323
]
},
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/runtime/api.js": 254,
"./node_modules/.pnpm/css-loader@5.0.1_webpack@5.11.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/.pnpm/resolve-url-loader@3.1.2/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@10.1.0_node-sass@5.0.0+webpack@5.11.1/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./src/scss/types/order.scss": 558
},
"usedIds": [
254,
558
]
}
}
],
"modules": {
"byIdentifier": {
"./node_modules/.pnpm/babel-loader@8.2.2_3ea652ad0eeb1c91bd4bd943f4964921/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/bootstrap@4.5.3_jquery@3.5.1+popper.js@1.16.1/node_modules/bootstrap/js/dist/alert.js": 6,

View File

@ -2,13 +2,6 @@
import $ from 'jquery';
//import 'bootstrap-select/dist/js/bootstrap-select';
//$.fn.selectpicker.Constructor.BootstrapVersion = '4';
import select2 from 'select2/dist/js/select2.js';
//import Inputmask from 'inputmask';
//import select2 from 'jquery.inputmask/dist/jquery.inputmask.bundle';
import Events from '../_events';
import SpinnerUI from './_ui.spinner';
import FormFieldUI from './_ui.form.fields';
@ -41,14 +34,6 @@ const FormBasics = (($) => {
new FormFieldUI(el);
});
const $selectFields = $el
.find('select:not([readonly])')
.not('.no-select2');
$selectFields.each((i, el) => {
$(el).select2();
});
$fields.each((e, el) => {
const $el = $(el);
@ -118,17 +103,6 @@ const FormBasics = (($) => {
const ui = this;
const $el = $(ui._el);
const $selectFields = $el
.find('select:not([readonly])')
.not('.no-select2');
$selectFields.each((i, el) => {
const $el = $(el);
if ($el.hasClass('select2-hidden-accessible')) {
$el.select2('destroy');
}
});
$.removeData(ui._el, DATA_KEY);
ui._el = null;
$el.removeClass(`${NAME}-active`);

View File

@ -0,0 +1,97 @@
'use strict';
import $ from 'jquery';
import select2 from 'select2/dist/js/select2.js';
import Events from '../_events';
const FormSelect2 = (($) => {
// Constants
const NAME = 'jsFormSelect2';
const DATA_KEY = NAME;
const $Html = $('html, body');
const W = window;
const D = document;
class FormSelect2 {
constructor(el) {
const ui = this;
const $el = $(el);
ui._el = el;
ui.dispose();
console.log(`${NAME}: init`);
$el.data(DATA_KEY, this);
const $fields = $el.find(Events.FORM_FIELDS);
const $selectFields = $el
.find('select:not([readonly])')
.not('.no-select2');
$selectFields.each((i, el) => {
$(el).select2();
});
$el.addClass(`${NAME}-active`);
$el.trigger(Events.FORM_INIT_BASICS);
}
// Public methods
dispose() {
console.log(`${NAME}: dispose`);
const ui = this;
const $el = $(ui._el);
const $selectFields = $el
.find('select:not([readonly])')
.not('.no-select2');
$selectFields.each((i, el) => {
const $el = $(el);
if ($el.hasClass('select2-hidden-accessible')) {
$el.select2('destroy');
}
});
$.removeData(ui._el, DATA_KEY);
ui._el = null;
$el.removeClass(`${NAME}-active`);
}
static _jQueryInterface() {
return this.each(() => {
// attach functionality to el
const $el = $(this);
let data = $el.data(DATA_KEY);
if (!data) {
data = new FormSelect2(this);
$el.data(DATA_KEY, data);
}
});
}
}
// jQuery interface
$.fn[NAME] = FormSelect2._jQueryInterface;
$.fn[NAME].Constructor = FormSelect2;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return FormSelect2._jQueryInterface;
};
const init = () => {
$('form').jsFormSelect2();
};
// auto-apply
$(W).on(`${NAME}.init ${Events.AJAX} ${Events.LOADED}`, () => {
init();
});
return FormSelect2;
})($);
export default FormSelect2;

View File

@ -77,6 +77,8 @@ import '@a2nt/meta-lightbox/src/js/app';
// Map UI
//import MapApi from './_components/_ui.map.api';
//import FormSelect2 from './_components/_ui.form.select2';
import './_main';
import './_layout';

View File

@ -268,10 +268,12 @@ textarea,
@keyframes expand {
from {
max-height: 0;
overflow: hidden;
}
to {
max-height: 500rem;
max-height: 200vh;
overflow: auto;
}
}