-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work for #8129 extract list-item-content
- Loading branch information
OlgaLarina
committed
May 22, 2024
1 parent
0d53b95
commit 0d5ead5
Showing
10 changed files
with
105 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/survey-angular-ui/src/components/list/list-item-content.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ng-template #template> | ||
<svg *ngIf="model.iconName" [class]="listModel.cssClasses.itemIcon" [iconName]="model.iconName" [size]="model.iconSize" | ||
sv-ng-svg-icon></svg> | ||
<sv-ng-string [model]="model.locTitle"></sv-ng-string> | ||
</ng-template> |
22 changes: 22 additions & 0 deletions
22
packages/survey-angular-ui/src/components/list/list-item-content.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { ListModel, Action } from "survey-core"; | ||
import { BaseAngular } from "../../base-angular"; | ||
import { AngularComponentFactory } from "../../component-factory"; | ||
|
||
@Component({ | ||
selector: "sv-ng-list-item-content, '[sv-ng-list-item-content]'", | ||
templateUrl: "./list-item-content.component.html", | ||
styleUrls: ["../../hide-host.scss"], | ||
}) | ||
|
||
export class ListItemContentComponent extends BaseAngular { | ||
@Input() element: any; | ||
@Input() model!: Action; | ||
@Input() listModel!: ListModel; | ||
|
||
getModel() { | ||
return this.model; | ||
} | ||
} | ||
|
||
AngularComponentFactory.Instance.registerComponent("sv-list-item-content", ListItemContentComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/survey-vue3-ui/src/components/list/ListItemContent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template> | ||
<sv-svg-icon | ||
v-if="item.iconName" | ||
v-bind:class="model.cssClasses.itemIcon" | ||
:iconName="item.iconName" | ||
:size="item.iconSize" | ||
></sv-svg-icon> | ||
<survey-string :locString="item.locTitle" /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { useBase } from "@/base"; | ||
import type { ListModel, Action, IAction } from "survey-core"; | ||
const props = defineProps<{ model: ListModel; item: Action }>(); | ||
useBase(() => props.item); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from "react"; | ||
import { ListModel } from "survey-core"; | ||
import { ReactElementFactory } from "../../element-factory"; | ||
import { SurveyElementBase } from "../../reactquestion_element"; | ||
import { SvgIcon } from "../svg-icon/svg-icon"; | ||
|
||
interface IListItemProps { | ||
model: ListModel; | ||
item: any; | ||
} | ||
|
||
export class ListItemContent extends SurveyElementBase<IListItemProps, any> { | ||
get model(): ListModel { | ||
return this.props.model; | ||
} | ||
get item(): any { | ||
return this.props.item; | ||
} | ||
getStateElement() { | ||
return this.item; | ||
} | ||
render(): JSX.Element | null { | ||
if (!this.item) return null; | ||
|
||
const content: Array<JSX.Element> = []; | ||
const text = this.renderLocString(this.item.locTitle, undefined, "locString"); | ||
if(this.item.iconName) { | ||
const icon = <SvgIcon | ||
key={1} | ||
className={this.model.cssClasses.itemIcon} | ||
iconName={this.item.iconName} | ||
size={this.item.iconSize} | ||
aria-label={this.item.title} | ||
></SvgIcon>; | ||
content.push(icon); | ||
content.push(<span key={2}>{text}</span>); | ||
} else { | ||
content.push(text); | ||
} | ||
|
||
return <> | ||
{content} | ||
</>; | ||
} | ||
} | ||
|
||
ReactElementFactory.Instance.registerElement("sv-list-item-content", (props) => { | ||
return React.createElement(ListItemContent, props); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters