@tmlmobilidade/ui 20250305.1754.42 → 20250305.1816.36
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/cjs/index.js +26 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/layout/Sidebar/index.d.ts +1 -1
- package/dist/cjs/types/src/hooks/use-is-active-domain.d.ts +1 -0
- package/dist/cjs/types/src/lib/generate-icon.d.ts +1 -0
- package/dist/esm/index.js +16 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/layout/Sidebar/index.d.ts +1 -1
- package/dist/esm/types/src/hooks/use-is-active-domain.d.ts +1 -0
- package/dist/esm/types/src/lib/generate-icon.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/styles.css +4 -0
- package/package.json +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
export declare function useIsActiveDomain(domain: string): boolean;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function generateIcon(name: string): React.ReactNode;
|
package/dist/esm/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use client';
|
2
2
|
import * as React from 'react';
|
3
|
-
import React__default, { createContext, useState, useEffect, useMemo, useContext, useCallback } from 'react';
|
3
|
+
import React__default, { createContext, useState, useEffect, useMemo, useContext, useCallback, createElement } from 'react';
|
4
4
|
import { clsx } from 'clsx';
|
5
5
|
import { DateTime } from 'luxon';
|
6
6
|
import { ActionIcon as ActionIcon$1, createTheme, TextInput, Textarea, PasswordInput as PasswordInput$1, Button as Button$1, MantineProvider, Menu as Menu$1, ColorSwatch, Badge as Badge$1, Checkbox as Checkbox$1, useCombobox, Combobox, Group, CheckIcon, PillsInput, Pill, InputBase, Input, SegmentedControl as SegmentedControl$1, Slider as Slider$1, Switch as Switch$1, Text as Text$1, Tooltip as Tooltip$1, Center, rem, Table, Accordion } from '@mantine/core';
|
@@ -9,6 +9,7 @@ import { DatesProvider, DateTimePicker as DateTimePicker$1 } from '@mantine/date
|
|
9
9
|
import { ModalsProvider, modals as modals$1 } from '@mantine/modals';
|
10
10
|
export * from '@mantine/modals';
|
11
11
|
import { Notifications, notifications } from '@mantine/notifications';
|
12
|
+
import * as Icon from '@tabler/icons-react';
|
12
13
|
import { IconX, IconCaretDownFilled, IconCalendar, IconTrash, IconUpload, IconEye, IconEyeClosed, IconInfoCircle, IconArrowUpRhombus, IconArrowDownRhombus, IconArrowsUpDown, IconSettings, IconLogin, IconCaretLeftFilled } from '@tabler/icons-react';
|
13
14
|
import { ViewportList } from 'react-viewport-list';
|
14
15
|
import { useDebouncedValue } from '@mantine/hooks';
|
@@ -1542,15 +1543,12 @@ function DataTableContent({ classnames, columns, maxHeight, onRowClick, onRowCon
|
|
1542
1543
|
return (jsxRuntimeExports.jsxs("div", { className: cn(styles$8.root, classnames?.root), children: [jsxRuntimeExports.jsx(DataTableTitle, { search: search, title: title ?? '' }), jsxRuntimeExports.jsx("div", { className: cn(styles$8.tableWrapper, classnames?.tableWrapper), style: { maxHeight: maxHeight || '100%' }, children: jsxRuntimeExports.jsxs(Table, { className: cn(styles$8.table, classnames?.table, 'block'), children: [jsxRuntimeExports.jsx(DataTableHeader, { columns: columns }), jsxRuntimeExports.jsx(Table.Tbody, { children: jsxRuntimeExports.jsx(ViewportList, { itemMargin: 0, items: data.records, children: (record, rowIndex) => (jsxRuntimeExports.jsx(DataTableRow, { columns: columns, onRowClick: onRowClick, onRowContextMenu: onRowContextMenu, onRowDoubleClick: onRowDoubleClick, record: record }, rowIdAccessor ? getValueAtPath(record, rowIdAccessor) : rowIndex)) }) })] }) })] }));
|
1543
1544
|
}
|
1544
1545
|
|
1545
|
-
function
|
1546
|
+
function useIsActiveDomain(domain) {
|
1546
1547
|
const [isActive, setIsActive] = useState(false);
|
1547
1548
|
useEffect(() => {
|
1548
1549
|
const handleRouteChange = () => {
|
1549
|
-
const
|
1550
|
-
if (
|
1551
|
-
setIsActive(true);
|
1552
|
-
}
|
1553
|
-
else if (href && pathname.includes(href) && href !== '/') {
|
1550
|
+
const currentDomain = window.location.hostname;
|
1551
|
+
if (domain === currentDomain) {
|
1554
1552
|
setIsActive(true);
|
1555
1553
|
}
|
1556
1554
|
else {
|
@@ -1566,10 +1564,18 @@ function useIsActivePage(href) {
|
|
1566
1564
|
window.removeEventListener('pushState', handleRouteChange);
|
1567
1565
|
window.removeEventListener('replaceState', handleRouteChange);
|
1568
1566
|
};
|
1569
|
-
}, [
|
1567
|
+
}, [domain]);
|
1570
1568
|
return isActive;
|
1571
1569
|
}
|
1572
1570
|
|
1571
|
+
function generateIcon(name) {
|
1572
|
+
const IconComponent = Icon[name];
|
1573
|
+
if (!IconComponent) {
|
1574
|
+
return null;
|
1575
|
+
}
|
1576
|
+
return createElement(IconComponent);
|
1577
|
+
}
|
1578
|
+
|
1573
1579
|
var styles$7 = {"container":"styles-module_container__tduxg","navWrapper":"styles-module_navWrapper__Xb59N","navButton":"styles-module_navButton__kTv0k","selected":"styles-module_selected__w-GVG","disabled":"styles-module_disabled__lxQjN"};
|
1574
1580
|
|
1575
1581
|
function Sidebar({ items, }) {
|
@@ -1582,11 +1588,11 @@ function Sidebar({ items, }) {
|
|
1582
1588
|
//
|
1583
1589
|
}
|
1584
1590
|
function SidebarItem({ classNames, disabled, href, icon, label, }) {
|
1585
|
-
const isActive =
|
1591
|
+
const isActive = useIsActiveDomain(href);
|
1586
1592
|
return (jsxRuntimeExports.jsx(Tooltip$1, { label: label, position: "right", children: jsxRuntimeExports.jsx("a", { href: href, children: jsxRuntimeExports.jsx(ActionIcon$1, { size: "xl", className: cn(styles$7.navButton, classNames?.navButton, {
|
1587
1593
|
[styles$7.disabled]: disabled,
|
1588
1594
|
[styles$7.selected]: isActive,
|
1589
|
-
}), children: icon }) }) }));
|
1595
|
+
}), children: typeof icon === 'string' ? generateIcon(icon) : icon }) }) }));
|
1590
1596
|
}
|
1591
1597
|
|
1592
1598
|
/* * */
|