@loja-integrada/admin-components 0.9.1 → 0.9.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loja-integrada/admin-components",
3
- "version": "0.9.1",
3
+ "version": "0.9.5",
4
4
  "author": "Loja Integrada Front-End Team",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -5,7 +5,7 @@ const LoadingPlaceholderComponent = ({
5
5
  }: LoadingPlaceholderProps) => {
6
6
  return (
7
7
  <div className={`animate-pulse flex ${className}`}>
8
- <div className="h-4 bg-inverted-2 bg-opacity-20 rounded w-80 max-w-full"></div>
8
+ <div className="h-4 bg-inverted-2 bg-opacity-20 rounded w-full max-w-full"></div>
9
9
  </div>
10
10
  )
11
11
  }
@@ -197,11 +197,15 @@ const TableComponent = ({
197
197
  <tbody {...getTableBodyProps()} className="text-sm text-on-base">
198
198
  {isLoading ? (
199
199
  <tr>
200
- <td colSpan={columnsLength || 1} className={`${TdClasses}`}>
201
- <TdWrapper>
202
- <LoadingPlaceholder />
203
- </TdWrapper>
204
- </td>
200
+ {Array(columnsLength)
201
+ .fill(0)
202
+ .map((key) => (
203
+ <td key={key} className={`${TdClasses}`}>
204
+ <TdWrapper>
205
+ <LoadingPlaceholder />
206
+ </TdWrapper>
207
+ </td>
208
+ ))}
205
209
  </tr>
206
210
  ) : !rows || !rows.length ? (
207
211
  <tr>
@@ -26,13 +26,14 @@ export const TabsItem = ({
26
26
  }: TabsItemProps) => {
27
27
  return (
28
28
  <button
29
+ id={`btnTab${id}`}
29
30
  className={`tabs-item ${
30
31
  active ? 'tabs-item-active' : ''
31
32
  } group min-w-0 flex-shrink-0 overflow-x-hidden px-2 last:-mr-2 first:-ml-2`}
32
33
  onClick={() => onChange(id)}
33
34
  >
34
35
  <span
35
- className={`block text-f6 text-sm py-4 border-b-4 break-words group-hover:font-semibold ${activeStyles(
36
+ className={`block text-f6 tracking-4 text-sm py-4 border-b-4 break-words group-hover:font-semibold ${activeStyles(
36
37
  active
37
38
  )} ${boldFixStyle}`}
38
39
  data-title={title}
@@ -9,6 +9,7 @@ const CheckboxComponent = (
9
9
  checked,
10
10
  disabled,
11
11
  indeterminate,
12
+ boxAlign = 'center',
12
13
  ...props
13
14
  }: CheckboxProps,
14
15
  ref: React.ForwardedRef<HTMLInputElement>
@@ -19,6 +20,7 @@ const CheckboxComponent = (
19
20
  const [isIndeterminate, setIsIndeterminate] = React.useState(
20
21
  !!indeterminate || false
21
22
  )
23
+ const isCenterBoxAlign = boxAlign === 'center'
22
24
 
23
25
  React.useEffect(() => {
24
26
  setIsChecked(!!checked)
@@ -41,13 +43,17 @@ const CheckboxComponent = (
41
43
  isChecked || isIndeterminate ? 'scale-100' : 'scale-0'
42
44
  }`
43
45
 
44
- const checkboxIconContainerClasses = `border border-card-stroke transition duration-200 ease-in-out ${
45
- disabled
46
- ? 'bg-base-4'
47
- : isChecked || isIndeterminate
48
- ? 'bg-primary border-primary'
49
- : 'bg-base-1'
50
- } rounded w-4 h-4 flex justify-center items-center m-px`
46
+ const checkboxIconContainerClasses = `border border-card-stroke transition duration-200 ease-in-out
47
+ ${
48
+ disabled
49
+ ? 'bg-base-4'
50
+ : isChecked || isIndeterminate
51
+ ? 'bg-primary border-primary'
52
+ : 'bg-base-1'
53
+ }
54
+ ${isCenterBoxAlign ? 'items-center' : ''}
55
+ rounded w-4 h-4 flex justify-center m-px
56
+ `
51
57
 
52
58
  const checkboxLabelClasses = `ml-1 input-label text-f6 tracking-4 leading-6 ${
53
59
  disabled ? 'text-inverted-2' : ''
@@ -56,7 +62,7 @@ const CheckboxComponent = (
56
62
  return (
57
63
  <label
58
64
  htmlFor={inputId}
59
- className="inline-flex items-center cursor-pointer"
65
+ className={`inline-flex items-${boxAlign} cursor-pointer`}
60
66
  >
61
67
  <span className="rounded z-50 flex items-center justify-center focus-within:ring-2 ring-focus">
62
68
  <input
@@ -110,4 +116,5 @@ export interface CheckboxProps
110
116
  extends React.InputHTMLAttributes<HTMLInputElement> {
111
117
  label?: string | React.ReactNode
112
118
  indeterminate?: boolean
119
+ boxAlign?: 'center' | 'baseline'
113
120
  }
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+
3
+ export const Image = () => (
4
+ <path
5
+ fillRule="evenodd"
6
+ d="M10.5 5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Zm5.5 7.5H2a.5.5 0 0 1-.5-.5v-.937L5.176 8.39a2.247 2.247 0 0 1 2.647 0l2.188 1.59a3.759 3.759 0 0 0 4.027.246L16.5 8.857V12a.5.5 0 0 1-.5.5ZM2 1.5h14a.5.5 0 0 1 .5.5v5.261a.704.704 0 0 0-.364.084l-2.827 1.57a2.258 2.258 0 0 1-2.416-.147L8.706 7.177a3.743 3.743 0 0 0-4.412 0L1.5 9.209V2a.5.5 0 0 1 .5-.5ZM16 0H2a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Z"
7
+ clipRule="evenodd"
8
+ />
9
+ )
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+
3
+ export const Move = () => (
4
+ <path
5
+ fillRule="evenodd"
6
+ d="M9.5 14c0-.828-.672-1.5-1.5-1.5s-1.5.672-1.5 1.5.672 1.5 1.5 1.5 1.5-.672 1.5-1.5zm-6 0c0-.828-.671-1.5-1.5-1.5S.5 13.172.5 14s.671 1.5 1.5 1.5 1.5-.672 1.5-1.5zm6-12C9.5 1.172 8.828.5 8 .5S6.5 1.172 6.5 2 7.172 3.5 8 3.5 9.5 2.828 9.5 2zm-6 0C3.5 1.172 2.829.5 2 .5S.5 1.172.5 2 1.171 3.5 2 3.5 3.5 2.828 3.5 2zm6 6c0-.828-.672-1.5-1.5-1.5S6.5 7.172 6.5 8 7.172 9.5 8 9.5 9.5 8.828 9.5 8zM2 9.5C1.171 9.5.5 8.828.5 8S1.171 6.5 2 6.5s1.5.672 1.5 1.5S2.829 9.5 2 9.5z"
7
+ clipRule="evenodd"
8
+ />
9
+ )
@@ -23,6 +23,8 @@ import { Eye } from './Eye'
23
23
  import { ExclamationTriangle } from './ExclamationTriangle'
24
24
  import { ExternalLink } from './ExternalLink'
25
25
  import { Home } from './Home'
26
+ import { Image } from './Image'
27
+ import { Move } from './Move'
26
28
  import { Order } from './Order'
27
29
  import { Pagali } from './Pagali'
28
30
  import { PaperList } from './PaperList'
@@ -74,6 +76,8 @@ export const icons = {
74
76
  exclamationTriangle: ExclamationTriangle,
75
77
  externalLink: ExternalLink,
76
78
  home: Home,
79
+ image: Image,
80
+ move: Move,
77
81
  order: Order,
78
82
  pagali: Pagali,
79
83
  paperList: PaperList,
@@ -6,10 +6,10 @@ import { Button } from '../../Components/Button'
6
6
 
7
7
  export default {
8
8
  component: ActionBar,
9
- title: 'Layout/ActionBar'
9
+ title: 'Layout/ActionBar',
10
10
  } as Meta
11
11
 
12
- const Template: Story<ActionBarProps> = args => <ActionBar {...args} />
12
+ const Template: Story<ActionBarProps> = (args) => <ActionBar {...args} />
13
13
 
14
14
  export const Default = Template.bind({})
15
15
  Default.args = {
@@ -20,8 +20,8 @@ Default.args = {
20
20
  <Button variant="primary" icon="checkCircle" onClick={() => {}}>
21
21
  <span className="hidden lg:block">Criar novo registro</span>
22
22
  <span className="block lg:hidden">Criar</span>
23
- </Button>
24
- ]
23
+ </Button>,
24
+ ],
25
25
  }
26
26
 
27
27
  export const OnlyMobile = Template.bind({})
@@ -34,8 +34,9 @@ OnlyMobile.args = {
34
34
  <Button icon="checkCircle" onClick={() => {}}>
35
35
  Ativar
36
36
  </Button>,
37
+ <></>,
37
38
  <Button icon="ban" onClick={() => {}}>
38
39
  Inativar
39
- </Button>
40
- ]
41
- }
40
+ </Button>,
41
+ ],
42
+ }
@@ -50,22 +50,25 @@ const ActionBarComponent = ({ onlyMobile, children }: ActionBarProps) => {
50
50
  </div>
51
51
  )}
52
52
  <div className="lg:hidden">
53
- {React.Children.map(children, ({ props }) => (
54
- <button
55
- className={
56
- 'px-4 py-1 text-base-1' +
57
- (props?.loading ? ' pointer-events-none' : '')
58
- }
59
- onClick={props?.onClick}
60
- >
61
- {props?.loading ? (
62
- <Icon icon="loading" className="p-px" />
63
- ) : (
64
- props?.icon && <Icon icon={props?.icon} className="p-px" />
65
- )}
66
- <span className="block text-f8">{props.children}</span>
67
- </button>
68
- ))}
53
+ {React.Children.map(children, ({ props }) => {
54
+ if (!props.children) return
55
+ return (
56
+ <button
57
+ className={
58
+ 'px-4 py-1 text-base-1' +
59
+ (props?.loading ? ' pointer-events-none' : '')
60
+ }
61
+ onClick={props?.onClick}
62
+ >
63
+ {props?.loading ? (
64
+ <Icon icon="loading" className="p-px" />
65
+ ) : (
66
+ props?.icon && <Icon icon={props?.icon} className="p-px" />
67
+ )}
68
+ <span className="block text-f8">{props.children}</span>
69
+ </button>
70
+ )
71
+ })}
69
72
  </div>
70
73
  </div>
71
74
  </div>
@@ -22,6 +22,7 @@ const PaginationInfoComponent = ({
22
22
  <div className="flex items-center mr-5 text-inverted-2 tracking-4 text-f6">
23
23
  {itemsLengthOptions ? (
24
24
  <Select
25
+ id="selectItemsPerPage"
25
26
  options={itemsLengthOptions}
26
27
  withoutStyle
27
28
  aria-label="Itens por página"
@@ -48,6 +48,7 @@ const PaginationNavComponent = ({
48
48
  <div className="pagination-nav flex items-center justify-between w-full sm:w-auto">
49
49
  <div className="text-inverted-2 text-f6 tracking-4">
50
50
  <span
51
+ id="btnPaginationActualPage"
51
52
  className="pagination-nav-current text-primary font-semibold"
52
53
  ref={inputEl}
53
54
  contentEditable={true}
@@ -61,6 +62,7 @@ const PaginationNavComponent = ({
61
62
  </span>{' '}
62
63
  /{' '}
63
64
  <button
65
+ id="btnPaginationLastPage"
64
66
  className="pagination-nav-total focus:outline-none"
65
67
  onClick={() => {
66
68
  if (currentPage !== maxTotalPages) handleChange(maxTotalPages)
@@ -71,7 +73,8 @@ const PaginationNavComponent = ({
71
73
  </div>
72
74
  <div className="text-inverted-2 ml-5 flex items-center">
73
75
  <button
74
- className={`pagination-nav-previous mr-3 duration-200 focus:outline-none ${
76
+ id="btnPaginationPrev"
77
+ className={`pagination-nav-previous mr-3 duration-200 outline-none ${
75
78
  hasPrev ? 'hover:text-inverted-1' : ''
76
79
  }`}
77
80
  aria-label="Ir para página anterior"
@@ -82,7 +85,8 @@ const PaginationNavComponent = ({
82
85
  <Icon icon="arrowLeft" block size={4} />
83
86
  </button>
84
87
  <button
85
- className={`pagination-nav-next duration-200 focus:outline-none ${
88
+ id="btnPaginationNext"
89
+ className={`pagination-nav-next duration-200 outline-none ${
86
90
  hasNext ? 'hover:text-inverted-1' : ''
87
91
  }`}
88
92
  aria-label="Ir para próxima página"