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

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.
@@ -771,6 +771,10 @@ select {
771
771
  bottom: 0px;
772
772
  }
773
773
 
774
+ .\!-top-\[8px\] {
775
+ top: -8px !important;
776
+ }
777
+
774
778
  .-bottom-10 {
775
779
  bottom: -2.5rem;
776
780
  }
@@ -931,10 +935,6 @@ select {
931
935
  top: -24rem;
932
936
  }
933
937
 
934
- .-top-\[9px\] {
935
- top: -9px;
936
- }
937
-
938
938
  .bottom-0 {
939
939
  bottom: 0px;
940
940
  }
@@ -1139,6 +1139,10 @@ select {
1139
1139
  top: 1px;
1140
1140
  }
1141
1141
 
1142
+ .top-\[9px\] {
1143
+ top: 9px;
1144
+ }
1145
+
1142
1146
  .z-10 {
1143
1147
  z-index: 10;
1144
1148
  }
@@ -1736,6 +1740,10 @@ select {
1736
1740
  margin-bottom: 24rem;
1737
1741
  }
1738
1742
 
1743
+ .\!ml-\[\.172rem\] {
1744
+ margin-left: .172rem !important;
1745
+ }
1746
+
1739
1747
  .-ml-px {
1740
1748
  margin-left: -1px;
1741
1749
  }
@@ -1764,8 +1772,8 @@ select {
1764
1772
  margin-left: 0.75rem;
1765
1773
  }
1766
1774
 
1767
- .ml-\[\.172rem\] {
1768
- margin-left: .172rem;
1775
+ .ml-\[3px\] {
1776
+ margin-left: 3px;
1769
1777
  }
1770
1778
 
1771
1779
  .mr-4 {
@@ -54406,6 +54414,11 @@ select {
54406
54414
  font-family: Mulish, sans-serif;
54407
54415
  }
54408
54416
 
54417
+ .\!text-xs {
54418
+ font-size: 0.75rem !important;
54419
+ line-height: 1rem !important;
54420
+ }
54421
+
54409
54422
  .text-2xl {
54410
54423
  font-size: 1.5rem;
54411
54424
  line-height: 2rem;
@@ -63463,12 +63476,8 @@ select {
63463
63476
  --tw-ring-offset-width: 2px;
63464
63477
  }
63465
63478
 
63466
- .group:focus-within .group-focus-within\:\!-top-\[12px\] {
63467
- top: -12px !important;
63468
- }
63469
-
63470
- .group:focus-within .group-focus-within\:\!left-1 {
63471
- left: 0.25rem !important;
63479
+ .group:focus-within .group-focus-within\:\!-top-\[8px\] {
63480
+ top: -8px !important;
63472
63481
  }
63473
63482
 
63474
63483
  .group:focus-within .group-focus-within\:\!ml-\[\.172rem\] {
@@ -63480,6 +63489,11 @@ select {
63480
63489
  line-height: 1rem !important;
63481
63490
  }
63482
63491
 
63492
+ .group:focus-within .group-focus-within\:text-gray-600 {
63493
+ --tw-text-opacity: 1;
63494
+ color: rgb(75 85 99 / var(--tw-text-opacity));
63495
+ }
63496
+
63483
63497
  .group:focus-within .group-focus-within\:ring-1 {
63484
63498
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
63485
63499
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
@@ -63499,22 +63513,30 @@ select {
63499
63513
  --tw-ring-offset-color: #fff;
63500
63514
  }
63501
63515
 
63502
- .peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:top-2 {
63503
- top: 0.5rem;
63516
+ .peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:\!-top-\[8px\] {
63517
+ top: -8px !important;
63504
63518
  }
63505
63519
 
63506
- .peer:placeholder-shown ~ .peer-placeholder-shown\:top-2 {
63507
- top: 0.5rem;
63520
+ .peer:placeholder-shown ~ .peer-placeholder-shown\:\!-top-\[8px\] {
63521
+ top: -8px !important;
63508
63522
  }
63509
63523
 
63510
- .peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:text-sm {
63511
- font-size: 0.875rem;
63512
- line-height: 1.25rem;
63524
+ .peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:\!ml-\[\.172rem\] {
63525
+ margin-left: .172rem !important;
63513
63526
  }
63514
63527
 
63515
- .peer:placeholder-shown ~ .peer-placeholder-shown\:text-sm {
63516
- font-size: 0.875rem;
63517
- line-height: 1.25rem;
63528
+ .peer:placeholder-shown ~ .peer-placeholder-shown\:\!ml-\[\.172rem\] {
63529
+ margin-left: .172rem !important;
63530
+ }
63531
+
63532
+ .peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:\!text-xs {
63533
+ font-size: 0.75rem !important;
63534
+ line-height: 1rem !important;
63535
+ }
63536
+
63537
+ .peer:placeholder-shown ~ .peer-placeholder-shown\:\!text-xs {
63538
+ font-size: 0.75rem !important;
63539
+ line-height: 1rem !important;
63518
63540
  }
63519
63541
 
63520
63542
  .peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:text-gray-600 {
@@ -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, 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, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps, ISimpleSelectOptions };
5
- export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput, TextInputSelect };
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 };
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,12 +1,12 @@
1
1
  import React from "react";
2
2
  export type AcceptedInputTypes = "date" | "datetime-local" | "email" | "month" | "number" | "password" | "search" | "submit" | "tel" | "text" | "url" | "currency";
3
- export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"> {
3
+ export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
4
4
  /** Callback on change */
5
5
  handleChange: (value: string) => void;
6
6
  /** Input ID*/
7
- id: string;
7
+ id?: string;
8
8
  /** Input Name */
9
- name: string;
9
+ name?: string;
10
10
  /** Force the focus state on the input */
11
11
  isFocused?: boolean;
12
12
  /** Error condition */
@@ -23,6 +23,8 @@ export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"
23
23
  required?: boolean;
24
24
  /** use input psuedo classes for :valid and :invalid styles. on by default */
25
25
  clientSideCheck?: boolean;
26
+ /** Placeholder text */
27
+ placeholder?: string;
26
28
  /**ref for input */
27
29
  ref?: React.Ref<HTMLInputElement>;
28
30
  }
@@ -1,18 +1,20 @@
1
1
  import React from "react";
2
2
  import { IDynamicIconProps } from "@/stories/atoms";
3
+ interface ToggleSwitchLabel {
4
+ text: string | JSX.Element;
5
+ className?: string;
6
+ xPosition?: "left" | "right";
7
+ }
3
8
  export interface IToggleSwitchProps {
4
9
  isChecked: boolean;
5
10
  onChange: (isChecked: boolean) => void;
6
- label?: {
7
- text: string | JSX.Element;
8
- className?: string;
9
- xPosition?: "left" | "right";
10
- };
11
- screenReaderLabel: string;
11
+ label?: ToggleSwitchLabel;
12
+ screenReaderLabel?: string;
12
13
  name: string;
13
14
  id: string;
14
- variant: "base" | "short";
15
+ variant?: "base" | "short";
15
16
  withIcon?: IDynamicIconProps;
17
+ disabled?: boolean;
16
18
  }
17
19
  declare const ToggleSwitch: React.FC<IToggleSwitchProps>;
18
20
  export default ToggleSwitch;
@@ -1,18 +1,16 @@
1
1
  import React from "react";
2
2
  import { IInputFieldProps } from "@/stories/molecules/inputs/InputField";
3
- import { ITextareaProps } from "@/stories/molecules/inputs/textArea/TextArea";
4
3
  interface ILabelProps extends React.ComponentPropsWithoutRef<"label"> {
5
4
  display: string;
6
5
  }
7
- export interface IAnimatedLabelInputProps {
6
+ export interface IAnimatedLabelInputProps extends Omit<IInputFieldProps, "handleChange"> {
8
7
  id: string;
9
8
  containerStyles?: string;
10
9
  message?: string;
11
- input?: IInputFieldProps;
12
- textarea?: ITextareaProps;
13
10
  required?: boolean;
14
11
  isError?: boolean;
15
12
  label: ILabelProps;
13
+ handleChange: (value: string) => void;
16
14
  }
17
15
  declare const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps>;
18
16
  export default AnimatedLabelInput;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { ITextareaProps } from "@/stories/molecules/inputs/textArea";
3
+ export interface IAnimatedLabelTextAreaProps extends ITextareaProps {
4
+ id: string;
5
+ containerStyles?: string;
6
+ message?: string;
7
+ required?: boolean;
8
+ isError?: boolean;
9
+ handleChange: (value: string) => void;
10
+ }
11
+ declare const AnimatedLabelTextArea: React.FC<IAnimatedLabelTextAreaProps>;
12
+ export default AnimatedLabelTextArea;
@@ -0,0 +1,3 @@
1
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea";
2
+ export type { IAnimatedLabelTextAreaProps };
3
+ export default AnimatedLabelTextArea;
@@ -1,8 +1,9 @@
1
1
  import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput";
2
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea";
2
3
  import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown";
3
4
  import Dropdown, { IDropdownClassnames, IDropdownProps, IItemProp } from "./DropdownComponent";
4
5
  import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder";
5
6
  import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons";
6
7
  import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect";
7
- export type { IAnimatedLabelInputProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps };
8
- export { AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect };
8
+ export type { IAnimatedLabelInputProps, IAnimatedLabelTextAreaProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps };
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-rc11",
3
+ "version": "2.0.0-rc13",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/stories/index.ts CHANGED
@@ -53,6 +53,8 @@ import {
53
53
  // Organism Components, props, and type gaurds.
54
54
  import {
55
55
  IAnimatedLabelInputProps,
56
+ AnimatedLabelTextArea,
57
+ IAnimatedLabelTextAreaProps,
56
58
  IButtonDropdownProps,
57
59
  IDropdownClassnames,
58
60
  IDropdownProps,
@@ -89,6 +91,7 @@ export type {
89
91
  IToggleSwitchProps,
90
92
  AcceptedInputTypes,
91
93
  IAnimatedLabelInputProps,
94
+ IAnimatedLabelTextAreaProps,
92
95
  IButtonDropdownProps,
93
96
  IDropdownClassnames,
94
97
  IDropdownProps,
@@ -114,6 +117,7 @@ export {
114
117
  Textarea,
115
118
  ToggleSwitch,
116
119
  AnimatedLabelInput,
120
+ AnimatedLabelTextArea,
117
121
  ButtonDropdown,
118
122
  Dropdown,
119
123
  EmptySectionPlaceholder,
@@ -15,13 +15,13 @@ export type AcceptedInputTypes =
15
15
  | "url"
16
16
  | "currency"
17
17
 
18
- export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"> {
18
+ export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
19
19
  /** Callback on change */
20
20
  handleChange: (value: string) => void
21
21
  /** Input ID*/
22
- id: string
22
+ id?: string
23
23
  /** Input Name */
24
- name: string
24
+ name?: string
25
25
  /** Force the focus state on the input */
26
26
  isFocused?: boolean
27
27
  /** Error condition */
@@ -38,6 +38,8 @@ export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"
38
38
  required?: boolean
39
39
  /** use input psuedo classes for :valid and :invalid styles. on by default */
40
40
  clientSideCheck?: boolean
41
+ /** Placeholder text */
42
+ placeholder?: string
41
43
  /**ref for input */
42
44
  ref?: React.Ref<HTMLInputElement>
43
45
  }
@@ -54,28 +56,26 @@ const InputField: React.FC<IInputFieldProps> = ({
54
56
  handleChange,
55
57
  required,
56
58
  clientSideCheck = true,
57
- placeholder,
58
59
  className,
60
+ placeholder,
59
61
  ref,
60
62
  ...rest
61
63
  }) => {
62
-
63
64
  return (
64
65
  <input
65
66
  {...{
67
+ ref,
66
68
  type,
67
69
  id,
68
- ref,
69
70
  name,
70
71
  value,
71
72
  onChange: (e) => {
72
- console.log(e)
73
- handleChange(e.target.value)
73
+ if (handleChange) handleChange(e.target.value)
74
74
  },
75
75
  autoFocus: isFocused,
76
76
  readOnly: isReadonly,
77
77
  disabled: isDisabled,
78
- placeholder: placeholder || " ",
78
+ placeholder: placeholder || undefined,
79
79
  required,
80
80
  "aria-invalid": isError,
81
81
  "aria-disabled": isDisabled,
@@ -76,19 +76,46 @@ const Textarea: React.FC<ITextareaProps> = ({
76
76
 
77
77
  if (!id) id = `ta-${uniqueID}`
78
78
 
79
+ if (!label) {
80
+ return (
81
+ <textarea
82
+ ref={ref}
83
+ maxLength={maxLength}
84
+ onChange={handleOnchange}
85
+ rows={rows}
86
+ name={name}
87
+ id={id}
88
+ cols={cols}
89
+ className={cn(
90
+ "peer block w-full rounded focus:border-purple-500 focus:ring-purple-500 sm:text-sm",
91
+ { "border-gray-300 ": !isError },
92
+ {
93
+ "border-red-500 outline-red-500 focus:ring-red-500": isError
94
+ },
95
+ className
96
+ )}
97
+ disabled={isDisabled}
98
+ defaultValue={defaultValue}
99
+ value={value}
100
+ placeholder={placeholder}
101
+ {...rest}
102
+ />
103
+ )
104
+ }
105
+
106
+ //with label
79
107
  return (
80
108
  <div>
81
- {label && (
82
- <InputLabel
83
- isPlaceholder
84
- isActive
85
- label={label}
86
- isRequired={isRequired}
87
- id={id}
88
- isError={isError}
89
- isDisabled={isDisabled}
90
- />
91
- )}
109
+ <InputLabel
110
+ isPlaceholder
111
+ isActive
112
+ label={label}
113
+ isRequired={isRequired}
114
+ id={id}
115
+ isError={isError}
116
+ isDisabled={isDisabled}
117
+ />
118
+
92
119
  <div>
93
120
  <textarea
94
121
  ref={ref}
@@ -2,74 +2,78 @@ import React, { useEffect, useState } from "react"
2
2
  import { default as cn } from "classnames"
3
3
  import { Switch } from "@headlessui/react"
4
4
  import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms"
5
+
6
+ interface ToggleSwitchLabel {
7
+ text: string | JSX.Element
8
+ className?: string
9
+ xPosition?: "left" | "right"
10
+ }
11
+
5
12
  export interface IToggleSwitchProps {
6
13
  isChecked: boolean
7
14
  onChange: (isChecked: boolean) => void
8
- label?: {
9
- text: string | JSX.Element
10
- className?: string
11
- xPosition?: "left" | "right"
12
- }
13
- screenReaderLabel: string
15
+ label?: ToggleSwitchLabel
16
+ screenReaderLabel?: string
14
17
  name: string
15
18
  id: string
16
- variant: "base" | "short"
19
+ variant?: "base" | "short"
17
20
  withIcon?: IDynamicIconProps
21
+ disabled?: boolean
18
22
  }
19
23
 
20
24
  const ToggleSwitch: React.FC<IToggleSwitchProps> = ({
21
- isChecked,
22
- onChange,
23
- label,
24
- screenReaderLabel,
25
- name,
26
- id,
27
- variant = "base",
28
- withIcon,
25
+ isChecked,
26
+ onChange,
27
+ label,
28
+ screenReaderLabel,
29
+ name,
30
+ id,
31
+ variant = "base",
32
+ withIcon,
33
+ disabled
29
34
  }) => {
30
- const [checked, setChecked] = useState<boolean>(isChecked)
31
- useEffect(() => setChecked(isChecked), [isChecked])
35
+ const [checked, setChecked] = useState<boolean>(isChecked)
36
+ useEffect(() => setChecked(isChecked), [isChecked])
32
37
 
33
- return (
34
- <Switch.Group as={"div"} className={"flex items-center gap-2"}>
35
- {label && label.xPosition === "left" && (
36
- <Switch.Label className={label.className}>{label.text}</Switch.Label>
37
- )}
38
- <Switch
39
- name={name}
40
- id={id}
41
- checked={checked}
42
- onChange={(v: boolean) => {
43
- onChange(v)
44
- setChecked(v)
45
- }}
46
- className={cn(
47
- { "w-9 h-4": variant === "short", " h-6 w-11": variant === "base" },
48
- checked ? "bg-purple-600" : "bg-gray-200",
49
- "relative inline-flex items-center rounded-full focus-visible:ring-2 focus-visible:ring-purple-600 focus-visible:ring-offset-2 focus-within:ring-2 focus-within:ring-purple-600 focus-within:ring-offset-2 focus:ring-2 focus:ring-purple-600 focus:ring-offset-2 active:ring-2 active:ring-purple-600 active:ring-offset-2"
50
- )}
51
- >
52
- <span className="sr-only">{screenReaderLabel}</span>
53
- <span
54
- className={cn(
55
- checked ? "translate-x-[22px]" : "translate-x-[2px]",
56
- {
57
- "border border-gray-200 translate-x-0": variant === "short",
58
- "!translate-x-[22px]": checked && variant === "short",
59
- },
60
- " h-5 w-5 transform rounded-full bg-white transition shadow-sm drop-shadow flex items-center justify-center"
61
- )}
62
- >
63
- {withIcon && (
64
- <DynamicIcon {...withIcon} className={"text-gray-400 m-[2px]"} />
65
- )}
66
- </span>
67
- </Switch>
68
- {label && label.xPosition === "right" && (
69
- <Switch.Label className={label.className}>{label.text}</Switch.Label>
70
- )}
71
- </Switch.Group>
72
- )
38
+ return (
39
+ <Switch.Group as={"div"} className={"flex items-center gap-2"}>
40
+ {label && label.xPosition === "left" && (
41
+ <Switch.Label className={label.className}>{label.text}</Switch.Label>
42
+ )}
43
+ <Switch
44
+ name={name}
45
+ id={id}
46
+ checked={checked}
47
+ onChange={(v: boolean) => {
48
+ onChange(v)
49
+ setChecked(v)
50
+ }}
51
+ className={cn(
52
+ { "w-9 h-4 transition-all": variant === "short", " h-6 w-11": variant === "base" },
53
+ checked && disabled ? "bg-purple-200" : checked ? "bg-purple-600" : "bg-gray-200",
54
+ "relative inline-flex items-center rounded-full focus-visible:ring-2 focus-visible:ring-purple-600 focus-visible:ring-offset-2 focus-within:ring-2 focus-within:ring-purple-600 focus-within:ring-offset-2 focus:ring-2 focus:ring-purple-600 focus:ring-offset-2 active:ring-2 active:ring-purple-600 active:ring-offset-2"
55
+ )}
56
+ disabled={disabled}
57
+ >
58
+ {screenReaderLabel && <span className="sr-only">{screenReaderLabel}</span>}
59
+ <span
60
+ className={cn(
61
+ checked ? "translate-x-[22px]" : "translate-x-[2px]",
62
+ {
63
+ "border border-gray-200 translate-x-0": variant === "short",
64
+ "!translate-x-[22px]": checked && variant === "short"
65
+ },
66
+ " h-5 w-5 transform rounded-full bg-white transition shadow-sm drop-shadow flex items-center justify-center"
67
+ )}
68
+ >
69
+ {withIcon && <DynamicIcon {...withIcon} className={"text-gray-400 m-[2px]"} />}
70
+ </span>
71
+ </Switch>
72
+ {label && label.xPosition === "right" && (
73
+ <Switch.Label className={label.className}>{label.text}</Switch.Label>
74
+ )}
75
+ </Switch.Group>
76
+ )
73
77
  }
74
78
 
75
79
  export default ToggleSwitch
@@ -11,11 +11,20 @@ const meta: Meta<typeof AnimatedLabelInput> = {
11
11
  export default meta
12
12
  type Story = StoryObj<typeof AnimatedLabelInput>
13
13
  export const DefaultAnimatedLabelInputsStory: Story = {
14
+ args: {
15
+ id: "test",
16
+ label: {
17
+ display: "Label"
18
+ }
19
+ } as IAnimatedLabelInputProps
20
+ }
21
+
22
+ export const DefaultAnimatedLabelInputsStoryWithPlaceHolder: Story = {
14
23
  args: {
15
24
  id: "test",
16
25
  label: {
17
26
  display: "Label"
18
27
  },
19
- input: {}
28
+ placeholder: "Placeholder"
20
29
  } as IAnimatedLabelInputProps
21
30
  }
@@ -1,47 +1,51 @@
1
1
  import React from "react"
2
2
  import { default as cn } from "classnames"
3
3
  import InputField, { IInputFieldProps } from "@/stories/molecules/inputs/InputField"
4
- import Textarea, { ITextareaProps } from "@/stories/molecules/inputs/textArea/TextArea"
5
4
 
6
5
  interface ILabelProps extends React.ComponentPropsWithoutRef<"label"> {
7
6
  display: string
8
7
  }
9
8
 
10
- export interface IAnimatedLabelInputProps {
9
+ export interface IAnimatedLabelInputProps extends Omit<IInputFieldProps, "handleChange"> {
11
10
  id: string
12
11
  containerStyles?: string
13
12
  message?: string
14
- input?: IInputFieldProps
15
- textarea?: ITextareaProps
16
13
  required?: boolean
17
14
  isError?: boolean
18
15
  label: ILabelProps
16
+ handleChange: (value: string) => void
19
17
  }
20
18
 
21
- const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = ({
22
- id,
23
- label,
24
- input,
25
- message,
26
- textarea,
27
- required,
28
- isError,
29
- containerStyles
30
- }) => {
19
+ const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = (props: IAnimatedLabelInputProps) => {
20
+ const { id, containerStyles, message, required, isError, label, value, handleChange, ...input } = props
21
+
22
+ const [hasValue, setHasValue] = React.useState<boolean>(!!value)
23
+
31
24
  return (
32
25
  <div className={cn("group relative", containerStyles ? containerStyles : "")}>
33
- {input && <InputField isError={isError} {...input} />}
34
- {textarea && <Textarea isError={isError} {...textarea} />}
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
+ />
35
36
  <label
36
37
  className={cn(
37
- "absolute left-1 z-10 ml-[.172rem] inline-block bg-white px-1 text-xs transition-all peer-placeholder-shown:top-2 peer-placeholder-shown:text-sm peer-placeholder-shown:text-gray-600",
38
- "-top-[9px] group-focus-within:!-top-[12px] group-focus-within:!left-1 group-focus-within:!ml-[.172rem] group-focus-within:!text-xs",
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",
42
+
39
43
  isError && "!text-red-600"
40
44
  )}
41
45
  htmlFor={id}
42
46
  >
43
47
  {label.display}
44
- {required && <span className="text-red-600">*</span>}
48
+ {required && <span className="text-red-600 ml-1">*</span>}
45
49
  </label>
46
50
 
47
51
  <div className="flex flex-row space-x-3">
@@ -0,0 +1,26 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
3
+
4
+ const meta: Meta<typeof AnimatedLabelTextArea> = {
5
+ title: "Design System/organisms/Animated Label Text Area",
6
+ component: AnimatedLabelTextArea,
7
+ tags: ["autodocs"],
8
+ argTypes: {}
9
+ }
10
+
11
+ export default meta
12
+ type Story = StoryObj<typeof AnimatedLabelTextArea>
13
+ export const DefaultAnimatedLabelTextAreasStory: Story = {
14
+ args: {
15
+ id: "test",
16
+ label: "Label"
17
+ } as IAnimatedLabelTextAreaProps
18
+ }
19
+
20
+ export const DefaultAnimatedLabelTextAreasStoryWithPlaceholder: Story = {
21
+ args: {
22
+ id: "test",
23
+ label: "Label",
24
+ placeholder: "Placeholder"
25
+ } as IAnimatedLabelTextAreaProps
26
+ }