@loja-integrada/admin-components 0.20.0 → 0.21.1

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.20.0",
3
+ "version": "0.21.1",
4
4
  "author": "Loja Integrada Front-End Team",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -134,7 +134,7 @@
134
134
  "tailwindcss": ">=3.1.0"
135
135
  },
136
136
  "dependencies": {
137
- "@loja-integrada/tailwindcss-config": "^2.0.3",
137
+ "@loja-integrada/tailwindcss-config": "^2.4.0",
138
138
  "@tippyjs/react": "^4.2.5",
139
139
  "@types/react-select": "^4.0.17",
140
140
  "babel-jest": "^29.2.2",
@@ -27,12 +27,12 @@ const commonFocus =
27
27
 
28
28
  const listOfStyles = {
29
29
  primary: `bg-primary text-base-1 ${listOfStylesHover['primary']} ${listOfStylesActive['primary']} ${commonFocus}`,
30
- secondary: `bg-primary-light text-primary-bold ${listOfStylesHover['secondary']} ${listOfStylesActive['secondary']} ${commonFocus}`,
30
+ secondary: `bg-primary-light text-primary-bold komea:bg-secondary komea:text-secondary-bold komea:hover:bg-secondary/80 komea:active:bg-secondary/60 komea:active:shadow-none ${listOfStylesHover['secondary']} ${listOfStylesActive['secondary']} ${commonFocus}`,
31
31
  outlineSecondary: `bg-transparent text-primary border border-primary ${listOfStylesHover['outlineSecondary']} ${listOfStylesActive['outlineSecondary']} ${commonFocus}`,
32
32
  tertiary: `bg-inverted-2 text-on-primary ${listOfStylesHover['tertiary']} ${listOfStylesActive['tertiary']} ${commonFocus}`,
33
33
  warning: `bg-warning text-on-base ${listOfStylesHover['warning']} ${listOfStylesActive['warning']} ${commonFocus}`,
34
34
  danger: `bg-danger text-base-1 ${listOfStylesHover['danger']} ${listOfStylesActive['danger']} ${commonFocus}`,
35
- outline: `bg-transparent text-inverted-2 border border-inverted-2 ${listOfStylesHover['outline']} ${listOfStylesActive['outline']} ${commonFocus}`,
35
+ outline: `bg-transparent text-inverted-2 border border-inverted-2 komea:border-card-stroke komea:bg-base-2 komea:text-on-base komea:hover:bg-primary-light komea:active:bg-secondary komea:active:shadow-none ${listOfStylesHover['outline']} ${listOfStylesActive['outline']} ${commonFocus}`,
36
36
  onlyText: `bg-transparent border-transparent text-inverted-2 px-0 ${listOfStylesHover['onlyText']} ${listOfStylesActive['onlyText']} ${commonFocus}`,
37
37
  }
38
38
 
@@ -48,10 +48,16 @@ const listOfStylesDisabled = {
48
48
  onlyText: `bg-transparent text-on-base-3 shadow-none ring-0 border-0 `,
49
49
  }
50
50
 
51
+ const listOfSizePaddings = {
52
+ small: `komea:px-3`,
53
+ default: ``,
54
+ large: `komea:px-6`,
55
+ }
56
+
51
57
  const listOfSizes = {
52
- small: `text-f6 h-10`,
53
- default: `text-f6 h-12`,
54
- large: `text-f5 h-14`,
58
+ small: `text-f6 komea:h-8 h-10`,
59
+ default: `text-f6 komea:h-9 h-12`,
60
+ large: `text-f5 komea:h-10 h-14`,
55
61
  }
56
62
 
57
63
  const ButtonType = React.forwardRef(
@@ -97,7 +103,13 @@ const ButtonComponent = (
97
103
  ;(!disabled || !loading) && onClick && onClick(event)
98
104
  }
99
105
 
100
- let classes = `inline-flex font-medium items-center justify-center px-5 text-center no-underline cursor-pointer transition rounded-md after:align-middle focus:outline-none `
106
+ // `onlyText` é o único que não tem caixa, e o padding horizontal fica fora dele. Não dá para
107
+ // apenas parear com `komea:px-0`: as duas classes empatam em especificidade e o Tailwind emite
108
+ // `px-0` antes de `px-3`/`px-4`/`px-6`, então o zero perderia pela ordem.
109
+ const horizontalPadding =
110
+ variant === 'onlyText' ? '' : `px-5 komea:px-4 ${listOfSizePaddings[size]}`
111
+
112
+ let classes = `inline-flex font-medium items-center justify-center ${horizontalPadding} text-center no-underline cursor-pointer transition rounded-md after:align-middle focus:outline-none `
101
113
 
102
114
  if (loading) {
103
115
  classes +=
@@ -57,7 +57,7 @@ const ModalComponent = ({
57
57
  <div {...props}>
58
58
  <div className="ReactModal__header w-full flex justify-between items-start">
59
59
  <span
60
- className={`min-w-0 text-inverted-2 text-xs font-semibold uppercase break-words ${
60
+ className={`min-w-0 text-inverted-2 text-xs font-semibold uppercase komea:font-medium komea:normal-case break-words ${
61
61
  headerTitle ? 'pb-3' : ''
62
62
  }`}
63
63
  >
@@ -150,7 +150,7 @@ const TableComponent = ({
150
150
  <table
151
151
  {...getTableProps()}
152
152
  id={id}
153
- className={`w-full bg-base-1 rounded border-separate border border-card-stroke`}
153
+ className={`w-full bg-base-1 rounded komea:rounded-xs border-separate border border-card-stroke`}
154
154
  cellSpacing="0"
155
155
  >
156
156
  <thead className={`text-left`}>
@@ -49,12 +49,12 @@ const CheckboxComponent = (
49
49
  isChecked || isIndeterminate ? 'scale-100' : 'scale-0'
50
50
  }`
51
51
 
52
- const checkboxIconContainerClasses = `border border-card-stroke transition duration-200 ease-in-out
52
+ const checkboxIconContainerClasses = `border border-card-stroke komea:border-input-stroke komea:shadow-sm transition duration-200 ease-in-out
53
53
  ${
54
54
  disabled
55
55
  ? 'bg-base-4'
56
56
  : isChecked || isIndeterminate
57
- ? 'bg-primary border-primary'
57
+ ? 'bg-primary border-primary komea:border-primary'
58
58
  : 'bg-base-1'
59
59
  }
60
60
  ${isCenterBoxAlign ? 'items-center' : ''}
@@ -87,7 +87,7 @@ const CheckboxComponent = (
87
87
  htmlFor={inputId}
88
88
  className={`inline-flex ${alignOptions[boxAlign]} cursor-pointer`}
89
89
  >
90
- <span className="relative rounded-xs z-10 flex items-center justify-center focus-within:ring-2 ring-focus">
90
+ <span className="relative rounded-xs z-10 flex items-center justify-center focus-within:ring-2 komea:focus-within:ring-[3px] ring-focus komea:ring-focus/50">
91
91
  <input
92
92
  ref={ref || inputRef}
93
93
  type="checkbox"
@@ -13,9 +13,9 @@ import { InputHelpText } from '../InputHelpText'
13
13
  import { InputLabel, InputLabelProps } from '../InputLabel'
14
14
 
15
15
  export const sizeClasses = {
16
- default: 'h-12',
16
+ default: 'komea:h-9 h-12',
17
17
  small: 'h-8',
18
- large: 'h-14',
18
+ large: 'komea:h-10 h-14',
19
19
  xlarge: 'h-24',
20
20
  }
21
21
 
@@ -27,7 +27,8 @@ export const valueFontSizesClasses = {
27
27
  }
28
28
 
29
29
  export const variantControlClasses = {
30
- default: 'border-card-stroke rounded pl-2',
30
+ default:
31
+ 'border-card-stroke rounded pl-2 komea:border-input-stroke komea:shadow-sm',
31
32
  secondary:
32
33
  'border-inverted-2 hover:bg-base-3 rounded-md focus:ring-2 focus:ring-focus focus:ring-offset-2 focus:bg-base-1 pl-2',
33
34
  simple: 'border-0 border-b border-on-base-3',
@@ -9,7 +9,9 @@ import {
9
9
  defaultBorderClasses,
10
10
  inputContainerClasses,
11
11
  variantClasses,
12
+ prefixBorderlessKomeaClasses,
12
13
  prefixClasses,
14
+ sufixBorderlessKomeaClasses,
13
15
  sufixClasses,
14
16
  focusClass,
15
17
  } from '../commonStyles'
@@ -42,11 +44,11 @@ const InputComponent = (
42
44
 
43
45
  const prefixClass = `${prefixClasses} ${variantClasses[variant]} ${
44
46
  hasErrorState ? errorBorderClasses : ''
45
- }`
47
+ } ${prefixBorder ? '' : prefixBorderlessKomeaClasses}`
46
48
 
47
49
  const sufixClass = `${sufixClasses} ${variantClasses[variant]} ${
48
50
  hasErrorState ? errorBorderClasses : ''
49
- }`
51
+ } ${sufixBorder ? '' : sufixBorderlessKomeaClasses}`
50
52
 
51
53
  let inputContainerClass = `${inputContainerClasses} ${variantClasses[variant]}`
52
54
  if (disabled) {
@@ -59,12 +61,12 @@ const InputComponent = (
59
61
  inputContainerClass += ` ${defaultBorderClasses}`
60
62
  }
61
63
 
62
- const inputClass = `w-full px-4 appearance-none shadow-none outline-none bg-transparent box-border ${focusClass} ${
64
+ const inputClass = `w-full px-4 komea:px-3 appearance-none shadow-none outline-none bg-transparent box-border ${focusClass} ${
63
65
  hasErrorState ? errorBorderClasses : defaultBorderClasses
64
66
  } ${prefix && prefixBorder ? 'border-l' : ''} ${
65
67
  sufix && sufixBorder ? 'border-r' : ''
66
- } ${prefix && !prefixBorder ? 'pl-0' : ''} ${
67
- sufix && !sufixBorder ? 'pr-0' : ''
68
+ } ${prefix && !prefixBorder ? 'pl-0 komea:pl-2' : ''} ${
69
+ sufix && !sufixBorder ? 'pr-0 komea:pr-2' : ''
68
70
  }`
69
71
 
70
72
  const LabelComponent = (
@@ -51,7 +51,7 @@ const ToggleComponent = (
51
51
 
52
52
  const toggleCircleClasses = `transform ${toggleClasses.circle[toggleCheckText][toggleStatusText]} absolute left-[6px] top-[6px] w-5 h-5 rounded-full transition`
53
53
 
54
- const toggleLabelClasses = `ml-2 text-inverted-1 text-f6 label`
54
+ const toggleLabelClasses = `ml-2 text-inverted-1 text-f6 komea:font-medium label`
55
55
 
56
56
  return (
57
57
  <label
@@ -1,29 +1,51 @@
1
1
  export const inputPlaceholderClasses = 'placeholder-on-base-2'
2
2
 
3
3
  export const inputContainerDisabledClasses =
4
- '!bg-base-3 !pointer-events-none !text-on-base-2'
4
+ '!bg-base-3 !pointer-events-none !text-on-base-2 komea:!bg-base-1 komea:!text-on-base komea:opacity-50'
5
5
 
6
6
  export const inputContainerReadonlyClasses = '!bg-base-2'
7
7
 
8
- export const errorBorderClasses = 'border-danger focus:border-danger'
8
+ export const errorBorderClasses =
9
+ 'border-danger focus:border-danger komea:focus-within:border-danger komea:focus-within:ring-danger/20'
9
10
 
10
- export const defaultBorderClasses = 'border-card-stroke'
11
+ export const defaultBorderClasses =
12
+ 'border-card-stroke komea:border-input-stroke komea:focus-within:border-focus komea:focus-within:ring-focus/50'
11
13
 
12
14
  export const focusClass = 'focus:border-inverted-1'
13
15
 
14
- export const inputClasses = `appearance-none shadow-none outline-none bg-base-1 border px-4 rounded text-on-base text-sm min-w-0 w-full transition-border duration-75 ${focusClass} ${inputPlaceholderClasses}`
16
+ export const inputClasses = `appearance-none shadow-none outline-none bg-base-1 border px-4 rounded text-on-base text-sm min-w-0 w-full transition-border duration-75 komea:px-3 komea:shadow-sm komea:text-body-large md:komea:text-body komea:focus-within:ring-[3px] ${focusClass} ${inputPlaceholderClasses}`
15
17
 
16
- export const inputContainerClasses = `flex focus-within:border-inverted-1 bg-base-1 border rounded text-on-base text-sm min-w-0 w-full transition-border duration-75 overflow-hidden ${inputPlaceholderClasses}`
18
+ export const inputContainerClasses = `flex focus-within:border-inverted-1 bg-base-1 border rounded text-on-base text-sm min-w-0 w-full transition-border duration-75 overflow-hidden komea:shadow-sm komea:text-body-large md:komea:text-body komea:focus-within:ring-[3px] ${inputPlaceholderClasses}`
17
19
 
18
20
  const adornmentClasses = `adornment flex justify-center items-center relative w-16 text-f6 text-inverted-2 -mt-px`
19
21
 
22
+ // Sem borda o adorno não é uma caixa, é o addon do komea-ds: 12px de recuo, ícone de 16px e 8px até
23
+ // o valor.
24
+ //
25
+ // O ícone é normalizado porque o default do nosso `Icon` é 5 (20px) e o DS usa 16 nos campos — é o
26
+ // que torna a geometria determinística em vez de depender do `size` que a app passou. Descendente e
27
+ // não filho direto (`[&_svg]`, não `[&>svg]`) porque a app pode embrulhar o ícone: o campo de busca
28
+ // põe um `<button>` no meio. E `h-4 w-4` em vez de `size-4`, porque `size-*` só existe do Tailwind
29
+ // 3.4 em diante e há app desta linha pinada em 3.3.0, onde a classe não seria gerada.
30
+ //
31
+ // Os 8px até o valor saem do padding do **campo**, não do adorno: um filho `w-full` — o botão do
32
+ // campo de busca — ocuparia a caixa de conteúdo inteira e comeria um padding posto aqui.
33
+ //
34
+ // `shrink-0` porque o adorno é item flex: sem ele o `w-7` é só uma base e o navegador comprime a
35
+ // caixa quando o campo é estreito, levando a geometria junto.
36
+ const borderlessKomeaIcon = 'komea:[&_svg]:h-4 komea:[&_svg]:w-4'
37
+
38
+ export const prefixBorderlessKomeaClasses = `komea:w-7 komea:shrink-0 komea:justify-start komea:pl-3 ${borderlessKomeaIcon}`
39
+
40
+ export const sufixBorderlessKomeaClasses = `komea:w-7 komea:shrink-0 komea:justify-end komea:pr-3 ${borderlessKomeaIcon}`
41
+
20
42
  export const prefixClasses = `${adornmentClasses} rounded-l left-0`
21
43
 
22
44
  export const sufixClasses = `${adornmentClasses} rounded-r right-0`
23
45
 
24
46
  export const variantClasses = {
25
- default: 'h-12',
26
- small: 'h-10',
27
- large: 'h-14',
47
+ default: 'komea:h-9 h-12',
48
+ small: 'komea:h-8 h-10',
49
+ large: 'komea:h-10 h-14',
28
50
  xlarge: 'h-24',
29
51
  }
@@ -36,7 +36,7 @@ describe(specTitle('Alert tests'), () => {
36
36
  cy.get('.alert').should('have.class', 'bg-danger-light')
37
37
 
38
38
  mount(<Default type="info" />)
39
- cy.get('.alert').should('have.class', 'bg-focus-light')
39
+ cy.get('.alert').should('have.class', 'bg-info-light')
40
40
 
41
41
  mount(<Default type="primary" />)
42
42
  cy.get('.alert').should('have.class', 'bg-primary-light')
@@ -16,42 +16,51 @@ const alertTypes: Record<
16
16
  class: string
17
17
  icon: IconProps['icon']
18
18
  iconClass: string
19
+ textClass: string
19
20
  }
20
21
  > = {
21
22
  success: {
22
- class: 'bg-success-light border-success',
23
+ class: 'bg-success-light border-success komea:border-success-stroke',
23
24
  icon: 'checkCircle',
24
- iconClass: 'text-success',
25
+ iconClass: 'text-success komea:text-success-dark',
26
+ textClass: 'komea:text-success-dark',
25
27
  },
26
28
  warning: {
27
- class: 'bg-warning-light border-warning-dark',
29
+ class: 'bg-warning-light border-warning-dark komea:border-warning-stroke',
28
30
  icon: 'exclamationTriangle',
29
31
  iconClass: 'text-warning-dark',
32
+ textClass: 'komea:text-warning-dark',
30
33
  },
31
34
  danger: {
32
- class: 'bg-danger-light border-danger',
35
+ class: 'bg-danger-light border-danger komea:border-danger-stroke',
33
36
  icon: 'ban',
34
- iconClass: 'text-danger',
37
+ iconClass: 'text-danger komea:text-danger-dark',
38
+ textClass: 'komea:text-danger-dark',
35
39
  },
36
40
  info: {
37
- class: 'bg-focus-light border-focus-dark',
41
+ class: 'bg-info-light border-info-dark komea:border-info-stroke',
38
42
  icon: 'infoCircle',
39
- iconClass: 'text-focus-dark',
43
+ iconClass: 'text-info-dark',
44
+ textClass: 'komea:text-info-dark',
40
45
  },
41
46
  infoOutline: {
42
- class: 'bg-base-1 border-focus-dark',
47
+ class: 'bg-base-1 border-info-dark komea:border-info-stroke',
43
48
  icon: 'infoCircle',
44
- iconClass: 'text-focus-dark',
49
+ iconClass: 'text-info-dark',
50
+ textClass: '',
45
51
  },
46
52
  infoDark: {
47
- class: 'bg-base-1 border-[#607081]',
53
+ // O hex cravado não acompanha o `data-chrome`; na chrome nova cai no neutro do design system.
54
+ class: 'bg-base-1 border-[#607081] komea:border-card-stroke',
48
55
  icon: 'infoCircle',
49
- iconClass: 'text-[#607081]',
56
+ iconClass: 'text-[#607081] komea:text-on-base-2',
57
+ textClass: '',
50
58
  },
51
59
  primary: {
52
- class: 'bg-primary-light border-primary',
60
+ class: 'bg-primary-light border-primary komea:border-card-stroke',
53
61
  icon: 'infoCircle',
54
62
  iconClass: 'text-primary',
63
+ textClass: '',
55
64
  },
56
65
  }
57
66
 
@@ -80,7 +89,7 @@ const AlertComponent = ({
80
89
  if (!alertIsOpen) return null
81
90
  return (
82
91
  <div
83
- className={`alert border-l-4 py-4 pl-6 pr-5 rounded w-full relative flex items-start sm:items-center ${
92
+ className={`alert border-l-4 komea:border-l py-4 pl-6 pr-5 rounded w-full relative flex items-start sm:items-center ${
84
93
  alertTypes[type].class
85
94
  }${hideBorder ? '' : ' border'}`}
86
95
  >
@@ -95,9 +104,17 @@ const AlertComponent = ({
95
104
  </div>
96
105
  )}
97
106
  <div className="flex-grow flex flex-col sm:flex-row items-start sm:items-center justify-between min-w-0">
98
- <div className="flex flex-col justify-center min-w-0 break-words text-f6 text-on-base">
99
- <span className="alert-title font-semibold">{title}</span>
100
- {subtitle && <span className="alert-subtitle mt-1">{subtitle}</span>}
107
+ <div
108
+ className={`flex flex-col justify-center min-w-0 break-words text-f6 text-on-base ${alertTypes[type].textClass}`}
109
+ >
110
+ <span className="alert-title font-semibold komea:font-medium">
111
+ {title}
112
+ </span>
113
+ {subtitle && (
114
+ <span className="alert-subtitle komea:text-caption mt-1">
115
+ {subtitle}
116
+ </span>
117
+ )}
101
118
  </div>
102
119
  {actions && (
103
120
  <div className="alert-actions flex flex-shrink-0 items-center flex-row sm:flex-row-reverse sm:space-x-reverse space-x-3 mt-3 sm:mt-0 sm:ml-5">
@@ -69,6 +69,6 @@ describe(specTitle('Badge tests'), () => {
69
69
  cy.get(badgeClass).should('have.class', 'bg-danger-dark text-base-1')
70
70
 
71
71
  mount(<Default type="focus" />)
72
- cy.get(badgeClass).should('have.class', 'bg-focus text-base-1')
72
+ cy.get(badgeClass).should('have.class', 'bg-info text-base-1')
73
73
  })
74
74
  })
@@ -8,7 +8,7 @@ const badgeTypes = {
8
8
  danger: 'bg-danger-dark text-base-1',
9
9
  success: 'bg-success-dark text-base-1',
10
10
  warning: 'bg-warning-dark text-base-1',
11
- focus: 'bg-focus text-base-1',
11
+ focus: 'bg-info text-base-1',
12
12
  }
13
13
 
14
14
  const badgeRounded = {
@@ -29,9 +29,9 @@ describe(specTitle('InformationBox tests'), () => {
29
29
  cy.get('.InformationBox').should('have.class', 'bg-danger-light')
30
30
 
31
31
  mount(<Default type="info" />)
32
- cy.get('.InformationBox-title').should('have.class', 'text-focus-dark')
32
+ cy.get('.InformationBox-title').should('have.class', 'text-info-dark')
33
33
  cy.get('.InformationBox-icon').should('have.class', 'icon-lightbulb')
34
- cy.get('.InformationBox').should('have.class', 'bg-focus-light')
34
+ cy.get('.InformationBox').should('have.class', 'bg-info-light')
35
35
  })
36
36
 
37
37
  it('Close button', () => {
@@ -36,10 +36,10 @@ const InformationBoxTypes: Record<
36
36
  },
37
37
  info: {
38
38
  title: 'Informação',
39
- titleClass: 'text-focus-dark',
40
- class: 'bg-focus-light border-focus-dark',
39
+ titleClass: 'text-info-dark',
40
+ class: 'bg-info-light border-info-dark komea:border-info-stroke',
41
41
  icon: 'lightbulb',
42
- iconClass: 'text-focus-dark',
42
+ iconClass: 'text-info-dark',
43
43
  },
44
44
  }
45
45
 
@@ -34,7 +34,7 @@ const Container = () => {
34
34
  return (
35
35
  <ToastContainer
36
36
  toastClassName={(props) =>
37
- `mb-3 border flex items-top justify-between p-3 pb-4 pr-4 relative rounded shadow-md ${
37
+ `mb-3 border flex items-top justify-between p-3 pb-4 pr-4 relative rounded shadow-md overflow-hidden ${
38
38
  contextClass[props?.type || 'info']
39
39
  }`
40
40
  }
package/src/tailwind.scss CHANGED
@@ -2,7 +2,7 @@
2
2
  @tailwind components;
3
3
  @tailwind utilities;
4
4
 
5
- @import '@loja-integrada/tailwindcss-config/styles/_variables.scss';
5
+ @import '@loja-integrada/tailwindcss-config/styles/variables';
6
6
 
7
7
  body {
8
8
  @apply antialiased;