Skip to content

Commit

Permalink
Merge pull request #426 from vc-rakesh/main
Browse files Browse the repository at this point in the history
fix: #424 and #425 issues
  • Loading branch information
iamrsojitra authored Aug 3, 2023
2 parents a305e9e + 5b9af7f commit 6abde12
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 47 deletions.
16 changes: 16 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
export * from './src/app/components/ionic-selectable/ionic-selectable.component';
export * from './src/app/components/ionic-selectable/ionic-selectable-add-item-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-close-button-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-footer-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-group-end-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-group-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-header-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-icon-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-item-end-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-item-icon-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-item-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-message-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-modal.component';
export * from './src/app/components/ionic-selectable/ionic-selectable-placeholder-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-search-fail-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-title-template.directive';
export * from './src/app/components/ionic-selectable/ionic-selectable-value-template.directive';
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.0.0",
"version": "5.0.2",
"name": "ionic-selectable",
"title": "Ionic Selectable",
"description": "An Ionic component similar to Ionic Select, that allows to search items, including async search, group, add, edit, delete items, and much more.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div class="ionic-selectable-spinner-background"></div>
<ion-spinner></ion-spinner>
</div>
<ion-list class="ion-no-margin" *ngIf="!selectComponent.hasVirtualScroll && selectComponent._hasFilteredItems">
<ion-list class="ion-no-margin" *ngIf="selectComponent._hasFilteredItems">
<ion-item-group *ngFor="let group of selectComponent._filteredGroups" class="ionic-selectable-group">
<ion-item-divider *ngIf="selectComponent._hasGroups"
[color]="selectComponent.groupColor ? selectComponent.groupColor : null">
Expand Down Expand Up @@ -98,46 +98,10 @@
{{selectComponent.searchFailText}}
</div>
</div>
<ion-infinite-scroll *ngIf="!selectComponent.hasVirtualScroll" [disabled]="!selectComponent.hasInfiniteScroll"
<ion-infinite-scroll [disabled]="!selectComponent.hasInfiniteScroll"
(ionInfinite)="selectComponent._getMoreItems()">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
<div *ngFor="let item of selectComponent._filteredGroups[0].items">
<ion-item button="true" detail="false" *virtualItem="let item" (click)="selectComponent._select(item)"
class="ionic-selectable-item" [ngClass]="{
'ionic-selectable-item-is-selected': selectComponent._isItemSelected(item),
'ionic-selectable-item-is-disabled': selectComponent._isItemDisabled(item)
}" [disabled]="selectComponent._isItemDisabled(item)">
<!-- Need span for text ellipsis. -->
<span *ngIf="selectComponent.itemTemplate" [ngTemplateOutlet]="selectComponent.itemTemplate"
[ngTemplateOutletContext]="{ item: item, isItemSelected: selectComponent._isItemSelected(item) }">
</span>
<!-- Need ion-label for text ellipsis. -->
<ion-label *ngIf="!selectComponent.itemTemplate">
{{selectComponent._formatItem(item)}}
</ion-label>
<div *ngIf="selectComponent.itemEndTemplate" slot="end">
<div [ngTemplateOutlet]="selectComponent.itemEndTemplate"
[ngTemplateOutletContext]="{ item: item, isItemSelected: selectComponent._isItemSelected(item) }">
</div>
</div>
<span *ngIf="selectComponent.itemIconTemplate" [ngTemplateOutlet]="selectComponent.itemIconTemplate"
[ngTemplateOutletContext]="{ item: item, isItemSelected: selectComponent._isItemSelected(item) }">
</span>
<ion-icon *ngIf="!selectComponent.itemIconTemplate"
[name]="selectComponent._isItemSelected(item) ? 'checkmark-circle' : 'radio-button-off'"
[color]="selectComponent._isItemSelected(item) ? 'primary' : null" [slot]="selectComponent.itemIconSlot">
</ion-icon>
<ion-button *ngIf="selectComponent.canSaveItem" class="ionic-selectable-item-button" slot="end" fill="outline"
(click)="selectComponent._saveItem($event, item)">
<ion-icon slot="icon-only" name="md-create"></ion-icon>
</ion-button>
<ion-button *ngIf="selectComponent.canDeleteItem" class="ionic-selectable-item-button" slot="end" fill="outline"
(click)="selectComponent._deleteItemClick($event, item)">
<ion-icon slot="icon-only" name="md-trash"></ion-icon>
</ion-button>
</ion-item>
</div>
</ion-content>
<div class="ionic-selectable-add-item-template" *ngIf="selectComponent._isAddItemTemplateVisible"
[ngStyle]="{ 'top.px': _header.offsetHeight }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ export class IonicSelectableComponent implements ControlValueAccessor, OnInit, D
private _element: ElementRef,
private _renderer: Renderer2
) {
if (!this.items || !this.items.length) {
if (!this.items?.length) {
this.items = [];
}

Expand Down Expand Up @@ -955,7 +955,7 @@ export class IonicSelectableComponent implements ControlValueAccessor, OnInit, D
// Default filtering.
let groups = [];

if (!this._searchText || !this._searchText.trim()) {
if (!this._searchText?.trim()) {
groups = this._groups;
} else {
const filterText = this._searchText.trim().toLowerCase();
Expand Down Expand Up @@ -1197,7 +1197,7 @@ export class IonicSelectableComponent implements ControlValueAccessor, OnInit, D

private _areGroupsEmpty(groups: any) {
return groups.length === 0 || groups.every((group: any) => {
return !group.items || group.items.length === 0;
return !group.items?.length;
});
}

Expand Down Expand Up @@ -1227,7 +1227,7 @@ export class IonicSelectableComponent implements ControlValueAccessor, OnInit, D
items: items || []
}];

if (items && items.length) {
if (items?.length) {
if (this._hasGroups) {
groups = [];

Expand Down Expand Up @@ -1366,7 +1366,6 @@ export class IonicSelectableComponent implements ControlValueAccessor, OnInit, D

if (itemsChanges) {
this._setItems(this.items);
this.value = this.value;

this.onItemsChange.emit({
component: this
Expand Down Expand Up @@ -1629,7 +1628,7 @@ export class IonicSelectableComponent implements ControlValueAccessor, OnInit, D
*/
toggleItems(isSelect: boolean, items?: any[]) {
if (isSelect) {
const hasItems = items && items.length;
const hasItems = items?.length;
let itemsToToggle = this._groups.reduce((allItems, group) => {
return allItems.concat(group.items);
}, []);
Expand Down

0 comments on commit 6abde12

Please sign in to comment.