@fpkit/acss 0.5.3 → 0.5.5
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/libs/chunk-QHIABQNQ.js +8 -0
- package/libs/chunk-QHIABQNQ.js.map +1 -0
- package/libs/chunk-ZOHIKF6I.cjs +31 -0
- package/libs/chunk-ZOHIKF6I.cjs.map +1 -0
- package/libs/components/breadcrumbs/breadcrumb.css +1 -1
- package/libs/components/breadcrumbs/breadcrumb.min.css +1 -1
- package/libs/components/buttons/button.css +1 -1
- package/libs/components/buttons/button.css.map +1 -1
- package/libs/components/buttons/button.min.css +2 -2
- package/libs/components/details/details.css +1 -1
- package/libs/components/details/details.css.map +1 -1
- package/libs/components/details/details.min.css +2 -2
- package/libs/components/dialog/dialog.css +1 -0
- package/libs/components/dialog/dialog.css.map +1 -0
- package/libs/components/dialog/dialog.min.css +3 -0
- package/libs/components/icons/icon.css +1 -1
- package/libs/components/icons/icon.css.map +1 -1
- package/libs/components/icons/icon.min.css +2 -2
- package/libs/{icons-2f29127c.d.ts → icons-1f5afc0c.d.ts} +1 -32
- package/libs/icons.cjs +2 -2
- package/libs/icons.d.cts +1 -1
- package/libs/icons.d.ts +1 -1
- package/libs/icons.js +1 -1
- package/libs/index.cjs +39 -39
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +27 -28
- package/libs/index.d.ts +27 -28
- package/libs/index.js +6 -6
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/alert-dialog/alert-dialog.stories.tsx +35 -0
- package/src/components/alert-dialog/alert-dialog.tsx +76 -0
- package/src/components/badge/badge.stories.tsx +21 -23
- package/src/components/breadcrumbs/breadcrumb.scss +2 -2
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +42 -47
- package/src/components/buttons/button.scss +40 -15
- package/src/components/buttons/button.stories.tsx +8 -1
- package/src/components/cards/card.stories.tsx +15 -15
- package/src/components/details/details.scss +6 -5
- package/src/components/details/details.stories.tsx +33 -30
- package/src/components/details/details.tsx +17 -17
- package/src/components/dialog/dialog.scss +61 -0
- package/src/components/dialog/dialog.stories.tsx +61 -0
- package/src/components/dialog/dialog.tsx +83 -0
- package/src/components/dialog/view/dialog-header.stories.tsx +43 -0
- package/src/components/dialog/view/dialog-header.tsx +32 -0
- package/src/components/form/form.stories.tsx +16 -16
- package/src/components/form/input.stories.tsx +62 -62
- package/src/components/form/select.stories.tsx +22 -15
- package/src/components/heading/heading.stories.tsx +32 -33
- package/src/components/heading/heading.tsx +1 -1
- package/src/components/icons/components/svg.tsx +0 -1
- package/src/components/icons/icon.scss +1 -3
- package/src/components/icons/icon.stories.tsx +45 -78
- package/src/components/icons/icon.tsx +0 -11
- package/src/components/icons/types.ts +1 -1
- package/src/components/images/figure.stories.tsx +13 -13
- package/src/components/images/img.stories.tsx +12 -12
- package/src/components/link/link.stories.tsx +32 -35
- package/src/components/link/link.tsx +27 -14
- package/src/components/list/list.stories.tsx +16 -16
- package/src/components/modal/dialog.tsx +13 -12
- package/src/components/modal/modal.tsx +28 -30
- package/src/components/nav/nav.stories.tsx +25 -24
- package/src/components/popover/popover.stories.tsx +17 -18
- package/src/components/progress/progress.stories.tsx +14 -20
- package/src/components/tag/tag.stories.tsx +17 -18
- package/src/components/text/text.stories.tsx +28 -29
- package/src/components/text-to-speech/TextToSpeech.stories.tsx +100 -101
- package/src/index.scss +22 -21
- package/src/index.ts +31 -30
- package/src/patterns/page/page-header.stories.tsx +17 -21
- package/src/sass/_globals.scss +7 -31
- package/src/sass/_styles.scss +2 -1
- package/src/sass/styles/_colors.scss +13 -0
- package/src/styles/breadcrumbs/breadcrumb.css +1 -1
- package/src/styles/buttons/button.css +25 -2
- package/src/styles/buttons/button.css.map +1 -1
- package/src/styles/details/details.css +5 -3
- package/src/styles/details/details.css.map +1 -1
- package/src/styles/dialog/dialog.css +61 -0
- package/src/styles/dialog/dialog.css.map +1 -0
- package/src/styles/icons/icon.css +1 -3
- package/src/styles/icons/icon.css.map +1 -1
- package/src/styles/index.css +107 -30
- package/src/styles/index.css.map +1 -1
- package/libs/chunk-TBM2QIVT.js +0 -8
- package/libs/chunk-TBM2QIVT.js.map +0 -1
- package/libs/chunk-VAH6X2DZ.cjs +0 -31
- package/libs/chunk-VAH6X2DZ.cjs.map +0 -1
- package/src/components/readme.stories.mdx +0 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--dialog-min-w: 320px;
|
|
3
|
+
--dialog-gap: 0.75rem;
|
|
4
|
+
--dialog-border-color: lightgray;
|
|
5
|
+
--dialog-border-radius: 0.5rem;
|
|
6
|
+
--dialog-padding: 0.5rem;
|
|
7
|
+
--dialog-padding-inline: 1rem;
|
|
8
|
+
--dialog-close-color: gray;
|
|
9
|
+
--dialog-button-bg: transparent;
|
|
10
|
+
--dialog-button-border: transparent 1px solid;
|
|
11
|
+
--dialog-button-hover-bg: whitesmoke;
|
|
12
|
+
--dialog-display: flex;
|
|
13
|
+
--dialog-flex-direction: column;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
dialog {
|
|
17
|
+
min-width: var(--dialog-min-w);
|
|
18
|
+
gap: var(--dialog-gap);
|
|
19
|
+
border-color: var(--dialog-border-color);
|
|
20
|
+
border-radius: var(--dialog-border-radius);
|
|
21
|
+
padding: var(--dialog-padding);
|
|
22
|
+
padding-inline: var(--dialog-padding-inline);
|
|
23
|
+
padding-block-start: calc(var(--dialog-padding) - 0rem);
|
|
24
|
+
|
|
25
|
+
&[open] {
|
|
26
|
+
display: var(--dialog-display);
|
|
27
|
+
flex-direction: var(--dialog-flex-direction);
|
|
28
|
+
gap: var(--dialog-gap);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.dialog-header {
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
align-items: center;
|
|
36
|
+
width: 100%;
|
|
37
|
+
min-width: 320px;
|
|
38
|
+
h3 {
|
|
39
|
+
margin-block-start: 0;
|
|
40
|
+
margin-block-end: 0;
|
|
41
|
+
}
|
|
42
|
+
.dialog-close {
|
|
43
|
+
margin-block-end: 0;
|
|
44
|
+
}
|
|
45
|
+
button[type="button"] {
|
|
46
|
+
background-color: var(--dialog-button-bg);
|
|
47
|
+
border: var(--dialog-button-border);
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
&:hover,
|
|
50
|
+
&:focus {
|
|
51
|
+
border-color: currentColor;
|
|
52
|
+
background-color: var(--dialog-button-hover-bg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.alert-dialog-actions {
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: flex-start;
|
|
60
|
+
gap: 0.5rem;
|
|
61
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect } from "@storybook/test";
|
|
3
|
+
|
|
4
|
+
import Dialog from "./dialog";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Dialog> = {
|
|
7
|
+
title: "FP.REACT Components/Dialog",
|
|
8
|
+
component: Dialog,
|
|
9
|
+
tags: ["alpha"],
|
|
10
|
+
parameters: {
|
|
11
|
+
// actions: { argTypesRegex: "^on.*" },
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component: "Dialog component for displaying modal dialogs.",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
children: "Dialog Content",
|
|
20
|
+
},
|
|
21
|
+
decorators: [
|
|
22
|
+
(Story) => (
|
|
23
|
+
<div
|
|
24
|
+
style={{
|
|
25
|
+
display: "flex",
|
|
26
|
+
justifyContent: "center",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
width: "500px",
|
|
29
|
+
marginInline: "20px",
|
|
30
|
+
marginBlockStart: "5rem",
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<Story />
|
|
34
|
+
</div>
|
|
35
|
+
),
|
|
36
|
+
],
|
|
37
|
+
} as Story;
|
|
38
|
+
|
|
39
|
+
export default meta;
|
|
40
|
+
type Story = StoryObj<typeof Dialog>;
|
|
41
|
+
|
|
42
|
+
export const DialogComponent: Story = {
|
|
43
|
+
args: {},
|
|
44
|
+
play: async ({ canvasElement }) => {
|
|
45
|
+
const canvas = within(canvasElement);
|
|
46
|
+
expect(canvas.getByText(/dialog content/i)).toBeInTheDocument();
|
|
47
|
+
expect(canvas.getByRole("dialog")).toBeInTheDocument();
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const NoDialogTitle: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
dialogTitle: "",
|
|
54
|
+
children:
|
|
55
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga quod tenetur, alias vitae incidunt porro rem laboriosam deserunt, fugit eligendi eum eos ducimus inventore suscipit, quasi dignissimos dicta. Deleniti, error",
|
|
56
|
+
},
|
|
57
|
+
play: async ({ canvasElement }) => {
|
|
58
|
+
const canvas = within(canvasElement);
|
|
59
|
+
expect(canvas.queryByRole("heading")).not.toBeInTheDocument();
|
|
60
|
+
},
|
|
61
|
+
} as Story;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import UI from "#components/ui";
|
|
3
|
+
import DialogHeader from "./view/dialog-header";
|
|
4
|
+
|
|
5
|
+
export type DialogProps = {
|
|
6
|
+
isOpen?: boolean;
|
|
7
|
+
onOpen?: () => void;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
onCancel?: () => void;
|
|
10
|
+
dialogTitle?: string;
|
|
11
|
+
showDialogHeader?: boolean;
|
|
12
|
+
isAlertDialog?: boolean;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Dialog = ({
|
|
17
|
+
isOpen = true,
|
|
18
|
+
dialogTitle = "Dialog",
|
|
19
|
+
onOpen,
|
|
20
|
+
onClose,
|
|
21
|
+
onCancel,
|
|
22
|
+
showDialogHeader = true,
|
|
23
|
+
isAlertDialog,
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}: DialogProps): JSX.Element => {
|
|
27
|
+
const dialogRef = React.useRef<HTMLDialogElement>(null);
|
|
28
|
+
const [dialogOpen, setDialogOpen] = React.useState(isOpen);
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (isOpen && onOpen) {
|
|
32
|
+
dialogRef.current?.showModal();
|
|
33
|
+
onOpen();
|
|
34
|
+
}
|
|
35
|
+
setDialogOpen(isOpen);
|
|
36
|
+
}, [isOpen]);
|
|
37
|
+
|
|
38
|
+
const handleCancelEvent = (e: React.SyntheticEvent<HTMLDialogElement>) => {
|
|
39
|
+
if (e.currentTarget === e.target) {
|
|
40
|
+
if (onCancel) {
|
|
41
|
+
onCancel();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleCloseEvent = (e: React.SyntheticEvent<HTMLDialogElement>) => {
|
|
47
|
+
if (e.currentTarget === e.target) {
|
|
48
|
+
if (onClose) {
|
|
49
|
+
onClose();
|
|
50
|
+
}
|
|
51
|
+
isOpen = false;
|
|
52
|
+
dialogRef.current?.close();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const closeDialog = () => {
|
|
57
|
+
if (onClose) {
|
|
58
|
+
onClose();
|
|
59
|
+
}
|
|
60
|
+
isOpen = false;
|
|
61
|
+
dialogRef.current?.close();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<UI
|
|
66
|
+
as="dialog"
|
|
67
|
+
open={dialogOpen}
|
|
68
|
+
ref={dialogRef}
|
|
69
|
+
role={isAlertDialog ? "alertdialog" : undefined}
|
|
70
|
+
onCancel={handleCancelEvent}
|
|
71
|
+
onClose={handleCloseEvent}
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
{showDialogHeader && (
|
|
75
|
+
<DialogHeader dialogTitle={dialogTitle} onClose={closeDialog} />
|
|
76
|
+
)}
|
|
77
|
+
{children}
|
|
78
|
+
</UI>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default React.memo(Dialog);
|
|
83
|
+
Dialog.displayName = "Dialog";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect } from "@storybook/test";
|
|
3
|
+
|
|
4
|
+
import DialogHeader from "./dialog-header";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof DialogHeader> = {
|
|
7
|
+
title: "FP.REACT Views/Dialog ",
|
|
8
|
+
component: DialogHeader,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
actions: { argTypesRegex: "^on.*" },
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component:
|
|
15
|
+
"DialogHeader component - A header component for dialog/modal windows that displays a title and optional close button.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
children: "Dialog Header",
|
|
21
|
+
},
|
|
22
|
+
} as Meta;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof DialogHeader>;
|
|
26
|
+
|
|
27
|
+
export const Default: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
dialogTitle: "Default Dialog ",
|
|
30
|
+
},
|
|
31
|
+
play: async ({ canvasElement }) => {
|
|
32
|
+
const canvas = within(canvasElement);
|
|
33
|
+
expect(canvas.getByText(/default dialog/i)).toBeInTheDocument();
|
|
34
|
+
},
|
|
35
|
+
} as Story;
|
|
36
|
+
|
|
37
|
+
export const WithCloseButton: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
dialogTitle: "Dialog Header with Close",
|
|
40
|
+
onClose: () => console.log("Close clicked"),
|
|
41
|
+
},
|
|
42
|
+
} as Story;
|
|
43
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import UI from "#components/ui";
|
|
3
|
+
import Heading from "#components/heading/heading";
|
|
4
|
+
import Button from "#components/buttons/button";
|
|
5
|
+
import Icon from "#components/icons/icon";
|
|
6
|
+
|
|
7
|
+
export type DialogHeaderProps = {
|
|
8
|
+
dialogTitle: string;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const DialogHeader = ({
|
|
13
|
+
dialogTitle,
|
|
14
|
+
onClose,
|
|
15
|
+
}: DialogHeaderProps): JSX.Element => {
|
|
16
|
+
return (
|
|
17
|
+
<UI as="div" classes="dialog-header">
|
|
18
|
+
{dialogTitle && <Heading type="h3">{dialogTitle}</Heading>}
|
|
19
|
+
<Button
|
|
20
|
+
type="button"
|
|
21
|
+
onClick={onClose}
|
|
22
|
+
classes="transparent"
|
|
23
|
+
data-btn="icon pill"
|
|
24
|
+
>
|
|
25
|
+
<Icon.Remove size={16} />
|
|
26
|
+
</Button>
|
|
27
|
+
</UI>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default React.memo(DialogHeader);
|
|
32
|
+
DialogHeader.displayName = "DialogHeader";
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, expect } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import './form.scss'
|
|
4
|
+
import Form from "./form";
|
|
5
|
+
import "./form.scss";
|
|
7
6
|
|
|
8
7
|
const meta: Meta<typeof Form> = {
|
|
9
|
-
title:
|
|
8
|
+
title: "FP.REACT Forms/Examples",
|
|
9
|
+
tags: ["beta"],
|
|
10
10
|
component: Form,
|
|
11
11
|
parameters: {
|
|
12
12
|
docs: {
|
|
13
13
|
description: {
|
|
14
|
-
component:
|
|
14
|
+
component: "Form description here...",
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
args: {
|
|
19
|
-
children:
|
|
20
|
-
name:
|
|
19
|
+
children: "Link",
|
|
20
|
+
name: "my-form",
|
|
21
21
|
},
|
|
22
|
-
} as Story
|
|
22
|
+
} as Story;
|
|
23
23
|
|
|
24
|
-
export default meta
|
|
25
|
-
type Story = StoryObj<typeof Form
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof Form>;
|
|
26
26
|
|
|
27
27
|
export const FormComponent: Story = {
|
|
28
28
|
args: {
|
|
@@ -42,8 +42,8 @@ export const FormComponent: Story = {
|
|
|
42
42
|
),
|
|
43
43
|
},
|
|
44
44
|
play: async ({ canvasElement }) => {
|
|
45
|
-
const canvas = within(canvasElement)
|
|
46
|
-
const form = canvas.getByRole(
|
|
47
|
-
await expect(form).toBeInTheDocument()
|
|
45
|
+
const canvas = within(canvasElement);
|
|
46
|
+
const form = canvas.getByRole("form");
|
|
47
|
+
await expect(form).toBeInTheDocument();
|
|
48
48
|
},
|
|
49
|
-
} as Story
|
|
49
|
+
} as Story;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within, userEvent, expect } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, userEvent, expect } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import './form.scss'
|
|
4
|
+
import Input from "./inputs";
|
|
5
|
+
import "./form.scss";
|
|
7
6
|
|
|
8
7
|
const meta: Meta<typeof Input> = {
|
|
9
|
-
title:
|
|
8
|
+
title: "FP.REACT Forms/Inputs",
|
|
10
9
|
component: Input,
|
|
10
|
+
tags: ["rc"],
|
|
11
11
|
args: {},
|
|
12
12
|
parameters: {
|
|
13
13
|
docs: {
|
|
@@ -17,18 +17,18 @@ const meta: Meta<typeof Input> = {
|
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
} as Story
|
|
20
|
+
} as Story;
|
|
21
21
|
|
|
22
|
-
export default meta
|
|
23
|
-
type Story = StoryObj<typeof Input
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof Input>;
|
|
24
24
|
|
|
25
25
|
export const InputComponent: Story = {
|
|
26
26
|
args: {},
|
|
27
27
|
play: async ({ canvasElement }) => {
|
|
28
|
-
const canvas = within(canvasElement)
|
|
29
|
-
expect(canvas.getByRole(
|
|
28
|
+
const canvas = within(canvasElement);
|
|
29
|
+
expect(canvas.getByRole("textbox")).toBeInTheDocument();
|
|
30
30
|
},
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
|
|
33
33
|
//required input story
|
|
34
34
|
export const RequiredInput: Story = {
|
|
@@ -41,32 +41,32 @@ export const RequiredInput: Story = {
|
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
args: {
|
|
44
|
-
type:
|
|
44
|
+
type: "text",
|
|
45
45
|
required: true,
|
|
46
|
-
placeholder:
|
|
46
|
+
placeholder: "This Field is required (placeholder)",
|
|
47
47
|
},
|
|
48
48
|
|
|
49
49
|
play: async ({ canvasElement }) => {
|
|
50
|
-
const canvas = within(canvasElement)
|
|
51
|
-
const input = canvas.getByRole(
|
|
52
|
-
expect(input).toBeRequired()
|
|
50
|
+
const canvas = within(canvasElement);
|
|
51
|
+
const input = canvas.getByRole("textbox");
|
|
52
|
+
expect(input).toBeRequired();
|
|
53
53
|
|
|
54
|
-
await userEvent.type(input,
|
|
55
|
-
expect(input).toBeValid()
|
|
54
|
+
await userEvent.type(input, "test");
|
|
55
|
+
expect(input).toBeValid();
|
|
56
56
|
|
|
57
|
-
await userEvent.clear(input)
|
|
57
|
+
await userEvent.clear(input);
|
|
58
58
|
|
|
59
|
-
userEvent.type(input,
|
|
60
|
-
expect(input).toBeInvalid()
|
|
59
|
+
userEvent.type(input, "\n");
|
|
60
|
+
expect(input).toBeInvalid();
|
|
61
61
|
},
|
|
62
|
-
} as Story
|
|
62
|
+
} as Story;
|
|
63
63
|
|
|
64
64
|
export const DefaultRequired: Story = {
|
|
65
65
|
args: {
|
|
66
|
-
type:
|
|
66
|
+
type: "text",
|
|
67
67
|
required: true,
|
|
68
68
|
},
|
|
69
|
-
} as Story
|
|
69
|
+
} as Story;
|
|
70
70
|
|
|
71
71
|
export const InputDisabled: Story = {
|
|
72
72
|
parameters: {
|
|
@@ -78,78 +78,78 @@ export const InputDisabled: Story = {
|
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
args: {
|
|
81
|
-
type:
|
|
81
|
+
type: "text",
|
|
82
82
|
isDisabled: true,
|
|
83
83
|
},
|
|
84
|
-
} as Story
|
|
84
|
+
} as Story;
|
|
85
85
|
|
|
86
86
|
export const EmailInput: Story = {
|
|
87
87
|
args: {
|
|
88
|
-
type:
|
|
88
|
+
type: "email",
|
|
89
89
|
},
|
|
90
90
|
play: async ({ canvasElement }) => {
|
|
91
|
-
const canvas = within(canvasElement)
|
|
92
|
-
const input = canvas.getByRole(
|
|
93
|
-
expect(input).toHaveAttribute(
|
|
91
|
+
const canvas = within(canvasElement);
|
|
92
|
+
const input = canvas.getByRole("textbox");
|
|
93
|
+
expect(input).toHaveAttribute("type", "email");
|
|
94
94
|
|
|
95
|
-
await userEvent.type(input,
|
|
96
|
-
expect(input).toHaveValue(
|
|
95
|
+
await userEvent.type(input, "test@example.com");
|
|
96
|
+
expect(input).toHaveValue("test@example.com");
|
|
97
97
|
},
|
|
98
|
-
} as Story
|
|
98
|
+
} as Story;
|
|
99
99
|
|
|
100
100
|
export const PasswordInput: Story = {
|
|
101
101
|
args: {
|
|
102
|
-
type:
|
|
102
|
+
type: "password",
|
|
103
103
|
},
|
|
104
104
|
play: async ({ canvasElement }) => {
|
|
105
|
-
const canvas = within(canvasElement)
|
|
106
|
-
const input = canvas.getByPlaceholderText(/password/i)
|
|
107
|
-
expect(input).toHaveAttribute(
|
|
105
|
+
const canvas = within(canvasElement);
|
|
106
|
+
const input = canvas.getByPlaceholderText(/password/i);
|
|
107
|
+
expect(input).toHaveAttribute("type", "password");
|
|
108
108
|
|
|
109
|
-
await userEvent.type(input,
|
|
110
|
-
expect(input).toHaveValue(
|
|
109
|
+
await userEvent.type(input, "password");
|
|
110
|
+
expect(input).toHaveValue("password");
|
|
111
111
|
},
|
|
112
|
-
} as Story
|
|
112
|
+
} as Story;
|
|
113
113
|
|
|
114
114
|
export const SearchInput: Story = {
|
|
115
115
|
args: {
|
|
116
|
-
type:
|
|
116
|
+
type: "search",
|
|
117
117
|
},
|
|
118
118
|
play: async ({ canvasElement }) => {
|
|
119
|
-
const canvas = within(canvasElement)
|
|
120
|
-
const input = canvas.getByRole(
|
|
121
|
-
expect(input).toHaveAttribute(
|
|
119
|
+
const canvas = within(canvasElement);
|
|
120
|
+
const input = canvas.getByRole("searchbox");
|
|
121
|
+
expect(input).toHaveAttribute("type", "search");
|
|
122
122
|
|
|
123
|
-
await userEvent.type(input,
|
|
124
|
-
expect(input).toHaveValue(
|
|
123
|
+
await userEvent.type(input, "search term");
|
|
124
|
+
expect(input).toHaveValue("search term");
|
|
125
125
|
},
|
|
126
|
-
} as Story
|
|
126
|
+
} as Story;
|
|
127
127
|
|
|
128
128
|
export const TelInput: Story = {
|
|
129
129
|
args: {
|
|
130
|
-
type:
|
|
130
|
+
type: "tel",
|
|
131
131
|
},
|
|
132
132
|
play: async ({ canvasElement }) => {
|
|
133
|
-
const canvas = within(canvasElement)
|
|
134
|
-
const input = canvas.getByRole(
|
|
135
|
-
expect(input).toHaveAttribute(
|
|
133
|
+
const canvas = within(canvasElement);
|
|
134
|
+
const input = canvas.getByRole("textbox");
|
|
135
|
+
expect(input).toHaveAttribute("type", "tel");
|
|
136
136
|
|
|
137
|
-
await userEvent.type(input,
|
|
138
|
-
expect(input).toHaveValue(
|
|
137
|
+
await userEvent.type(input, "1234567890");
|
|
138
|
+
expect(input).toHaveValue("1234567890");
|
|
139
139
|
},
|
|
140
|
-
} as Story
|
|
140
|
+
} as Story;
|
|
141
141
|
|
|
142
142
|
// URL text input story
|
|
143
143
|
export const UrlInput: Story = {
|
|
144
144
|
args: {
|
|
145
|
-
type:
|
|
145
|
+
type: "url",
|
|
146
146
|
},
|
|
147
147
|
play: async ({ canvasElement }) => {
|
|
148
|
-
const canvas = within(canvasElement)
|
|
149
|
-
const input = canvas.getByRole(
|
|
150
|
-
expect(input).toHaveAttribute(
|
|
148
|
+
const canvas = within(canvasElement);
|
|
149
|
+
const input = canvas.getByRole("textbox");
|
|
150
|
+
expect(input).toHaveAttribute("type", "url");
|
|
151
151
|
|
|
152
|
-
await userEvent.type(input,
|
|
153
|
-
expect(input).toHaveValue(
|
|
152
|
+
await userEvent.type(input, "https://example.com");
|
|
153
|
+
expect(input).toHaveValue("https://example.com");
|
|
154
154
|
},
|
|
155
|
-
} as Story
|
|
155
|
+
} as Story;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
2
|
-
import { within,
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
+
import { within, expect } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import React from 'react'
|
|
4
|
+
import Select from "./select";
|
|
5
|
+
import React from "react";
|
|
7
6
|
const meta: Meta<typeof Select> = {
|
|
8
|
-
title:
|
|
7
|
+
title: "FP.REACT Forms/Select",
|
|
8
|
+
tags: ["rc"],
|
|
9
9
|
component: Select,
|
|
10
10
|
parameters: {
|
|
11
11
|
docs: {
|
|
12
12
|
description: {
|
|
13
|
-
component:
|
|
13
|
+
component: "Base select/Combobox component",
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
args: {
|
|
18
|
-
// @ts-ignore
|
|
19
18
|
children: (
|
|
20
19
|
<>
|
|
21
20
|
<Select.Option selectValue="value" selectLabel="Option 1" />
|
|
@@ -24,15 +23,23 @@ const meta: Meta<typeof Select> = {
|
|
|
24
23
|
</>
|
|
25
24
|
),
|
|
26
25
|
},
|
|
27
|
-
} as Story
|
|
26
|
+
} as Story;
|
|
28
27
|
|
|
29
|
-
export default meta
|
|
30
|
-
type Story = StoryObj<typeof Select
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof Select>;
|
|
31
30
|
|
|
32
31
|
export const SelectComponent: Story = {
|
|
33
|
-
args: {
|
|
32
|
+
args: {
|
|
33
|
+
children: (
|
|
34
|
+
<>
|
|
35
|
+
<Select.Option selectValue="value" selectLabel="Option 1" />
|
|
36
|
+
<Select.Option selectValue="value" selectLabel="Option 2" />
|
|
37
|
+
<Select.Option selectValue="value" selectLabel="Option 3" />
|
|
38
|
+
</>
|
|
39
|
+
),
|
|
40
|
+
},
|
|
34
41
|
play: async ({ canvasElement }) => {
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const canvas = within(canvasElement);
|
|
43
|
+
expect(canvas.getByRole("combobox")).toBeInTheDocument();
|
|
37
44
|
},
|
|
38
|
-
}
|
|
45
|
+
} as Story;
|