@loja-integrada/admin-components 0.12.5 → 0.12.8
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/Timeline/Timeline.d.ts +5 -1
- package/dist/Components/Timeline/Timeline.stories.d.ts +1 -0
- package/dist/Components/Timeline/TimelineItem.interface.d.ts +4 -0
- package/dist/Icons/icons-path/MoneyBill.d.ts +2 -0
- package/dist/Icons/icons-path/index.d.ts +1 -0
- package/dist/Layout/Box/Box.d.ts +4 -0
- package/dist/admin-components.cjs.development.js +35 -10
- package/dist/admin-components.cjs.development.js.map +1 -1
- package/dist/admin-components.cjs.production.min.js +1 -1
- package/dist/admin-components.cjs.production.min.js.map +1 -1
- package/dist/admin-components.esm.js +35 -10
- package/dist/admin-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Components/Timeline/Timeline.spec.tsx +13 -1
- package/src/Components/Timeline/Timeline.stories.tsx +7 -1
- package/src/Components/Timeline/Timeline.tsx +9 -1
- package/src/Components/Timeline/TimelineItem.interface.ts +4 -0
- package/src/Components/Timeline/TimelineItem.tsx +9 -7
- package/src/Icons/icons-path/MoneyBill.tsx +9 -0
- package/src/Icons/icons-path/index.ts +2 -0
- package/src/Layout/Box/Box.tsx +7 -0
- package/src/Navigation/Pagination/PaginationNav.tsx +3 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { composeStories } from "@storybook/testing-react"
|
|
|
3
3
|
import { mount } from "@cypress/react"
|
|
4
4
|
import * as stories from "./Timeline.stories"
|
|
5
5
|
|
|
6
|
-
const { Default, Loading, Empty } = composeStories(stories)
|
|
6
|
+
const { Default, WithoutToggle, Loading, Empty } = composeStories(stories)
|
|
7
7
|
|
|
8
8
|
describe('Timeline tests', () => {
|
|
9
9
|
|
|
@@ -20,6 +20,18 @@ describe('Timeline tests', () => {
|
|
|
20
20
|
})
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
+
it('Without Toggle', () => {
|
|
24
|
+
mount(<WithoutToggle />)
|
|
25
|
+
cy.get('.timeline .timeline-item')
|
|
26
|
+
.should('have.length', 4)
|
|
27
|
+
.first().within(() => {
|
|
28
|
+
cy.get('.timeline-title').contains('Venda criada')
|
|
29
|
+
cy.get('.timeline-timestamp').contains('11/11/2011')
|
|
30
|
+
cy.get('.timeline-description').should('be.visible')
|
|
31
|
+
cy.get('.timeline-title button').should('not.exist')
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
23
35
|
it('Loading', () => {
|
|
24
36
|
mount(<Loading />)
|
|
25
37
|
cy.get('.timeline .timeline-item')
|
|
@@ -22,9 +22,10 @@ export default {
|
|
|
22
22
|
title: 'Venda criada',
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
title: '
|
|
25
|
+
title: 'Venda criada sem toggle',
|
|
26
26
|
iconBackgroundColor: 'bg-danger',
|
|
27
27
|
description: 'Status change: from Cancelling to Cancelled',
|
|
28
|
+
toggle: false,
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
31
|
title: 'Venda criada',
|
|
@@ -39,6 +40,11 @@ const Template: Story<TimelineProps> = args => <Timeline {...args} />
|
|
|
39
40
|
|
|
40
41
|
export const Default = Template.bind({})
|
|
41
42
|
|
|
43
|
+
export const WithoutToggle = Template.bind({})
|
|
44
|
+
WithoutToggle.args = {
|
|
45
|
+
toggleItems: false,
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
export const Loading = Template.bind({})
|
|
43
49
|
Loading.args = {
|
|
44
50
|
isLoading: true,
|
|
@@ -8,6 +8,7 @@ const TimelineComponent = ({
|
|
|
8
8
|
className = '',
|
|
9
9
|
items,
|
|
10
10
|
isLoading = false,
|
|
11
|
+
toggleItems = true,
|
|
11
12
|
emptyTitle = 'Nenhum registro encontrado',
|
|
12
13
|
}: TimelineProps) => {
|
|
13
14
|
if (!isLoading && (!items || !Array.isArray(items))) return null
|
|
@@ -37,7 +38,10 @@ const TimelineComponent = ({
|
|
|
37
38
|
/>
|
|
38
39
|
) : (
|
|
39
40
|
items?.map((item, index) => (
|
|
40
|
-
<TimelineItem
|
|
41
|
+
<TimelineItem
|
|
42
|
+
key={`timeline-item-${index}`}
|
|
43
|
+
item={{ ...item, toggle: item.toggle ?? toggleItems }}
|
|
44
|
+
/>
|
|
41
45
|
))
|
|
42
46
|
)}
|
|
43
47
|
</ul>
|
|
@@ -64,4 +68,8 @@ export interface TimelineProps {
|
|
|
64
68
|
* @default 'Nenhum registro encontrado'
|
|
65
69
|
*/
|
|
66
70
|
emptyTitle?: string
|
|
71
|
+
/** Timeline item show toggle
|
|
72
|
+
* @default true
|
|
73
|
+
*/
|
|
74
|
+
toggleItems?: boolean
|
|
67
75
|
}
|
|
@@ -4,9 +4,10 @@ import { Icon } from '../../Icons/Icon'
|
|
|
4
4
|
import { TimelineItemInterface } from './TimelineItem.interface'
|
|
5
5
|
|
|
6
6
|
export const TimelineItem = ({ item }: TimelineItemProps) => {
|
|
7
|
-
const [isOpen, setIsOpen] = useState(
|
|
7
|
+
const [isOpen, setIsOpen] = useState(!item.toggle)
|
|
8
8
|
const iconBackgroundColor = item.iconBackgroundColor || `bg-inverted-2`
|
|
9
9
|
const icon = item.icon || 'minus'
|
|
10
|
+
const showToggle = item.toggle && item.description
|
|
10
11
|
|
|
11
12
|
return (
|
|
12
13
|
<li className={`timeline-item relative mb-10 last:mb-0`}>
|
|
@@ -17,12 +18,12 @@ export const TimelineItem = ({ item }: TimelineItemProps) => {
|
|
|
17
18
|
</div>
|
|
18
19
|
<div className="ml-7 pt-px">
|
|
19
20
|
<div
|
|
20
|
-
className={`timeline-title group
|
|
21
|
-
|
|
21
|
+
className={`timeline-title group py-1 text-f6 leading-6 tracking-4 text-inverted-1 font-semibold break-words ${
|
|
22
|
+
showToggle ? 'cursor-pointer' : ''
|
|
22
23
|
}`}
|
|
23
|
-
onClick={() =>
|
|
24
|
+
onClick={() => showToggle && setIsOpen((isOpen) => !isOpen)}
|
|
24
25
|
>
|
|
25
|
-
{
|
|
26
|
+
{showToggle && (
|
|
26
27
|
<button
|
|
27
28
|
className={`float-right p-1 -mt-px text-inverted-2 group-hover:text-inverted-1 focus:outline-none`}
|
|
28
29
|
>
|
|
@@ -39,13 +40,14 @@ export const TimelineItem = ({ item }: TimelineItemProps) => {
|
|
|
39
40
|
<span className="inline break-words">{item.title}</span>
|
|
40
41
|
</div>
|
|
41
42
|
{item.timestamp && (
|
|
42
|
-
<div className="timeline-timestamp mb-1 text-xs text-inverted-2 break-words">
|
|
43
|
+
<div className="timeline-timestamp mb-1 inline-flex items-center text-xs tracking-4 text-inverted-2 break-words">
|
|
44
|
+
<Icon icon="clock" size={3} className="mr-1" />
|
|
43
45
|
{item.timestamp}
|
|
44
46
|
</div>
|
|
45
47
|
)}
|
|
46
48
|
{item.description && (
|
|
47
49
|
<div
|
|
48
|
-
className={`timeline-description overflow-hidden text-sm text-inverted-1 break-words transition-max-height ${
|
|
50
|
+
className={`timeline-description overflow-hidden text-sm tracking-4 text-inverted-1 break-words transition-max-height ${
|
|
49
51
|
isOpen ? 'max-h-96' : 'max-h-0'
|
|
50
52
|
}`}
|
|
51
53
|
>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const MoneyBill = () => (
|
|
4
|
+
<path
|
|
5
|
+
fillRule="evenodd"
|
|
6
|
+
d="M3.245 12.2h11.51a1.995 1.995 0 0 1 1.945-1.945v-6.51A1.995 1.995 0 0 1 14.755 1.8H3.245A1.995 1.995 0 0 1 1.3 3.745v6.51A1.995 1.995 0 0 1 3.245 12.2ZM18 2v10a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 0 12V2A1.5 1.5 0 0 1 1.5.5h15A1.5 1.5 0 0 1 18 2Zm-6.5 5c0 2-1 3-2.5 3S6.5 9 6.5 7s1-3 2.5-3 2.5 1 2.5 3Z"
|
|
7
|
+
clipRule="evenodd"
|
|
8
|
+
/>
|
|
9
|
+
)
|
|
@@ -26,6 +26,7 @@ import { ExclamationTriangle } from './ExclamationTriangle'
|
|
|
26
26
|
import { ExternalLink } from './ExternalLink'
|
|
27
27
|
import { Home } from './Home'
|
|
28
28
|
import { Image } from './Image'
|
|
29
|
+
import { MoneyBill } from './MoneyBill'
|
|
29
30
|
import { Move } from './Move'
|
|
30
31
|
import { Order } from './Order'
|
|
31
32
|
import { Pagali } from './Pagali'
|
|
@@ -82,6 +83,7 @@ export const icons = {
|
|
|
82
83
|
externalLink: ExternalLink,
|
|
83
84
|
home: Home,
|
|
84
85
|
image: Image,
|
|
86
|
+
moneyBill: MoneyBill,
|
|
85
87
|
move: Move,
|
|
86
88
|
order: Order,
|
|
87
89
|
pagali: Pagali,
|
package/src/Layout/Box/Box.tsx
CHANGED
|
@@ -26,6 +26,7 @@ export class Box extends React.PureComponent<BoxProps, BoxState> {
|
|
|
26
26
|
className = '',
|
|
27
27
|
variant = 'default',
|
|
28
28
|
isToggle = false,
|
|
29
|
+
id,
|
|
29
30
|
} = this.props
|
|
30
31
|
const toggleContent = (value?: boolean) =>
|
|
31
32
|
this.setState({ isOpen: value ?? !this.state.isOpen })
|
|
@@ -43,6 +44,7 @@ export class Box extends React.PureComponent<BoxProps, BoxState> {
|
|
|
43
44
|
<div
|
|
44
45
|
className={`box w-full flex flex-col bg-base-1 border border-card-stroke rounded ${className}`}
|
|
45
46
|
data-opened={isOpen}
|
|
47
|
+
id={id}
|
|
46
48
|
>
|
|
47
49
|
{children}
|
|
48
50
|
</div>
|
|
@@ -56,6 +58,10 @@ export interface BoxProps extends Partial<SharedContextProps> {
|
|
|
56
58
|
* Custom class name
|
|
57
59
|
* */
|
|
58
60
|
className?: string
|
|
61
|
+
/**
|
|
62
|
+
* Box ID
|
|
63
|
+
* */
|
|
64
|
+
id?: string
|
|
59
65
|
/**
|
|
60
66
|
* Box Header and Content
|
|
61
67
|
*/
|
|
@@ -69,6 +75,7 @@ export interface BoxProps extends Partial<SharedContextProps> {
|
|
|
69
75
|
* */
|
|
70
76
|
isOpen?: boolean
|
|
71
77
|
}
|
|
78
|
+
|
|
72
79
|
interface BoxState {
|
|
73
80
|
isOpen: boolean
|
|
74
81
|
}
|
|
@@ -62,6 +62,7 @@ const PaginationNavComponent = ({
|
|
|
62
62
|
</span>{' '}
|
|
63
63
|
/{' '}
|
|
64
64
|
<button
|
|
65
|
+
type="button"
|
|
65
66
|
id="btnPaginationLastPage"
|
|
66
67
|
className="pagination-nav-total focus:outline-none"
|
|
67
68
|
onClick={() => {
|
|
@@ -73,6 +74,7 @@ const PaginationNavComponent = ({
|
|
|
73
74
|
</div>
|
|
74
75
|
<div className="text-inverted-2 ml-5 flex items-center">
|
|
75
76
|
<button
|
|
77
|
+
type="button"
|
|
76
78
|
id="btnPaginationPrev"
|
|
77
79
|
className={`pagination-nav-previous mr-3 duration-200 outline-none ${
|
|
78
80
|
hasPrev ? 'hover:text-inverted-1' : ''
|
|
@@ -85,6 +87,7 @@ const PaginationNavComponent = ({
|
|
|
85
87
|
<Icon icon="arrowLeft" block size={4} />
|
|
86
88
|
</button>
|
|
87
89
|
<button
|
|
90
|
+
type="button"
|
|
88
91
|
id="btnPaginationNext"
|
|
89
92
|
className={`pagination-nav-next duration-200 outline-none ${
|
|
90
93
|
hasNext ? 'hover:text-inverted-1' : ''
|