@agility/plenum-ui 2.0.0-rc13 → 2.0.0-rc14
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/build.js +8 -4
- package/dist/index.d.ts +6 -9
- package/dist/index.js +1 -6372
- package/dist/index.js.map +3 -3
- package/dist/types/stories/atoms/buttons/Button/Button.d.ts +2 -2
- package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +1 -1
- package/dist/types/stories/atoms/icons/DynamicIcon.d.ts +1 -1
- package/dist/types/stories/atoms/icons/TablerIcon.d.ts +1 -1
- package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +1 -1
- package/package.json +29 -4
- package/rollup.config.mjs +42 -0
- package/scripts/build.sh +53 -0
- package/scripts/resolve-files.js +32 -0
- package/scripts/rewrite-imports.js +24 -0
- package/stories/atoms/buttons/Button/Button.tsx +3 -2
- package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
- package/stories/atoms/icons/DynamicIcon.tsx +2 -2
- package/stories/atoms/icons/TablerIcon.tsx +1 -1
- package/stories/atoms/loaders/Loader.tsx +12 -6
- package/stories/molecules/inputs/textArea/TextArea.tsx +13 -16
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +35 -33
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +3 -3
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +1 -1
- package/stories/organisms/index.ts +9 -1
- package/tsconfig.lib.json +13 -6
- package/dist/types/stories/layouts/index.d.ts +0 -0
- package/stories/layouts/CardLayout/CardLayout.stories.tsx +0 -18
- package/stories/layouts/CardLayout/CardLayout.tsx +0 -22
- package/stories/layouts/CardLayout/index.tsx +0 -3
- package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +0 -18
- package/stories/layouts/ModalLayout/ModalLayout.tsx +0 -22
- package/stories/layouts/ModalLayout/index.tsx +0 -3
- package/stories/layouts/index.ts +0 -0
- package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
- /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.
|
|
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.
|
|
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.
|
|
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.
|
|
4
|
+
export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
5
5
|
icon: TablerIconName;
|
|
6
6
|
className?: ClassNameWithAutocomplete;
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { IInputFieldProps } from "@/stories/molecules/inputs/InputField";
|
|
3
|
-
interface ILabelProps extends React.
|
|
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"> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agility/plenum-ui",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -17,12 +17,14 @@
|
|
|
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/
|
|
20
|
+
"build:tw": "tailwindcss -o ./dist/tailwind.css",
|
|
21
21
|
"build:tsc": "yarn node build.js",
|
|
22
|
+
"Xbuild:rollup": "rollup -c",
|
|
22
23
|
"prepare": "yarn build",
|
|
23
|
-
"build": "
|
|
24
|
+
"build": "yarn clean && npm-run-all -s \"build:*\" ",
|
|
24
25
|
"clean": "rimraf dist",
|
|
25
|
-
"create-component": "node scripts/create-component.js"
|
|
26
|
+
"create-component": "node scripts/create-component.js",
|
|
27
|
+
"buildsh": "./scripts/build.sh --external:react --external:react-dom"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@floating-ui/react": "^0.25.0",
|
|
@@ -30,6 +32,9 @@
|
|
|
30
32
|
"@headlessui/tailwindcss": "^0.1.2",
|
|
31
33
|
"@heroicons/react": "^1.0.5",
|
|
32
34
|
"@next/font": "^13.4.12",
|
|
35
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
36
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
37
|
+
"@rollup/plugin-typescript": "^11.1.2",
|
|
33
38
|
"@storybook/addon-designs": "^7.0.1",
|
|
34
39
|
"@storybook/addon-essentials": "^7.1.1",
|
|
35
40
|
"@storybook/addon-interactions": "^7.1.1",
|
|
@@ -45,6 +50,7 @@
|
|
|
45
50
|
"@tailwindcss/forms": "^0.5.3",
|
|
46
51
|
"@tailwindcss/typography": "^0.5.9",
|
|
47
52
|
"@types/node": "18.11.18",
|
|
53
|
+
"acorn-jsx": "^5.3.2",
|
|
48
54
|
"autoprefixer": "^10.4.13",
|
|
49
55
|
"classnames": "^2.3.2",
|
|
50
56
|
"concurrently": "^7.6.0",
|
|
@@ -52,6 +58,7 @@
|
|
|
52
58
|
"eslint": "8.32.0",
|
|
53
59
|
"eslint-config-next": "13.1.6",
|
|
54
60
|
"eslint-plugin-storybook": "^0.6.13",
|
|
61
|
+
"fast-glob": "^3.3.1",
|
|
55
62
|
"next": "13.1.6",
|
|
56
63
|
"npm-dts": "^1.3.12",
|
|
57
64
|
"npm-run-all": "^4.1.5",
|
|
@@ -59,8 +66,26 @@
|
|
|
59
66
|
"react": "18.2.0",
|
|
60
67
|
"react-dom": "18.2.0",
|
|
61
68
|
"react-icons": "^4.10.1",
|
|
69
|
+
"rimraf": "^5.0.1",
|
|
70
|
+
"rollup": "3.28.0",
|
|
71
|
+
"rollup-plugin-dts": "^5.3.1",
|
|
72
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
73
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
74
|
+
"rollup-plugin-typescript2": "^0.35.0",
|
|
62
75
|
"storybook": "^7.1.1",
|
|
63
76
|
"tailwindcss": "^3.2.4",
|
|
64
77
|
"typescript": "^5.1.6"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"@floating-ui/react": "^0.25.0",
|
|
81
|
+
"@headlessui/react": "^1.7.10",
|
|
82
|
+
"@headlessui/tailwindcss": "^0.1.2",
|
|
83
|
+
"@heroicons/react": "^1.0.5",
|
|
84
|
+
"@tabler/icons": "^2.26.0",
|
|
85
|
+
"@tabler/icons-react": "^2.27.0",
|
|
86
|
+
"classnames": "^2.3.2",
|
|
87
|
+
"react": "18.2.0",
|
|
88
|
+
"react-dom": "18.2.0",
|
|
89
|
+
"react-icons": "^4.10.1"
|
|
65
90
|
}
|
|
66
91
|
}
|
|
@@ -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;
|
package/scripts/build.sh
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR=$(cd ${0%/*} && pwd -P)
|
|
5
|
+
|
|
6
|
+
# Known variables
|
|
7
|
+
SRC='./stories'
|
|
8
|
+
DST='./dist'
|
|
9
|
+
name="plenum-ui"
|
|
10
|
+
input="./${SRC}/index.ts"
|
|
11
|
+
|
|
12
|
+
# Find executables
|
|
13
|
+
esbuild=$(yarn bin esbuild)
|
|
14
|
+
tsc=$(yarn bin tsc)
|
|
15
|
+
resolver="${SCRIPT_DIR}/resolve-files.js"
|
|
16
|
+
rewriteImports="${SCRIPT_DIR}/rewrite-imports.js"
|
|
17
|
+
|
|
18
|
+
# Setup shared options for esbuild
|
|
19
|
+
sharedOptions=()
|
|
20
|
+
sharedOptions+=("--platform=browser")
|
|
21
|
+
sharedOptions+=("--target=es2019")
|
|
22
|
+
|
|
23
|
+
# Generate actual builds
|
|
24
|
+
# ESM
|
|
25
|
+
resolverOptions=()
|
|
26
|
+
resolverOptions+=($SRC)
|
|
27
|
+
resolverOptions+=('/**/*.{ts,tsx}')
|
|
28
|
+
resolverOptions+=('--ignore=.test.,__mocks__')
|
|
29
|
+
INPUT_FILES=$($resolver ${resolverOptions[@]})
|
|
30
|
+
|
|
31
|
+
NODE_ENV=production $esbuild $INPUT_FILES --format=esm --outdir=$DST --outbase=$SRC --minify --pure:React.createElement --define:process.env.TEST_BYPASS_TRACKED_POINTER="false" --define:__DEV__="false" ${sharedOptions[@]} &
|
|
32
|
+
NODE_ENV=production $esbuild $input --format=esm --outfile=$DST/$name.esm.js --outbase=$SRC --minify --pure:React.createElement --define:process.env.TEST_BYPASS_TRACKED_POINTER="false" --define:__DEV__="false" ${sharedOptions[@]} &
|
|
33
|
+
|
|
34
|
+
# Common JS
|
|
35
|
+
NODE_ENV=production $esbuild $input --format=cjs --outfile=$DST/$name.prod.cjs --minify --bundle --pure:React.createElement --define:process.env.TEST_BYPASS_TRACKED_POINTER="false" --define:__DEV__="false" ${sharedOptions[@]} $@ &
|
|
36
|
+
NODE_ENV=development $esbuild $input --format=cjs --outfile=$DST/$name.dev.cjs --bundle --pure:React.createElement --define:process.env.TEST_BYPASS_TRACKED_POINTER="false" --define:__DEV__="true" ${sharedOptions[@]} $@ &
|
|
37
|
+
|
|
38
|
+
# Generate types
|
|
39
|
+
tsc --emitDeclarationOnly --project tsconfig.lib.json --outDir $DST &
|
|
40
|
+
|
|
41
|
+
# Copy build files over
|
|
42
|
+
cp -rf ./build/ $DST
|
|
43
|
+
|
|
44
|
+
# Wait for all the scripts to finish
|
|
45
|
+
wait
|
|
46
|
+
|
|
47
|
+
# Rewrite ESM imports 😤
|
|
48
|
+
$rewriteImports "$DST" '/**/*.js'
|
|
49
|
+
$rewriteImports "$DST" '/**/*.d.ts'
|
|
50
|
+
|
|
51
|
+
# Remove test related files
|
|
52
|
+
rm -rf `$resolver "$DST" '/**/*.{test,__mocks__,}.*'`
|
|
53
|
+
rm -rf `$resolver "$DST" '/**/test-utils/*'`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
let fastGlob = require('fast-glob')
|
|
3
|
+
|
|
4
|
+
let parts = process.argv.slice(2)
|
|
5
|
+
let [args, flags] = parts.reduce(
|
|
6
|
+
([args, flags], part) => {
|
|
7
|
+
if (part.startsWith('--')) {
|
|
8
|
+
flags[part.slice(2, part.indexOf('='))] = part.slice(part.indexOf('=') + 1)
|
|
9
|
+
} else {
|
|
10
|
+
args.push(part)
|
|
11
|
+
}
|
|
12
|
+
return [args, flags]
|
|
13
|
+
},
|
|
14
|
+
[[], {}]
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
flags.ignore = flags.ignore ?? ''
|
|
18
|
+
flags.ignore = flags.ignore.split(',').filter(Boolean)
|
|
19
|
+
|
|
20
|
+
console.log(
|
|
21
|
+
fastGlob
|
|
22
|
+
.sync(args.join(''))
|
|
23
|
+
.filter((file) => {
|
|
24
|
+
for (let ignore of flags.ignore) {
|
|
25
|
+
if (file.includes(ignore)) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return true
|
|
30
|
+
})
|
|
31
|
+
.join('\n')
|
|
32
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
let fs = require('fs')
|
|
4
|
+
let path = require('path')
|
|
5
|
+
let fastGlob = require('fast-glob')
|
|
6
|
+
|
|
7
|
+
console.time('Rewrote imports in')
|
|
8
|
+
fastGlob.sync([process.argv.slice(2).join('')]).forEach((file) => {
|
|
9
|
+
file = path.resolve(process.cwd(), file)
|
|
10
|
+
let content = fs.readFileSync(file, 'utf8')
|
|
11
|
+
let result = content.replace(/(import|export)([^"']*?)(["'])\.(.*?)\3/g, (full, a, b, _, d) => {
|
|
12
|
+
// For idempotency reasons, if `.js` already exists, then we can skip this. This allows us to
|
|
13
|
+
// run this script over and over again without adding .js files every time.
|
|
14
|
+
if (d.endsWith('.js')) {
|
|
15
|
+
return full
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return `${a}${b}'.${d}.js'`
|
|
19
|
+
})
|
|
20
|
+
if (result !== content) {
|
|
21
|
+
fs.writeFileSync(file, result, 'utf8')
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
console.timeEnd('Rewrote imports in')
|
|
@@ -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
|
|
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
|
|
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.
|
|
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.
|
|
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
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
@@ -51,29 +51,16 @@ const Textarea: React.FC<ITextareaProps> = ({
|
|
|
51
51
|
rows = 12,
|
|
52
52
|
cols = 48,
|
|
53
53
|
onChange,
|
|
54
|
-
value
|
|
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={
|
|
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={
|
|
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.
|
|
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
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -17,4 +17,12 @@ export type {
|
|
|
17
17
|
IFormInputWithAddonsProps,
|
|
18
18
|
ITextInputSelectProps
|
|
19
19
|
}
|
|
20
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
AnimatedLabelInput,
|
|
22
|
+
AnimatedLabelTextArea,
|
|
23
|
+
ButtonDropdown,
|
|
24
|
+
Dropdown,
|
|
25
|
+
EmptySectionPlaceholder,
|
|
26
|
+
FormInputWithAddons,
|
|
27
|
+
TextInputSelect
|
|
28
|
+
}
|
package/tsconfig.lib.json
CHANGED
|
@@ -3,17 +3,24 @@
|
|
|
3
3
|
"declaration": true,
|
|
4
4
|
"declarationDir": "./dist/types",
|
|
5
5
|
"outDir": "./dist",
|
|
6
|
-
"module": "
|
|
6
|
+
"module": "ESNext",
|
|
7
7
|
"rootDir": "./",
|
|
8
|
-
"target": "
|
|
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": [
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
"include": [
|
|
20
|
+
"stories/**/*.ts",
|
|
21
|
+
"utils/**/*.ts"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
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;
|