tycho-components 0.0.15-SNAPSHOT-14 → 0.0.16-SNAPSHOT

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.
@@ -0,0 +1,17 @@
1
+ import './style.scss';
2
+ type Props = {
3
+ gotoPage: (p: number) => void;
4
+ canPreviousPage: boolean;
5
+ canNextPage: boolean;
6
+ previousPage: () => void;
7
+ nextPage: () => void;
8
+ pageIndex: number;
9
+ pageOptions: number[];
10
+ setPageSize: (p: number) => void;
11
+ pageSize: number;
12
+ multiple?: number;
13
+ total: number;
14
+ hideTotal?: boolean;
15
+ };
16
+ export default function AppPagination({ gotoPage, canPreviousPage, canNextPage, previousPage, nextPage, pageIndex, pageOptions, setPageSize, pageSize, multiple, total, hideTotal, }: Props): import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { faChevronLeft, faChevronRight, } from '@fortawesome/free-solid-svg-icons';
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
+ import { useEffect, useState } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import AppSelect from '../AppSelect';
7
+ import './style.scss';
8
+ const minPages = 5;
9
+ export default function AppPagination({ gotoPage, canPreviousPage, canNextPage, previousPage, nextPage, pageIndex, pageOptions, setPageSize, pageSize, multiple, total, hideTotal, }) {
10
+ const { t } = useTranslation('common');
11
+ const getPageSizeOptions = () => {
12
+ const arrayPagination = [];
13
+ if (multiple) {
14
+ for (let i = 0; i < 5; i += 1)
15
+ arrayPagination.push({
16
+ label: `${t('pagination.label.showing')} ${(i + 1) * multiple} ${t('pagination.label.results')}`,
17
+ value: (i + 1) * multiple,
18
+ });
19
+ }
20
+ return arrayPagination;
21
+ };
22
+ const alterColorPageSelected = (pageOption) => pageOption === pageIndex ? 'page-item selected' : 'page-item';
23
+ const [buttons, setButtons] = useState([]);
24
+ const renderButton = (pageOption) => {
25
+ if (pageOption === undefined)
26
+ return null;
27
+ if (pageOption === -1 || pageOption === -2) {
28
+ return (_jsx("button", { type: "button", className: "page-ellipsis", children: "..." }, pageOption.valueOf()));
29
+ }
30
+ return (_jsx("button", { type: "button", onClick: () => {
31
+ gotoPage(pageOption);
32
+ }, className: alterColorPageSelected(pageOption), children: pageOption + 1 }, pageOption.valueOf()));
33
+ };
34
+ useEffect(() => {
35
+ if (pageOptions && pageOptions.length > minPages) {
36
+ const arr = [];
37
+ // add first and check for need of ...
38
+ arr.push(0);
39
+ if (pageIndex > 1)
40
+ arr.push(-1);
41
+ if (pageIndex >= pageOptions.length - 3) {
42
+ for (let i = pageOptions.length - 3; i < pageOptions.length; i += 1) {
43
+ if (i !== pageOptions.length - 1) {
44
+ arr.push(i);
45
+ }
46
+ }
47
+ }
48
+ else {
49
+ for (let i = 0; i < 3; i += 1) {
50
+ if (pageIndex + i !== 0) {
51
+ arr.push(pageIndex + i);
52
+ }
53
+ }
54
+ }
55
+ // check for need of ... and add last
56
+ if (pageIndex < pageOptions.length - 3)
57
+ arr.push(-2);
58
+ arr.push(pageOptions[pageOptions.length - 1]);
59
+ setButtons(arr);
60
+ }
61
+ else {
62
+ setButtons(pageOptions.slice());
63
+ }
64
+ }, [pageIndex]);
65
+ return (_jsxs("div", { className: "pagination-container", children: [_jsxs("div", { className: "select", children: [multiple && (_jsx(AppSelect, { options: getPageSizeOptions(), value: getPageSizeOptions().find((p) => p.value === pageSize), emptyValue: false, onChange: (e) => {
66
+ setPageSize(e);
67
+ } })), !hideTotal && (_jsxs("span", { className: "total", children: [t('pagination.label.total'), ": ", total] }))] }), _jsxs("div", { className: "pages", children: [_jsx("button", { type: "button", onClick: () => previousPage(), disabled: !canPreviousPage, className: "page-item-chevron", children: _jsx(FontAwesomeIcon, { icon: faChevronLeft }) }), buttons?.map((pageOption, idx) => renderButton(pageOption)), _jsx("button", { type: "button", onClick: () => nextPage(), disabled: !canNextPage, className: "page-item-chevron", children: _jsx(FontAwesomeIcon, { icon: faChevronRight }) })] })] }));
68
+ }
@@ -0,0 +1,2 @@
1
+ import AppPagination from './AppPagination';
2
+ export default AppPagination;
@@ -0,0 +1,2 @@
1
+ import AppPagination from './AppPagination';
2
+ export default AppPagination;
@@ -0,0 +1,59 @@
1
+ .pagination-container {
2
+ display: flex;
3
+ align-items: center;
4
+
5
+ > .pages {
6
+ display: flex;
7
+ margin-left: auto;
8
+
9
+ .page-item,
10
+ .page-item-chevron,
11
+ .page-ellipsis {
12
+ height: 30px;
13
+ width: 35px;
14
+ margin-left: 4px;
15
+ border-radius: var(--radius-100);
16
+ background-color: var(--background-default);
17
+ }
18
+
19
+ .page-item-chevron {
20
+ border: none;
21
+ }
22
+
23
+ .page-ellipsis {
24
+ cursor: default;
25
+ }
26
+
27
+ .page-item,
28
+ .page-ellipsis {
29
+ @include button-small;
30
+ border: 1px solid var(--border-subtle-3);
31
+ background-color: var(--button-secondary-default);
32
+ color: var(--text-secondary);
33
+ align-items: center;
34
+
35
+ &.selected {
36
+ background: var(--button-primary-default);
37
+ color: var(--text-on-color-light);
38
+ }
39
+
40
+ &:hover {
41
+ background: var(--button-secondary-hover);
42
+ }
43
+ }
44
+ }
45
+
46
+ .select {
47
+ display: flex;
48
+ align-items: center;
49
+ gap: 16px;
50
+
51
+ .form-select {
52
+ width: auto;
53
+ }
54
+
55
+ .total {
56
+ @include label-medium-2;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,9 @@
1
+ import './style.scss';
2
+ type Props = {
3
+ options: any[];
4
+ value: any;
5
+ onChange: (value: any) => void;
6
+ emptyValue?: boolean;
7
+ };
8
+ export default function AppSelect({ options, onChange, emptyValue, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Form } from 'react-bootstrap';
3
+ import './style.scss';
4
+ import { useTranslation } from 'react-i18next';
5
+ export default function AppSelect({ options, onChange, emptyValue = true, }) {
6
+ const { t } = useTranslation('common');
7
+ const getValues = () => {
8
+ if (Array.isArray(options))
9
+ return options;
10
+ const arr = [];
11
+ Object.keys(options).forEach((key) => {
12
+ arr.push({
13
+ label: options[key],
14
+ value: key,
15
+ });
16
+ });
17
+ return arr;
18
+ };
19
+ return (_jsxs(Form.Select, { onChange: (e) => onChange(e.target.value), children: [emptyValue && _jsx("option", { value: "", children: t('select.empty') }), getValues().map((option, idx) => (_jsx("option", { value: option.value, children: option.label }, idx.valueOf())))] }));
20
+ }
@@ -0,0 +1,2 @@
1
+ import AppSelect from './AppSelect';
2
+ export default AppSelect;
@@ -0,0 +1,2 @@
1
+ import AppSelect from './AppSelect';
2
+ export default AppSelect;
File without changes
@@ -9,6 +9,8 @@ type Props = {
9
9
  freeAccess?: boolean;
10
10
  hideKeyboard?: boolean;
11
11
  hideReplaceAll?: boolean;
12
+ parser?: boolean;
13
+ customHeader?: React.ReactNode;
12
14
  };
13
- export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, }: Props): import("react/jsx-runtime").JSX.Element;
15
+ export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, customHeader, }: Props): import("react/jsx-runtime").JSX.Element;
14
16
  export {};
@@ -12,7 +12,7 @@ import HeaderReplaceAll from './HeaderReplaceAll';
12
12
  import HeaderUser from './HeaderUser';
13
13
  import './styles.scss';
14
14
  const linkTurorials = 'https://www.tycho.iel.unicamp.br/home/tutorials';
15
- export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, }) {
15
+ export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, customHeader, }) {
16
16
  const { t } = useTranslation('header');
17
17
  const { getCorpus, hasCorpus } = useCorpusUtils();
18
18
  const [openKeyboard, setOpenKeyboard] = useState(false);
@@ -22,5 +22,5 @@ export default function Header({ tool, navigateHome, navigateCorpora, navigateLo
22
22
  const homeTextsClass = cx('texts', {
23
23
  pointer: navigateHome !== undefined,
24
24
  });
25
- return (_jsxs("div", { className: "ds-header", children: [_jsx(HeaderApps, { freeAccess: freeAccess }), _jsxs("div", { className: homeTextsClass, onClick: () => navigateHome && navigateHome(), children: [_jsx("span", { className: "title", children: t('label.platform') }), _jsx("span", { className: "subtitle", children: tool })] }), _jsx(HeaderCorpora, { redirect: redirect, autoload: autoload, freeAccess: freeAccess, navigateCorpora: navigateCorpora }), _jsxs("div", { className: profileClass, children: [!hideReplaceAll && _jsx(HeaderReplaceAll, {}), !hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard') })), _jsx(IconButton, { name: "live_help", size: "medium", title: t('tooltip.tutorials'), onClick: () => window.open(linkTurorials, '_blank') }), _jsx(LanguageSelector, {}), !freeAccess && _jsx(HeaderUser, { navigateLogout: navigateLogout })] }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: getCorpus().keyboardLayout || 'english' }))] }));
25
+ return (_jsxs("div", { className: "ds-header", children: [_jsx(HeaderApps, { freeAccess: freeAccess }), _jsxs("div", { className: homeTextsClass, onClick: () => navigateHome && navigateHome(), children: [_jsx("span", { className: "title", children: t('label.platform') }), _jsx("span", { className: "subtitle", children: tool })] }), customHeader, !customHeader && (_jsx(HeaderCorpora, { redirect: redirect, autoload: autoload, freeAccess: freeAccess, navigateCorpora: navigateCorpora })), _jsxs("div", { className: profileClass, children: [!hideReplaceAll && _jsx(HeaderReplaceAll, {}), !hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard') })), _jsx(IconButton, { name: "live_help", size: "medium", title: t('tooltip.tutorials'), onClick: () => window.open(linkTurorials, '_blank') }), _jsx(LanguageSelector, {}), !freeAccess && _jsx(HeaderUser, { navigateLogout: navigateLogout })] }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: getCorpus().keyboardLayout || 'english' }))] }));
26
26
  }
@@ -4,6 +4,7 @@ export declare const commonResources: {
4
4
  'button.confirm': string;
5
5
  'button.cancel': string;
6
6
  'button.remove': string;
7
+ 'select.empty': string;
7
8
  'pagination.label.showing': string;
8
9
  'pagination.label.results': string;
9
10
  'pagination.label.total': string;
@@ -133,6 +134,8 @@ export declare const commonResources: {
133
134
  common: {
134
135
  'button.confirm': string;
135
136
  'button.cancel': string;
137
+ 'button.remove': string;
138
+ 'select.empty': string;
136
139
  'pagination.label.showing': string;
137
140
  'pagination.label.results': string;
138
141
  'pagination.label.total': string;
@@ -3,6 +3,7 @@ export declare const CommonTexts: {
3
3
  'button.confirm': string;
4
4
  'button.cancel': string;
5
5
  'button.remove': string;
6
+ 'select.empty': string;
6
7
  'pagination.label.showing': string;
7
8
  'pagination.label.results': string;
8
9
  'pagination.label.total': string;
@@ -21,6 +22,8 @@ export declare const CommonTexts: {
21
22
  'pt-BR': {
22
23
  'button.confirm': string;
23
24
  'button.cancel': string;
25
+ 'button.remove': string;
26
+ 'select.empty': string;
24
27
  'pagination.label.showing': string;
25
28
  'pagination.label.results': string;
26
29
  'pagination.label.total': string;
@@ -40,6 +43,7 @@ export declare const CommonTexts: {
40
43
  'button.confirm': string;
41
44
  'button.cancel': string;
42
45
  'button.remove': string;
46
+ 'select.empty': string;
43
47
  'pagination.label.showing': string;
44
48
  'pagination.label.results': string;
45
49
  'pagination.label.total': string;
@@ -3,6 +3,7 @@ export const CommonTexts = {
3
3
  'button.confirm': 'Confirm',
4
4
  'button.cancel': 'Cancel',
5
5
  'button.remove': 'Remove',
6
+ 'select.empty': 'Select',
6
7
  'pagination.label.showing': 'Showing',
7
8
  'pagination.label.results': 'results per page',
8
9
  'pagination.label.total': 'Total',
@@ -21,6 +22,8 @@ export const CommonTexts = {
21
22
  'pt-BR': {
22
23
  'button.confirm': 'Confirmar',
23
24
  'button.cancel': 'Cancelar',
25
+ 'button.remove': 'Remover',
26
+ 'select.empty': 'Selecionar',
24
27
  'pagination.label.showing': 'Exibindo',
25
28
  'pagination.label.results': 'resultados por página',
26
29
  'pagination.label.total': 'Total',
@@ -40,6 +43,7 @@ export const CommonTexts = {
40
43
  'button.confirm': 'Conferma',
41
44
  'button.cancel': 'Annulla',
42
45
  'button.remove': 'Rimuovi',
46
+ 'select.empty': 'Seleziona',
43
47
  'pagination.label.showing': 'Mostrando',
44
48
  'pagination.label.results': 'risultati per pagina',
45
49
  'pagination.label.total': 'Totale',
package/dist/index.d.ts CHANGED
@@ -6,8 +6,10 @@ export { default as AppLoading } from './AppLoading';
6
6
  export { default as AppModal } from './AppModal';
7
7
  export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
8
8
  export { default as AppModalRemove } from './AppModal/AppModalRemove';
9
+ export { default as AppPagination } from './AppPagination';
9
10
  export { default as AppPicture } from './AppPicture';
10
11
  export { default as AppPlaceholder } from './AppPlaceholder';
12
+ export { default as AppSelect } from './AppSelect';
11
13
  export { default as AppToast } from './AppToast';
12
14
  export { default as CommentComponent } from './Comments';
13
15
  export { default as Header } from './Header';
package/dist/index.js CHANGED
@@ -6,8 +6,10 @@ export { default as AppLoading } from './AppLoading';
6
6
  export { default as AppModal } from './AppModal';
7
7
  export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
8
8
  export { default as AppModalRemove } from './AppModal/AppModalRemove';
9
+ export { default as AppPagination } from './AppPagination';
9
10
  export { default as AppPicture } from './AppPicture';
10
11
  export { default as AppPlaceholder } from './AppPlaceholder';
12
+ export { default as AppSelect } from './AppSelect';
11
13
  export { default as AppToast } from './AppToast';
12
14
  export { default as CommentComponent } from './Comments';
13
15
  export { default as Header } from './Header';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.15-SNAPSHOT-14",
4
+ "version": "0.0.16-SNAPSHOT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {