Skip to content

Commit

Permalink
Merge pull request #1639 from Infineon/1615-single-select-remove-the-…
Browse files Browse the repository at this point in the history
…close-button-when-nested-inside-pagination

Single-select: removes the close button on small resolution and adds it when default option is selected
  • Loading branch information
tishoyanchev authored Dec 10, 2024
2 parents 79cc930 + 8d67c31 commit 1336eda
Show file tree
Hide file tree
Showing 13 changed files with 3,569 additions and 4,648 deletions.
2 changes: 1 addition & 1 deletion examples/wrapper-components/react-vite-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-react": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"@infineon/infineon-design-system-react": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"path": "^0.12.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/wrapper-components/vue-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-vue": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"@infineon/infineon-design-system-vue": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"vite": "^5.0.12",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"version": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"command": {
"publish": {
"verifyAccess": false
Expand Down
8,107 changes: 3,474 additions & 4,633 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/components-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "components-angular",
"version": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"version": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -26,7 +26,7 @@
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@infineon/infineon-design-system-angular": "^29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"@infineon/infineon-design-system-angular": "^29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"typescript": "~5.4.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-angular",
"version": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"version": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"description": "Infineon design system Stencil web components for Angular",
"author": "Verena Lechner",
"license": "MIT",
Expand All @@ -11,7 +11,7 @@
"@angular/common": "^18.0.0",
"@angular/core": "^18.0.0",
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0"
"@infineon/infineon-design-system-stencil": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0"
},
"dependencies": {
"tslib": "^2.3.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/components-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-react",
"version": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"version": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"description": "Infineon design system Stencil web components for React",
"main": "./dist/index.js",
"types": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "^29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"@infineon/infineon-design-system-stencil": "^29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"@stencil/react-output-target": "^0.7.1"
},
"auto": {
Expand Down
4 changes: 2 additions & 2 deletions packages/components-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-vue",
"version": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"version": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"description": "Infineon design system Stencil web components for Vue",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "^29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0"
"@infineon/infineon-design-system-stencil": "^29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0"
},
"auto": {
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-stencil",
"version": "29.2.1--canary.1638.b8df42a289a6ff6eb917dbf3f987e4b3899cfdce.0",
"version": "29.3.0--canary.1639.52a545f9a651e2536d4f40c373f7eb826907d680.0",
"private": false,
"description": "Infineon design system Stencil web components",
"homepage": "https://infineon.github.io/infineon-design-system-stencil",
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/components/pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export class Pagination {

@Listen('ifxSelect')
setItemsPerPage(e) {
this.itemsPerPage = parseInt(e.detail.label)
if(e.detail) {
this.itemsPerPage = parseInt(e.detail.label)
} else {
this.itemsPerPage = 10;
}
}

componentDidLoad() {
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/components/select/single-select/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ Type: `Promise<void>`



### `handleDeleteIcon() => Promise<void>`



#### Returns

Type: `Promise<void>`



### `hideDropdown(blurInput?: boolean) => Promise<this>`


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
display: flex;
align-items: center;
justify-content: center;

&.hide {
display: none;
}
}

}
Expand Down
66 changes: 64 additions & 2 deletions packages/components/src/components/select/single-select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export class Choices implements IChoicesProps, IChoicesMethods {
@Prop({ mutable: true }) options: any[] | string;
@Prop() size: string = 'medium (40px)';
@State() selectedOption: any | null = null;
@State() optionIsSelected: boolean = false;

private resizeObserver: ResizeObserver;

@Element() private readonly root: HTMLElement;
private choice;
Expand All @@ -101,6 +104,7 @@ export class Choices implements IChoicesProps, IChoicesMethods {
this.setPreSelected(null);
this.closeDropdown();
this.ifxSelect.emit(null);
this.optionIsSelected = false;
}

@Method()
Expand Down Expand Up @@ -245,18 +249,76 @@ export class Choices implements IChoicesProps, IChoicesMethods {
return this;
}

@Method()
async handleDeleteIcon() {
const width = this.root.offsetWidth;
const deleteIconWrapper = this.root.querySelector('.ifx-choices__icon-wrapper-delete');
if(deleteIconWrapper) {
if (width <= 180) {
deleteIconWrapper.classList.add('hide')
} else {
deleteIconWrapper.classList.remove('hide')
}
}
}


handleCloseButton() {
if(typeof this.options === 'string') {
const optionsToArray = JSON.parse(this.options);
const optionIsSelected = optionsToArray.find(option => option.selected === true)
if(optionIsSelected) {
this.optionIsSelected = true;
} else {
this.optionIsSelected = false;
}
} else if(this.options && Array.isArray(this.options)) {
const optionIsSelected = this.options.find(option => option.selected === true)
if(optionIsSelected) {
this.optionIsSelected = true;
} else {
this.optionIsSelected = false;
}
}
}

protected componentWillLoad() {
this.handleCloseButton()
}

protected componentWillUpdate() {
this.handleCloseButton()

}

addResizeObserver() {
this.resizeObserver = new ResizeObserver(() => {
this.handleDeleteIcon();
});

const componentWrapper = this.root.querySelector('.ifx-choices__wrapper');
this.resizeObserver.observe(componentWrapper);
}

protected componentDidLoad() {
this.init();
this.addEventListenersToHandleCustomFocusAndActiveState();

this.handleDeleteIcon();
this.addResizeObserver()
}

protected componentDidUpdate() {
this.init();
this.handleDeleteIcon()
}

protected disconnectedCallback() {
this.destroy();

if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
}

protected render(): any {
Expand Down Expand Up @@ -289,7 +351,7 @@ export class Choices implements IChoicesProps, IChoicesMethods {
{this.createSelectOptions(this.options)}
</select>

{ this.selectedOption && (
{ this.optionIsSelected && (
<div class="ifx-choices__icon-wrapper-delete">
<ifx-icon icon="cremove16" onClick={() => this.handleDeleteSelection()}></ifx-icon>
</div>
Expand Down

0 comments on commit 1336eda

Please sign in to comment.