proicons 4.8.0 → 4.9.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proicons.cjs","sources":["../../src/categories.ts","../../src/interfaces.ts","../../bin/rename.js","../../src/getIconInfo.ts","../../src/replace.ts","../../src/search.ts"],"sourcesContent":["import icons from './configs/tags.json'\r\n\r\n/** List of all icon categories */\r\nconst categories = Object.values(icons).map((item) => item.category).filter((value, index, self) => self.indexOf(value) === index)\r\n\r\nexport default categories","export interface ProIconReplaceConfig {\r\n /** Determines the color of the icons. Defaults to `currentColor`. */\r\n color: string,\r\n /** Determines the default stroke width of the icon. Defaults to `1.5`. This only works on SVG elements with existing strokes; add `strokeFilledElements` for this property to affect such elements. */\r\n strokeWidth: number,\r\n /** Apply strokes to filled SVG elements, such as circles, by the provided amount with `1.5` (default stroke value) subtracted, if `strokeWidth` is set to a value above `1.5`. Defaults to `false`\r\n * @example If `strokeWidth` is set to `2`, filled SVG elements will have an additional `0.5`px stroke\r\n */\r\n strokeFilledElements: boolean\r\n /** Defaults to `round` */\r\n strokeCaps: 'round' | 'square' | 'butt',\r\n /** Defaults to `round` */\r\n strokeJoin: 'round' | 'miter' | 'bevel',\r\n /** Determines the corner radius of SVG elements. Does not apply to all rounded elements. */\r\n cornerRadius: number,\r\n /** The attribute name that is checked for when converting elements to icons. Defaults to `proicon`. */\r\n attributeName: string,\r\n /** Determines whether to overwrite elements when converting to icons. Setting this to `auto` will overwrite only if the element does not have any children. Defaults to `auto`. */\r\n overwrite: boolean | 'auto',\r\n /** Determines whether to apply existing HTMl attributes such as styles to the converted SVGs. Defaults to `true` */\r\n useAttributes: false\r\n}\r\n\r\nexport class ProIconInfo {\r\n name: string;\r\n kebabCase: string;\r\n camelCase: string;\r\n element: SVGSVGElement;\r\n category: string;\r\n tags: string[];\r\n /**\r\n * \r\n * @param name The name of the icon in Friendly Form\r\n * @param kebabCase The name of the icon in kebab-case\r\n * @param camelCase The name of the icon in camelCase\r\n * @param element The icon as an `SVGSVGElement`. Use the `outerHTML` property on this to return the icon as a string.\r\n * @param category The category of the icon.\r\n * @param tags An array of the icon's tags.\r\n */\r\n constructor(\r\n name: string,\r\n kebabCase: string,\r\n camelCase: string,\r\n element: SVGSVGElement,\r\n tags: string[],\r\n category: string\r\n ) {\r\n this.name = name;\r\n this.kebabCase = kebabCase;\r\n this.camelCase = camelCase;\r\n this.element = element;\r\n this.category = category;\r\n this.tags = tags;\r\n }\r\n}","function removeParenthesis(str) {\r\n return str.replace(/[()]/g, '')\r\n}\r\nfunction camelCase(str) {\r\n return removeParenthesis(str).split(' ').map((word, i) => i == 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1)).join('')\r\n}\r\nfunction kebabCase(str) {\r\n return removeParenthesis(str).replaceAll(' ', '-').toLowerCase()\r\n}\r\nexport default { camelCase, kebabCase };","import icons from './configs/icons.json';\r\nimport tags from './configs/tags.json';\r\nimport { ProIconInfo } from './interfaces';\r\nimport rename from '../bin/rename';\r\n\r\n/**\r\n * Returns information about an icon from the provided key.\r\n * Throws an error if the provided key does not match an icon name in Friendly Form, camelCase or kebab-case. Use the method `search` instead to return icons that contain a keyword inside its name or tags.\r\n * @param key The icon name in Friendly Form, camelCase or kebab-case. Throws an error if the provided key is invalid. Case-insensitive\r\n * @example The following keys are valid:\r\n * getIconInfo('Add Square')\r\n * getIconInfo('addSquare')\r\n * getIconInfo('add-square')\r\n */\r\nfunction getIconInfo(key: string): ProIconInfo {\r\n let prop: string;\r\n\r\n const isFriendly = (t: string) => t.toLowerCase() == key.toLowerCase();\r\n const isKebab = (t: string) => rename.kebabCase(t.toLowerCase()) == rename.kebabCase(key.toLowerCase());\r\n const isCamel = isFriendly\r\n\r\n if (Object.keys(tags).some(isFriendly)) {\r\n prop = rename.camelCase(Object.keys(tags).find(isFriendly));\r\n\r\n } else if (Object.keys(tags).some(isKebab)) {\r\n prop = rename.camelCase(Object.keys(tags).find(isKebab));\r\n\r\n } else if (Object.keys(icons).some(isCamel)) {\r\n // @ts-ignore\r\n prop = Object.keys(icons).find(isCamel);\r\n\r\n } else {\r\n throw new Error(`Invalid icon key '${key}': Icon not found`);\r\n }\r\n\r\n const friendlyName = Object.keys(tags).find((t) => {\r\n return rename.camelCase(t) == prop;\r\n });\r\n\r\n const domParser = new DOMParser();\r\n const parsed = domParser.parseFromString(icons[prop], 'image/svg+xml');\r\n\r\n const tagItem = tags[friendlyName]\r\n const info = new ProIconInfo(\r\n friendlyName, //friendly\r\n rename.kebabCase(friendlyName), //kebab\r\n prop, //camel\r\n parsed.querySelector('svg'), //svg\r\n tagItem.description?.split(',').map(m => m.trim()), //desc\r\n tagItem.category, //tags\r\n );\r\n return info;\r\n}\r\n\r\nexport default getIconInfo","// @ts-nocheck\r\nimport getIconInfo from './getIconInfo'\r\nimport { ProIconReplaceConfig, ProIconInfo } from './interfaces';\r\n\r\n/**\r\n * Converts all elements with the `proicon` attribute (which can be customised in the config) on the page to an icon corresponding to the attribute value.\r\n * @param rootElm The element to search inside for children with the `proicon` attribute. Defaults to `document.body`.\r\n * @param config An optional configuration to customise the behaviour of the replace method\r\n */\r\nfunction replace(rootElm?: Element, config?: ProIconReplaceConfig): void {\r\n if (!rootElm) rootElm = document.body;\r\n const useAttrs = config?.useAttributes ?? true\r\n\r\n const attr = config?.attributeName ?? 'proicon';\r\n rootElm.querySelectorAll(`[${attr}]`).forEach((element) => {\r\n let toReplace;\r\n switch (config?.overwrite) {\r\n case true: toReplace = true; break;\r\n case false: toReplace = false; break;\r\n case 'auto': toReplace = !element.hasChildNodes(); break;\r\n default: toReplace = !element.hasChildNodes(); break;\r\n }\r\n\r\n let iconName = element.getAttribute(attr).trim()\r\n let icon: SVGElement = getIconInfo(iconName).element\r\n\r\n const attributeList = {\r\n // HtmlAttribute, configKey, svgAttr\r\n \"color\": [\"color\", [\"stroke\", 'fill']],\r\n \"stroke-width\": [\"strokeWidth\", [\"stroke-width\"]],\r\n \"join\": [\"strokeCaps\", [\"stroke-linejoin\"]],\r\n \"caps\": [\"strokeJoin\", [\"stroke-linecap\"]],\r\n \"corner-radius\": [\"cornerRadius\", [\"rx\"]],\r\n \"outline\": [\"strokeFilledElements\", undefined]\r\n }\r\n if (config) {\r\n Object.values(attributeList)\r\n .map((v) => v[0])\r\n .forEach((c, i) => {\r\n const htmlAttr = Object.keys(attributeList)[i];\r\n let valueToUse\r\n\r\n if (useAttrs && element.hasAttribute(htmlAttr)) {\r\n valueToUse = element.getAttribute(htmlAttr)\r\n } else if (config[c]) {\r\n valueToUse = config[c]\r\n }\r\n\r\n if (valueToUse) {\r\n element.setAttribute(htmlAttr, valueToUse);\r\n }\r\n });\r\n }\r\n for (const attr of element.attributes) {\r\n const name = attr.name.toLowerCase()\r\n const value = attr.value\r\n\r\n if (Object.hasOwn(attributeList, name)) {\r\n if (name != 'outline') {\r\n if (value) {\r\n const n = attributeList[name][1]\r\n n.forEach(x => {\r\n icon.querySelectorAll(`[${x}]`).forEach(b => {\r\n b.setAttribute(x, value)\r\n })\r\n })\r\n }\r\n } else {\r\n // Behaviour for outlining\r\n const defaultStrokeWidth = 1.5\r\n const unstrokedElms = Array.from(icon.querySelectorAll('*')).filter(f => !f.hasAttribute('stroke'))\r\n\r\n unstrokedElms.forEach(elm => {\r\n const reducedStroke = +element.getAttribute('stroke-width') - defaultStrokeWidth\r\n if (reducedStroke > 0) {\r\n elm.setAttribute('stroke', element.getAttribute('color') ?? 'currentColor')\r\n elm.setAttribute('stroke-width', reducedStroke)\r\n elm.setAttribute('stroke-linejoin', element.getAttribute('strokeJoin') ?? 'round')\r\n elm.setAttribute('stroke-linecap', element.getAttribute('strokeCaps') ?? 'round')\r\n }\r\n })\r\n }\r\n } else {\r\n icon.setAttribute(name, value)\r\n }\r\n }\r\n\r\n\r\n icon.classList.add('proicon')\r\n icon.setAttribute('data-proicon-id', getIconInfo(iconName).kebabCase)\r\n\r\n toReplace == true ? element.replaceWith(icon)\r\n : element.insertBefore(icon, element.childNodes[0])\r\n });\r\n}\r\n\r\nexport default replace\r\n","import getIconInfo from \"./getIconInfo\"\r\nimport tags from './configs/tags.json'\r\nimport icons from './configs/icons.json'\r\nimport { ProIconInfo } from \"./interfaces\"\r\n\r\n/** Searches for icons with names or tags that contain `key` and returns them as `ProIconInfo`. */\r\nfunction search(key: string): ProIconInfo[] {\r\n const iconsAsInfo = Object.keys(icons).map((icon) => {\r\n // Don't index the element\r\n const j = getIconInfo(icon)\r\n delete j.element\r\n return j\r\n })\r\n const filtered = iconsAsInfo.filter((icon) => JSON.stringify(icon).includes(key))\r\n\r\n return filtered\r\n}\r\n\r\nexport default search"],"names":["categories","icons","item","value","index","self","ProIconInfo","name","kebabCase","camelCase","element","tags","category","removeParenthesis","str","word","i","rename","getIconInfo","key","prop","isFriendly","t","isKebab","isCamel","friendlyName","parsed","tagItem","_a","m","replace","rootElm","config","useAttrs","attr","_b","toReplace","iconName","icon","attributeList","v","c","htmlAttr","valueToUse","x","b","f","elm","reducedStroke","_c","search","j"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAE,QAAaC,GAAA,CACvCA,EAAA,aAAaD,EAAGzC,CAAK,CAAA,CAC1B,CAAA,CACJ,EAKiB,MAAM,KAAKmC,EAAK,iBAAiB,GAAG,CAAC,EAAE,OAAYQ,GAAA,CAACA,EAAE,aAAa,QAAQ,CAAC,EAEpF,QAAeC,GAAA,WACzB,MAAMC,EAAgB,CAACtC,EAAQ,aAAa,cAAc,EAAI,IAC1DsC,EAAgB,IAChBD,EAAI,aAAa,UAAUnB,EAAAlB,EAAQ,aAAa,OAAO,IAA5B,KAAAkB,EAAiC,cAAc,EACtEmB,EAAA,aAAa,eAAgBC,CAAa,EAC9CD,EAAI,aAAa,mBAAmBZ,EAAAzB,EAAQ,aAAa,YAAY,IAAjC,KAAAyB,EAAsC,OAAO,EACjFY,EAAI,aAAa,kBAAkBE,EAAAvC,EAAQ,aAAa,YAAY,IAAjC,KAAAuC,EAAsC,OAAO,EACpF,CACH,EAGAX,EAAA,aAAa/B,EAAMJ,CAAK,CAErC,CAGKmC,EAAA,UAAU,IAAI,SAAS,EAC5BA,EAAK,aAAa,kBAAmBpB,EAAYmB,CAAQ,EAAE,SAAS,EAEvDD,GAAA,GAAO1B,EAAQ,YAAY4B,CAAI,EACtC5B,EAAQ,aAAa4B,EAAM5B,EAAQ,WAAW,CAAC,CAAC,CAAA,CACzD,CACL,CCxFA,SAASwC,EAAO/B,EAA4B,CASjC,OARa,OAAO,KAAKlB,CAAK,EAAE,IAAKqC,GAAS,CAE3C,MAAAa,EAAIjC,EAAYoB,CAAI,EAC1B,cAAOa,EAAE,QACFA,CAAA,CACV,EAC4B,OAAQb,GAAS,KAAK,UAAUA,CAAI,EAAE,SAASnB,CAAG,CAAC,CAGpF"}
@@ -1,2 +1,3 @@
1
+ /** List of all icon categories */
1
2
  declare const categories: string[];
2
3
  export default categories;
@@ -1,3 +1,12 @@
1
1
  import { ProIconInfo } from './interfaces';
2
+ /**
3
+ * Returns information about an icon from the provided key.
4
+ * Throws an error if the provided key does not match an icon name in Friendly Form, camelCase or kebab-case. Use the method `search` instead to return icons that contain a keyword inside its name or tags.
5
+ * @param key The icon name in Friendly Form, camelCase or kebab-case. Throws an error if the provided key is invalid. Case-insensitive
6
+ * @example The following keys are valid:
7
+ * getIconInfo('Add Square')
8
+ * getIconInfo('addSquare')
9
+ * getIconInfo('add-square')
10
+ */
2
11
  declare function getIconInfo(key: string): ProIconInfo;
3
12
  export default getIconInfo;
@@ -1,20 +1,40 @@
1
1
  export interface ProIconReplaceConfig {
2
+ /** Determines the color of the icons. Defaults to `currentColor`. */
2
3
  color: string;
4
+ /** Determines the default stroke width of the icon. Defaults to `1.5`. This only works on SVG elements with existing strokes; add `strokeFilledElements` for this property to affect such elements. */
3
5
  strokeWidth: number;
6
+ /** Apply strokes to filled SVG elements, such as circles, by the provided amount with `1.5` (default stroke value) subtracted, if `strokeWidth` is set to a value above `1.5`. Defaults to `false`
7
+ * @example If `strokeWidth` is set to `2`, filled SVG elements will have an additional `0.5`px stroke
8
+ */
4
9
  strokeFilledElements: boolean;
10
+ /** Defaults to `round` */
5
11
  strokeCaps: 'round' | 'square' | 'butt';
12
+ /** Defaults to `round` */
6
13
  strokeJoin: 'round' | 'miter' | 'bevel';
14
+ /** Determines the corner radius of SVG elements. Does not apply to all rounded elements. */
7
15
  cornerRadius: number;
16
+ /** The attribute name that is checked for when converting elements to icons. Defaults to `proicon`. */
8
17
  attributeName: string;
18
+ /** Determines whether to overwrite elements when converting to icons. Setting this to `auto` will overwrite only if the element does not have any children. Defaults to `auto`. */
9
19
  overwrite: boolean | 'auto';
20
+ /** Determines whether to apply existing HTMl attributes such as styles to the converted SVGs. Defaults to `true` */
10
21
  useAttributes: false;
11
22
  }
12
23
  export declare class ProIconInfo {
13
24
  name: string;
14
25
  kebabCase: string;
15
26
  camelCase: string;
16
- element: SVGElement;
27
+ element: SVGSVGElement;
17
28
  category: string;
18
29
  tags: string[];
19
- constructor(name: string, kebabCase: string, camelCase: string, element: SVGElement, tags: string[], category: string);
30
+ /**
31
+ *
32
+ * @param name The name of the icon in Friendly Form
33
+ * @param kebabCase The name of the icon in kebab-case
34
+ * @param camelCase The name of the icon in camelCase
35
+ * @param element The icon as an `SVGSVGElement`. Use the `outerHTML` property on this to return the icon as a string.
36
+ * @param category The category of the icon.
37
+ * @param tags An array of the icon's tags.
38
+ */
39
+ constructor(name: string, kebabCase: string, camelCase: string, element: SVGSVGElement, tags: string[], category: string);
20
40
  }
package/lib/proicons.d.ts CHANGED
@@ -1,440 +1,8 @@
1
+ import icons from './configs/icons.json';
2
+ import categories from './categories';
1
3
  import replace from './replace';
2
4
  import getIconInfo from './getIconInfo';
3
5
  import search from './search';
4
- declare const _default: {
5
- icons: {
6
- add: string;
7
- addCircular: string;
8
- addRhombus: string;
9
- addSquare: string;
10
- addSquareMultiple: string;
11
- "addSquareMultiple-Var": string;
12
- appRemove: string;
13
- apps: string;
14
- appsAdd: string;
15
- backspace: string;
16
- cancel: string;
17
- checkmark: string;
18
- compose: string;
19
- copy: string;
20
- "copy-Var": string;
21
- crop: string;
22
- cut: string;
23
- delete: string;
24
- eye: string;
25
- eyeOff: string;
26
- fastFoward: string;
27
- heart: string;
28
- heartStylistic: string;
29
- keyboardShift: string;
30
- more: string;
31
- moreVertical: string;
32
- pause: string;
33
- pencil: string;
34
- play: string;
35
- playCircular: string;
36
- reverse: string;
37
- search: string;
38
- star: string;
39
- tune: string;
40
- checkmarkStarburst: string;
41
- creditCard: string;
42
- lock: string;
43
- lockOpen: string;
44
- shield: string;
45
- shieldCancel: string;
46
- shieldCheckmark: string;
47
- shieldKeyhole: string;
48
- chat: string;
49
- cloud: string;
50
- comment: string;
51
- commentMultiple: string;
52
- "commentMultiple-Var": string;
53
- database: string;
54
- databaseAdd: string;
55
- globe: string;
56
- mail: string;
57
- mailOpen: string;
58
- megaphone: string;
59
- megaphoneLoud: string;
60
- mention: string;
61
- narrator: string;
62
- person: string;
63
- person2: string;
64
- personAdd: string;
65
- personAdd2: string;
66
- personCircle: string;
67
- personMultiple: string;
68
- phoneAccept: string;
69
- phoneHangUp: string;
70
- send: string;
71
- "wi-fi": string;
72
- anchor: string;
73
- attatch: string;
74
- bookInfo2: string;
75
- calendar: string;
76
- diamond: string;
77
- eraser: string;
78
- eyedropper: string;
79
- eyedropperColor: string;
80
- flashlight: string;
81
- gift: string;
82
- hatGraduation: string;
83
- highlighter: string;
84
- hourglass: string;
85
- layers: string;
86
- lightbulb: string;
87
- link: string;
88
- microphone: string;
89
- microphoneOff: string;
90
- pin: string;
91
- pinOff: string;
92
- timer: string;
93
- wrench: string;
94
- alertCircle: string;
95
- alertTriangle: string;
96
- arrowSync: string;
97
- arrowSync2: string;
98
- badge: string;
99
- bell: string;
100
- cancelCircle: string;
101
- cancelSquare: string;
102
- checkmarkCircle: string;
103
- clock: string;
104
- doNotDisturb: string;
105
- info: string;
106
- prohibited: string;
107
- spinner: string;
108
- emoji: string;
109
- emojiFrown: string;
110
- emojiGrin: string;
111
- emojiLaughter: string;
112
- skull: string;
113
- arrowClockwise: string;
114
- arrowCounterclockwise: string;
115
- arrowDown: string;
116
- arrowDownload: string;
117
- arrowEnter: string;
118
- arrowExport: string;
119
- arrowFoward: string;
120
- arrowImport: string;
121
- arrowLeft: string;
122
- arrowMove: string;
123
- arrowRedo: string;
124
- arrowRedo2: string;
125
- arrowReply: string;
126
- arrowRight: string;
127
- arrowRotateClockwise: string;
128
- arrowRotateCounterclockwise: string;
129
- arrowSort: string;
130
- arrowSwap: string;
131
- arrowTrending: string;
132
- arrowUndo: string;
133
- arrowUndo2: string;
134
- arrowUp: string;
135
- arrowUpDown: string;
136
- arrowUpload: string;
137
- chevronDown: string;
138
- chevronLeft: string;
139
- chevronRight: string;
140
- chevronUp: string;
141
- subtract: string;
142
- document: string;
143
- drawText: string;
144
- note: string;
145
- noteAdd: string;
146
- quote: string;
147
- spacebar: string;
148
- symbols: string;
149
- text: string;
150
- textAdd: string;
151
- textAlignCenter: string;
152
- textAlignJustify: string;
153
- textAlignLeft: string;
154
- textAlignRight: string;
155
- textBold: string;
156
- textCaseLowercase: string;
157
- textCaseTitle: string;
158
- textCaseUppercase: string;
159
- textClearFormatting: string;
160
- textCollapse: string;
161
- textColor: string;
162
- textEditStyle: string;
163
- textEffects: string;
164
- textExpand: string;
165
- textFont: string;
166
- textFontSize: string;
167
- textFootnote: string;
168
- textHighlightColor: string;
169
- textIndentDecrease: string;
170
- textIndentIncrease: string;
171
- textItalic: string;
172
- textLarge: string;
173
- textLetterSpacing: string;
174
- textLineHeight: string;
175
- textLineSpacing: string;
176
- textNumberList: string;
177
- textPositionBottom: string;
178
- textPositionMiddle: string;
179
- textPositionTop: string;
180
- textSmall: string;
181
- textStrikethrough: string;
182
- textSubscript: string;
183
- textSuperscript: string;
184
- textTypography: string;
185
- textUnderline: string;
186
- file: string;
187
- fileAdd: string;
188
- fileSync: string;
189
- folder: string;
190
- folderAdd: string;
191
- folderOpen: string;
192
- hardDrive: string;
193
- pdf: string;
194
- pdf2: string;
195
- photo: string;
196
- qrCode: string;
197
- save: string;
198
- saveAs: string;
199
- accessibility: string;
200
- battery: string;
201
- batteryFull: string;
202
- button: string;
203
- checkboxIntermediate2: string;
204
- checkboxUnchecked: string;
205
- checkmarkChecked: string;
206
- checkmarkIntermediate: string;
207
- closedCaptions: string;
208
- cursor: string;
209
- cursorClick: string;
210
- darkTheme: string;
211
- extension: string;
212
- menu: string;
213
- settings: string;
214
- zoomIn: string;
215
- zoomOut: string;
216
- airplane: string;
217
- airplaneLanding: string;
218
- airplaneTakeoff: string;
219
- beach: string;
220
- buildingMultiple: string;
221
- component: string;
222
- directions: string;
223
- home: string;
224
- home2: string;
225
- location: string;
226
- map: string;
227
- museum: string;
228
- vehicleCar: string;
229
- barGraph: string;
230
- boxMargins: string;
231
- clipboard: string;
232
- clipboardPaste: string;
233
- clipboardSearch: string;
234
- compareSize: string;
235
- grid: string;
236
- gridDots: string;
237
- layout: string;
238
- pageMargins: string;
239
- panelLeft: string;
240
- panelLeftContract: string;
241
- panelLeftExpand: string;
242
- panelLeftOpen: string;
243
- panelRight: string;
244
- panelRightContract: string;
245
- panelRightExpand: string;
246
- table: string;
247
- tableSimple: string;
248
- backgroundColor: string;
249
- borderAll: string;
250
- colorPalette: string;
251
- mask: string;
252
- paintBucket: string;
253
- paintbrush: string;
254
- paintbrush2: string;
255
- shapeDifference: string;
256
- shapeIntersect: string;
257
- shapeSubtract: string;
258
- shapeUnion: string;
259
- strokeThickness: string;
260
- arrowMaximize: string;
261
- arrowMinimize: string;
262
- chromeRestore: string;
263
- "chromeRestore-Var": string;
264
- contractDown: string;
265
- expand: string;
266
- fullScreenMaximize: string;
267
- fullScreenMinimize: string;
268
- open: string;
269
- pictureInPicture: string;
270
- pictureInPicture2: string;
271
- pictureInPictureEnter: string;
272
- pictureInPictureExit: string;
273
- window: string;
274
- windowMultiple: string;
275
- "windowMultiple-Var": string;
276
- beaker: string;
277
- braces: string;
278
- bracesVariable: string;
279
- branch: string;
280
- branchCompare: string;
281
- branchFork: string;
282
- branchFork2: string;
283
- bug: string;
284
- code: string;
285
- gitCommit: string;
286
- script: string;
287
- script2: string;
288
- terminal: string;
289
- videoClip: string;
290
- arc: string;
291
- circle: string;
292
- circleSmall: string;
293
- cornerRadius: string;
294
- hexagon: string;
295
- lineDiagonal: string;
296
- octagon: string;
297
- pentagon: string;
298
- rectangleWide: string;
299
- rhombus: string;
300
- square: string;
301
- triangle: string;
302
- backgroundColorAccent: string;
303
- eyedropperColorAccent: string;
304
- highlighterAccent: string;
305
- paintBucketAccent: string;
306
- tagAccent: string;
307
- textColorAccent: string;
308
- textHighlightColorAccent: string;
309
- amazon: string;
310
- appStore: string;
311
- apple: string;
312
- bluetooth: string;
313
- css: string;
314
- facebook: string;
315
- figma: string;
316
- github: string;
317
- google: string;
318
- google2: string;
319
- googleChrome: string;
320
- googlePlay: string;
321
- html: string;
322
- instagram: string;
323
- javascript: string;
324
- microsoft: string;
325
- microsoftEdge: string;
326
- python: string;
327
- roblox: string;
328
- tiktok: string;
329
- visualStudioCode: string;
330
- xTwitter: string;
331
- youtube: string;
332
- youtubeShorts: string;
333
- book: string;
334
- book2: string;
335
- bookAdd: string;
336
- bookAdd2: string;
337
- bookInfo: string;
338
- bookOpen: string;
339
- box: string;
340
- broom: string;
341
- calligraphyPen: string;
342
- cart: string;
343
- compass: string;
344
- flag: string;
345
- library: string;
346
- photoFilter: string;
347
- ribbon: string;
348
- ribbonStar: string;
349
- video: string;
350
- briefcase: string;
351
- briefcase2: string;
352
- cent: string;
353
- dollar: string;
354
- graph: string;
355
- toolbox: string;
356
- cake: string;
357
- coffeeHot: string;
358
- cookies: string;
359
- drop: string;
360
- hamburger: string;
361
- boxDrag: string;
362
- cursorDrag: string;
363
- hand: string;
364
- thumbsDown: string;
365
- thumbsUp: string;
366
- angle: string;
367
- calculator: string;
368
- hash: string;
369
- ruler: string;
370
- screenSize: string;
371
- headphones: string;
372
- movie: string;
373
- musicNote: string;
374
- musicNote2: string;
375
- soundwave: string;
376
- volume: string;
377
- volume0: string;
378
- volume1: string;
379
- volumeMute: string;
380
- leaf: string;
381
- leafThree: string;
382
- leafTwo: string;
383
- history: string;
384
- question: string;
385
- questionCircle: string;
386
- sparkle: string;
387
- alignBottom: string;
388
- alignHorizontalCenters: string;
389
- alignLeft: string;
390
- alignRight: string;
391
- alignTop: string;
392
- alignVerticalCenters: string;
393
- appsList: string;
394
- archive: string;
395
- archiveAdd2: string;
396
- board: string;
397
- bookmark: string;
398
- bookmarkAdd: string;
399
- bookmarkMultiple: string;
400
- "bookmarkMultiple-Var": string;
401
- centerHorizontal: string;
402
- centerVertical: string;
403
- filter: string;
404
- filter2: string;
405
- filterCancel: string;
406
- filterCancel2: string;
407
- sectionBreak: string;
408
- tag: string;
409
- tagMultiple: string;
410
- "tagMultiple-Var": string;
411
- taskList: string;
412
- textBulletList: string;
413
- textBulletListSquare: string;
414
- textBulletListSquareAdd: string;
415
- camera: string;
416
- computer: string;
417
- computerMac: string;
418
- foldableHorizontal: string;
419
- foldableHorizontalHalf: string;
420
- foldableVertical: string;
421
- foldableVerticalHalf: string;
422
- game: string;
423
- keyboard: string;
424
- laptop: string;
425
- motherboard: string;
426
- phone: string;
427
- printer: string;
428
- tv: string;
429
- tablet: string;
430
- watch: string;
431
- brightness: string;
432
- moon: string;
433
- weatherCloudy: string;
434
- };
435
- replace: typeof replace;
436
- getIconInfo: typeof getIconInfo;
437
- categories: string[];
438
- search: typeof search;
439
- };
440
- export default _default;
6
+ export {
7
+ /** List of all available icons with camelCase keys and SVG strings as values. */
8
+ icons, replace, getIconInfo, categories, search };
package/lib/replace.d.ts CHANGED
@@ -1,3 +1,8 @@
1
1
  import { ProIconReplaceConfig } from './interfaces';
2
+ /**
3
+ * Converts all elements with the `proicon` attribute (which can be customised in the config) on the page to an icon corresponding to the attribute value.
4
+ * @param rootElm The element to search inside for children with the `proicon` attribute. Defaults to `document.body`.
5
+ * @param config An optional configuration to customise the behaviour of the replace method
6
+ */
2
7
  declare function replace(rootElm?: Element, config?: ProIconReplaceConfig): void;
3
8
  export default replace;
package/lib/search.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { ProIconInfo } from "./interfaces";
2
+ /** Searches for icons with names or tags that contain `key` and returns them as `ProIconInfo`. */
2
3
  declare function search(key: string): ProIconInfo[];
3
4
  export default search;