@clubmed/trident-ui 1.0.0-alpha.36 → 1.0.0-alpha.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +56 -28
  3. package/atoms/Icons/Icon.js +8 -7
  4. package/atoms/Icons/IconsResolver.d.ts +4 -43
  5. package/atoms/Icons/IconsResolver.js +15 -38
  6. package/atoms/Icons/contexts/IconsContext.d.ts +43 -0
  7. package/atoms/Icons/contexts/IconsContext.js +46 -0
  8. package/atoms/Icons/fonts/Actions.d.ts +2 -1
  9. package/atoms/Icons/fonts/Actions.js +112 -106
  10. package/atoms/Icons/fonts/Activities.d.ts +2 -1
  11. package/atoms/Icons/fonts/Activities.js +144 -138
  12. package/atoms/Icons/fonts/Brand.d.ts +2 -1
  13. package/atoms/Icons/fonts/Brand.js +91 -85
  14. package/atoms/Icons/fonts/Covid.d.ts +2 -1
  15. package/atoms/Icons/fonts/Covid.js +60 -54
  16. package/atoms/Icons/fonts/FontIconResolver.d.ts +1 -1
  17. package/atoms/Icons/fonts/FontIconResolver.js +6 -7
  18. package/atoms/Icons/fonts/Food.d.ts +2 -1
  19. package/atoms/Icons/fonts/Food.js +105 -99
  20. package/atoms/Icons/fonts/HappyToCare.d.ts +2 -1
  21. package/atoms/Icons/fonts/HappyToCare.js +57 -51
  22. package/atoms/Icons/fonts/Places.d.ts +2 -1
  23. package/atoms/Icons/fonts/Places.js +60 -54
  24. package/atoms/Icons/fonts/Room.d.ts +2 -1
  25. package/atoms/Icons/fonts/Room.js +114 -108
  26. package/atoms/Icons/fonts/Services.d.ts +2 -1
  27. package/atoms/Icons/fonts/Services.js +72 -66
  28. package/atoms/Icons/fonts/Socials.d.ts +2 -1
  29. package/atoms/Icons/fonts/Socials.js +72 -66
  30. package/atoms/Icons/fonts/Transports.d.ts +2 -1
  31. package/atoms/Icons/fonts/Transports.js +48 -42
  32. package/atoms/Icons/fonts/Utilities.d.ts +2 -1
  33. package/atoms/Icons/fonts/Utilities.js +153 -147
  34. package/atoms/Icons/fonts/index.js +4 -4
  35. package/atoms/Icons/hooks/useIcon.d.ts +2 -0
  36. package/atoms/Icons/hooks/useIcon.js +16 -0
  37. package/atoms/Icons/index.js +9 -8
  38. package/atoms/Icons/svg/Actions.d.ts +2 -1
  39. package/atoms/Icons/svg/Actions.js +145 -139
  40. package/atoms/Icons/svg/Activities.d.ts +2 -1
  41. package/atoms/Icons/svg/Activities.js +189 -183
  42. package/atoms/Icons/svg/Brand.d.ts +2 -1
  43. package/atoms/Icons/svg/Brand.js +90 -84
  44. package/atoms/Icons/svg/Covid.d.ts +2 -1
  45. package/atoms/Icons/svg/Covid.js +77 -71
  46. package/atoms/Icons/svg/Food.d.ts +2 -1
  47. package/atoms/Icons/svg/Food.js +137 -131
  48. package/atoms/Icons/svg/HappyToCare.d.ts +2 -1
  49. package/atoms/Icons/svg/HappyToCare.js +73 -67
  50. package/atoms/Icons/svg/Places.d.ts +2 -1
  51. package/atoms/Icons/svg/Places.js +77 -71
  52. package/atoms/Icons/svg/ResortFill-EC.d.ts +2 -1
  53. package/atoms/Icons/svg/ResortFill-EC.js +135 -129
  54. package/atoms/Icons/svg/ResortFill.d.ts +2 -1
  55. package/atoms/Icons/svg/ResortFill.js +399 -393
  56. package/atoms/Icons/svg/ResortOutline-EC.d.ts +2 -1
  57. package/atoms/Icons/svg/ResortOutline-EC.js +135 -129
  58. package/atoms/Icons/svg/ResortOutline.d.ts +2 -1
  59. package/atoms/Icons/svg/ResortOutline.js +399 -393
  60. package/atoms/Icons/svg/Room.d.ts +2 -1
  61. package/atoms/Icons/svg/Room.js +149 -143
  62. package/atoms/Icons/svg/Services.d.ts +2 -1
  63. package/atoms/Icons/svg/Services.js +93 -87
  64. package/atoms/Icons/svg/Socials.d.ts +2 -1
  65. package/atoms/Icons/svg/Socials.js +83 -77
  66. package/atoms/Icons/svg/SvgIconResolver.d.ts +1 -2
  67. package/atoms/Icons/svg/SvgIconResolver.js +6 -8
  68. package/atoms/Icons/svg/Transports.d.ts +2 -1
  69. package/atoms/Icons/svg/Transports.js +61 -55
  70. package/atoms/Icons/svg/Utilities.d.ts +2 -1
  71. package/atoms/Icons/svg/Utilities.js +201 -195
  72. package/atoms/Icons/svg/index.js +3 -2
  73. package/atoms/Icons/svg-use/Actions.d.ts +2 -1
  74. package/atoms/Icons/svg-use/Actions.js +156 -150
  75. package/atoms/Icons/svg-use/Activities.d.ts +2 -1
  76. package/atoms/Icons/svg-use/Activities.js +195 -189
  77. package/atoms/Icons/svg-use/Brand.d.ts +2 -1
  78. package/atoms/Icons/svg-use/Brand.js +97 -91
  79. package/atoms/Icons/svg-use/Covid.d.ts +2 -1
  80. package/atoms/Icons/svg-use/Covid.js +80 -74
  81. package/atoms/Icons/svg-use/Food.d.ts +2 -1
  82. package/atoms/Icons/svg-use/Food.js +145 -139
  83. package/atoms/Icons/svg-use/HappyToCare.d.ts +2 -1
  84. package/atoms/Icons/svg-use/HappyToCare.js +78 -72
  85. package/atoms/Icons/svg-use/Places.d.ts +2 -1
  86. package/atoms/Icons/svg-use/Places.js +83 -77
  87. package/atoms/Icons/svg-use/ResortFill-EC.d.ts +2 -1
  88. package/atoms/Icons/svg-use/ResortFill-EC.js +141 -135
  89. package/atoms/Icons/svg-use/ResortFill.d.ts +2 -1
  90. package/atoms/Icons/svg-use/ResortFill.js +410 -404
  91. package/atoms/Icons/svg-use/ResortOutline-EC.d.ts +2 -1
  92. package/atoms/Icons/svg-use/ResortOutline-EC.js +144 -138
  93. package/atoms/Icons/svg-use/ResortOutline.d.ts +2 -1
  94. package/atoms/Icons/svg-use/ResortOutline.js +408 -402
  95. package/atoms/Icons/svg-use/Room.d.ts +2 -1
  96. package/atoms/Icons/svg-use/Room.js +159 -153
  97. package/atoms/Icons/svg-use/Services.d.ts +2 -1
  98. package/atoms/Icons/svg-use/Services.js +97 -91
  99. package/atoms/Icons/svg-use/Socials.d.ts +2 -1
  100. package/atoms/Icons/svg-use/Socials.js +85 -79
  101. package/atoms/Icons/svg-use/SvgUseIconResolver.d.ts +1 -2
  102. package/atoms/Icons/svg-use/SvgUseIconResolver.js +8 -10
  103. package/atoms/Icons/svg-use/Transports.d.ts +2 -1
  104. package/atoms/Icons/svg-use/Transports.js +67 -61
  105. package/atoms/Icons/svg-use/Utilities.d.ts +2 -1
  106. package/atoms/Icons/svg-use/Utilities.js +212 -206
  107. package/atoms/Icons/svg-use/index.js +3 -2
  108. package/atoms/Icons/utils/getIcons.d.ts +4 -0
  109. package/atoms/Icons/utils/getIcons.js +21 -0
  110. package/fonts/Actions/tui-actions.css +6 -6
  111. package/fonts/Actions/tui-actions.eot +0 -0
  112. package/fonts/Actions/tui-actions.less +6 -6
  113. package/fonts/Actions/tui-actions.module.less +6 -6
  114. package/fonts/Actions/tui-actions.scss +6 -6
  115. package/fonts/Actions/tui-actions.styl +6 -6
  116. package/fonts/Actions/tui-actions.ttf +0 -0
  117. package/fonts/Actions/tui-actions.woff +0 -0
  118. package/fonts/Actions/tui-actions.woff2 +0 -0
  119. package/fonts/Activities/tui-activities.css +6 -6
  120. package/fonts/Activities/tui-activities.eot +0 -0
  121. package/fonts/Activities/tui-activities.less +6 -6
  122. package/fonts/Activities/tui-activities.module.less +6 -6
  123. package/fonts/Activities/tui-activities.scss +6 -6
  124. package/fonts/Activities/tui-activities.styl +6 -6
  125. package/fonts/Activities/tui-activities.ttf +0 -0
  126. package/fonts/Activities/tui-activities.woff +0 -0
  127. package/fonts/Activities/tui-activities.woff2 +0 -0
  128. package/fonts/Brand/tui-brand.css +6 -6
  129. package/fonts/Brand/tui-brand.eot +0 -0
  130. package/fonts/Brand/tui-brand.less +6 -6
  131. package/fonts/Brand/tui-brand.module.less +6 -6
  132. package/fonts/Brand/tui-brand.scss +6 -6
  133. package/fonts/Brand/tui-brand.styl +6 -6
  134. package/fonts/Brand/tui-brand.ttf +0 -0
  135. package/fonts/Brand/tui-brand.woff +0 -0
  136. package/fonts/Brand/tui-brand.woff2 +0 -0
  137. package/fonts/Covid/tui-covid.css +6 -6
  138. package/fonts/Covid/tui-covid.eot +0 -0
  139. package/fonts/Covid/tui-covid.less +6 -6
  140. package/fonts/Covid/tui-covid.module.less +6 -6
  141. package/fonts/Covid/tui-covid.scss +6 -6
  142. package/fonts/Covid/tui-covid.styl +6 -6
  143. package/fonts/Covid/tui-covid.ttf +0 -0
  144. package/fonts/Covid/tui-covid.woff +0 -0
  145. package/fonts/Covid/tui-covid.woff2 +0 -0
  146. package/fonts/Food/tui-food.css +6 -6
  147. package/fonts/Food/tui-food.eot +0 -0
  148. package/fonts/Food/tui-food.less +6 -6
  149. package/fonts/Food/tui-food.module.less +6 -6
  150. package/fonts/Food/tui-food.scss +6 -6
  151. package/fonts/Food/tui-food.styl +6 -6
  152. package/fonts/Food/tui-food.ttf +0 -0
  153. package/fonts/Food/tui-food.woff +0 -0
  154. package/fonts/Food/tui-food.woff2 +0 -0
  155. package/fonts/HappyToCare/tui-happy-to-care.css +6 -6
  156. package/fonts/HappyToCare/tui-happy-to-care.eot +0 -0
  157. package/fonts/HappyToCare/tui-happy-to-care.less +6 -6
  158. package/fonts/HappyToCare/tui-happy-to-care.module.less +6 -6
  159. package/fonts/HappyToCare/tui-happy-to-care.scss +6 -6
  160. package/fonts/HappyToCare/tui-happy-to-care.styl +6 -6
  161. package/fonts/HappyToCare/tui-happy-to-care.ttf +0 -0
  162. package/fonts/HappyToCare/tui-happy-to-care.woff +0 -0
  163. package/fonts/HappyToCare/tui-happy-to-care.woff2 +0 -0
  164. package/fonts/Places/tui-places.css +6 -6
  165. package/fonts/Places/tui-places.eot +0 -0
  166. package/fonts/Places/tui-places.less +6 -6
  167. package/fonts/Places/tui-places.module.less +6 -6
  168. package/fonts/Places/tui-places.scss +6 -6
  169. package/fonts/Places/tui-places.styl +6 -6
  170. package/fonts/Places/tui-places.ttf +0 -0
  171. package/fonts/Places/tui-places.woff +0 -0
  172. package/fonts/Places/tui-places.woff2 +0 -0
  173. package/fonts/Room/tui-room.css +6 -6
  174. package/fonts/Room/tui-room.eot +0 -0
  175. package/fonts/Room/tui-room.less +6 -6
  176. package/fonts/Room/tui-room.module.less +6 -6
  177. package/fonts/Room/tui-room.scss +6 -6
  178. package/fonts/Room/tui-room.styl +6 -6
  179. package/fonts/Room/tui-room.ttf +0 -0
  180. package/fonts/Room/tui-room.woff +0 -0
  181. package/fonts/Room/tui-room.woff2 +0 -0
  182. package/fonts/Services/tui-services.css +6 -6
  183. package/fonts/Services/tui-services.eot +0 -0
  184. package/fonts/Services/tui-services.less +6 -6
  185. package/fonts/Services/tui-services.module.less +6 -6
  186. package/fonts/Services/tui-services.scss +6 -6
  187. package/fonts/Services/tui-services.styl +6 -6
  188. package/fonts/Services/tui-services.ttf +0 -0
  189. package/fonts/Services/tui-services.woff +0 -0
  190. package/fonts/Services/tui-services.woff2 +0 -0
  191. package/fonts/Socials/tui-socials.css +6 -6
  192. package/fonts/Socials/tui-socials.eot +0 -0
  193. package/fonts/Socials/tui-socials.less +6 -6
  194. package/fonts/Socials/tui-socials.module.less +6 -6
  195. package/fonts/Socials/tui-socials.scss +6 -6
  196. package/fonts/Socials/tui-socials.styl +6 -6
  197. package/fonts/Socials/tui-socials.ttf +0 -0
  198. package/fonts/Socials/tui-socials.woff +0 -0
  199. package/fonts/Socials/tui-socials.woff2 +0 -0
  200. package/fonts/Transports/tui-transports.css +6 -6
  201. package/fonts/Transports/tui-transports.eot +0 -0
  202. package/fonts/Transports/tui-transports.less +6 -6
  203. package/fonts/Transports/tui-transports.module.less +6 -6
  204. package/fonts/Transports/tui-transports.scss +6 -6
  205. package/fonts/Transports/tui-transports.styl +6 -6
  206. package/fonts/Transports/tui-transports.ttf +0 -0
  207. package/fonts/Transports/tui-transports.woff +0 -0
  208. package/fonts/Transports/tui-transports.woff2 +0 -0
  209. package/fonts/Utilities/tui-utilities.css +6 -6
  210. package/fonts/Utilities/tui-utilities.eot +0 -0
  211. package/fonts/Utilities/tui-utilities.less +6 -6
  212. package/fonts/Utilities/tui-utilities.module.less +6 -6
  213. package/fonts/Utilities/tui-utilities.scss +6 -6
  214. package/fonts/Utilities/tui-utilities.styl +6 -6
  215. package/fonts/Utilities/tui-utilities.ttf +0 -0
  216. package/fonts/Utilities/tui-utilities.woff +0 -0
  217. package/fonts/Utilities/tui-utilities.woff2 +0 -0
  218. package/molecules/Breadcrumb.js +5 -4
  219. package/molecules/Buttons/ButtonContent.js +5 -4
  220. package/molecules/Card.js +7 -6
  221. package/molecules/Forms/Checkbox.js +8 -7
  222. package/molecules/Forms/DateField.js +3 -2
  223. package/molecules/Forms/Filter.js +15 -14
  224. package/molecules/Forms/FormControl.js +9 -8
  225. package/molecules/Forms/NumberField.d.ts +2 -2
  226. package/molecules/Forms/TextField.js +11 -10
  227. package/molecules/Link.js +8 -7
  228. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ClubMed React UI components changelog
2
2
 
3
+ # [1.0.0-alpha.37](https://scm.clubmed.com/clubmed/cm-trident-ui/compare/v1.0.0-alpha.36...v1.0.0-alpha.37) (2024-04-09)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **icons:** use context to trigger change when icons are loaded ([4774acc](https://scm.clubmed.com/clubmed/cm-trident-ui/-/commit/4774acc2b2da16bb85ad5ba88fec11e36f1f7a09))
9
+
3
10
  # [1.0.0-alpha.36](https://scm.clubmed.com/clubmed/cm-trident-ui/compare/v1.0.0-alpha.35...v1.0.0-alpha.36) (2024-04-08)
4
11
 
5
12
 
package/README.md CHANGED
@@ -114,6 +114,8 @@ import App from './App';
114
114
  import React from 'react';
115
115
  import { createRoot } from 'react-dom/client';
116
116
  import { TridentUIConfigProvider } from '@clubmed/trident-ui';
117
+ import { IconsProvider } from '@clubmed/trident-ui/atoms/icons/contexts/IconsContext.js';
118
+ import Actions from '@clubmed/trident-ui/atoms/icons/svg/Actions';
117
119
 
118
120
  const baseName = (window as any).basename || '/';
119
121
 
@@ -124,7 +126,9 @@ createRoot(document.getElementById('root')!).render(
124
126
  locale: 'fr-FR',
125
127
  }}
126
128
  >
127
- <App />
129
+ <IconsProvider icons={[Actions]}>
130
+ <App />
131
+ </IconsProvider>
128
132
  </TridentUIConfigProvider>
129
133
  </React.StrictMode>,
130
134
  );
@@ -164,31 +168,53 @@ By default, no icons provider is set. You have to import a subset icons in your
164
168
  Svg mode:
165
169
 
166
170
  ```tsx
167
- import '@clubmed/trident-ui/atoms/Icons/svg/Actions'; // load only the Actions subset using SVG mode
171
+ import Actions from '@clubmed/trident-ui/atoms/Icons/svg/Actions'; // load only the Actions subset using SVG mode
172
+ import { Icon } from '@clubmed/trident-ui/atoms/Icons/Icon';
173
+
174
+ function App() {
175
+ return (
176
+ <IconsProvider icons={[Actions]}>
177
+ <Icon name="ArrowDefaultLeft" />
178
+ </IconsProvider>
179
+ );
180
+ }
168
181
  ```
169
182
 
170
183
  Fonts mode:
171
184
 
172
185
  ```tsx
173
- import '@clubmed/trident-ui/atoms/Icons/fonts/Actions'; // load the Actions subset
186
+ import Actions from '@clubmed/trident-ui/atoms/Icons/fonts/Actions'; // load the Actions subset
174
187
  import '@clubmed/trident-ui/fonts/tui-actions.css'; // load css rules for Actions
188
+ import { Icon } from '@clubmed/trident-ui/atoms/Icons/Icon';
189
+
190
+ function App() {
191
+ return (
192
+ <IconsProvider icons={[Actions]}>
193
+ <Icon name="ArrowDefaultLeft" />
194
+ </IconsProvider>
195
+ );
196
+ }
175
197
  ```
176
198
 
177
199
  You can mix usage of SVG and fonts mode:
178
200
 
179
201
  ```tsx
180
- import '@clubmed/trident-ui/atoms/Icons/fonts/Actions'; // load the Actions subset
202
+ import Actions from '@clubmed/trident-ui/atoms/Icons/fonts/Actions'; // load the Actions subset
181
203
  import '@clubmed/trident-ui/fonts/tui-actions.css'; // load css rules for Actions
182
- import '@clubmed/trident-ui/Icons/svg/Brand';
183
- ```
204
+ import Brand from '@clubmed/trident-ui/Icons/svg/Brand';
184
205
 
185
- In this case, Icon component will automatically use the appropriate IconResolver to load and display the icon.
186
-
187
- ```tsx
188
- <Icon name="ArrowDefaultLeft" /> // use Font provider
189
- <Icon name="ClubMed" /> // SVG provider
206
+ function App() {
207
+ return (
208
+ <IconsProvider icons={[Actions, Brand]}>
209
+ <Icon name="ArrowDefaultLeft" />
210
+ <Icon name="ClubMed" />
211
+ </IconsProvider>
212
+ );
213
+ }
190
214
  ```
191
215
 
216
+ > In this case, Icon component will automatically use the appropriate IconResolver to load and display the icon.
217
+
192
218
  ### Extra configuration for Svg use
193
219
 
194
220
  If you are using the `SvgUseIconProvider`, you have to instrument your bundler tool to resolve the url of the icons:
@@ -214,24 +240,26 @@ Trident UI provide function to register any external Svg icons (or font) without
214
240
  a custom Icon component. Just use `registerSvgIcon` or `registerFontIcon` to add your new icon:
215
241
 
216
242
  ```tsx
217
- import { registerSvgIcon } from '@/atoms/Icons/svg';
218
- registerSvgIcon({
219
- name: 'MyCustomIcon',
220
- group: 'custom',
221
- element: lazy(() => import('./MyCustomIcon.svg?react')),
222
- // viewBox: '0 0 30 30', // default '0 0 30 30'
223
- // aspectRatio: 1, // default '1'
224
- // orientation: 'left' // apply rotation to the icon
225
- });
226
- ```
243
+ import { resolver } from '@/atoms/Icons/svg/SvgIconResolver';
244
+
245
+ const CustomIcons = resolver([
246
+ {
247
+ name: 'MyCustomIcon',
248
+ group: 'custom',
249
+ element: lazy(() => import('./MyCustomIcon.svg?react')),
250
+ // viewBox: '0 0 30 30', // default '0 0 30 30'
251
+ // aspectRatio: 1, // default '1'
252
+ // orientation: 'left' // apply rotation to the icon
253
+ },
254
+ ]);
227
255
 
228
- ```tsx
229
- registerFontIcon('MyCustomIcon', {
230
- group: 'custom',
231
- prefix: 'tui-custom', // or icon- if it's a third parties icons library
232
- name: 'MyCustomIcon', // classname
233
- // orientation: 'left' // apply rotation to the icon
234
- });
256
+ function App() {
257
+ return (
258
+ <IconsProvider icons={[CustomIcons]}>
259
+ <Icon name="MyCustomIcon" />
260
+ </IconsProvider>
261
+ );
262
+ }
235
263
  ```
236
264
 
237
265
  ### Generate fonts from icons (dev)
@@ -1,12 +1,13 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { getIcon as i } from "./IconsResolver.js";
3
- function f(n) {
4
- const o = i(n.name, n.type);
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { c as t } from "../../index-Cu0xwYjD.js";
3
+ import { useIcon as e } from "./hooks/useIcon.js";
4
+ function l(n) {
5
+ const o = e(n.name, n.type);
5
6
  if (o === void 0)
6
7
  return null;
7
- const { component: t, ...c } = o;
8
- return /* @__PURE__ */ e(t, { ...n, ...c });
8
+ const { component: m, ...c } = o;
9
+ return /* @__PURE__ */ s(m, { ...n, ...c, className: t(c.className, n.className) });
9
10
  }
10
11
  export {
11
- f as Icon
12
+ l as Icon
12
13
  };
@@ -1,47 +1,8 @@
1
- import { FunctionComponent } from 'react';
2
- import type { CSS, Interpolation, SpringValue } from '@react-spring/web';
3
- import { IconOrientationProps } from './hooks/useIconOrientation.js';
4
- export interface IconProps extends IconOrientationProps {
5
- name: string;
6
- type?: string;
7
- /**
8
- * Width of the icon
9
- */
10
- width?: string | null;
11
- /**
12
- * Color
13
- */
14
- color?: string;
15
- /**
16
- * Additional class names
17
- */
18
- className?: string;
19
- /**
20
- * Additional styles
21
- */
22
- style?: {
23
- [key: string]: string | number | SpringValue<string> | SpringValue<number> | Interpolation<string, string> | CSS.Properties;
24
- };
25
- }
26
- export type IconResolverProps<Props extends IconProps = IconProps> = Props & {
27
- name: string;
28
- group?: string;
29
- withOrientation?: boolean;
30
- component: FunctionComponent<Props>;
31
- };
32
- export type IconsRegistryValue<Props extends IconProps = IconProps> = IconResolverProps<Props> & {
33
- key: string;
34
- };
35
- /**
36
- * Register an icon in the registry
37
- */
38
- export declare function registerIcon<Props extends IconProps = IconProps>(props: IconResolverProps<Props>): void;
1
+ import { IconProps, IconResolverProps } from './contexts/IconsContext.js';
2
+ export * from './contexts/IconsContext.js';
39
3
  /**
40
4
  * create function to register multiple icons at once.
41
5
  * It generates also the orientation for each icon if withOrientation is true
42
- * @param register
6
+ * @param resolver
43
7
  */
44
- export declare function registerIconsFactory<Props extends IconProps = IconProps>(register: (props: Omit<IconResolverProps<Props>, 'component'>) => void): (group: string, icons: Omit<IconResolverProps<Props>, 'component'>[]) => void;
45
- export declare function getIcon<Props extends IconProps = IconProps>(key: string, type?: string): IconsRegistryValue<Props> | undefined;
46
- export declare function getIcons(type: string): IconsRegistryValue<IconProps>[];
47
- export declare function getIconsByType(type: string): Map<string, IconsRegistryValue>;
8
+ export declare function resolverIconsFactory<Props extends IconProps = IconProps>(resolver: (props: Omit<IconResolverProps<Props>, 'component'>) => IconResolverProps<Props>): (group: string, icons: Omit<IconResolverProps<Props>, 'component'>[]) => IconResolverProps<Props>[];
@@ -1,42 +1,19 @@
1
1
  import { ORIENTATIONS as a } from "./hooks/useIconOrientation.js";
2
- const o = /* @__PURE__ */ new Map();
3
- function I(t) {
4
- const e = t.type || "default", n = c(e) || /* @__PURE__ */ new Map();
5
- o.set(e, n);
6
- const r = t.name + f(t.orientation);
7
- n.set(r, { ...t, type: e, key: r });
8
- }
9
- function l(t) {
10
- return (e, n) => {
11
- n.flatMap(({ name: r, withOrientation: s, ...i }) => (s ? Object.keys(a) : [""]).map((u) => ({
12
- ...i,
13
- name: r,
14
- orientation: u
15
- }))).forEach((r) => t({
16
- ...r,
17
- group: e
18
- }));
19
- };
20
- }
21
- function m(t, e = "default") {
22
- e === "default" && (e = o.keys().next().value);
23
- const n = c(e);
24
- return n == null ? void 0 : n.get(t);
25
- }
26
- function p(t) {
27
- const e = c(t);
28
- return e ? [...e.values()] : [];
29
- }
30
- function c(t) {
31
- return o.get(t);
32
- }
33
- function f(t) {
34
- return t ? t.charAt(0).toUpperCase() + t.slice(1) : "";
2
+ import { IconTypesRegistry as f, IconsContext as y, IconsProvider as l, loadIcons as x } from "./contexts/IconsContext.js";
3
+ function I(r) {
4
+ return (t, n) => n.flatMap(({ name: o, withOrientation: e, ...s }) => (e ? Object.keys(a) : [""]).map((c) => ({
5
+ ...s,
6
+ name: o,
7
+ orientation: c
8
+ }))).map((o) => r({
9
+ ...o,
10
+ group: t
11
+ }));
35
12
  }
36
13
  export {
37
- m as getIcon,
38
- p as getIcons,
39
- c as getIconsByType,
40
- I as registerIcon,
41
- l as registerIconsFactory
14
+ f as IconTypesRegistry,
15
+ y as IconsContext,
16
+ l as IconsProvider,
17
+ x as loadIcons,
18
+ I as resolverIconsFactory
42
19
  };
@@ -0,0 +1,43 @@
1
+ import { FunctionComponent, PropsWithChildren } from 'react';
2
+ import { IconOrientationProps } from '../hooks/useIconOrientation.js';
3
+ import type { CSS, Interpolation, SpringValue } from '@react-spring/web';
4
+ export interface IconProps extends IconOrientationProps {
5
+ name: string;
6
+ type?: string;
7
+ /**
8
+ * Width of the icon
9
+ */
10
+ width?: string | null;
11
+ /**
12
+ * Color
13
+ */
14
+ color?: string;
15
+ /**
16
+ * Additional class names
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Additional styles
21
+ */
22
+ style?: {
23
+ [key: string]: string | number | SpringValue<string> | SpringValue<number> | Interpolation<string, string> | CSS.Properties;
24
+ };
25
+ }
26
+ export type IconsRegistryValue<Props extends IconProps = IconProps> = IconResolverProps<Props> & {
27
+ key: string;
28
+ };
29
+ export type IconResolverProps<Props extends IconProps = IconProps> = Props & {
30
+ name: string;
31
+ group?: string;
32
+ withOrientation?: boolean;
33
+ component: FunctionComponent<Props>;
34
+ };
35
+ export declare const IconTypesRegistry: Map<string, Map<string, IconsRegistryValue<IconProps>>>;
36
+ export declare function loadIcons<Props extends IconProps = IconProps>(icons: IconResolverProps<Props>[] | IconResolverProps<Props>[][]): Map<string, Map<string, IconsRegistryValue<IconProps>>>;
37
+ export declare const IconsContext: import("react").Context<{
38
+ container: Map<string, Map<string, IconsRegistryValue>>;
39
+ updateContainer: (_: IconResolverProps[] | IconResolverProps[][]) => void;
40
+ }>;
41
+ export declare function IconsProvider<Props extends IconProps = IconProps>({ icons, children, }: PropsWithChildren<{
42
+ icons: IconResolverProps<Props>[] | IconResolverProps<Props>[][];
43
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,46 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { createContext as s, useState as u } from "react";
3
+ const r = /* @__PURE__ */ new Map();
4
+ function f(t) {
5
+ return t ? t.charAt(0).toUpperCase() + t.slice(1) : "";
6
+ }
7
+ function d(t) {
8
+ const e = t.type || "default", n = r.get(e) || /* @__PURE__ */ new Map();
9
+ r.set(e, n);
10
+ const o = t.name + f(t.orientation);
11
+ n.set(o, { ...t, type: e, key: o });
12
+ }
13
+ function c(t) {
14
+ return t.flat().forEach((e) => {
15
+ d(e);
16
+ }), r;
17
+ }
18
+ const p = s({
19
+ container: r,
20
+ updateContainer: () => {
21
+ }
22
+ });
23
+ function l({
24
+ icons: t,
25
+ children: e
26
+ }) {
27
+ const [n, o] = u(() => c(t));
28
+ return /* @__PURE__ */ i(
29
+ p.Provider,
30
+ {
31
+ value: {
32
+ container: n,
33
+ updateContainer: (a) => {
34
+ o(c(a));
35
+ }
36
+ },
37
+ children: e
38
+ }
39
+ );
40
+ }
41
+ export {
42
+ r as IconTypesRegistry,
43
+ p as IconsContext,
44
+ l as IconsProvider,
45
+ c as loadIcons
46
+ };
@@ -1 +1,2 @@
1
- export {};
1
+ declare const _default: import("..").IconResolverProps<import("./FontIcon").FontIconProps>[];
2
+ export default _default;
@@ -1,106 +1,112 @@
1
- import { registerFontIcons as e } from "./FontIconResolver.js";
2
- e("actions", [
3
- {
4
- name: "ArrowDefault",
5
- withOrientation: !0
6
- },
7
- {
8
- name: "ArrowFilled",
9
- withOrientation: !0
10
- },
11
- {
12
- name: "ArrowOutlined",
13
- withOrientation: !0
14
- },
15
- {
16
- name: "ArrowTail",
17
- withOrientation: !0
18
- },
19
- {
20
- name: "CheckDefault"
21
- },
22
- {
23
- name: "CheckFilled"
24
- },
25
- {
26
- name: "CheckOutlined"
27
- },
28
- {
29
- name: "Clipboard"
30
- },
31
- {
32
- name: "Compare"
33
- },
34
- {
35
- name: "CrossDefault"
36
- },
37
- {
38
- name: "CrossFilled"
39
- },
40
- {
41
- name: "CrossOutlined"
42
- },
43
- {
44
- name: "Delete"
45
- },
46
- {
47
- name: "Download"
48
- },
49
- {
50
- name: "Edit"
51
- },
52
- {
53
- name: "Error"
54
- },
55
- {
56
- name: "Expand"
57
- },
58
- {
59
- name: "HeartFilled"
60
- },
61
- {
62
- name: "HeartOutlined"
63
- },
64
- {
65
- name: "Information"
66
- },
67
- {
68
- name: "MinusDefault"
69
- },
70
- {
71
- name: "MinusFilled"
72
- },
73
- {
74
- name: "MinusOutlined"
75
- },
76
- {
77
- name: "New"
78
- },
79
- {
80
- name: "PlusDefault"
81
- },
82
- {
83
- name: "PlusFilled"
84
- },
85
- {
86
- name: "PlusOutlined"
87
- },
88
- {
89
- name: "Reduce"
90
- },
91
- {
92
- name: "Reload"
93
- },
94
- {
95
- name: "Search"
96
- },
97
- {
98
- name: "Share"
99
- },
100
- {
101
- name: "StarFilled"
102
- },
103
- {
104
- name: "StarOutlined"
105
- }
106
- ]);
1
+ import { resolver as e } from "./FontIconResolver.js";
2
+ const n = e(
3
+ "actions",
4
+ [
5
+ {
6
+ name: "ArrowDefault",
7
+ withOrientation: !0
8
+ },
9
+ {
10
+ name: "ArrowFilled",
11
+ withOrientation: !0
12
+ },
13
+ {
14
+ name: "ArrowOutlined",
15
+ withOrientation: !0
16
+ },
17
+ {
18
+ name: "ArrowTail",
19
+ withOrientation: !0
20
+ },
21
+ {
22
+ name: "CheckDefault"
23
+ },
24
+ {
25
+ name: "CheckFilled"
26
+ },
27
+ {
28
+ name: "CheckOutlined"
29
+ },
30
+ {
31
+ name: "Clipboard"
32
+ },
33
+ {
34
+ name: "Compare"
35
+ },
36
+ {
37
+ name: "CrossDefault"
38
+ },
39
+ {
40
+ name: "CrossFilled"
41
+ },
42
+ {
43
+ name: "CrossOutlined"
44
+ },
45
+ {
46
+ name: "Delete"
47
+ },
48
+ {
49
+ name: "Download"
50
+ },
51
+ {
52
+ name: "Edit"
53
+ },
54
+ {
55
+ name: "Error"
56
+ },
57
+ {
58
+ name: "Expand"
59
+ },
60
+ {
61
+ name: "HeartFilled"
62
+ },
63
+ {
64
+ name: "HeartOutlined"
65
+ },
66
+ {
67
+ name: "Information"
68
+ },
69
+ {
70
+ name: "MinusDefault"
71
+ },
72
+ {
73
+ name: "MinusFilled"
74
+ },
75
+ {
76
+ name: "MinusOutlined"
77
+ },
78
+ {
79
+ name: "New"
80
+ },
81
+ {
82
+ name: "PlusDefault"
83
+ },
84
+ {
85
+ name: "PlusFilled"
86
+ },
87
+ {
88
+ name: "PlusOutlined"
89
+ },
90
+ {
91
+ name: "Reduce"
92
+ },
93
+ {
94
+ name: "Reload"
95
+ },
96
+ {
97
+ name: "Search"
98
+ },
99
+ {
100
+ name: "Share"
101
+ },
102
+ {
103
+ name: "StarFilled"
104
+ },
105
+ {
106
+ name: "StarOutlined"
107
+ }
108
+ ]
109
+ );
110
+ export {
111
+ n as default
112
+ };
@@ -1 +1,2 @@
1
- export {};
1
+ declare const _default: import("..").IconResolverProps<import("./FontIcon").FontIconProps>[];
2
+ export default _default;