@tmlmobilidade/ui 20250122.1933.16 → 20250124.1545.56
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 +221 -145
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/index.d.ts +0 -1
- package/dist/cjs/types/src/hooks/toast.d.ts +64 -0
- package/dist/cjs/types/src/index.d.ts +1 -0
- package/dist/esm/index.js +222 -146
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/index.d.ts +0 -1
- package/dist/esm/types/src/hooks/toast.d.ts +64 -0
- package/dist/esm/types/src/index.d.ts +1 -0
- package/dist/index.d.ts +51 -32
- package/dist/styles.css +42 -102
- package/package.json +2 -1
- package/dist/cjs/types/src/components/authentication/LoginForm/index.d.ts +0 -45
- package/dist/cjs/types/src/components/authentication/LoginForm/use-login.d.ts +0 -8
- package/dist/cjs/types/src/components/authentication/index.d.ts +0 -1
- package/dist/esm/types/src/components/authentication/LoginForm/index.d.ts +0 -45
- package/dist/esm/types/src/components/authentication/LoginForm/use-login.d.ts +0 -8
- package/dist/esm/types/src/components/authentication/index.d.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -8,10 +8,9 @@ var luxon = require('luxon');
|
|
|
8
8
|
var iconsReact = require('@tabler/icons-react');
|
|
9
9
|
var dates = require('@mantine/dates');
|
|
10
10
|
var modals = require('@mantine/modals');
|
|
11
|
+
var notifications = require('@mantine/notifications');
|
|
11
12
|
var hooks = require('@mantine/hooks');
|
|
12
13
|
var reactViewportList = require('react-viewport-list');
|
|
13
|
-
var Cookies = require('js-cookie');
|
|
14
|
-
var coreTypes = require('@tmlmobilidade/core-types');
|
|
15
14
|
|
|
16
15
|
function _interopNamespaceDefault(e) {
|
|
17
16
|
var n = Object.create(null);
|
|
@@ -749,7 +748,7 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
749
748
|
|
|
750
749
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
751
750
|
|
|
752
|
-
var styles$
|
|
751
|
+
var styles$j = {"button":"styles-module_button__wVZ97","buttonLabel":"styles-module_buttonLabel__Ug8JX","primary":"styles-module_primary__v5fv1","secondary":"styles-module_secondary__0hxpR","muted":"styles-module_muted__fgyym","disabled":"styles-module_disabled__eVT3b","danger":"styles-module_danger__zdksP","info":"styles-module_info__JOafx","success":"styles-module_success__YS7oM","warning":"styles-module_warning__ZxzQE","active":"styles-module_active__BKRtv"};
|
|
753
752
|
|
|
754
753
|
/**
|
|
755
754
|
* Utility function that merges class names together
|
|
@@ -781,30 +780,30 @@ function getValueAtPath(obj, path) {
|
|
|
781
780
|
/* * */
|
|
782
781
|
function Component$4({ className, icon, children, onClick, target, type = 'button', variant = 'primary', disabled, textTransform = 'none', ...props }) {
|
|
783
782
|
//
|
|
784
|
-
const btnClass = cn(className, styles$
|
|
785
|
-
[styles$
|
|
786
|
-
[styles$
|
|
787
|
-
[styles$
|
|
788
|
-
[styles$
|
|
789
|
-
[styles$
|
|
790
|
-
[styles$
|
|
791
|
-
[styles$
|
|
792
|
-
[styles$
|
|
793
|
-
}, disabled && styles$
|
|
794
|
-
return (jsxRuntimeExports.jsx(core.Button, { className: btnClass, leftSection: icon && icon, onClick: onClick, type: type, variant: variant, disabled: disabled, classNames: { label: styles$
|
|
783
|
+
const btnClass = cn(className, styles$j.button, !disabled && {
|
|
784
|
+
[styles$j.danger]: variant === 'danger',
|
|
785
|
+
[styles$j.primary]: variant === 'primary',
|
|
786
|
+
[styles$j.secondary]: variant === 'secondary',
|
|
787
|
+
[styles$j.muted]: variant === 'muted',
|
|
788
|
+
[styles$j.info]: variant === 'info',
|
|
789
|
+
[styles$j.success]: variant === 'success',
|
|
790
|
+
[styles$j.warning]: variant === 'warning',
|
|
791
|
+
[styles$j.active]: variant === 'active',
|
|
792
|
+
}, disabled && styles$j.disabled);
|
|
793
|
+
return (jsxRuntimeExports.jsx(core.Button, { className: btnClass, leftSection: icon && icon, onClick: onClick, type: type, variant: variant, disabled: disabled, classNames: { label: styles$j.buttonLabel, ...props.classNames }, ...props, style: { textTransform: textTransform }, children: children }));
|
|
795
794
|
//
|
|
796
795
|
}
|
|
797
796
|
|
|
798
|
-
var styles$
|
|
797
|
+
var styles$i = {"inner":"styles-module_inner__d9DH7","input":"styles-module_input__rce0R","labelWrapper":"styles-module_labelWrapper__AGQzf","label":"styles-module_label__U404g","description":"styles-module_description__bkV5V","error":"styles-module_error__ZtPYT"};
|
|
799
798
|
|
|
800
799
|
function Checkbox(props) {
|
|
801
|
-
return jsxRuntimeExports.jsx(core.Checkbox, { classNames: { ...styles$
|
|
800
|
+
return jsxRuntimeExports.jsx(core.Checkbox, { classNames: { ...styles$i, ...props.classNames }, ...props });
|
|
802
801
|
}
|
|
803
802
|
|
|
804
|
-
var styles$
|
|
803
|
+
var styles$h = {"root":"styles-module_root__vNUQ9","indicator":"styles-module_indicator__0XMRf","label":"styles-module_label__Mf1Ea"};
|
|
805
804
|
|
|
806
805
|
function SegmentedControl({ ...props }) {
|
|
807
|
-
return jsxRuntimeExports.jsx(core.SegmentedControl, { ...props, classNames: styles$
|
|
806
|
+
return jsxRuntimeExports.jsx(core.SegmentedControl, { ...props, classNames: styles$h });
|
|
808
807
|
}
|
|
809
808
|
|
|
810
809
|
function Component$3({ error, validation, value, classNames, ...props }) {
|
|
@@ -858,7 +857,7 @@ function Component$1({ classNames, ...props }) {
|
|
|
858
857
|
return jsxRuntimeExports.jsx(core.Textarea, { classNames: classNames, ...props });
|
|
859
858
|
}
|
|
860
859
|
|
|
861
|
-
var styles$
|
|
860
|
+
var styles$g = {"wrapper":"styles-module_wrapper__7zsRX","input":"styles-module_input__kZP4l","placeholder":"styles-module_placeholder__uazW4","pillInputWrapper":"styles-module_pillInputWrapper__rtJzo","pillInputField":"styles-module_pillInputField__LYXhi","icon":"styles-module_icon__jXQ8R","pillClearButton":"styles-module_pillClearButton__RYrwJ","pill":"styles-module_pill__eWbVa","label":"styles-module_label__tB0Ce","description":"styles-module_description__KHjxV","dropdownWrapper":"styles-module_dropdownWrapper__guQYa"};
|
|
862
861
|
|
|
863
862
|
function Component({ multiple = false, searchable = false, autoComplete = false, onChange, data = [], clearable = false, label, description, ...props }) {
|
|
864
863
|
// A. Setup Variables
|
|
@@ -914,108 +913,108 @@ function Component({ multiple = false, searchable = false, autoComplete = false,
|
|
|
914
913
|
// D. Render Components
|
|
915
914
|
const renderClearButton = () => {
|
|
916
915
|
if (clearable && value && value.length > 0) {
|
|
917
|
-
return (jsxRuntimeExports.jsx(core.ActionIcon, { variant: "transparent", onClick: () => resetValue(), "aria-label": "Clear value", style: { cursor: 'pointer' }, className: styles$
|
|
916
|
+
return (jsxRuntimeExports.jsx(core.ActionIcon, { variant: "transparent", onClick: () => resetValue(), "aria-label": "Clear value", style: { cursor: 'pointer' }, className: styles$g.icon, children: jsxRuntimeExports.jsx(iconsReact.IconX, { size: 24 }) }));
|
|
918
917
|
}
|
|
919
|
-
return jsxRuntimeExports.jsx(iconsReact.IconCaretDownFilled, { size: 24, className: styles$
|
|
918
|
+
return jsxRuntimeExports.jsx(iconsReact.IconCaretDownFilled, { size: 24, className: styles$g.icon });
|
|
920
919
|
};
|
|
921
920
|
const renderValues = () => Array.isArray(value)
|
|
922
|
-
? value.map((item) => (jsxRuntimeExports.jsx(core.Pill, { className: styles$
|
|
921
|
+
? value.map((item) => (jsxRuntimeExports.jsx(core.Pill, { className: styles$g.pill, withRemoveButton: true, onRemove: () => removeValue(item), children: item }, item)))
|
|
923
922
|
: [];
|
|
924
923
|
const renderOptions = () => filterData().map((item) => (jsxRuntimeExports.jsx(core.Combobox.Option, { value: item, active: value?.includes?.(item), children: jsxRuntimeExports.jsxs(core.Group, { gap: "sm", children: [value?.includes?.(item) && jsxRuntimeExports.jsx(core.CheckIcon, { size: 12 }), jsxRuntimeExports.jsx("span", { children: item })] }) }, item)));
|
|
925
924
|
const renderInput = () => {
|
|
926
925
|
if (multiple) {
|
|
927
|
-
return (jsxRuntimeExports.jsx(core.Combobox.DropdownTarget, { children: jsxRuntimeExports.jsx(core.PillsInput, { onClick: () => combobox.openDropdown(), className: cn(styles$
|
|
926
|
+
return (jsxRuntimeExports.jsx(core.Combobox.DropdownTarget, { children: jsxRuntimeExports.jsx(core.PillsInput, { onClick: () => combobox.openDropdown(), className: cn(styles$g.input, styles$g.pillInputWrapper), children: jsxRuntimeExports.jsxs(core.Pill.Group, { style: { marginRight: '25px' }, children: [renderValues(), jsxRuntimeExports.jsx(core.Combobox.EventsTarget, { children: jsxRuntimeExports.jsx(core.PillsInput.Field, { style: { backgroundColor: 'transparent' }, type: searchable ? 'visible' : 'hidden', value: search, placeholder: "Search values", onFocus: () => combobox.openDropdown(), onBlur: () => combobox.closeDropdown(), onChange: handleSearchChange, onKeyDown: (event) => {
|
|
928
927
|
if (event.key === 'Backspace' &&
|
|
929
928
|
!search &&
|
|
930
929
|
Array.isArray(value) &&
|
|
931
930
|
value.length > 0) {
|
|
932
931
|
removeValue(value[value.length - 1] || '');
|
|
933
932
|
}
|
|
934
|
-
} }) }), jsxRuntimeExports.jsx("div", { className: styles$
|
|
933
|
+
} }) }), jsxRuntimeExports.jsx("div", { className: styles$g.pillClearButton, children: renderClearButton() })] }) }) }));
|
|
935
934
|
}
|
|
936
|
-
return (jsxRuntimeExports.jsx(core.Combobox.Target, { children: searchable ? (jsxRuntimeExports.jsx(core.InputBase, { className: styles$
|
|
935
|
+
return (jsxRuntimeExports.jsx(core.Combobox.Target, { children: searchable ? (jsxRuntimeExports.jsx(core.InputBase, { className: styles$g.input, type: "text", value: search, rightSection: renderClearButton(), rightSectionPointerEvents: value === null ? 'none' : 'all', onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), onBlur: () => {
|
|
937
936
|
combobox.closeDropdown();
|
|
938
937
|
setSearch(value?.toString() || '');
|
|
939
|
-
}, onChange: handleSearchChange, placeholder: "Search value" })) : (jsxRuntimeExports.jsx(core.InputBase, { className: styles$
|
|
938
|
+
}, onChange: handleSearchChange, placeholder: "Search value" })) : (jsxRuntimeExports.jsx(core.InputBase, { className: styles$g.input, component: "button", type: "button", pointer: true, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), onBlur: () => {
|
|
940
939
|
combobox.closeDropdown();
|
|
941
940
|
setSearch(value?.toString() || '');
|
|
942
|
-
}, rightSection: renderClearButton(), rightSectionPointerEvents: value === null ? 'none' : 'all', children: value || jsxRuntimeExports.jsx(core.Input.Placeholder, { className: styles$
|
|
941
|
+
}, rightSection: renderClearButton(), rightSectionPointerEvents: value === null ? 'none' : 'all', children: value || jsxRuntimeExports.jsx(core.Input.Placeholder, { className: styles$g.placeholder, children: "Pick value" }) })) }));
|
|
943
942
|
};
|
|
944
|
-
return (jsxRuntimeExports.jsxs("div", { className: styles$
|
|
943
|
+
return (jsxRuntimeExports.jsxs("div", { className: styles$g.wrapper, children: [label && jsxRuntimeExports.jsx("label", { className: styles$g.label, children: label }), description && jsxRuntimeExports.jsx("p", { className: styles$g.description, children: description }), jsxRuntimeExports.jsxs(core.Combobox, { store: combobox, onOptionSubmit: updateValue, withinPortal: false, children: [renderInput(), jsxRuntimeExports.jsx(core.Combobox.Dropdown, { className: styles$g.dropdownWrapper, children: jsxRuntimeExports.jsx(core.Combobox.Options, { children: renderOptions().length > 0 ? (renderOptions()) : (jsxRuntimeExports.jsx(core.Combobox.Empty, { children: "Nothing found..." })) }) })] })] }));
|
|
945
944
|
}
|
|
946
945
|
|
|
947
|
-
var styles$
|
|
946
|
+
var styles$f = {"button":"styles-module_button__fQIgs","fontxs":"styles-module_fontxs__c61kh","fontsm":"styles-module_fontsm__zi0bq","fontbase":"styles-module_fontbase__Uzeoy","fontlg":"styles-module_fontlg__TfMwu","fontxl":"styles-module_fontxl__4IxFS","tag":"styles-module_tag__HOLQE","pill":"styles-module_pill__VAXc-","fullWidth":"styles-module_fullWidth__zWbR4","primary":"styles-module_primary__HWgQU","secondary":"styles-module_secondary__UOKnw","muted":"styles-module_muted__fA0Fl","disabled":"styles-module_disabled__EKMKd","danger":"styles-module_danger__gZERs","info":"styles-module_info__b-gyN","success":"styles-module_success__mRhfk","warning":"styles-module_warning__G977Z","active":"styles-module_active__5pkXl"};
|
|
948
947
|
|
|
949
948
|
/* * */
|
|
950
949
|
function Badge({ className, icon, children, variant = 'primary', filled = false, fullWidth = false, disabled = false, type = 'tag', size = 'md', ...props }) {
|
|
951
950
|
//
|
|
952
|
-
const btnClass = cn(styles$
|
|
953
|
-
[styles$
|
|
954
|
-
[styles$
|
|
955
|
-
[styles$
|
|
956
|
-
[styles$
|
|
957
|
-
[styles$
|
|
958
|
-
[styles$
|
|
959
|
-
[styles$
|
|
960
|
-
[styles$
|
|
961
|
-
}, disabled && styles$
|
|
951
|
+
const btnClass = cn(styles$f.button, !disabled && {
|
|
952
|
+
[styles$f.danger]: variant === 'danger',
|
|
953
|
+
[styles$f.primary]: variant === 'primary',
|
|
954
|
+
[styles$f.secondary]: variant === 'secondary',
|
|
955
|
+
[styles$f.muted]: variant === 'muted',
|
|
956
|
+
[styles$f.info]: variant === 'info',
|
|
957
|
+
[styles$f.success]: variant === 'success',
|
|
958
|
+
[styles$f.warning]: variant === 'warning',
|
|
959
|
+
[styles$f.active]: variant === 'active',
|
|
960
|
+
}, disabled && styles$f.disabled, type === 'pill' && styles$f.pill, type === 'tag' && styles$f.tag, fullWidth && styles$f.fullWidth, styles$f[`font${size}`], className);
|
|
962
961
|
return (jsxRuntimeExports.jsx(core.Badge, { leftSection: icon, className: btnClass, ...props, "data-active": filled, children: children }));
|
|
963
962
|
//
|
|
964
963
|
}
|
|
965
964
|
|
|
966
|
-
var styles$
|
|
965
|
+
var styles$e = {"tooltip":"styles-module_tooltip__HFS4I"};
|
|
967
966
|
|
|
968
967
|
function Tooltip({ children, ...props }) {
|
|
969
|
-
return jsxRuntimeExports.jsx(core.Tooltip, { classNames: { ...styles$
|
|
968
|
+
return jsxRuntimeExports.jsx(core.Tooltip, { classNames: { ...styles$e, ...props.classNames }, ...props, children: children });
|
|
970
969
|
}
|
|
971
970
|
|
|
972
|
-
var styles$
|
|
971
|
+
var styles$d = {"inner":"styles-module_inner__xu0uv","track":"styles-module_track__xeUYf","input":"styles-module_input__DyZyB","labelWrapper":"styles-module_labelWrapper__XNVsq","label":"styles-module_label__PsGVs","description":"styles-module_description__qLTxA","error":"styles-module_error__sQ6n-"};
|
|
973
972
|
|
|
974
973
|
function Switch({ classNames, ...props }) {
|
|
975
|
-
return jsxRuntimeExports.jsx(core.Switch, { classNames: { ...styles$
|
|
974
|
+
return jsxRuntimeExports.jsx(core.Switch, { classNames: { ...styles$d, ...classNames }, ...props });
|
|
976
975
|
}
|
|
977
976
|
|
|
978
|
-
var styles$
|
|
977
|
+
var styles$c = {"thumb":"styles-module_thumb__PE26N","track":"styles-module_track__kkjfP","bar":"styles-module_bar__3e8BW","mark":"styles-module_mark__Wxc6d"};
|
|
979
978
|
|
|
980
979
|
function Slider({ classNames, ...props }) {
|
|
981
|
-
return jsxRuntimeExports.jsx(core.Slider, { classNames: { ...styles$
|
|
980
|
+
return jsxRuntimeExports.jsx(core.Slider, { classNames: { ...styles$c, ...classNames }, ...props });
|
|
982
981
|
}
|
|
983
982
|
|
|
984
|
-
var styles$
|
|
983
|
+
var styles$b = {"button":"styles-module_button__ngo3Q","primary":"styles-module_primary__1Forr","secondary":"styles-module_secondary__F-Pxy","muted":"styles-module_muted__IRFQC","disabled":"styles-module_disabled__Q0YEb","danger":"styles-module_danger__-aPaa","info":"styles-module_info__z1XFz","success":"styles-module_success__V-kNZ","warning":"styles-module_warning__gGAPU","active":"styles-module_active__0bskK"};
|
|
985
984
|
|
|
986
985
|
function ActionIcon({ children, className, disabled, variant, ...props }) {
|
|
987
|
-
const btnClass = cn(className, styles$
|
|
988
|
-
[styles$
|
|
989
|
-
[styles$
|
|
990
|
-
[styles$
|
|
991
|
-
[styles$
|
|
992
|
-
[styles$
|
|
993
|
-
[styles$
|
|
994
|
-
[styles$
|
|
995
|
-
[styles$
|
|
996
|
-
}, disabled && styles$
|
|
986
|
+
const btnClass = cn(className, styles$b.button, !disabled && {
|
|
987
|
+
[styles$b.danger]: variant === 'danger',
|
|
988
|
+
[styles$b.primary]: variant === 'primary',
|
|
989
|
+
[styles$b.secondary]: variant === 'secondary',
|
|
990
|
+
[styles$b.muted]: variant === 'muted',
|
|
991
|
+
[styles$b.info]: variant === 'info',
|
|
992
|
+
[styles$b.success]: variant === 'success',
|
|
993
|
+
[styles$b.warning]: variant === 'warning',
|
|
994
|
+
[styles$b.active]: variant === 'active',
|
|
995
|
+
}, disabled && styles$b.disabled);
|
|
997
996
|
return (jsxRuntimeExports.jsx(core.ActionIcon, { className: btnClass, ...props, children: children }));
|
|
998
997
|
}
|
|
999
998
|
|
|
1000
|
-
var styles$
|
|
999
|
+
var styles$a = {"dropdown":"styles-module_dropdown__wzdfT","arrow":"styles-module_arrow__pmKfn"};
|
|
1001
1000
|
|
|
1002
1001
|
function Menu(props) {
|
|
1003
|
-
return jsxRuntimeExports.jsx(core.Menu, { ...props, classNames: { arrow: styles$
|
|
1002
|
+
return jsxRuntimeExports.jsx(core.Menu, { ...props, classNames: { arrow: styles$a.arrow } });
|
|
1004
1003
|
}
|
|
1005
1004
|
Menu.Target = function MenuTarget(props) {
|
|
1006
1005
|
return jsxRuntimeExports.jsx(core.Menu.Target, { ...props });
|
|
1007
1006
|
};
|
|
1008
1007
|
Menu.Dropdown = function MenuDropdown(props) {
|
|
1009
|
-
return jsxRuntimeExports.jsx(core.Menu.Dropdown, { ...props, className: styles$
|
|
1008
|
+
return jsxRuntimeExports.jsx(core.Menu.Dropdown, { ...props, className: styles$a.dropdown });
|
|
1010
1009
|
};
|
|
1011
1010
|
Menu.Item = function MenuItem(props) {
|
|
1012
|
-
return jsxRuntimeExports.jsx(core.Menu.Item, { ...props, className: styles$
|
|
1011
|
+
return jsxRuntimeExports.jsx(core.Menu.Item, { ...props, className: styles$a.item });
|
|
1013
1012
|
};
|
|
1014
1013
|
Menu.Divider = function MenuDivider(props) {
|
|
1015
|
-
return jsxRuntimeExports.jsx(core.Menu.Divider, { ...props, className: styles$
|
|
1014
|
+
return jsxRuntimeExports.jsx(core.Menu.Divider, { ...props, className: styles$a.divider });
|
|
1016
1015
|
};
|
|
1017
1016
|
Menu.Label = function MenuLabel(props) {
|
|
1018
|
-
return jsxRuntimeExports.jsx(core.Menu.Label, { ...props, className: styles$
|
|
1017
|
+
return jsxRuntimeExports.jsx(core.Menu.Label, { ...props, className: styles$a.label });
|
|
1019
1018
|
};
|
|
1020
1019
|
|
|
1021
1020
|
var TextInputOverride = {"input":"text-input-module_input__9C3ID","wrapper":"text-input-module_wrapper__jrJs0","variantWhite":"text-input-module_variantWhite__M5THF","section":"text-input-module_section__uYM8p","sizeSm":"text-input-module_sizeSm__9YY9u","label":"text-input-module_label__sLogM","description":"text-input-module_description__hPkID"};
|
|
@@ -1097,7 +1096,7 @@ function ThemeProvider({ children, initialTheme }) {
|
|
|
1097
1096
|
}), [currentTheme]);
|
|
1098
1097
|
//
|
|
1099
1098
|
// C. Render components
|
|
1100
|
-
return (jsxRuntimeExports.jsx(ThemeContext.Provider, { value: contextValue, children: jsxRuntimeExports.jsx(core.MantineProvider, { defaultColorScheme: "auto", theme: theme, children: jsxRuntimeExports.jsx(dates.DatesProvider, { settings: mantineDatesSettings, children: jsxRuntimeExports.
|
|
1099
|
+
return (jsxRuntimeExports.jsx(ThemeContext.Provider, { value: contextValue, children: jsxRuntimeExports.jsx(core.MantineProvider, { defaultColorScheme: "auto", theme: theme, children: jsxRuntimeExports.jsx(dates.DatesProvider, { settings: mantineDatesSettings, children: jsxRuntimeExports.jsxs(modals.ModalsProvider, { children: [jsxRuntimeExports.jsx(notifications.Notifications, { styles: { root: { marginTop: '60px' } } }), children] }) }) }) }));
|
|
1101
1100
|
}
|
|
1102
1101
|
|
|
1103
1102
|
function useTheme() {
|
|
@@ -1108,7 +1107,7 @@ function useTheme() {
|
|
|
1108
1107
|
return context;
|
|
1109
1108
|
}
|
|
1110
1109
|
|
|
1111
|
-
var styles$
|
|
1110
|
+
var styles$9 = {"dropdown":"styles-module_dropdown__9W7AN"};
|
|
1112
1111
|
|
|
1113
1112
|
/* * */
|
|
1114
1113
|
const getCssVariableValue = (variableName) => {
|
|
@@ -1143,7 +1142,7 @@ function ThemeSwitcher({ onThemeChange }) {
|
|
|
1143
1142
|
onThemeChange?.(theme);
|
|
1144
1143
|
};
|
|
1145
1144
|
// Render the primary colors
|
|
1146
|
-
return (jsxRuntimeExports.jsxs(core.Menu, { classNames: styles$
|
|
1145
|
+
return (jsxRuntimeExports.jsxs(core.Menu, { classNames: styles$9, children: [jsxRuntimeExports.jsx(core.Menu.Target, { children: jsxRuntimeExports.jsx("div", { style: { cursor: 'pointer' }, children: jsxRuntimeExports.jsx(core.ColorSwatch, { color: themeColors[theme] }) }) }), jsxRuntimeExports.jsx(core.Menu.Dropdown, { children: THEMES.map((t) => (jsxRuntimeExports.jsx(core.Menu.Item, { value: t, children: jsxRuntimeExports.jsx(core.ColorSwatch, { color: themeColors[t], onClick: () => handleThemeChange(t) }) }, t))) })] }));
|
|
1147
1146
|
}
|
|
1148
1147
|
|
|
1149
1148
|
/**
|
|
@@ -1193,44 +1192,44 @@ function TMLogo() {
|
|
|
1193
1192
|
return (jsxRuntimeExports.jsx(Themer, { dark: jsxRuntimeExports.jsx(TMLogoDark, {}), light: jsxRuntimeExports.jsx(TMLogoLight, {}) }));
|
|
1194
1193
|
}
|
|
1195
1194
|
|
|
1196
|
-
var styles$
|
|
1195
|
+
var styles$8 = {"container":"styles-module_container__u-Ao-","hAlignstart":"styles-module_hAlignstart__Poz-6","hAligncenter":"styles-module_hAligncenter__-8-PQ","hAlignend":"styles-module_hAlignend__9-hiG","vAlignstart":"styles-module_vAlignstart__UHr2W","vAligncenter":"styles-module_vAligncenter__AI3ka","vAlignend":"styles-module_vAlignend__Ufwik","gapnone":"styles-module_gapnone__yv7lm","gapxs":"styles-module_gapxs__qCDUv","gapsm":"styles-module_gapsm__9Pnop","gapmd":"styles-module_gapmd__9lCqV","gaplg":"styles-module_gaplg__kvQt9","gapxl":"styles-module_gapxl__5-mrY","a":"styles-module_a__NDsdd","aab":"styles-module_aab__xvehZ","ab":"styles-module_ab__JtDDA","abb":"styles-module_abb__jlnJf","abc":"styles-module_abc__XRK-M","abcd":"styles-module_abcd__3jl83"};
|
|
1197
1196
|
|
|
1198
1197
|
/* * */
|
|
1199
1198
|
function Grid({ children, className, columns = 'a', hAlign = 'start', vAlign = 'start', gap = 'none', ...props }) {
|
|
1200
|
-
return (jsxRuntimeExports.jsx("div", { className: cn(styles$
|
|
1199
|
+
return (jsxRuntimeExports.jsx("div", { className: cn(styles$8.container, styles$8[columns], styles$8[`hAlign${hAlign}`], styles$8[`vAlign${vAlign}`], styles$8[`gap${gap}`], className), ...props, children: children }));
|
|
1201
1200
|
}
|
|
1202
1201
|
|
|
1203
|
-
var styles$
|
|
1202
|
+
var styles$7 = {"titleWrapper":"styles-module_titleWrapper__PzdlG","title":"styles-module_title__hJPfo","description":"styles-module_description__b9iYX","control":"styles-module_control__WpPBD","chevron":"styles-module_chevron__ow73h","icon":"styles-module_icon__ut-ws"};
|
|
1204
1203
|
|
|
1205
1204
|
function Section({ title, description, icon, children, titleAs = 'h2', }) {
|
|
1206
1205
|
//
|
|
1207
1206
|
// B. Render Component
|
|
1208
1207
|
const renderControl = () => {
|
|
1209
|
-
return (jsxRuntimeExports.jsxs("div", { className: styles$
|
|
1208
|
+
return (jsxRuntimeExports.jsxs("div", { className: styles$7.titleWrapper, children: [icon && icon, React.createElement(titleAs, { className: styles$7.title }, title), description && jsxRuntimeExports.jsx("p", { className: styles$7.description, children: description })] }));
|
|
1210
1209
|
};
|
|
1211
|
-
return (jsxRuntimeExports.jsx(core.Accordion, { classNames: styles$
|
|
1210
|
+
return (jsxRuntimeExports.jsx(core.Accordion, { classNames: styles$7, chevron: jsxRuntimeExports.jsx(iconsReact.IconCaretLeftFilled, { className: styles$7.icon }), children: jsxRuntimeExports.jsxs(core.Accordion.Item, { value: "section", children: [jsxRuntimeExports.jsx(core.Accordion.Control, { children: renderControl() }), jsxRuntimeExports.jsx(core.Accordion.Panel, { children: children })] }) }));
|
|
1212
1211
|
}
|
|
1213
1212
|
|
|
1214
|
-
var styles$
|
|
1213
|
+
var styles$6 = {"sizexs":"styles-module_sizexs__f81Qf","sizesm":"styles-module_sizesm__cOyRy","sizemd":"styles-module_sizemd__uYu-S","sizelg":"styles-module_sizelg__CdAjx","sizexl":"styles-module_sizexl__tWmKz","size2xl":"styles-module_size2xl__Rtw-9","size3xl":"styles-module_size3xl__kvrLp","size4xl":"styles-module_size4xl__aJHXX","orientationvertical":"styles-module_orientationvertical__ktvLu","orientationhorizontal":"styles-module_orientationhorizontal__LyAb1"};
|
|
1215
1214
|
|
|
1216
1215
|
function Spacer({ size, orientation, className }) {
|
|
1217
1216
|
const sizeClass = `size${size}`;
|
|
1218
1217
|
const orientationClass = `orientation${orientation}`;
|
|
1219
|
-
return (jsxRuntimeExports.jsx("div", { className: cn(styles$
|
|
1218
|
+
return (jsxRuntimeExports.jsx("div", { className: cn(styles$6[sizeClass], styles$6[orientationClass], className), style: {
|
|
1220
1219
|
minHeight: orientation === 'horizontal' ? '100%' : undefined,
|
|
1221
1220
|
} }));
|
|
1222
1221
|
}
|
|
1223
1222
|
|
|
1224
|
-
var styles$
|
|
1223
|
+
var styles$5 = {"root":"styles-module_root__Rhx1c","surface":"styles-module_surface__kO8HP","borderRadius-none":"styles-module_borderRadius-none__HBRpR","borderRadius-sm":"styles-module_borderRadius-sm__73-nw","borderRadius-md":"styles-module_borderRadius-md__2-luz","borderRadius-lg":"styles-module_borderRadius-lg__oEtfh","borderRadius-xl":"styles-module_borderRadius-xl__ZDDZc","padding-none":"styles-module_padding-none__eO-gr","padding-sm":"styles-module_padding-sm__5MvKx","padding-md":"styles-module_padding-md__0Asee","padding-lg":"styles-module_padding-lg__1fB8Q","padding-xl":"styles-module_padding-xl__lBM42","divider":"styles-module_divider__Pwhgc","default":"styles-module_default__Ty9eo","primary":"styles-module_primary__AirHO","secondary":"styles-module_secondary__Kw0cY","gap-none":"styles-module_gap-none__P8puF","gap-sm":"styles-module_gap-sm__0DQmT","gap-md":"styles-module_gap-md__HYXte","gap-lg":"styles-module_gap-lg__dhDB3","gap-xl":"styles-module_gap-xl__fa4pK"};
|
|
1225
1224
|
|
|
1226
1225
|
function Surface({ children, classNames, borderRadius = 'none', padding = 'none', gap = 'none', divider = false, flexDirection = 'column', variant = 'default', justifyContent = 'start', alignItems = 'start', ...props }) {
|
|
1227
|
-
const rootClass = cn(styles$
|
|
1228
|
-
const dividerClass = cn(styles$
|
|
1229
|
-
const surfaceClass = cn(styles$
|
|
1226
|
+
const rootClass = cn(styles$5.root, classNames?.root);
|
|
1227
|
+
const dividerClass = cn(styles$5.divider, !divider && 'hidden', styles$5[`borderRadius-${borderRadius}`], classNames?.divider);
|
|
1228
|
+
const surfaceClass = cn(styles$5.surface, styles$5[`borderRadius-${borderRadius}`], styles$5[`padding-${padding}`], styles$5[variant], styles$5[`gap-${gap}`], classNames?.surface);
|
|
1230
1229
|
return (jsxRuntimeExports.jsxs("div", { className: rootClass, ...props, children: [jsxRuntimeExports.jsx("div", { className: surfaceClass, style: { justifyContent, alignItems, flexDirection }, children: children }), jsxRuntimeExports.jsx("div", { className: dividerClass })] }));
|
|
1231
1230
|
}
|
|
1232
1231
|
|
|
1233
|
-
var styles$
|
|
1232
|
+
var styles$4 = {"container":"styles-module_container__tduxg","navWrapper":"styles-module_navWrapper__Xb59N","navButton":"styles-module_navButton__kTv0k","selected":"styles-module_selected__w-GVG"};
|
|
1234
1233
|
|
|
1235
1234
|
function useIsActivePage(href) {
|
|
1236
1235
|
if (typeof window === 'undefined')
|
|
@@ -1251,15 +1250,15 @@ function useIsActivePage(href) {
|
|
|
1251
1250
|
function Sidebar({ items, classNames }) {
|
|
1252
1251
|
//
|
|
1253
1252
|
// A. Render components
|
|
1254
|
-
return (jsxRuntimeExports.jsx("div", { className: cn(styles$
|
|
1253
|
+
return (jsxRuntimeExports.jsx("div", { className: cn(styles$4.container, classNames?.container), children: jsxRuntimeExports.jsx("div", { className: cn(styles$4.navWrapper, classNames?.navWrapper), children: items.map((item) => {
|
|
1255
1254
|
return item.permission ? (jsxRuntimeExports.jsx(SidebarItem, { href: item.href, icon: item.icon, label: item.label }, item.href)) : (jsxRuntimeExports.jsx(SidebarItem, { href: item.href, icon: item.icon, label: item.label }, item.href));
|
|
1256
1255
|
}) }) }));
|
|
1257
1256
|
//
|
|
1258
1257
|
}
|
|
1259
1258
|
function SidebarItem({ href, icon, label, classNames, }) {
|
|
1260
1259
|
const isActive = useIsActivePage(href);
|
|
1261
|
-
return (jsxRuntimeExports.jsx(core.Tooltip, { label: label, position: "right", children: jsxRuntimeExports.jsx("a", { href: href, children: jsxRuntimeExports.jsx(core.ActionIcon, { className: cn(styles$
|
|
1262
|
-
[styles$
|
|
1260
|
+
return (jsxRuntimeExports.jsx(core.Tooltip, { label: label, position: "right", children: jsxRuntimeExports.jsx("a", { href: href, children: jsxRuntimeExports.jsx(core.ActionIcon, { className: cn(styles$4.navButton, classNames?.navButton, {
|
|
1261
|
+
[styles$4.selected]: isActive,
|
|
1263
1262
|
}), color: "gray", size: "xl", children: icon }) }) }));
|
|
1264
1263
|
}
|
|
1265
1264
|
|
|
@@ -1389,7 +1388,7 @@ function useDataTableContext() {
|
|
|
1389
1388
|
return context;
|
|
1390
1389
|
}
|
|
1391
1390
|
|
|
1392
|
-
var styles$
|
|
1391
|
+
var styles$3 = {"header":"styles-module_header__6dpaJ","cell":"styles-module_cell__mfzlU","cellContent":"styles-module_cellContent__NO9HT","row":"styles-module_row__0kxC4"};
|
|
1393
1392
|
|
|
1394
1393
|
/* * */
|
|
1395
1394
|
function DataTableHeader({ columns, }) {
|
|
@@ -1403,21 +1402,21 @@ function DataTableHeader({ columns, }) {
|
|
|
1403
1402
|
return null;
|
|
1404
1403
|
return (jsxRuntimeExports.jsx(ActionIcon, { variant: "muted", children: sortState?.accessor === column.accessor ? (sortState.order === 'asc' ? (jsxRuntimeExports.jsx(iconsReact.IconArrowUpRhombus, { size: 18 })) : sortState.order === 'desc' ? (jsxRuntimeExports.jsx(iconsReact.IconArrowDownRhombus, { size: 18 })) : (jsxRuntimeExports.jsx(iconsReact.IconArrowsUpDown, { size: 18 }))) : (jsxRuntimeExports.jsx(iconsReact.IconArrowsUpDown, { size: 18 })) }));
|
|
1405
1404
|
};
|
|
1406
|
-
return (jsxRuntimeExports.jsx(core.Table.Thead, { className: cn(styles$
|
|
1405
|
+
return (jsxRuntimeExports.jsx(core.Table.Thead, { className: cn(styles$3.header), children: jsxRuntimeExports.jsx(core.Table.Tr, { className: cn(styles$3.row), children: columns.map((column, idx) => (jsxRuntimeExports.jsx(core.Table.Th, { className: cn(styles$3.cell), children: jsxRuntimeExports.jsxs("div", { className: styles$3.cellContent, onClick: () => column.sortable &&
|
|
1407
1406
|
handleSort(column.sortKey ?? String(column.accessor)), children: [column.title, column.sortable && renderSortIcon(column)] }) }, idx))) }) }));
|
|
1408
1407
|
}
|
|
1409
1408
|
|
|
1410
|
-
var styles$
|
|
1409
|
+
var styles$2 = {"row":"styles-module_row__46pHv","cell":"styles-module_cell__Yb-lZ"};
|
|
1411
1410
|
|
|
1412
1411
|
function DataTableRow({ columns, record, }) {
|
|
1413
|
-
return (jsxRuntimeExports.jsx(core.Table.Tr, { className: cn(styles$
|
|
1412
|
+
return (jsxRuntimeExports.jsx(core.Table.Tr, { className: cn(styles$2.row), children: columns.map((column, colIndex) => (jsxRuntimeExports.jsx(core.Table.Td, { className: cn(styles$2.cell), children: column.render
|
|
1414
1413
|
? column.render(record)
|
|
1415
1414
|
: getValueAtPath(record, column.accessor) === null
|
|
1416
1415
|
? null
|
|
1417
1416
|
: String(getValueAtPath(record, column.accessor)) }, colIndex))) }));
|
|
1418
1417
|
}
|
|
1419
1418
|
|
|
1420
|
-
var styles$
|
|
1419
|
+
var styles$1 = {"root":"styles-module_root__2WSxN","title":"styles-module_title__qCJZG","item":"styles-module_item__yl--3","itemsWrapper":"styles-module_itemsWrapper__8xwKJ"};
|
|
1421
1420
|
|
|
1422
1421
|
function DataTableTitle({ search, title }) {
|
|
1423
1422
|
//
|
|
@@ -1432,10 +1431,10 @@ function DataTableTitle({ search, title }) {
|
|
|
1432
1431
|
};
|
|
1433
1432
|
//
|
|
1434
1433
|
// C. Render Components
|
|
1435
|
-
return (jsxRuntimeExports.jsxs("div", { className: styles$
|
|
1434
|
+
return (jsxRuntimeExports.jsxs("div", { className: styles$1.root, children: [jsxRuntimeExports.jsx("div", { className: styles$1.title, children: title && title }), search && !search.hidden && (jsxRuntimeExports.jsx("div", { className: styles$1.filters, children: jsxRuntimeExports.jsx(Component$3, { onChange: handleSearchChange, placeholder: search.placeholder, value: searchQuery }) }))] }));
|
|
1436
1435
|
}
|
|
1437
1436
|
|
|
1438
|
-
var styles
|
|
1437
|
+
var styles = {"root":"styles-module_root__AStX6","tableWrapper":"styles-module_tableWrapper__ByR84","table":"styles-module_table__IKm6A","body":"styles-module_body__Ou1Rp"};
|
|
1439
1438
|
|
|
1440
1439
|
function DataTable({ records, ...props }) {
|
|
1441
1440
|
return (jsxRuntimeExports.jsx(DataTableProvider, { initialRecords: records, searchAccessors: props.search?.accessors ?? [], children: jsxRuntimeExports.jsx(DataTableContent, { ...props }) }));
|
|
@@ -1447,63 +1446,7 @@ function DataTableContent({ classnames, columns, maxHeight, search, title, }) {
|
|
|
1447
1446
|
const { data } = useDataTableContext();
|
|
1448
1447
|
//
|
|
1449
1448
|
// B. Render Components
|
|
1450
|
-
return (jsxRuntimeExports.jsxs("div", { className: cn(styles
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
var styles = {"header":"styles-module_header__4P5BD","headerContent":"styles-module_headerContent__D-SOV","headerTitle":"styles-module_headerTitle__WltM4","headerDescription":"styles-module_headerDescription__QJ7PA","headerImage":"styles-module_headerImage__XF2xY","form":"styles-module_form__19X8o","formFooter":"styles-module_formFooter__txTAr","formFooterLinks":"styles-module_formFooterLinks__55jsp","formButton":"styles-module_formButton__pOMY2"};
|
|
1454
|
-
|
|
1455
|
-
function useLogin(authUrl) {
|
|
1456
|
-
const [loading, setLoading] = React.useState(false);
|
|
1457
|
-
const [error, setError] = React.useState(null);
|
|
1458
|
-
const login = async (credentials) => {
|
|
1459
|
-
setLoading(true);
|
|
1460
|
-
setError(null);
|
|
1461
|
-
try {
|
|
1462
|
-
const response = await fetch(authUrl, {
|
|
1463
|
-
method: 'POST',
|
|
1464
|
-
headers: {
|
|
1465
|
-
'Content-Type': 'application/json',
|
|
1466
|
-
},
|
|
1467
|
-
body: JSON.stringify(credentials),
|
|
1468
|
-
});
|
|
1469
|
-
if (!response.ok) {
|
|
1470
|
-
const errorData = await response.json();
|
|
1471
|
-
throw new Error(errorData.message || 'Authentication failed');
|
|
1472
|
-
}
|
|
1473
|
-
const data = await response.json();
|
|
1474
|
-
const token = data.token;
|
|
1475
|
-
if (token) {
|
|
1476
|
-
Cookies.set('sessionToken', token.token, { expires: token.expires_at }); // TODO: Add Domain
|
|
1477
|
-
}
|
|
1478
|
-
else {
|
|
1479
|
-
throw new Error('Token not found in response');
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
catch (err) {
|
|
1483
|
-
setError(err.message || 'An unexpected error occurred');
|
|
1484
|
-
}
|
|
1485
|
-
finally {
|
|
1486
|
-
setLoading(false);
|
|
1487
|
-
}
|
|
1488
|
-
};
|
|
1489
|
-
return { login, loading, error };
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
function LoginForm({ authUrl, classNames, footerLinks, title, description, buttonLabel = 'Login', buttonIcon = jsxRuntimeExports.jsx(iconsReact.IconArrowRight, { size: 20 }), }) {
|
|
1493
|
-
//
|
|
1494
|
-
// A. Define Variables
|
|
1495
|
-
const { login, loading } = useLogin(authUrl);
|
|
1496
|
-
const [username, setUsername] = React.useState('');
|
|
1497
|
-
const [password, setPassword] = React.useState('');
|
|
1498
|
-
//
|
|
1499
|
-
// B. Define Functions
|
|
1500
|
-
const handleSubmit = async (event) => {
|
|
1501
|
-
event.preventDefault();
|
|
1502
|
-
await login({ email: coreTypes.createEmail(username), password });
|
|
1503
|
-
};
|
|
1504
|
-
//
|
|
1505
|
-
// A. Render Components
|
|
1506
|
-
return (jsxRuntimeExports.jsxs(Surface, { padding: "md", className: cn(styles.root, classNames?.root), children: [jsxRuntimeExports.jsxs("div", { className: cn(styles.header, classNames?.header), children: [jsxRuntimeExports.jsxs("div", { className: cn(styles.headerContent, classNames?.headerContent), children: [jsxRuntimeExports.jsx("div", { className: cn(styles.headerTitle, classNames?.headerTitle), children: title }), jsxRuntimeExports.jsx("div", { className: styles.headerDescription, children: description })] }), jsxRuntimeExports.jsx("div", { className: cn(styles.headerImage, classNames?.headerImage), children: jsxRuntimeExports.jsx(TMLogo, {}) })] }), jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className: cn(styles.form, classNames?.form), children: [jsxRuntimeExports.jsx(Component$3, { placeholder: "Email", value: username, onChange: (e) => setUsername(e.target.value) }), jsxRuntimeExports.jsx(Component$2, { placeholder: "Password", value: password, onChange: (e) => setPassword(e.target.value) }), jsxRuntimeExports.jsxs("div", { className: cn(styles.formFooter, classNames?.formFooter), children: [jsxRuntimeExports.jsxs(Component$4, { loading: loading, type: "submit", variant: "primary", textTransform: "uppercase", className: cn(styles.formButton, classNames?.formButton), children: [buttonIcon, " ", buttonLabel] }), jsxRuntimeExports.jsx("div", { className: cn(styles.formFooterLinks, classNames?.formFooterLinks), children: footerLinks })] })] })] }));
|
|
1449
|
+
return (jsxRuntimeExports.jsxs("div", { className: cn(styles.root, classnames?.root), children: [jsxRuntimeExports.jsx(DataTableTitle, { search: search, title: title ?? '' }), jsxRuntimeExports.jsx("div", { className: cn(styles.tableWrapper, classnames?.tableWrapper), style: { maxHeight: maxHeight || '100%' }, children: jsxRuntimeExports.jsxs(core.Table, { className: cn(styles.table, classnames?.table, 'block'), children: [jsxRuntimeExports.jsx(DataTableHeader, { columns: columns }), jsxRuntimeExports.jsx(core.Table.Tbody, { children: jsxRuntimeExports.jsx(reactViewportList.ViewportList, { itemMargin: 0, items: data.records, children: (record, rowIndex) => (jsxRuntimeExports.jsx(DataTableRow, { columns: columns, record: record }, rowIndex)) }) })] }) })] }));
|
|
1507
1450
|
}
|
|
1508
1451
|
|
|
1509
1452
|
const MOBILE_BREAKPOINT = parseInt(getCssVariableValue('--breakpoint-mobile') ?? '768');
|
|
@@ -1524,6 +1467,139 @@ function useScreenSize() {
|
|
|
1524
1467
|
return screenSize;
|
|
1525
1468
|
}
|
|
1526
1469
|
|
|
1470
|
+
/* eslint-disable @stylistic/no-mixed-spaces-and-tabs */
|
|
1471
|
+
class Toast {
|
|
1472
|
+
/**
|
|
1473
|
+
* Hides all toasts
|
|
1474
|
+
*/
|
|
1475
|
+
clean() {
|
|
1476
|
+
notifications.notifications.clean();
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Shows an error toast
|
|
1480
|
+
* @param props - The toast props
|
|
1481
|
+
*/
|
|
1482
|
+
error(props) {
|
|
1483
|
+
return this.show({
|
|
1484
|
+
...props,
|
|
1485
|
+
type: 'error',
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Hides specific toast
|
|
1490
|
+
* @param id - The toast id
|
|
1491
|
+
*/
|
|
1492
|
+
hide(id) {
|
|
1493
|
+
notifications.notifications.hide(id);
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Shows an info toast
|
|
1497
|
+
* @param props - The toast props
|
|
1498
|
+
*/
|
|
1499
|
+
info(props) {
|
|
1500
|
+
return this.show({
|
|
1501
|
+
...props,
|
|
1502
|
+
type: 'info',
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Shows a loading toast
|
|
1507
|
+
* @param props - The toast props
|
|
1508
|
+
*/
|
|
1509
|
+
loading(props) {
|
|
1510
|
+
return this.show({
|
|
1511
|
+
...props,
|
|
1512
|
+
loading: true,
|
|
1513
|
+
type: 'info',
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Promise wrapper for toast
|
|
1518
|
+
* @param promise - The promise to be wrapped
|
|
1519
|
+
* @param statusMessages - The status messages for the promise
|
|
1520
|
+
*/
|
|
1521
|
+
promise(promise, { error, pending, success }) {
|
|
1522
|
+
// If the promise is not a Promise instance, show the success message immediately
|
|
1523
|
+
if (!(promise instanceof Promise)) {
|
|
1524
|
+
this.success({
|
|
1525
|
+
message: success,
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
const notifyPromise = typeof promise === 'function' ? promise() : promise;
|
|
1529
|
+
const id = this.loading({
|
|
1530
|
+
message: pending,
|
|
1531
|
+
});
|
|
1532
|
+
notifyPromise.then((result) => {
|
|
1533
|
+
console.log('result', result);
|
|
1534
|
+
this.update(id, {
|
|
1535
|
+
color: 'green',
|
|
1536
|
+
loading: false,
|
|
1537
|
+
message: success,
|
|
1538
|
+
});
|
|
1539
|
+
return result;
|
|
1540
|
+
}).catch((err) => {
|
|
1541
|
+
console.log('err', err);
|
|
1542
|
+
this.update(id, {
|
|
1543
|
+
color: 'red',
|
|
1544
|
+
loading: false,
|
|
1545
|
+
message: err.message,
|
|
1546
|
+
title: error,
|
|
1547
|
+
});
|
|
1548
|
+
return error;
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Shows a toast
|
|
1553
|
+
* @param props - The toast props
|
|
1554
|
+
*/
|
|
1555
|
+
show(props) {
|
|
1556
|
+
const color = props.color
|
|
1557
|
+
|| (props.type === 'error' && 'red')
|
|
1558
|
+
|| (props.type === 'info' && 'blue')
|
|
1559
|
+
|| (props.type === 'success' && 'green')
|
|
1560
|
+
|| (props.type === 'warning' && 'orange')
|
|
1561
|
+
|| undefined;
|
|
1562
|
+
return notifications.notifications.show({
|
|
1563
|
+
color: color,
|
|
1564
|
+
mt: 10,
|
|
1565
|
+
position: props.position || 'top-right',
|
|
1566
|
+
...props,
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Shows a success toast
|
|
1571
|
+
* @param props - The toast props
|
|
1572
|
+
*/
|
|
1573
|
+
success(props) {
|
|
1574
|
+
return this.show({
|
|
1575
|
+
...props,
|
|
1576
|
+
type: 'success',
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Updates a toast given its id
|
|
1581
|
+
* @param id - The toast id
|
|
1582
|
+
* @param props - The toast props
|
|
1583
|
+
*/
|
|
1584
|
+
update(id, props) {
|
|
1585
|
+
notifications.notifications.update({
|
|
1586
|
+
id,
|
|
1587
|
+
...props,
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Shows a warning toast
|
|
1592
|
+
* @param props - The toast props
|
|
1593
|
+
*/
|
|
1594
|
+
warning(props) {
|
|
1595
|
+
return this.show({
|
|
1596
|
+
...props,
|
|
1597
|
+
type: 'warning',
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
const useToast = new Toast();
|
|
1602
|
+
|
|
1527
1603
|
exports.ActionIcon = ActionIcon;
|
|
1528
1604
|
exports.Badge = Badge;
|
|
1529
1605
|
exports.Button = Component$4;
|
|
@@ -1533,7 +1609,6 @@ exports.Checkbox = Checkbox;
|
|
|
1533
1609
|
exports.Combobox = Component;
|
|
1534
1610
|
exports.DataTable = DataTable;
|
|
1535
1611
|
exports.Grid = Grid;
|
|
1536
|
-
exports.LoginForm = LoginForm;
|
|
1537
1612
|
exports.Menu = Menu;
|
|
1538
1613
|
exports.PasswordInput = Component$2;
|
|
1539
1614
|
exports.Section = Section;
|
|
@@ -1556,6 +1631,7 @@ exports.Themer = Themer;
|
|
|
1556
1631
|
exports.Tooltip = Tooltip;
|
|
1557
1632
|
exports.useScreenSize = useScreenSize;
|
|
1558
1633
|
exports.useTheme = useTheme;
|
|
1634
|
+
exports.useToast = useToast;
|
|
1559
1635
|
Object.keys(hooks).forEach(function (k) {
|
|
1560
1636
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1561
1637
|
enumerable: true,
|