@omniumretail/component-library 0.1.15 → 0.1.17

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/main.css CHANGED
@@ -52,10 +52,10 @@
52
52
  color: var(--button-disabled-default-text-color);
53
53
  pointer-events: none;
54
54
  }
55
- /*!***************************************************************************************************************************************************************!*\
56
- !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/sass-loader/dist/cjs.js!./src/components/Header/styles.module.scss ***!
57
- \***************************************************************************************************************************************************************/
58
- .SF5f_Q_Ggz_4JHUHS2Xa {
55
+ /*!*******************************************************************************************************************************************************************!*\
56
+ !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/sass-loader/dist/cjs.js!./src/components/Navigation/styles.module.scss ***!
57
+ \*******************************************************************************************************************************************************************/
58
+ .UxfXOleP69PjM5rFOMTD {
59
59
  display: grid;
60
60
  grid-template-columns: repeat(3, 1fr);
61
61
  justify-items: center;
@@ -65,23 +65,23 @@
65
65
  position: relative;
66
66
  }
67
67
  @media (max-width: 767px) {
68
- .SF5f_Q_Ggz_4JHUHS2Xa {
68
+ .UxfXOleP69PjM5rFOMTD {
69
69
  padding-top: 32px;
70
70
  display: flex;
71
71
  align-items: center;
72
72
  justify-content: space-between;
73
73
  }
74
74
  }
75
- .SF5f_Q_Ggz_4JHUHS2Xa .fVSt3bSZBcJGsOdA5nIN {
75
+ .UxfXOleP69PjM5rFOMTD .LzcTbjk0fp70tXlKd3eS {
76
76
  font-size: var(--font-size-body-4);
77
77
  font-weight: var(--font-weight-semibold);
78
78
  text-transform: uppercase;
79
79
  }
80
- .SF5f_Q_Ggz_4JHUHS2Xa .yVW6IeVCSAwXxdRW9PIK {
80
+ .UxfXOleP69PjM5rFOMTD .gn06XRZhFG00HaVjAqNc {
81
81
  align-self: center;
82
82
  }
83
83
  @media (max-width: 767px) {
84
- .SF5f_Q_Ggz_4JHUHS2Xa .yVW6IeVCSAwXxdRW9PIK {
84
+ .UxfXOleP69PjM5rFOMTD .gn06XRZhFG00HaVjAqNc {
85
85
  position: absolute;
86
86
  top: 0;
87
87
  margin: 0 auto;
@@ -90,10 +90,10 @@
90
90
  text-align: center;
91
91
  }
92
92
  }
93
- .SF5f_Q_Ggz_4JHUHS2Xa .zpR1xIlHnIvOAGtMYHMN {
93
+ .UxfXOleP69PjM5rFOMTD .UK3esJZjnri5Jb9Jxcca {
94
94
  justify-self: start;
95
95
  }
96
- .SF5f_Q_Ggz_4JHUHS2Xa .cZ7HbAWj4tgAgHB3UcVg {
96
+ .UxfXOleP69PjM5rFOMTD .U5tZ7kRlrIHUKsuduD1S {
97
97
  justify-self: end;
98
98
  }
99
99
  /*!*************************************************************************************************************************************************************!*\
@@ -273,7 +273,7 @@
273
273
  !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/sass-loader/dist/cjs.js!./src/components/DatePicker/styles.module.scss ***!
274
274
  \*******************************************************************************************************************************************************************/
275
275
  .vdTO5pKaLXA2FdyblLq5 {
276
- border: 1px solid var(--button-border-color) !important;
276
+ border-color: rgba(var(--color-black-rgb), 0.5);
277
277
  }
278
278
  /*!**************************************************************************************************************************************************************!*\
279
279
  !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/sass-loader/dist/cjs.js!./src/components/Radio/styles.module.scss ***!
@@ -1,5 +1,5 @@
1
1
  import { Meta, Story } from "@storybook/react";
2
- import { HeaderProps } from '.';
2
+ import { NavigationProps } from '.';
3
3
  declare const _default: Meta<import("@storybook/react").Args>;
4
4
  export default _default;
5
- export declare const Primary: Story<HeaderProps>;
5
+ export declare const Primary: Story<NavigationProps>;
@@ -0,0 +1,10 @@
1
+ export interface NavigationProps {
2
+ backLink?: boolean;
3
+ title: string;
4
+ homeLink?: boolean;
5
+ loginLink?: boolean;
6
+ loginOnClickFunction?: () => void;
7
+ backLinkOnClickFunction?: () => void;
8
+ homeOnClickFunction?: () => void;
9
+ }
10
+ export declare const Navigation: (props: NavigationProps) => JSX.Element;
@@ -1,2 +1,5 @@
1
1
  import { SelectProps } from 'antd';
2
- export declare const CustomSelect: (props: SelectProps) => any;
2
+ export interface CustomSelectProps extends SelectProps {
3
+ customClass?: string;
4
+ }
5
+ export declare const CustomSelect: (props: CustomSelectProps) => any;
@@ -5,3 +5,4 @@ export default _default;
5
5
  export declare const Primary: Story<customTableProps>;
6
6
  export declare const Secondary: Story<customTableProps>;
7
7
  export declare const WithCheckbox: Story<customTableProps>;
8
+ export declare const withActions: Story<customTableProps>;
@@ -4,6 +4,10 @@ export interface FilterOptions {
4
4
  label: string;
5
5
  direction: string;
6
6
  }
7
+ export interface Actions {
8
+ key: string;
9
+ label: string;
10
+ }
7
11
  export declare enum sortBy {
8
12
  asc = "asc",
9
13
  desc = "desc"
@@ -15,5 +19,7 @@ export interface customTableProps extends TableProps<any> {
15
19
  sortInfo?: any;
16
20
  paginationInfo?: any;
17
21
  headingTranslationsKey?: string;
22
+ actions: boolean;
23
+ actionsArray: any;
18
24
  }
19
25
  export declare const CustomTable: (props: customTableProps) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  export * from './Button';
2
- export * from './Header';
2
+ export * from './Navigation';
3
3
  export * from './Input';
4
4
  export * from './InputCountryCode';
5
5
  export * from './Label';
@@ -1 +1 @@
1
- export {};
1
+ export declare const mergei18n: (appResources: any) => void;
@@ -1 +1,2 @@
1
1
  export * from './components';
2
+ export * from './constants/i18n';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -43,6 +43,7 @@
43
43
  "jest": "^27.4.3",
44
44
  "jest-resolve": "^27.4.2",
45
45
  "jest-watch-typeahead": "^1.0.0",
46
+ "lodash.merge": "^4.6.2",
46
47
  "mini-css-extract-plugin": "^2.7.2",
47
48
  "moment": "^2.29.4",
48
49
  "postcss": "^8.4.4",
@@ -1,4 +1,3 @@
1
1
  .sitooDatePicker {
2
- border: 1px solid var(--button-border-color) !important;
2
+ border-color: rgba(var(--color-black-rgb), .5);
3
3
  }
4
-
@@ -1,16 +1,17 @@
1
1
  import { Meta, Story } from "@storybook/react";
2
- import { Header, HeaderProps } from '.';
2
+ import { Navigation, NavigationProps } from '.';
3
3
 
4
4
  export default {
5
- title: 'Header',
6
- component: Header,
5
+ title: 'Navigation',
6
+ component: Navigation,
7
7
  } as Meta;
8
8
 
9
- const Template: Story<HeaderProps> = (args) => <Header {...args}></Header>;
9
+ const Template: Story<NavigationProps> = (args) => <Navigation {...args}></Navigation>;
10
10
 
11
11
  export const Primary = Template.bind({});
12
12
  Primary.args = {
13
13
  backLink: true,
14
14
  title: 'Gestão de Aplicações',
15
15
  homeLink: true,
16
+ loginLink: true,
16
17
  };
@@ -2,29 +2,31 @@ import styles from './styles.module.scss';
2
2
  import { Link } from '../Link';
3
3
  import { ArrowLeftOutlined, HomeOutlined, LogoutOutlined } from '@ant-design/icons';
4
4
  import { useTranslation } from 'react-i18next';
5
- export interface HeaderProps {
5
+ export interface NavigationProps {
6
6
  backLink?: boolean;
7
7
  title: string;
8
8
  homeLink?: boolean;
9
9
  loginLink?: boolean;
10
- onClickFunction?: () => void;
10
+ loginOnClickFunction?: () => void;
11
+ backLinkOnClickFunction?: () => void;
12
+ homeOnClickFunction?: () => void;
11
13
  }
12
14
 
13
- export const Header = (props: HeaderProps) => {
14
- const { backLink, title, homeLink, onClickFunction, loginLink } = props;
15
+ export const Navigation = (props: NavigationProps) => {
16
+ const { backLink, title, homeLink, loginOnClickFunction, loginLink, backLinkOnClickFunction, homeOnClickFunction } = props;
15
17
  const { t } = useTranslation();
16
18
 
17
19
  return (
18
- <div className={styles.header}>
20
+ <div className={styles.navigation}>
19
21
  <div className={styles.columnLeft}>
20
- { backLink && <Link href="#" icon={<ArrowLeftOutlined />} linkSecondary> {t('navigation.back')} </Link> }
22
+ { backLink && <Link href="#" icon={<ArrowLeftOutlined />} linkSecondary onClick={backLinkOnClickFunction}> {t('navigation.back')} </Link> }
21
23
  </div>
22
24
  <div className={styles.columnCenter}>
23
25
  <h1 className={styles.title}>{title}</h1>
24
26
  </div>
25
27
  <div className={styles.columnRight}>
26
- {homeLink && <Link href="#" icon={<HomeOutlined />} linkSecondary iconAlignRight> {t('navigation.home')} </Link>}
27
- {loginLink && <Link href="#" onClick={onClickFunction} icon={<LogoutOutlined />} linkSecondary iconAlignRight> {t('navigation.logout')} </Link>}
28
+ {homeLink && <Link href="#" icon={<HomeOutlined />} linkSecondary iconAlignRight onClick={homeOnClickFunction}> {t('navigation.home')} </Link>}
29
+ {loginLink && <Link href="#" onClick={loginOnClickFunction} icon={<LogoutOutlined />} linkSecondary iconAlignRight> {t('navigation.logout')} </Link>}
28
30
  </div>
29
31
  </div>
30
32
  )
@@ -1,4 +1,4 @@
1
- .header {
1
+ .navigation {
2
2
  display: grid;
3
3
  grid-template-columns: repeat(3, 1fr);
4
4
  justify-items: center;
@@ -1,13 +1,17 @@
1
1
  import styles from './styles.module.scss';
2
2
  import { Select, SelectProps } from 'antd';
3
3
 
4
- export const CustomSelect = (props: SelectProps) => {
5
- const { defaultValue, options } = props;
4
+ export interface CustomSelectProps extends SelectProps {
5
+ customClass?: string;
6
+ }
7
+
8
+ export const CustomSelect = (props: CustomSelectProps) => {
9
+ const { defaultValue, options, customClass } = props;
6
10
 
7
11
  return (
8
12
  (options || defaultValue) &&
9
13
  <Select
10
- className={styles.select}
14
+ className={`${styles.select} ${customClass}`}
11
15
  defaultValue={defaultValue}
12
16
  style={{ minWidth: 180 }}
13
17
  options={options}
@@ -1,6 +1,7 @@
1
1
  import { Meta, Story } from "@storybook/react";
2
2
  import { CustomTable, customTableProps } from '.';
3
3
  import { useState } from "react";
4
+ import { useTranslation } from "react-i18next";
4
5
 
5
6
  export default {
6
7
  title: 'customTable',
@@ -8,20 +9,30 @@ export default {
8
9
  } as Meta;
9
10
 
10
11
  const Template: Story<customTableProps> = (args) => {
12
+ const { t } = useTranslation();
11
13
  const [pageInfo, setPageInfo] = useState<any>({});
12
14
  // const [sortingInfo, setSortingInfo] = useState<any>({});
13
15
  const [sortBy, setSortBy] = useState<string[]>(['key', 'desc']);
14
16
 
15
17
  const newDataSource = args.dataSource?.slice().sort((a, b) => {
16
- if(sortBy[1] === 'asc') {
18
+ if (sortBy[1] === 'asc') {
17
19
  return a[sortBy[0]].localeCompare(b[sortBy[0]]);
18
20
  } else {
19
- debugger;
20
21
  return b[sortBy[0]].localeCompare(a[sortBy[0]]);
21
22
  }
22
23
  });
23
24
 
24
- return <CustomTable {...args} dataSource={newDataSource} onSort={(field, sort) => setSortBy([field, sort]) } paginationInfo={setPageInfo} headingTranslationsKey={'tableHeadings'} ></CustomTable>;
25
+ return <CustomTable {...args} dataSource={newDataSource} onSort={(field, sort) => setSortBy([field, sort])} paginationInfo={setPageInfo} headingTranslationsKey={'tableHeadings'} actionsArray={
26
+ [
27
+ { key: '1', label: `${t('actions.one')}`, onClick: () => {
28
+ console.log('oi');
29
+ } },
30
+ { key: '2', label: `${t('actions.two')}` },
31
+ {
32
+ key: '3', label: 'label 3'
33
+ }
34
+ ]
35
+ }></CustomTable>;
25
36
  };
26
37
 
27
38
  export const Primary = Template.bind({});
@@ -150,3 +161,48 @@ WithCheckbox.args = {
150
161
  type: "checkbox"
151
162
  }
152
163
  };
164
+
165
+ export const withActions = Template.bind({});
166
+ withActions.args = {
167
+ fieldsToSort: ['store', 'mecanographicNumber'],
168
+ selectPlaceholder: 'Order by',
169
+ dataSource: [
170
+ {
171
+ key: `1`,
172
+ name: `John Brown`,
173
+ mecanographicNumber: "232",
174
+ store: `Levi's Sta Catarina`,
175
+ role: `Gerente`,
176
+ type: `Efetivo`
177
+ },
178
+ {
179
+ key: `2`,
180
+ name: `Mary Brown`,
181
+ mecanographicNumber: "32",
182
+ store: `Levi's Sta Catarina`,
183
+ role: `Comercial`,
184
+ type: `Efetivo`
185
+ },
186
+ {
187
+ key: `3`,
188
+ name: `Anna Astori`,
189
+ mecanographicNumber: "3212",
190
+ store: `Levi's Sta Catarina`,
191
+ role: `Funcionário`,
192
+ type: `Efetivo`
193
+ },
194
+ {
195
+ key: `4`,
196
+ name: `Yield Ona`,
197
+ mecanographicNumber: "21232",
198
+ store: `Adidas Restaurantes`,
199
+ role: `Gerente`,
200
+ type: `Efetivo`
201
+ },
202
+ ],
203
+ pagination: {
204
+ total: 24,
205
+ pageSize: 4
206
+ },
207
+ actions: true,
208
+ };
@@ -1,14 +1,20 @@
1
1
  import { useState, useEffect } from 'react';
2
- import { Space, TableProps, Select } from 'antd';
2
+ import { Space, TableProps, Select, Dropdown, MenuProps } from 'antd';
3
3
  import { Table } from 'antd';
4
4
  import type { ColumnsType } from 'antd/es/table/interface';
5
5
  import styles from './styles.module.scss';
6
6
  import { useTranslation } from 'react-i18next';
7
+ import { EllipsisOutlined } from '@ant-design/icons';
7
8
 
8
9
  export interface FilterOptions {
9
- value: string,
10
- label: string,
11
- direction: string,
10
+ value: string;
11
+ label: string;
12
+ direction: string;
13
+ }
14
+
15
+ export interface Actions {
16
+ key: string;
17
+ label: string;
12
18
  }
13
19
 
14
20
  export enum sortBy {
@@ -23,18 +29,22 @@ export interface customTableProps extends TableProps<any> {
23
29
  sortInfo?: any;
24
30
  paginationInfo?: any;
25
31
  headingTranslationsKey?: string;
32
+ actions: boolean;
33
+ actionsArray: any;
26
34
  }
27
35
 
28
36
  export const CustomTable = (props: customTableProps) => {
29
37
  const { t } = useTranslation();
30
38
 
31
- const {
32
- dataSource,
33
- fieldsToSort = ['key', 'name', 'store'],
34
- selectPlaceholder, onSort,
35
- headingTranslationsKey
39
+ const {
40
+ dataSource,
41
+ fieldsToSort = ['key', 'name', 'store'],
42
+ selectPlaceholder, onSort,
43
+ headingTranslationsKey,
44
+ actions,
45
+ actionsArray: items,
36
46
  } = props;
37
-
47
+
38
48
  const [customFilters, setCustomFilters] = useState<any>([]);
39
49
  const [customColumns, setCustomColumns] = useState<ColumnsType<any>>([]);
40
50
  const [sortInfo, setSortInfo] = useState<any>([]);
@@ -44,7 +54,7 @@ export const CustomTable = (props: customTableProps) => {
44
54
  currentPage: pagination.current,
45
55
  }
46
56
 
47
- const getSortAndPaginationInfo = {...sortInfo, ...getPagination}
57
+ const getSortAndPaginationInfo = { ...sortInfo, ...getPagination }
48
58
  props.paginationInfo(getSortAndPaginationInfo);
49
59
  };
50
60
 
@@ -60,12 +70,32 @@ export const CustomTable = (props: customTableProps) => {
60
70
 
61
71
  useEffect(() => {
62
72
  // Columns
63
- const columns = Object.keys(dataSource?.[0]).map(key => ({
64
- title: headingTranslationsKey ? `${headingTranslationsKey}.${key}` : key,
65
- dataIndex: key,
66
- key: key,
67
- ellipsis: true,
68
- }));
73
+ let columns = Object.keys(dataSource?.[0]).map(key => {
74
+ return ({
75
+ title: headingTranslationsKey ? t(`${headingTranslationsKey}.${key}`) : key,
76
+ dataIndex: key,
77
+ key: key,
78
+ ellipsis: true,
79
+ })
80
+ });
81
+
82
+ let columnActions = {
83
+ title: 'Action',
84
+ key: 'action',
85
+ dataIndex: 6,
86
+ ellipsis: false,
87
+ render: () => (
88
+ <Space size="middle">
89
+ <Dropdown menu={{ items }}>
90
+ <a>
91
+ <EllipsisOutlined />
92
+ </a>
93
+ </Dropdown>
94
+ </Space>
95
+ ),
96
+ };
97
+
98
+ actions && columns.push(columnActions as any);
69
99
 
70
100
  setCustomColumns(columns);
71
101
 
@@ -113,15 +143,8 @@ export const CustomTable = (props: customTableProps) => {
113
143
  dataSource={dataSource}
114
144
  onChange={handleChange}
115
145
  {...props}
116
- >
117
- {customColumns.map((column) => (
118
- <Table.Column
119
- key={column.key}
120
- title={headingTranslationsKey ? t(column.title as string) : column.title}
121
- dataIndex={(column as any).dataIndex}
122
- />
123
- ))}
124
- </Table>
146
+ columns={customColumns}
147
+ />
125
148
  </div>
126
149
  );
127
150
  }
@@ -1,5 +1,5 @@
1
1
  export * from './Button';
2
- export * from './Header';
2
+ export * from './Navigation';
3
3
  export * from './Input';
4
4
  export * from './InputCountryCode';
5
5
  export * from './Label';
@@ -4,19 +4,22 @@ import { initReactI18next } from "react-i18next";
4
4
  import en from '../locales/en.json';
5
5
  import es from '../locales/es.json';
6
6
  import pt from '../locales/pt.json';
7
+ var merge = require('lodash.merge');
7
8
 
8
- i18next
9
+ export const mergei18n = (appResources: any) => {
10
+ i18next
9
11
  .use(initReactI18next)
10
12
  .use(LanguageDetector)
11
13
  .init({
12
- resources: {
14
+ resources: merge({
13
15
  en: { translation: en },
14
16
  pt: { translation: pt },
15
17
  es: { translation: es },
16
- },
18
+ }, appResources),
17
19
  detection: {
18
20
  order: ['querystring', 'navigator', 'htmlTag'],
19
21
  lookupQuerystring: 'lng',
20
22
  htmlTag: document.documentElement,
21
23
  },
22
24
  });
25
+ }
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './components';
2
+ export * from './constants/i18n';
@@ -11,5 +11,9 @@
11
11
  "back": "Go Back",
12
12
  "logout": "Log Out",
13
13
  "home": "Home"
14
+ },
15
+ "actions": {
16
+ "one": "one",
17
+ "two": "two"
14
18
  }
15
19
  }
@@ -11,5 +11,9 @@
11
11
  "back": "Go Back ES",
12
12
  "logout": "Log Out ES",
13
13
  "home": "Home ES"
14
+ },
15
+ "actions": {
16
+ "one": "one ES",
17
+ "two": "two ES"
14
18
  }
15
19
  }
@@ -11,5 +11,9 @@
11
11
  "back": "Go Back PT",
12
12
  "logout": "Log Out PT",
13
13
  "home": "Home PT"
14
+ },
15
+ "actions": {
16
+ "one": "one PT",
17
+ "two": "two PT"
14
18
  }
15
19
  }
@@ -1,8 +0,0 @@
1
- export interface HeaderProps {
2
- backLink?: boolean;
3
- title: string;
4
- homeLink?: boolean;
5
- loginLink?: boolean;
6
- onClickFunction?: () => void;
7
- }
8
- export declare const Header: (props: HeaderProps) => JSX.Element;