@fe-free/core 2.8.14 → 3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - feat: theme
8
+
9
+ ### Patch Changes
10
+
11
+ - @fe-free/tool@3.0.0
12
+
13
+ ## 2.8.15
14
+
15
+ ### Patch Changes
16
+
17
+ - feat: data viewer
18
+ - @fe-free/tool@2.8.15
19
+
3
20
  ## 2.8.14
4
21
 
5
22
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "2.8.14",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -41,7 +41,7 @@
41
41
  "safe-stable-stringify": "^2.5.0",
42
42
  "vanilla-jsoneditor": "^0.23.1",
43
43
  "zustand": "^4.5.4",
44
- "@fe-free/tool": "2.8.14"
44
+ "@fe-free/tool": "3.0.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@ant-design/pro-components": "2.8.9",
package/src/crud/crud.tsx CHANGED
@@ -118,7 +118,7 @@ function CRUDComponent<
118
118
  const disabled = readProps?.operateIsDisabled?.(record) || false;
119
119
  if (disabled) {
120
120
  btns.push(
121
- <span key="read" className="cursor-not-allowed text-desc">
121
+ <span key="read" className="cursor-not-allowed text-03">
122
122
  {readProps?.operateText || '查看'}
123
123
  </span>,
124
124
  );
@@ -144,7 +144,7 @@ function CRUDComponent<
144
144
  const disabled = readProps?.operateIsDisabled?.(record) || false;
145
145
  if (disabled) {
146
146
  btns.push(
147
- <span key="read" className="cursor-not-allowed text-desc">
147
+ <span key="read" className="cursor-not-allowed text-03">
148
148
  {readProps?.operateText || '查看'}
149
149
  </span>,
150
150
  );
@@ -169,7 +169,7 @@ function CRUDComponent<
169
169
 
170
170
  if (disabled) {
171
171
  btns.push(
172
- <span key="update" className="cursor-not-allowed text-desc">
172
+ <span key="update" className="cursor-not-allowed text-03">
173
173
  {updateProps?.operateText || '编辑'}
174
174
  </span>,
175
175
  );
@@ -39,7 +39,7 @@ function OperateDelete(props: Params) {
39
39
  const { doDelete } = useDelete({ name, desc, onDelete, operateText });
40
40
 
41
41
  if (disabled) {
42
- return <span className="text-desc cursor-not-allowed">{operateText || '删除'}</span>;
42
+ return <span className="cursor-not-allowed text-03">{operateText || '删除'}</span>;
43
43
  }
44
44
 
45
45
  return (
@@ -31,7 +31,7 @@ export const Basic: Story = {
31
31
 
32
32
  export const ForJSON: Story = {
33
33
  args: {
34
- data: JSON.stringify({ action: 'hello', data: 'world' }, null, 2),
34
+ data: JSON.stringify({ action: 'hello', data: 'world' }),
35
35
  },
36
36
  render: (props) => <BasicDemo {...props} />,
37
37
  };
@@ -1,6 +1,6 @@
1
1
  import { ArrowsAltOutlined } from '@ant-design/icons';
2
2
  import { Button, Modal, Select } from 'antd';
3
- import { useState } from 'react';
3
+ import { useMemo, useState } from 'react';
4
4
  import { Editor } from '../editor';
5
5
  import { PageLayout } from '../page_layout';
6
6
 
@@ -24,6 +24,18 @@ function DataViewer({ data, title, enableMaximize }: DataViewerProps) {
24
24
  options[0].value as DataViewerLanguage,
25
25
  );
26
26
 
27
+ const value = useMemo(() => {
28
+ try {
29
+ if (language === 'json') {
30
+ return JSON.stringify(JSON.parse(data), null, 2);
31
+ }
32
+ return data;
33
+ } catch (err) {
34
+ console.error(err);
35
+ return data;
36
+ }
37
+ }, [data, language]);
38
+
27
39
  return (
28
40
  <>
29
41
  <PageLayout
@@ -34,7 +46,7 @@ function DataViewer({ data, title, enableMaximize }: DataViewerProps) {
34
46
  <Select
35
47
  options={options}
36
48
  value={language}
37
- onChange={(value) => setLanguage(value)}
49
+ onChange={(v) => setLanguage(v)}
38
50
  className="w-[110px]"
39
51
  />
40
52
  {enableMaximize && (
@@ -45,7 +57,7 @@ function DataViewer({ data, title, enableMaximize }: DataViewerProps) {
45
57
  >
46
58
  <div className="relative h-full">
47
59
  <Editor
48
- value={data}
60
+ value={value}
49
61
  language={language === 'text' ? undefined : language}
50
62
  editable={false}
51
63
  />
@@ -55,7 +67,7 @@ function DataViewer({ data, title, enableMaximize }: DataViewerProps) {
55
67
  <Modal title="查看" open width={'80vw'} onCancel={() => setMaximize(false)} footer={null}>
56
68
  <div className="h-[80vh]">
57
69
  <Editor
58
- value={data}
70
+ value={value}
59
71
  language={language === 'text' ? undefined : language}
60
72
  editable={false}
61
73
  />
@@ -110,10 +110,10 @@ function useDropdown({ items, renderItem, onSelect, editorRef }) {
110
110
  left: `${position.left}px`,
111
111
  }}
112
112
  >
113
- {items.length === 0 && <div className="p-2 text-sm text-desc">暂无数据</div>}
113
+ {items.length === 0 && <div className="p-2 text-sm text-03">暂无数据</div>}
114
114
  {items.map((group, i) => (
115
115
  <div key={group.label}>
116
- <div className="p-2 text-sm text-desc">{group.label}</div>
116
+ <div className="p-2 text-sm text-03">{group.label}</div>
117
117
  <div>
118
118
  {group.options.map((item) => (
119
119
  <div
@@ -57,7 +57,7 @@ function FileCard({
57
57
  <FileIcon name={name} className="text-4xl" />
58
58
  <div className={classNames('flex flex-col', { 'items-center': direction === 'vertical' })}>
59
59
  {name && <div className="truncate">{name}</div>}
60
- {size && <div className="text-sm text-desc">{getFileSize(size)}</div>}
60
+ {size && <div className="text-sm text-03">{getFileSize(size)}</div>}
61
61
  </div>
62
62
  </div>
63
63
  );
package/src/index.ts CHANGED
@@ -57,6 +57,7 @@ export { Table } from './table';
57
57
  export type { TableProps } from './table';
58
58
  export { Tabs } from './tabs';
59
59
  export type { TabsProps } from './tabs';
60
+ export { themeVariables } from './theme';
60
61
  export { FileTree, Tree, flatToTreeData } from './tree';
61
62
  export type { FileTreeProps, TreeProps } from './tree';
62
63
  export { useLocalforageState } from './use_localforage_state';
@@ -103,8 +103,8 @@ const InfiniteListBase = <D, P>({
103
103
  </div>
104
104
  )}
105
105
  <div className="flex w-full items-center justify-center">
106
- {noMore && <div className="my-5 text-center text-desc">没有更多数据</div>}
107
- {loadingMore && <div className="my-5 text-center text-desc">加载更多数据中...</div>}
106
+ {noMore && <div className="my-5 text-center text-03">没有更多数据</div>}
107
+ {loadingMore && <div className="my-5 text-center text-03">加载更多数据中...</div>}
108
108
  </div>
109
109
  </div>
110
110
  );
@@ -0,0 +1,14 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ import { themeVariables } from './theme';
3
+
4
+ module.exports = {
5
+ theme: {
6
+ extend: {
7
+ colors: themeVariables.color,
8
+ textColor: themeVariables.textColor,
9
+ borderColor: themeVariables.borderColor,
10
+ backgroundColor: themeVariables.backgroundColor,
11
+ },
12
+ },
13
+ plugins: [],
14
+ };
@@ -6,12 +6,64 @@ export default {
6
6
  export const Default = () => {
7
7
  return (
8
8
  <div>
9
- <div>@fe-free/core 扩展的</div>
9
+ <div>@fe-free/core 扩展的 </div>
10
+ <h1>tailwindcss</h1>
11
+ <h2>textColor</h2>
10
12
  <div>
11
- <div className="text-primary">text-primary</div>
12
- <div className="text-secondary">text-secondary</div>
13
- <div className="text-desc">text-desc</div>
13
+ <div className="bg-black px-2 text-00">text-00</div>
14
+ <div className="text-01">text-01</div>
15
+ <div className="text-02">text-02</div>
16
+ <div className="text-03">text-03</div>
17
+ <div className="text-04">text-04</div>
14
18
  </div>
19
+ <h2>borderColor</h2>
20
+ <div className="space-y-2">
21
+ <div className="border border-solid border-01">border-01</div>
22
+ <div className="border border-solid border-02">border-02</div>
23
+ <div className="border border-solid border-03">border-03</div>
24
+ </div>
25
+ <h2>backgroundColor</h2>
26
+ <div>
27
+ <div className="bg-00">bg-00</div>
28
+ <div className="bg-005">bg-005</div>
29
+ <div className="bg-01">bg-01</div>
30
+ <div className="bg-02">bg-02</div>
31
+ <div className="bg-03">bg-03</div>
32
+ </div>
33
+ <h2>colors</h2>
34
+ <div>
35
+ <div className="bg-primary">bg-primary</div>
36
+ </div>
37
+ <h2>colors - themeColor</h2>
38
+ <div>
39
+ <div className="bg-theme09">theme09</div>
40
+ <div className="bg-theme08">theme08</div>
41
+ <div className="bg-theme05">theme05</div>
42
+ <div className="bg-theme03">theme03</div>
43
+ <div className="bg-theme02">theme02</div>
44
+ </div>
45
+ <h2>colors - redColor</h2>
46
+ <div>
47
+ <div className="bg-red09">red09</div>
48
+ <div className="bg-red08">red08</div>
49
+ <div className="bg-red05">red05</div>
50
+ <div className="bg-red03">red03</div>
51
+ </div>
52
+ <h2>colors - greenColor</h2>
53
+ <div>
54
+ <div className="bg-green09">green09</div>
55
+ <div className="bg-green08">green08</div>
56
+ <div className="bg-green05">green05</div>
57
+ <div className="bg-green03">green03</div>
58
+ </div>
59
+ <h2>colors - yellowColor</h2>
60
+ <div>
61
+ <div className="bg-yellow09">yellow09</div>
62
+ <div className="bg-yellow08">yellow08</div>
63
+ <div className="bg-yellow05">yellow05</div>
64
+ <div className="bg-yellow03">yellow03</div>
65
+ </div>
66
+ <h1>className</h1>
15
67
  <div>
16
68
  <div className="fec-border-bottom">fec-border-bottom</div>
17
69
  <div className="fec-border-top">fec-border-top</div>
package/src/theme.ts ADDED
@@ -0,0 +1,48 @@
1
+ const themeVariables = {
2
+ color: {
3
+ primary: '#0374e9',
4
+
5
+ // 目前是主题蓝
6
+ theme09: '#0368d2',
7
+ theme08: '#0374e9',
8
+ theme05: '#a2cbf7',
9
+ theme03: '#e6f1fd',
10
+ theme02: '#f0f7fe',
11
+
12
+ red09: '#e64547',
13
+ red08: '#ff4d4f',
14
+ red05: '#ffb8b9',
15
+ red03: '#ffeded',
16
+
17
+ green09: '#01a468',
18
+ green08: '#01b673',
19
+ green05: '#9be5c8',
20
+ green03: '#ddf9ec',
21
+
22
+ yellow09: '#bf7a05',
23
+ yellow08: '#faad14',
24
+ yellow05: '#eecf9b',
25
+ yellow03: '#f6e7cd',
26
+ },
27
+ textColor: {
28
+ '00': '#ffffff',
29
+ '01': '#15191e',
30
+ '02': '#444444',
31
+ '03': '#777777',
32
+ '04': '#94999f',
33
+ },
34
+ borderColor: {
35
+ '01': '#e2e7f0',
36
+ '02': '#d5dde9',
37
+ '03': '#c0c7d2',
38
+ },
39
+ backgroundColor: {
40
+ '00': '#ffffff',
41
+ '005': '#f1f3f5',
42
+ '01': '#ececec',
43
+ '02': '#d9d9d9',
44
+ '03': '#c0c0c0',
45
+ },
46
+ } as const;
47
+
48
+ export { themeVariables };
@@ -22,6 +22,7 @@ type Story = StoryObj<typeof meta>;
22
22
  export const Default: Story = {
23
23
  args: {
24
24
  title: '某某公司',
25
+ titleDescription: '某某公司的描述',
25
26
  enableSearch: true,
26
27
  actions: ['create', 'update', 'delete'],
27
28
  requestCreateByValues: (values) => {
@@ -106,7 +106,7 @@ function More({
106
106
  actions?.includes('create') &&
107
107
  !isCreateHidden && {
108
108
  label: isCreateDisabled ? (
109
- <div className="cursor-not-allowed text-desc">新建子目录</div>
109
+ <div className="cursor-not-allowed text-03">新建子目录</div>
110
110
  ) : (
111
111
  <Detail
112
112
  action="create"
@@ -120,7 +120,7 @@ function More({
120
120
  actions?.includes('update') &&
121
121
  !isUpdateHidden && {
122
122
  label: isUpdateDisabled ? (
123
- <div className="cursor-not-allowed text-desc">编辑</div>
123
+ <div className="cursor-not-allowed text-03">编辑</div>
124
124
  ) : (
125
125
  <Detail
126
126
  action="update"
@@ -134,7 +134,7 @@ function More({
134
134
  actions?.includes('delete') &&
135
135
  !isDeleteHidden && {
136
136
  label: isDeleteDisabled ? (
137
- <div className="cursor-not-allowed text-desc">删除</div>
137
+ <div className="cursor-not-allowed text-03">删除</div>
138
138
  ) : (
139
139
  <OperateDelete
140
140
  name={nodeData.title}
@@ -192,7 +192,7 @@ function FileTree<D extends DataNode>(props: FileTreeProps<D>) {
192
192
  />
193
193
  )}
194
194
  <div className="flex-1 truncate">{nodeData.title}</div>
195
- <div className={classNames('text-desc', { 'group-hover:hidden': hasMore })}>
195
+ <div className={classNames('text-03', { 'group-hover:hidden': hasMore })}>
196
196
  {nodeData.children?.length || 0}
197
197
  </div>
198
198
  {hasMore && (
package/src/tree/tree.tsx CHANGED
@@ -187,7 +187,7 @@ function Tree<T extends DataNode>(props: TreeProps<T>) {
187
187
  <div className="flex gap-2 px-2">
188
188
  <div className="flex-1">
189
189
  <div className="truncate">{title}</div>
190
- {titleDescription && <div className="text-desc">{titleDescription}</div>}
190
+ {titleDescription && <div className="text-03">{titleDescription}</div>}
191
191
  </div>
192
192
  {titleExtra}
193
193
  </div>
@@ -141,13 +141,13 @@ function UploadDragger(props: ImageUploadDraggerProps) {
141
141
  <p className={classNames('ant-upload-drag-icon')}>
142
142
  <InboxOutlined
143
143
  className={classNames({
144
- '!text-desc': isDisabled,
144
+ '!text-03': isDisabled,
145
145
  })}
146
146
  />
147
147
  </p>
148
148
  <p
149
149
  className={classNames('ant-upload-text', {
150
- '!text-desc': isDisabled,
150
+ '!text-03': isDisabled,
151
151
  })}
152
152
  >
153
153
  点击或拖拽到此区域进行上传
@@ -1,15 +0,0 @@
1
- /** @type {import('tailwindcss').Config} */
2
- module.exports = {
3
- theme: {
4
- extend: {
5
- colors: {
6
- primary: '#1677ff',
7
- /** 次要文本 */
8
- secondary: 'rgba(0, 0, 0, 0.65)',
9
- /** 描述文本 */
10
- desc: 'rgba(0, 0, 0, 0.45)',
11
- },
12
- },
13
- },
14
- plugins: [],
15
- };