simple-accordian 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,63 +1,180 @@
|
|
|
1
|
-
|
|
1
|
+
Accordion Component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight, reusable, and standalone Angular Accordion component.
|
|
4
|
+
Supports single or multiple open items, disabled items, and is fully configurable via inputs.
|
|
5
|
+
Built to be library-ready, easy to integrate, and works out-of-the-box in Angular 16+ projects.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
✨ Features
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
🧱 Standalone Angular component
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
ng generate component component-name
|
|
11
|
-
```
|
|
11
|
+
📦 npm publish ready
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
📑 Single or multiple items open at once
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
ng generate --help
|
|
17
|
-
```
|
|
15
|
+
🚫 Disable individual accordion items
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
🎨 Fully configurable via inputs
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
💻 Lightweight and reusable
|
|
20
|
+
|
|
21
|
+
✅ No module imports required
|
|
22
|
+
|
|
23
|
+
📦 Installation
|
|
24
|
+
|
|
25
|
+
Install the package using npm:
|
|
26
|
+
|
|
27
|
+
npm install accordian
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Requirements
|
|
31
|
+
|
|
32
|
+
Angular 16+
|
|
33
|
+
|
|
34
|
+
Standalone components enabled (default in Angular 16+)
|
|
35
|
+
|
|
36
|
+
🚀 Basic Usage
|
|
37
|
+
|
|
38
|
+
Use the component directly in your templates:
|
|
39
|
+
|
|
40
|
+
<simple-accordian [items]="items" [multiple]="false"></simple-accordian>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
No module imports are required because the component is standalone.
|
|
44
|
+
|
|
45
|
+
🧩 Configuration Details
|
|
46
|
+
|
|
47
|
+
The accordion is fully configured via the items input and optional multiple input.
|
|
48
|
+
|
|
49
|
+
Boolean Input
|
|
50
|
+
<simple-accordian [multiple]="true"></simple-accordian>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
📘 API Reference
|
|
54
|
+
|
|
55
|
+
Component: simple-accordian
|
|
56
|
+
|
|
57
|
+
Inputs
|
|
58
|
+
Input Type Default Description
|
|
59
|
+
items AccordionItemInterface[] [] Array of accordion items. Each item can have title, content, open, and disabled.
|
|
60
|
+
multiple boolean false Allows multiple items to be open at the same time.
|
|
61
|
+
Item Interface
|
|
62
|
+
export interface AccordionItemInterface {
|
|
63
|
+
title: string;
|
|
64
|
+
content: string;
|
|
65
|
+
open?: boolean; // Open by default
|
|
66
|
+
disabled?: boolean; // Disable the item
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Example Items
|
|
70
|
+
items: AccordionItemInterface[] = [
|
|
71
|
+
{ title: 'Item 1', content: 'Content 1' },
|
|
72
|
+
{ title: 'Item 2', content: 'Content 2', disabled: true }, // Disabled
|
|
73
|
+
{ title: 'Item 3', content: 'Content 3' }
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
Template Usage
|
|
77
|
+
<simple-accordian [items]="items" [multiple]="false"></simple-accordian>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
🎨 Styling
|
|
81
|
+
|
|
82
|
+
The component comes with a default CSS file (accordian.css) that can be customized:
|
|
83
|
+
|
|
84
|
+
.accordion-header.disabled {
|
|
85
|
+
opacity: 0.5;
|
|
86
|
+
cursor: not-allowed;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
🏗️ Building the Library
|
|
22
91
|
|
|
23
|
-
```bash
|
|
24
92
|
ng build accordian
|
|
25
|
-
```
|
|
26
93
|
|
|
27
|
-
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
94
|
|
|
29
|
-
|
|
95
|
+
Build output:
|
|
96
|
+
|
|
97
|
+
dist/accordian
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
📤 Publishing
|
|
101
|
+
|
|
102
|
+
cd dist/accordian
|
|
103
|
+
npm publish --access public
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
🤝 Contribution Guidelines
|
|
107
|
+
|
|
108
|
+
Contributions are welcome!
|
|
109
|
+
|
|
110
|
+
How to contribute
|
|
111
|
+
|
|
112
|
+
Fork the repository
|
|
113
|
+
|
|
114
|
+
Create a new branch:
|
|
115
|
+
|
|
116
|
+
git checkout -b feature/your-feature-name
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
Make your changes
|
|
120
|
+
|
|
121
|
+
Commit with a clear message:
|
|
122
|
+
|
|
123
|
+
git commit -m "feat: add new feature"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
Push and open a Pull Request
|
|
127
|
+
|
|
128
|
+
Contribution rules
|
|
129
|
+
|
|
130
|
+
Follow existing code style
|
|
131
|
+
|
|
132
|
+
Keep components reusable and generic
|
|
133
|
+
|
|
134
|
+
Avoid breaking changes unless necessary
|
|
135
|
+
|
|
136
|
+
Update README if you add new features
|
|
137
|
+
|
|
138
|
+
🐞 Troubleshooting & Bug Reports
|
|
139
|
+
|
|
140
|
+
If you encounter bugs:
|
|
141
|
+
|
|
142
|
+
Check existing issues first
|
|
143
|
+
|
|
144
|
+
Open a new issue with:
|
|
145
|
+
|
|
146
|
+
Angular version
|
|
147
|
+
|
|
148
|
+
Browser
|
|
149
|
+
|
|
150
|
+
Minimal reproduction (code or repo)
|
|
151
|
+
|
|
152
|
+
Screenshots if UI-related
|
|
153
|
+
|
|
154
|
+
📍 Report issues here:
|
|
155
|
+
👉 GitHub Issues page (link
|
|
156
|
+
)
|
|
30
157
|
|
|
31
|
-
|
|
158
|
+
♿ Accessibility
|
|
32
159
|
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
cd dist/accordian
|
|
36
|
-
```
|
|
160
|
+
Uses semantic HTML and buttons
|
|
37
161
|
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm publish
|
|
41
|
-
```
|
|
162
|
+
Disabled items prevent interaction
|
|
42
163
|
|
|
43
|
-
|
|
164
|
+
Works with keyboard navigation
|
|
44
165
|
|
|
45
|
-
|
|
166
|
+
🛣️ Roadmap
|
|
46
167
|
|
|
47
|
-
|
|
48
|
-
ng test
|
|
49
|
-
```
|
|
168
|
+
Icon support (expand/collapse)
|
|
50
169
|
|
|
51
|
-
|
|
170
|
+
Animation enhancements
|
|
52
171
|
|
|
53
|
-
|
|
172
|
+
CSS variables for theming
|
|
54
173
|
|
|
55
|
-
|
|
56
|
-
ng e2e
|
|
57
|
-
```
|
|
174
|
+
Angular Elements / Web Component support
|
|
58
175
|
|
|
59
|
-
|
|
176
|
+
Storybook documentation
|
|
60
177
|
|
|
61
|
-
|
|
178
|
+
📄 License
|
|
62
179
|
|
|
63
|
-
|
|
180
|
+
MIT License © 2025
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-accordian.mjs","sources":["../../../projects/accordian/src/lib/accordian/accordian.ts","../../../projects/accordian/src/lib/accordian/accordian.html","../../../projects/accordian/src/public-api.ts","../../../projects/accordian/src/simple-accordian.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport { Component, Input } from '@angular/core';\r\n\r\nexport interface AccordionItemInterface {\r\n title: string;\r\n content: string;\r\n open?: boolean;\r\n disabled?: boolean;\r\n}\r\n\r\n@Component({\r\n selector: 'simple-accordian',\r\n standalone: true,\r\n imports: [CommonModule],\r\n templateUrl: './accordian.html',\r\n styleUrls: ['./accordian.css']\r\n})\r\nexport class Accordian {\r\n\r\n //for the inputs of the accordian component\r\n @Input() items: AccordionItemInterface[] = []; // Array of accordion items\r\n @Input() multiple = false; // Allow multiple sections to be open simultaneously\r\n\r\n //function to toggle the accordian items\r\n toggle(index: number) {\r\n const clicked = this.items[index];\r\n if (clicked.disabled) return;\r\n\r\n this.items = this.items.map((item, i) => {\r\n if (this.multiple) {\r\n return i === index\r\n ? { ...item, open: !item.open }\r\n : item;\r\n }\r\n\r\n return i === index\r\n ? { ...item, open: !item.open }\r\n : { ...item, open: false };\r\n });\r\n }\r\n}\r\n","<div class=\"accordion\">\r\n @for (item of items; track $index; let i = $index) {\r\n <div class=\"accordion-item\">\r\n <button\r\n class=\"accordion-header\"\r\n (click)=\"toggle(i)\"\r\n [class.active]=\"item.open\"\r\n [disabled]=\"item.disabled\">\r\n\r\n <span>{{ item.title }}</span>\r\n <span class=\"icon\">{{ item.open ? '−' : '+' }}</span>\r\n </button>\r\n\r\n <div class=\"accordion-body\" [class.open]=\"item.open\">\r\n <div class=\"accordion-content\">\r\n {{ item.content }}\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n","/*\r\n * Public API Surface of accordian\r\n */\r\n\r\nexport * from './lib/accordian/accordian';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAiBa,SAAS,CAAA;;AAGX,IAAA,KAAK,GAA6B,EAAE,CAAC;AACrC,IAAA,QAAQ,GAAG,KAAK,CAAC;;AAG1B,IAAA,MAAM,CAAC,KAAa,EAAA;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACjC,IAAI,OAAO,CAAC,QAAQ;YAAE;AAEtB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAI;AACtC,YAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjB,OAAO,CAAC,KAAK;sBACT,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI;sBAC3B,IAAI;YACV;YAEA,OAAO,CAAC,KAAK;kBACT,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI;kBAC3B,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;AAC9B,QAAA,CAAC,CAAC;IACJ;uGAtBW,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAT,SAAS,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,OAAA,EAAA,QAAA,EAAA,UAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECjBtB,qoBAqBA,EAAA,MAAA,EAAA,CAAA,ixCAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDRY,YAAY,EAAA,CAAA,EAAA,CAAA;;2FAIX,SAAS,EAAA,UAAA,EAAA,CAAA;kBAPrB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,kBAAkB,EAAA,UAAA,EAChB,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,CAAC,EAAA,QAAA,EAAA,qoBAAA,EAAA,MAAA,EAAA,CAAA,ixCAAA,CAAA,EAAA;;sBAOtB;;sBACA;;;AErBH;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-accordian",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^21.1.0",
|
|
6
6
|
"@angular/core": "^21.1.0"
|
|
@@ -9,25 +9,15 @@
|
|
|
9
9
|
"tslib": "^2.3.0"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": false,
|
|
12
|
-
"module": "fesm2022/accordian.mjs",
|
|
13
|
-
"typings": "types/accordian.d.ts",
|
|
12
|
+
"module": "fesm2022/simple-accordian.mjs",
|
|
13
|
+
"typings": "types/simple-accordian.d.ts",
|
|
14
14
|
"exports": {
|
|
15
15
|
"./package.json": {
|
|
16
16
|
"default": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
".": {
|
|
19
|
-
"types": "./types/accordian.d.ts",
|
|
20
|
-
"default": "./fesm2022/accordian.mjs"
|
|
19
|
+
"types": "./types/simple-accordian.d.ts",
|
|
20
|
+
"default": "./fesm2022/simple-accordian.mjs"
|
|
21
21
|
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
"main": "index.js",
|
|
25
|
-
"scripts": {
|
|
26
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
27
|
-
},
|
|
28
|
-
"keywords": [
|
|
29
|
-
"accordian"
|
|
30
|
-
],
|
|
31
|
-
"author": "Debdip",
|
|
32
|
-
"license": "ISC"
|
|
33
|
-
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accordian.mjs","sources":["../../../projects/accordian/src/lib/accordian/accordian.ts","../../../projects/accordian/src/lib/accordian/accordian.html","../../../projects/accordian/src/public-api.ts","../../../projects/accordian/src/accordian.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport { Component, Input } from '@angular/core';\r\n\r\nexport interface AccordionItemInterface {\r\n title: string;\r\n content: string;\r\n open?: boolean;\r\n disabled?: boolean;\r\n}\r\n\r\n@Component({\r\n selector: 'simple-accordian',\r\n standalone: true,\r\n imports: [CommonModule],\r\n templateUrl: './accordian.html',\r\n styleUrls: ['./accordian.css']\r\n})\r\nexport class Accordian {\r\n\r\n //for the inputs of the accordian component\r\n @Input() items: AccordionItemInterface[] = []; // Array of accordion items\r\n @Input() multiple = false; // Allow multiple sections to be open simultaneously\r\n\r\n //function to toggle the accordian items\r\n toggle(index: number) {\r\n const clicked = this.items[index];\r\n if (clicked.disabled) return;\r\n\r\n this.items = this.items.map((item, i) => {\r\n if (this.multiple) {\r\n return i === index\r\n ? { ...item, open: !item.open }\r\n : item;\r\n }\r\n\r\n return i === index\r\n ? { ...item, open: !item.open }\r\n : { ...item, open: false };\r\n });\r\n }\r\n}\r\n","<div class=\"accordion\">\r\n @for (item of items; track $index; let i = $index) {\r\n <div class=\"accordion-item\">\r\n <button\r\n class=\"accordion-header\"\r\n (click)=\"toggle(i)\"\r\n [class.active]=\"item.open\"\r\n [disabled]=\"item.disabled\">\r\n\r\n <span>{{ item.title }}</span>\r\n <span class=\"icon\">{{ item.open ? '−' : '+' }}</span>\r\n </button>\r\n\r\n <div class=\"accordion-body\" [class.open]=\"item.open\">\r\n <div class=\"accordion-content\">\r\n {{ item.content }}\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n","/*\r\n * Public API Surface of accordian\r\n */\r\n\r\nexport * from './lib/accordian/accordian';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAiBa,SAAS,CAAA;;AAGX,IAAA,KAAK,GAA6B,EAAE,CAAC;AACrC,IAAA,QAAQ,GAAG,KAAK,CAAC;;AAG1B,IAAA,MAAM,CAAC,KAAa,EAAA;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACjC,IAAI,OAAO,CAAC,QAAQ;YAAE;AAEtB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAI;AACtC,YAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjB,OAAO,CAAC,KAAK;sBACT,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI;sBAC3B,IAAI;YACV;YAEA,OAAO,CAAC,KAAK;kBACT,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI;kBAC3B,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;AAC9B,QAAA,CAAC,CAAC;IACJ;uGAtBW,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAT,SAAS,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,OAAA,EAAA,QAAA,EAAA,UAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECjBtB,qoBAqBA,EAAA,MAAA,EAAA,CAAA,ixCAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDRY,YAAY,EAAA,CAAA,EAAA,CAAA;;2FAIX,SAAS,EAAA,UAAA,EAAA,CAAA;kBAPrB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,kBAAkB,EAAA,UAAA,EAChB,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,CAAC,EAAA,QAAA,EAAA,qoBAAA,EAAA,MAAA,EAAA,CAAA,ixCAAA,CAAA,EAAA;;sBAOtB;;sBACA;;;AErBH;;AAEG;;ACFH;;AAEG;;;;"}
|
|
File without changes
|