onchain-uikit 0.0.2 → 0.0.6

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.
Files changed (49) hide show
  1. package/.storybook/preview.tsx +31 -0
  2. package/config/theme.ts +34 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.es.js +581 -311
  5. package/dist/index.umd.js +30 -0
  6. package/dist/src/App.d.ts +5 -0
  7. package/dist/src/components/PlmMosaic/index.d.ts +5 -0
  8. package/dist/src/index.d.ts +3 -0
  9. package/dist/src/main.d.ts +0 -0
  10. package/dist/src/stories/Button.d.ts +14 -0
  11. package/dist/src/stories/Button.stories.d.ts +23 -0
  12. package/dist/src/stories/Header.d.ts +11 -0
  13. package/dist/src/stories/Header.stories.d.ts +18 -0
  14. package/dist/src/stories/OnChainProvider.d.ts +12 -0
  15. package/dist/src/stories/Page.d.ts +2 -0
  16. package/dist/src/stories/Page.stories.d.ts +12 -0
  17. package/dist/src/stories/PlmMosaic.stories.d.ts +14 -0
  18. package/dist/src/stories/PlmSelect/PlmSelect.stories.d.ts +21 -0
  19. package/dist/src/stories/PlmSelect/index.d.ts +20 -0
  20. package/dist/src/stories/XsButton.d.ts +22 -0
  21. package/dist/src/stories/XsButton.stories.d.ts +14 -0
  22. package/dist/src/utils/authority/basicsAuthority.d.ts +22 -0
  23. package/dist/src/utils/authority/index.d.ts +10 -0
  24. package/dist/vite.config.d.ts +2 -0
  25. package/package.json +23 -3
  26. package/src/App.tsx +30 -7
  27. package/src/assets/styles/antd.custom.less +1144 -0
  28. package/src/assets/styles/mixins.less +5 -0
  29. package/src/components/PlmMosaic/index.module.less +6 -0
  30. package/src/components/PlmMosaic/index.tsx +15 -0
  31. package/src/global.less +973 -0
  32. package/src/index.ts +5 -2
  33. package/src/main.tsx +7 -4
  34. package/src/stories/OnChainProvider.tsx +37 -0
  35. package/src/stories/PlmMosaic.stories.ts +35 -0
  36. package/src/stories/PlmSelect/PlmSelect.stories.ts +50 -0
  37. package/src/stories/PlmSelect/index.module.less +73 -0
  38. package/src/stories/PlmSelect/index.tsx +136 -0
  39. package/src/stories/XsButton.stories.ts +30 -0
  40. package/src/stories/XsButton.tsx +33 -0
  41. package/src/typings.d.ts +636 -0
  42. package/src/utils/authority/basicsAuthority.ts +46 -0
  43. package/src/utils/authority/index.tsx +28 -0
  44. package/tsconfig.json +84 -5
  45. package/typings.d.ts +130 -0
  46. package/vite.config.ts +63 -5
  47. package/.storybook/preview.ts +0 -14
  48. package/dist/index.cjs.js +0 -30
  49. package/dist/onchain-uikit.css +0 -1
package/src/index.ts CHANGED
@@ -1,3 +1,6 @@
1
- import { Button as XsButton } from "./stories/Button";
1
+ // import { Button as XsButton } from "./stories/Button";
2
+ import OnChainProvider from "./stories/OnChainProvider";
3
+ import XsButton from "./stories/XsButton";
4
+ import PlmSelect from "./stories/PlmSelect";
2
5
 
3
- export { XsButton };
6
+ export { OnChainProvider, XsButton, PlmSelect };
package/src/main.tsx CHANGED
@@ -1,10 +1,13 @@
1
1
  import { StrictMode } from "react";
2
2
  import { createRoot } from "react-dom/client";
3
3
  import "./index.css";
4
- import App from "./App.tsx";
4
+ import App, { rootContainer } from "./App";
5
5
 
6
+ /** vite工程入口,跟storybook无关 */
6
7
  createRoot(document.getElementById("root")!).render(
7
- <StrictMode>
8
- <App />
9
- </StrictMode>
8
+ rootContainer(
9
+ <StrictMode>
10
+ <App />
11
+ </StrictMode>
12
+ )
10
13
  );
@@ -0,0 +1,37 @@
1
+ import { ConfigProvider } from "antd";
2
+ import zhCN from "antd/lib/locale/zh_CN";
3
+ import React from "react";
4
+
5
+ /**
6
+ * Antd Provider
7
+ */
8
+ export interface OnChainProviderProps {
9
+ /** 设置统一样式前缀 */
10
+ prefixCls?: string;
11
+ /** 内容 */
12
+ children?: React.ReactNode;
13
+ }
14
+
15
+ const OnChainProvider = (
16
+ { prefixCls = "frontend", ...props }: OnChainProviderProps,
17
+ ref
18
+ ) => {
19
+ ConfigProvider.config({
20
+ prefixCls: prefixCls,
21
+ });
22
+
23
+ const root = React.createElement(
24
+ ConfigProvider,
25
+ {
26
+ prefixCls: prefixCls,
27
+ locale: zhCN,
28
+ input: { autoComplete: "off" },
29
+ autoInsertSpaceInButton: false,
30
+ },
31
+ props.children
32
+ );
33
+
34
+ return root;
35
+ };
36
+
37
+ export default OnChainProvider;
@@ -0,0 +1,35 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+ // import PlmMosaic from "@/components/PlmMosaic";
4
+ import PlmMosaic from "../components/PlmMosaic";
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
7
+ const meta = {
8
+ title: "PLM/Component/PlmMosaic",
9
+ component: PlmMosaic,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: "centered",
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ["autodocs"],
16
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
+ argTypes: {
18
+ // backgroundColor: { control: "color" },
19
+ },
20
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
21
+ args: {},
22
+ } satisfies Meta<typeof PlmMosaic>;
23
+
24
+ export default meta;
25
+ type Story = StoryObj<typeof meta>;
26
+
27
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
28
+
29
+ export const InLineTrue: Story = {
30
+ args: { inLine: true },
31
+ };
32
+
33
+ // export const InLineFalse: Story = {
34
+ // args: { inLine: false },
35
+ // };
@@ -0,0 +1,50 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+
4
+ import PlmSelect from ".";
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
7
+ const meta = {
8
+ title: "PLM/Component/PlmSelect",
9
+ component: PlmSelect,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: "centered",
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ["autodocs"],
16
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
+ argTypes: {
18
+ // backgroundColor: { control: "color" },
19
+ },
20
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
21
+ args: {
22
+ /** 列表值 */
23
+ options: [
24
+ { label: "label1", value: "1" },
25
+ { label: "label2", value: "2" },
26
+ { label: "label3", value: "3" },
27
+ ],
28
+ },
29
+ } satisfies Meta<typeof PlmSelect>;
30
+
31
+ export default meta;
32
+ type Story = StoryObj<typeof meta>;
33
+
34
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
35
+
36
+ export const Large: Story = {
37
+ args: {
38
+ pane: {
39
+ cols: 5,
40
+ },
41
+ },
42
+ };
43
+
44
+ export const Small: Story = {
45
+ args: {
46
+ pane: {
47
+ cols: 3,
48
+ },
49
+ },
50
+ };
@@ -0,0 +1,73 @@
1
+ .pane {
2
+ // padding: 10px;
3
+ // .item {
4
+ // // width: 150px;
5
+ // float: left;
6
+ // cursor: pointer;
7
+ // flex: 1;
8
+ // text-align: left;
9
+ // height: 30px;
10
+ // line-height: 30px;
11
+ // padding-left: 10px;
12
+ // &.selected {
13
+ // background-color: rgba(23, 97, 253, 0.08);
14
+ // }
15
+ // &:hover {
16
+ // background-color: rgba(23, 97, 253, 0.2);
17
+ // }
18
+ // }
19
+ }
20
+ .main {
21
+ :global {
22
+ .frontend-select-multiple .frontend-select-selection-overflow {
23
+ gap: 1px !important;
24
+ }
25
+
26
+ .frontend-select-dropdown-menu {
27
+ background-color: aqua;
28
+ scrollbar-width: thin;
29
+ scrollbar-color: #d3d2d2 #ffffff;
30
+
31
+ ::-webkit-scrollbar {
32
+ height: 6px;
33
+ width: 6px;
34
+ }
35
+ ::-webkit-scrollbar-thumb {
36
+ // border-radius: 3px;
37
+ background: #e0e0e0;
38
+ }
39
+ ::-webkit-scrollbar-track {
40
+ &:horizontal {
41
+ // border-right: 1px solid @sider-border;
42
+ // border-top: 1px solid @sider-border;
43
+ }
44
+ &:vertical {
45
+ // border-bottom: 1px solid @sider-border;
46
+ // border-left: 1px solid @sider-border;
47
+ }
48
+ padding: 2px;
49
+ box-shadow: 0;
50
+ border-radius: 0;
51
+ background: #ffffff;
52
+ }
53
+ }
54
+ .rc-virtual-list-holder-inner {
55
+ }
56
+ }
57
+ }
58
+ :global {
59
+ .backend-select-pane {
60
+ padding: 10px;
61
+ .rc-virtual-list-holder-inner {
62
+ display: unset !important;
63
+ /* height: 400px; */
64
+ width: 100% !important;
65
+ /* flex-direction: row; */
66
+ /* justify-content: space-around; */
67
+ .backend-select-item-option {
68
+ width: 25% !important;
69
+ float: left !important;
70
+ }
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,136 @@
1
+ /*
2
+ * @Author: hny_147
3
+ * @Date: 2022-02-04 19:01:35
4
+ * @Description: select组件
5
+ */
6
+ import { BaseComponentProps } from "@/typings";
7
+ import classNames from "classnames";
8
+ import { forwardRef, useImperativeHandle } from "react";
9
+ import styles from "./index.module.less";
10
+ import { Select, SelectProps, Tag } from "antd";
11
+ import { omit } from "lodash";
12
+ import { useRef } from "react";
13
+ import Highlighter from "react-highlight-words";
14
+ import { useState, useEffect } from "react";
15
+ // import { Authority } from "@/utils/authority";
16
+ import PlmMosaic from "../../components/PlmMosaic";
17
+
18
+ export interface PlmSelectProps extends BaseComponentProps, SelectProps<any> {
19
+ pane?: {
20
+ cols?: number;
21
+ item?: BaseComponentProps;
22
+ };
23
+
24
+ /** 分页信息 */
25
+ pagination: {
26
+ /**网络请求URL */
27
+ url: string;
28
+ page: number;
29
+ pageSize: number;
30
+ total: number;
31
+ };
32
+ }
33
+
34
+ export interface PlmSelectForwardRefProps {}
35
+
36
+ const PlmSelect = forwardRef(
37
+ (props: PlmSelectProps, ref) => {
38
+ const paneDropRef = useRef(null);
39
+ const mainRef = useRef(null);
40
+ const { Option } = Select;
41
+ const newProps = { ...props };
42
+
43
+ const [searchValue, setSearchValue] = useState<string>("");
44
+
45
+ const getHighlighter = (label: string, searchValue: string) => {
46
+ return (
47
+ <Highlighter
48
+ //@ts-ignore
49
+ highlightStyle={{
50
+ color: "#F5325C",
51
+ backgroundColor: "rgb(0, 0, 0, 0)",
52
+ padding: "0",
53
+ }}
54
+ //@ts-ignore
55
+ searchWords={[searchValue ? searchValue.toString() : ""]}
56
+ autoEscape
57
+ textToHighlight={label ? label.toString() : ""}
58
+ />
59
+ );
60
+ };
61
+
62
+ if (props.pagination) {
63
+ newProps.onPopupScroll = (e) => {
64
+ // console.log(e);
65
+ };
66
+ newProps.dropdownRender = (menu) => {
67
+ return (
68
+ <div
69
+ ref={paneDropRef}
70
+ className={classNames(styles.pane, "clearfix")}
71
+ >
72
+ {menu}
73
+ <div>只显示20条数据,共XXX条</div>
74
+ </div>
75
+ );
76
+ };
77
+ }
78
+
79
+ if (newProps.loading) {
80
+ return <Select value={""} open={false} loading={true}></Select>;
81
+ }
82
+ return (
83
+ <Select
84
+ style={{ ...newProps.style, width: "100%" }}
85
+ className={classNames(styles.main, newProps.className, {
86
+ rrrrr: true,
87
+ [styles.pane]: props.pane,
88
+ })}
89
+ {...omit(newProps, ["options"])}
90
+ onSearch={(value) => {
91
+ setSearchValue(value);
92
+ }}
93
+ filterOption={(inputValue, option: any) => {
94
+ return option.label && option.label.indexOf(inputValue) >= 0;
95
+ }}
96
+ dropdownClassName={styles.plm_select_dropdown}
97
+ showSearch
98
+ allowClear={props.allowClear == undefined ? true : props.allowClear}
99
+ optionLabelProp="label"
100
+ >
101
+ {props.options?.map((option: any) => {
102
+ if (false) {
103
+ // if (Authority.isMosaic(option.label)) {
104
+ return (
105
+ <Option disabled={true}>
106
+ <PlmMosaic />
107
+ </Option>
108
+ );
109
+ }
110
+ return (
111
+ <Option
112
+ {...option}
113
+ value={option.value}
114
+ disabled={option.disabled}
115
+ key={option.value}
116
+ label={option.label}
117
+ >
118
+ <div
119
+ title={option.label}
120
+ style={{
121
+ width: "100%",
122
+ overflow: "hidden",
123
+ textOverflow: "ellipsis",
124
+ }}
125
+ >
126
+ {getHighlighter(option.label, searchValue)}
127
+ </div>
128
+ </Option>
129
+ );
130
+ })}
131
+ </Select>
132
+ );
133
+ }
134
+ );
135
+
136
+ export default PlmSelect;
@@ -0,0 +1,30 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+ import XsButton from "./XsButton";
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
6
+ const meta = {
7
+ title: "PLM/Component/XsButton",
8
+ component: XsButton,
9
+ parameters: {
10
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
11
+ layout: "centered",
12
+ },
13
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
14
+ tags: ["autodocs"],
15
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
16
+ argTypes: {
17
+ // backgroundColor: { control: "color" },
18
+ },
19
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
20
+ args: {},
21
+ } satisfies Meta<typeof XsButton>;
22
+
23
+ export default meta;
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
27
+
28
+ export const Init: Story = {
29
+ args: { label: "asdf", btnType: "default", btnType2: "default", custObj: {} },
30
+ };
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import { Button } from "antd";
3
+ import { ButtonType } from "antd/lib/button";
4
+
5
+ export interface XsButtonProps {
6
+ /** 按钮文本 */
7
+ label: string;
8
+ /** 按钮类型 */
9
+ btnType?: ButtonType;
10
+ /** 按钮类型2 */
11
+ btnType2?: "default" | "primary" | "ghost" | "dashed" | "link" | "text";
12
+ /** Optional click handler */
13
+ onClick?: () => void;
14
+ /** 自定义对象 */
15
+ custObj?: custObjTemp;
16
+ }
17
+ /** 对象 */
18
+ type custObjTemp = {
19
+ /** 年龄 */
20
+ name?: string;
21
+ /** 姓名 */
22
+ age?: number;
23
+ };
24
+
25
+ const XsButton = (props: XsButtonProps, ref) => {
26
+ return (
27
+ <Button type={props.btnType} className="my-button">
28
+ {props.custObj?.name || props.label}
29
+ </Button>
30
+ );
31
+ };
32
+
33
+ export default XsButton;