@pcoi/components 0.1.0 → 0.1.1
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/dist/components.css +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +2 -2
- package/dist/index.mjs +296 -375
- package/package.json +12 -5
- package/src/Badge/Badge.css +2 -2
- package/src/Button/Button.css +4 -4
- package/src/Button/Button.figma.tsx +3 -5
- package/src/Button/Button.test.tsx +32 -0
- package/src/Callout/Callout.css +5 -5
- package/src/Callout/Callout.figma.tsx +25 -0
- package/src/Card/Card.css +8 -8
- package/src/Card/Card.figma.tsx +28 -0
- package/src/ChatInterface/ChatInterface.css +5 -5
- package/src/ChatInterface/ChatInterface.integration.test.tsx +123 -0
- package/src/ChatMessage/ChatMessage.css +8 -8
- package/src/ChatMessageList/ChatMessageList.css +4 -4
- package/src/ChatMessageList/ChatMessageList.test.tsx +74 -0
- package/src/Checkbox/Checkbox.css +6 -6
- package/src/CitationMark/CitationMark.css +3 -3
- package/src/CitedExcerpt/CitedExcerpt.css +7 -7
- package/src/ComparisonTable/ComparisonTable.css +6 -6
- package/src/ContactForm/ContactForm.css +5 -5
- package/src/ContactForm/ContactForm.tsx +1 -1
- package/src/DataTable/DataTable.css +4 -4
- package/src/DocumentOverlay/DocumentOverlay.css +5 -5
- package/src/DocumentOverlay/DocumentOverlay.test.tsx +95 -0
- package/src/DocumentOverlay/DocumentOverlay.tsx +1 -1
- package/src/Footer/Footer.css +9 -9
- package/src/FormField/FormField.css +4 -4
- package/src/FormField/FormField.figma.tsx +28 -0
- package/src/HowStep/HowStep.css +4 -4
- package/src/HowStep/HowStep.figma.tsx +23 -0
- package/src/LogoMark/LogoMark.tsx +1 -2
- package/src/Modal/Modal.css +11 -11
- package/src/Modal/Modal.figma.tsx +28 -0
- package/src/Modal/Modal.test.tsx +46 -0
- package/src/Modal/Modal.tsx +17 -19
- package/src/Nav/Nav.css +16 -16
- package/src/Panel/Panel.css +3 -3
- package/src/PromptBar/PromptBar.css +10 -10
- package/src/PromptBar/PromptBar.figma.tsx +25 -0
- package/src/PromptBar/PromptBar.test.tsx +83 -0
- package/src/PromptBar/PromptBar.tsx +2 -2
- package/src/RadioGroup/RadioGroup.css +11 -11
- package/src/SectionHeader/SectionHeader.css +4 -4
- package/src/SectionHeader/SectionHeader.figma.tsx +23 -0
- package/src/Select/Select.css +5 -5
- package/src/Select/Select.figma.tsx +33 -0
- package/src/Select/Select.tsx +1 -1
- package/src/SignalsPanel/SignalsPanel.css +9 -9
- package/src/SuggestionCard/SuggestionCard.css +5 -5
- package/src/SuggestionCards/SuggestionCards.css +1 -1
- package/src/SuggestionCards/SuggestionCards.test.tsx +27 -0
- package/src/SuggestionCards/SuggestionCards.tsx +1 -1
- package/src/Toast/Toast.css +14 -14
- package/src/Toast/Toast.tsx +1 -1
- package/src/Toggle/Toggle.css +15 -15
- package/src/Toggle/Toggle.figma.tsx +24 -0
- package/src/TypingIndicator/TypingIndicator.css +6 -6
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import type { Suggestion } from "../types";
|
|
4
|
+
import { SuggestionCards } from "./SuggestionCards";
|
|
5
|
+
|
|
6
|
+
describe("SuggestionCards", () => {
|
|
7
|
+
it("renders suggestions and calls onSelect with clicked item", () => {
|
|
8
|
+
const suggestions: Suggestion[] = [
|
|
9
|
+
{ id: "s1", label: "What is PCOI?" },
|
|
10
|
+
{ id: "s2", label: "How does indexing work?" },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const onSelect = vi.fn();
|
|
14
|
+
|
|
15
|
+
render(<SuggestionCards suggestions={suggestions} onSelect={onSelect} />);
|
|
16
|
+
|
|
17
|
+
const first = screen.getByRole("button", { name: "What is PCOI?" });
|
|
18
|
+
const second = screen.getByRole("button", { name: "How does indexing work?" });
|
|
19
|
+
|
|
20
|
+
expect(first).toBeInTheDocument();
|
|
21
|
+
expect(second).toBeInTheDocument();
|
|
22
|
+
|
|
23
|
+
fireEvent.click(second);
|
|
24
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
25
|
+
expect(onSelect).toHaveBeenCalledWith(suggestions[1]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -3,7 +3,7 @@ import { SuggestionCard } from "../SuggestionCard/SuggestionCard";
|
|
|
3
3
|
import type { Suggestion } from "../types";
|
|
4
4
|
|
|
5
5
|
export interface SuggestionCardsProps
|
|
6
|
-
extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> {
|
|
7
7
|
/** Array of suggestion prompts */
|
|
8
8
|
suggestions: Suggestion[];
|
|
9
9
|
/** Called when a suggestion card is clicked */
|
package/src/Toast/Toast.css
CHANGED
|
@@ -2,41 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
.pcoi-toast {
|
|
4
4
|
position: fixed;
|
|
5
|
-
bottom: var(--pcoi-spacing-
|
|
6
|
-
right: var(--pcoi-spacing-
|
|
7
|
-
z-index: var(--pcoi-layout-
|
|
5
|
+
bottom: var(--pcoi-semantic-spacing-btn-x);
|
|
6
|
+
right: var(--pcoi-semantic-spacing-btn-x);
|
|
7
|
+
z-index: var(--pcoi-semantic-layout-z-toast, 600);
|
|
8
8
|
animation: pcoi-toast-slide-in 0.3s ease;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.pcoi-toast__content {
|
|
12
12
|
display: flex;
|
|
13
13
|
align-items: center;
|
|
14
|
-
gap: var(--pcoi-spacing-
|
|
14
|
+
gap: var(--pcoi-semantic-spacing-panel-gap);
|
|
15
15
|
font-family: var(--pcoi-semantic-type-body-font);
|
|
16
16
|
background: var(--pcoi-semantic-surface-elevated);
|
|
17
17
|
border: 1px solid var(--pcoi-semantic-border-default);
|
|
18
|
-
border-radius: var(--pcoi-radius-
|
|
18
|
+
border-radius: var(--pcoi-semantic-radius-card);
|
|
19
19
|
box-shadow: var(--pcoi-effect-shadow-elevated);
|
|
20
|
-
padding: var(--pcoi-spacing-
|
|
21
|
-
min-width: var(--pcoi-
|
|
22
|
-
max-width: var(--pcoi-
|
|
20
|
+
padding: var(--pcoi-semantic-spacing-btn-y-comfortable) var(--pcoi-semantic-spacing-card-gap);
|
|
21
|
+
min-width: var(--pcoi-semantic-sizing-toast-width-min);
|
|
22
|
+
max-width: var(--pcoi-semantic-sizing-toast-width-max);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/* ── Left accent border per variant ── */
|
|
26
26
|
.pcoi-toast--success .pcoi-toast__content {
|
|
27
|
-
border-left: var(--pcoi-
|
|
27
|
+
border-left: var(--pcoi-semantic-sizing-accent-border-width) solid var(--pcoi-semantic-border-success);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.pcoi-toast--error .pcoi-toast__content {
|
|
31
|
-
border-left: var(--pcoi-
|
|
31
|
+
border-left: var(--pcoi-semantic-sizing-accent-border-width) solid var(--pcoi-semantic-border-error);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.pcoi-toast--warning .pcoi-toast__content {
|
|
35
|
-
border-left: var(--pcoi-
|
|
35
|
+
border-left: var(--pcoi-semantic-sizing-accent-border-width) solid var(--pcoi-semantic-border-warning);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
.pcoi-toast--info .pcoi-toast__content {
|
|
39
|
-
border-left: var(--pcoi-
|
|
39
|
+
border-left: var(--pcoi-semantic-sizing-accent-border-width) solid var(--pcoi-semantic-border-info);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.pcoi-toast__message {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
font-size: var(--pcoi-semantic-type-close-sm-size);
|
|
54
54
|
line-height: var(--pcoi-semantic-type-none-line-height);
|
|
55
55
|
cursor: pointer;
|
|
56
|
-
padding: var(--pcoi-spacing-
|
|
57
|
-
border-radius: var(--pcoi-radius-
|
|
56
|
+
padding: var(--pcoi-semantic-spacing-control-padding-2xs);
|
|
57
|
+
border-radius: var(--pcoi-semantic-radius-btn);
|
|
58
58
|
flex-shrink: 0;
|
|
59
59
|
transition: color var(--pcoi-effect-transition-fast, 0.2s ease);
|
|
60
60
|
}
|
package/src/Toast/Toast.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useCallback } from "react";
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
|
-
import { CloseIcon } from "
|
|
3
|
+
import { CloseIcon } from "@pcoi/icons";
|
|
4
4
|
|
|
5
5
|
export type ToastVariant = "success" | "error" | "warning" | "info";
|
|
6
6
|
|
package/src/Toggle/Toggle.css
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
.pcoi-toggle {
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
-
gap: var(--pcoi-spacing-
|
|
6
|
+
gap: var(--pcoi-semantic-spacing-form-gap-compact);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.pcoi-toggle__control {
|
|
10
10
|
display: inline-flex;
|
|
11
11
|
align-items: center;
|
|
12
|
-
gap: var(--pcoi-spacing-
|
|
12
|
+
gap: var(--pcoi-semantic-spacing-panel-gap);
|
|
13
13
|
cursor: pointer;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.pcoi-toggle__track {
|
|
29
|
-
width: var(--pcoi-
|
|
30
|
-
height: var(--pcoi-
|
|
29
|
+
width: var(--pcoi-semantic-sizing-toggle-track-width);
|
|
30
|
+
height: var(--pcoi-semantic-sizing-toggle-track-height);
|
|
31
31
|
flex-shrink: 0;
|
|
32
|
-
border-radius: var(--pcoi-radius-
|
|
32
|
+
border-radius: var(--pcoi-semantic-radius-badge);
|
|
33
33
|
background: var(--pcoi-semantic-action-toggle-bg);
|
|
34
34
|
position: relative;
|
|
35
35
|
transition: background var(--pcoi-effect-transition-fast, 0.2s ease);
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
|
|
38
38
|
.pcoi-toggle__thumb {
|
|
39
39
|
position: absolute;
|
|
40
|
-
top: var(--pcoi-
|
|
41
|
-
left: var(--pcoi-
|
|
42
|
-
width: var(--pcoi-
|
|
43
|
-
height: var(--pcoi-
|
|
44
|
-
border-radius: var(--pcoi-radius-
|
|
40
|
+
top: var(--pcoi-semantic-spacing-toggle-thumb-inset);
|
|
41
|
+
left: var(--pcoi-semantic-spacing-toggle-thumb-inset);
|
|
42
|
+
width: var(--pcoi-semantic-sizing-toggle-thumb-size);
|
|
43
|
+
height: var(--pcoi-semantic-sizing-toggle-thumb-size);
|
|
44
|
+
border-radius: var(--pcoi-semantic-radius-badge);
|
|
45
45
|
background: var(--pcoi-semantic-action-toggle-thumb);
|
|
46
46
|
transition: transform var(--pcoi-effect-transition-fast, 0.2s ease),
|
|
47
47
|
background var(--pcoi-effect-transition-fast, 0.2s ease);
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
position: absolute;
|
|
53
53
|
top: 50%;
|
|
54
54
|
left: 50%;
|
|
55
|
-
width: var(--pcoi-
|
|
56
|
-
height: var(--pcoi-
|
|
55
|
+
width: var(--pcoi-semantic-sizing-toggle-check-width);
|
|
56
|
+
height: var(--pcoi-semantic-sizing-toggle-check-height);
|
|
57
57
|
border: solid var(--pcoi-semantic-action-success);
|
|
58
|
-
border-width: 0 var(--pcoi-
|
|
58
|
+
border-width: 0 var(--pcoi-semantic-sizing-toggle-check-stroke) var(--pcoi-semantic-sizing-toggle-check-stroke) 0;
|
|
59
59
|
transform: translate(-50%, -60%) rotate(45deg);
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity var(--pcoi-effect-transition-fast, 0.2s ease);
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
.pcoi-toggle__input:checked + .pcoi-toggle__track .pcoi-toggle__thumb {
|
|
77
|
-
transform: translateX(var(--pcoi-
|
|
77
|
+
transform: translateX(var(--pcoi-semantic-spacing-toggle-thumb-travel)) var(--pcoi-effect-transform-toggle-thumb-on);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
.pcoi-toggle__input:checked + .pcoi-toggle__track .pcoi-toggle__thumb::after {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
font-size: var(--pcoi-semantic-type-label-size);
|
|
101
101
|
color: var(--pcoi-semantic-text-error);
|
|
102
102
|
margin: 0;
|
|
103
|
-
padding-left: calc(var(--pcoi-
|
|
103
|
+
padding-left: calc(var(--pcoi-semantic-sizing-toggle-track-width) + var(--pcoi-semantic-spacing-panel-gap));
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/* ── Disabled state ── */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import figma from "@figma/code-connect";
|
|
2
|
+
import { Toggle } from "./Toggle";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Code Connect: Toggle
|
|
6
|
+
* Maps Figma toggle states to React Toggle props
|
|
7
|
+
*/
|
|
8
|
+
figma.connect(Toggle, "https://www.figma.com/file/PCOIxDesignSystem/PCOI-Design-System?node-id=110-1", {
|
|
9
|
+
props: {
|
|
10
|
+
label: figma.string("Label"),
|
|
11
|
+
checked: figma.boolean("Checked"),
|
|
12
|
+
disabled: figma.boolean("Disabled"),
|
|
13
|
+
hasError: figma.boolean("Error"),
|
|
14
|
+
},
|
|
15
|
+
example: ({ label, checked, disabled, hasError }) => (
|
|
16
|
+
<Toggle
|
|
17
|
+
name="mapped-toggle"
|
|
18
|
+
label={label}
|
|
19
|
+
defaultChecked={checked}
|
|
20
|
+
disabled={disabled}
|
|
21
|
+
error={hasError ? "Please resolve this setting." : undefined}
|
|
22
|
+
/>
|
|
23
|
+
),
|
|
24
|
+
});
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
.pcoi-typing-indicator {
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
-
gap: var(--pcoi-spacing-
|
|
7
|
-
padding: var(--pcoi-spacing-
|
|
6
|
+
gap: var(--pcoi-semantic-spacing-stack-sm);
|
|
7
|
+
padding: var(--pcoi-semantic-spacing-panel-padding-sm);
|
|
8
8
|
background: var(--pcoi-semantic-surface-accent-dim);
|
|
9
9
|
border: 1px solid var(--pcoi-semantic-border-card);
|
|
10
|
-
border-radius: var(--pcoi-radius-
|
|
10
|
+
border-radius: var(--pcoi-semantic-radius-card);
|
|
11
11
|
animation: pcoi-typing-fade-in 0.2s ease;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
display: flex;
|
|
21
21
|
align-items: center;
|
|
22
22
|
gap: 6px;
|
|
23
|
-
padding: var(--pcoi-spacing-
|
|
23
|
+
padding: var(--pcoi-semantic-spacing-inline-2xs) 0;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.pcoi-typing-indicator__dot {
|
|
27
27
|
width: 8px;
|
|
28
28
|
height: 8px;
|
|
29
|
-
border-radius: var(--pcoi-radius-
|
|
29
|
+
border-radius: var(--pcoi-semantic-radius-avatar);
|
|
30
30
|
background: var(--pcoi-semantic-text-accent);
|
|
31
31
|
opacity: 0.4;
|
|
32
32
|
animation: pcoi-typing-bounce 1.4s ease-in-out infinite;
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
/* ── Responsive: offset to match assistant messages on desktop ── */
|
|
66
66
|
@media (min-width: 1025px) {
|
|
67
67
|
.pcoi-typing-indicator {
|
|
68
|
-
margin-right: var(--pcoi-spacing-
|
|
68
|
+
margin-right: var(--pcoi-semantic-spacing-inline-xl);
|
|
69
69
|
}
|
|
70
70
|
}
|