@agility/plenum-ui 2.2.6 → 2.2.8

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.
@@ -1,15 +1,12 @@
1
1
  import React from "react";
2
- import * as SolidIcons from "@heroicons/react/solid";
3
- import * as OutlineIcons from "@heroicons/react/outline";
4
- import * as FA from "react-icons/fa";
2
+ import type * as SolidIcons from "@heroicons/react/solid";
3
+ import type * as OutlineIcons from "@heroicons/react/outline";
5
4
  import { TablerIconName } from "./tablerIconNames";
6
5
  import { ClassNameWithAutocomplete } from "@/utils/types";
7
6
  export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons;
8
- export type FAIconName = keyof typeof FA;
9
- export type UnifiedIconName = TablerIconName | IconName | FAIconName;
7
+ export type UnifiedIconName = TablerIconName | IconName;
10
8
  export declare function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons;
11
9
  export declare function isTablerIcon(name: UnifiedIconName): name is TablerIconName;
12
- export declare function isFAIcon(name: UnifiedIconName): name is keyof typeof FA;
13
10
  export declare function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName;
14
11
  export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
15
12
  icon: UnifiedIconName;
@@ -2,9 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { DynamicIcon } from "./DynamicIcon";
3
3
  declare const meta: Meta<typeof DynamicIcon>;
4
4
  type Story = StoryObj<typeof DynamicIcon>;
5
- export declare const HeroIconSolid: Story;
6
- export declare const HeroIconOutline: Story;
7
5
  export declare const TablerIconSolid: Story;
8
6
  export declare const TablerIconOutline: Story;
9
- export declare const FAIcon: Story;
7
+ export declare const TablerIconBrandGithub: Story;
10
8
  export default meta;
@@ -1,4 +1,4 @@
1
- import { DynamicIcon, FAIconName, IDynamicIconProps, IconName, UnifiedIconName, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName } from "./DynamicIcon";
1
+ import { DynamicIcon, IDynamicIconProps, IconName, UnifiedIconName, isHeroIcon, isTablerIcon, isUnifiedIconName } from "./DynamicIcon";
2
2
  import IconWithShadow, { IIconWithShadowProps } from "./IconWithShadow";
3
- export { DynamicIcon, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, IconWithShadow };
4
- export type { FAIconName, IDynamicIconProps, IconName, UnifiedIconName, IIconWithShadowProps };
3
+ export { DynamicIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, IconWithShadow };
4
+ export type { IDynamicIconProps, IconName, UnifiedIconName, IIconWithShadowProps };
@@ -1,10 +1,10 @@
1
1
  import Avatar, { IAvatarProps } from "./Avatar";
2
2
  import Badge, { IBadgeProps } from "./badges";
3
3
  import { Button, Capsule, BTNActionType, IButtonProps, ICapsuleProps } from "./buttons";
4
- import { DynamicIcon, FAIconName, IDynamicIconProps, IIconWithShadowProps, IconName, IconWithShadow, UnifiedIconName, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName } from "./icons";
4
+ import { DynamicIcon, IDynamicIconProps, IIconWithShadowProps, IconName, IconWithShadow, UnifiedIconName, isHeroIcon, isTablerIcon, isUnifiedIconName } from "./icons";
5
5
  import { ILoaderProps, IRadialProgressProps, Loader, RadialProgress } from "./loaders";
6
6
  import { Heading, HeadingProps } from "./Typography/Heading";
7
7
  import { Label, LabelProps } from "./Typography/Label";
8
8
  import { Paragraph, ParagraphProps } from "./Typography/Paragraph";
9
- export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, HeadingProps, LabelProps, ParagraphProps, UnifiedIconName, IconName, FAIconName, BTNActionType };
10
- export { Avatar, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, Heading, Label, Paragraph, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName };
9
+ export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, HeadingProps, LabelProps, ParagraphProps, UnifiedIconName, IconName, BTNActionType };
10
+ export { Avatar, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, Heading, Label, Paragraph, isHeroIcon, isTablerIcon, isUnifiedIconName };
@@ -1,5 +1,5 @@
1
- import { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, UnifiedIconName, IconName, FAIconName, BTNActionType, Avatar, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, Heading, HeadingProps, Label, LabelProps, Paragraph, ParagraphProps } from "./atoms";
1
+ import { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, UnifiedIconName, IconName, BTNActionType, Avatar, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isHeroIcon, isTablerIcon, isUnifiedIconName, Heading, HeadingProps, Label, LabelProps, Paragraph, ParagraphProps } from "./atoms";
2
2
  import { ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, TextInput, ITextInputProps, ISimpleSelectOptions } from "./molecules";
3
3
  import { IAnimatedLabelInputProps, AnimatedLabelTextArea, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, ITextInputSelectProps, IAnimatedFormInputWithAddons, AnimatedFormInputWithAddons, DropdownWithMultiSelect, MultiSelectItemProps } from "./organisms";
4
- export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, ITextInputSelectProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps, ISimpleSelectOptions, IAnimatedFormInputWithAddons, MultiSelectItemProps, HeadingProps, LabelProps, ParagraphProps };
5
- export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput, TextInputSelect, AnimatedFormInputWithAddons, DropdownWithMultiSelect, Heading, Label, Paragraph };
4
+ export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, ITextInputSelectProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, BTNActionType, ITextInputProps, ISimpleSelectOptions, IAnimatedFormInputWithAddons, MultiSelectItemProps, HeadingProps, LabelProps, ParagraphProps };
5
+ export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput, TextInputSelect, AnimatedFormInputWithAddons, DropdownWithMultiSelect, Heading, Label, Paragraph };
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "sideEffects": [
9
+ "**/*.css"
10
+ ],
8
11
  "engines": {
9
12
  "node": ">= 18.0.0"
10
13
  },
@@ -73,7 +76,6 @@
73
76
  "jest-environment-jsdom": "^29.7.0",
74
77
  "react": "18.2.0",
75
78
  "react-dom": "18.2.0",
76
- "react-icons": "^4.10.1",
77
79
  "rimraf": "^5.0.1",
78
80
  "storybook": "^7.1.1",
79
81
  "ts-node": "^10.9.2",
@@ -88,7 +90,6 @@
88
90
  "@tabler/icons-react": "^2.27.0",
89
91
  "classnames": "^2.3.2",
90
92
  "react": "18.2.0",
91
- "react-dom": "18.2.0",
92
- "react-icons": "^4.10.1"
93
+ "react-dom": "18.2.0"
93
94
  }
94
95
  }
@@ -1,43 +1,31 @@
1
- import type { Meta, StoryObj } from "@storybook/react"
2
- import { DynamicIcon } from "./DynamicIcon"
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { DynamicIcon } from "./DynamicIcon";
3
3
 
4
4
  const meta: Meta<typeof DynamicIcon> = {
5
5
  title: "Design System/atoms/Icons/DynamicIcon",
6
6
  component: DynamicIcon,
7
7
  tags: ["autodocs"]
8
- }
8
+ };
9
9
 
10
- type Story = StoryObj<typeof DynamicIcon>
10
+ type Story = StoryObj<typeof DynamicIcon>;
11
11
 
12
- export const HeroIconSolid: Story = {
13
- args: {
14
- icon: "TrashIcon",
15
- outline: false
16
- }
17
- }
18
- export const HeroIconOutline: Story = {
19
- args: {
20
- icon: "TrashIcon",
21
- outline: true
22
- }
23
- }
24
12
  export const TablerIconSolid: Story = {
25
13
  args: {
26
14
  icon: "IconTrashFilled",
27
15
  outline: false
28
16
  }
29
- }
17
+ };
30
18
  export const TablerIconOutline: Story = {
31
19
  args: {
32
20
  icon: "IconTrash",
33
21
  outline: true
34
22
  }
35
- }
36
- export const FAIcon: Story = {
23
+ };
24
+ export const TablerIconBrandGithub: Story = {
37
25
  args: {
38
- icon: "FaGithub",
26
+ icon: "IconBrandGithub",
39
27
  outline: true
40
28
  }
41
- }
29
+ };
42
30
 
43
- export default meta
31
+ export default meta;
@@ -1,8 +1,7 @@
1
1
  import React from "react"
2
- // TODO: Fix heroicons support
3
- import * as SolidIcons from "@heroicons/react/solid"
4
- import * as OutlineIcons from "@heroicons/react/outline"
5
- import * as FA from "react-icons/fa"
2
+ // TODO: Fix heroicons support — using import type to avoid bundling full icon sets
3
+ import type * as SolidIcons from "@heroicons/react/solid"
4
+ import type * as OutlineIcons from "@heroicons/react/outline"
6
5
  import { tablerIconNames, TablerIconName } from "./tablerIconNames"
7
6
  import { default as cn } from "classnames"
8
7
 
@@ -10,24 +9,20 @@ import { ClassNameWithAutocomplete } from "@/utils/types"
10
9
  import TablerIcon from "./TablerIcon"
11
10
 
12
11
  export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons
13
- export type FAIconName = keyof typeof FA
14
12
 
15
- export type UnifiedIconName = TablerIconName | IconName | FAIconName
13
+ export type UnifiedIconName = TablerIconName | IconName
16
14
 
15
+ // isHeroIcon: heroicon support is pending (TODO: Fix heroicons support)
17
16
  export function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons {
18
- return name in SolidIcons || name in OutlineIcons
17
+ return false
19
18
  }
20
19
 
21
20
  export function isTablerIcon(name: UnifiedIconName): name is TablerIconName {
22
21
  return tablerIconNames.includes(name as TablerIconName)
23
22
  }
24
23
 
25
- export function isFAIcon(name: UnifiedIconName): name is keyof typeof FA {
26
- return name in FA
27
- }
28
-
29
24
  export function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName {
30
- return isTablerIcon(name) // || isHeroIcon(name) || isFAIcon(name)
25
+ return isTablerIcon(name)
31
26
  }
32
27
 
33
28
  export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
@@ -62,29 +57,5 @@ export const DynamicIcon = ({
62
57
  )
63
58
  }
64
59
 
65
- if (isFAIcon(icon)) {
66
- const Icon = FA[icon]
67
- return (
68
- <i {...{ ...props, className: "flex items-center justify-center" }}>
69
- <Icon
70
- className={cn(className, {
71
- "h-5 w-5 text-gray-600": !className
72
- })}
73
- />
74
- </i>
75
- )
76
- }
77
- if (isHeroIcon(icon)) {
78
- const Icon = outline ? OutlineIcons[icon] : SolidIcons[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
60
  return <></>
90
61
  }
@@ -1,8 +1,22 @@
1
- import React from "react";
1
+ import React, { useState, useEffect, type ComponentType } from "react";
2
2
  import { TablerIconName } from "./tablerIconNames";
3
- import * as TablerIcons from "@tabler/icons-react";
4
3
  import { ClassNameWithAutocomplete } from "@/utils/types";
5
4
 
5
+ let iconRegistry: Record<string, ComponentType<any>> | null = null;
6
+ let registryPromise: Promise<void> | null = null;
7
+
8
+ function loadIconRegistry(): Promise<void> {
9
+ if (!registryPromise) {
10
+ registryPromise = import("@tabler/icons-react").then((mod) => {
11
+ iconRegistry = mod as unknown as Record<string, ComponentType<any>>;
12
+ });
13
+ }
14
+ return registryPromise;
15
+ }
16
+
17
+ // Kick off load eagerly on module import
18
+ loadIconRegistry();
19
+
6
20
  export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
7
21
  icon: TablerIconName;
8
22
  className?: ClassNameWithAutocomplete;
@@ -11,9 +25,18 @@ export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttr
11
25
  const TablerIcon: React.FC<ITablerIconProps> = ({
12
26
  icon,
13
27
  className = "w-6 h-6 text-gray-600"
14
- }: ITablerIconProps): JSX.Element => {
15
- //@ts-ignore
16
- const Icon = TablerIcons[icon];
28
+ }: ITablerIconProps): JSX.Element | null => {
29
+ const [Icon, setIcon] = useState<ComponentType<any> | null>(
30
+ iconRegistry && icon ? (iconRegistry[icon] ?? null) : null
31
+ );
32
+
33
+ useEffect(() => {
34
+ if (!icon) { setIcon(null); return; }
35
+ if (iconRegistry) { setIcon(iconRegistry[icon] ?? null); return; }
36
+ loadIconRegistry().then(() => setIcon(iconRegistry![icon] ?? null));
37
+ }, [icon]);
38
+
39
+ if (!Icon) return null;
17
40
  return (
18
41
  <i>
19
42
  <Icon className={className} />
@@ -1,14 +1,12 @@
1
1
  import {
2
2
  DynamicIcon,
3
- FAIconName,
4
3
  IDynamicIconProps,
5
4
  IconName,
6
5
  UnifiedIconName,
7
- isFAIcon,
8
6
  isHeroIcon,
9
7
  isTablerIcon,
10
8
  isUnifiedIconName
11
9
  } from "./DynamicIcon"
12
10
  import IconWithShadow, { IIconWithShadowProps } from "./IconWithShadow"
13
- export { DynamicIcon, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, IconWithShadow }
14
- export type { FAIconName, IDynamicIconProps, IconName, UnifiedIconName, IIconWithShadowProps }
11
+ export { DynamicIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, IconWithShadow }
12
+ export type { IDynamicIconProps, IconName, UnifiedIconName, IIconWithShadowProps }
@@ -3,13 +3,11 @@ import Badge, { IBadgeProps } from "./badges";
3
3
  import { Button, Capsule, BTNActionType, IButtonProps, ICapsuleProps } from "./buttons";
4
4
  import {
5
5
  DynamicIcon,
6
- FAIconName,
7
6
  IDynamicIconProps,
8
7
  IIconWithShadowProps,
9
8
  IconName,
10
9
  IconWithShadow,
11
10
  UnifiedIconName,
12
- isFAIcon,
13
11
  isHeroIcon,
14
12
  isTablerIcon,
15
13
  isUnifiedIconName
@@ -32,7 +30,6 @@ export type {
32
30
  ParagraphProps,
33
31
  UnifiedIconName,
34
32
  IconName,
35
- FAIconName,
36
33
  BTNActionType
37
34
  };
38
35
  export {
@@ -47,7 +44,6 @@ export {
47
44
  Heading,
48
45
  Label,
49
46
  Paragraph,
50
- isFAIcon,
51
47
  isHeroIcon,
52
48
  isTablerIcon,
53
49
  isUnifiedIconName
package/stories/index.ts CHANGED
@@ -10,7 +10,6 @@ import {
10
10
  IRadialProgressProps,
11
11
  UnifiedIconName,
12
12
  IconName,
13
- FAIconName,
14
13
  BTNActionType,
15
14
  Avatar,
16
15
  Badge,
@@ -20,7 +19,6 @@ import {
20
19
  IconWithShadow,
21
20
  Loader,
22
21
  RadialProgress,
23
- isFAIcon,
24
22
  isHeroIcon,
25
23
  isTablerIcon,
26
24
  isUnifiedIconName,
@@ -108,7 +106,6 @@ export type {
108
106
  IFormInputWithAddonsProps,
109
107
  UnifiedIconName,
110
108
  IconName,
111
- FAIconName,
112
109
  BTNActionType,
113
110
  ITextInputProps,
114
111
  ISimpleSelectOptions,
@@ -142,7 +139,6 @@ export {
142
139
  IconWithShadow,
143
140
  Loader,
144
141
  RadialProgress,
145
- isFAIcon,
146
142
  isHeroIcon,
147
143
  isTablerIcon,
148
144
  isUnifiedIconName,
@@ -39,12 +39,11 @@ describe("DropdownWithMultiSelect", () => {
39
39
  vi.stubGlobal("ResizeObserver", ResizeObserver);
40
40
  });
41
41
 
42
- it("renders a button", () => {
42
+ it("renders a button", async () => {
43
43
  const { container } = render(<DropdownWithMultiSelect {...defaultProps} />);
44
44
  const button = screen.getByRole("button", { name: /Filters/i });
45
45
  expect(button).toBeInTheDocument();
46
- const icon = container.querySelector("svg");
47
- expect(icon).toBeInTheDocument();
46
+ await waitFor(() => expect(container.querySelector("svg")).toBeInTheDocument());
48
47
  });
49
48
 
50
49
  it("opens the popover and shows options", async () => {