@loja-integrada/admin-components 0.9.2 → 0.9.6

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.2",
3
+ "version": "0.9.6",
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>
@@ -12,7 +12,8 @@ export default {
12
12
  layout: 'padded',
13
13
  design: {
14
14
  type: 'figma',
15
- url: 'https://www.figma.com/file/Z2WDD4SH8zwaJC2K5wbtMO/Sistema-Integrado?node-id=95%3A7532',
15
+ url:
16
+ 'https://www.figma.com/file/Z2WDD4SH8zwaJC2K5wbtMO/Sistema-Integrado?node-id=95%3A7532',
16
17
  },
17
18
  },
18
19
  args: {
@@ -37,10 +38,25 @@ export default {
37
38
  id: 'vendas',
38
39
  title: 'Vendas',
39
40
  },
40
- ]
41
+ ],
41
42
  },
42
43
  } as Meta
43
44
 
44
- const Template: Story<TabsProps> = args => <Tabs {...args} />
45
+ const Template: Story<TabsProps> = (args) => <Tabs {...args} />
45
46
 
46
47
  export const Default = Template.bind({})
48
+
49
+ export const WithTabDisabled = Template.bind({})
50
+ WithTabDisabled.args = {
51
+ items: [
52
+ {
53
+ id: 'pedidos',
54
+ title: 'Pedidos',
55
+ },
56
+ {
57
+ id: 'cupons',
58
+ title: 'Cupons de desconto',
59
+ disabled: true,
60
+ },
61
+ ],
62
+ }
@@ -7,6 +7,10 @@ export interface TabsItemInterface {
7
7
  * Item visible title
8
8
  */
9
9
  title: string
10
+ /**
11
+ * Disabled a specific tab
12
+ */
13
+ disabled?: boolean
10
14
  /**
11
15
  * Item content
12
16
  * @deprecated Not implemented
@@ -6,7 +6,7 @@ const activeStyles = (active: boolean) =>
6
6
  active ? `border-primary font-semibold` : `border-transparent`
7
7
  // When using bold at hover, prevent text shift
8
8
  const boldFixStyle = `before:content-[attr(data-title)] before:block before:font-semibold before:h-0 before:overflow-hidden before:visibility-hidden`
9
-
9
+ const disabledStyle = 'text-inverted-2 cursor-not-allowed'
10
10
  interface TabsItemProps extends TabsItemInterface {
11
11
  /**
12
12
  * Item is active
@@ -22,19 +22,24 @@ export const TabsItem = ({
22
22
  id,
23
23
  title,
24
24
  active = false,
25
+ disabled = false,
25
26
  onChange,
26
27
  }: TabsItemProps) => {
27
28
  return (
28
29
  <button
30
+ id={`btnTab${id}`}
29
31
  className={`tabs-item ${
30
32
  active ? 'tabs-item-active' : ''
31
- } group min-w-0 flex-shrink-0 overflow-x-hidden px-2 last:-mr-2 first:-ml-2`}
33
+ } group min-w-0 flex-shrink-0 overflow-x-hidden px-2 last:-mr-2 first:-ml-2 ${
34
+ disabled ? disabledStyle : ''
35
+ }`}
32
36
  onClick={() => onChange(id)}
37
+ disabled={disabled}
33
38
  >
34
39
  <span
35
- className={`block text-f6 text-sm py-4 border-b-4 break-words group-hover:font-semibold ${activeStyles(
36
- active
37
- )} ${boldFixStyle}`}
40
+ className={`block tracking-4 text-f6 text-sm py-4 border-b-4 break-words ${
41
+ disabled ? '' : 'group-hover:font-semibold'
42
+ } ${activeStyles(active)} ${boldFixStyle}`}
38
43
  data-title={title}
39
44
  >
40
45
  {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
  }
@@ -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"