@agility/plenum-ui 2.0.0-rc47 → 2.0.0-rc49
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.
- package/.eslintrc.json +6 -6
- package/.prettierrc +13 -13
- package/.storybook/Layout.jsx +12 -12
- package/.storybook/head.tsx +4 -4
- package/.storybook/main.ts +18 -18
- package/.storybook/manager-head.html +1 -1
- package/.storybook/manager.ts +25 -25
- package/.storybook/plenumTheme.ts +8 -8
- package/.storybook/preview-head.html +3 -3
- package/.storybook/preview.tsx +28 -28
- package/.vscode/settings.json +3 -3
- package/README.md +271 -271
- package/app/globals.css +99 -99
- package/app/head.tsx +59 -59
- package/app/layout.tsx +28 -28
- package/app/page.tsx +7 -7
- package/build.js +45 -45
- package/dist/index.d.ts +232 -230
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +2 -0
- package/local.sh +100 -100
- package/next.config.js +8 -8
- package/package.json +82 -82
- package/pages/api/hello.ts +13 -13
- package/postcss.config.js +6 -6
- package/rollup.config.mjs +41 -41
- package/scripts/create-component.js +97 -97
- package/stories/Introduction.mdx +314 -314
- package/stories/assets/stackalt.svg +1 -1
- package/stories/atoms/Avatar/Avatar.stories.tsx +96 -96
- package/stories/atoms/Avatar/Avatar.tsx +123 -123
- package/stories/atoms/Avatar/index.ts +3 -3
- package/stories/atoms/badges/Badge.tsx +127 -127
- package/stories/atoms/badges/Pill/Pill.stories.tsx +75 -75
- package/stories/atoms/badges/Rounded/Rounded.stories.tsx +75 -75
- package/stories/atoms/badges/index.ts +3 -3
- package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +86 -86
- package/stories/atoms/buttons/Button/Button.tsx +232 -232
- package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +90 -90
- package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +97 -97
- package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +93 -93
- package/stories/atoms/buttons/Button/defaultArgs.ts +9 -9
- package/stories/atoms/buttons/Button/index.ts +3 -3
- package/stories/atoms/buttons/Capsule/Alternative/Alternative.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/Capsule.tsx +88 -88
- package/stories/atoms/buttons/Capsule/Danger/Danger.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/Primary/Primary.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/Secondary/Secondary.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/index.ts +3 -3
- package/stories/atoms/buttons/FloatingActionButton/FloatingActionButton.stories.tsx +15 -15
- package/stories/atoms/buttons/FloatingActionButton/FloatingActionButton.tsx +22 -22
- package/stories/atoms/buttons/FloatingActionButton/index.tsx +3 -3
- package/stories/atoms/buttons/index.ts +4 -4
- package/stories/atoms/crumb/Crumb.stories.tsx +18 -18
- package/stories/atoms/crumb/Crumb.tsx +22 -22
- package/stories/atoms/crumb/index.tsx +3 -3
- package/stories/atoms/icons/DynamicIcon.stories.ts +43 -43
- package/stories/atoms/icons/DynamicIcon.tsx +90 -90
- package/stories/atoms/icons/IconWithShadow.stories.ts +43 -43
- package/stories/atoms/icons/IconWithShadow.tsx +16 -16
- package/stories/atoms/icons/TablerIcon.tsx +22 -22
- package/stories/atoms/icons/index.tsx +14 -14
- package/stories/atoms/icons/tablerIconNames.ts +4336 -4336
- package/stories/atoms/index.ts +46 -46
- package/stories/atoms/loaders/Loader.stories.ts +15 -15
- package/stories/atoms/loaders/Loader.tsx +21 -21
- package/stories/atoms/loaders/NProgress/RadialProgress.stories.tsx +19 -19
- package/stories/atoms/loaders/NProgress/RadialProgress.tsx +74 -74
- package/stories/atoms/loaders/NProgress/index.ts +3 -3
- package/stories/atoms/loaders/index.ts +4 -4
- package/stories/index.ts +136 -136
- package/stories/molecules/index.ts +51 -51
- package/stories/molecules/inputs/InputCounter/InputCounter.stories.tsx +18 -18
- package/stories/molecules/inputs/InputCounter/InputCounter.tsx +24 -24
- package/stories/molecules/inputs/InputCounter/index.tsx +3 -3
- package/stories/molecules/inputs/InputField/InputField.stories.tsx +29 -29
- package/stories/molecules/inputs/InputField/InputField.tsx +96 -96
- package/stories/molecules/inputs/InputField/index.tsx +3 -3
- package/stories/molecules/inputs/InputLabel/InputLabel.stories.tsx +19 -19
- package/stories/molecules/inputs/InputLabel/InputLabel.tsx +45 -45
- package/stories/molecules/inputs/InputLabel/index.tsx +3 -3
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.stories.tsx +52 -52
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.tsx +64 -64
- package/stories/molecules/inputs/NestedInputButton/index.tsx +3 -3
- package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +32 -32
- package/stories/molecules/inputs/TextInput/TextInput.tsx +165 -165
- package/stories/molecules/inputs/TextInput/index.tsx +5 -5
- package/stories/molecules/inputs/checkbox/Checkbox.stories.ts +23 -23
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +98 -98
- package/stories/molecules/inputs/checkbox/index.ts +3 -3
- package/stories/molecules/inputs/combobox/ComboBox.stories.ts +41 -41
- package/stories/molecules/inputs/combobox/ComboBox.tsx +185 -185
- package/stories/molecules/inputs/combobox/index.ts +3 -3
- package/stories/molecules/inputs/index.ts +38 -38
- package/stories/molecules/inputs/radio/Radio.stories.ts +27 -27
- package/stories/molecules/inputs/radio/Radio.tsx +92 -92
- package/stories/molecules/inputs/radio/index.ts +3 -3
- package/stories/molecules/inputs/select/Select.stories.ts +23 -23
- package/stories/molecules/inputs/select/Select.tsx +108 -100
- package/stories/molecules/inputs/select/index.ts +3 -3
- package/stories/molecules/inputs/textArea/TextArea.stories.ts +22 -22
- package/stories/molecules/inputs/textArea/TextArea.tsx +158 -158
- package/stories/molecules/inputs/textArea/index.ts +3 -3
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.stories.tsx +118 -118
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +81 -81
- package/stories/molecules/inputs/toggleSwitch/index.ts +3 -3
- package/stories/molecules/tabs/Tabs.stories.tsx +18 -18
- package/stories/molecules/tabs/Tabs.tsx +22 -22
- package/stories/molecules/tabs/index.tsx +2 -2
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +30 -30
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +66 -66
- package/stories/organisms/AnimatedLabelInput/index.tsx +3 -3
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.stories.tsx +26 -26
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +61 -61
- package/stories/organisms/AnimatedLabelTextArea/index.tsx +3 -3
- package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +125 -125
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +86 -86
- package/stories/organisms/ButtonDropdown/index.tsx +3 -3
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +73 -73
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +346 -346
- package/stories/organisms/DropdownComponent/dropdownItems.ts +122 -122
- package/stories/organisms/DropdownComponent/index.ts +4 -4
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.stories.tsx +76 -76
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.tsx +52 -52
- package/stories/organisms/EmptySectionPlaceholder/index.tsx +4 -4
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +29 -29
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +145 -145
- package/stories/organisms/FormInputWithAddons/index.tsx +3 -3
- package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -59
- package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -33
- package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -186
- package/stories/organisms/TextInputSelect/index.tsx +3 -3
- package/stories/organisms/index.ts +27 -27
- package/tailwind.config.js +192 -192
- package/tsconfig.json +29 -29
- package/tsconfig.lib.json +25 -25
- package/utils/types.d.ts +2 -2
- package/utils/types.ts +3 -3
- package/utils/useId.d.ts +1 -1
- package/utils/useId.tsx +16 -16
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ICheckboxProps,
|
|
3
|
-
IComboboxProps,
|
|
4
|
-
IInputFieldProps,
|
|
5
|
-
IInputLabelProps,
|
|
6
|
-
INestedInputButtonProps,
|
|
7
|
-
IRadioProps,
|
|
8
|
-
ISelectProps,
|
|
9
|
-
ISimpleSelectOptions,
|
|
10
|
-
ITextareaProps,
|
|
11
|
-
IToggleSwitchProps,
|
|
12
|
-
AcceptedInputTypes,
|
|
13
|
-
Checkbox,
|
|
14
|
-
Combobox,
|
|
15
|
-
InputField,
|
|
16
|
-
InputLabel,
|
|
17
|
-
NestedInputButton,
|
|
18
|
-
Radio,
|
|
19
|
-
Select,
|
|
20
|
-
Textarea,
|
|
21
|
-
ToggleSwitch,
|
|
22
|
-
ITextInputProps,
|
|
23
|
-
TextInput
|
|
24
|
-
} from "./inputs"
|
|
25
|
-
|
|
26
|
-
export type {
|
|
27
|
-
ICheckboxProps,
|
|
28
|
-
IComboboxProps,
|
|
29
|
-
IInputFieldProps,
|
|
30
|
-
IInputLabelProps,
|
|
31
|
-
INestedInputButtonProps,
|
|
32
|
-
IRadioProps,
|
|
33
|
-
ISelectProps,
|
|
34
|
-
ISimpleSelectOptions,
|
|
35
|
-
ITextareaProps,
|
|
36
|
-
IToggleSwitchProps,
|
|
37
|
-
AcceptedInputTypes,
|
|
38
|
-
ITextInputProps
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
Checkbox,
|
|
42
|
-
Combobox,
|
|
43
|
-
InputField,
|
|
44
|
-
InputLabel,
|
|
45
|
-
NestedInputButton,
|
|
46
|
-
Radio,
|
|
47
|
-
Select,
|
|
48
|
-
Textarea,
|
|
49
|
-
ToggleSwitch,
|
|
50
|
-
TextInput
|
|
51
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ICheckboxProps,
|
|
3
|
+
IComboboxProps,
|
|
4
|
+
IInputFieldProps,
|
|
5
|
+
IInputLabelProps,
|
|
6
|
+
INestedInputButtonProps,
|
|
7
|
+
IRadioProps,
|
|
8
|
+
ISelectProps,
|
|
9
|
+
ISimpleSelectOptions,
|
|
10
|
+
ITextareaProps,
|
|
11
|
+
IToggleSwitchProps,
|
|
12
|
+
AcceptedInputTypes,
|
|
13
|
+
Checkbox,
|
|
14
|
+
Combobox,
|
|
15
|
+
InputField,
|
|
16
|
+
InputLabel,
|
|
17
|
+
NestedInputButton,
|
|
18
|
+
Radio,
|
|
19
|
+
Select,
|
|
20
|
+
Textarea,
|
|
21
|
+
ToggleSwitch,
|
|
22
|
+
ITextInputProps,
|
|
23
|
+
TextInput
|
|
24
|
+
} from "./inputs"
|
|
25
|
+
|
|
26
|
+
export type {
|
|
27
|
+
ICheckboxProps,
|
|
28
|
+
IComboboxProps,
|
|
29
|
+
IInputFieldProps,
|
|
30
|
+
IInputLabelProps,
|
|
31
|
+
INestedInputButtonProps,
|
|
32
|
+
IRadioProps,
|
|
33
|
+
ISelectProps,
|
|
34
|
+
ISimpleSelectOptions,
|
|
35
|
+
ITextareaProps,
|
|
36
|
+
IToggleSwitchProps,
|
|
37
|
+
AcceptedInputTypes,
|
|
38
|
+
ITextInputProps
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
Checkbox,
|
|
42
|
+
Combobox,
|
|
43
|
+
InputField,
|
|
44
|
+
InputLabel,
|
|
45
|
+
NestedInputButton,
|
|
46
|
+
Radio,
|
|
47
|
+
Select,
|
|
48
|
+
Textarea,
|
|
49
|
+
ToggleSwitch,
|
|
50
|
+
TextInput
|
|
51
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
-
import InputCounter, { IInputCounterProps } from "./InputCounter"
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof InputCounter> = {
|
|
5
|
-
title: "Design System/molecules/inputs/InputCounter",
|
|
6
|
-
component: InputCounter,
|
|
7
|
-
tags: ["autodocs"],
|
|
8
|
-
argTypes: {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default meta
|
|
12
|
-
type Story = StoryObj<typeof InputCounter>
|
|
13
|
-
export const DefaultInputCounterStory: Story = {
|
|
14
|
-
args: {
|
|
15
|
-
limit: 100,
|
|
16
|
-
current: 0
|
|
17
|
-
} as IInputCounterProps
|
|
18
|
-
}
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import InputCounter, { IInputCounterProps } from "./InputCounter"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof InputCounter> = {
|
|
5
|
+
title: "Design System/molecules/inputs/InputCounter",
|
|
6
|
+
component: InputCounter,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof InputCounter>
|
|
13
|
+
export const DefaultInputCounterStory: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
limit: 100,
|
|
16
|
+
current: 0
|
|
17
|
+
} as IInputCounterProps
|
|
18
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, { FC } from "react"
|
|
2
|
-
|
|
3
|
-
export interface IInputCounterProps {
|
|
4
|
-
/** Counter limit */
|
|
5
|
-
limit: number | undefined
|
|
6
|
-
/** Counter current number */
|
|
7
|
-
current: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** Primary UI component for user interaction */
|
|
11
|
-
const InputCounter: FC<IInputCounterProps> = ({ current = 0, limit }) => {
|
|
12
|
-
return (
|
|
13
|
-
<div className="mt-1 text-center text-sm text-gray-500 flex gap-1">
|
|
14
|
-
<div className="currentCount">{current}</div>
|
|
15
|
-
{(limit || 0) > 0 && (
|
|
16
|
-
<>
|
|
17
|
-
<div>/</div>
|
|
18
|
-
<div className="limitCount">{limit}</div>
|
|
19
|
-
</>
|
|
20
|
-
)}
|
|
21
|
-
</div>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
export default InputCounter
|
|
1
|
+
import React, { FC } from "react"
|
|
2
|
+
|
|
3
|
+
export interface IInputCounterProps {
|
|
4
|
+
/** Counter limit */
|
|
5
|
+
limit: number | undefined
|
|
6
|
+
/** Counter current number */
|
|
7
|
+
current: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Primary UI component for user interaction */
|
|
11
|
+
const InputCounter: FC<IInputCounterProps> = ({ current = 0, limit }) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className="mt-1 text-center text-sm text-gray-500 flex gap-1">
|
|
14
|
+
<div className="currentCount">{current}</div>
|
|
15
|
+
{(limit || 0) > 0 && (
|
|
16
|
+
<>
|
|
17
|
+
<div>/</div>
|
|
18
|
+
<div className="limitCount">{limit}</div>
|
|
19
|
+
</>
|
|
20
|
+
)}
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
export default InputCounter
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export { default } from './InputCounter';
|
|
3
|
-
export * from './InputCounter';
|
|
1
|
+
|
|
2
|
+
export { default } from './InputCounter';
|
|
3
|
+
export * from './InputCounter';
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
-
import InputField from "./InputField"
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof InputField> = {
|
|
5
|
-
title: "Design System/molecules/inputs/Input Field",
|
|
6
|
-
component: InputField,
|
|
7
|
-
tags: ["autodocs"],
|
|
8
|
-
argTypes: {},
|
|
9
|
-
parameters: {
|
|
10
|
-
design: {
|
|
11
|
-
type: "figma",
|
|
12
|
-
url: "https://www.figma.com/file/Rb5fJ8hD3pwvLnidgCaGgB/Agility-UI?type=design&node-id=114-1861&mode=dev&device-scaling=100%25&page-id=0%3A1"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default meta
|
|
18
|
-
type Story = StoryObj<typeof InputField>
|
|
19
|
-
|
|
20
|
-
export const DefaultInputField: Story = {
|
|
21
|
-
args: {
|
|
22
|
-
id: "input",
|
|
23
|
-
name: "input",
|
|
24
|
-
type: "text",
|
|
25
|
-
placeholder: "Base Input Field",
|
|
26
|
-
defaultValue: "",
|
|
27
|
-
isDisabled: false
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import InputField from "./InputField"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof InputField> = {
|
|
5
|
+
title: "Design System/molecules/inputs/Input Field",
|
|
6
|
+
component: InputField,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {},
|
|
9
|
+
parameters: {
|
|
10
|
+
design: {
|
|
11
|
+
type: "figma",
|
|
12
|
+
url: "https://www.figma.com/file/Rb5fJ8hD3pwvLnidgCaGgB/Agility-UI?type=design&node-id=114-1861&mode=dev&device-scaling=100%25&page-id=0%3A1"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default meta
|
|
18
|
+
type Story = StoryObj<typeof InputField>
|
|
19
|
+
|
|
20
|
+
export const DefaultInputField: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
id: "input",
|
|
23
|
+
name: "input",
|
|
24
|
+
type: "text",
|
|
25
|
+
placeholder: "Base Input Field",
|
|
26
|
+
defaultValue: "",
|
|
27
|
+
isDisabled: false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import React, { forwardRef } from "react"
|
|
2
|
-
import { default as cn } from "classnames"
|
|
3
|
-
|
|
4
|
-
export type AcceptedInputTypes =
|
|
5
|
-
| "date"
|
|
6
|
-
| "datetime-local"
|
|
7
|
-
| "email"
|
|
8
|
-
| "month"
|
|
9
|
-
| "number"
|
|
10
|
-
| "password"
|
|
11
|
-
| "search"
|
|
12
|
-
| "submit"
|
|
13
|
-
| "tel"
|
|
14
|
-
| "text"
|
|
15
|
-
| "url"
|
|
16
|
-
| "currency"
|
|
17
|
-
|
|
18
|
-
export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
19
|
-
/** Callback on change */
|
|
20
|
-
handleChange: (value: string) => void
|
|
21
|
-
/** Input ID*/
|
|
22
|
-
id?: string
|
|
23
|
-
/** Input Name */
|
|
24
|
-
name?: string
|
|
25
|
-
/** Force the focus state on the input */
|
|
26
|
-
isFocused?: boolean
|
|
27
|
-
/** Error condition */
|
|
28
|
-
isError?: boolean
|
|
29
|
-
/** Disabled state */
|
|
30
|
-
isDisabled?: boolean
|
|
31
|
-
/** Readonly state */
|
|
32
|
-
isReadonly?: boolean
|
|
33
|
-
/** Input value */
|
|
34
|
-
value: string
|
|
35
|
-
/** Type of Text Input to Render eg. "text", "email" */
|
|
36
|
-
type: AcceptedInputTypes
|
|
37
|
-
/** If field is required */
|
|
38
|
-
required?: boolean
|
|
39
|
-
/** use input psuedo classes for :valid and :invalid styles. on by default */
|
|
40
|
-
clientSideCheck?: boolean
|
|
41
|
-
/** Placeholder text */
|
|
42
|
-
placeholder?: string
|
|
43
|
-
/**ref for input */
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const InputField = (
|
|
47
|
-
{
|
|
48
|
-
type,
|
|
49
|
-
id,
|
|
50
|
-
name,
|
|
51
|
-
value,
|
|
52
|
-
isFocused,
|
|
53
|
-
isError,
|
|
54
|
-
isReadonly,
|
|
55
|
-
isDisabled,
|
|
56
|
-
handleChange,
|
|
57
|
-
required,
|
|
58
|
-
clientSideCheck = true,
|
|
59
|
-
className,
|
|
60
|
-
placeholder,
|
|
61
|
-
...rest
|
|
62
|
-
}: IInputFieldProps,
|
|
63
|
-
ref: React.Ref<HTMLInputElement>
|
|
64
|
-
) => {
|
|
65
|
-
return (
|
|
66
|
-
<input
|
|
67
|
-
{...{
|
|
68
|
-
ref,
|
|
69
|
-
type,
|
|
70
|
-
id,
|
|
71
|
-
name,
|
|
72
|
-
value,
|
|
73
|
-
onChange: (e) => {
|
|
74
|
-
if (handleChange) handleChange(e.target.value)
|
|
75
|
-
},
|
|
76
|
-
autoFocus: isFocused,
|
|
77
|
-
readOnly: isReadonly,
|
|
78
|
-
disabled: isDisabled,
|
|
79
|
-
placeholder: placeholder || undefined,
|
|
80
|
-
required,
|
|
81
|
-
"aria-invalid": isError,
|
|
82
|
-
"aria-disabled": isDisabled,
|
|
83
|
-
className: cn(
|
|
84
|
-
"peer w-full rounded border border-gray-200 px-3 text-sm font-normal leading-5 outline-offset-0 ring-offset-0 focus:border-purple-600 focus:ring-purple-600 ",
|
|
85
|
-
isError ? "!border-red-600 !text-red-600 focus:!ring-red-600" : "",
|
|
86
|
-
isReadonly ? "!border-gray-400 !text-gray-500 focus:!ring-gray-400" : "",
|
|
87
|
-
className
|
|
88
|
-
),
|
|
89
|
-
...rest
|
|
90
|
-
}}
|
|
91
|
-
/>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const _InputField = forwardRef<HTMLInputElement, IInputFieldProps>(InputField)
|
|
96
|
-
export default _InputField
|
|
1
|
+
import React, { forwardRef } from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
|
|
4
|
+
export type AcceptedInputTypes =
|
|
5
|
+
| "date"
|
|
6
|
+
| "datetime-local"
|
|
7
|
+
| "email"
|
|
8
|
+
| "month"
|
|
9
|
+
| "number"
|
|
10
|
+
| "password"
|
|
11
|
+
| "search"
|
|
12
|
+
| "submit"
|
|
13
|
+
| "tel"
|
|
14
|
+
| "text"
|
|
15
|
+
| "url"
|
|
16
|
+
| "currency"
|
|
17
|
+
|
|
18
|
+
export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
19
|
+
/** Callback on change */
|
|
20
|
+
handleChange: (value: string) => void
|
|
21
|
+
/** Input ID*/
|
|
22
|
+
id?: string
|
|
23
|
+
/** Input Name */
|
|
24
|
+
name?: string
|
|
25
|
+
/** Force the focus state on the input */
|
|
26
|
+
isFocused?: boolean
|
|
27
|
+
/** Error condition */
|
|
28
|
+
isError?: boolean
|
|
29
|
+
/** Disabled state */
|
|
30
|
+
isDisabled?: boolean
|
|
31
|
+
/** Readonly state */
|
|
32
|
+
isReadonly?: boolean
|
|
33
|
+
/** Input value */
|
|
34
|
+
value: string
|
|
35
|
+
/** Type of Text Input to Render eg. "text", "email" */
|
|
36
|
+
type: AcceptedInputTypes
|
|
37
|
+
/** If field is required */
|
|
38
|
+
required?: boolean
|
|
39
|
+
/** use input psuedo classes for :valid and :invalid styles. on by default */
|
|
40
|
+
clientSideCheck?: boolean
|
|
41
|
+
/** Placeholder text */
|
|
42
|
+
placeholder?: string
|
|
43
|
+
/**ref for input */
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const InputField = (
|
|
47
|
+
{
|
|
48
|
+
type,
|
|
49
|
+
id,
|
|
50
|
+
name,
|
|
51
|
+
value,
|
|
52
|
+
isFocused,
|
|
53
|
+
isError,
|
|
54
|
+
isReadonly,
|
|
55
|
+
isDisabled,
|
|
56
|
+
handleChange,
|
|
57
|
+
required,
|
|
58
|
+
clientSideCheck = true,
|
|
59
|
+
className,
|
|
60
|
+
placeholder,
|
|
61
|
+
...rest
|
|
62
|
+
}: IInputFieldProps,
|
|
63
|
+
ref: React.Ref<HTMLInputElement>
|
|
64
|
+
) => {
|
|
65
|
+
return (
|
|
66
|
+
<input
|
|
67
|
+
{...{
|
|
68
|
+
ref,
|
|
69
|
+
type,
|
|
70
|
+
id,
|
|
71
|
+
name,
|
|
72
|
+
value,
|
|
73
|
+
onChange: (e) => {
|
|
74
|
+
if (handleChange) handleChange(e.target.value)
|
|
75
|
+
},
|
|
76
|
+
autoFocus: isFocused,
|
|
77
|
+
readOnly: isReadonly,
|
|
78
|
+
disabled: isDisabled,
|
|
79
|
+
placeholder: placeholder || undefined,
|
|
80
|
+
required,
|
|
81
|
+
"aria-invalid": isError,
|
|
82
|
+
"aria-disabled": isDisabled,
|
|
83
|
+
className: cn(
|
|
84
|
+
"peer w-full rounded border border-gray-200 px-3 text-sm font-normal leading-5 outline-offset-0 ring-offset-0 focus:border-purple-600 focus:ring-purple-600 ",
|
|
85
|
+
isError ? "!border-red-600 !text-red-600 focus:!ring-red-600" : "",
|
|
86
|
+
isReadonly ? "!border-gray-400 !text-gray-500 focus:!ring-gray-400" : "",
|
|
87
|
+
className
|
|
88
|
+
),
|
|
89
|
+
...rest
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const _InputField = forwardRef<HTMLInputElement, IInputFieldProps>(InputField)
|
|
96
|
+
export default _InputField
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import InputField, { AcceptedInputTypes, IInputFieldProps } from "./InputField"
|
|
2
|
-
export type { AcceptedInputTypes, IInputFieldProps }
|
|
3
|
-
export default InputField
|
|
1
|
+
import InputField, { AcceptedInputTypes, IInputFieldProps } from "./InputField"
|
|
2
|
+
export type { AcceptedInputTypes, IInputFieldProps }
|
|
3
|
+
export default InputField
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
-
import InputLabel from "./InputLabel"
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof InputLabel> = {
|
|
5
|
-
title: "Design System/molecules/inputs/Input Label",
|
|
6
|
-
component: InputLabel,
|
|
7
|
-
tags: ["autodocs"],
|
|
8
|
-
argTypes: {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default meta
|
|
12
|
-
type Story = StoryObj<typeof InputLabel>
|
|
13
|
-
|
|
14
|
-
export const Default: Story = {
|
|
15
|
-
args: {
|
|
16
|
-
label: "Label",
|
|
17
|
-
id: "input-label"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import InputLabel from "./InputLabel"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof InputLabel> = {
|
|
5
|
+
title: "Design System/molecules/inputs/Input Label",
|
|
6
|
+
component: InputLabel,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof InputLabel>
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
label: "Label",
|
|
17
|
+
id: "input-label"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import React, { FC } from "react"
|
|
2
|
-
import { default as cn } from "classnames"
|
|
3
|
-
|
|
4
|
-
export interface IInputLabelProps {
|
|
5
|
-
/** Prop comment */
|
|
6
|
-
isPlaceholder?: boolean
|
|
7
|
-
id: string
|
|
8
|
-
isRequired?: boolean
|
|
9
|
-
isDisabled?: boolean
|
|
10
|
-
isError?: boolean
|
|
11
|
-
isActive?: boolean
|
|
12
|
-
isFocused?: boolean
|
|
13
|
-
label?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Comment */
|
|
17
|
-
const InputLabel: FC<IInputLabelProps> = ({
|
|
18
|
-
isPlaceholder = false,
|
|
19
|
-
id,
|
|
20
|
-
isRequired,
|
|
21
|
-
isDisabled,
|
|
22
|
-
isActive,
|
|
23
|
-
isError,
|
|
24
|
-
label
|
|
25
|
-
}: IInputLabelProps) => {
|
|
26
|
-
const labelStyles = cn(
|
|
27
|
-
"z-[2]",
|
|
28
|
-
{ "inline-block font-medium transition-all text-sm text-gray-700 mb-1": !isPlaceholder },
|
|
29
|
-
{ "inline-block font-medium ml-2 relative transition-all": isPlaceholder },
|
|
30
|
-
{ "text-sm text-gray-400 px-2 top-8": isPlaceholder && !isActive },
|
|
31
|
-
{ "text-xs text-gray-700 px-1 top-[10px] bg-white": isPlaceholder && isActive },
|
|
32
|
-
{ "text-xs text-red-500 px-1 top-[10px] bg-white": isPlaceholder && isError },
|
|
33
|
-
{ "text-red-500 bg-white": !isPlaceholder && isError },
|
|
34
|
-
{ "text-gray-700/[.5]": isDisabled }
|
|
35
|
-
)
|
|
36
|
-
if (!label) return null
|
|
37
|
-
return (
|
|
38
|
-
<label htmlFor={id} className={labelStyles}>
|
|
39
|
-
{label}
|
|
40
|
-
{isRequired && <span className="text-red-500"> *</span>}
|
|
41
|
-
</label>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default InputLabel
|
|
1
|
+
import React, { FC } from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
|
|
4
|
+
export interface IInputLabelProps {
|
|
5
|
+
/** Prop comment */
|
|
6
|
+
isPlaceholder?: boolean
|
|
7
|
+
id: string
|
|
8
|
+
isRequired?: boolean
|
|
9
|
+
isDisabled?: boolean
|
|
10
|
+
isError?: boolean
|
|
11
|
+
isActive?: boolean
|
|
12
|
+
isFocused?: boolean
|
|
13
|
+
label?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Comment */
|
|
17
|
+
const InputLabel: FC<IInputLabelProps> = ({
|
|
18
|
+
isPlaceholder = false,
|
|
19
|
+
id,
|
|
20
|
+
isRequired,
|
|
21
|
+
isDisabled,
|
|
22
|
+
isActive,
|
|
23
|
+
isError,
|
|
24
|
+
label
|
|
25
|
+
}: IInputLabelProps) => {
|
|
26
|
+
const labelStyles = cn(
|
|
27
|
+
"z-[2]",
|
|
28
|
+
{ "inline-block font-medium transition-all text-sm text-gray-700 mb-1": !isPlaceholder },
|
|
29
|
+
{ "inline-block font-medium ml-2 relative transition-all": isPlaceholder },
|
|
30
|
+
{ "text-sm text-gray-400 px-2 top-8": isPlaceholder && !isActive },
|
|
31
|
+
{ "text-xs text-gray-700 px-1 top-[10px] bg-white": isPlaceholder && isActive },
|
|
32
|
+
{ "text-xs text-red-500 px-1 top-[10px] bg-white": isPlaceholder && isError },
|
|
33
|
+
{ "text-red-500 bg-white": !isPlaceholder && isError },
|
|
34
|
+
{ "text-gray-700/[.5]": isDisabled }
|
|
35
|
+
)
|
|
36
|
+
if (!label) return null
|
|
37
|
+
return (
|
|
38
|
+
<label htmlFor={id} className={labelStyles}>
|
|
39
|
+
{label}
|
|
40
|
+
{isRequired && <span className="text-red-500"> *</span>}
|
|
41
|
+
</label>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default InputLabel
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import InputLabel, { IInputLabelProps } from "./InputLabel"
|
|
2
|
-
export type { IInputLabelProps }
|
|
3
|
-
export default InputLabel
|
|
1
|
+
import InputLabel, { IInputLabelProps } from "./InputLabel"
|
|
2
|
+
export type { IInputLabelProps }
|
|
3
|
+
export default InputLabel
|