@loja-integrada/admin-components 0.18.24 → 0.18.25
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/Icons/icons-path/Rocket.d.ts +2 -0
- package/dist/Icons/icons-path/index.d.ts +1 -0
- package/dist/Indicators/Badge/Badge.d.ts +11 -1
- package/dist/Layout/ListActions/ListActions.d.ts +42 -0
- package/dist/Layout/ListActions/ListActions.spec.d.ts +1 -0
- package/dist/Layout/ListActions/ListActions.stories.d.ts +4 -0
- package/dist/Layout/ListActions/index.d.ts +1 -0
- package/dist/Layout/index.d.ts +1 -0
- package/dist/admin-components.cjs.development.js +1257 -73
- 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 +1257 -74
- package/dist/admin-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Forms/Checkbox/Checkbox.tsx +2 -2
- package/src/Icons/icons-path/Rocket.tsx +22 -0
- package/src/Icons/icons-path/index.ts +2 -0
- package/src/Indicators/Badge/Badge.spec.tsx +21 -0
- package/src/Indicators/Badge/Badge.tsx +25 -5
- package/src/Layout/ListActions/ListActions.spec.tsx +23 -0
- package/src/Layout/ListActions/ListActions.stories.tsx +71 -0
- package/src/Layout/ListActions/ListActions.tsx +149 -0
- package/src/Layout/ListActions/index.tsx +1 -0
- package/src/Layout/index.ts +1 -0
package/package.json
CHANGED
|
@@ -87,13 +87,13 @@ const CheckboxComponent = (
|
|
|
87
87
|
htmlFor={inputId}
|
|
88
88
|
className={`inline-flex ${alignOptions[boxAlign]} cursor-pointer`}
|
|
89
89
|
>
|
|
90
|
-
<span className="relative rounded z-
|
|
90
|
+
<span className="relative rounded z-10 flex items-center justify-center focus-within:ring-2 ring-focus">
|
|
91
91
|
<input
|
|
92
92
|
ref={ref || inputRef}
|
|
93
93
|
type="checkbox"
|
|
94
94
|
id={inputId}
|
|
95
95
|
name={name}
|
|
96
|
-
className="opacity-0 absolute h-4 w-4 z-
|
|
96
|
+
className="opacity-0 absolute h-4 w-4 z-10 cursor-pointer"
|
|
97
97
|
checked={isChecked}
|
|
98
98
|
onChange={handleChange}
|
|
99
99
|
disabled={!!disabled}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const Rocket = () => (
|
|
4
|
+
<>
|
|
5
|
+
<path
|
|
6
|
+
fillRule="evenodd"
|
|
7
|
+
d="M16.784.869a.75.75 0 0 1 .546.545l.29 1.157a8.942 8.942 0 0 1-2.353 8.492l-.26.26a10.78 10.78 0 0 1-1.644 1.348l-3.416 2.277a.75.75 0 0 1-.946-.094L3.344 9.198a.75.75 0 0 1-.094-.947l2.278-3.416c.394-.59.845-1.141 1.347-1.643l.26-.26A8.942 8.942 0 0 1 15.627.579l1.157.29Zm-.8 1.346-.72-.18a7.442 7.442 0 0 0-7.068 1.957l-.26.26c-.433.433-.821.907-1.16 1.415L4.84 8.572l4.787 4.787 2.904-1.936a9.29 9.29 0 0 0 1.415-1.16l.26-.26a7.442 7.442 0 0 0 1.958-7.068l-.18-.72Z"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
/>
|
|
10
|
+
<path
|
|
11
|
+
fillRule="evenodd"
|
|
12
|
+
d="M13.49 8.597a2.75 2.75 0 1 1-3.889-3.889 2.75 2.75 0 0 1 3.89 3.89ZM10.769 7.43a1.1 1.1 0 1 0 1.556-1.555 1.1 1.1 0 0 0-1.556 1.555Z"
|
|
13
|
+
clipRule="evenodd"
|
|
14
|
+
/>
|
|
15
|
+
<path d="M2.063 13.661a.5.5 0 0 1 .707 0l.353.354a.5.5 0 0 1 0 .707l-.425.425a.5.5 0 0 1-.707 0l-.353-.354a.5.5 0 0 1 0-.707l.425-.425ZM3.477 15.075a.5.5 0 0 1 .707 0l.353.354a.5.5 0 0 1 0 .707l-1.3 1.3a.5.5 0 0 1-.706 0l-.354-.354a.5.5 0 0 1 0-.707l1.3-1.3Z" />
|
|
16
|
+
<path
|
|
17
|
+
fillRule="evenodd"
|
|
18
|
+
d="m4.475 11.602.884-.883-1.061-1.061-1.06 1.06a1.25 1.25 0 0 0 0 1.768l2.474 2.475a1.25 1.25 0 0 0 1.768 0l1.06-1.06-1.06-1.061-.884.884-2.121-2.122ZM12.456 14.228l-.56-1.681 1.422-.475.707 2.122a.75.75 0 0 1-.18.767l-2.122 2.121a.75.75 0 0 1-1.22-.235l-1.06-2.474 1.378-.591.624 1.457 1.01-1.01ZM3.97 5.743l1.682.56.474-1.423-2.121-.707a.75.75 0 0 0-.768.182l-2.12 2.12a.75.75 0 0 0 .234 1.22l2.475 1.061.59-1.379-1.456-.624 1.01-1.01Z"
|
|
19
|
+
clipRule="evenodd"
|
|
20
|
+
/>
|
|
21
|
+
</>
|
|
22
|
+
)
|
|
@@ -71,6 +71,7 @@ import { WhatsApp } from './WhatsApp'
|
|
|
71
71
|
import { IconSolidLI } from './IconSolidLI'
|
|
72
72
|
import { ThinAngleRight } from './ThinAngleRight'
|
|
73
73
|
import { EyeSlash } from './EyeSlash'
|
|
74
|
+
import { Rocket } from './Rocket'
|
|
74
75
|
|
|
75
76
|
export const icons = {
|
|
76
77
|
adjust: Adjust,
|
|
@@ -147,4 +148,5 @@ export const icons = {
|
|
|
147
148
|
iconSolidLI: IconSolidLI,
|
|
148
149
|
thinAngleRight: ThinAngleRight,
|
|
149
150
|
eyeSlash: EyeSlash,
|
|
151
|
+
rocket: Rocket,
|
|
150
152
|
}
|
|
@@ -2,6 +2,7 @@ import * as React from "react"
|
|
|
2
2
|
import { composeStories } from "@storybook/testing-react"
|
|
3
3
|
import { mount } from "@cypress/react"
|
|
4
4
|
import * as stories from "./Badge.stories"
|
|
5
|
+
import { Badge } from "./Badge"
|
|
5
6
|
|
|
6
7
|
const { Default, Small, Expanded } = composeStories(stories)
|
|
7
8
|
const badgeClass = '.badge'
|
|
@@ -21,6 +22,26 @@ describe(specTitle('Badge tests'), () => {
|
|
|
21
22
|
cy.get(badgeClass).should('have.class', 'px-1.5')
|
|
22
23
|
})
|
|
23
24
|
|
|
25
|
+
it('Size XSmall', () => {
|
|
26
|
+
mount(<Badge size="xsmall" text="Example text" />)
|
|
27
|
+
cy.get(badgeClass).should('have.class', 'text-f8')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('Rounded Small', () => {
|
|
31
|
+
mount(<Badge rounded="small" text="Example text" />)
|
|
32
|
+
cy.get(badgeClass).should('have.class', 'rounded')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('Rounded None', () => {
|
|
36
|
+
mount(<Badge rounded="none" text="Example text" />)
|
|
37
|
+
cy.get(badgeClass).should('have.class', 'rounded-none')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('Rounded Full', () => {
|
|
41
|
+
mount(<Badge rounded="full" text="Example text" />)
|
|
42
|
+
cy.get(badgeClass).should('have.class', 'rounded-full')
|
|
43
|
+
})
|
|
44
|
+
|
|
24
45
|
it('Expanded', () => {
|
|
25
46
|
mount(<Expanded />)
|
|
26
47
|
cy.get(badgeClass).should('have.class', 'w-full')
|
|
@@ -10,9 +10,22 @@ const badgeTypes = {
|
|
|
10
10
|
focus: 'bg-focus',
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const badgeRounded = {
|
|
14
|
+
full: 'rounded-full',
|
|
15
|
+
small: 'rounded',
|
|
16
|
+
none: 'rounded-none',
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
const badgeSizes = {
|
|
14
|
-
default: '
|
|
15
|
-
small: '
|
|
20
|
+
default: 'text-xs',
|
|
21
|
+
small: 'text-[0.70rem]',
|
|
22
|
+
xsmall: 'text-f8',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const badgeClasses = {
|
|
26
|
+
default: 'px-2 py-0.5',
|
|
27
|
+
small: 'px-1.5',
|
|
28
|
+
xsmall: 'px-0.5 py-px',
|
|
16
29
|
}
|
|
17
30
|
|
|
18
31
|
const BadgeComponent = ({
|
|
@@ -20,12 +33,15 @@ const BadgeComponent = ({
|
|
|
20
33
|
text,
|
|
21
34
|
size = 'default',
|
|
22
35
|
expanded = false,
|
|
36
|
+
rounded = 'full',
|
|
23
37
|
}: BadgeProps) => {
|
|
24
38
|
return (
|
|
25
39
|
<div
|
|
26
|
-
className={`badge items-center justify-center rounded
|
|
27
|
-
|
|
28
|
-
} ${badgeSizes[size]} ${
|
|
40
|
+
className={`badge items-center justify-center ${badgeRounded[rounded]} ${
|
|
41
|
+
badgeClasses[size]
|
|
42
|
+
} ${badgeTypes[type]} ${badgeSizes[size]} ${
|
|
43
|
+
expanded ? 'flex w-full' : 'inline-flex'
|
|
44
|
+
}`}
|
|
29
45
|
>
|
|
30
46
|
<span
|
|
31
47
|
className={`badgeText tracking-4 font-semibold ${
|
|
@@ -57,4 +73,8 @@ export interface BadgeProps {
|
|
|
57
73
|
* Enlarge width of the badge
|
|
58
74
|
* */
|
|
59
75
|
expanded?: boolean
|
|
76
|
+
/**
|
|
77
|
+
* Style of rounded corners
|
|
78
|
+
* */
|
|
79
|
+
rounded?: keyof typeof badgeRounded
|
|
60
80
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { composeStories } from '@storybook/testing-react'
|
|
3
|
+
import { mount } from '@cypress/react'
|
|
4
|
+
import * as stories from './ListActions.stories'
|
|
5
|
+
|
|
6
|
+
const { Default } = composeStories(stories)
|
|
7
|
+
|
|
8
|
+
const specTitle = require('cypress-sonarqube-reporter/specTitle')
|
|
9
|
+
|
|
10
|
+
describe(specTitle('ListActions tests'), () => {
|
|
11
|
+
it('Default', () => {
|
|
12
|
+
mount(<Default />)
|
|
13
|
+
cy.get('.list-actions').should('have.class', 'opacity-100')
|
|
14
|
+
cy.get('.list-actions__button').should('exist')
|
|
15
|
+
cy.get('.remove-selected').should('have.class', 'lg:text-danger-dark')
|
|
16
|
+
|
|
17
|
+
let alerted = ''
|
|
18
|
+
cy.on('window:alert', (msg) => (alerted = msg))
|
|
19
|
+
cy.get('.remove-selected')
|
|
20
|
+
.click()
|
|
21
|
+
.then(() => expect(alerted).to.match(/Remove/))
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Story, Meta } from '@storybook/react'
|
|
3
|
+
|
|
4
|
+
import { ListActions, ListActionsProps } from '.'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
component: ListActions,
|
|
8
|
+
title: 'Layout/ListActions',
|
|
9
|
+
} as Meta
|
|
10
|
+
|
|
11
|
+
const Template: Story<ListActionsProps> = (args) => <ListActions {...args} />
|
|
12
|
+
|
|
13
|
+
export const Default = Template.bind({})
|
|
14
|
+
Default.args = {
|
|
15
|
+
actions: [
|
|
16
|
+
{
|
|
17
|
+
buttons: [
|
|
18
|
+
{
|
|
19
|
+
className: 'edit-selected hidden lg:flex',
|
|
20
|
+
icon: 'blog',
|
|
21
|
+
text: (
|
|
22
|
+
<>
|
|
23
|
+
Editar em <br />
|
|
24
|
+
massa
|
|
25
|
+
</>
|
|
26
|
+
),
|
|
27
|
+
tagType: 'sign',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
buttons: [
|
|
33
|
+
{
|
|
34
|
+
className: 'enable-selected',
|
|
35
|
+
icon: 'checkCircle',
|
|
36
|
+
text: (
|
|
37
|
+
<>
|
|
38
|
+
Ativar <span className="hidden lg:inline">selecionados</span>
|
|
39
|
+
</>
|
|
40
|
+
),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
className: 'disable-selected',
|
|
44
|
+
icon: 'ban',
|
|
45
|
+
text: (
|
|
46
|
+
<>
|
|
47
|
+
Inativar <span className="hidden lg:inline">selecionados</span>
|
|
48
|
+
</>
|
|
49
|
+
),
|
|
50
|
+
tagType: 'new',
|
|
51
|
+
id: 'disable-selected',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
buttons: [
|
|
57
|
+
{
|
|
58
|
+
className: 'remove-selected',
|
|
59
|
+
variant: 'danger',
|
|
60
|
+
icon: 'trash',
|
|
61
|
+
text: (
|
|
62
|
+
<>
|
|
63
|
+
Remover <span className="hidden lg:inline">selecionados</span>
|
|
64
|
+
</>
|
|
65
|
+
),
|
|
66
|
+
onClick: () => alert('Remove'),
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { ButtonHTMLAttributes, useEffect } from 'react'
|
|
2
|
+
import { Icon, IconProps } from '../../Icons'
|
|
3
|
+
import { Badge } from '../../Indicators'
|
|
4
|
+
|
|
5
|
+
export interface ListActionsTagProps {
|
|
6
|
+
type: ListActionButtonProps['tagType']
|
|
7
|
+
text?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Tag = ({ type, text }: ListActionsTagProps) => {
|
|
11
|
+
const commonClasses = 'hidden lg:block absolute'
|
|
12
|
+
if (type === 'sign') {
|
|
13
|
+
return (
|
|
14
|
+
<span
|
|
15
|
+
className={`-mb-1 -mr-3 bottom-0 right-0 text-primary-dark ${commonClasses}`}
|
|
16
|
+
>
|
|
17
|
+
<Icon icon="rocket" size={3} />
|
|
18
|
+
</span>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<span
|
|
24
|
+
className={`top-3 left-3 px-0.5 py-px rounded-sm text-f8 font-semibold leading-3 text-base-1 ${commonClasses}`}
|
|
25
|
+
>
|
|
26
|
+
<Badge
|
|
27
|
+
size="xsmall"
|
|
28
|
+
type="primary"
|
|
29
|
+
rounded="small"
|
|
30
|
+
text={text ? text : 'NOVO'}
|
|
31
|
+
/>
|
|
32
|
+
</span>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const ListActionButton = ({
|
|
37
|
+
className,
|
|
38
|
+
tagType,
|
|
39
|
+
tagText,
|
|
40
|
+
icon,
|
|
41
|
+
text,
|
|
42
|
+
variant = 'default',
|
|
43
|
+
type = 'button',
|
|
44
|
+
...props
|
|
45
|
+
}: ListActionButtonProps) => {
|
|
46
|
+
const variantClasses = {
|
|
47
|
+
default: 'lg:text-inverted-2',
|
|
48
|
+
danger: 'lg:text-danger-dark',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<button
|
|
53
|
+
{...props}
|
|
54
|
+
type={type}
|
|
55
|
+
className={`list-actions__button rounded relative flex items-center justify-center flex-col gap-y-px lg:gap-y-1 px-3 lg:p-2 lg:border border-transparent text-base-1 transition-colors duration-200 lg:hover:bg-base-3 lg:hover:border-card-stroke ${
|
|
56
|
+
variant ? variantClasses[variant] : ''
|
|
57
|
+
} ${className ? className : ''}`}
|
|
58
|
+
>
|
|
59
|
+
<span className="relative">
|
|
60
|
+
<Icon icon={icon} size={5} className="p-px" />
|
|
61
|
+
{tagType || tagText ? <Tag type={tagType} text={tagText} /> : null}
|
|
62
|
+
</span>
|
|
63
|
+
<p className="lg:w-24 text-f8 lg:text-f7 font-semibold tracking-4 text-center select-none leading-tight">
|
|
64
|
+
{text}
|
|
65
|
+
</p>
|
|
66
|
+
</button>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ListActionsComponent = ({
|
|
71
|
+
actions,
|
|
72
|
+
isVisible = true,
|
|
73
|
+
}: ListActionsProps) => {
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const botbar =
|
|
76
|
+
window?.parent?.document?.querySelector<HTMLElement>('.botbar')
|
|
77
|
+
if (botbar) botbar.style.display = 'none'
|
|
78
|
+
|
|
79
|
+
return () => {
|
|
80
|
+
if (botbar) botbar.style.display = ''
|
|
81
|
+
}
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
className={`list-actions w-full z-50 h-12 lg:h-auto pb-0-safe fixed right-0 bottom-0 flex justify-center items-center lg:gap-x-8 shadow bg-inverted-1 lg:bg-base-2 transition-all px-4 lg:py-2 ${
|
|
87
|
+
isVisible
|
|
88
|
+
? 'opacity-100 pointer-events-auto translate-y-0'
|
|
89
|
+
: 'opacity-0 pointer-events-none translate-y-2'
|
|
90
|
+
}`}
|
|
91
|
+
>
|
|
92
|
+
{actions.map((columns) =>
|
|
93
|
+
Object.values(columns).map(
|
|
94
|
+
(buttons: ListActionButtonProps[], index) => (
|
|
95
|
+
<div
|
|
96
|
+
key={index}
|
|
97
|
+
className="relative flex lg:after:absolute after:-right-4 after:w-px after:h-full after:bg-base-4 last:after:hidden"
|
|
98
|
+
>
|
|
99
|
+
{buttons.map((button) => (
|
|
100
|
+
<ListActionButton key={button.icon} {...button} />
|
|
101
|
+
))}
|
|
102
|
+
</div>
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const ListActions = React.memo(ListActionsComponent)
|
|
111
|
+
|
|
112
|
+
export interface ListActionsButtons {
|
|
113
|
+
buttons: ListActionButtonProps[]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ListActionsProps {
|
|
117
|
+
/**
|
|
118
|
+
* Actions of list
|
|
119
|
+
*/
|
|
120
|
+
actions: ListActionsButtons[]
|
|
121
|
+
/**
|
|
122
|
+
* Visibility of component
|
|
123
|
+
*/
|
|
124
|
+
isVisible?: boolean
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ListActionButtonProps
|
|
128
|
+
extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
129
|
+
/**
|
|
130
|
+
* Button tag
|
|
131
|
+
*/
|
|
132
|
+
tagType?: 'new' | 'sign'
|
|
133
|
+
/**
|
|
134
|
+
* Button tag text
|
|
135
|
+
*/
|
|
136
|
+
tagText?: string
|
|
137
|
+
/**
|
|
138
|
+
* Button icon
|
|
139
|
+
*/
|
|
140
|
+
icon: IconProps['icon']
|
|
141
|
+
/**
|
|
142
|
+
* Button text
|
|
143
|
+
*/
|
|
144
|
+
text: string | React.ReactNode
|
|
145
|
+
/**
|
|
146
|
+
* Button type
|
|
147
|
+
*/
|
|
148
|
+
variant?: 'default' | 'danger'
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ListActions'
|