hisd3-ui-kit 1.0.0 → 2.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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hisd3-ui-kit",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "A UI kit for HISD3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "build": "tsc",
9
+ "build": "rollup -c",
10
10
  "start": "webpack serve"
11
11
  },
12
12
  "repository": {
@@ -15,18 +15,36 @@
15
15
  },
16
16
  "author": "HISD3",
17
17
  "license": "MIT",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ },
23
+ "./Sidebar": {
24
+ "import": "./dist/components/Sidebar/index.js",
25
+ "types": "./dist/components/Sidebar/index.d.ts"
26
+ }
27
+ },
28
+ "sideEffects": false,
18
29
  "dependencies": {
19
30
  "@ant-design/icons": "^6.0.0",
20
31
  "@ant-design/pro-components": "^2.6.10",
32
+ "@rollup/plugin-terser": "^0.4.4",
21
33
  "antd": "^5.24.8",
22
34
  "react": "18",
23
35
  "react-dom": "18",
24
36
  "styled-components": "^6.1.17"
25
37
  },
26
38
  "devDependencies": {
39
+ "@rollup/plugin-commonjs": "^28.0.3",
40
+ "@rollup/plugin-node-resolve": "^16.0.1",
41
+ "@rollup/plugin-typescript": "^12.1.2",
27
42
  "@types/react": "^19.1.2",
28
43
  "@types/react-dom": "^19.1.2",
29
44
  "mini-css-extract-plugin": "^2.9.2",
45
+ "rollup": "^4.40.1",
46
+ "rollup-plugin-dts": "^6.2.1",
47
+ "rollup-plugin-peer-deps-external": "^2.2.4",
30
48
  "terser-webpack-plugin": "^5.3.14",
31
49
  "typescript": "^5.8.3"
32
50
  },
@@ -1,109 +0,0 @@
1
- import styled from "styled-components";
2
- import { Avatar, List } from "antd";
3
-
4
- export const StyledDropdownList = styled(List)`
5
- & .ant-list-item {
6
- padding: 5px 12px;
7
- cursor: pointer;
8
- }
9
- `;
10
-
11
- export const StyledCrUserInfo = styled.div`
12
- background-color: transparent;
13
- padding: 7px 12px;
14
- height: 56px;
15
- display: flex;
16
- flex-direction: column;
17
- justify-content: center;
18
- transition: all 0.2s ease;
19
-
20
- @media screen and (min-width: ${({ theme }) => theme.breakpoints.md}px) {
21
- padding-top: 10px;
22
- padding-bottom: 10px;
23
- height: 71px;
24
- }
25
-
26
- & .ant-dropdown-link {
27
- color: inherit;
28
-
29
- & .anticon {
30
- font-size: ${({ theme }) => theme.font.size.sm};
31
- }
32
- }
33
-
34
- &.light {
35
- & .ant-dropdown-link {
36
- color: inherit;
37
- }
38
- }
39
- `;
40
-
41
- export const StyledCrUserInfoInner = styled.a`
42
- display: flex;
43
- align-items: center;
44
- `;
45
-
46
- export const StyledCrUserInfoAvatar = styled(Avatar)`
47
- font-size: 24px;
48
- background-color: ${({ theme }) => theme.palette.orange[6]};
49
- width: 40px;
50
- height: 40px;
51
- display: flex;
52
- align-items: center;
53
- justify-content: center;
54
- `;
55
-
56
- export const StyledCrUserInfoContent = styled.span`
57
- width: calc(100% - 62px);
58
- margin-left: 16px;
59
- transition: all 0.2s ease;
60
-
61
- [dir="rtl"] & {
62
- margin-left: 0;
63
- margin-right: 16px;
64
- }
65
- `;
66
-
67
- export const StyledUsernameInfo = styled.span`
68
- display: flex;
69
- align-items: center;
70
- justify-content: space-between;
71
- `;
72
-
73
- export const StyledUsername = styled.h3`
74
- margin-bottom: 0;
75
- font-size: ${({ theme }) => theme.font.size.sm};
76
- font-weight: ${({ theme }) => theme.font.weight.lg};
77
- color: #000000e0;
78
-
79
- &.light {
80
- color: #000000e0;
81
- }
82
- `;
83
-
84
- export const StyledUserArrow = styled.span`
85
- margin-left: 12px;
86
- width: 24px;
87
- display: flex;
88
- align-items: center;
89
- justify-content: center;
90
-
91
- [dir="rtl"] & {
92
- margin-left: 0;
93
- margin-right: 12px;
94
- }
95
-
96
- & svg {
97
- display: block;
98
- }
99
- `;
100
-
101
- export const StyledCrUserDesignation = styled.span`
102
- margin-top: -2px;
103
- color: #000000e0;
104
- font-size: ${({ theme }) => theme.font.size.sm};
105
-
106
- .ant-layout-sider-dark & {
107
- color: #000000e0;
108
- }
109
- `;
@@ -1,168 +0,0 @@
1
- import {
2
- DownOutlined,
3
- ExclamationCircleOutlined,
4
- LogoutOutlined,
5
- SettingOutlined,
6
- } from "@ant-design/icons";
7
- import { ProConfigProvider, ProLayout } from "@ant-design/pro-components";
8
- import { Dropdown, Modal } from "antd";
9
- import React, { useEffect, useState } from "react";
10
-
11
- import { ThemeProvider } from "styled-components";
12
- import { IUserEmployee } from "../../types/account";
13
- import { StyledTheme } from "../../types/theme";
14
- import {
15
- StyledCrUserDesignation,
16
- StyledCrUserInfo,
17
- StyledCrUserInfoAvatar,
18
- StyledCrUserInfoContent,
19
- StyledCrUserInfoInner,
20
- StyledUserArrow,
21
- StyledUsername,
22
- StyledUsernameInfo,
23
- } from "./index.styled";
24
-
25
- interface HISD3SidebarProps {
26
- account: IUserEmployee;
27
- logoUrl: string;
28
- appName: string;
29
- menuItems: any[];
30
- onLogout: () => Promise<void>;
31
- pathname: string;
32
- styledTheme: StyledTheme;
33
- collapsed?: boolean;
34
- loading?: boolean;
35
- hideSidebar?: boolean;
36
- layoutTop?: boolean;
37
- avatarSrc?: string;
38
- settingsUrl?: string;
39
- children: React.ReactNode;
40
- }
41
-
42
- export const HISD3Sidebar: React.FC<HISD3SidebarProps> = ({
43
- children,
44
- account,
45
- logoUrl,
46
- appName,
47
- menuItems,
48
- onLogout,
49
- pathname,
50
- avatarSrc,
51
- styledTheme,
52
- settingsUrl,
53
- collapsed = false,
54
- loading = false,
55
- hideSidebar = false,
56
- layoutTop = false,
57
- }) => {
58
- const [isCollapsed, setIsCollapsed] = useState(collapsed);
59
-
60
- useEffect(() => {
61
- if (collapsed !== isCollapsed) {
62
- setIsCollapsed(collapsed);
63
- }
64
- }, [collapsed]);
65
-
66
- const confirmLogout = () => {
67
- Modal.confirm({
68
- title: "Are you sure you want to logout?",
69
- content: "Please click OK to continue",
70
- icon: <ExclamationCircleOutlined />,
71
- onOk: onLogout,
72
- });
73
- };
74
-
75
- if (typeof document === "undefined") {
76
- return null;
77
- }
78
-
79
- return (
80
- <ThemeProvider theme={styledTheme}>
81
- <ProConfigProvider hashed={false}>
82
- {!hideSidebar ? (
83
- <ProLayout
84
- layout={layoutTop ? "top" : "side"}
85
- title={appName}
86
- logo={logoUrl}
87
- location={{ pathname }}
88
- loading={loading}
89
- collapsed={isCollapsed}
90
- onCollapse={(collapse) => setIsCollapsed(collapse)}
91
- menuDataRender={() => menuItems}
92
- menu={{
93
- collapsedShowGroupTitle: true,
94
- }}
95
- token={{
96
- header: {
97
- colorBgMenuItemSelected: "rgba(0,0,0,0.04)",
98
- },
99
- sider: {
100
- colorBgMenuItemActive: "#e0f7f7",
101
- colorBgMenuItemHover: "#e0f7f7",
102
- colorTextMenuItemHover: "#00796b",
103
- colorBgMenuItemSelected: "#e0f7f7",
104
- colorTextMenuSelected: "#00796b",
105
- },
106
- }}
107
- headerTitleRender={(logo, title) => (
108
- <a href="/">
109
- {logo}
110
- {title}
111
- </a>
112
- )}
113
- menuFooterRender={() => (
114
- <StyledCrUserInfo className="cr-user-info-light">
115
- <Dropdown
116
- trigger={["click"]}
117
- placement="topRight"
118
- menu={{
119
- items: [
120
- {
121
- key: "settings",
122
- icon: <SettingOutlined />,
123
- label: "Settings",
124
- onClick: () =>
125
- (window.location.href = settingsUrl ?? "/settings"),
126
- },
127
- {
128
- key: "logout",
129
- icon: <LogoutOutlined />,
130
- label: "Logout",
131
- onClick: confirmLogout,
132
- },
133
- ],
134
- }}
135
- >
136
- <StyledCrUserInfoInner className="ant-dropdown-link">
137
- {avatarSrc && (
138
- <StyledCrUserInfoAvatar src={avatarSrc} size="small" />
139
- )}
140
- <StyledCrUserInfoContent>
141
- <StyledUsernameInfo>
142
- <StyledUsername>{account.fullName}</StyledUsername>
143
- <StyledUserArrow>
144
- <DownOutlined />
145
- </StyledUserArrow>
146
- </StyledUsernameInfo>
147
- <StyledCrUserDesignation>
148
- {account.positionType}
149
- </StyledCrUserDesignation>
150
- </StyledCrUserInfoContent>
151
- </StyledCrUserInfoInner>
152
- </Dropdown>
153
- </StyledCrUserInfo>
154
- )}
155
- menuItemRender={(item, dom) => <a href={item.path || "/"}>{dom}</a>}
156
- >
157
- {children}
158
- </ProLayout>
159
- ) : (
160
- // If no sidebar, just render children
161
- <>{children}</>
162
- )}
163
- </ProConfigProvider>
164
- </ThemeProvider>
165
- );
166
- };
167
-
168
- export default HISD3Sidebar;