@loja-integrada/admin-components 0.12.3 → 0.12.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.
Files changed (54) hide show
  1. package/dist/Components/Button/Button.stories.d.ts +8 -9
  2. package/dist/Components/LoadingPlaceholder/LoadingPlaceholder.stories.d.ts +2 -3
  3. package/dist/Components/Modal/Modal.stories.d.ts +5 -6
  4. package/dist/Components/Table/Table.stories.d.ts +6 -7
  5. package/dist/Components/Tabs/Tabs.stories.d.ts +3 -4
  6. package/dist/Components/Timeline/Timeline.d.ts +5 -1
  7. package/dist/Components/Timeline/Timeline.stories.d.ts +5 -5
  8. package/dist/Components/Timeline/TimelineItem.interface.d.ts +4 -0
  9. package/dist/Forms/Checkbox/Checkbox.stories.d.ts +8 -9
  10. package/dist/Forms/Dropdown/Dropdown.stories.d.ts +17 -18
  11. package/dist/Forms/Input/Input.stories.d.ts +19 -19
  12. package/dist/Forms/InputCurrency/InputCurrency.stories.d.ts +6 -7
  13. package/dist/Forms/InputHelpText/InputHelpText.stories.d.ts +2 -3
  14. package/dist/Forms/InputLabel/InputLabel.stories.d.ts +3 -4
  15. package/dist/Forms/InputMask/InputMask.stories.d.ts +8 -9
  16. package/dist/Forms/Select/Select.stories.d.ts +6 -7
  17. package/dist/Forms/Toggle/Toggle.stories.d.ts +6 -7
  18. package/dist/Icons/Icon.stories.d.ts +1 -2
  19. package/dist/Indicators/Alert/Alert.stories.d.ts +3 -4
  20. package/dist/Indicators/Badge/Badge.d.ts +5 -1
  21. package/dist/Indicators/Badge/Badge.stories.d.ts +4 -4
  22. package/dist/Indicators/Status/Status.stories.d.ts +2 -3
  23. package/dist/Indicators/Toast/Toast.stories.d.ts +2 -3
  24. package/dist/Indicators/Tooltip/Tooltip.stories.d.ts +2 -3
  25. package/dist/Layout/ActionBar/ActionBar.stories.d.ts +3 -4
  26. package/dist/Layout/Box/Box.stories.d.ts +6 -7
  27. package/dist/Layout/Box/Components/Content/BoxContent.stories.d.ts +2 -3
  28. package/dist/Layout/Box/Components/Header/BoxHeader.stories.d.ts +2 -3
  29. package/dist/Layout/Box/Components/Separator/BoxSeparator.stories.d.ts +2 -3
  30. package/dist/Layout/Container/Container.stories.d.ts +3 -4
  31. package/dist/Layout/Sidebar/Sidebar.stories.d.ts +2 -2
  32. package/dist/Layout/Topbar/Topbar.stories.d.ts +2 -3
  33. package/dist/Navigation/Breadcrumb/Breadcrumb.stories.d.ts +5 -6
  34. package/dist/Navigation/Pagination/Pagination.stories.d.ts +4 -5
  35. package/dist/admin-components.cjs.development.js +24 -11
  36. package/dist/admin-components.cjs.development.js.map +1 -1
  37. package/dist/admin-components.cjs.production.min.js +1 -1
  38. package/dist/admin-components.cjs.production.min.js.map +1 -1
  39. package/dist/admin-components.esm.js +24 -11
  40. package/dist/admin-components.esm.js.map +1 -1
  41. package/package.json +8 -8
  42. package/src/Components/Table/Table.tsx +4 -11
  43. package/src/Components/Timeline/Timeline.spec.tsx +13 -1
  44. package/src/Components/Timeline/Timeline.stories.tsx +7 -1
  45. package/src/Components/Timeline/Timeline.tsx +9 -1
  46. package/src/Components/Timeline/TimelineItem.interface.ts +4 -0
  47. package/src/Components/Timeline/TimelineItem.tsx +9 -7
  48. package/src/Forms/Input/Input.stories.tsx +17 -2
  49. package/src/Forms/Input/Input.tsx +2 -2
  50. package/src/Forms/InputCurrency/InputCurrency.tsx +2 -3
  51. package/src/Indicators/Badge/Badge.spec.tsx +6 -1
  52. package/src/Indicators/Badge/Badge.stories.tsx +10 -1
  53. package/src/Indicators/Badge/Badge.tsx +8 -1
  54. package/src/Layout/ActionBar/ActionBar.tsx +2 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loja-integrada/admin-components",
3
- "version": "0.12.3",
3
+ "version": "0.12.6",
4
4
  "author": "Loja Integrada Front-End Team",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -69,15 +69,15 @@
69
69
  "@cypress/webpack-dev-server": "^1.3.1",
70
70
  "@fullhuman/postcss-purgecss": "^4.0.3",
71
71
  "@size-limit/preset-small-lib": "^4.10.1",
72
- "@storybook/addon-a11y": "^6.3.7",
73
- "@storybook/addon-essentials": "^6.3.7",
72
+ "@storybook/addon-a11y": "^6.4.19",
73
+ "@storybook/addon-essentials": "^6.4.19",
74
74
  "@storybook/addon-info": "^5.3.21",
75
- "@storybook/addon-links": "^6.3.7",
75
+ "@storybook/addon-links": "^6.4.19",
76
76
  "@storybook/addon-postcss": "^2.0.0",
77
- "@storybook/addons": "^6.3.7",
78
- "@storybook/react": "^6.3.7",
77
+ "@storybook/addons": "^6.4.19",
78
+ "@storybook/react": "^6.4.19",
79
79
  "@storybook/storybook-deployer": "^2.8.10",
80
- "@storybook/testing-react": "^0.0.21",
80
+ "@storybook/testing-react": "^1.2.3",
81
81
  "@testing-library/react": "^11.2.7",
82
82
  "@types/node": "^15.12.0",
83
83
  "@types/react": "^17.0.3",
@@ -100,7 +100,7 @@
100
100
  "react-is": "^17.0.1",
101
101
  "rollup-plugin-postcss": "^4.0.0",
102
102
  "size-limit": "^4.11.0",
103
- "storybook-addon-designs": "^6.0.1",
103
+ "storybook-addon-designs": "^6.2.1",
104
104
  "tailwindcss": "^2.2.4",
105
105
  "tsdx": "^0.14.1",
106
106
  "tslib": "^2.1.0",
@@ -65,13 +65,8 @@ const TableComponent = ({
65
65
  [columnsProps]
66
66
  )
67
67
 
68
- const {
69
- getTableProps,
70
- getTableBodyProps,
71
- headerGroups,
72
- rows,
73
- prepareRow,
74
- } = useTable({ columns, data: rowsPropsMemoized })
68
+ const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } =
69
+ useTable({ columns, data: rowsPropsMemoized })
75
70
 
76
71
  const handleSelect = React.useCallback(
77
72
  (newSelectedRows: number[]) => {
@@ -160,10 +155,8 @@ const TableComponent = ({
160
155
  >
161
156
  <thead className={`text-left`}>
162
157
  {headerGroups.map((headerGroup) => {
163
- const {
164
- key,
165
- ...restHeaderGroupProps
166
- } = headerGroup.getHeaderGroupProps()
158
+ const { key, ...restHeaderGroupProps } =
159
+ headerGroup.getHeaderGroupProps()
167
160
  return (
168
161
  <tr key={key} {...restHeaderGroupProps} className="bg-base-2">
169
162
  {selectable && (
@@ -3,7 +3,7 @@ import { composeStories } from "@storybook/testing-react"
3
3
  import { mount } from "@cypress/react"
4
4
  import * as stories from "./Timeline.stories"
5
5
 
6
- const { Default, Loading, Empty } = composeStories(stories)
6
+ const { Default, WithoutToggle, Loading, Empty } = composeStories(stories)
7
7
 
8
8
  describe('Timeline tests', () => {
9
9
 
@@ -20,6 +20,18 @@ describe('Timeline tests', () => {
20
20
  })
21
21
  })
22
22
 
23
+ it('Without Toggle', () => {
24
+ mount(<WithoutToggle />)
25
+ cy.get('.timeline .timeline-item')
26
+ .should('have.length', 4)
27
+ .first().within(() => {
28
+ cy.get('.timeline-title').contains('Venda criada')
29
+ cy.get('.timeline-timestamp').contains('11/11/2011')
30
+ cy.get('.timeline-description').should('be.visible')
31
+ cy.get('.timeline-title button').should('not.exist')
32
+ })
33
+ })
34
+
23
35
  it('Loading', () => {
24
36
  mount(<Loading />)
25
37
  cy.get('.timeline .timeline-item')
@@ -22,9 +22,10 @@ export default {
22
22
  title: 'Venda criada',
23
23
  },
24
24
  {
25
- title: 'Vendacriadadacriadadacriadadacriadadacriadadacriadadacriadadacriadadacriadadacriadadacriadadacriada',
25
+ title: 'Venda criada sem toggle',
26
26
  iconBackgroundColor: 'bg-danger',
27
27
  description: 'Status change: from Cancelling to Cancelled',
28
+ toggle: false,
28
29
  },
29
30
  {
30
31
  title: 'Venda criada',
@@ -39,6 +40,11 @@ const Template: Story<TimelineProps> = args => <Timeline {...args} />
39
40
 
40
41
  export const Default = Template.bind({})
41
42
 
43
+ export const WithoutToggle = Template.bind({})
44
+ WithoutToggle.args = {
45
+ toggleItems: false,
46
+ }
47
+
42
48
  export const Loading = Template.bind({})
43
49
  Loading.args = {
44
50
  isLoading: true,
@@ -8,6 +8,7 @@ const TimelineComponent = ({
8
8
  className = '',
9
9
  items,
10
10
  isLoading = false,
11
+ toggleItems = true,
11
12
  emptyTitle = 'Nenhum registro encontrado',
12
13
  }: TimelineProps) => {
13
14
  if (!isLoading && (!items || !Array.isArray(items))) return null
@@ -37,7 +38,10 @@ const TimelineComponent = ({
37
38
  />
38
39
  ) : (
39
40
  items?.map((item, index) => (
40
- <TimelineItem key={`timeline-item-${index}`} item={item} />
41
+ <TimelineItem
42
+ key={`timeline-item-${index}`}
43
+ item={{ ...item, toggle: item.toggle ?? toggleItems }}
44
+ />
41
45
  ))
42
46
  )}
43
47
  </ul>
@@ -64,4 +68,8 @@ export interface TimelineProps {
64
68
  * @default 'Nenhum registro encontrado'
65
69
  */
66
70
  emptyTitle?: string
71
+ /** Timeline item show toggle
72
+ * @default true
73
+ */
74
+ toggleItems?: boolean
67
75
  }
@@ -21,4 +21,8 @@ export interface TimelineItemInterface {
21
21
  * Background of the current icon (className)
22
22
  */
23
23
  iconBackgroundColor?: string
24
+ /**
25
+ * Toggle item description
26
+ */
27
+ toggle?: boolean
24
28
  }
@@ -4,9 +4,10 @@ import { Icon } from '../../Icons/Icon'
4
4
  import { TimelineItemInterface } from './TimelineItem.interface'
5
5
 
6
6
  export const TimelineItem = ({ item }: TimelineItemProps) => {
7
- const [isOpen, setIsOpen] = useState(false)
7
+ const [isOpen, setIsOpen] = useState(!item.toggle)
8
8
  const iconBackgroundColor = item.iconBackgroundColor || `bg-inverted-2`
9
9
  const icon = item.icon || 'minus'
10
+ const showToggle = item.toggle && item.description
10
11
 
11
12
  return (
12
13
  <li className={`timeline-item relative mb-10 last:mb-0`}>
@@ -17,12 +18,12 @@ export const TimelineItem = ({ item }: TimelineItemProps) => {
17
18
  </div>
18
19
  <div className="ml-7 pt-px">
19
20
  <div
20
- className={`timeline-title group mb-1 py-1 text-sm text-inverted-1 font-semibold break-words ${
21
- item.description ? 'cursor-pointer' : ''
21
+ className={`timeline-title group py-1 text-f6 leading-6 tracking-4 text-inverted-1 font-semibold break-words ${
22
+ showToggle ? 'cursor-pointer' : ''
22
23
  }`}
23
- onClick={() => item.description && setIsOpen((isOpen) => !isOpen)}
24
+ onClick={() => showToggle && setIsOpen((isOpen) => !isOpen)}
24
25
  >
25
- {item.description && (
26
+ {showToggle && (
26
27
  <button
27
28
  className={`float-right p-1 -mt-px text-inverted-2 group-hover:text-inverted-1 focus:outline-none`}
28
29
  >
@@ -39,13 +40,14 @@ export const TimelineItem = ({ item }: TimelineItemProps) => {
39
40
  <span className="inline break-words">{item.title}</span>
40
41
  </div>
41
42
  {item.timestamp && (
42
- <div className="timeline-timestamp mb-1 text-xs text-inverted-2 break-words">
43
+ <div className="timeline-timestamp mb-1 inline-flex items-center text-xs tracking-4 text-inverted-2 break-words">
44
+ <Icon icon="clock" size={3} className="mr-1" />
43
45
  {item.timestamp}
44
46
  </div>
45
47
  )}
46
48
  {item.description && (
47
49
  <div
48
- className={`timeline-description overflow-hidden text-sm text-inverted-1 break-words transition-max-height ${
50
+ className={`timeline-description overflow-hidden text-sm tracking-4 text-inverted-1 break-words transition-max-height ${
49
51
  isOpen ? 'max-h-96' : 'max-h-0'
50
52
  }`}
51
53
  >
@@ -146,10 +146,25 @@ WithBothWithoutBorder.args = {
146
146
  name: 'valor',
147
147
  }
148
148
 
149
- export const WithComplement = Template.bind({})
150
- WithComplement.args = {
149
+ export const WithLabelComplement = Template.bind({})
150
+ WithLabelComplement.args = {
151
151
  label: 'Label',
152
152
  labelComplement: <Icon icon="infoCircle" size={4} block />,
153
153
  required: true,
154
154
  name: 'nome',
155
155
  }
156
+
157
+ export const Search = Template.bind({})
158
+ Search.args = {
159
+ type: "search",
160
+ sufix: (
161
+ <button
162
+ type="submit"
163
+ className="w-full h-full flex items-center justify-center text-tertiary hover:text-primary"
164
+ >
165
+ <Icon icon="search" block />
166
+ </button>
167
+ ),
168
+ sufixBorder: false,
169
+ name: 'search',
170
+ }
@@ -63,8 +63,8 @@ const InputComponent = (
63
63
  hasErrorState ? errorBorderClasses : defaultBorderClasses
64
64
  } ${prefix && prefixBorder ? 'border-l' : ''} ${
65
65
  sufix && sufixBorder ? 'border-r' : ''
66
- } ${prefix && !prefixBorder ? 'pl-0 -ml-2' : ''} ${
67
- sufix && !sufixBorder ? 'pr-0 -mr-2' : ''
66
+ } ${prefix && !prefixBorder ? 'pl-0' : ''} ${
67
+ sufix && !sufixBorder ? 'pr-0' : ''
68
68
  }`
69
69
 
70
70
  const LabelComponent = (
@@ -100,9 +100,8 @@ export const InputCurrencyComponent = (
100
100
  setMaskedValue(calculatedMaskedValue)
101
101
  return [calculatedValue, calculatedMaskedValue]
102
102
  } else {
103
- const [maxCalculatedValue, maxCalculatedMaskedValue] = calculateValues(
104
- max
105
- )
103
+ const [maxCalculatedValue, maxCalculatedMaskedValue] =
104
+ calculateValues(max)
106
105
  setMaskedValue(maxCalculatedMaskedValue)
107
106
  return [maxCalculatedValue, maxCalculatedMaskedValue]
108
107
  }
@@ -3,7 +3,7 @@ import { composeStories } from "@storybook/testing-react"
3
3
  import { mount } from "@cypress/react"
4
4
  import * as stories from "./Badge.stories"
5
5
 
6
- const { Default, Small } = composeStories(stories)
6
+ const { Default, Small, Expanded } = composeStories(stories)
7
7
  const badgeClass = '.badge'
8
8
 
9
9
  describe('Badge tests', () => {
@@ -19,6 +19,11 @@ describe('Badge tests', () => {
19
19
  cy.get(badgeClass).should('have.class', 'px-1')
20
20
  })
21
21
 
22
+ it('Expanded', () => {
23
+ mount(<Expanded />)
24
+ cy.get(badgeClass).should('have.class', 'w-full')
25
+ })
26
+
22
27
  it('Variants', () => {
23
28
  mount(<Default type="neutral" />)
24
29
  cy.get(badgeClass).should('have.class', 'bg-inverted-2')
@@ -21,10 +21,19 @@ export default {
21
21
  },
22
22
  } as Meta
23
23
 
24
- const Template: Story<BadgeProps> = args => <Badge {...args} />
24
+ const Template: Story<BadgeProps> = args => (
25
+ <div className="w-48 flex justify-center items-center">
26
+ <Badge {...args} />
27
+ </div>
28
+ )
25
29
 
26
30
  export const Default = Template.bind({})
27
31
 
32
+ export const Expanded = Template.bind({})
33
+ Expanded.args = {
34
+ expanded: true,
35
+ }
36
+
28
37
  export const Small = Template.bind({})
29
38
  Small.args = {
30
39
  size: 'small',
@@ -17,10 +17,13 @@ const BadgeComponent = ({
17
17
  type = 'neutral',
18
18
  text,
19
19
  size = 'default',
20
+ expanded = false,
20
21
  }: BadgeProps) => {
21
22
  return (
22
23
  <div
23
- className={`badge inline-flex items-center justify-center rounded-full ${badgeTypes[type]} ${badgeSizes[size]}`}
24
+ className={`badge items-center justify-center rounded-full ${
25
+ badgeTypes[type]
26
+ } ${badgeSizes[size]} ${expanded ? 'flex w-full' : 'inline-flex'}`}
24
27
  >
25
28
  <span className={`text-xs tracking-4 font-semibold text-base-1`}>
26
29
  {text}
@@ -44,4 +47,8 @@ export interface BadgeProps {
44
47
  * @default default
45
48
  * */
46
49
  size?: keyof typeof badgeSizes
50
+ /**
51
+ * Enlarge width of the badge
52
+ * */
53
+ expanded?: boolean
47
54
  }
@@ -8,9 +8,8 @@ const ActionBarComponent = ({ onlyMobile, children }: ActionBarProps) => {
8
8
  const [containerExpanded, setContainerExpanded] = React.useState(true)
9
9
  useEffect(() => {
10
10
  const botbar = window.parent.document.querySelector<HTMLElement>('.botbar')
11
- const container = window.document.querySelector<HTMLElement>(
12
- '.page-container'
13
- )
11
+ const container =
12
+ window.document.querySelector<HTMLElement>('.page-container')
14
13
 
15
14
  if (botbar) botbar.style.display = 'none'
16
15
  if (container) {