@redvars/peacock 3.0.0

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.
Files changed (61) hide show
  1. package/.editorconfig +29 -0
  2. package/.husky/pre-commit +1 -0
  3. package/LICENSE +21 -0
  4. package/README.md +46 -0
  5. package/custom-elements-manifest.config.mjs +34 -0
  6. package/custom-elements.md +252 -0
  7. package/demo/index.html +24 -0
  8. package/demo/tokens.css +510 -0
  9. package/dist/src/LoaderUtils.d.ts +23 -0
  10. package/dist/src/LoaderUtils.js +81 -0
  11. package/dist/src/LoaderUtils.js.map +1 -0
  12. package/dist/src/avatar/avatar.css.d.ts +1 -0
  13. package/dist/src/avatar/avatar.css.js +41 -0
  14. package/dist/src/avatar/avatar.css.js.map +1 -0
  15. package/dist/src/avatar/avatar.d.ts +14 -0
  16. package/dist/src/avatar/avatar.js +44 -0
  17. package/dist/src/avatar/avatar.js.map +1 -0
  18. package/dist/src/icon/datasource.d.ts +2 -0
  19. package/dist/src/icon/datasource.js +20 -0
  20. package/dist/src/icon/datasource.js.map +1 -0
  21. package/dist/src/icon/icon.css.d.ts +1 -0
  22. package/dist/src/icon/icon.css.js +22 -0
  23. package/dist/src/icon/icon.css.js.map +1 -0
  24. package/dist/src/icon/icon.d.ts +26 -0
  25. package/dist/src/icon/icon.js +119 -0
  26. package/dist/src/icon/icon.js.map +1 -0
  27. package/dist/src/icon/p-icon.d.ts +3 -0
  28. package/dist/src/icon/p-icon.js +10 -0
  29. package/dist/src/icon/p-icon.js.map +1 -0
  30. package/dist/src/index.d.ts +2 -0
  31. package/dist/src/index.js +3 -0
  32. package/dist/src/index.js.map +1 -0
  33. package/dist/src/peacock-loader.d.ts +1 -0
  34. package/dist/src/peacock-loader.js +16 -0
  35. package/dist/src/peacock-loader.js.map +1 -0
  36. package/dist/src/utils.d.ts +3 -0
  37. package/dist/src/utils.js +101 -0
  38. package/dist/src/utils.js.map +1 -0
  39. package/dist/test/icon.test.d.ts +1 -0
  40. package/dist/test/icon.test.js +14 -0
  41. package/dist/test/icon.test.js.map +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/package.json +87 -0
  44. package/readme-gen.mjs +11 -0
  45. package/rollup.config.js +19 -0
  46. package/src/LoaderUtils.ts +121 -0
  47. package/src/avatar/avatar.css.ts +41 -0
  48. package/src/avatar/avatar.ts +39 -0
  49. package/src/avatar/demo/index.html +26 -0
  50. package/src/icon/datasource.ts +28 -0
  51. package/src/icon/demo/index.html +25 -0
  52. package/src/icon/icon.css.ts +22 -0
  53. package/src/icon/icon.ts +117 -0
  54. package/src/icon/p-icon.ts +5 -0
  55. package/src/index.ts +2 -0
  56. package/src/peacock-loader.ts +17 -0
  57. package/src/utils.ts +118 -0
  58. package/test/icon.test.ts +16 -0
  59. package/tsconfig.json +22 -0
  60. package/web-dev-server.config.js +27 -0
  61. package/web-test-runner.config.js +41 -0
package/.editorconfig ADDED
@@ -0,0 +1,29 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+
8
+ [*]
9
+
10
+ # Change these settings to your own preference
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ # We recommend you to keep these unchanged
15
+ end_of_line = lf
16
+ charset = utf-8
17
+ trim_trailing_whitespace = true
18
+ insert_final_newline = true
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
22
+
23
+ [*.json]
24
+ indent_size = 2
25
+
26
+ [*.{html,js,md}]
27
+ block_comment_start = /**
28
+ block_comment = *
29
+ block_comment_end = */
@@ -0,0 +1 @@
1
+ ./node_modules/.bin/lint-staged
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 p-icon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # `src/Icon.ts`:
2
+
3
+ ## class: `Icon`
4
+
5
+ ### Superclass
6
+
7
+ | Name | Module | Package |
8
+ | ------------ | ------ | ------- |
9
+ | `LitElement` | | lit |
10
+
11
+ ### Fields
12
+
13
+ | Name | Privacy | Type | Default | Description | Inherited From |
14
+ | ---------- | ------- | --------------------------------------------- | -------------------- | ----------- | -------------- |
15
+ | `name` | | `string \| undefined` | `'home'` | | |
16
+ | `src` | | `string \| undefined` | | | |
17
+ | `provider` | | `'material-symbols' \| 'carbon' \| undefined` | `'material-symbols'` | | |
18
+
19
+ ### Events
20
+
21
+ | Name | Type | Description | Inherited From |
22
+ | ------------ | ------------- | ----------- | -------------- |
23
+ | `icon-error` | `CustomEvent` | | |
24
+
25
+ ### Attributes
26
+
27
+ | Name | Field | Inherited From |
28
+ | ---------- | -------- | -------------- |
29
+ | `name` | name | |
30
+ | `src` | src | |
31
+ | `provider` | provider | |
32
+
33
+ ### CSS Properties
34
+
35
+ | Name | Default | Description |
36
+ | -------------- | ------- | ------------------------------- |
37
+ | `--icon-color` | | Controls the color of the icon. |
38
+ | `--icon-size` | | Controls the size of the icon. |
39
+
40
+ <hr/>
41
+
42
+ ## Exports
43
+
44
+ | Kind | Name | Declaration | Module | Package |
45
+ | ---- | ------ | ----------- | ----------- | ------- |
46
+ | `js` | `Icon` | Icon | src/Icon.ts | |
@@ -0,0 +1,34 @@
1
+ import { lazyLoaderPlugin } from '@wc-toolkit/lazy-loader';
2
+
3
+ const formatComponentName = str => {
4
+ return (
5
+ str
6
+ // 1. Remove the word "Component" if it exists at the end
7
+ .replace(/Component$/, '')
8
+ // 2. Find uppercase letters and replace with "-lowercase"
9
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
10
+ // 3. Convert the whole string to lowercase
11
+ .toLowerCase()
12
+ );
13
+ };
14
+
15
+ export default {
16
+ /** Globs to analyze */
17
+ globs: ['src/**/*.ts'],
18
+
19
+ outdir: 'dist',
20
+
21
+ /** Enable special handling for litelement */
22
+ litelement: true,
23
+
24
+ /*plugins: [
25
+ lazyLoaderPlugin({
26
+ importPathTemplate: (name, tagName) => {
27
+ console.log(`./src/${formatComponentName(name)}/${tagName}.js`);
28
+ return `./src/${formatComponentName(name)}/${tagName}.js`;
29
+ },
30
+ outdir: 'dist',
31
+ eagerLoad: ['p-icon'],
32
+ }),
33
+ ],*/
34
+ };
@@ -0,0 +1,252 @@
1
+ # `src/index.ts`:
2
+
3
+ ## Exports
4
+
5
+ | Kind | Name | Declaration | Module | Package |
6
+ | ---- | -------- | ----------- | ------------------ | ------- |
7
+ | `js` | `Icon` | Icon | ./icon/icon.js | |
8
+ | `js` | `Avatar` | Avatar | ./avatar/avatar.js | |
9
+
10
+ # `src/LoaderUtils.ts`:
11
+
12
+ ## class: `LoaderUtils`
13
+
14
+ ### Static Methods
15
+
16
+ | Name | Privacy | Description | Parameters | Return | Inherited From |
17
+ | ------------------- | ------- | ----------- | ------------------------------------------ | ------ | -------------- |
18
+ | `registerComponent` | | | `tagName: string, CustomElementClass: any` | | |
19
+
20
+ ### Methods
21
+
22
+ | Name | Privacy | Description | Parameters | Return | Inherited From |
23
+ | --------------------- | ------- | ----------- | --------------------------- | --------------- | -------------- |
24
+ | `start` | | | | | |
25
+ | `eagerLoadComponents` | | | | | |
26
+ | `getFullTagName` | | | `name: string` | | |
27
+ | `registerAsync` | | | `tagName: string` | `Promise<void>` | |
28
+ | `load` | | | `root: Element \| Document` | `Promise<void>` | |
29
+ | `lazyLoadComponents` | | | `root: any` | | |
30
+
31
+ <hr/>
32
+
33
+ ## Variables
34
+
35
+ | Name | Description | Type |
36
+ | -------------------- | ----------- | ---- |
37
+ | `CustomElementClass` | | |
38
+
39
+ <hr/>
40
+
41
+ ## Exports
42
+
43
+ | Kind | Name | Declaration | Module | Package |
44
+ | --------------------------- | -------------- | ------------------ | ------------------ | ------- |
45
+ | `js` | `LoaderConfig` | LoaderConfig | src/LoaderUtils.ts | |
46
+ | `js` | `LoaderUtils` | LoaderUtils | src/LoaderUtils.ts | |
47
+ | `custom-element-definition` | `tagName` | CustomElementClass | src/LoaderUtils.ts | |
48
+ | `custom-element-definition` | `tagName` | CustomElementClass | src/LoaderUtils.ts | |
49
+
50
+ # `src/utils.ts`:
51
+
52
+ ## Functions
53
+
54
+ | Name | Description | Parameters | Return |
55
+ | ------------------ | ----------- | ---------------- | ------ |
56
+ | `createCacheFetch` | | `name: string` | |
57
+ | `sanitizeSvg` | | `rawSvg: string` | |
58
+ | `getTypography` | | `name: string` | |
59
+
60
+ <hr/>
61
+
62
+ ## Exports
63
+
64
+ | Kind | Name | Declaration | Module | Package |
65
+ | ---- | ------------------ | ---------------- | ------------ | ------- |
66
+ | `js` | `createCacheFetch` | createCacheFetch | src/utils.ts | |
67
+ | `js` | `sanitizeSvg` | sanitizeSvg | src/utils.ts | |
68
+ | `js` | `getTypography` | getTypography | src/utils.ts | |
69
+
70
+ # `src/avatar/avatar.css.ts`:
71
+
72
+ ## Variables
73
+
74
+ | Name | Description | Type |
75
+ | -------- | ----------- | ---- |
76
+ | `styles` | | |
77
+
78
+ <hr/>
79
+
80
+ ## Exports
81
+
82
+ | Kind | Name | Declaration | Module | Package |
83
+ | ---- | -------- | ----------- | ------------------------ | ------- |
84
+ | `js` | `styles` | styles | src/avatar/avatar.css.ts | |
85
+
86
+ # `src/avatar/avatar.ts`:
87
+
88
+ ## class: `Avatar`
89
+
90
+ ### Superclass
91
+
92
+ | Name | Module | Package |
93
+ | ------------ | ------ | ------- |
94
+ | `LitElement` | | lit |
95
+
96
+ ### Fields
97
+
98
+ | Name | Privacy | Type | Default | Description | Inherited From |
99
+ | ------ | ------- | --------------------- | ------- | ----------- | -------------- |
100
+ | `name` | | `string` | `''` | | |
101
+ | `src` | | `string \| undefined` | | | |
102
+
103
+ ### Attributes
104
+
105
+ | Name | Field | Inherited From |
106
+ | ------ | ----- | -------------- |
107
+ | `name` | name | |
108
+ | `src` | src | |
109
+
110
+ ### CSS Properties
111
+
112
+ | Name | Default | Description |
113
+ | -------------- | ------- | ------------------------------- |
114
+ | `--icon-color` | | Controls the color of the icon. |
115
+ | `--icon-size` | | Controls the size of the icon. |
116
+
117
+ <hr/>
118
+
119
+ ## Exports
120
+
121
+ | Kind | Name | Declaration | Module | Package |
122
+ | ---- | -------- | ----------- | -------------------- | ------- |
123
+ | `js` | `Avatar` | Avatar | src/avatar/avatar.ts | |
124
+
125
+ # `src/icon/datasource.ts`:
126
+
127
+ ## Functions
128
+
129
+ | Name | Description | Parameters | Return |
130
+ | ----------- | ----------- | -------------------------------- | ------ |
131
+ | `fetchSVG` | | `url: string` | |
132
+ | `fetchIcon` | | `name: string, provider: string` | |
133
+
134
+ <hr/>
135
+
136
+ ## Exports
137
+
138
+ | Kind | Name | Declaration | Module | Package |
139
+ | ---- | ----------- | ----------- | ---------------------- | ------- |
140
+ | `js` | `fetchSVG` | fetchSVG | src/icon/datasource.ts | |
141
+ | `js` | `fetchIcon` | fetchIcon | src/icon/datasource.ts | |
142
+
143
+ # `src/icon/icon.css.ts`:
144
+
145
+ ## Variables
146
+
147
+ | Name | Description | Type |
148
+ | -------- | ----------- | ---- |
149
+ | `styles` | | |
150
+
151
+ <hr/>
152
+
153
+ ## Exports
154
+
155
+ | Kind | Name | Declaration | Module | Package |
156
+ | ---- | -------- | ----------- | -------------------- | ------- |
157
+ | `js` | `styles` | styles | src/icon/icon.css.ts | |
158
+
159
+ # `src/icon/icon.ts`:
160
+
161
+ ## class: `Icon`
162
+
163
+ ### Superclass
164
+
165
+ | Name | Module | Package |
166
+ | ------------ | ------ | ------- |
167
+ | `LitElement` | | lit |
168
+
169
+ ### Fields
170
+
171
+ | Name | Privacy | Type | Default | Description | Inherited From |
172
+ | ---------- | ------- | --------------------------------------------- | -------------------- | ----------- | -------------- |
173
+ | `name` | | `string \| undefined` | `'home'` | | |
174
+ | `src` | | `string \| undefined` | | | |
175
+ | `provider` | | `'material-symbols' \| 'carbon' \| undefined` | `'material-symbols'` | | |
176
+
177
+ ### Events
178
+
179
+ | Name | Type | Description | Inherited From |
180
+ | ------------ | ------------- | ----------- | -------------- |
181
+ | `icon-error` | `CustomEvent` | | |
182
+
183
+ ### Attributes
184
+
185
+ | Name | Field | Inherited From |
186
+ | ---------- | -------- | -------------- |
187
+ | `name` | name | |
188
+ | `src` | src | |
189
+ | `provider` | provider | |
190
+
191
+ ### CSS Properties
192
+
193
+ | Name | Default | Description |
194
+ | -------------- | ------- | ------------------------------------------------- |
195
+ | `--icon-color` | | Controls the color of the icon. |
196
+ | `--icon-size` | `1rem` | Controls the size of the icon. Defaults to "1rem" |
197
+
198
+ <hr/>
199
+
200
+ ## Exports
201
+
202
+ | Kind | Name | Declaration | Module | Package |
203
+ | ---- | ------ | ----------- | ---------------- | ------- |
204
+ | `js` | `Icon` | Icon | src/icon/icon.ts | |
205
+
206
+ # `src/icon/p-icon.ts`:
207
+
208
+ ## class: `IconComponent`, `p-icon`
209
+
210
+ ### Superclass
211
+
212
+ | Name | Module | Package |
213
+ | ------ | ----------------- | ------- |
214
+ | `Icon` | /src/icon/icon.js | |
215
+
216
+ ### Fields
217
+
218
+ | Name | Privacy | Type | Default | Description | Inherited From |
219
+ | ---------- | ------- | --------------------------------------------- | -------------------- | ----------- | -------------- |
220
+ | `name` | | `string \| undefined` | `'home'` | | Icon |
221
+ | `src` | | `string \| undefined` | | | Icon |
222
+ | `provider` | | `'material-symbols' \| 'carbon' \| undefined` | `'material-symbols'` | | Icon |
223
+
224
+ ### Events
225
+
226
+ | Name | Type | Description | Inherited From |
227
+ | ------------ | ------------- | ----------- | -------------- |
228
+ | `icon-error` | `CustomEvent` | | Icon |
229
+
230
+ ### Attributes
231
+
232
+ | Name | Field | Inherited From |
233
+ | ---------- | -------- | -------------- |
234
+ | `name` | name | Icon |
235
+ | `src` | src | Icon |
236
+ | `provider` | provider | Icon |
237
+
238
+ ### CSS Properties
239
+
240
+ | Name | Default | Description |
241
+ | -------------- | ------- | ------------------------------------------------- |
242
+ | `--icon-color` | | Controls the color of the icon. |
243
+ | `--icon-size` | `1rem` | Controls the size of the icon. Defaults to "1rem" |
244
+
245
+ <hr/>
246
+
247
+ ## Exports
248
+
249
+ | Kind | Name | Declaration | Module | Package |
250
+ | --------------------------- | --------------- | ------------- | ------------------ | ------- |
251
+ | `js` | `IconComponent` | IconComponent | src/icon/p-icon.ts | |
252
+ | `custom-element-definition` | `p-icon` | IconComponent | src/icon/p-icon.ts | |
@@ -0,0 +1,24 @@
1
+ <!doctype html>
2
+ <html lang='en-GB'>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover' />
6
+ <link rel='stylesheet' href='/demo/tokens.css' />
7
+ <style>
8
+ body {
9
+ background: #fafafa;
10
+ }
11
+ </style>
12
+
13
+ </head>
14
+ <body>
15
+
16
+ <a href='/src/icon/demo/index.html'>icon</a>
17
+
18
+ <p-icon provider='carbon' name='logo--github'></p-icon>
19
+
20
+ <p-avatar name='Test'></p-avatar>
21
+
22
+ <script type='module' src='/dist/src/peacock-loader.js'></script>
23
+ </body>
24
+ </html>