@agility/plenum-ui 2.0.0-rc13 → 2.0.0-rc15

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 (40) hide show
  1. package/build.js +8 -4
  2. package/dist/index.d.ts +26 -24
  3. package/dist/index.js +1 -6372
  4. package/dist/index.js.map +3 -3
  5. package/dist/types/stories/atoms/buttons/Button/Button.d.ts +2 -2
  6. package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +1 -1
  7. package/dist/types/stories/atoms/icons/DynamicIcon.d.ts +1 -1
  8. package/dist/types/stories/atoms/icons/TablerIcon.d.ts +1 -1
  9. package/dist/types/stories/index.d.ts +2 -2
  10. package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +1 -1
  11. package/dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts +14 -9
  12. package/dist/types/stories/organisms/DropdownComponent/index.d.ts +2 -2
  13. package/dist/types/stories/organisms/index.d.ts +2 -2
  14. package/package.json +18 -3
  15. package/rollup.config.mjs +42 -0
  16. package/stories/atoms/buttons/Button/Button.tsx +3 -2
  17. package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
  18. package/stories/atoms/icons/DynamicIcon.tsx +2 -2
  19. package/stories/atoms/icons/TablerIcon.tsx +1 -1
  20. package/stories/atoms/loaders/Loader.tsx +12 -6
  21. package/stories/index.ts +0 -2
  22. package/stories/molecules/inputs/textArea/TextArea.tsx +13 -16
  23. package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +35 -33
  24. package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +3 -3
  25. package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +13 -16
  26. package/stories/organisms/DropdownComponent/DropdownComponent.tsx +17 -15
  27. package/stories/organisms/DropdownComponent/index.ts +2 -2
  28. package/stories/organisms/index.ts +10 -3
  29. package/tsconfig.lib.json +13 -6
  30. package/.yarnrc.yml +0 -1
  31. package/dist/types/stories/layouts/index.d.ts +0 -0
  32. package/stories/layouts/CardLayout/CardLayout.stories.tsx +0 -18
  33. package/stories/layouts/CardLayout/CardLayout.tsx +0 -22
  34. package/stories/layouts/CardLayout/index.tsx +0 -3
  35. package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +0 -18
  36. package/stories/layouts/ModalLayout/ModalLayout.tsx +0 -22
  37. package/stories/layouts/ModalLayout/index.tsx +0 -3
  38. package/stories/layouts/index.ts +0 -0
  39. package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
  40. /package/dist/{lib/tailwind.css → tailwind.css} +0 -0
@@ -1,7 +1,7 @@
1
- import { HTMLAttributeAnchorTarget } from "react";
1
+ import React, { HTMLAttributeAnchorTarget } from "react";
2
2
  import { UnifiedIconName, IDynamicIconProps } from "../../icons";
3
3
  export type BTNActionType = "primary" | "secondary" | "alternative" | "danger";
4
- export interface IButtonProps extends React.ComponentPropsWithoutRef<"button"> {
4
+ export interface IButtonProps extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
5
5
  /** Is the button a Primary CTA, alternative or danger button? */
6
6
  actionType?: BTNActionType;
7
7
  /** How lg should the button be? - Defaults to 'base'. */
@@ -3,7 +3,7 @@ import { BTNActionType } from "../Button/Button";
3
3
  /**
4
4
  * Capsule Style Button
5
5
  */
6
- export interface ICapsuleProps extends React.ComponentPropsWithoutRef<"button"> {
6
+ export interface ICapsuleProps extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
7
7
  /** Is the button a Primary CTA, alternative or danger button? */
8
8
  actionType: BTNActionType;
9
9
  /** How lg should the button be? - Defaults to 'base'. */
@@ -11,7 +11,7 @@ export declare function isHeroIcon(name: UnifiedIconName): name is keyof typeof
11
11
  export declare function isTablerIcon(name: UnifiedIconName): name is TablerIconName;
12
12
  export declare function isFAIcon(name: UnifiedIconName): name is keyof typeof FA;
13
13
  export declare function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName;
14
- export interface IDynamicIconProps extends React.ComponentProps<"i"> {
14
+ export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
15
15
  icon: UnifiedIconName;
16
16
  className?: ClassNameWithAutocomplete;
17
17
  outline?: boolean;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { TablerIconName } from "./tablerIconNames";
3
3
  import { ClassNameWithAutocomplete } from "@/utils/types";
4
- export interface ITablerIconProps extends React.ComponentProps<"i"> {
4
+ export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
5
5
  icon: TablerIconName;
6
6
  className?: ClassNameWithAutocomplete;
7
7
  }
@@ -1,5 +1,5 @@
1
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 } 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
- import { IAnimatedLabelInputProps, AnimatedLabelTextArea, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, ITextInputSelectProps } 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, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps, ISimpleSelectOptions };
3
+ import { IAnimatedLabelInputProps, AnimatedLabelTextArea, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, ITextInputSelectProps } 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 };
5
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 };
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { IInputFieldProps } from "@/stories/molecules/inputs/InputField";
3
- interface ILabelProps extends React.ComponentPropsWithoutRef<"label"> {
3
+ interface ILabelProps extends React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {
4
4
  display: string;
5
5
  }
6
6
  export interface IAnimatedLabelInputProps extends Omit<IInputFieldProps, "handleChange"> {
@@ -10,19 +10,17 @@ export interface IItemProp extends HTMLAttributes<HTMLButtonElement> {
10
10
  isEmphasized?: boolean;
11
11
  key: React.Key;
12
12
  }
13
- export interface IDropdownClassnames {
14
- groupClassname?: ClassNameWithAutocomplete;
15
- itemsClassname?: ClassNameWithAutocomplete;
16
- itemClassname?: ClassNameWithAutocomplete;
17
- activeItemClassname?: ClassNameWithAutocomplete;
18
- buttonClassname?: ClassNameWithAutocomplete;
19
- }
20
13
  export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
21
14
  items: IItemProp[][];
22
15
  label: string;
23
16
  CustomDropdownTrigger?: React.ReactNode;
24
17
  id: string;
25
- classNames?: IDropdownClassnames;
18
+ groupClassname?: ClassNameWithAutocomplete;
19
+ itemsClassname?: ClassNameWithAutocomplete;
20
+ itemClassname?: ClassNameWithAutocomplete;
21
+ activeItemClassname?: ClassNameWithAutocomplete;
22
+ buttonClassname?: ClassNameWithAutocomplete;
23
+ iconClassname?: ClassNameWithAutocomplete;
26
24
  placement?: Placement;
27
25
  offsetOptions?: Partial<{
28
26
  mainAxis: number;
@@ -30,7 +28,14 @@ export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
30
28
  alignmentAxis: number | null;
31
29
  }>;
32
30
  }
33
- export declare const defaultClassNames: IDropdownClassnames;
31
+ export declare const defaultClassNames: {
32
+ groupClassname: string;
33
+ itemsClassname: string;
34
+ itemClassname: string;
35
+ activeItemClassname: string;
36
+ buttonClassname: string;
37
+ iconClassname: string;
38
+ };
34
39
  /** Comment */
35
40
  declare const Dropdown: React.FC<IDropdownProps>;
36
41
  export default Dropdown;
@@ -1,4 +1,4 @@
1
- import Dropdown, { IItemProp, IDropdownClassnames, IDropdownProps, defaultClassNames } from "./DropdownComponent";
2
- export type { IItemProp, IDropdownClassnames, IDropdownProps };
1
+ import Dropdown, { IItemProp, IDropdownProps, defaultClassNames } from "./DropdownComponent";
2
+ export type { IItemProp, IDropdownProps };
3
3
  export { defaultClassNames };
4
4
  export default Dropdown;
@@ -1,9 +1,9 @@
1
1
  import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput";
2
2
  import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea";
3
3
  import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown";
4
- import Dropdown, { IDropdownClassnames, IDropdownProps, IItemProp } from "./DropdownComponent";
4
+ import Dropdown, { IDropdownProps, IItemProp } from "./DropdownComponent";
5
5
  import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder";
6
6
  import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons";
7
7
  import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect";
8
- export type { IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps };
8
+ export type { IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps };
9
9
  export { AnimatedLabelInput, AnimatedLabelTextArea, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.0.0-rc13",
3
+ "version": "2.0.0-rc15",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -17,10 +17,10 @@
17
17
  "storybook:tw": "tailwindcss -o ./lib/tailwind.css -w ",
18
18
  "storybook": "npm-run-all -p \"storybook:*\" ",
19
19
  "dev": "yarn storybook",
20
- "build:tw": "tailwindcss -o ./dist/lib/tailwind.css",
20
+ "build:tw": "tailwindcss -o ./dist/tailwind.css",
21
21
  "build:tsc": "yarn node build.js",
22
22
  "prepare": "yarn build",
23
- "build": "npm run clean && npm-run-all -s \"build:*\" ",
23
+ "build": "yarn clean && npm-run-all -s \"build:*\" ",
24
24
  "clean": "rimraf dist",
25
25
  "create-component": "node scripts/create-component.js"
26
26
  },
@@ -45,6 +45,7 @@
45
45
  "@tailwindcss/forms": "^0.5.3",
46
46
  "@tailwindcss/typography": "^0.5.9",
47
47
  "@types/node": "18.11.18",
48
+ "acorn-jsx": "^5.3.2",
48
49
  "autoprefixer": "^10.4.13",
49
50
  "classnames": "^2.3.2",
50
51
  "concurrently": "^7.6.0",
@@ -52,6 +53,7 @@
52
53
  "eslint": "8.32.0",
53
54
  "eslint-config-next": "13.1.6",
54
55
  "eslint-plugin-storybook": "^0.6.13",
56
+ "fast-glob": "^3.3.1",
55
57
  "next": "13.1.6",
56
58
  "npm-dts": "^1.3.12",
57
59
  "npm-run-all": "^4.1.5",
@@ -59,8 +61,21 @@
59
61
  "react": "18.2.0",
60
62
  "react-dom": "18.2.0",
61
63
  "react-icons": "^4.10.1",
64
+ "rimraf": "^5.0.1",
62
65
  "storybook": "^7.1.1",
63
66
  "tailwindcss": "^3.2.4",
64
67
  "typescript": "^5.1.6"
68
+ },
69
+ "peerDependencies": {
70
+ "@floating-ui/react": "^0.25.0",
71
+ "@headlessui/react": "^1.7.10",
72
+ "@headlessui/tailwindcss": "^0.1.2",
73
+ "@heroicons/react": "^1.0.5",
74
+ "@tabler/icons": "^2.26.0",
75
+ "@tabler/icons-react": "^2.27.0",
76
+ "classnames": "^2.3.2",
77
+ "react": "18.2.0",
78
+ "react-dom": "18.2.0",
79
+ "react-icons": "^4.10.1"
65
80
  }
66
81
  }
@@ -0,0 +1,42 @@
1
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import typescript from '@rollup/plugin-typescript';
5
+
6
+
7
+ const config = [
8
+ {
9
+
10
+ input: 'stories/index.ts',
11
+
12
+ output: [
13
+ {
14
+ file: "lib/index.js",
15
+ format: 'cjs',
16
+ sourcemap: true
17
+ },
18
+ {
19
+ file: "lib/index.esm.js",
20
+ format: 'esm',
21
+ sourcemap: true
22
+ }
23
+ ],
24
+ external: ["react", "react-dom"],
25
+ plugins: [
26
+ peerDepsExternal(),
27
+ resolve(),
28
+ commonjs(),
29
+ typescript({
30
+ tsconfig: "./tsconfig.lib.json",
31
+ })
32
+ ]
33
+ },
34
+ {
35
+ input: "lib/esm/types/index.d.ts",
36
+ output: [{ file: "dist/index.d.ts", format: "esm" }],
37
+ plugins: [dts()],
38
+ external: ["react", "react-dom"],
39
+ },
40
+ ];
41
+
42
+ export default config;
@@ -1,12 +1,13 @@
1
1
  import Loader from "stories/atoms/loaders/Loader"
2
2
  import { default as cn } from "classnames"
3
- import { HTMLAttributeAnchorTarget } from "react"
3
+ import React, { HTMLAttributeAnchorTarget } from "react"
4
4
  import { DynamicIcon, UnifiedIconName, IDynamicIconProps } from "../../icons"
5
5
 
6
6
  // import Loader from "../loaders/loader/Loader"
7
7
 
8
8
  export type BTNActionType = "primary" | "secondary" | "alternative" | "danger"
9
- export interface IButtonProps extends React.ComponentPropsWithoutRef<"button"> {
9
+ export interface IButtonProps
10
+ extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
10
11
  /** Is the button a Primary CTA, alternative or danger button? */
11
12
  actionType?: BTNActionType
12
13
  /** How lg should the button be? - Defaults to 'base'. */
@@ -6,7 +6,8 @@ import { UnifiedIconName } from "../../icons/DynamicIcon"
6
6
  /**
7
7
  * Capsule Style Button
8
8
  */
9
- export interface ICapsuleProps extends React.ComponentPropsWithoutRef<"button"> {
9
+ export interface ICapsuleProps
10
+ extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
10
11
  /** Is the button a Primary CTA, alternative or danger button? */
11
12
  actionType: BTNActionType
12
13
  /** How lg should the button be? - Defaults to 'base'. */
@@ -1,5 +1,5 @@
1
1
  import React from "react"
2
- // TODO: Fix heroicons support
2
+ // TODO: Fix heroicons support
3
3
  import * as SolidIcons from "@heroicons/react/solid"
4
4
  import * as OutlineIcons from "@heroicons/react/outline"
5
5
  import * as TablerIconComponents from "@tabler/icons-react"
@@ -31,7 +31,7 @@ export function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconNam
31
31
  return isTablerIcon(name) || isFAIcon(name)
32
32
  }
33
33
 
34
- export interface IDynamicIconProps extends React.ComponentProps<"i"> {
34
+ export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
35
35
  icon: UnifiedIconName
36
36
  className?: ClassNameWithAutocomplete
37
37
  outline?: boolean
@@ -3,7 +3,7 @@ import { TablerIconName } from "./tablerIconNames"
3
3
  import * as TablerIcons from "@tabler/icons-react"
4
4
  import { ClassNameWithAutocomplete } from "@/utils/types"
5
5
 
6
- export interface ITablerIconProps extends React.ComponentProps<"i"> {
6
+ export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
7
7
  icon: TablerIconName
8
8
  className?: ClassNameWithAutocomplete
9
9
  }
@@ -1,15 +1,21 @@
1
1
  import React from "react"
2
- import classNames, { default as cn } from "classnames"
2
+ import { default as cn } from "classnames"
3
3
 
4
4
  export interface ILoaderProps {
5
5
  className?: string
6
6
  }
7
7
  const Loader: React.FC<ILoaderProps> = ({ className }) => {
8
- const outerLoaderStyles = cn(
9
- "rounded-full w-16 h-16 inline-block border-8 animate-spin m-auto",
10
- className ? className : "border-purple-700 border-r-gray-200"
11
- )
12
- return <i className={outerLoaderStyles} role="status" />
8
+ return (
9
+ <>
10
+ <i
11
+ className={cn(
12
+ "rounded-full w-16 h-16 inline-block border-8 animate-spin m-auto",
13
+ className ? className : "border-purple-700 border-r-gray-200"
14
+ )}
15
+ role="status"
16
+ />
17
+ </>
18
+ )
13
19
  }
14
20
 
15
21
  export default Loader
package/stories/index.ts CHANGED
@@ -56,7 +56,6 @@ import {
56
56
  AnimatedLabelTextArea,
57
57
  IAnimatedLabelTextAreaProps,
58
58
  IButtonDropdownProps,
59
- IDropdownClassnames,
60
59
  IDropdownProps,
61
60
  IEmptySectionPlaceholderProps,
62
61
  IItemProp,
@@ -93,7 +92,6 @@ export type {
93
92
  IAnimatedLabelInputProps,
94
93
  IAnimatedLabelTextAreaProps,
95
94
  IButtonDropdownProps,
96
- IDropdownClassnames,
97
95
  IDropdownProps,
98
96
  IEmptySectionPlaceholderProps,
99
97
  IItemProp,
@@ -51,29 +51,16 @@ const Textarea: React.FC<ITextareaProps> = ({
51
51
  rows = 12,
52
52
  cols = 48,
53
53
  onChange,
54
- value: externalValue,
54
+ value,
55
55
  placeholder,
56
56
  className,
57
57
  ref,
58
58
  ...rest
59
59
  }) => {
60
60
  const uniqueID = useId()
61
- const [value, setValue] = useState<string | undefined>(externalValue || defaultValue || "")
62
- const handleOnchange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
63
- const targetValue = e.currentTarget.value
64
- typeof onChange === "function" && onChange(targetValue)
65
- setValue(targetValue)
66
- }
67
61
 
68
62
  const discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError })
69
63
 
70
- useEffect(() => {
71
- //if the external value is updated by the parent component, reset the value in here...
72
- if (externalValue !== undefined && externalValue !== null) {
73
- setValue(externalValue)
74
- }
75
- }, [externalValue])
76
-
77
64
  if (!id) id = `ta-${uniqueID}`
78
65
 
79
66
  if (!label) {
@@ -81,7 +68,12 @@ const Textarea: React.FC<ITextareaProps> = ({
81
68
  <textarea
82
69
  ref={ref}
83
70
  maxLength={maxLength}
84
- onChange={handleOnchange}
71
+ onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {
72
+ const targetValue = e.target.value
73
+ if (onChange) {
74
+ onChange(targetValue)
75
+ }
76
+ }}
85
77
  rows={rows}
86
78
  name={name}
87
79
  id={id}
@@ -120,7 +112,12 @@ const Textarea: React.FC<ITextareaProps> = ({
120
112
  <textarea
121
113
  ref={ref}
122
114
  maxLength={maxLength}
123
- onChange={handleOnchange}
115
+ onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {
116
+ const targetValue = e.target.value
117
+ if (onChange) {
118
+ onChange(targetValue)
119
+ }
120
+ }}
124
121
  rows={rows}
125
122
  name={name}
126
123
  id={id}
@@ -2,7 +2,7 @@ import React from "react"
2
2
  import { default as cn } from "classnames"
3
3
  import InputField, { IInputFieldProps } from "@/stories/molecules/inputs/InputField"
4
4
 
5
- interface ILabelProps extends React.ComponentPropsWithoutRef<"label"> {
5
+ interface ILabelProps extends React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {
6
6
  display: string
7
7
  }
8
8
 
@@ -22,42 +22,44 @@ const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = (props: IAnimated
22
22
  const [hasValue, setHasValue] = React.useState<boolean>(!!value)
23
23
 
24
24
  return (
25
- <div className={cn("group relative", containerStyles ? containerStyles : "")}>
26
- <InputField
27
- id={id}
28
- isError={isError}
29
- value={value}
30
- handleChange={(v) => {
31
- setHasValue(!!v)
32
- if (handleChange) handleChange(v)
33
- }}
34
- {...input}
35
- />
36
- <label
37
- className={cn(
38
- "absolute z-10 ml-[3px] inline-block bg-white text-sm transition-all text-gray-500 left-1 px-1",
39
- hasValue ? "!-top-[8px] !ml-[.172rem] !text-xs text-gray-600" : "top-[9px]",
40
- "peer-placeholder-shown:!-top-[8px] peer-placeholder-shown:!ml-[.172rem] peer-placeholder-shown:!text-xs peer-placeholder-shown:text-gray-600",
41
- "group-focus-within:!-top-[8px] group-focus-within:!ml-[.172rem] group-focus-within:!text-xs group-focus-within:text-gray-600",
25
+ <>
26
+ <div className={cn("group relative", containerStyles ? containerStyles : "")}>
27
+ <InputField
28
+ id={id}
29
+ isError={isError}
30
+ value={value}
31
+ handleChange={(v) => {
32
+ setHasValue(!!v)
33
+ if (handleChange) handleChange(v)
34
+ }}
35
+ {...input}
36
+ />
37
+ <label
38
+ className={cn(
39
+ "absolute z-10 ml-[3px] inline-block bg-white text-sm transition-all text-gray-500 left-1 px-1",
40
+ hasValue ? "!-top-[8px] !ml-[.172rem] !text-xs text-gray-600" : "top-[9px]",
41
+ "peer-placeholder-shown:!-top-[8px] peer-placeholder-shown:!ml-[.172rem] peer-placeholder-shown:!text-xs peer-placeholder-shown:text-gray-600",
42
+ "group-focus-within:!-top-[8px] group-focus-within:!ml-[.172rem] group-focus-within:!text-xs group-focus-within:text-gray-600",
42
43
 
43
- isError && "!text-red-600"
44
- )}
45
- htmlFor={id}
46
- >
47
- {label.display}
48
- {required && <span className="text-red-600 ml-1">*</span>}
49
- </label>
50
-
51
- <div className="flex flex-row space-x-3">
52
- <div className="grow transition-all">
53
- {message && (
54
- <span className={cn("mt-1 block text-sm", isError ? "text-red-500" : "text-gray-500")}>
55
- {message}
56
- </span>
44
+ isError && "!text-red-600"
57
45
  )}
46
+ htmlFor={id}
47
+ >
48
+ {label.display}
49
+ {required && <span className="text-red-600 ml-1">*</span>}
50
+ </label>
51
+
52
+ <div className="flex flex-row space-x-3">
53
+ <div className="grow transition-all">
54
+ {message && (
55
+ <span className={cn("mt-1 block text-sm", isError ? "text-red-500" : "text-gray-500")}>
56
+ {message}
57
+ </span>
58
+ )}
59
+ </div>
58
60
  </div>
59
61
  </div>
60
- </div>
62
+ </>
61
63
  )
62
64
  }
63
65
 
@@ -13,7 +13,7 @@ export interface IAnimatedLabelTextAreaProps extends ITextareaProps {
13
13
  }
14
14
 
15
15
  const AnimatedLabelTextArea: React.FC<IAnimatedLabelTextAreaProps> = (props: IAnimatedLabelTextAreaProps) => {
16
- const { id, containerStyles, message, required, isError, label, value, handleChange, ...input } = props
16
+ const { id, containerStyles, message, required, isError, label, value, handleChange, onChange, ...input } = props
17
17
 
18
18
  const [hasValue, setHasValue] = React.useState<boolean>(!!value)
19
19
 
@@ -23,11 +23,11 @@ const AnimatedLabelTextArea: React.FC<IAnimatedLabelTextAreaProps> = (props: IAn
23
23
  id={id}
24
24
  isError={isError}
25
25
  value={value}
26
+ {...input}
26
27
  onChange={(v) => {
27
28
  setHasValue(!!v)
28
29
  if (handleChange) handleChange(v)
29
30
  }}
30
- {...input}
31
31
  label={undefined}
32
32
  />
33
33
  <label
@@ -41,7 +41,7 @@ const AnimatedLabelTextArea: React.FC<IAnimatedLabelTextAreaProps> = (props: IAn
41
41
  )}
42
42
  htmlFor={id}
43
43
  >
44
- {label}
44
+ {label} {`${hasValue}`}
45
45
  {required && <span className="text-red-600 ml-1">*</span>}
46
46
  </label>
47
47
 
@@ -16,21 +16,7 @@ export interface IButtonDropdownProps {
16
16
  * Primary UI component for user interaction
17
17
  */
18
18
  const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, placement, offsetOptions }) => {
19
- const dropDownClasses: IDropdownProps["classNames"] = {
20
- ...defaultClassNames,
21
- groupClassname: cn(
22
- "flex items-center justify-center rounded-l-none border !border-l-0 rounded-r px-2 transition-all hover:!border-l-0",
23
- button.actionType === "primary"
24
- ? "border-purple-600 bg-purple-600 !text-white hover:border-purple-700 hover:bg-purple-700 active:!border-purple-800 active:!bg-purple-800 fill-white"
25
- : "",
26
- button.actionType === "secondary"
27
- ? "border-purple-50 bg-purple-50 !text-purple-700 hover:border-purple-100 hover:bg-purple-100 active:!border-purple-300 active:!bg-purple-300 fill-purple-700"
28
- : "",
29
- button.actionType === "alternative"
30
- ? "border-gray-300 bg-white !text-gray-700 fill-gray-700 hover:border-gray-300 hover:bg-gray-50 active:bg-gray-100"
31
- : ""
32
- )
33
- }
19
+
34
20
  return (
35
21
  <div className="flex items-stretch focus-within:ring-purple-600 focus-within:ring-2 focus-within:ring-offset-white focus-within:ring-offset-2 rounded-[3px]">
36
22
  <Button
@@ -65,7 +51,18 @@ const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, placement,
65
51
  }}
66
52
  />
67
53
  ),
68
- classNames: dropDownClasses,
54
+ groupClassname: cn(
55
+ "flex items-center justify-center rounded-l-none border !border-l-0 rounded-r px-2 transition-all hover:!border-l-0",
56
+ button.actionType === "primary"
57
+ ? "border-purple-600 bg-purple-600 !text-white hover:border-purple-700 hover:bg-purple-700 active:!border-purple-800 active:!bg-purple-800 fill-white"
58
+ : "",
59
+ button.actionType === "secondary"
60
+ ? "border-purple-50 bg-purple-50 !text-purple-700 hover:border-purple-100 hover:bg-purple-100 active:!border-purple-300 active:!bg-purple-300 fill-purple-700"
61
+ : "",
62
+ button.actionType === "alternative"
63
+ ? "border-gray-300 bg-white !text-gray-700 fill-gray-700 hover:border-gray-300 hover:bg-gray-50 active:bg-gray-100"
64
+ : ""
65
+ ),
69
66
  offsetOptions: offsetOptions ?? {
70
67
  crossAxis: 0,
71
68
  mainAxis: 5, //up/down
@@ -28,19 +28,17 @@ export interface IItemProp extends HTMLAttributes<HTMLButtonElement> {
28
28
  isEmphasized?: boolean
29
29
  key: React.Key
30
30
  }
31
- export interface IDropdownClassnames {
32
- groupClassname?: ClassNameWithAutocomplete
33
- itemsClassname?: ClassNameWithAutocomplete
34
- itemClassname?: ClassNameWithAutocomplete
35
- activeItemClassname?: ClassNameWithAutocomplete
36
- buttonClassname?: ClassNameWithAutocomplete
37
- }
38
31
  export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
39
32
  items: IItemProp[][]
40
33
  label: string
41
34
  CustomDropdownTrigger?: React.ReactNode
42
35
  id: string
43
- classNames?: IDropdownClassnames
36
+ groupClassname?: ClassNameWithAutocomplete
37
+ itemsClassname?: ClassNameWithAutocomplete
38
+ itemClassname?: ClassNameWithAutocomplete
39
+ activeItemClassname?: ClassNameWithAutocomplete
40
+ buttonClassname?: ClassNameWithAutocomplete
41
+ iconClassname?: ClassNameWithAutocomplete
44
42
  placement?: Placement
45
43
  offsetOptions?: Partial<{
46
44
  mainAxis: number
@@ -48,7 +46,7 @@ export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
48
46
  alignmentAxis: number | null
49
47
  }>
50
48
  }
51
- export const defaultClassNames: IDropdownClassnames = {
49
+ export const defaultClassNames = {
52
50
  groupClassname: "flex inline-block text-left",
53
51
  itemsClassname:
54
52
  "mt-2 origin-bottom-right rounded bg-white shadow-lg z-20 divide-y divide-gray-100 border border-gray-300 ",
@@ -56,7 +54,8 @@ export const defaultClassNames: IDropdownClassnames = {
56
54
  "group flex font-muli cursor-pointer items-center px-4 py-2 text-sm transition-all hover:bg-gray-100 hover:text-gray-900 justify-between gap-4 ",
57
55
  activeItemClassname: "block px-4 py-2 text-sm text-gray-700 bg-gray-100 hover:bg-gray-200 hover:text-gray-900",
58
56
  buttonClassname:
59
- "py-[2px] z-20 flex items-center rounded outline-purple-500 transition-all text-gray-400 hover:text-gray-600 "
57
+ "py-[2px] z-20 flex items-center rounded outline-purple-500 transition-all text-gray-400 hover:text-gray-600 ",
58
+ iconClassname: "ml-1 h-5 w-6"
60
59
  }
61
60
 
62
61
  /** Comment */
@@ -64,7 +63,12 @@ const Dropdown: React.FC<IDropdownProps> = ({
64
63
  items,
65
64
  id,
66
65
  label,
67
- classNames = defaultClassNames,
66
+ groupClassname = defaultClassNames.groupClassname,
67
+ itemsClassname = defaultClassNames.itemsClassname,
68
+ itemClassname = defaultClassNames.itemClassname,
69
+ activeItemClassname = defaultClassNames.activeItemClassname,
70
+ buttonClassname = defaultClassNames.buttonClassname,
71
+ iconClassname = defaultClassNames.iconClassname,
68
72
  CustomDropdownTrigger,
69
73
  placement = "bottom-start",
70
74
  offsetOptions,
@@ -104,8 +108,6 @@ const Dropdown: React.FC<IDropdownProps> = ({
104
108
  }
105
109
  })
106
110
 
107
- const { groupClassname, buttonClassname, itemsClassname, itemClassname, activeItemClassname } = classNames
108
-
109
111
  return (
110
112
  <div
111
113
  {...{
@@ -132,7 +134,7 @@ const Dropdown: React.FC<IDropdownProps> = ({
132
134
  ) : (
133
135
  <>
134
136
  <span className="pl-1">{label}</span>
135
- <DynamicIcon icon="ChevronDownIcon" className="ml-1 h-5 w-6 " />
137
+ <DynamicIcon icon="ChevronDownIcon" className={iconClassname} />
136
138
  </>
137
139
  )}
138
140
  </button>
@@ -215,7 +217,7 @@ const Dropdown: React.FC<IDropdownProps> = ({
215
217
  setActiveItem(key)
216
218
  onClick && onClick()
217
219
  },
218
- key,
220
+ key: key,
219
221
  className: cn(itemClass, "w-full"),
220
222
  ...rest
221
223
  }}
@@ -1,4 +1,4 @@
1
- import Dropdown, { IItemProp, IDropdownClassnames, IDropdownProps, defaultClassNames } from "./DropdownComponent"
2
- export type { IItemProp, IDropdownClassnames, IDropdownProps }
1
+ import Dropdown, { IItemProp, IDropdownProps, defaultClassNames } from "./DropdownComponent"
2
+ export type { IItemProp, IDropdownProps }
3
3
  export { defaultClassNames }
4
4
  export default Dropdown