Skip to content

Commit

Permalink
revert migration file
Browse files Browse the repository at this point in the history
  • Loading branch information
myrta2302 committed Dec 13, 2024
1 parent 1fe8556 commit a00b695
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions packages/migrations/src/migrations/post/custom-select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,67 @@ import { DomUpdate, getDomMigrationRule } from '../../../utils/dom-migration';

export default function (): Rule {
return getDomMigrationRule(
new CustomSelectFloatingLabelWrapperUpdate(),
new CustomSelectClassesUpdate(),
new CustomSelectMenuClassesUpdate(),
new CustomSelectFloatingLabelWrapperUpdate,
new CustomSelectClassesUpdate,
new CustomSelectMenuClassesUpdate,
);
}

class CustomSelectFloatingLabelWrapperUpdate implements DomUpdate {
selector = '.form-group';

update($elements: Cheerio<AnyNode>, $: CheerioAPI) {
$elements.each((_i, element) => {
const $element = $(element);
const $control = $element.find('> button.form-control-lg');
const $label = $control.next('label');
const isNgbDropdown = $element.attr('ngbDropdown') !== undefined;
const isFloatingLabel = $control.length > 0 && $label.length > 0;

if (isNgbDropdown && isFloatingLabel) {
$element.removeClass('form-group').addClass('form-floating');

$control.removeClass('form-control-lg');
}
});
$elements
.each((_i, element) => {
const $element = $(element);
const $control = $element.find('> button.form-control-lg');
const $label = $control.next('label');
const isNgbDropdown = $element.attr('ngbDropdown') !== undefined;
const isFloatingLabel = $control.length > 0 && $label.length > 0;

if (isNgbDropdown && isFloatingLabel) {
$element
.removeClass('form-group')
.addClass('form-floating');

$control.removeClass('form-control-lg');
}
});
}
}

class CustomSelectClassesUpdate implements DomUpdate {
selector = 'button.form-control';

update($elements: Cheerio<AnyNode>, $: CheerioAPI) {
$elements.each((_i, element) => {
const $element = $(element);
const isNgbDropdownToggle = $element.attr('ngbDropdownToggle') !== undefined;

if (isNgbDropdownToggle) {
$element.removeClass('form-control custom-select').addClass('form-select');
}
});
$elements
.each((_i, element) => {
const $element = $(element);
const isNgbDropdownToggle = $element.attr('ngbDropdownToggle') !== undefined;

if (isNgbDropdownToggle) {
$element
.removeClass('form-control custom-select')
.addClass('form-select');
}
});
}
}

class CustomSelectMenuClassesUpdate implements DomUpdate {
selector = '.custom-select-menu';

update($elements: Cheerio<AnyNode>, $: CheerioAPI) {
$elements.each((_i, element) => {
const $element = $(element);
const isNgbDropdownMenu = $element.attr('ngbDropdownMenu') !== undefined;

if (isNgbDropdownMenu) {
$element.removeClass('custom-select-menu').addClass('w-100 min-w-100');
}
});
$elements
.each((_i, element) => {
const $element = $(element);
const isNgbDropdownMenu = $element.attr('ngbDropdownMenu') !== undefined;

if (isNgbDropdownMenu) {
$element
.removeClass('custom-select-menu')
.addClass('w-100 mw-100');
}
});
}
}

0 comments on commit a00b695

Please sign in to comment.