@agility/plenum-ui 2.0.0-rc27 → 2.0.0-rc29

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.
@@ -6,10 +6,10 @@ import { TablerIconName } from "./tablerIconNames";
6
6
  import { ClassNameWithAutocomplete } from "@/utils/types";
7
7
  export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons;
8
8
  export type FAIconName = keyof typeof FA;
9
- export type UnifiedIconName = TablerIconName;
9
+ export type UnifiedIconName = TablerIconName | IconName | FAIconName;
10
+ export declare function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons;
10
11
  export declare function isTablerIcon(name: UnifiedIconName): name is TablerIconName;
11
- export declare function isHeroIcon(name: UnifiedIconName): boolean;
12
- export declare function isFAIcon(name: UnifiedIconName): boolean;
12
+ export declare function isFAIcon(name: UnifiedIconName): name is keyof typeof FA;
13
13
  export declare function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName;
14
14
  export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
15
15
  icon: UnifiedIconName;
@@ -9,6 +9,7 @@ export interface IItemProp {
9
9
  onClick?(): void;
10
10
  isEmphasized?: boolean;
11
11
  key: React.Key;
12
+ iconObj?: JSX.Element;
12
13
  }
13
14
  export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
14
15
  items: IItemProp[][];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.0.0-rc27",
3
+ "version": "2.0.0-rc29",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -11,13 +11,13 @@ type Story = StoryObj<typeof DynamicIcon>
11
11
 
12
12
  export const HeroIconSolid: Story = {
13
13
  args: {
14
- icon: "IconTrash",
14
+ icon: "TrashIcon",
15
15
  outline: false
16
16
  }
17
17
  }
18
18
  export const HeroIconOutline: Story = {
19
19
  args: {
20
- icon: "IconTrash",
20
+ icon: "TrashIcon",
21
21
  outline: true
22
22
  }
23
23
  }
@@ -35,7 +35,7 @@ export const TablerIconOutline: Story = {
35
35
  }
36
36
  export const FAIcon: Story = {
37
37
  args: {
38
- icon: "IconBrandGithub",
38
+ icon: "FaGithub",
39
39
  outline: true
40
40
  }
41
41
  }
@@ -2,40 +2,30 @@ import React from "react"
2
2
  // TODO: Fix heroicons support
3
3
  import * as SolidIcons from "@heroicons/react/solid"
4
4
  import * as OutlineIcons from "@heroicons/react/outline"
5
- import * as TablerIconComponents from "@tabler/icons-react"
6
5
  import * as FA from "react-icons/fa"
7
6
  import { tablerIconNames, TablerIconName } from "./tablerIconNames"
8
7
  import { default as cn } from "classnames"
9
8
 
10
- import TablerIcon from "./TablerIcon"
11
9
  import { ClassNameWithAutocomplete } from "@/utils/types"
10
+ import TablerIcon from "./TablerIcon"
12
11
 
13
12
  export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons
14
-
15
13
  export type FAIconName = keyof typeof FA
16
14
 
17
- export type UnifiedIconName = TablerIconName //HACK to eliminate some icons...| IconName | FAIconName
15
+ export type UnifiedIconName = TablerIconName | IconName | FAIconName
18
16
 
19
- // export function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons {
20
- // return name in SolidIcons || name in OutlineIcons
21
- // }
17
+ export function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons {
18
+ return name in SolidIcons || name in OutlineIcons
19
+ }
22
20
 
23
21
  export function isTablerIcon(name: UnifiedIconName): name is TablerIconName {
24
22
  return tablerIconNames.includes(name as TablerIconName)
25
23
  }
26
24
 
27
- export function isHeroIcon(name: UnifiedIconName) {
28
- return false
25
+ export function isFAIcon(name: UnifiedIconName): name is keyof typeof FA {
26
+ return name in FA
29
27
  }
30
28
 
31
- export function isFAIcon(name: UnifiedIconName) {
32
- return false
33
- }
34
-
35
- // export function isFAIcon(name: UnifiedIconName): name is keyof typeof FA {
36
- // return name in FA
37
- // }
38
-
39
29
  export function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName {
40
30
  return isTablerIcon(name) // || isHeroIcon(name) || isFAIcon(name)
41
31
  }
@@ -73,30 +63,30 @@ export const DynamicIcon = ({
73
63
  />
74
64
  )
75
65
  }
76
- //HACK
77
- // if (isFAIcon(icon)) {
78
- // const Icon = FA[icon]
79
- // return (
80
- // <i {...{ ...props, className: "flex items-center justify-center" }}>
81
- // <Icon
82
- // className={cn(className, {
83
- // "h-5 w-5 text-gray-600": !className
84
- // })}
85
- // />
86
- // </i>
87
- // )
88
- // }
89
- // if (isHeroIcon(icon)) {
90
- // const Icon = outline ? OutlineIcons[icon] : SolidIcons[icon]
91
- // return (
92
- // <i {...{ ...props, className: "flex items-center justify-center" }}>
93
- // <Icon
94
- // className={cn(className, {
95
- // "h-5 w-5 text-gray-600": !className
96
- // })}
97
- // />
98
- // </i>
99
- // )
100
- // }
66
+
67
+ if (isFAIcon(icon)) {
68
+ const Icon = FA[icon]
69
+ return (
70
+ <i {...{ ...props, className: "flex items-center justify-center" }}>
71
+ <Icon
72
+ className={cn(className, {
73
+ "h-5 w-5 text-gray-600": !className
74
+ })}
75
+ />
76
+ </i>
77
+ )
78
+ }
79
+ if (isHeroIcon(icon)) {
80
+ const Icon = outline ? OutlineIcons[icon] : SolidIcons[icon]
81
+ return (
82
+ <i {...{ ...props, className: "flex items-center justify-center" }}>
83
+ <Icon
84
+ className={cn(className, {
85
+ "h-5 w-5 text-gray-600": !className
86
+ })}
87
+ />
88
+ </i>
89
+ )
90
+ }
101
91
  return <></>
102
92
  }
@@ -27,6 +27,7 @@ export interface IItemProp {
27
27
  onClick?(): void
28
28
  isEmphasized?: boolean
29
29
  key: React.Key
30
+ iconObj?: JSX.Element
30
31
  }
31
32
 
32
33
  export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
@@ -170,7 +171,16 @@ const Dropdown: React.FC<IDropdownProps> = ({
170
171
  <React.Fragment key={`${idx}-list-${id}`}>
171
172
  {itemStack.map(
172
173
  (
173
- { onClick, label, key, isEmphasized, icon, iconPosition, ...rest },
174
+ {
175
+ onClick,
176
+ label,
177
+ key,
178
+ isEmphasized,
179
+ icon,
180
+ iconPosition,
181
+ iconObj,
182
+ ...rest
183
+ },
174
184
  idx
175
185
  ) => {
176
186
  const active = activeItem && activeItem === key
@@ -217,6 +227,12 @@ const Dropdown: React.FC<IDropdownProps> = ({
217
227
  iconSpacingClassname
218
228
  )}
219
229
  >
230
+ {iconObj &&
231
+ (iconPosition === "leading" ||
232
+ iconPosition === undefined) && (
233
+ <>{iconObj}</>
234
+ )}
235
+
220
236
  {icon &&
221
237
  (iconPosition === "leading" ||
222
238
  iconPosition === undefined) &&
@@ -247,6 +263,10 @@ const Dropdown: React.FC<IDropdownProps> = ({
247
263
  />
248
264
  ))}
249
265
  <div className="whitespace-nowrap">{label}</div>
266
+ {iconObj && iconPosition === "trailing" && (
267
+ <>{iconObj}</>
268
+ )}
269
+
250
270
  {icon &&
251
271
  iconPosition === "trailing" &&
252
272
  (typeof icon === "string" ? (