@starasia/admin 1.0.0
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/components/ActionMenu/components/ButtonDefault.d.ts +6 -0
- package/dist/components/ActionMenu/index.d.ts +28 -0
- package/dist/components/AdvanceFilter/components/Chip.d.ts +13 -0
- package/dist/components/AdvanceFilter/components/Container.d.ts +13 -0
- package/dist/components/AdvanceFilter/components/Field.d.ts +34 -0
- package/dist/components/AdvanceFilter/components/Form.d.ts +0 -0
- package/dist/components/AdvanceFilter/components/Group.d.ts +0 -0
- package/dist/components/AdvanceFilter/components/Header.d.ts +11 -0
- package/dist/components/AdvanceFilter/components/Toggle.d.ts +7 -0
- package/dist/components/AdvanceFilter/hooks.d.ts +48 -0
- package/dist/components/AdvanceFilter/index.d.ts +7 -0
- package/dist/components/AdvanceFilter/types.d.ts +27 -0
- package/dist/components/AdvanceFilter/utils.d.ts +10 -0
- package/dist/components/AsideBar/index.d.ts +8 -0
- package/dist/components/AuthLayout/index.d.ts +8 -0
- package/dist/components/ContentLayout/index.d.ts +10 -0
- package/dist/components/DashboardLayout/index.d.ts +33 -0
- package/dist/components/DecisionWrapper/index.d.ts +11 -0
- package/dist/components/EachUtils/index.d.ts +6 -0
- package/dist/components/FloatingFooter/index.d.ts +14 -0
- package/dist/components/Form/ToggleStatus.d.ts +20 -0
- package/dist/components/Form/components/ActionButton.d.ts +15 -0
- package/dist/components/Form/components/CheckBoxOptions.d.ts +27 -0
- package/dist/components/Form/components/Custom.d.ts +21 -0
- package/dist/components/Form/components/ErrorMessage.d.ts +7 -0
- package/dist/components/Form/components/FormTitle.d.ts +7 -0
- package/dist/components/Form/components/InputDate.d.ts +22 -0
- package/dist/components/Form/components/InputDropdown.d.ts +24 -0
- package/dist/components/Form/components/InputImgFile.d.ts +21 -0
- package/dist/components/Form/components/InputSingleFile.d.ts +20 -0
- package/dist/components/Form/components/InputText.d.ts +23 -0
- package/dist/components/Form/components/InputTextArea.d.ts +21 -0
- package/dist/components/Form/components/RadioOptions.d.ts +28 -0
- package/dist/components/Form/components/TextFormLabel.d.ts +7 -0
- package/dist/components/Form/components/ToggleForm.d.ts +22 -0
- package/dist/components/Form/components/index.d.ts +13 -0
- package/dist/components/Form/index.d.ts +149 -0
- package/dist/components/Header/MenuSelectButton.d.ts +16 -0
- package/dist/components/Header/MobileBottomDrawer.d.ts +9 -0
- package/dist/components/Header/PhotoProfile.d.ts +11 -0
- package/dist/components/Header/hooks.d.ts +4 -0
- package/dist/components/Header/index.d.ts +37 -0
- package/dist/components/HorizontalField/components/Field.d.ts +5 -0
- package/dist/components/HorizontalField/components/FieldGroup.d.ts +10 -0
- package/dist/components/HorizontalField/index.d.ts +11 -0
- package/dist/components/HorizontalField/types.d.ts +12 -0
- package/dist/components/HorizontalField/utils.d.ts +3 -0
- package/dist/components/InputFile/FilledField.d.ts +11 -0
- package/dist/components/InputFile/InitialField.d.ts +12 -0
- package/dist/components/InputFile/index.d.ts +19 -0
- package/dist/components/InputFile/utils.d.ts +2 -0
- package/dist/components/InputImage/index.d.ts +27 -0
- package/dist/components/InputImage/utils.d.ts +12 -0
- package/dist/components/ModalDialog/index.d.ts +12 -0
- package/dist/components/PageLayout/index.d.ts +33 -0
- package/dist/components/Pressable/index.d.ts +6 -0
- package/dist/components/RightDrawer/index.d.ts +18 -0
- package/dist/components/ScrollToTopButton/index.d.ts +5 -0
- package/dist/components/Section/index.d.ts +25 -0
- package/dist/components/SelectButton/index.d.ts +13 -0
- package/dist/components/Sidebar/components/Group.d.ts +9 -0
- package/dist/components/Sidebar/components/Item.d.ts +13 -0
- package/dist/components/Sidebar/components/Provider.d.ts +5 -0
- package/dist/components/Sidebar/components/Wrapper.d.ts +10 -0
- package/dist/components/Sidebar/context.d.ts +32 -0
- package/dist/components/Sidebar/hooks.d.ts +4 -0
- package/dist/components/Sidebar/index.d.ts +15 -0
- package/dist/components/Sidebar/types.d.ts +18 -0
- package/dist/components/SwitchApps/drawer/AppCard.d.ts +14 -0
- package/dist/components/SwitchApps/drawer/index-v2.d.ts +13 -0
- package/dist/components/SwitchApps/drawer/index.d.ts +16 -0
- package/dist/components/SwitchApps/index.d.ts +15 -0
- package/dist/components/SwitchApps/types.d.ts +18 -0
- package/dist/components/Typography/index.d.ts +22 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/entries/App/context.d.ts +16 -0
- package/dist/entries/App/hooks.d.ts +10 -0
- package/dist/entries/App/index.d.ts +22 -0
- package/dist/entries/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useAuthRole.d.ts +35 -0
- package/dist/hooks/useDynamicTitle.d.ts +7 -0
- package/dist/hooks/useRouteParams.d.ts +49 -0
- package/dist/hooks/useTabState.d.ts +8 -0
- package/dist/index.cjs.js +12816 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.es.js +51531 -0
- package/dist/index.umd.js +12816 -0
- package/dist/style.css +1 -0
- package/dist/types/auth.d.ts +31 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/formatter.d.ts +11 -0
- package/dist/utils/handler.d.ts +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/regex.d.ts +5 -0
- package/dist/utils/styles.d.ts +18 -0
- package/dist/utils/texts.d.ts +2 -0
- package/dist/utils/url.d.ts +0 -0
- package/dist/utils/validator.d.ts +8 -0
- package/package.json +73 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AppAccessModel, OrganizationAccessModel } from '../types';
|
|
3
|
+
|
|
4
|
+
interface DrawerSwitchAppsProps {
|
|
5
|
+
show: boolean;
|
|
6
|
+
onHide: () => void;
|
|
7
|
+
dataApps?: AppAccessModel[];
|
|
8
|
+
dataOrgs?: OrganizationAccessModel[];
|
|
9
|
+
totalData?: number;
|
|
10
|
+
handleSwitch?: (appKey: string, organizationId?: string, item?: AppAccessModel) => void;
|
|
11
|
+
setSelectedApp: (item: string) => void;
|
|
12
|
+
handleToSelectOrg?: (item: AppAccessModel) => void;
|
|
13
|
+
isLoadingOrgList?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const DrawerSwitchApps: React.FC<DrawerSwitchAppsProps>;
|
|
16
|
+
export default DrawerSwitchApps;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AppAccessModel, OrganizationAccessModel } from './types';
|
|
3
|
+
|
|
4
|
+
interface SwitchAppsProps {
|
|
5
|
+
dataApp?: AppAccessModel[];
|
|
6
|
+
dataOrg?: OrganizationAccessModel[];
|
|
7
|
+
totalData?: number;
|
|
8
|
+
handleSwitch?: (appKey: string, organizationId?: string) => void;
|
|
9
|
+
handleToSelectOrg?: (item: AppAccessModel) => void;
|
|
10
|
+
isLoadingOrg?: boolean;
|
|
11
|
+
variant?: "single-api" | "multi-api";
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const SwitchApps: ({ totalData, dataApp, dataOrg, handleSwitch, handleToSelectOrg, isLoadingOrg, variant, isLoading, }: SwitchAppsProps) => React.JSX.Element;
|
|
15
|
+
export * from './types';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AppAccessModel {
|
|
2
|
+
id: number | string;
|
|
3
|
+
name: string;
|
|
4
|
+
applicationKey: string;
|
|
5
|
+
isTenant: boolean;
|
|
6
|
+
role?: Role;
|
|
7
|
+
organizations?: OrganizationAccessModel[];
|
|
8
|
+
}
|
|
9
|
+
export interface OrganizationAccessModel {
|
|
10
|
+
id: number | string;
|
|
11
|
+
name: string;
|
|
12
|
+
role: Role;
|
|
13
|
+
}
|
|
14
|
+
interface Role {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TextProps } from '@starasia/text';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
props?: Omit<TextProps, "children" | "fontSize" | "fontWeight" | "variant">;
|
|
7
|
+
}
|
|
8
|
+
export declare const Typography: {
|
|
9
|
+
H1: (props: Props) => React.JSX.Element;
|
|
10
|
+
H2: (props: Props) => React.JSX.Element;
|
|
11
|
+
H3: (props: Props) => React.JSX.Element;
|
|
12
|
+
H4: (props: Props) => React.JSX.Element;
|
|
13
|
+
H5: (props: Props) => React.JSX.Element;
|
|
14
|
+
H6: (props: Props) => React.JSX.Element;
|
|
15
|
+
SubH1: (props: Props) => React.JSX.Element;
|
|
16
|
+
SubH2: (props: Props) => React.JSX.Element;
|
|
17
|
+
SubH3: (props: Props) => React.JSX.Element;
|
|
18
|
+
Body1: (props: Props) => React.JSX.Element;
|
|
19
|
+
Body2: (props: Props) => React.JSX.Element;
|
|
20
|
+
Body3: (props: Props) => React.JSX.Element;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './AuthLayout';
|
|
2
|
+
export * from './ContentLayout';
|
|
3
|
+
export * from './DashboardLayout';
|
|
4
|
+
export * from './Header';
|
|
5
|
+
export * from './HorizontalField';
|
|
6
|
+
export * from './ModalDialog';
|
|
7
|
+
export * from './PageLayout';
|
|
8
|
+
export * from './Pressable';
|
|
9
|
+
export * from './RightDrawer';
|
|
10
|
+
export * from './Section';
|
|
11
|
+
export * from './Sidebar';
|
|
12
|
+
export * from './ActionMenu';
|
|
13
|
+
export * from './AdvanceFilter';
|
|
14
|
+
export * from './EachUtils';
|
|
15
|
+
export * from './DecisionWrapper';
|
|
16
|
+
export * from './SwitchApps';
|
|
17
|
+
export * from './Form';
|
|
18
|
+
export * from './InputFile';
|
|
19
|
+
export * from './Typography';
|
|
20
|
+
export * from './ScrollToTopButton';
|
|
21
|
+
export * from './InputImage';
|
|
22
|
+
export * from './AsideBar';
|
|
23
|
+
export * from './FloatingFooter';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HeaderButtonProps, SidebarMenuItem, SidebarMenus, HeaderUserData } from '../../components';
|
|
2
|
+
import { MenuSelectButtonProps } from '../../components/Header/MenuSelectButton';
|
|
3
|
+
|
|
4
|
+
export interface AppContextValue {
|
|
5
|
+
menus: SidebarMenus;
|
|
6
|
+
menuBottom?: SidebarMenuItem[];
|
|
7
|
+
userData: HeaderUserData | null;
|
|
8
|
+
setUserData: (value: HeaderUserData) => void;
|
|
9
|
+
logo: string;
|
|
10
|
+
headerButtons?: HeaderButtonProps[];
|
|
11
|
+
headerButtonsLeft?: HeaderButtonProps[];
|
|
12
|
+
menuSelectButtons?: MenuSelectButtonProps[];
|
|
13
|
+
menuSelectCustom?: React.ReactNode;
|
|
14
|
+
bottomDrawerContent?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const AppContext: import('react').Context<AppContextValue>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HeaderUserData } from '../../components';
|
|
2
|
+
|
|
3
|
+
export declare const useApp: () => import('./context').AppContextValue;
|
|
4
|
+
export interface UseAppStateProps {
|
|
5
|
+
initialUserData?: HeaderUserData | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const useAppState: (props?: UseAppStateProps) => {
|
|
8
|
+
userData: HeaderUserData | null;
|
|
9
|
+
setUserData: import('react').Dispatch<import('react').SetStateAction<HeaderUserData | null>>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { HeaderButtonProps, HeaderUserData, SidebarMenuItem, SidebarMenus } from '../../components';
|
|
3
|
+
import { ThemeObject } from '@starasia/theme';
|
|
4
|
+
import { MenuSelectButtonProps } from '../../components/Header/MenuSelectButton';
|
|
5
|
+
|
|
6
|
+
interface AppProps extends PropsWithChildren {
|
|
7
|
+
router: React.ReactNode;
|
|
8
|
+
menus: SidebarMenus;
|
|
9
|
+
menuBottom?: SidebarMenuItem[];
|
|
10
|
+
logo: string;
|
|
11
|
+
theme?: ThemeObject;
|
|
12
|
+
headerButtons?: HeaderButtonProps[];
|
|
13
|
+
initialUserData?: HeaderUserData | null;
|
|
14
|
+
headerButtonsLeft?: HeaderButtonProps[];
|
|
15
|
+
menuSelectButtons?: MenuSelectButtonProps[];
|
|
16
|
+
menuSelectCustom?: React.ReactNode;
|
|
17
|
+
bottomDrawerContent?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const AppComponent: ({ router, menus, menuBottom, logo, initialUserData, theme, headerButtons, headerButtonsLeft, menuSelectButtons, menuSelectCustom, bottomDrawerContent, }: AppProps) => React.JSX.Element;
|
|
20
|
+
export declare const App: React.MemoExoticComponent<({ router, menus, menuBottom, logo, initialUserData, theme, headerButtons, headerButtonsLeft, menuSelectButtons, menuSelectCustom, bottomDrawerContent, }: AppProps) => React.JSX.Element>;
|
|
21
|
+
export * from './hooks';
|
|
22
|
+
export * from './context';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './App';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AccessPayload } from '../types';
|
|
2
|
+
|
|
3
|
+
export interface AuthRoleConfig<T extends Record<string, string>> {
|
|
4
|
+
decodedAccessToken: AccessPayload | null;
|
|
5
|
+
role: T;
|
|
6
|
+
}
|
|
7
|
+
export type RoleKey<T extends Record<string, string>> = keyof T;
|
|
8
|
+
type SnakeToCamel<S extends string> = S extends `${infer F}_${infer R}` ? `${Capitalize<Lowercase<F>>}${SnakeToCamel<R>}` : Capitalize<Lowercase<S>>;
|
|
9
|
+
type RoleFlags<T extends Record<string, string>> = {
|
|
10
|
+
[K in keyof T as `is${SnakeToCamel<K & string>}`]: boolean;
|
|
11
|
+
};
|
|
12
|
+
type UseAuthRoleReturn<T extends Record<string, string>> = RoleFlags<T> & {
|
|
13
|
+
hasRole: (role: keyof T) => boolean;
|
|
14
|
+
getRoleKey: () => string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Generic hook untuk role-based access
|
|
18
|
+
*
|
|
19
|
+
* Example:
|
|
20
|
+
*
|
|
21
|
+
* import { APP_CONFIG } from "@core/configs/app";
|
|
22
|
+
*
|
|
23
|
+
* const ROLE_CODE = {
|
|
24
|
+
* OWNER: APP_CONFIG.role.owner,
|
|
25
|
+
* PRODUCT_MANAGER: APP_CONFIG.role.productManager,
|
|
26
|
+
* FINANCE: APP_CONFIG.role.finance,
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* const { isOwner, isFinance, hasRole, getRoleKey } = useAuthRole({
|
|
30
|
+
* decodedAccessToken: decodedAccessToken,
|
|
31
|
+
* role: ROLE_CODE,
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
export declare function useAuthRole<T extends Record<string, string>>(config: AuthRoleConfig<T>): UseAuthRoleReturn<T>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useSearchParams } from 'react-router-dom';
|
|
2
|
+
|
|
3
|
+
type UseRouteParamsReturn = {
|
|
4
|
+
setSearchParams: ReturnType<typeof useSearchParams>[1];
|
|
5
|
+
searchParams: URLSearchParams;
|
|
6
|
+
searchQueries: Record<string, string>;
|
|
7
|
+
isHasQuery: (key: string, value: string) => boolean;
|
|
8
|
+
getQueryParam: (key: string) => string | null;
|
|
9
|
+
getRouteParam: (key: string) => string | undefined;
|
|
10
|
+
params: Record<string, string | undefined>;
|
|
11
|
+
id?: string;
|
|
12
|
+
hasId: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Custom hook untuk mengakses dan memodifikasi **route params** (`useParams`)
|
|
16
|
+
* dan **query params** (`useSearchParams`) dalam satu utilitas.
|
|
17
|
+
*
|
|
18
|
+
* Cocok digunakan ketika ingin membaca parameter dari URL
|
|
19
|
+
* (misalnya `/users/:id?tab=profile`) secara konsisten.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Route: /users/123?tab=profile&filter=active
|
|
23
|
+
* const {
|
|
24
|
+
* id,
|
|
25
|
+
* hasId,
|
|
26
|
+
* getRouteParam,
|
|
27
|
+
* getQueryParam,
|
|
28
|
+
* isHasQuery,
|
|
29
|
+
* setSearchParams,
|
|
30
|
+
* searchQueries
|
|
31
|
+
* } = useRouteParams();
|
|
32
|
+
*
|
|
33
|
+
* console.log(id); // "123"
|
|
34
|
+
* console.log(hasId); // true
|
|
35
|
+
* console.log(getRouteParam("id")); // "123"
|
|
36
|
+
*
|
|
37
|
+
* // query params
|
|
38
|
+
* console.log(getQueryParam("tab")); // "profile"
|
|
39
|
+
* console.log(isHasQuery("filter", "active")); // true
|
|
40
|
+
*
|
|
41
|
+
* // searchQueries → object hasil parsing query string
|
|
42
|
+
* console.log(searchQueries);
|
|
43
|
+
* // { tab: "profile", filter: "active" }
|
|
44
|
+
*
|
|
45
|
+
* // Update query param
|
|
46
|
+
* setSearchParams({ tab: "settings" });
|
|
47
|
+
*/
|
|
48
|
+
export declare const useRouteParams: () => UseRouteParamsReturn;
|
|
49
|
+
export {};
|