@tmlmobilidade/ui 20250723.2143.18 → 20250723.2202.16
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/index.d.ts +27 -2
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/src/components/display/AlertMessage/index.js +10 -0
- package/dist/src/components/display/AlertMessage/index.js.map +1 -0
- package/dist/src/components/upload/FileButton/index.js +39 -0
- package/dist/src/components/upload/FileButton/index.js.map +1 -0
- package/dist/src/components/upload/FileUpload/index.js +64 -0
- package/dist/src/components/upload/FileUpload/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -340,6 +340,13 @@ interface DataTableColumn<T> {
|
|
|
340
340
|
}
|
|
341
341
|
declare function DataTable<T>({ records, ...props }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
342
342
|
|
|
343
|
+
interface AlertMessageProps {
|
|
344
|
+
icon?: React.ReactNode;
|
|
345
|
+
message?: string;
|
|
346
|
+
title?: string;
|
|
347
|
+
}
|
|
348
|
+
declare function AlertMessage({ icon, message, title }: AlertMessageProps): react_jsx_runtime.JSX.Element;
|
|
349
|
+
|
|
343
350
|
interface ErrorDisplayProps {
|
|
344
351
|
message?: string;
|
|
345
352
|
}
|
|
@@ -675,6 +682,24 @@ interface ThemeSwitcherProps {
|
|
|
675
682
|
}
|
|
676
683
|
declare function ThemeSwitcher({ onThemeChange }: ThemeSwitcherProps): react_jsx_runtime.JSX.Element;
|
|
677
684
|
|
|
685
|
+
interface FileButtonProps {
|
|
686
|
+
accept?: string;
|
|
687
|
+
disabled?: boolean;
|
|
688
|
+
icon?: ReactNode;
|
|
689
|
+
label: string;
|
|
690
|
+
loading?: boolean;
|
|
691
|
+
onCancel?: () => void;
|
|
692
|
+
onFileChange?: (file: File) => void;
|
|
693
|
+
}
|
|
694
|
+
declare function FileButton({ accept, disabled, icon, label, loading, onCancel, onFileChange }: FileButtonProps): react_jsx_runtime.JSX.Element;
|
|
695
|
+
|
|
696
|
+
interface FileUploadProps extends FileButtonProps {
|
|
697
|
+
fileName?: string;
|
|
698
|
+
fileUrl?: string;
|
|
699
|
+
maxFileSize?: number;
|
|
700
|
+
}
|
|
701
|
+
declare function FileUpload({ accept, fileName, fileUrl, label, maxFileSize, onFileChange }: FileUploadProps): react_jsx_runtime.JSX.Element;
|
|
702
|
+
|
|
678
703
|
interface MeContextState {
|
|
679
704
|
actions: {
|
|
680
705
|
hasPermission: (scope: string, action: string) => boolean;
|
|
@@ -867,5 +892,5 @@ declare const getBaseGeoJsonFeatureLineString: () => GeoJSON.Feature<GeoJSON.Lin
|
|
|
867
892
|
*/
|
|
868
893
|
declare const getBaseGeoJsonFeatureCollection: () => GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.Point, GeoJSON.GeoJsonProperties>;
|
|
869
894
|
|
|
870
|
-
export { AVAILABLE_THEMES, AppProvider, AppWrapper, BackButton, Badge, Button, CMIcon, CMLogo, Checkbox, Collapsible, ComboboxComponent as Combobox, ComponentWrapper, DataTable, DatePicker, DateTimePicker, DeleteButton, Description, Divider, ErrorDisplay, FilterMenu, FilterMenuTarget, FiltersBar, Grid, HasPermission, Indicator, Label, Loader, LoadingOverlay, LockButton, MapOptionsContextProvider, MapView, MapViewStyleActiveStops, MapViewStyleActiveStopsInteractiveLayerId, MapViewStyleActiveStopsPrimaryLayerId, MapViewStylePath, MapViewStylePathInteractiveLayerId, MapViewStylePathPrimaryLayerId, MapViewStyleStops, MapViewStyleStopsInteractiveLayerId, MapViewStyleStopsPrimaryLayerId, MapViewStyleVehicles, MapViewStyleVehiclesInteractiveLayerId, MapViewStyleVehiclesPrimaryLayerId, MeContextProvider, Menu, MultiSelect, NoDataLabel, NumberInput, Pane, PanesManager, PasswordInput, Popover, SearchInput, Section, SegmentedControl, Sidebar, SidebarContextProvider, SidebarItem, SidebarSubItem, Slider, Spacer, Surface, Switch, TMLogo, TMLogoDark, TMLogoLight, Tag, TagGroup, Text, TextInput, Textarea, ThemeContextProvider, ThemeDark, ThemeLight, ThemeSwitcher, Themer, Tooltip, accessorSearch, centerMap, getBaseGeoJsonFeatureCollection, getBaseGeoJsonFeatureLineString, moveMap, plainSearch, sidebarApps, useIsActiveDomain, useIsActivePage, useMapOptionsContext, useMeContext, useScreenSize, useSearch, useSidebarContext, useThemeContext, useToast };
|
|
871
|
-
export type { ButtonProps, CheckboxGroupProps, CheckboxProps, DataItem$1 as DataItem, DataTableColumn, DataTableProps, LabelProps, LoaderProps, MapStyle, NoDataLabelProps, NumberInputProps, PopoverDropdownProps, PopoverProps, PopoverTargetProps, SearchInputProps, SidebarItemProps, SidebarSubItemProps, SurfaceProps, TagGroupProps, TagProps, TextInputProps, TextProps, TextareaProps, ThemeType, ToastPromiseParams, ToastProps };
|
|
895
|
+
export { AVAILABLE_THEMES, AlertMessage, AppProvider, AppWrapper, BackButton, Badge, Button, CMIcon, CMLogo, Checkbox, Collapsible, ComboboxComponent as Combobox, ComponentWrapper, DataTable, DatePicker, DateTimePicker, DeleteButton, Description, Divider, ErrorDisplay, FileButton, FileUpload, FilterMenu, FilterMenuTarget, FiltersBar, Grid, HasPermission, Indicator, Label, Loader, LoadingOverlay, LockButton, MapOptionsContextProvider, MapView, MapViewStyleActiveStops, MapViewStyleActiveStopsInteractiveLayerId, MapViewStyleActiveStopsPrimaryLayerId, MapViewStylePath, MapViewStylePathInteractiveLayerId, MapViewStylePathPrimaryLayerId, MapViewStyleStops, MapViewStyleStopsInteractiveLayerId, MapViewStyleStopsPrimaryLayerId, MapViewStyleVehicles, MapViewStyleVehiclesInteractiveLayerId, MapViewStyleVehiclesPrimaryLayerId, MeContextProvider, Menu, MultiSelect, NoDataLabel, NumberInput, Pane, PanesManager, PasswordInput, Popover, SearchInput, Section, SegmentedControl, Sidebar, SidebarContextProvider, SidebarItem, SidebarSubItem, Slider, Spacer, Surface, Switch, TMLogo, TMLogoDark, TMLogoLight, Tag, TagGroup, Text, TextInput, Textarea, ThemeContextProvider, ThemeDark, ThemeLight, ThemeSwitcher, Themer, Tooltip, accessorSearch, centerMap, getBaseGeoJsonFeatureCollection, getBaseGeoJsonFeatureLineString, moveMap, plainSearch, sidebarApps, useIsActiveDomain, useIsActivePage, useMapOptionsContext, useMeContext, useScreenSize, useSearch, useSidebarContext, useThemeContext, useToast };
|
|
896
|
+
export type { ButtonProps, CheckboxGroupProps, CheckboxProps, DataItem$1 as DataItem, DataTableColumn, DataTableProps, FileButtonProps, LabelProps, LoaderProps, MapStyle, NoDataLabelProps, NumberInputProps, PopoverDropdownProps, PopoverProps, PopoverTargetProps, SearchInputProps, SidebarItemProps, SidebarSubItemProps, SurfaceProps, TagGroupProps, TagProps, TextInputProps, TextProps, TextareaProps, ThemeType, ToastPromiseParams, ToastProps };
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { Switch } from './src/components/common/Switch/index.js';
|
|
|
22
22
|
export { Tree, getTreeExpandedState, useTree } from '@mantine/core';
|
|
23
23
|
export { TextInput } from './src/components/inputs/TextInput/index.js';
|
|
24
24
|
export { DataTable } from './src/components/datatable/DataTable/index.js';
|
|
25
|
+
export { AlertMessage } from './src/components/display/AlertMessage/index.js';
|
|
25
26
|
export { ErrorDisplay } from './src/components/display/ErrorDisplay/index.js';
|
|
26
27
|
export { Indicator } from './src/components/display/Indicator/index.js';
|
|
27
28
|
export { Label } from './src/components/display/Label/index.js';
|
|
@@ -57,6 +58,8 @@ export { SidebarItem } from './src/components/sidebar/SidebarItem/index.js';
|
|
|
57
58
|
export { SidebarSubItem } from './src/components/sidebar/SidebarSubItem/index.js';
|
|
58
59
|
export { ThemeDark, ThemeLight, Themer } from './src/components/theme/Themer/index.js';
|
|
59
60
|
export { ThemeSwitcher } from './src/components/theme/ThemeSwitcher/index.js';
|
|
61
|
+
export { FileButton } from './src/components/upload/FileButton/index.js';
|
|
62
|
+
export { FileUpload } from './src/components/upload/FileUpload/index.js';
|
|
60
63
|
export { MapOptionsContextProvider, useMapOptionsContext } from './src/contexts/MapOptions.context.js';
|
|
61
64
|
export { MeContextProvider, useMeContext } from './src/contexts/Me.context.js';
|
|
62
65
|
export { SidebarContextProvider, useSidebarContext } from './src/contexts/Sidebar.context.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from '../../../../_virtual/jsx-runtime.js';
|
|
2
|
+
import { Alert } from '@mantine/core';
|
|
3
|
+
|
|
4
|
+
/* * */
|
|
5
|
+
function AlertMessage({ icon, message, title }) {
|
|
6
|
+
return (jsxRuntimeExports.jsx(Alert, { icon: icon, title: title, children: message }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { AlertMessage };
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/display/AlertMessage/index.tsx"],"sourcesContent":[null],"names":["_jsx","MantineAlert"],"mappings":";;;AAYA;AAEM,SAAU,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAqB,EAAA;AACvE,IAAA,QACCA,qBAAA,CAACC,KAAY,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAA,QAAA,EACpC,OAAO,EAAA,CACM;AAEjB;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { j as jsxRuntimeExports } from '../../../../_virtual/jsx-runtime.js';
|
|
3
|
+
import { Button } from '../../buttons/Button/index.js';
|
|
4
|
+
import { IconArrowBigUpLinesFilled } from '@tabler/icons-react';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
|
|
7
|
+
/* * */
|
|
8
|
+
function FileButton({ accept, disabled, icon, label, loading, onCancel, onFileChange }) {
|
|
9
|
+
//
|
|
10
|
+
//
|
|
11
|
+
// A. Setup variables
|
|
12
|
+
const [isLoading, setIsLoading] = useState(loading ?? false);
|
|
13
|
+
//
|
|
14
|
+
// B. Handle actions
|
|
15
|
+
const handleFileSelect = async () => {
|
|
16
|
+
setIsLoading(true);
|
|
17
|
+
const input = document.createElement('input');
|
|
18
|
+
input.type = 'file';
|
|
19
|
+
input.accept = accept ?? '';
|
|
20
|
+
input.onchange = (event) => {
|
|
21
|
+
const file = event.target.files?.[0];
|
|
22
|
+
if (file && onFileChange)
|
|
23
|
+
onFileChange(file);
|
|
24
|
+
setIsLoading(false);
|
|
25
|
+
};
|
|
26
|
+
input.oncancel = () => {
|
|
27
|
+
setIsLoading(false);
|
|
28
|
+
onCancel?.();
|
|
29
|
+
};
|
|
30
|
+
input.click();
|
|
31
|
+
};
|
|
32
|
+
//
|
|
33
|
+
// C. Render components
|
|
34
|
+
return (jsxRuntimeExports.jsx(Button, { disabled: disabled, icon: icon ?? jsxRuntimeExports.jsx(IconArrowBigUpLinesFilled, {}), label: label, loading: isLoading, onClick: handleFileSelect }));
|
|
35
|
+
//
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { FileButton };
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/upload/FileButton/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;AAoBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;SAEgB,UAAU,CAAC,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAAE,CAAA,CAAA,CAAA,CAAI,CAAA,CAAE,CAAA,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,CAC3C,CAAA,CAAA,CAAA,CAAA,CAAK,EAAE,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CACZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAE,SAAS,CAAA,CAClB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgB,EAAA,CACxB,CAAA;;AAIJ;;"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from '../../../../_virtual/jsx-runtime.js';
|
|
2
|
+
import 'clsx';
|
|
3
|
+
import 'luxon';
|
|
4
|
+
import '@mantine/core';
|
|
5
|
+
import { IconFileZip } from '@tabler/icons-react';
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
|
+
import 'react-viewport-list';
|
|
8
|
+
import ComponentWrapper from '../../common/ComponentWrapper/index.js';
|
|
9
|
+
import '@mantine/dates';
|
|
10
|
+
import '../../common/Menu/index.js';
|
|
11
|
+
import { Label } from '../../display/Label/index.js';
|
|
12
|
+
import { Section } from '../../layout/Section/index.js';
|
|
13
|
+
import '../../../contexts/Theme.context.js';
|
|
14
|
+
import '../../common/Checkbox/index.js';
|
|
15
|
+
import '../../../contexts/Me.context.js';
|
|
16
|
+
import '../../common/Popover/index.js';
|
|
17
|
+
import '@tmlmobilidade/lib';
|
|
18
|
+
import '../../sidebar/Sidebar/index.js';
|
|
19
|
+
import { FileButton } from '../FileButton/index.js';
|
|
20
|
+
import '@tmlmobilidade/utils';
|
|
21
|
+
import '@mantine/hooks';
|
|
22
|
+
import { useToast } from '../../../hooks/toast.js';
|
|
23
|
+
import '../../../hooks/use-screen-size.js';
|
|
24
|
+
|
|
25
|
+
function FileUpload({ accept, fileName, fileUrl, label, maxFileSize = 6 * 1024 * 1024, onFileChange }) {
|
|
26
|
+
//
|
|
27
|
+
//
|
|
28
|
+
// A. Setup variables
|
|
29
|
+
const [file, setFile] = useState(null);
|
|
30
|
+
const [preview, setPreview] = useState(fileUrl ?? null);
|
|
31
|
+
const [name, setName] = useState(fileName);
|
|
32
|
+
//
|
|
33
|
+
// B. Handle actions
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setPreview(fileUrl ?? null);
|
|
36
|
+
}, [fileUrl]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!fileName && file) {
|
|
39
|
+
setName(file.name);
|
|
40
|
+
}
|
|
41
|
+
}, [fileName, file]);
|
|
42
|
+
const handleFileChange = (file) => {
|
|
43
|
+
if (file.size > maxFileSize) {
|
|
44
|
+
useToast.error({
|
|
45
|
+
message: 'O tamanho do ficheiro excede o limite permitido.',
|
|
46
|
+
title: 'Ficheiro demasiado grande',
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setFile(file);
|
|
51
|
+
const reader = new FileReader();
|
|
52
|
+
reader.onload = () => setPreview(reader.result);
|
|
53
|
+
reader.readAsDataURL(file);
|
|
54
|
+
if (onFileChange)
|
|
55
|
+
onFileChange(file);
|
|
56
|
+
};
|
|
57
|
+
//
|
|
58
|
+
// C. Render components
|
|
59
|
+
return (jsxRuntimeExports.jsx(ComponentWrapper, { children: preview ? (jsxRuntimeExports.jsxs(Section, { alignItems: "center", gap: "sm", children: [jsxRuntimeExports.jsx(IconFileZip, { size: 52 }), jsxRuntimeExports.jsx(Label, { size: "sm", children: name })] })) : (jsxRuntimeExports.jsx(FileButton, { accept: accept, label: label ?? 'Selecionar ficheiro', onFileChange: handleFileChange })) }));
|
|
60
|
+
//
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { FileUpload };
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/upload/FileUpload/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"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C;AACrC,IAAA,CAAC;;;AAKD,IAAA,QACCA,qBAAA,CAAC,gBAAgB,EAAA,EAAA,QAAA,EACf,OAAO,IACPC,sBAAA,CAAC,OAAO,EAAA,EAAC,UAAU,EAAC,QAAQ,EAAC,GAAG,EAAC,IAAI,EAAA,QAAA,EAAA,CACpCD,qBAAA,CAAC,WAAW,EAAA,EAAC,IAAI,EAAE,EAAE,EAAA,CAAI,EACzBA,sBAAC,KAAK,EAAA,EAAC,IAAI,EAAC,IAAI,EAAA,QAAA,EAAE,IAAI,EAAA,CAAS,CAAA,EAAA,CACtB,KAEVA,qBAAA,CAAC,UAAU,IACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,IAAI,qBAAqB,EACrC,YAAY,EAAE,gBAAgB,EAAA,CAC7B,CACF,EAAA,CACiB;;AAIrB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmlmobilidade/ui",
|
|
3
3
|
"description": "UI components for Transportes Metropolitanos de Lisboa (TML) web applications.",
|
|
4
|
-
"version": "20250723.
|
|
4
|
+
"version": "20250723.2202.16",
|
|
5
5
|
"author": "João de Vasconcelos & Jusi Monteiro",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
7
7
|
"publishConfig": {
|