-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistbox-custom.component.ts
More file actions
82 lines (77 loc) · 2.52 KB
/
listbox-custom.component.ts
File metadata and controls
82 lines (77 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { StoryObj } from '@storybook/angular';
import { Listbox } from 'primeng/listbox';
import { SharedModule } from 'primeng/api';
const options = [
{ name: 'Profile', description: 'Manage your account', icon: 'ti ti-user' },
{ name: 'Settings', description: 'App preferences', icon: 'ti ti-settings' },
{ name: 'Messages', description: 'Your inbox', icon: 'ti ti-message' },
];
const template = `
<p-listbox [formControl]="ctrl" [options]="options" optionLabel="name">
<ng-template pTemplate="item" let-item>
<i [class]="item.icon"></i>
<div class="p-listbox-option-label-group">
<span>{{ item.name }}</span>
<small class="p-listbox-option-caption">{{ item.description }}</small>
</div>
</ng-template>
</p-listbox>
`;
const styles = '';
@Component({
selector: 'app-listbox-custom',
standalone: true,
imports: [Listbox, SharedModule, ReactiveFormsModule],
template,
styles,
})
export class ListboxCustomComponent {
ctrl = new FormControl(null);
options = options;
}
export const Custom: StoryObj = {
render: () => ({
template: `<app-listbox-custom></app-listbox-custom>`,
}),
parameters: {
controls: { disable: true },
docs: {
description: { story: 'Кастомный шаблон элемента с иконкой и подписью.' },
source: {
language: 'ts',
code: `
import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { Listbox } from 'primeng/listbox';
import { SharedModule } from 'primeng/api';
@Component({
selector: 'app-listbox-custom',
standalone: true,
imports: [Listbox, SharedModule, ReactiveFormsModule],
template: \`
<p-listbox [formControl]="ctrl" [options]="options" optionLabel="name">
<ng-template pTemplate="item" let-item>
<i [class]="item.icon"></i>
<div class="p-listbox-option-label-group">
<span>{{ item.name }}</span>
<small class="p-listbox-option-caption">{{ item.description }}</small>
</div>
</ng-template>
</p-listbox>
\`,
})
export class ListboxCustomComponent {
ctrl = new FormControl(null);
options = [
{ name: 'Profile', description: 'Manage your account', icon: 'ti ti-user' },
{ name: 'Settings', description: 'App preferences', icon: 'ti ti-settings' },
{ name: 'Messages', description: 'Your inbox', icon: 'ti ti-message' },
];
}
`,
},
},
},
};