@loja-integrada/admin-components 0.13.1 → 0.15.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.
Files changed (43) hide show
  1. package/dist/Components/TableList/TableList.d.ts +38 -0
  2. package/dist/Components/TableList/TableList.spec.d.ts +1 -0
  3. package/dist/Components/TableList/TableList.stories.d.ts +7 -0
  4. package/dist/Components/TableList/TableListItem.d.ts +3 -0
  5. package/dist/Components/TableList/TableListItem.interface.d.ts +56 -0
  6. package/dist/Components/TableList/TableListItem.spec.d.ts +1 -0
  7. package/dist/Components/TableList/TableListItem.stories.d.ts +4 -0
  8. package/dist/Components/TableList/TableListItemLoading.d.ts +3 -0
  9. package/dist/Components/TableList/TableListItemLoading.spec.d.ts +1 -0
  10. package/dist/Components/TableList/TableListItemLoading.stories.d.ts +4 -0
  11. package/dist/Components/TableList/TableListItemWrapper.d.ts +12 -0
  12. package/dist/Components/TableList/TableListItemWrapper.spec.d.ts +1 -0
  13. package/dist/Components/TableList/TableListItemWrapper.stories.d.ts +4 -0
  14. package/dist/Components/TableList/index.d.ts +1 -0
  15. package/dist/Components/index.d.ts +1 -0
  16. package/dist/Indicators/Alert/Alert.d.ts +5 -1
  17. package/dist/Navigation/Breadcrumb/index.d.ts +5 -2
  18. package/dist/admin-components.cjs.development.js +191 -3
  19. package/dist/admin-components.cjs.development.js.map +1 -1
  20. package/dist/admin-components.cjs.production.min.js +1 -1
  21. package/dist/admin-components.cjs.production.min.js.map +1 -1
  22. package/dist/admin-components.esm.js +191 -4
  23. package/dist/admin-components.esm.js.map +1 -1
  24. package/package.json +10 -6
  25. package/src/Components/LoadingPlaceholder/LoadingPlaceholder.stories.tsx +1 -1
  26. package/src/Components/TableList/TableList.spec.tsx +85 -0
  27. package/src/Components/TableList/TableList.stories.tsx +168 -0
  28. package/src/Components/TableList/TableList.tsx +168 -0
  29. package/src/Components/TableList/TableListItem.interface.ts +57 -0
  30. package/src/Components/TableList/TableListItem.spec.tsx +64 -0
  31. package/src/Components/TableList/TableListItem.stories.tsx +43 -0
  32. package/src/Components/TableList/TableListItem.tsx +63 -0
  33. package/src/Components/TableList/TableListItemLoading.spec.tsx +18 -0
  34. package/src/Components/TableList/TableListItemLoading.stories.tsx +22 -0
  35. package/src/Components/TableList/TableListItemLoading.tsx +40 -0
  36. package/src/Components/TableList/TableListItemWrapper.spec.tsx +32 -0
  37. package/src/Components/TableList/TableListItemWrapper.stories.tsx +38 -0
  38. package/src/Components/TableList/TableListItemWrapper.tsx +40 -0
  39. package/src/Components/TableList/index.tsx +1 -0
  40. package/src/Components/index.ts +1 -0
  41. package/src/Indicators/Alert/Alert.tsx +9 -1
  42. package/src/Navigation/Breadcrumb/Breadcrumb.spec.tsx +12 -0
  43. package/src/Navigation/Breadcrumb/index.tsx +17 -3
@@ -0,0 +1,63 @@
1
+ import React from 'react'
2
+
3
+ import { Icon } from '../../Icons'
4
+ import { TableListItemProps } from './TableListItem.interface'
5
+ import { TableListItemWrapper } from './TableListItemWrapper'
6
+
7
+ export const TableListItem: React.FunctionComponent<TableListItemProps> = ({
8
+ forceBorderDesktop = false,
9
+ title,
10
+ description,
11
+ timestampTime,
12
+ timestampDate,
13
+ itemWrapper,
14
+ itemWrapperProps,
15
+ withHover = false,
16
+ isInsideContainer = false,
17
+ withIcon,
18
+ }) => {
19
+ return (
20
+ <div
21
+ className={`table-item border-primary-bold border-opacity-10 border-t first:border-t-0 ${
22
+ forceBorderDesktop ? 'lg:first:border-t' : ''
23
+ }`}
24
+ >
25
+ <TableListItemWrapper
26
+ Wrapper={itemWrapper}
27
+ props={itemWrapperProps}
28
+ withHover={withHover}
29
+ isInsideContainer={isInsideContainer}
30
+ >
31
+ {withIcon && (
32
+ <div className="table-item-icon flex items-center justify-center flex-none mr-4">
33
+ <div
34
+ className={`table-item-icon-background h-8 w-8 flex items-center justify-center rounded ${
35
+ withIcon.class || ''
36
+ }`}
37
+ >
38
+ <Icon icon={withIcon.icon || 'minus'} block size={5} />
39
+ </div>
40
+ </div>
41
+ )}
42
+ <div className="table-item-content flex flex-col justify-center flex-auto gap-1.5 min-w-0 w-full">
43
+ <div className="table-item-title text-f6 font-semibold">{title}</div>
44
+ {description && (
45
+ <div className="table-item-description">{description}</div>
46
+ )}
47
+ </div>
48
+ {timestampTime && (
49
+ <div className="table-item-timestamp flex flex-col justify-center items-end shrink-0 gap-1.5 ml-4 min-w-0 max-w-[50%] text-right">
50
+ <div className="table-item-timestamp-time w-full">
51
+ {timestampTime}
52
+ </div>
53
+ {timestampDate && (
54
+ <div className="table-item-timestamp-date w-full hidden lg:block">
55
+ {timestampDate}
56
+ </div>
57
+ )}
58
+ </div>
59
+ )}
60
+ </TableListItemWrapper>
61
+ </div>
62
+ )
63
+ }
@@ -0,0 +1,18 @@
1
+ import * as React from "react"
2
+ import { composeStories } from "@storybook/testing-react"
3
+ import { mount } from "@cypress/react"
4
+ import * as stories from "./TableListItemLoading.stories"
5
+
6
+ const { ItemLoading } = composeStories(stories)
7
+
8
+ describe('TableListItemLoading tests', () => {
9
+
10
+ it('Default', () => {
11
+ mount(<ItemLoading />)
12
+ cy.get('.table-item.table-item-loading')
13
+ .should('exist')
14
+ .find('.table-item-content .table-item-title .animate-pulse')
15
+ .should('exist')
16
+ })
17
+
18
+ })
@@ -0,0 +1,22 @@
1
+ import React from 'react'
2
+ import { Story, Meta } from '@storybook/react'
3
+ import { withDesign } from 'storybook-addon-designs'
4
+
5
+ import { TableListItemProps } from './TableListItem.interface'
6
+ import { TableListItemLoading } from './TableListItemLoading'
7
+
8
+ export default {
9
+ title: 'Components/TableList',
10
+ component: TableListItemLoading,
11
+ decorators: [withDesign],
12
+ parameters: {
13
+ layout: 'padded',
14
+ },
15
+ args: {
16
+ forceBorderDesktop: false,
17
+ },
18
+ } as Meta
19
+
20
+ const Template: Story<Pick<TableListItemProps, 'forceBorderDesktop'>> = (args) => <TableListItemLoading {...args} />
21
+
22
+ export const ItemLoading = Template.bind({})
@@ -0,0 +1,40 @@
1
+ import React from 'react'
2
+
3
+ import { LoadingPlaceholder } from '../LoadingPlaceholder'
4
+ import { TableListItemProps } from './TableListItem.interface'
5
+ import { TableListItemWrapper } from './TableListItemWrapper'
6
+
7
+ export const TableListItemLoading: React.FunctionComponent<
8
+ Pick<TableListItemProps, 'forceBorderDesktop'>
9
+ > = ({ forceBorderDesktop = false }) => {
10
+ return (
11
+ <div
12
+ className={`table-item table-item-loading border-primary-bold border-opacity-10 border-t first:border-t-0 ${
13
+ forceBorderDesktop ? 'lg:first:border-t' : ''
14
+ }`}
15
+ >
16
+ <TableListItemWrapper>
17
+ <div className="table-item-icon flex items-center justify-center flex-none mr-4">
18
+ <div
19
+ className={`table-item-icon-background h-8 w-8 flex items-center justify-center rounded`}
20
+ >
21
+ <LoadingPlaceholder className="w-full" />
22
+ </div>
23
+ </div>
24
+ <div className="table-item-content flex flex-col justify-center flex-auto gap-1.5 min-w-0 w-full">
25
+ <div className="table-item-title text-f6 font-semibold">
26
+ <LoadingPlaceholder className="w-2/3" />
27
+ </div>
28
+ <div className="table-item-description">
29
+ <LoadingPlaceholder className="w-1/3" />
30
+ </div>
31
+ </div>
32
+ <div className="table-item-timestamp flex flex-col justify-center items-end shrink-0 gap-1.5 ml-4 min-w-0 max-w-[50%] text-right">
33
+ <div className="table-item-timestamp-time w-full">
34
+ <LoadingPlaceholder className="w-16" />
35
+ </div>
36
+ </div>
37
+ </TableListItemWrapper>
38
+ </div>
39
+ )
40
+ }
@@ -0,0 +1,32 @@
1
+ import * as React from "react"
2
+ import { composeStories } from "@storybook/testing-react"
3
+ import { mount } from "@cypress/react"
4
+ import * as stories from "./TableListItemWrapper.stories"
5
+
6
+ const { ItemWrapper } = composeStories(stories)
7
+
8
+ describe('TableListItemWrapper tests', () => {
9
+
10
+ it('Default', () => {
11
+ mount(<ItemWrapper withHover={false} isInsideContainer={false} />)
12
+ cy.get('a.table-item-wrapper')
13
+ .should('exist')
14
+ .should('have.attr', 'href', '#a')
15
+ .should('have.class', 'flex relative')
16
+ .should('not.have.class', 'hover:bg-base-2 before:hover:block')
17
+ .contains('Some randon content')
18
+
19
+ })
20
+
21
+ it('Without Wrapper', () => {
22
+ mount(<ItemWrapper Wrapper={undefined} />)
23
+ cy.get('div.table-item-wrapper').should('exist')
24
+ })
25
+
26
+ it('With Hover', () => {
27
+ mount(<ItemWrapper withHover={true} isInsideContainer={true} Wrapper={undefined} />)
28
+ cy.get('.table-item-wrapper').should('have.class', 'hover:bg-base-2 before:hover:block')
29
+ cy.get('.table-item-wrapper').should('have.class', 'after:hover:block')
30
+ })
31
+
32
+ })
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+ import { Story, Meta } from '@storybook/react'
3
+ import { withDesign } from 'storybook-addon-designs'
4
+
5
+ import { TableListItemWrapper, TableListItemWrapperProps } from './TableListItemWrapper'
6
+
7
+ const CellLink = (props: any) => {
8
+ const { href = '/', children, ...restProps } = props
9
+ return (
10
+ <a href={href} {...restProps}>{children}</a>
11
+ )
12
+ }
13
+
14
+ export default {
15
+ title: 'Components/TableList',
16
+ component: TableListItemWrapper,
17
+ decorators: [withDesign],
18
+ parameters: {
19
+ layout: 'padded',
20
+ },
21
+ args: {
22
+ Wrapper: CellLink,
23
+ children: (
24
+ <div>
25
+ Some randon content
26
+ </div>
27
+ ),
28
+ props: {
29
+ href: '#a'
30
+ },
31
+ withHover: true,
32
+ isInsideContainer: true
33
+ },
34
+ } as Meta
35
+
36
+ const Template: Story<TableListItemWrapperProps> = (args) => <TableListItemWrapper {...args} />
37
+
38
+ export const ItemWrapper = Template.bind({})
@@ -0,0 +1,40 @@
1
+ import React from 'react'
2
+
3
+ import { TableListItemWrapperProp } from './TableListItem.interface'
4
+
5
+ const ItemWrapperClasses = `flex relative py-6 text-f7 leading-4 break-words no-underline`
6
+ const ItemWrapperClassesContainerHover = `before:hover:block before:hover:absolute before:hover:h-full before:hover:w-8 before:hover:top-0 before:hover:-left-8 before:hover:bg-base-2 after:hover:block after:hover:absolute after:hover:h-full after:hover:w-8 after:hover:top-0 after:hover:-right-8 after:hover:bg-base-2`
7
+
8
+ const DefaultWrapper = (props: any) => {
9
+ const { children, ...restProps } = props
10
+ return <div {...restProps}>{children}</div>
11
+ }
12
+
13
+ export const TableListItemWrapper = ({
14
+ Wrapper = DefaultWrapper,
15
+ props = {},
16
+ children,
17
+ withHover = false,
18
+ isInsideContainer = false,
19
+ }: TableListItemWrapperProps) => (
20
+ <Wrapper
21
+ className={`table-item-wrapper ${ItemWrapperClasses} ${
22
+ withHover
23
+ ? `hover:bg-base-2 ${
24
+ isInsideContainer ? ItemWrapperClassesContainerHover : ''
25
+ }`
26
+ : ''
27
+ }`}
28
+ {...props}
29
+ >
30
+ {children}
31
+ </Wrapper>
32
+ )
33
+
34
+ export interface TableListItemWrapperProps {
35
+ Wrapper?: TableListItemWrapperProp
36
+ children: React.ReactNode
37
+ props?: { [key: string]: unknown }
38
+ withHover?: boolean
39
+ isInsideContainer?: boolean
40
+ }
@@ -0,0 +1 @@
1
+ export * from './TableList'
@@ -1,6 +1,7 @@
1
1
  export * from './Button'
2
2
  export * from './LoadingPlaceholder'
3
3
  export * from './Table'
4
+ export * from './TableList'
4
5
  export * from './Tabs'
5
6
  export * from './Timeline'
6
7
  export * from './Modal'
@@ -47,6 +47,7 @@ const AlertComponent = ({
47
47
  showClose = false,
48
48
  onClose,
49
49
  hideIcon = false,
50
+ customIcon,
50
51
  }: AlertProps) => {
51
52
  const [alertIsOpen, setAlertIsOpen] = useState(isOpen)
52
53
  useEffect(() => {
@@ -67,7 +68,10 @@ const AlertComponent = ({
67
68
  <div
68
69
  className={`alert-icon hidden sm:block flex-shrink-0 mr-3 ${alertTypes[type].iconClass}`}
69
70
  >
70
- <Icon icon={alertTypes[type].icon} size={6} />
71
+ <Icon
72
+ icon={customIcon ? customIcon : alertTypes[type].icon}
73
+ size={6}
74
+ />
71
75
  </div>
72
76
  )}
73
77
  <div className="flex-grow flex flex-col sm:flex-row items-start sm:items-center justify-between min-w-0">
@@ -126,6 +130,10 @@ export interface AlertProps {
126
130
  * @default false
127
131
  */
128
132
  hideIcon?: boolean
133
+ /**
134
+ * Custom icon
135
+ */
136
+ customIcon?: IconProps['icon']
129
137
  /**
130
138
  * Action for the alert, like button and hiperlinks
131
139
  * */
@@ -55,8 +55,20 @@ describe('Breadcrumb tests', () => {
55
55
  it('WithActions', () => {
56
56
  mount(<WithActions />)
57
57
  cy.get('.header-navigation .header-navigation-content').within(() => {
58
+ cy.get('.header-navigation-actions').should('have.class', 'flex')
58
59
  cy.get('.header-navigation-actions button').should('exist')
59
60
  })
60
61
  })
61
62
 
63
+ it('WithActionsDisplay', () => {
64
+ mount(<WithActions actionsDisplay="desktop" />)
65
+ cy.get('.header-navigation .header-navigation-content').within(() => {
66
+ cy.get('.header-navigation-actions').should('have.class', 'hidden lg:flex')
67
+ })
68
+ mount(<WithActions actionsDisplay="mobile" />)
69
+ cy.get('.header-navigation .header-navigation-content').within(() => {
70
+ cy.get('.header-navigation-actions').should('have.class', 'flex lg:hidden')
71
+ })
72
+ })
73
+
62
74
  })
@@ -1,6 +1,12 @@
1
1
  import React from 'react'
2
2
  import { Icon } from '../../Icons/Icon'
3
3
 
4
+ const actionsDisplayClass = {
5
+ both: 'flex',
6
+ desktop: 'hidden lg:flex',
7
+ mobile: 'flex lg:hidden',
8
+ }
9
+
4
10
  export const Breadcrumb: React.FC<BreadcrumbProps> = React.memo(
5
11
  ({
6
12
  Link,
@@ -10,6 +16,7 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = React.memo(
10
16
  mobileAlign = 'left',
11
17
  help,
12
18
  actions,
19
+ actionsDisplay = 'both',
13
20
  className = '',
14
21
  }) => {
15
22
  const renderPrevTitle = (
@@ -102,7 +109,11 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = React.memo(
102
109
  )}
103
110
  </div>
104
111
  {actions && (
105
- <div className="header-navigation-actions flex items-center gap-5">
112
+ <div
113
+ className={`header-navigation-actions items-center gap-5 ${
114
+ actionsDisplayClass[actionsDisplay] || ''
115
+ }`}
116
+ >
106
117
  {actions}
107
118
  </div>
108
119
  )}
@@ -134,8 +145,7 @@ export interface BreadcrumbProps {
134
145
  * Example: `const Link = (props: any) => { return <a href="https://www.google.com" target="_blank" className={`underline ` + props.className}>{props.children}</a> }`
135
146
  * */
136
147
  Link?: React.ElementType
137
- /**
138
- * Aligment of `currentTitle` at mobile
148
+ /** Aligment of `currentTitle` at mobile
139
149
  * @default 'left'
140
150
  * */
141
151
  mobileAlign?: 'left' | 'center'
@@ -151,4 +161,8 @@ export interface BreadcrumbProps {
151
161
  * Custom actions and buttons
152
162
  * */
153
163
  actions?: React.ReactNode
164
+ /** Should show actions only at one resolution or always
165
+ * @default 'both'
166
+ * */
167
+ actionsDisplay?: 'desktop' | 'mobile' | 'both'
154
168
  }