@pagopa/io-app-design-system 2.0.3 → 2.0.4
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/lib/commonjs/components/typography/ComposedBodyFromArray.js +26 -0
- package/lib/commonjs/components/typography/ComposedBodyFromArray.js.map +1 -0
- package/lib/commonjs/components/typography/__test__/ComposedBodyFromArray.test.js +107 -0
- package/lib/commonjs/components/typography/__test__/ComposedBodyFromArray.test.js.map +1 -0
- package/lib/commonjs/components/typography/__test__/__snapshots__/ComposedBodyFromArray.test.tsx.snap +895 -0
- package/lib/commonjs/components/typography/index.js +11 -0
- package/lib/commonjs/components/typography/index.js.map +1 -1
- package/lib/module/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/module/components/typography/ComposedBodyFromArray.js +18 -0
- package/lib/module/components/typography/ComposedBodyFromArray.js.map +1 -0
- package/lib/module/components/typography/__test__/ComposedBodyFromArray.test.js +104 -0
- package/lib/module/components/typography/__test__/ComposedBodyFromArray.test.js.map +1 -0
- package/lib/module/components/typography/__test__/__snapshots__/ComposedBodyFromArray.test.tsx.snap +895 -0
- package/lib/module/components/typography/index.js +1 -0
- package/lib/module/components/typography/index.js.map +1 -1
- package/lib/typescript/components/featureInfo/FeatureInfo.d.ts +2 -2
- package/lib/typescript/components/featureInfo/FeatureInfo.d.ts.map +1 -1
- package/lib/typescript/components/typography/ComposedBodyFromArray.d.ts +13 -0
- package/lib/typescript/components/typography/ComposedBodyFromArray.d.ts.map +1 -0
- package/lib/typescript/components/typography/__test__/ComposedBodyFromArray.test.d.ts +2 -0
- package/lib/typescript/components/typography/__test__/ComposedBodyFromArray.test.d.ts.map +1 -0
- package/lib/typescript/components/typography/index.d.ts +1 -0
- package/lib/typescript/components/typography/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/featureInfo/FeatureInfo.tsx +2 -2
- package/src/components/typography/ComposedBodyFromArray.tsx +25 -0
- package/src/components/typography/__test__/ComposedBodyFromArray.test.tsx +99 -0
- package/src/components/typography/__test__/__snapshots__/ComposedBodyFromArray.test.tsx.snap +895 -0
- package/src/components/typography/index.tsx +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/typography/index.tsx"],"mappings":"AAAA,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,cAAc;AAC5B,cAAc,WAAW;AACzB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB"}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/typography/index.tsx"],"mappings":"AAAA,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,yBAAyB;AACvC,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,cAAc;AAC5B,cAAc,WAAW;AACzB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,MAAM;AACpB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import { GestureResponderEvent } from "react-native";
|
|
3
3
|
import { IOIcons, IOPictograms } from "../../components";
|
|
4
4
|
type PartialFeatureInfo = {
|
|
5
|
-
body?: string |
|
|
5
|
+
body?: string | ReactNode;
|
|
6
6
|
};
|
|
7
7
|
type FeatureInfoActionProps = {
|
|
8
8
|
action: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/featureInfo/FeatureInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FeatureInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/featureInfo/FeatureInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAQ,MAAM,cAAc,CAAC;AAC3D,OAAO,EAIL,OAAO,EAEP,YAAY,EAKb,MAAM,kBAAkB,CAAC;AAG1B,KAAK,kBAAkB,GAAG;IAExB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAEF,KAAK,sBAAsB,GACvB;IACE,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;KACjD,CAAC;CACH,GACD;IACE,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC;AAEN,KAAK,uBAAuB,GACxB;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,aAAa,EAAE,YAAY,CAAA;CAAE,GACjD;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEjD,KAAK,gBAAgB,GAAG,uBAAuB,GAC7C,kBAAkB,GAClB,sBAAsB,CAAC;AAiBzB,eAAO,MAAM,WAAW,8CAKrB,gBAAgB,sBA8BlB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ComponentProps, ReactElement } from "react";
|
|
2
|
+
import { TextStyle } from "react-native";
|
|
3
|
+
import { Body } from "./Body";
|
|
4
|
+
export type BodyProps = ComponentProps<typeof Body> & {
|
|
5
|
+
text: string | ReactElement;
|
|
6
|
+
};
|
|
7
|
+
type PropsComposedBody = {
|
|
8
|
+
body: Array<BodyProps>;
|
|
9
|
+
textAlign?: TextStyle["textAlign"];
|
|
10
|
+
};
|
|
11
|
+
export declare const ComposedBodyFromArray: ({ body, textAlign }: PropsComposedBody) => React.JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=ComposedBodyFromArray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposedBodyFromArray.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/ComposedBodyFromArray.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG;IACpD,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;CAC7B,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,wBAG/B,iBAAiB,sBAQnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposedBodyFromArray.test.d.ts","sourceRoot":"","sources":["../../../../../src/components/typography/__test__/ComposedBodyFromArray.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import { GestureResponderEvent, View } from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
Body,
|
|
@@ -16,7 +16,7 @@ import { IOStyles } from "../../core";
|
|
|
16
16
|
|
|
17
17
|
type PartialFeatureInfo = {
|
|
18
18
|
// Necessary to render main body with different formatting
|
|
19
|
-
body?: string |
|
|
19
|
+
body?: string | ReactNode;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
type FeatureInfoActionProps =
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { ComponentProps, ReactElement } from "react";
|
|
2
|
+
import { TextStyle } from "react-native";
|
|
3
|
+
import { Body } from "./Body";
|
|
4
|
+
|
|
5
|
+
export type BodyProps = ComponentProps<typeof Body> & {
|
|
6
|
+
text: string | ReactElement;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type PropsComposedBody = {
|
|
10
|
+
body: Array<BodyProps>;
|
|
11
|
+
textAlign?: TextStyle["textAlign"];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const ComposedBodyFromArray = ({
|
|
15
|
+
body,
|
|
16
|
+
textAlign = "center"
|
|
17
|
+
}: PropsComposedBody) => (
|
|
18
|
+
<Body style={{ textAlign }}>
|
|
19
|
+
{body.map(({ text, key, ...props }, i) => (
|
|
20
|
+
<Body key={key ?? `OpResScreen_${i}`} {...props}>
|
|
21
|
+
{text}
|
|
22
|
+
</Body>
|
|
23
|
+
))}
|
|
24
|
+
</Body>
|
|
25
|
+
);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
import { BodyProps, ComposedBodyFromArray } from "../ComposedBodyFromArray";
|
|
4
|
+
|
|
5
|
+
describe("ComposedBodyFromArray", () => {
|
|
6
|
+
it("should match snapshot, empty body, default text align", () => {
|
|
7
|
+
const component = render(<ComposedBodyFromArray body={[]} />);
|
|
8
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
9
|
+
});
|
|
10
|
+
it("should match snapshot, empty body, auto text align", () => {
|
|
11
|
+
const component = render(
|
|
12
|
+
<ComposedBodyFromArray body={[]} textAlign="auto" />
|
|
13
|
+
);
|
|
14
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
it("should match snapshot, empty body, center text align", () => {
|
|
17
|
+
const component = render(
|
|
18
|
+
<ComposedBodyFromArray body={[]} textAlign="center" />
|
|
19
|
+
);
|
|
20
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
it("should match snapshot, empty body, justify text align", () => {
|
|
23
|
+
const component = render(
|
|
24
|
+
<ComposedBodyFromArray body={[]} textAlign="justify" />
|
|
25
|
+
);
|
|
26
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it("should match snapshot, empty body, left text align", () => {
|
|
29
|
+
const component = render(
|
|
30
|
+
<ComposedBodyFromArray body={[]} textAlign="left" />
|
|
31
|
+
);
|
|
32
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
it("should match snapshot, empty body, right text align", () => {
|
|
35
|
+
const component = render(
|
|
36
|
+
<ComposedBodyFromArray body={[]} textAlign="right" />
|
|
37
|
+
);
|
|
38
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
it("should match snapshot, multiple items body, default text align", () => {
|
|
41
|
+
const component = render(
|
|
42
|
+
<ComposedBodyFromArray body={multipleItemsBody} />
|
|
43
|
+
);
|
|
44
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
45
|
+
});
|
|
46
|
+
it("should match snapshot, multiple items body, auto text align", () => {
|
|
47
|
+
const component = render(
|
|
48
|
+
<ComposedBodyFromArray body={multipleItemsBody} textAlign="auto" />
|
|
49
|
+
);
|
|
50
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
it("should match snapshot, multiple items body, center text align", () => {
|
|
53
|
+
const component = render(
|
|
54
|
+
<ComposedBodyFromArray body={multipleItemsBody} textAlign="center" />
|
|
55
|
+
);
|
|
56
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
it("should match snapshot, multiple items body, justify text align", () => {
|
|
59
|
+
const component = render(
|
|
60
|
+
<ComposedBodyFromArray body={multipleItemsBody} textAlign="justify" />
|
|
61
|
+
);
|
|
62
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
it("should match snapshot, multiple items body, left text align", () => {
|
|
65
|
+
const component = render(
|
|
66
|
+
<ComposedBodyFromArray body={multipleItemsBody} textAlign="left" />
|
|
67
|
+
);
|
|
68
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
it("should match snapshot, multiple items body, right text align", () => {
|
|
71
|
+
const component = render(
|
|
72
|
+
<ComposedBodyFromArray body={multipleItemsBody} textAlign="right" />
|
|
73
|
+
);
|
|
74
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const multipleItemsBody = [
|
|
78
|
+
{
|
|
79
|
+
text: "Multiple ",
|
|
80
|
+
weight: "Regular"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
text: "styles",
|
|
84
|
+
weight: "Bold"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
text: " text ",
|
|
88
|
+
weight: "Light"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
text: "just",
|
|
92
|
+
weight: "Medium"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
text: " weights",
|
|
96
|
+
weight: "Semibold"
|
|
97
|
+
}
|
|
98
|
+
] as Array<BodyProps>;
|
|
99
|
+
});
|