@jsb188/react 1.0.4 → 1.1.3
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 +6 -8
- package/states/appContext.ts +418 -0
- package/states/index.ts +1 -0
- package/states/modal.ts +1 -2
- package/states/popOver.ts +87 -99
- package/types/PopOver.d.ts +204 -0
- package/utils/hooks.ts +2 -26
- package/utils/schema.ts +150 -0
- package/icons/Icon.tsx +0 -207
- package/icons/IconSVGs.tsx +0 -1486
- package/types/dom.d.ts +0 -7
- package/utils/dom.ts +0 -303
- package/utils/priorityTimeout.ts +0 -57
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { ColorEnum } from '@jsb188/app/types/app.d';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility types
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface ClientRectValues {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
left: number;
|
|
11
|
+
right: number;
|
|
12
|
+
top: number;
|
|
13
|
+
bottom: number;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Pop over interfaces
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export interface PONListSubtitleObj {
|
|
23
|
+
__type: 'SUBTITLE';
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface POListBreakObj {
|
|
28
|
+
__type: 'BREAK';
|
|
29
|
+
hidden?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface POListItemObj {
|
|
33
|
+
__type: 'LIST_ITEM' | 'CHECK_LIST_ITEM';
|
|
34
|
+
value?: string | null;
|
|
35
|
+
text: string;
|
|
36
|
+
className?: string;
|
|
37
|
+
colorIndicator?: ColorEnum;
|
|
38
|
+
avatarDisplayName?: string;
|
|
39
|
+
photoUri?: string | null;
|
|
40
|
+
LinkComponent?: any;
|
|
41
|
+
allowDisabledOnClick?: boolean;
|
|
42
|
+
iconName?: string;
|
|
43
|
+
rightIconName?: string;
|
|
44
|
+
rightIconClassName?: string;
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
|
|
48
|
+
// Presets
|
|
49
|
+
preset?: 'small' | 'default';
|
|
50
|
+
|
|
51
|
+
// Web props
|
|
52
|
+
to?: string;
|
|
53
|
+
|
|
54
|
+
// Mobile props
|
|
55
|
+
// ?
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface POCheckListItemObj extends POListItemObj {
|
|
59
|
+
__type: 'CHECK_LIST_ITEM';
|
|
60
|
+
checked?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface PONavAvatarItemObj {
|
|
64
|
+
__type: 'AVATAR_ITEM';
|
|
65
|
+
value?: string | null;
|
|
66
|
+
text: string;
|
|
67
|
+
label: string;
|
|
68
|
+
avatarDisplayName?: string;
|
|
69
|
+
photoUri?: string | null;
|
|
70
|
+
className?: string;
|
|
71
|
+
LinkComponent?: any;
|
|
72
|
+
allowDisabledOnClick?: boolean;
|
|
73
|
+
rightIconName?: string;
|
|
74
|
+
hidden?: boolean;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
|
|
77
|
+
// Web props
|
|
78
|
+
to?: string;
|
|
79
|
+
|
|
80
|
+
// Mobile props
|
|
81
|
+
// ?
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface PODateRangeObj {
|
|
85
|
+
__type: 'DATE_RANGE';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type PONavItemObj = PONListSubtitleObj | POListBreakObj | POListItemObj | POCheckListItemObj | PONavAvatarItemObj | PODateRangeObj;
|
|
89
|
+
|
|
90
|
+
export interface OptionsPOIface {
|
|
91
|
+
name: 'PO_LIST';
|
|
92
|
+
variables: {
|
|
93
|
+
notReady?: boolean;
|
|
94
|
+
designClassName?: string;
|
|
95
|
+
className?: string;
|
|
96
|
+
savingValue?: string;
|
|
97
|
+
iconName?: string;
|
|
98
|
+
title?: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
displayName?: string;
|
|
101
|
+
photoUri?: string | null;
|
|
102
|
+
selectedValue?: string | null;
|
|
103
|
+
options: PONavItemObj[];
|
|
104
|
+
addFooterButton?: boolean;
|
|
105
|
+
footerButtonText?: string;
|
|
106
|
+
LinkComponent?: any;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface ImagePOIface {
|
|
111
|
+
name: 'PO_VIEW_IMAGE'
|
|
112
|
+
variables: {
|
|
113
|
+
imageUri: string;
|
|
114
|
+
alt?: string;
|
|
115
|
+
rect: any;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type PopOverIface = OptionsPOIface | ImagePOIface;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Pop overs
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
export type POPosition = 'top' | 'left' | 'right' | 'bottom' | 'bottom_left';
|
|
126
|
+
|
|
127
|
+
interface FixedElementProps {
|
|
128
|
+
id: string; // This ensures that the popover doesn't reset from within the same mouse pointer element
|
|
129
|
+
className: string;
|
|
130
|
+
position: POPosition;
|
|
131
|
+
variables: any;
|
|
132
|
+
popOverWidth: number;
|
|
133
|
+
popOverHeight: number;
|
|
134
|
+
rect?: ClientRectValues;
|
|
135
|
+
offsetX: number;
|
|
136
|
+
offsetY: number;
|
|
137
|
+
leftEdgeThreshold: number;
|
|
138
|
+
rightEdgeThreshold: number;
|
|
139
|
+
leftEdgePosition: number;
|
|
140
|
+
rightEdgePosition: number;
|
|
141
|
+
hover: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface PopOverProps extends Partial<FixedElementProps> {
|
|
145
|
+
id?: string;
|
|
146
|
+
name: string; // Used to be "__type"
|
|
147
|
+
closing?: boolean; // If true, multiple close() functions are triggered to animate & close popover
|
|
148
|
+
animationClassName?: string;
|
|
149
|
+
doNotTrackHover?: boolean;
|
|
150
|
+
globalState?: Record<string, any> | null; // Use this to listen to state changes from outside the popover
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface UpdatePopOverParams {
|
|
154
|
+
name: string;
|
|
155
|
+
variables: Record<string, any>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface PopOverGlobalStateParams {
|
|
159
|
+
action: 'ITEM' | 'MOUNT' | 'UNMOUNT';
|
|
160
|
+
value: any;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface PopOverGlobalStateObj extends PopOverGlobalStateParams {
|
|
164
|
+
id: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type OpenPopOverFn = (data: PopOverProps) => void;
|
|
168
|
+
export type ClosePopOverFn = (dismissIfName?: string) => void;
|
|
169
|
+
export type UpdatePopOverFn = (data: UpdatePopOverParams) => void;
|
|
170
|
+
export type SetPopOverStateFn = (data: PopOverGlobalStateParams | null) => void;
|
|
171
|
+
|
|
172
|
+
export interface PopOverHandlerProps {
|
|
173
|
+
openPopOver: OpenPopOverFn;
|
|
174
|
+
closePopOver: ClosePopOverFn;
|
|
175
|
+
updatePopOver: UpdatePopOverFn;
|
|
176
|
+
setPopOverState: SetPopOverStateFn;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface PopOverHookProps extends PopOverHandlerProps {
|
|
180
|
+
popOver: PopOverProps | null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Tooltips
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
export interface TooltipProps extends Partial<FixedElementProps> {
|
|
188
|
+
title?: string;
|
|
189
|
+
message?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type OpenTooltipFn = (data: TooltipProps) => void;
|
|
193
|
+
export type CloseTooltipFn = (removeId: string) => void;
|
|
194
|
+
export type UpdateTooltipFn = (data: TooltipProps) => void;
|
|
195
|
+
|
|
196
|
+
export interface TooltipHandlerProps {
|
|
197
|
+
openTooltip: OpenTooltipFn;
|
|
198
|
+
closeTooltip: CloseTooltipFn;
|
|
199
|
+
updateTooltip: UpdateTooltipFn;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface TooltipHookProps extends TooltipHandlerProps {
|
|
203
|
+
tooltip: TooltipProps | null;
|
|
204
|
+
}
|
package/utils/hooks.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { isAppHidden, setTimeoutPriority } from './priorityTimeout';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Check if database document needs an update, insert, or do nothing based on the user API arguments
|
|
@@ -139,7 +138,7 @@ export function useWatchChange(
|
|
|
139
138
|
* Check props diff (logging for dev)
|
|
140
139
|
*/
|
|
141
140
|
|
|
142
|
-
export function checkPropsDiff(pp, np) {
|
|
141
|
+
export function checkPropsDiff(pp: any, np: any) {
|
|
143
142
|
let isSame = true;
|
|
144
143
|
for (const k in pp) {
|
|
145
144
|
if (Object.prototype.hasOwnProperty.call(pp, k) && pp[k] !== np[k]) {
|
|
@@ -163,6 +162,7 @@ export function checkPropsDiff(pp, np) {
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
if (globalThis && globalThis.location?.origin?.indexOf('localhost') >= 0) {
|
|
165
|
+
// @ts-ignore - Dev only shim
|
|
166
166
|
globalThis.checkPropsDiff = checkPropsDiff;
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -291,27 +291,3 @@ export function useVisible(
|
|
|
291
291
|
|
|
292
292
|
return [visible, setVisible];
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Create an infinite loop timer
|
|
297
|
-
*/
|
|
298
|
-
|
|
299
|
-
export function useTimer(
|
|
300
|
-
refreshInterval: number = 60000
|
|
301
|
-
): null | number {
|
|
302
|
-
|
|
303
|
-
const [timestamp, setTimestamp] = useState<null | number>(null);
|
|
304
|
-
const appIsHidden = isAppHidden();
|
|
305
|
-
|
|
306
|
-
useEffect(() => {
|
|
307
|
-
const timeout = setTimeoutPriority(() => {
|
|
308
|
-
setTimestamp(Date.now());
|
|
309
|
-
}, refreshInterval);
|
|
310
|
-
|
|
311
|
-
return () => {
|
|
312
|
-
clearTimeout(timeout);
|
|
313
|
-
};
|
|
314
|
-
}, [appIsHidden, timestamp]);
|
|
315
|
-
|
|
316
|
-
return timestamp;
|
|
317
|
-
}
|
package/utils/schema.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import i18n from '@jsb188/app/i18n';
|
|
3
|
+
import type { FormItemSchemaObj, FormSchemaObj } from '@jsb188/app/types/form.d';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ComputedSchema {
|
|
10
|
+
formValues: any;
|
|
11
|
+
setFormValues: (formValues: any) => void;
|
|
12
|
+
listData: (FormItemSchemaObj & { name: string })[];
|
|
13
|
+
validate?: () => any;
|
|
14
|
+
isButtonDisabled?: (formValues: any) => boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Make form values from current form values, current data, and schema
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export function makeFormValues(
|
|
22
|
+
schema: any,
|
|
23
|
+
dataForSchema?: any,
|
|
24
|
+
currentData?: any,
|
|
25
|
+
) {
|
|
26
|
+
const newFormValues: Record<string, any> = {};
|
|
27
|
+
const { listData } = schema;
|
|
28
|
+
|
|
29
|
+
for (const obj of listData) {
|
|
30
|
+
const { item: { name, setter, items } } = obj;
|
|
31
|
+
|
|
32
|
+
if (currentData || dataForSchema) {
|
|
33
|
+
if (Array.isArray(items)) {
|
|
34
|
+
items.forEach((subItem: any) => {
|
|
35
|
+
if (typeof subItem.setter === 'function') {
|
|
36
|
+
newFormValues[subItem.name] = subItem.setter(
|
|
37
|
+
currentData,
|
|
38
|
+
dataForSchema,
|
|
39
|
+
);
|
|
40
|
+
} else if (currentData) {
|
|
41
|
+
newFormValues[subItem.name] = currentData[subItem.name];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
if (typeof setter === 'function') {
|
|
46
|
+
newFormValues[name] = setter(currentData, dataForSchema);
|
|
47
|
+
} else if (currentData) {
|
|
48
|
+
newFormValues[name] = currentData[name];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return newFormValues;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Resolve schema using data
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
export function useSchema(
|
|
62
|
+
schema: FormSchemaObj,
|
|
63
|
+
dataForSchema: any,
|
|
64
|
+
currentData?: any,
|
|
65
|
+
): ComputedSchema {
|
|
66
|
+
const { listData, rules, isButtonDisabled } = schema;
|
|
67
|
+
const [formValues, setFormValues] = useState(makeFormValues(schema, dataForSchema, currentData));
|
|
68
|
+
|
|
69
|
+
// Make listData from schema
|
|
70
|
+
|
|
71
|
+
const computedListData: any[] = listData.map((schemaItem: FormItemSchemaObj) => {
|
|
72
|
+
const { __type, hidden, locked, item } = schemaItem;
|
|
73
|
+
if (
|
|
74
|
+
hidden === true ||
|
|
75
|
+
(typeof hidden === 'function' && hidden(dataForSchema))
|
|
76
|
+
) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let lockedValue;
|
|
81
|
+
if (typeof locked === 'function') {
|
|
82
|
+
lockedValue = locked(dataForSchema);
|
|
83
|
+
} else if (typeof locked === 'boolean') {
|
|
84
|
+
lockedValue = locked;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const computedItem: Record<string, any> = { ...item };
|
|
88
|
+
if (computedItem) {
|
|
89
|
+
for (const key in computedItem) {
|
|
90
|
+
if (typeof computedItem[key] === 'function') {
|
|
91
|
+
computedItem[key] = computedItem[key](dataForSchema);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
__type,
|
|
98
|
+
locked: lockedValue,
|
|
99
|
+
item: computedItem,
|
|
100
|
+
};
|
|
101
|
+
}).filter(Boolean);
|
|
102
|
+
|
|
103
|
+
// Create validation function
|
|
104
|
+
|
|
105
|
+
const validate = (): any => {
|
|
106
|
+
if (rules) {
|
|
107
|
+
const __errorFields: string[] = [];
|
|
108
|
+
|
|
109
|
+
let firstError: any = null;
|
|
110
|
+
for (const ruleObj of rules) {
|
|
111
|
+
const { for: key, rule, error } = ruleObj;
|
|
112
|
+
const value = formValues[key];
|
|
113
|
+
const isValid = rule(value, formValues);
|
|
114
|
+
|
|
115
|
+
if (!isValid) {
|
|
116
|
+
if (!__errorFields.includes(key)) {
|
|
117
|
+
__errorFields.push(key);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!firstError) {
|
|
121
|
+
if (error) {
|
|
122
|
+
firstError = typeof error === 'function' ? error(value) : error;
|
|
123
|
+
} else {
|
|
124
|
+
firstError = {
|
|
125
|
+
message: i18n.t('error.unknown_error'),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
setFormValues({
|
|
133
|
+
...formValues,
|
|
134
|
+
__errorFields,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
return firstError;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
formValues,
|
|
145
|
+
setFormValues,
|
|
146
|
+
listData: computedListData,
|
|
147
|
+
validate,
|
|
148
|
+
isButtonDisabled,
|
|
149
|
+
};
|
|
150
|
+
}
|
package/icons/Icon.tsx
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
import type { ReactSpanElement } from '../types/dom';
|
|
3
|
-
import * as IconSVGs from './IconSVGs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Convert cameCalsed string to dash-separated
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
function camelCaseToDash(str: string) {
|
|
10
|
-
if (/^[A-Z0-9]+$/.test(str)) {
|
|
11
|
-
return str.toLowerCase();
|
|
12
|
-
}
|
|
13
|
-
return str.replace(/[A-Z0-9]/g, (m, i) => {
|
|
14
|
-
return `${i ? '-' : ''}${m.toLowerCase()}`;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Combine list of class names
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
export function cn(...classNames: (string | boolean | undefined | null)[]) {
|
|
23
|
-
return classNames.filter(Boolean).join(' ');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Icon map
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const ICON_MAP = Object.entries(IconSVGs).reduce((acc, [key, IconComponent]) => {
|
|
31
|
-
acc[camelCaseToDash(key)] = IconComponent;
|
|
32
|
-
return acc;
|
|
33
|
-
}, {} as Record<string, React.ReactNode>);
|
|
34
|
-
|
|
35
|
-
// Full icon map: https://tablericons.com/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Types
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
interface IconProps {
|
|
42
|
-
name: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface SpecialIconProps extends IconProps {
|
|
46
|
-
name: string;
|
|
47
|
-
cornerIconName?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface AIFaceProps extends ReactSpanElement {
|
|
51
|
-
size: 'tiny' | 'small' | 'default' | 'medium' | 'large';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Commonly used icon names
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export const COMMON_ICON_NAMES = {
|
|
59
|
-
ai_magic: 'sparkles',
|
|
60
|
-
broken_file: 'file-broken',
|
|
61
|
-
call: 'phone-call',
|
|
62
|
-
chat: 'messages',
|
|
63
|
-
click: 'click',
|
|
64
|
-
close: 'x',
|
|
65
|
-
close_small: 'x-filled',
|
|
66
|
-
co: 'crown',
|
|
67
|
-
colors: 'color-swatch',
|
|
68
|
-
copied: 'copy-check',
|
|
69
|
-
description: 'notes',
|
|
70
|
-
delete: 'trash-x',
|
|
71
|
-
delete_filled: 'trash-x-filled',
|
|
72
|
-
edit: 'edit-circle',
|
|
73
|
-
empty: 'square-forbid-2',
|
|
74
|
-
favorites: 'stars',
|
|
75
|
-
friends_list: 'address-book',
|
|
76
|
-
group: 'users-group',
|
|
77
|
-
image: 'photo',
|
|
78
|
-
images: 'library-photo',
|
|
79
|
-
live: 'broadcast',
|
|
80
|
-
mobile: 'device-mobile',
|
|
81
|
-
moderator: 'gavel',
|
|
82
|
-
not_pinned: 'pinned-off',
|
|
83
|
-
owner: 'crown',
|
|
84
|
-
personas: 'masks-theater',
|
|
85
|
-
pinned: 'pinned',
|
|
86
|
-
plus: 'plus',
|
|
87
|
-
plus_circle: 'circle-plus-filled',
|
|
88
|
-
read: 'checklist',
|
|
89
|
-
report: 'exclamation-circle',
|
|
90
|
-
smile: 'confetti',
|
|
91
|
-
settings: 'settings',
|
|
92
|
-
snooze: 'zzz',
|
|
93
|
-
sticker: 'sticker',
|
|
94
|
-
theme: 'photo-hexagon',
|
|
95
|
-
timeout: 'clock-cancel',
|
|
96
|
-
timeout_unban: 'clock-check',
|
|
97
|
-
unread: 'mailbox',
|
|
98
|
-
user: 'user',
|
|
99
|
-
user_scan: 'user-scan',
|
|
100
|
-
user_blocked: 'user-x',
|
|
101
|
-
user_deleted: 'user-off',
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Simple icon with a very basic fix
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
export const Icon = memo((p: IconProps) => {
|
|
109
|
-
const { name: iconName } = p;
|
|
110
|
-
const IconComponent = ICON_MAP[iconName];
|
|
111
|
-
|
|
112
|
-
if (!IconComponent) {
|
|
113
|
-
console.warn('Icon: Unknown icon name:', iconName);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return IconComponent || null;
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
Icon.displayName = 'Icon';
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Special icons that aren't included in FA
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
|
-
export const SpecialIcon = memo((p: SpecialIconProps) => {
|
|
126
|
-
const { name } = p;
|
|
127
|
-
const className = 'ic_special';
|
|
128
|
-
|
|
129
|
-
switch (name) {
|
|
130
|
-
case 'google':
|
|
131
|
-
return (
|
|
132
|
-
<img
|
|
133
|
-
alt='Google logo'
|
|
134
|
-
src='/img/google-icon.png'
|
|
135
|
-
className={className}
|
|
136
|
-
/>
|
|
137
|
-
);
|
|
138
|
-
default:
|
|
139
|
-
console.warn('SpecialIcon: Unknown icon name:', name);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return null;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
SpecialIcon.displayName = 'SpecialIcon';
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Icon with plus at corner
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
export const IconWithPlus = memo((p: SpecialIconProps) => {
|
|
152
|
-
const { name, cornerIconName } = p;
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<>
|
|
156
|
-
<Icon name={name} />
|
|
157
|
-
<span className='abs_corner_1 ic_df ft_t'>
|
|
158
|
-
<Icon name={cornerIconName || 'circle-plus'} />
|
|
159
|
-
</span>
|
|
160
|
-
</>
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
IconWithPlus.displayName = 'IconWithPlus';
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* AI (brand) icon
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
export const AIFace = memo((p: AIFaceProps) => {
|
|
171
|
-
const { size, className } = p;
|
|
172
|
-
|
|
173
|
-
let sizeClassName;
|
|
174
|
-
switch (size) {
|
|
175
|
-
case 'tiny':
|
|
176
|
-
sizeClassName = 'av_xs ic_df bd_s';
|
|
177
|
-
break;
|
|
178
|
-
case 'small':
|
|
179
|
-
sizeClassName = 'av_sm ic_l bd_d';
|
|
180
|
-
break;
|
|
181
|
-
case 'default':
|
|
182
|
-
case 'medium':
|
|
183
|
-
case 'large':
|
|
184
|
-
default:
|
|
185
|
-
console.warn(`<AIFace /> size "${size}" is not implemented yet.`);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<span
|
|
191
|
-
className={cn(
|
|
192
|
-
'ai_face bg v_center r av',
|
|
193
|
-
sizeClassName,
|
|
194
|
-
// 'bg_primary',
|
|
195
|
-
className
|
|
196
|
-
)}
|
|
197
|
-
>
|
|
198
|
-
<svg className='icon' viewBox="0 0 100 100" fill='currentColor'>
|
|
199
|
-
<path d="M77.44,65.61c-4.07-7.98-12.79-12.11-20.74-9.83-1.01.29-4.51,1.77-5.39,2.76-1.13,1.27-1.44,3.22-.75,4.75.64,1.41,1.96,2.21,3.52,2.15,1.52.01,3.75.04,4.72.06,5.75.11,6.8.65,11.46,4.39.35.28.9.82,1.43,1.35,1.22,1.2,2.49,2.44,3.37,2.77.33.12.66.19.96.19.43,0,.82-.12,1.17-.36,1.1-.76,1.33-2.41,1.33-3.66,0-1.77-.67-3.75-1.09-4.58Z"/>
|
|
200
|
-
<path d="M31.22,39.18h0c-5.16.52-7.43,5.17-6.99,9.49.38,3.78,2.97,7.61,7.79,7.61.3,0,.62-.02.94-.05,2.79-.27,4.96-1.83,6.11-4.39,1.38-3.04,1.01-7.02-.89-9.66-1.6-2.23-4.07-3.29-6.96-3Z"/>
|
|
201
|
-
<path d="M67.2,46.47c.73,0,1.48-.1,2.26-.3,4.74-1.24,6.47-5.94,5.74-9.96-.69-3.78-3.61-7.36-8.57-6.83-3.03.32-5.29,2.03-6.36,4.82-1.27,3.3-.58,7.38,1.68,9.92,1.38,1.55,3.2,2.35,5.26,2.35Z"/>
|
|
202
|
-
</svg>
|
|
203
|
-
</span>
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
AIFace.displayName = 'AIFace';
|