@junyiacademy/ui-test 1.5.15 → 1.6.1

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 (46) hide show
  1. package/{declarations/libs/ui/src → dist}/index.d.ts +0 -0
  2. package/dist/index.js +7 -0
  3. package/{declarations/libs/ui/src → dist}/interfaces/index.d.ts +4 -1
  4. package/dist/interfaces/index.js +1 -0
  5. package/{declarations/libs/ui/src → dist}/lib/button/Button.d.ts +0 -0
  6. package/dist/lib/button/Button.js +50 -0
  7. package/{declarations/libs/ui/src → dist}/lib/button-group/ButtonGroup.d.ts +0 -0
  8. package/dist/lib/button-group/ButtonGroup.js +29 -0
  9. package/{declarations/libs/ui/src → dist}/lib/menu-item/SelectMenuItem.d.ts +0 -0
  10. package/dist/lib/menu-item/SelectMenuItem.js +32 -0
  11. package/dist/lib/radio/Radio.d.ts +11 -0
  12. package/dist/lib/radio/Radio.js +47 -0
  13. package/dist/lib/select/OutlinedSelect.d.ts +3 -0
  14. package/dist/lib/select/OutlinedSelect.js +95 -0
  15. package/{declarations/libs/ui/src → dist}/lib/select/Select.d.ts +0 -0
  16. package/dist/lib/select/Select.js +22 -0
  17. package/dist/lib/select/StandardSelect.d.ts +3 -0
  18. package/dist/lib/select/StandardSelect.js +60 -0
  19. package/dist/lib/text-field/TextField.d.ts +3 -0
  20. package/dist/lib/text-field/TextField.js +78 -0
  21. package/{declarations/libs/ui/src → dist}/lib/topic-filter/TopicFilter.d.ts +0 -0
  22. package/dist/{libs/ui/src/lib → lib}/topic-filter/TopicFilter.js +21 -26
  23. package/dist/styles/theme.d.ts +24 -0
  24. package/dist/styles/theme.js +40 -0
  25. package/{declarations/libs/ui/src → dist}/utils/Capitalize.d.ts +0 -0
  26. package/dist/utils/Capitalize.js +3 -0
  27. package/dist/utils/topicTree.d.ts +2 -0
  28. package/dist/utils/topicTree.js +174 -0
  29. package/package.json +6 -6
  30. package/declarations/libs/ui/src/lib/TopicFilter.d.ts +0 -13
  31. package/declarations/libs/ui/src/lib/radio/Radio.d.ts +0 -10
  32. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +0 -3
  33. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +0 -3
  34. package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +0 -3
  35. package/dist/libs/ui/src/index.js +0 -20
  36. package/dist/libs/ui/src/interfaces/index.js +0 -2
  37. package/dist/libs/ui/src/lib/TopicFilter.js +0 -120
  38. package/dist/libs/ui/src/lib/button/Button.js +0 -44
  39. package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +0 -23
  40. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +0 -20
  41. package/dist/libs/ui/src/lib/radio/Radio.js +0 -33
  42. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +0 -82
  43. package/dist/libs/ui/src/lib/select/Select.js +0 -16
  44. package/dist/libs/ui/src/lib/select/StandardSelect.js +0 -65
  45. package/dist/libs/ui/src/lib/text-field/TextField.js +0 -68
  46. package/dist/libs/ui/src/utils/Capitalize.js +0 -6
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) 2020 Junyi Academy.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { createTheme } from '@mui/material/styles';
8
+ // Create a theme instance.
9
+ const theme = createTheme({
10
+ typography: {
11
+ fontFamily: ['Noto Sans TC', 'Helvetica', 'Arial', 'sans-serif'].join(','),
12
+ },
13
+ palette: {
14
+ primary: {
15
+ light: '#82C0FF',
16
+ main: '#4990E2',
17
+ dark: '#0063B0',
18
+ },
19
+ secondary: {
20
+ light: '#FFD759',
21
+ main: '#F5A623',
22
+ dark: '#BD7700',
23
+ contrastText: '#FFFFFF',
24
+ },
25
+ green: {
26
+ primary: {
27
+ light: '#9DD49E',
28
+ main: '#5CB85D',
29
+ dark: '#218838',
30
+ },
31
+ blueGreen: {
32
+ main: '#19A696',
33
+ },
34
+ grassGreen: {
35
+ main: '#80BB5A',
36
+ },
37
+ },
38
+ },
39
+ });
40
+ export default theme;
@@ -0,0 +1,3 @@
1
+ export default function capitalize(string) {
2
+ return `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
3
+ }
@@ -0,0 +1,2 @@
1
+ import { ITopicTreeNode } from '../interfaces';
2
+ export declare const topicTree: ITopicTreeNode;
@@ -0,0 +1,174 @@
1
+ export const topicTree = {
2
+ childTopics: [
3
+ {
4
+ childTopics: [
5
+ {
6
+ childTopics: [
7
+ {
8
+ childTopics: [
9
+ {
10
+ childTopics: [],
11
+ id: 'j-m1ach1',
12
+ isContentTopic: true,
13
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKFlWUkdyck1reDdXU3lSb3pQYXU4RDlDTnZ4Ukx3MjhYU2ZCcTF0LTEM',
14
+ tags: [],
15
+ title: '【一上】數到 10',
16
+ },
17
+ {
18
+ childTopics: [],
19
+ id: 'j-m1ach2',
20
+ isContentTopic: true,
21
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
22
+ tags: [],
23
+ title: '【一上】比長短1',
24
+ },
25
+ {
26
+ childTopics: [],
27
+ id: 'j-m1ach3',
28
+ isContentTopic: true,
29
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
30
+ tags: [],
31
+ title: '【一上】比長短2',
32
+ },
33
+ {
34
+ childTopics: [],
35
+ id: 'j-m1ach4',
36
+ isContentTopic: true,
37
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
38
+ tags: [],
39
+ title: '【一上】比長短3',
40
+ },
41
+ {
42
+ childTopics: [],
43
+ id: 'j-m1ach5',
44
+ isContentTopic: true,
45
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
46
+ tags: [],
47
+ title: '【一上】比長短4',
48
+ },
49
+ {
50
+ childTopics: [],
51
+ id: 'j-m1ach6',
52
+ isContentTopic: true,
53
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
54
+ tags: [],
55
+ title: '【一上】比長短5',
56
+ },
57
+ {
58
+ childTopics: [],
59
+ id: 'j-m1ach7',
60
+ isContentTopic: true,
61
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
62
+ tags: [],
63
+ title: '【一上】比長短6',
64
+ },
65
+ {
66
+ childTopics: [],
67
+ id: 'j-m1ach8',
68
+ isContentTopic: true,
69
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
70
+ tags: [],
71
+ title: '【一上】比長短7',
72
+ },
73
+ {
74
+ childTopics: [],
75
+ id: 'j-m1ach9',
76
+ isContentTopic: true,
77
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
78
+ tags: [],
79
+ title: '【一上】比長短8',
80
+ },
81
+ {
82
+ childTopics: [],
83
+ id: 'j-m1ach10',
84
+ isContentTopic: true,
85
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
86
+ tags: [],
87
+ title: '【一上】比長短9',
88
+ },
89
+ {
90
+ childTopics: [],
91
+ id: 'j-m1ach11',
92
+ isContentTopic: true,
93
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
94
+ tags: [],
95
+ title: '【一上】比長短10',
96
+ },
97
+ {
98
+ childTopics: [],
99
+ id: 'j-m1ach12',
100
+ isContentTopic: true,
101
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
102
+ tags: [],
103
+ title: '【一上】比長短11',
104
+ },
105
+ ],
106
+ id: 'math-grade-1-a',
107
+ isContentTopic: false,
108
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHN2MlIzS0VwaXlVeWdJQnhyYzBYakZ0RDZhU0JraGFJbGctU19qZFoM',
109
+ tags: [],
110
+ title: '均一版',
111
+ },
112
+ ],
113
+ id: 'math-1',
114
+ isContentTopic: false,
115
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKEVzRnVINFdtalZBRmdQUkpjeWtaWFVnSlR2OEc2RzVsWnA1a0ZEVV8M',
116
+ tags: ['grouping_eleme'],
117
+ title: '一年級',
118
+ },
119
+ {
120
+ childTopics: [
121
+ {
122
+ childTopics: [
123
+ {
124
+ childTopics: [],
125
+ id: 'n-m2ach1',
126
+ isContentTopic: true,
127
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKExzUnEyWUgzUEduZmVzWm1oVXdxLU5tdmxjZmx4aWJXbkVKN0JVcXYM',
128
+ tags: [],
129
+ title: '【二上】第一單元 數到 300',
130
+ },
131
+ {
132
+ childTopics: [],
133
+ id: 'n-m2ach2',
134
+ isContentTopic: true,
135
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKFJuTDZLWXhxS0xNQ3VPU3BkUXZBOVN6YkRrVTNqdVNRSFdjbTEwc2UM',
136
+ tags: [],
137
+ title: '【二上】第二單元 二位數的加法',
138
+ },
139
+ {
140
+ childTopics: [],
141
+ id: 'n-m2ach3',
142
+ isContentTopic: true,
143
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHpYUWFzZXNPbS16V1BVeG9qeVFRQXlfZzA5Wm44ajdVZnM1dU85UWkM',
144
+ tags: [],
145
+ title: '【二上】第三單元 幾公分',
146
+ },
147
+ ],
148
+ id: 'n-m2a',
149
+ isContentTopic: false,
150
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHl3QXRqNW1xMmk2QTRfR0JzWlpXQnVRQW1fYW5ZTEV4MkJ2ZUlYSmUM',
151
+ tags: [],
152
+ title: '南一版',
153
+ },
154
+ ],
155
+ id: 'math-2',
156
+ isContentTopic: false,
157
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKE92cm9EU1N4c3FZM2J6MzMzZ05XWFR6RGFLMDJudHlIaHFtN1VRcXIM',
158
+ tags: ['grouping_eleme'],
159
+ title: '二年級',
160
+ },
161
+ ],
162
+ id: 'course-compare',
163
+ isContentTopic: false,
164
+ key: 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKDFCSmFuVjVsTWlUUWZaU21MeE9FU3BZbVlmcktkNHJWN3Q5WU1VWjQM',
165
+ tags: ['has-pre-exam', 'has-post-exam'],
166
+ title: '數學',
167
+ },
168
+ ],
169
+ id: 'root',
170
+ isContentTopic: false,
171
+ key: 'ag5zfmp1bnlpYWNhZGVteXIzCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoM',
172
+ tags: [],
173
+ title: '知識樹',
174
+ };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@junyiacademy/ui-test",
3
- "version": "1.5.15",
3
+ "version": "1.6.1",
4
4
  "description": "junyiacademy ui library",
5
5
  "main": "./dist/libs/ui/src/index.js",
6
- "typings": "./declarations/libs/ui/src/index.d.ts",
6
+ "typings": "./dist/libs/ui/src/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
9
  "build": "tsc --build --clean && tsc --build"
@@ -17,10 +17,10 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@emotion/react": "11.7.1",
21
- "@emotion/styled": "11.6.0",
22
- "@mui/icons-material": "5.2.5",
23
- "@mui/material": "5.2.7",
20
+ "@emotion/react": "11.9.0",
21
+ "@emotion/styled": "11.8.1",
22
+ "@mui/icons-material": "5.6.2",
23
+ "@mui/material": "5.6.2",
24
24
  "react": "17.0.2"
25
25
  },
26
26
  "devDependencies": {
@@ -1,13 +0,0 @@
1
- import type { ITopicTreeNode } from '../interfaces';
2
- export interface TopicFilterProps {
3
- topicTree: ITopicTreeNode;
4
- onTopicSelected: (topic: ITopicTreeNode, selectedInfo: {
5
- layerNumber: number;
6
- selectedTopicIds: string[];
7
- }) => void;
8
- isLastLayer: (topic: ITopicTreeNode) => boolean;
9
- hasArrow: boolean;
10
- initSelectedTopicIds: string[];
11
- }
12
- export declare const TopicFilter: ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }: TopicFilterProps) => JSX.Element;
13
- export default TopicFilter;
@@ -1,10 +0,0 @@
1
- import { RadioProps as MuiRadioProps, FormControlLabelProps } from '@mui/material';
2
- export interface RadioProps extends FormControlLabelProps {
3
- color?: 'primary' | 'secondary' | 'default';
4
- size?: 'medium' | 'small';
5
- caption?: string;
6
- formControlLabelProps?: Partial<FormControlLabelProps>;
7
- radioProps?: Partial<MuiRadioProps>;
8
- }
9
- export declare const Radio: ({ checked, disabled, label, labelPlacement, value, formControlLabelProps, radioProps, color, size, caption, }: RadioProps) => JSX.Element;
10
- export default Radio;
@@ -1,3 +0,0 @@
1
- import { SelectProps } from '../../interfaces';
2
- export declare const OutlinedSelect: ({ label, helperText, InputProps, SelectProps, className, children, color, size, paperMaxHeight, error, hasLabel, hasShrink, value, disabled, }: SelectProps) => JSX.Element;
3
- export default OutlinedSelect;
@@ -1,3 +0,0 @@
1
- import { SelectProps } from '../../interfaces';
2
- export declare function StandardSelect({ label, helperText, InputProps, SelectProps, className, children, color, size, paperMaxHeight, error, hasShrink, value, disabled, }: SelectProps): JSX.Element;
3
- export default StandardSelect;
@@ -1,3 +0,0 @@
1
- import { TextFieldProps } from '@mui/material';
2
- export declare const TextField: (props: TextFieldProps) => JSX.Element;
3
- export default TextField;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Select = exports.TextField = exports.Radio = exports.ButtonGroup = exports.Button = exports.SelectMenuItem = exports.TopicFilter = void 0;
7
- var TopicFilter_1 = require("./lib/topic-filter/TopicFilter");
8
- Object.defineProperty(exports, "TopicFilter", { enumerable: true, get: function () { return __importDefault(TopicFilter_1).default; } });
9
- var SelectMenuItem_1 = require("./lib/menu-item/SelectMenuItem");
10
- Object.defineProperty(exports, "SelectMenuItem", { enumerable: true, get: function () { return __importDefault(SelectMenuItem_1).default; } });
11
- var Button_1 = require("./lib/button/Button");
12
- Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
13
- var ButtonGroup_1 = require("./lib/button-group/ButtonGroup");
14
- Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return __importDefault(ButtonGroup_1).default; } });
15
- var Radio_1 = require("./lib/radio/Radio");
16
- Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(Radio_1).default; } });
17
- var TextField_1 = require("./lib/text-field/TextField");
18
- Object.defineProperty(exports, "TextField", { enumerable: true, get: function () { return __importDefault(TextField_1).default; } });
19
- var Select_1 = require("./lib/select/Select");
20
- Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TopicFilter = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importStar(require("react"));
6
- const styles_1 = require("@material-ui/core/styles");
7
- const ArrowRightRounded_1 = tslib_1.__importDefault(require("@material-ui/icons/ArrowRightRounded"));
8
- const OutlinedSelect_1 = tslib_1.__importDefault(require("./select/OutlinedSelect"));
9
- const SelectMenuItem_1 = tslib_1.__importDefault(require("./menu-item/SelectMenuItem"));
10
- // self-defined-configs
11
- const PLACEHOLDER = '請選擇';
12
- // self-defined-components
13
- const PREFIX = 'JuiTopicFilter';
14
- const FiltersWrapper = styles_1.styled('div')({
15
- display: 'flex',
16
- alignItems: 'center',
17
- flexWrap: 'wrap',
18
- });
19
- const SelectWrapper = styles_1.styled('div')({
20
- display: 'flex',
21
- alignItems: 'center',
22
- });
23
- const StyledArrowRightRoundedIcon = styles_1.styled(ArrowRightRounded_1.default)(({ theme }) => ({
24
- margin: theme.spacing(-1, -1.5),
25
- fontSize: theme.spacing(7),
26
- color: '#444',
27
- }));
28
- const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
29
- const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
30
- const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
31
- const [isFocusedList, setIsFocusedList] = react_1.useState([]);
32
- const initSelectedLayers = () => {
33
- const newLayeredTopicList = initSelectedTopicIds.reduce((topicListAccumulator, topicId, index) => {
34
- var _a, _b;
35
- const selectedTopic = (_b = (_a = topicListAccumulator[index]) === null || _a === void 0 ? void 0 : _a.childTopics) === null || _b === void 0 ? void 0 : _b.find((childTopic) => childTopic.id === topicId);
36
- if (!selectedTopic) {
37
- return topicListAccumulator;
38
- }
39
- if (isLastLayer(selectedTopic)) {
40
- return topicListAccumulator;
41
- }
42
- return [...topicListAccumulator, selectedTopic];
43
- }, [topicTree]);
44
- setLayeredTopicList(newLayeredTopicList);
45
- setSelectedTopicIds(initSelectedTopicIds.slice(0, newLayeredTopicList.length));
46
- setIsFocusedList(Array(newLayeredTopicList.length).fill(false));
47
- };
48
- const handleChange = (e, layerNumber, layeredTopic) => {
49
- const selectedTopic = layeredTopic.childTopics.find((childTopic) => childTopic.id === e.target.value);
50
- const newSelectedTopicIds = [
51
- ...selectedTopicIds.slice(0, layerNumber),
52
- selectedTopic.id,
53
- ];
54
- setSelectedTopicIds(newSelectedTopicIds);
55
- onTopicSelected(selectedTopic, {
56
- layerNumber,
57
- selectedTopicIds: newSelectedTopicIds,
58
- });
59
- if (isLastLayer(selectedTopic)) {
60
- setLayeredTopicList((prevTopicList) => prevTopicList.slice(0, layerNumber + 1));
61
- setIsFocusedList((prevList) => prevList.slice(0, layerNumber + 1));
62
- }
63
- else {
64
- setLayeredTopicList((prevTopicList) => [
65
- ...prevTopicList.slice(0, layerNumber + 1),
66
- selectedTopic,
67
- ]);
68
- setIsFocusedList((prevList) => [
69
- ...prevList.slice(0, layerNumber + 1),
70
- false,
71
- ]);
72
- }
73
- };
74
- react_1.useEffect(() => {
75
- if (!topicTree || Object.keys(topicTree).length === 0) {
76
- return;
77
- }
78
- if (initSelectedTopicIds.length !== 0) {
79
- initSelectedLayers();
80
- return;
81
- }
82
- setLayeredTopicList([topicTree]);
83
- }, [topicTree]);
84
- if (layeredTopicList.length === 0) {
85
- return (react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', width: 220, placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
86
- }
87
- return (react_1.default.createElement(FiltersWrapper, null, layeredTopicList.map((layeredTopic, layerNumber) => {
88
- const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
89
- return (react_1.default.createElement(SelectWrapper, { key: layeredTopic.id },
90
- react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', width: 220, paperMaxHeight: 412, hasLabel: hasLabel, placeholder: PLACEHOLDER, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
91
- 'data-testid': `layered-topic-${layerNumber}`,
92
- }, OutlinedInputProps: {
93
- inputProps: {
94
- 'aria-label': `layered-topic-${layerNumber}`,
95
- },
96
- onChange: (e) => {
97
- handleChange(e, layerNumber, layeredTopic);
98
- },
99
- onFocus: () => {
100
- setIsFocusedList((prevList) => {
101
- const newList = [...prevList];
102
- newList[layerNumber] = true;
103
- return newList;
104
- });
105
- },
106
- onBlur: () => {
107
- setIsFocusedList((prevList) => {
108
- const newList = [...prevList];
109
- newList[layerNumber] = false;
110
- return newList;
111
- });
112
- },
113
- } },
114
- react_1.default.createElement(SelectMenuItem_1.default, { width: 220, disabled: true }, PLACEHOLDER),
115
- layeredTopic.childTopics.map((childTopic) => (react_1.default.createElement(SelectMenuItem_1.default, { width: 220, key: childTopic.id, value: childTopic.id, "data-testid": `layered-menuitem-${layerNumber}`, "data-is-content-topic": childTopic.isContentTopic }, childTopic.title)))),
116
- hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(StyledArrowRightRoundedIcon, { fontSize: 'large', "data-testid": 'topic-filter-arrow' }))));
117
- })));
118
- };
119
- exports.TopicFilter = TopicFilter;
120
- exports.default = exports.TopicFilter;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Button = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
6
- const styles_1 = require("@mui/material/styles");
7
- const material_1 = require("@mui/material");
8
- const Button_1 = require("@mui/material/Button");
9
- //utils
10
- const Capitalize_1 = tslib_1.__importDefault(require("../../utils/Capitalize"));
11
- const StyledButton = styles_1.styled(material_1.Button, {
12
- shouldForwardProp: (prop) => prop !== 'active',
13
- })(({ active, color = 'primary', theme }) => ({
14
- // For variant: outlined
15
- [`&.${Button_1.buttonClasses.outlined}${Capitalize_1.default(color)}`]: {
16
- backgroundColor: active
17
- ? theme.palette[color].main
18
- : theme.palette.common.white,
19
- color: active ? theme.palette.common.white : theme.palette[color].main,
20
- borderColor: theme.palette[color].main,
21
- '&:hover': {
22
- backgroundColor: active
23
- ? theme.palette[color].main
24
- : styles_1.alpha(theme.palette[color].main, 0.1),
25
- },
26
- [`&.${Button_1.buttonClasses.disabled}`]: {
27
- backgroundColor: theme.palette.common.white,
28
- borderColor: theme.palette.action.disabledBackground,
29
- color: theme.palette.action.disabled,
30
- },
31
- },
32
- // For variant: text
33
- [`&.${Button_1.buttonClasses.text}${Capitalize_1.default(color)}`]: {
34
- '&:hover': {
35
- backgroundColor: styles_1.alpha(theme.palette[color].main, 0.1),
36
- },
37
- },
38
- }));
39
- const Button = (_a) => {
40
- var { active, children } = _a, otherProps = tslib_1.__rest(_a, ["active", "children"]);
41
- return (react_1.default.createElement(StyledButton, Object.assign({ active: active }, otherProps), children));
42
- };
43
- exports.Button = Button;
44
- exports.default = exports.Button;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ButtonGroup = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
6
- const styles_1 = require("@mui/material/styles");
7
- const material_1 = require("@mui/material");
8
- const ButtonGroup_1 = require("@mui/material/ButtonGroup");
9
- //utils
10
- const Capitalize_1 = tslib_1.__importDefault(require("../../utils/Capitalize"));
11
- // self-defined-components
12
- const StyledButtonGroup = styles_1.styled(material_1.ButtonGroup)(({ color = 'primary', theme }) => ({
13
- [`& .${ButtonGroup_1.buttonGroupClasses.groupedOutlined}${Capitalize_1.default(color)}.${ButtonGroup_1.buttonGroupClasses.grouped}.${ButtonGroup_1.buttonGroupClasses.disabled}`]: {
14
- borderColor: styles_1.alpha(theme.palette[color].main, 0.5),
15
- color: styles_1.alpha(theme.palette[color].main, 0.5),
16
- },
17
- }));
18
- const ButtonGroup = (_a) => {
19
- var { children } = _a, otherProps = tslib_1.__rest(_a, ["children"]);
20
- return (react_1.default.createElement(StyledButtonGroup, Object.assign({}, otherProps), children));
21
- };
22
- exports.ButtonGroup = ButtonGroup;
23
- exports.default = exports.ButtonGroup;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
5
- const material_1 = require("@mui/material");
6
- const MenuItem_1 = require("@mui/material/MenuItem");
7
- const SelectMenuItem = (_a) => {
8
- var { children, value = '' } = _a, otherProps = tslib_1.__rest(_a, ["children", "value"]);
9
- return (react_1.default.createElement(material_1.MenuItem, Object.assign({ sx: (theme) => ({
10
- whiteSpace: 'unset',
11
- color: theme.palette.text.primary,
12
- [`&.${MenuItem_1.menuItemClasses.selected}`]: {
13
- backgroundColor: theme.palette.grey[300],
14
- '&:hover': {
15
- backgroundColor: theme.palette.grey[200],
16
- },
17
- },
18
- }), value: value }, otherProps), children));
19
- };
20
- exports.default = SelectMenuItem;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Radio = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
6
- const styles_1 = require("@mui/material/styles");
7
- const material_1 = require("@mui/material");
8
- const FormControlLabel_1 = require("@mui/material/FormControlLabel");
9
- const Radio_1 = require("@mui/material/Radio");
10
- // self-defined-components
11
- const StyledFormControlLabel = styles_1.styled(material_1.FormControlLabel)(({ theme }) => ({
12
- [`& .${FormControlLabel_1.formControlLabelClasses.label}`]: {
13
- color: theme.palette.text.secondary,
14
- [`&.${FormControlLabel_1.formControlLabelClasses.disabled}`]: {
15
- color: theme.palette.text.disabled,
16
- },
17
- },
18
- [`& .${Radio_1.radioClasses.checked} + .${FormControlLabel_1.formControlLabelClasses.label}`]: {
19
- color: theme.palette.text.primary,
20
- },
21
- }));
22
- const Radio = ({ checked, disabled, label, labelPlacement, value, formControlLabelProps, radioProps, color = 'secondary', size = 'medium', caption = '', }) => {
23
- return (react_1.default.createElement(react_1.default.Fragment, null,
24
- react_1.default.createElement(StyledFormControlLabel, Object.assign({ control: react_1.default.createElement(material_1.Radio, Object.assign({ sx: (theme) => ({
25
- color: theme.palette.text.primary,
26
- }), color: color, size: size }, radioProps)), checked: checked, disabled: disabled, label: label, labelPlacement: labelPlacement, value: value }, formControlLabelProps)),
27
- caption && (react_1.default.createElement(material_1.Typography, { sx: (theme) => ({
28
- color: theme.palette.text.disabled,
29
- margin: '0 0 0 30px',
30
- }), variant: 'body2' }, caption))));
31
- };
32
- exports.Radio = Radio;
33
- exports.default = exports.Radio;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OutlinedSelect = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
6
- const styles_1 = require("@mui/material/styles");
7
- const material_1 = require("@mui/material");
8
- const FormHelperText_1 = require("@mui/material/FormHelperText");
9
- const InputLabel_1 = require("@mui/material/InputLabel");
10
- const OutlinedInput_1 = require("@mui/material/OutlinedInput");
11
- const InputBase_1 = require("@mui/material/InputBase");
12
- const StyledInputLabel = styles_1.styled(material_1.InputLabel, {
13
- shouldForwardProp: (prop) => prop !== 'color',
14
- })(({ color, theme }) => ({
15
- color: theme.palette.text.secondary,
16
- [`&.${InputLabel_1.inputLabelClasses.outlined}`]: {
17
- [`&:not(.${InputLabel_1.inputLabelClasses.disabled}) .${InputLabel_1.inputLabelClasses.focused}`]: {
18
- color: theme.palette.action.active,
19
- },
20
- [`&.${InputLabel_1.inputLabelClasses.sizeSmall}:not(.${InputLabel_1.inputLabelClasses.shrink})`]: {
21
- transform: 'translate(12px, 12px) scale(1)',
22
- },
23
- },
24
- [`&.${InputLabel_1.inputLabelClasses.shrink}:not(.${InputLabel_1.inputLabelClasses.error}):not(.${InputLabel_1.inputLabelClasses.disabled}).${InputLabel_1.inputLabelClasses.focused}`]: {
25
- color: theme.palette[color].main,
26
- },
27
- [`&.${InputLabel_1.inputLabelClasses.shrink}`]: {
28
- backgroundColor: '#ffffff',
29
- padding: '0 2px',
30
- },
31
- }));
32
- const StyledOutlinedInput = styles_1.styled(material_1.OutlinedInput)(({ theme }) => ({
33
- [`&.${OutlinedInput_1.outlinedInputClasses.root}`]: {
34
- [`&.${OutlinedInput_1.outlinedInputClasses.error}.${OutlinedInput_1.outlinedInputClasses.focused} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
35
- borderColor: `${theme.palette.error.main}`,
36
- },
37
- [`& .${InputBase_1.inputBaseClasses.inputSizeSmall}`]: {
38
- padding: '12.5px 15px 12.5px 12px',
39
- },
40
- },
41
- [`& .${OutlinedInput_1.outlinedInputClasses.input}`]: {
42
- color: theme.palette.text.primary,
43
- '&:focus': {
44
- background: 'rgba(0,0,0,0)',
45
- },
46
- },
47
- }));
48
- const OutlinedSelect = ({ label, helperText, InputProps, SelectProps, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasLabel = true, hasShrink = false, value = '', disabled = false, }) => {
49
- const hasHelperText = !!helperText;
50
- return (react_1.default.createElement(material_1.FormControl, { sx: (theme) => ({
51
- backgroundColor: 'white',
52
- '&:hover': {
53
- [`& :not(.${OutlinedInput_1.outlinedInputClasses.disabled}):not(.${OutlinedInput_1.outlinedInputClasses.error}) .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
54
- borderColor: theme.palette[color].main,
55
- },
56
- },
57
- }), size: size, disabled: disabled, error: error, color: color, className: className },
58
- hasLabel && (react_1.default.createElement(StyledInputLabel, { color: color, shrink: hasShrink ? true : undefined }, label)),
59
- react_1.default.createElement(material_1.Select, Object.assign({ value: value, label: hasLabel ? label : undefined, MenuProps: {
60
- PaperProps: {
61
- sx: {
62
- maxHeight: paperMaxHeight,
63
- },
64
- },
65
- disableAutoFocusItem: true,
66
- anchorOrigin: {
67
- vertical: 2,
68
- horizontal: 'left',
69
- },
70
- transformOrigin: {
71
- vertical: 'top',
72
- horizontal: 'left',
73
- },
74
- }, input: react_1.default.createElement(StyledOutlinedInput, Object.assign({ color: color, label: hasLabel ? label : undefined, disabled: disabled }, InputProps)) }, SelectProps), children),
75
- hasHelperText && (react_1.default.createElement(material_1.FormHelperText, { sx: {
76
- [`&.${FormHelperText_1.formHelperTextClasses.root}`]: {
77
- marginLeft: 0,
78
- },
79
- } }, helperText))));
80
- };
81
- exports.OutlinedSelect = OutlinedSelect;
82
- exports.default = exports.OutlinedSelect;