@agility/plenum-ui 2.0.0-rc2 → 2.0.0-rc21

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 (99) hide show
  1. package/README.md +41 -11
  2. package/build.js +30 -25
  3. package/dist/index.d.ts +279 -93
  4. package/dist/index.js +1 -5935
  5. package/dist/index.js.map +4 -4
  6. package/dist/tailwind.css +63516 -0
  7. package/dist/types/stories/atoms/buttons/Button/Alternative/Alternative.stories.d.ts +1 -0
  8. package/dist/types/stories/atoms/buttons/Button/Button.d.ts +7 -9
  9. package/dist/types/stories/atoms/buttons/Button/Danger/Danger.stories.d.ts +1 -0
  10. package/dist/types/stories/atoms/buttons/Button/Primary/Primary.stories.d.ts +1 -0
  11. package/dist/types/stories/atoms/buttons/Button/Secondary/Secondary.stories.d.ts +1 -0
  12. package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +1 -1
  13. package/dist/types/stories/atoms/icons/DynamicIcon.d.ts +1 -1
  14. package/dist/types/stories/atoms/icons/TablerIcon.d.ts +1 -1
  15. package/dist/types/stories/index.d.ts +4 -4
  16. package/dist/types/stories/molecules/index.d.ts +3 -3
  17. package/dist/types/stories/molecules/inputs/InputCounter/InputCounter.d.ts +10 -0
  18. package/dist/types/stories/molecules/inputs/InputCounter/index.d.ts +2 -0
  19. package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +8 -4
  20. package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +39 -0
  21. package/dist/types/stories/molecules/inputs/TextInput/index.d.ts +4 -0
  22. package/dist/types/stories/molecules/inputs/index.d.ts +5 -4
  23. package/dist/types/stories/molecules/inputs/select/Select.d.ts +2 -2
  24. package/dist/types/stories/molecules/inputs/textArea/TextArea.d.ts +34 -21
  25. package/dist/types/stories/molecules/inputs/textArea/TextArea.stories.d.ts +4 -4
  26. package/dist/types/stories/molecules/inputs/textArea/index.d.ts +3 -3
  27. package/dist/types/stories/molecules/inputs/toggleSwitch/ToggleSwitch.d.ts +9 -7
  28. package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +3 -5
  29. package/dist/types/stories/organisms/AnimatedLabelInput/index.d.ts +1 -1
  30. package/dist/types/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.d.ts +12 -0
  31. package/dist/types/stories/organisms/AnimatedLabelTextArea/index.d.ts +3 -0
  32. package/dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts +18 -15
  33. package/dist/types/stories/organisms/DropdownComponent/index.d.ts +2 -2
  34. package/dist/types/stories/organisms/EmptySectionPlaceholder/index.d.ts +1 -1
  35. package/dist/types/stories/organisms/TextInputSelect/InputSelect.d.ts +16 -0
  36. package/dist/types/stories/organisms/TextInputSelect/TextInputSelect.d.ts +48 -0
  37. package/dist/types/stories/organisms/TextInputSelect/index.d.ts +3 -0
  38. package/dist/types/stories/organisms/index.d.ts +5 -3
  39. package/local.sh +100 -0
  40. package/package.json +35 -18
  41. package/rollup.config.mjs +42 -0
  42. package/stories/Introduction.mdx +1 -1
  43. package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +7 -0
  44. package/stories/atoms/buttons/Button/Button.tsx +45 -17
  45. package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +7 -0
  46. package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +7 -0
  47. package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +7 -0
  48. package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
  49. package/stories/atoms/icons/DynamicIcon.tsx +3 -2
  50. package/stories/atoms/icons/TablerIcon.tsx +1 -1
  51. package/stories/atoms/loaders/Loader.tsx +12 -6
  52. package/stories/index.ts +22 -10
  53. package/stories/molecules/index.ts +22 -6
  54. package/stories/molecules/inputs/InputCounter/InputCounter.stories.tsx +18 -0
  55. package/stories/molecules/inputs/InputCounter/InputCounter.tsx +24 -0
  56. package/stories/molecules/inputs/InputCounter/index.tsx +3 -0
  57. package/stories/molecules/inputs/InputField/InputField.tsx +13 -7
  58. package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +32 -0
  59. package/stories/molecules/inputs/TextInput/TextInput.tsx +165 -0
  60. package/stories/molecules/inputs/TextInput/index.tsx +5 -0
  61. package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -1
  62. package/stories/molecules/inputs/index.ts +18 -4
  63. package/stories/molecules/inputs/select/Select.tsx +1 -1
  64. package/stories/molecules/inputs/textArea/TextArea.stories.ts +7 -5
  65. package/stories/molecules/inputs/textArea/TextArea.tsx +139 -48
  66. package/stories/molecules/inputs/textArea/index.ts +3 -3
  67. package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +61 -57
  68. package/stories/molecules/tabs/index.tsx +2 -3
  69. package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +10 -1
  70. package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +43 -37
  71. package/stories/organisms/AnimatedLabelInput/index.tsx +1 -1
  72. package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.stories.tsx +26 -0
  73. package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +61 -0
  74. package/stories/organisms/AnimatedLabelTextArea/index.tsx +3 -0
  75. package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +59 -58
  76. package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +13 -16
  77. package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +1 -1
  78. package/stories/organisms/DropdownComponent/DropdownComponent.tsx +155 -131
  79. package/stories/organisms/DropdownComponent/dropdownItems.ts +32 -8
  80. package/stories/organisms/DropdownComponent/index.ts +2 -2
  81. package/stories/organisms/EmptySectionPlaceholder/index.tsx +2 -1
  82. package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +7 -2
  83. package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -0
  84. package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -0
  85. package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -0
  86. package/stories/organisms/TextInputSelect/index.tsx +3 -0
  87. package/stories/organisms/index.ts +15 -4
  88. package/tsconfig.lib.json +13 -6
  89. package/watch.js +50 -0
  90. package/.yarnrc.yml +0 -1
  91. package/dist/types/stories/layouts/index.d.ts +0 -0
  92. package/stories/layouts/CardLayout/CardLayout.stories.tsx +0 -18
  93. package/stories/layouts/CardLayout/CardLayout.tsx +0 -22
  94. package/stories/layouts/CardLayout/index.tsx +0 -3
  95. package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +0 -18
  96. package/stories/layouts/ModalLayout/ModalLayout.tsx +0 -22
  97. package/stories/layouts/ModalLayout/index.tsx +0 -3
  98. package/stories/layouts/index.ts +0 -0
  99. package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
@@ -0,0 +1,186 @@
1
+ import React, { FC, useEffect, useId, useRef, useState } from "react"
2
+ import { default as cn } from "classnames"
3
+
4
+ import { InputSelect } from "./InputSelect"
5
+ import { AcceptedInputTypes, InputField } from "@/stories/molecules"
6
+ import InputCounter from "@/stories/molecules/inputs/InputCounter"
7
+
8
+ export type SelectOptions = {
9
+ label: string
10
+ value: string
11
+ }
12
+
13
+ export interface ITextInputSelectProps {
14
+ /** Input type*/
15
+ type: AcceptedInputTypes
16
+ /** Input ID */
17
+ id?: string
18
+ /** Input Name */
19
+ name?: string
20
+ /** Label for the input */
21
+ label?: string
22
+ /** placeholder for the input */
23
+ placeholder?: string
24
+ /** Force the focus state on the input */
25
+ isFocused?: boolean
26
+ /** Error state */
27
+ isError?: boolean
28
+ /** If field is required */
29
+ isRequired?: boolean
30
+ /** Disabled state */
31
+ isDisabled?: boolean
32
+ /** Set default value */
33
+ defaultValue?: string
34
+ /** Set value */
35
+ value: string
36
+ /** Message shown under the text field */
37
+ message?: string
38
+ /** Input character counter */
39
+ isShowCounter?: boolean
40
+ /** Max length of input character */
41
+ maxLength?: number
42
+ /** Select input location */
43
+ selectLocation?: "left" | "right"
44
+ /** Prefix */
45
+ prefix?: string
46
+ /** List of options to show on the select field */
47
+ inputOptions?: SelectOptions[]
48
+ /** Callback on base input */
49
+ onChange?(value: string): void
50
+ /** Callback on input select field */
51
+ onSelectOption?(value: string): void
52
+ }
53
+
54
+ const TextInputSelect: FC<ITextInputSelectProps> = ({
55
+ label,
56
+ isFocused,
57
+ isError,
58
+ id,
59
+ name,
60
+ isRequired,
61
+ type,
62
+ defaultValue,
63
+ isDisabled,
64
+ message,
65
+ isShowCounter,
66
+ maxLength,
67
+ placeholder,
68
+ inputOptions,
69
+ selectLocation = "right",
70
+ prefix,
71
+ onChange,
72
+ onSelectOption,
73
+ value: externalValue
74
+ }: ITextInputSelectProps) => {
75
+ const [isFocus, setIsFocus] = useState<boolean>(Boolean(isFocused))
76
+ const [value, setValue] = useState<string>(defaultValue || "")
77
+ const inputRef = useRef<HTMLInputElement>(null)
78
+
79
+ const uniqueID = useId()
80
+ if (!id) id = `select-${uniqueID}`
81
+ if (!name) name = id
82
+
83
+ useEffect(() => {
84
+ setValue(externalValue)
85
+ }, [externalValue])
86
+
87
+ // set force focus
88
+ useEffect(() => {
89
+ const input = inputRef.current
90
+ if (!input || isFocus === undefined || isFocused === undefined || isDisabled) return
91
+ if (isFocus || isFocused) {
92
+ input.focus()
93
+ } else {
94
+ input.blur()
95
+ }
96
+ }, [isFocus, isFocused])
97
+
98
+ // set label as active if default value is set
99
+ useEffect(() => {
100
+ const input = inputRef.current
101
+ if (!input || defaultValue === undefined || defaultValue === "") return
102
+ }, [defaultValue])
103
+
104
+ const handleInputFocus = (): void => {
105
+ setIsFocus(true)
106
+ // add other focus effects here
107
+ }
108
+
109
+ const handleInputBlur = (): void => {
110
+ setIsFocus(false)
111
+ // add other focus effects here
112
+ }
113
+ const labelStyles = cn("block inline-block font-medium transition-all text-sm text-gray-700 mb-1", {
114
+ "text-red-500 bg-white": isError
115
+ })
116
+
117
+ const discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError })
118
+
119
+ return (
120
+ <div>
121
+ {label && (
122
+ <label htmlFor={id} className={labelStyles}>
123
+ {label}
124
+ {isRequired && <span className="text-red-500"> *</span>}
125
+ </label>
126
+ )}
127
+ <div className="flex">
128
+ {inputOptions?.length && selectLocation === "left" && (
129
+ <InputSelect
130
+ inputOptions={inputOptions}
131
+ align="left"
132
+ onSelectOption={onSelectOption}
133
+ className={cn(isError ? "border-red-500" : "")}
134
+ isDisabled={isDisabled}
135
+ />
136
+ )}
137
+ <div className="relative flex-grow focus-within:z-20">
138
+ {prefix && (
139
+ <div className="pointer-events-none pr-10 absolute inset-y-0 left-0 flex items-center pl-3">
140
+ <span className="text-gray-500 sm:text-sm">{prefix}</span>
141
+ </div>
142
+ )}
143
+ <InputField
144
+ onFocus={handleInputFocus}
145
+ onBlur={handleInputBlur}
146
+ handleChange={(v) => onChange && onChange(v)}
147
+ ref={inputRef}
148
+ type={type}
149
+ name={name}
150
+ id={id}
151
+ className={cn(
152
+ "w-full border border-gray-300 py-2 px-3 text-sm font-normal leading-5",
153
+ "focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm",
154
+ selectLocation === "right" ? `rounded-l` : `rounded-r`,
155
+ isError ? "border-red-500" : "",
156
+ prefix ? `pl-7` : ""
157
+ )}
158
+ isDisabled={isDisabled}
159
+ defaultValue={defaultValue}
160
+ value={value}
161
+ maxLength={maxLength}
162
+ placeholder={placeholder}
163
+ />
164
+ </div>
165
+ {inputOptions?.length && selectLocation === "right" && (
166
+ <InputSelect
167
+ inputOptions={inputOptions}
168
+ align={"right"}
169
+ onSelectOption={onSelectOption}
170
+ isDisabled={isDisabled}
171
+ className={cn(isError ? "border-red-500" : "")}
172
+ />
173
+ )}
174
+ </div>
175
+ <div className="flex flex-row space-x-3">
176
+ <div className="grow">{message && <span className={discriptionStyles}>{message}</span>}</div>
177
+ {isShowCounter && (
178
+ <div className="shrink-0">
179
+ <InputCounter current={Number(value?.length)} limit={maxLength} />
180
+ </div>
181
+ )}
182
+ </div>
183
+ </div>
184
+ )
185
+ }
186
+ export default TextInputSelect
@@ -0,0 +1,3 @@
1
+ import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
2
+ export type { ITextInputSelectProps }
3
+ export default TextInputSelect
@@ -1,16 +1,27 @@
1
1
  import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput"
2
+ import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
2
3
  import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown"
3
- import Dropdown, { IDropdownClassnames, IDropdownProps, IItemProp } from "./DropdownComponent"
4
+ import Dropdown, { IDropdownProps, IItemProp } from "./DropdownComponent"
4
5
  import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder"
5
6
  import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons"
7
+ import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
6
8
 
7
9
  export type {
8
10
  IAnimatedLabelInputProps,
11
+ IAnimatedLabelTextAreaProps,
9
12
  IButtonDropdownProps,
10
- IDropdownClassnames,
11
13
  IDropdownProps,
12
14
  IEmptySectionPlaceholderProps,
13
15
  IItemProp,
14
- IFormInputWithAddonsProps
16
+ IFormInputWithAddonsProps,
17
+ ITextInputSelectProps
18
+ }
19
+ export {
20
+ AnimatedLabelInput,
21
+ AnimatedLabelTextArea,
22
+ ButtonDropdown,
23
+ Dropdown,
24
+ EmptySectionPlaceholder,
25
+ FormInputWithAddons,
26
+ TextInputSelect
15
27
  }
16
- export { AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons }
package/tsconfig.lib.json CHANGED
@@ -3,17 +3,24 @@
3
3
  "declaration": true,
4
4
  "declarationDir": "./dist/types",
5
5
  "outDir": "./dist",
6
- "module": "esnext",
6
+ "module": "ESNext",
7
7
  "rootDir": "./",
8
- "target": "es2021",
8
+ "target": "ESNext",
9
9
  "esModuleInterop": true,
10
10
  "moduleResolution": "node",
11
11
  "baseUrl": ".",
12
12
  "paths": {
13
- "@/*": ["./*"]
13
+ "@/*": [
14
+ "./*"
15
+ ]
14
16
  },
15
17
  "jsx": "react-jsx"
16
18
  },
17
- "include": ["stories/**/*.ts", "utils/**/*.ts"],
18
- "exclude": ["node_modules"]
19
- }
19
+ "include": [
20
+ "stories/**/*.ts",
21
+ "utils/**/*.ts"
22
+ ],
23
+ "exclude": [
24
+ "node_modules"
25
+ ]
26
+ }
package/watch.js ADDED
@@ -0,0 +1,50 @@
1
+ require('dotenv').config()
2
+ const path = require('path')
3
+ const esbuild = require("esbuild")
4
+
5
+ const context = {
6
+ logLevel: "info",
7
+ entryPoints: [path.resolve(__dirname, "stories/index.ts")],
8
+ bundle: true,
9
+ platform: "browser",
10
+ target: ["esnext"],
11
+ minify: true,
12
+ pure: ["React.createElement"],
13
+ jsx: 'transform',
14
+ loader: { '.js': 'jsx' },
15
+ outdir: path.resolve(__dirname, "dist"),
16
+ sourcemap: true,
17
+ external: [
18
+ "react",
19
+ "react-dom",
20
+ "@floating-ui/react",
21
+ "@headlessui/react",
22
+ "@headlessui/tailwindcss",
23
+ "@heroicons/react",
24
+ "@tabler/icons",
25
+ "@tabler/icons-react",
26
+ "classnames",
27
+ "react-icons",
28
+ "@storybook/react",
29
+ "@storybook/addon-designs",
30
+ "@storybook/addon-essentials",
31
+ "@storybook/addon-interactions",
32
+ "@storybook/addon-links",
33
+ "@storybook/blocks",
34
+ "@storybook/manager-api",
35
+ "@storybook/nextjs",
36
+ "@storybook/react",
37
+ "@storybook/testing-library",
38
+ "@storybook/theming",
39
+ "storybook"
40
+ ],
41
+ format: "esm"
42
+ }
43
+
44
+ async function watch() {
45
+ const ctx = await esbuild.context(context)
46
+ ctx.watch()
47
+ console.log(`Watching....`)
48
+ }
49
+
50
+ watch()
package/.yarnrc.yml DELETED
@@ -1 +0,0 @@
1
- nodeLinker: node-modules
File without changes
@@ -1,18 +0,0 @@
1
-
2
- import type { Meta, StoryObj } from "@storybook/react"
3
- import CardLayout, { ICardLayoutProps } from "./CardLayout"
4
-
5
- const meta: Meta<typeof CardLayout> = {
6
- title: "Design System/layouts/CardLayout",
7
- component: CardLayout,
8
- tags: ["autodocs"],
9
- argTypes: {}
10
- }
11
-
12
- export default meta
13
- type Story = StoryObj<typeof CardLayout>
14
- export const DefaultCardLayoutStory: Story = {
15
- args: {
16
-
17
- }
18
- }
@@ -1,22 +0,0 @@
1
-
2
- import React from "react"
3
- import EmptySectionPlaceholder from "@/stories/organisms/EmptySectionPlaceholder"
4
-
5
- export interface ICardLayoutProps {}
6
-
7
- const CardLayout: React.FC<ICardLayoutProps> = ({}) => {
8
- return (
9
- <EmptySectionPlaceholder
10
- {...{
11
- icon: {
12
- icon: "IconCode"
13
- },
14
- mutedText: "Coming Soon! 🚧",
15
- primaryMessage: "We're working on this component. Be sure to check back soon!",
16
- actions: []
17
- }}
18
- />
19
- )
20
- };
21
-
22
- export default CardLayout;
@@ -1,3 +0,0 @@
1
-
2
- export { default } from './CardLayout';
3
- export * from './CardLayout';
@@ -1,18 +0,0 @@
1
-
2
- import type { Meta, StoryObj } from "@storybook/react"
3
- import ModalLayout, { IModalLayoutProps } from "./ModalLayout"
4
-
5
- const meta: Meta<typeof ModalLayout> = {
6
- title: "Design System/layouts/ModalLayout",
7
- component: ModalLayout,
8
- tags: ["autodocs"],
9
- argTypes: {}
10
- }
11
-
12
- export default meta
13
- type Story = StoryObj<typeof ModalLayout>
14
- export const DefaultModalLayoutStory: Story = {
15
- args: {
16
-
17
- }
18
- }
@@ -1,22 +0,0 @@
1
-
2
- import React from "react"
3
- import EmptySectionPlaceholder from "@/stories/organisms/EmptySectionPlaceholder"
4
-
5
- export interface IModalLayoutProps {}
6
-
7
- const ModalLayout: React.FC<IModalLayoutProps> = ({}) => {
8
- return (
9
- <EmptySectionPlaceholder
10
- {...{
11
- icon: {
12
- icon: "IconCode"
13
- },
14
- mutedText: "Coming Soon! 🚧",
15
- primaryMessage: "We're working on this component. Be sure to check back soon!",
16
- actions: []
17
- }}
18
- />
19
- )
20
- };
21
-
22
- export default ModalLayout;
@@ -1,3 +0,0 @@
1
-
2
- export { default } from './ModalLayout';
3
- export * from './ModalLayout';
File without changes