@purpurds/field-error-text 3.0.0
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/LICENSE.txt +38 -0
- package/dist/field-error-text.cjs.js +10 -0
- package/dist/field-error-text.cjs.js.map +1 -0
- package/dist/field-error-text.d.ts +9 -0
- package/dist/field-error-text.d.ts.map +1 -0
- package/dist/field-error-text.es.js +152 -0
- package/dist/field-error-text.es.js.map +1 -0
- package/dist/field-error-text.system.js +10 -0
- package/dist/field-error-text.system.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +61 -0
- package/readme.mdx +58 -0
- package/src/field-error-text.module.scss +15 -0
- package/src/field-error-text.stories.tsx +59 -0
- package/src/field-error-text.test.tsx +16 -0
- package/src/field-error-text.tsx +33 -0
- package/src/global.d.ts +4 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._purpur-field-error-text_1h4gy_1{font-family:var(--purpur-typography-family-default),Helvetica,Arial,"Lucida Grande",sans-serif;font-weight:var(--purpur-typography-weight-normal);font-size:var(--purpur-typography-scale-100);line-height:var(--purpur-typography-line-height-loose);color:var(--purpur-color-text-status-error-strong);display:flex;flex-direction:row;gap:var(--purpur-spacing-50);align-items:center}._purpur-field-error-text__icon_1h4gy_12{color:var(--purpur-color-text-status-error-medium);line-height:var(--purpur-typography-line-height-tight)}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purpurds/field-error-text",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"main": "./dist/field-error-text.cjs.js",
|
|
6
|
+
"types": "./dist/field-error-text.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/field-error-text.cjs.js",
|
|
10
|
+
"systemjs": "./dist/field-error-text.system.js",
|
|
11
|
+
"types": "./dist/field-error-text.d.ts",
|
|
12
|
+
"default": "./dist/field-error-text.es.js"
|
|
13
|
+
},
|
|
14
|
+
"./styles": "./dist/styles.css"
|
|
15
|
+
},
|
|
16
|
+
"source": "src/field-error-text.tsx",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"classnames": "~2.5.0",
|
|
19
|
+
"@purpurds/icon": "3.0.0",
|
|
20
|
+
"@purpurds/tokens": "3.0.0",
|
|
21
|
+
"@purpurds/paragraph": "3.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rushstack/eslint-patch": "~1.7.0",
|
|
25
|
+
"@storybook/blocks": "~7.6.0",
|
|
26
|
+
"@storybook/react": "~7.6.0",
|
|
27
|
+
"@telia/base-rig": "~8.2.0",
|
|
28
|
+
"@telia/react-rig": "~3.2.0",
|
|
29
|
+
"@testing-library/dom": "~9.3.3",
|
|
30
|
+
"@testing-library/jest-dom": "~6.3.0",
|
|
31
|
+
"@testing-library/react": "~14.1.2",
|
|
32
|
+
"@types/node": "18",
|
|
33
|
+
"@types/react-dom": "~18.2.17",
|
|
34
|
+
"@types/react": "~18.2.42",
|
|
35
|
+
"eslint-plugin-testing-library": "~6.2.0",
|
|
36
|
+
"eslint": "~8.56.0",
|
|
37
|
+
"jsdom": "~22.1.0",
|
|
38
|
+
"lint-staged": "~10.5.3",
|
|
39
|
+
"prettier": "~2.8.8",
|
|
40
|
+
"react-dom": "~18.2.0",
|
|
41
|
+
"react": "~18.2.0",
|
|
42
|
+
"typescript": "~5.2.2",
|
|
43
|
+
"vite": "~5.0.6",
|
|
44
|
+
"vitest": "~1.2.0",
|
|
45
|
+
"@purpurds/component-rig": "1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build:dev": "vite",
|
|
49
|
+
"build:watch": "vite build --watch",
|
|
50
|
+
"build": "rm -rf dist && vite build && vite build --mode systemjs",
|
|
51
|
+
"ci:build": "rushx build",
|
|
52
|
+
"coverage": "vitest run --coverage",
|
|
53
|
+
"lint:fix": "eslint . --fix",
|
|
54
|
+
"lint": "lint-staged --no-stash 2>&1",
|
|
55
|
+
"sbdev": "rush sbdev",
|
|
56
|
+
"test:unit": "vitest run --passWithNoTests",
|
|
57
|
+
"test:watch": "vitest --watch",
|
|
58
|
+
"test": "rushx test:unit",
|
|
59
|
+
"typecheck": "tsc -p ./tsconfig.json"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/readme.mdx
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
import * as FieldErrorTextStories from "./src/field-error-text.stories";
|
|
4
|
+
import packageInfo from "./package.json";
|
|
5
|
+
|
|
6
|
+
<Meta name="Docs" title="Components/FieldErrorText" of={FieldErrorTextStories} />
|
|
7
|
+
|
|
8
|
+
# FieldErrorText
|
|
9
|
+
|
|
10
|
+
<Subtitle>Version {packageInfo.version}</Subtitle>
|
|
11
|
+
|
|
12
|
+
This is an internal component used for form fields.
|
|
13
|
+
|
|
14
|
+
### Showcase
|
|
15
|
+
|
|
16
|
+
<Primary />
|
|
17
|
+
|
|
18
|
+
### Properties
|
|
19
|
+
|
|
20
|
+
<ArgTypes />
|
|
21
|
+
|
|
22
|
+
### Installation
|
|
23
|
+
|
|
24
|
+
#### Via NPM
|
|
25
|
+
|
|
26
|
+
Add the dependency to your consumer app like `"@purpurds/field-error-text": "x.y.z"`
|
|
27
|
+
|
|
28
|
+
#### From outside the monorepo (build-time)
|
|
29
|
+
|
|
30
|
+
To install this package, you need to setup access to the artifactory. [Click here to go to the guide on how to do that](https://github.com/telia-company/jfrog-documentation/blob/main/doc/JFrog/JFrog_Onboarding.md#getting-access-to-artifactory-and-other-jfrog-applications).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
In MyApp.tsx
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import "@purpurds/tokens/index.css";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
and
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import "@purpurds/field-error-text/styles";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In MyComponent.tsx
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { FieldErrorText } from "@purpurds/field-error-text";
|
|
50
|
+
|
|
51
|
+
export const MyComponent = () => {
|
|
52
|
+
return (
|
|
53
|
+
<div>
|
|
54
|
+
<FieldErrorText {...someProps}>Some content</FieldErrorText>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@import "@purpurds/paragraph/src/paragraph.mixins.scss";
|
|
2
|
+
|
|
3
|
+
.purpur-field-error-text {
|
|
4
|
+
@include purpur-paragraph-100;
|
|
5
|
+
color: var(--purpur-color-text-status-error-strong);
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
gap: var(--purpur-spacing-50);
|
|
9
|
+
align-items: center;
|
|
10
|
+
|
|
11
|
+
&__icon {
|
|
12
|
+
color: var(--purpur-color-text-status-error-medium);
|
|
13
|
+
line-height: var(--purpur-typography-line-height-tight);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
import "@purpurds/icon/styles";
|
|
4
|
+
import { FieldErrorText } from "./field-error-text";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof FieldErrorText> = {
|
|
7
|
+
title: "Components/FieldErrorText",
|
|
8
|
+
component: FieldErrorText,
|
|
9
|
+
parameters: {
|
|
10
|
+
design: [
|
|
11
|
+
{
|
|
12
|
+
name: "Checkbox",
|
|
13
|
+
type: "figma",
|
|
14
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1274%3A614&mode=design&t=5WYoIWv1It545kCs-1",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "Date picker",
|
|
18
|
+
type: "figma",
|
|
19
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=33657%3A20978&mode=design&t=5WYoIWv1It545kCs-1",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "Search input",
|
|
23
|
+
type: "figma",
|
|
24
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=25720-16573&mode=design&t=5WYoIWv1It545kCs-0",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "Select",
|
|
28
|
+
type: "figma",
|
|
29
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=2649%3A1994&mode=design&t=I7q1i4D0IFuULtpT-1",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Textarea",
|
|
33
|
+
type: "figma",
|
|
34
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1565%3A1896&mode=design&t=5WYoIWv1It545kCs-1",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "Text input",
|
|
38
|
+
type: "figma",
|
|
39
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1528%3A1886&mode=design&t=5WYoIWv1It545kCs-1",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
argTypes: {
|
|
44
|
+
children: { control: { type: "text" } },
|
|
45
|
+
relevant: {
|
|
46
|
+
control: { type: "select" },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default meta;
|
|
52
|
+
type Story = StoryObj<typeof FieldErrorText>;
|
|
53
|
+
|
|
54
|
+
export const Showcase: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
children: "Error text",
|
|
57
|
+
relevant: "additions text",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as matchers from "@testing-library/jest-dom/matchers";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { FieldErrorText } from "./field-error-text";
|
|
7
|
+
|
|
8
|
+
expect.extend(matchers);
|
|
9
|
+
|
|
10
|
+
describe("FieldErrorText", () => {
|
|
11
|
+
it("should have tests", () => {
|
|
12
|
+
render(<FieldErrorText data-testid="field-error-text">Some error text</FieldErrorText>);
|
|
13
|
+
|
|
14
|
+
expect(screen.getByTestId("field-error-text")).toHaveTextContent("Some error text");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { errorFilled, Icon } from "@purpurds/icon";
|
|
3
|
+
import c from "classnames";
|
|
4
|
+
|
|
5
|
+
import styles from "./field-error-text.module.scss";
|
|
6
|
+
|
|
7
|
+
export type FieldErrorTextProps = {
|
|
8
|
+
["data-testid"]?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
relevant?: "additions text" | "additions" | "removals" | "text" | "all";
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const rootClassName = "purpur-field-error-text";
|
|
15
|
+
|
|
16
|
+
export const FieldErrorText = ({
|
|
17
|
+
["data-testid"]: dataTestId,
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
relevant = "additions text",
|
|
21
|
+
...props
|
|
22
|
+
}: FieldErrorTextProps) => (
|
|
23
|
+
<div
|
|
24
|
+
className={c([className, styles[rootClassName]])}
|
|
25
|
+
data-testid={dataTestId}
|
|
26
|
+
aria-live="assertive"
|
|
27
|
+
aria-relevant={relevant}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
<Icon svg={errorFilled} size="xs" className={styles[`${rootClassName}__icon`]} />
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
package/src/global.d.ts
ADDED