countries selection fixed
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
/* WMS Select2 professional dark theme. */
|
||||
/* WMS Select2 professional dark theme.
|
||||
Imported after Select2's own CSS so it overrides the vendor defaults. */
|
||||
|
||||
.wms-select2-field {
|
||||
min-width: 0;
|
||||
.select2-hidden-accessible {
|
||||
position: absolute !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
overflow: hidden !important;
|
||||
clip: rect(0 0 0 0) !important;
|
||||
white-space: nowrap !important;
|
||||
border: 0 !important;
|
||||
padding: 0 !important;
|
||||
margin: -1px !important;
|
||||
}
|
||||
|
||||
.wms-select2-field .select2-container,
|
||||
@@ -14,19 +23,6 @@
|
||||
margin-top: 0.5rem !important;
|
||||
}
|
||||
|
||||
.wms-select2-field select[data-wms-select2].select2-hidden-accessible,
|
||||
.wms-select2-field select.wms-select2-control.select2-hidden-accessible {
|
||||
position: absolute !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
overflow: hidden !important;
|
||||
clip: rect(0 0 0 0) !important;
|
||||
white-space: nowrap !important;
|
||||
border: 0 !important;
|
||||
padding: 0 !important;
|
||||
margin: -1px !important;
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-selection--single {
|
||||
position: relative !important;
|
||||
height: 3rem !important;
|
||||
@@ -35,6 +31,8 @@
|
||||
border-radius: 0.75rem !important;
|
||||
background: rgb(9 9 11) !important;
|
||||
box-shadow: 0 1px 2px rgb(0 0 0 / 0.2) !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
outline: none !important;
|
||||
transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease !important;
|
||||
}
|
||||
@@ -46,7 +44,7 @@
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-selection--single .select2-selection__rendered {
|
||||
height: 100% !important;
|
||||
width: 100% !important;
|
||||
padding: 0 2.75rem 0 1rem !important;
|
||||
color: rgb(244 244 245) !important;
|
||||
font-size: 0.875rem !important;
|
||||
@@ -59,13 +57,12 @@
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
|
||||
/* Keep the Select2 arrow as a plain chevron, not a boxed button. */
|
||||
.select2-container--wms .select2-selection--single .select2-selection__arrow {
|
||||
position: absolute !important;
|
||||
top: 0 !important;
|
||||
right: 0.875rem !important;
|
||||
width: 1.25rem !important;
|
||||
height: 3rem !important;
|
||||
width: 1rem !important;
|
||||
height: 100% !important;
|
||||
background: transparent !important;
|
||||
border: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
@@ -73,39 +70,35 @@
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-selection--single .select2-selection__arrow b {
|
||||
position: absolute !important;
|
||||
left: 50% !important;
|
||||
top: 50% !important;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
margin-left: -4px !important;
|
||||
margin-top: -2px !important;
|
||||
border-color: rgb(212 212 216) transparent transparent transparent !important;
|
||||
border-style: solid !important;
|
||||
border-width: 5px 4px 0 4px !important;
|
||||
border-color: rgb(212 212 216) transparent transparent transparent !important;
|
||||
height: 0 !important;
|
||||
left: 50% !important;
|
||||
margin-left: -4px !important;
|
||||
margin-top: -2px !important;
|
||||
position: absolute !important;
|
||||
top: 50% !important;
|
||||
width: 0 !important;
|
||||
}
|
||||
|
||||
.select2-container--wms.select2-container--open .select2-selection--single .select2-selection__arrow b {
|
||||
margin-top: -3px !important;
|
||||
border-width: 0 4px 5px 4px !important;
|
||||
border-color: transparent transparent rgb(212 212 216) transparent !important;
|
||||
border-width: 0 4px 5px 4px !important;
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-selection--single .select2-selection__clear {
|
||||
position: absolute !important;
|
||||
right: 2.1rem !important;
|
||||
top: 0 !important;
|
||||
right: 2.25rem !important;
|
||||
height: 3rem !important;
|
||||
width: 1.25rem !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
height: 100% !important;
|
||||
width: 1rem !important;
|
||||
background: transparent !important;
|
||||
border: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
box-shadow: none !important;
|
||||
color: rgb(161 161 170) !important;
|
||||
font-size: 1.1rem !important;
|
||||
font-weight: 700 !important;
|
||||
font-size: 1.125rem !important;
|
||||
line-height: 3rem !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
@@ -124,26 +117,21 @@
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-search--dropdown {
|
||||
padding: 0.625rem !important;
|
||||
padding: 0.75rem !important;
|
||||
background: rgb(24 24 27) !important;
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-search--dropdown .select2-search__field {
|
||||
height: 2.5rem !important;
|
||||
height: 2.75rem !important;
|
||||
border: 1px solid rgb(63 63 70) !important;
|
||||
border-radius: 0.75rem !important;
|
||||
background: rgb(9 9 11) !important;
|
||||
color: rgb(244 244 245) !important;
|
||||
padding: 0 0.875rem !important;
|
||||
font-size: 0.875rem !important;
|
||||
font-weight: 500 !important;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-search--dropdown .select2-search__field::placeholder {
|
||||
color: rgb(161 161 170) !important;
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-search--dropdown .select2-search__field:focus {
|
||||
border-color: rgb(59 130 246) !important;
|
||||
box-shadow: 0 0 0 3px rgb(59 130 246 / 0.22) !important;
|
||||
@@ -155,7 +143,7 @@
|
||||
}
|
||||
|
||||
.select2-container--wms .select2-results__option {
|
||||
padding: 0.7rem 1rem !important;
|
||||
padding: 0.75rem 1rem !important;
|
||||
color: rgb(244 244 245) !important;
|
||||
font-size: 0.875rem !important;
|
||||
font-weight: 500 !important;
|
||||
@@ -176,7 +164,7 @@
|
||||
color: rgb(161 161 170) !important;
|
||||
}
|
||||
|
||||
/* Fallback styling before Select2 initialises, matching WMS inputs. */
|
||||
/* Matching fallback before Select2 initialises. */
|
||||
.wms-select2-field > select[data-wms-select2],
|
||||
.wms-select2-field > select.wms-select2-control {
|
||||
margin-top: 0.5rem;
|
||||
|
||||
+45
-28
@@ -143,9 +143,19 @@ function renderWmsCharts() {
|
||||
|
||||
|
||||
function livewireComponentFor(element) {
|
||||
const componentRoot = element.closest('[wire\:id]');
|
||||
if (!element || !window.Livewire) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!componentRoot || !window.Livewire) {
|
||||
let componentRoot = null;
|
||||
|
||||
try {
|
||||
componentRoot = element.closest('[wire\\:id]');
|
||||
} catch (error) {
|
||||
componentRoot = null;
|
||||
}
|
||||
|
||||
if (!componentRoot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -167,25 +177,32 @@ function setLivewireProperty(element, model, value) {
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function initialiseSelect2() {
|
||||
function initialiseSelect2(root = document) {
|
||||
if (!window.jQuery?.fn?.select2) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('[data-helpdesk-select2], [data-wms-select2], .wms-select2-control').each(function () {
|
||||
const $select = $(this);
|
||||
const $root = root instanceof window.Element ? $(root) : $(document);
|
||||
const selector = 'select[data-helpdesk-select2], select[data-wms-select2], select.wms-select2-control';
|
||||
|
||||
$root.find(selector).add($root.is(selector) ? $root : $()).each(function () {
|
||||
const select = this;
|
||||
const $select = $(select);
|
||||
|
||||
if ($select.hasClass('select2-hidden-accessible')) {
|
||||
$select.select2('destroy');
|
||||
return;
|
||||
}
|
||||
|
||||
const isMultiple = $select.prop('multiple');
|
||||
|
||||
const placeholder =
|
||||
$select.data('placeholder') ||
|
||||
$select.find('option[value=""]').first().text() ||
|
||||
(isMultiple ? 'Select options' : 'Select option');
|
||||
|
||||
if (!isMultiple && $select.find('option[value=""]').length === 0) {
|
||||
$select.prepend(new Option('', '', false, false));
|
||||
}
|
||||
|
||||
$select.select2({
|
||||
theme: 'wms',
|
||||
width: '100%',
|
||||
@@ -201,26 +218,9 @@ function initialiseSelect2() {
|
||||
},
|
||||
});
|
||||
|
||||
$select.off('select2:open.wms-select2');
|
||||
$select.on('select2:open.wms-select2', function () {
|
||||
const searchField = document.querySelector('.select2-container--open .select2-search__field');
|
||||
|
||||
if (searchField) {
|
||||
searchField.placeholder = placeholder;
|
||||
searchField.focus();
|
||||
}
|
||||
});
|
||||
|
||||
$select.off('change.select2-livewire');
|
||||
|
||||
$select.on('change.select2-livewire', function () {
|
||||
$select.off('change.wms-select2-livewire');
|
||||
$select.on('change.wms-select2-livewire', function () {
|
||||
setLivewireProperty(this, this.dataset.wireModel, $select.val());
|
||||
|
||||
this.dispatchEvent(
|
||||
new Event('change', {
|
||||
bubbles: true,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -236,11 +236,28 @@ function bootUi() {
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', bootUi);
|
||||
window.addEventListener('load', bootUi);
|
||||
window.addEventListener('pageshow', bootUi);
|
||||
|
||||
document.addEventListener('livewire:navigated', bootUi);
|
||||
|
||||
document.addEventListener('livewire:init', () => {
|
||||
Livewire.hook('morphed', () => {
|
||||
initialiseSelect2();
|
||||
Livewire.hook('morphed', ({ el }) => {
|
||||
initialiseSelect2(el || document);
|
||||
});
|
||||
});
|
||||
|
||||
const select2Observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
if (node instanceof window.Element) {
|
||||
initialiseSelect2(node);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
select2Observer.observe(document.documentElement, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user