Skip to content

Commit e48d0ee

Browse files
authored
v4.2.1
* fix: when the container component has only one content component * fix: modify unit tests * chore: change version * chore: some changes to PR request file * fix: publish github action
1 parent aec4724 commit e48d0ee

File tree

20 files changed

+58
-53
lines changed

20 files changed

+58
-53
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 📚 Description
1+
## 📚 Description
22

33
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
44

@@ -14,14 +14,14 @@ Please delete options that are not relevant.
1414
- [ ] This change requires a documentation update
1515
- [ ] Other (If yes, please write one phrase about this update)
1616

17-
# 👀 How Has This Been Tested?
17+
## 👀 How Has This Been Tested?
1818

1919
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
2020

2121
- [ ] Test A
2222
- [ ] Test B
2323

24-
# ✅ Checklist
24+
## ✅ Checklist
2525

2626
- [ ] My code follows the style guidelines of this project
2727
- [ ] I have performed a self-review of my code

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: '🚀 Publish new release'
33
on:
44
push:
55
branches: [master]
6-
pull_request:
7-
branches: [master]
86

97
jobs:
108
coverage:
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PropsWithChildren } from 'react';
12
import { ContainerProps } from '../../interfaces';
2-
declare const Container: ({ title, startDate, endDate, today, withoutDay, children }: ContainerProps) => JSX.Element;
3+
declare const Container: ({ title, startDate, endDate, today, withoutDay, children, }: PropsWithChildren<ContainerProps>) => JSX.Element;
34
export { Container };
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PropsWithChildren } from 'react';
12
import { TimelineProps } from '../../interfaces';
2-
declare const Timeline: ({ theme, lang, dateFormat, collapse, withoutDay, customStyles, children, }: TimelineProps) => JSX.Element;
3+
declare const Timeline: ({ theme, lang, dateFormat, collapse, withoutDay, customStyles, children, }: PropsWithChildren<TimelineProps>) => JSX.Element;
34
export { Timeline };

lib/cjs/components/validate/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ var react_1 = __importStar(require("react"));
2828
var error_message_1 = require("../error-message");
2929
var Validate = function (_a) {
3030
var children = _a.children, componentToValidate = _a.componentToValidate;
31-
var count = react_1.Children.count(children);
32-
if (count === 0)
31+
var count = children && react_1.Children.count(children);
32+
if (count === 0 || !children)
3333
return react_1.default.createElement(error_message_1.ErrorMessage, { type: "atLeast", component: componentToValidate.name });
34-
if (count === 1 && children.type !== componentToValidate)
35-
return react_1.default.createElement(error_message_1.ErrorMessage, { type: "onlySupports", component: componentToValidate.name });
3634
var elements = react_1.Children.map(children, function (element) {
37-
return element.type === componentToValidate ? element : null;
35+
return element.type === componentToValidate ? (element) : (react_1.default.createElement(error_message_1.ErrorMessage, { type: "onlySupports", component: componentToValidate.name }));
3836
});
3937
return react_1.default.createElement(react_1.default.Fragment, null, elements);
4038
};

lib/cjs/interfaces/index.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CSSProperties, ReactElement } from 'react';
1+
import { CSSProperties } from 'react';
22
export interface Theme {
33
yearColor: string;
44
lineColor: string;
@@ -23,7 +23,6 @@ export interface TimelineProps {
2323
collapse?: boolean;
2424
withoutDay?: boolean;
2525
customStyles?: CustomStyles;
26-
children: ReactElement<ContainerProps> | ReactElement<ContainerProps>[];
2726
}
2827
export interface DefaultTimelineProps {
2928
theme: Theme;
@@ -39,7 +38,6 @@ export interface ContainerProps {
3938
endDate?: string | Date;
4039
today?: boolean;
4140
withoutDay?: boolean;
42-
children: ReactElement<ContentProps> | ReactElement<ContentProps>[];
4341
}
4442
export interface ContentProps {
4543
title: string;

lib/cjs/styles/main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PropsWithChildren } from 'react';
12
import { ContainerProps } from '../../interfaces';
2-
declare const Container: ({ title, startDate, endDate, today, withoutDay, children }: ContainerProps) => JSX.Element;
3+
declare const Container: ({ title, startDate, endDate, today, withoutDay, children, }: PropsWithChildren<ContainerProps>) => JSX.Element;
34
export { Container };
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PropsWithChildren } from 'react';
12
import { TimelineProps } from '../../interfaces';
2-
declare const Timeline: ({ theme, lang, dateFormat, collapse, withoutDay, customStyles, children, }: TimelineProps) => JSX.Element;
3+
declare const Timeline: ({ theme, lang, dateFormat, collapse, withoutDay, customStyles, children, }: PropsWithChildren<TimelineProps>) => JSX.Element;
34
export { Timeline };

lib/esm/components/validate/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import React, { Children } from 'react';
22
import { ErrorMessage } from '../error-message';
33
var Validate = function (_a) {
44
var children = _a.children, componentToValidate = _a.componentToValidate;
5-
var count = Children.count(children);
6-
if (count === 0)
5+
var count = children && Children.count(children);
6+
if (count === 0 || !children)
77
return React.createElement(ErrorMessage, { type: "atLeast", component: componentToValidate.name });
8-
if (count === 1 && children.type !== componentToValidate)
9-
return React.createElement(ErrorMessage, { type: "onlySupports", component: componentToValidate.name });
108
var elements = Children.map(children, function (element) {
11-
return element.type === componentToValidate ? element : null;
9+
return element.type === componentToValidate ? (element) : (React.createElement(ErrorMessage, { type: "onlySupports", component: componentToValidate.name }));
1210
});
1311
return React.createElement(React.Fragment, null, elements);
1412
};

0 commit comments

Comments
 (0)