@antscorp/antsomi-ui 1.3.3-beta.3 → 1.3.3-beta.5
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/dist/index.js +1 -1
- package/es/components/molecules/FontSetting/constants.d.ts +3 -0
- package/es/components/molecules/FontSetting/constants.js +22 -0
- package/es/components/molecules/FontSetting/index.d.ts +10 -4
- package/es/components/molecules/FontSetting/index.js +36 -35
- package/es/components/molecules/FontSetting/types.d.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const FONT_SETTING_DEFAULT = {
|
|
2
|
+
fontColor: '#000000',
|
|
3
|
+
fontFamily: 'Roboto',
|
|
4
|
+
fontItalic: false,
|
|
5
|
+
fontSize: 14,
|
|
6
|
+
fontWeight: '400',
|
|
7
|
+
letterSpacing: 2,
|
|
8
|
+
lineHeight: 1.5,
|
|
9
|
+
textTransform: 'none',
|
|
10
|
+
textDecoration: 'none',
|
|
11
|
+
};
|
|
12
|
+
export const FONT_STYLE_DEFAULT = {
|
|
13
|
+
color: '#000000',
|
|
14
|
+
fontFamily: 'Roboto',
|
|
15
|
+
fontSize: 14,
|
|
16
|
+
fontWeight: '400',
|
|
17
|
+
lineHeight: 1.5,
|
|
18
|
+
letterSpacing: 2,
|
|
19
|
+
textTransform: 'none',
|
|
20
|
+
textDecoration: 'none',
|
|
21
|
+
fontStyle: 'normal',
|
|
22
|
+
};
|
|
@@ -2,17 +2,23 @@ import React from 'react';
|
|
|
2
2
|
import { PopoverProps } from 'antd';
|
|
3
3
|
import { SettingWrapperProps } from '../SettingWrapper';
|
|
4
4
|
import { TFontSettings, TFontStyles } from './types';
|
|
5
|
+
type TFontSettingOptions = 'fontFamily' | 'color' | 'fontSize' | 'fontWeight' | 'textTransform' | 'textDecoration' | 'italic' | 'lineHeight' | 'letterSpacing';
|
|
5
6
|
export type TFontSettingProps = {
|
|
6
7
|
label?: string;
|
|
7
|
-
settings: TFontSettings
|
|
8
|
+
settings: Partial<TFontSettings>;
|
|
9
|
+
styles: Partial<TFontStyles>;
|
|
10
|
+
showSettings?: TFontSettingOptions[];
|
|
8
11
|
wrapperProps?: Omit<SettingWrapperProps, 'label'>;
|
|
9
12
|
popoverProps?: Omit<PopoverProps, 'content'>;
|
|
10
13
|
childrenProps?: Omit<TFontSettingEditProps, 'settings' | 'styles' | 'onChange'>;
|
|
11
|
-
onChange?:
|
|
14
|
+
onChange?: (settings: Partial<TFontSettings>, styles: Partial<TFontStyles>) => void;
|
|
12
15
|
};
|
|
13
16
|
export type TFontSettingEditProps = {
|
|
14
|
-
settings: TFontSettings
|
|
15
|
-
|
|
17
|
+
settings: Partial<TFontSettings>;
|
|
18
|
+
styles: Partial<TFontStyles>;
|
|
19
|
+
showSettings?: TFontSettingOptions[];
|
|
20
|
+
onChange?: (settings: Partial<TFontSettings>, styles: Partial<TFontStyles>) => void;
|
|
16
21
|
};
|
|
17
22
|
export declare const FontSettingEdit: React.FC<TFontSettingEditProps>;
|
|
18
23
|
export declare const FontSetting: React.FC<TFontSettingProps>;
|
|
24
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
/* Components */
|
|
3
3
|
import { Space, Switch } from '../../atoms';
|
|
4
4
|
import { ColorSetting } from '../ColorSetting';
|
|
@@ -9,45 +9,46 @@ import { FontFamilySelect } from '../FontFamilySelect';
|
|
|
9
9
|
import { FontWeightSelect } from '../FontWeightSelect';
|
|
10
10
|
import { TextTransformSelect } from '../TextTransformSelect';
|
|
11
11
|
import { TextDecorationSelect } from '../TextDecorationSelect';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
fontFamily: settings.fontFamily,
|
|
16
|
-
fontColor: settings.fontColor,
|
|
17
|
-
fontSize: settings.fontSize,
|
|
18
|
-
fontWeight: settings.fontWeight,
|
|
19
|
-
lineHeight: settings.lineHeight,
|
|
20
|
-
letterSpacing: settings.letterSpacing,
|
|
21
|
-
textTransform: settings.textTransform,
|
|
22
|
-
textDecoration: settings.textDecoration,
|
|
23
|
-
fontStyle: settings.fontItalic ? 'italic' : 'normal',
|
|
24
|
-
});
|
|
25
|
-
const handleChange = (setting) => {
|
|
12
|
+
import { FONT_SETTING_DEFAULT, FONT_STYLE_DEFAULT } from './constants';
|
|
13
|
+
export const FontSettingEdit = ({ settings, styles, showSettings, onChange, }) => {
|
|
14
|
+
const handleChange = (setting, style) => {
|
|
26
15
|
if (typeof onChange === 'function') {
|
|
27
16
|
const newSettings = Object.assign(Object.assign({}, settings), setting);
|
|
28
|
-
const newStyles =
|
|
17
|
+
const newStyles = Object.assign(Object.assign({}, styles), style);
|
|
29
18
|
onChange(newSettings, newStyles);
|
|
30
19
|
}
|
|
31
20
|
};
|
|
32
|
-
|
|
33
|
-
React.createElement(FontFamilySelect, { label: "Font Family", value: settings === null || settings === void 0 ? void 0 : settings.fontFamily, onChange:
|
|
34
|
-
React.createElement(ColorSetting, { label: "Font Color", color: settings === null || settings === void 0 ? void 0 : settings.fontColor, onChange: fontColor => handleChange({ fontColor }) }),
|
|
35
|
-
React.createElement(SettingWrapper, { label: "Font Size", vertical: true },
|
|
36
|
-
React.createElement(SliderWithInputNumber, { value: typeof (settings === null || settings === void 0 ? void 0 : settings.fontSize) !== 'undefined' ? +settings.fontSize : 0, onAfterChange: fontSize => handleChange({ fontSize }) })),
|
|
37
|
-
React.createElement(FontWeightSelect, { label: "Font Weight", value: settings === null || settings === void 0 ? void 0 : settings.fontWeight,
|
|
38
|
-
React.createElement(SettingWrapper, { label: "Line Height", vertical: true },
|
|
39
|
-
React.createElement(SliderWithInputNumber, { defaultValue: typeof (settings === null || settings === void 0 ? void 0 : settings.lineHeight) !== 'undefined' ? +settings.lineHeight : 0, min: 1, max: 5, step: 0.1, onAfterChange: lineHeight => handleChange({ lineHeight }) })),
|
|
40
|
-
React.createElement(SettingWrapper, { label: "Letter Spacing", vertical: true },
|
|
41
|
-
React.createElement(SliderWithInputNumber, { defaultValue: typeof (settings === null || settings === void 0 ? void 0 : settings.letterSpacing) !== 'undefined' ? +settings.letterSpacing : 0, min: -10, max: 10, onAfterChange: letterSpacing => handleChange({ letterSpacing }) })),
|
|
42
|
-
React.createElement(TextTransformSelect, { label: "Text Transform", value: settings === null || settings === void 0 ? void 0 : settings.textTransform, onChange: textTransform => handleChange({ textTransform }) }),
|
|
43
|
-
React.createElement(TextDecorationSelect, { label: "Text Decoration", value: settings === null || settings === void 0 ? void 0 : settings.textDecoration, onChange: textDecoration => handleChange({ textDecoration }) }),
|
|
44
|
-
React.createElement(SettingWrapper, { label: "Font Style Italic" },
|
|
45
|
-
React.createElement(Switch, { checked: settings === null || settings === void 0 ? void 0 : settings.fontItalic, onChange: fontItalic => handleChange({ fontItalic }) })))
|
|
21
|
+
const settingMap = useMemo(() => ({
|
|
22
|
+
fontFamily: (React.createElement(FontFamilySelect, { label: "Font Family", value: settings === null || settings === void 0 ? void 0 : settings.fontFamily, onChange: fontFamily => handleChange({ fontFamily }, { fontFamily }) })),
|
|
23
|
+
color: (React.createElement(ColorSetting, { label: "Font Color", color: settings === null || settings === void 0 ? void 0 : settings.fontColor, onChange: fontColor => handleChange({ fontColor }, { color: fontColor }) })),
|
|
24
|
+
fontSize: (React.createElement(SettingWrapper, { label: "Font Size", vertical: true },
|
|
25
|
+
React.createElement(SliderWithInputNumber, { value: typeof (settings === null || settings === void 0 ? void 0 : settings.fontSize) !== 'undefined' ? +settings.fontSize : 0, onAfterChange: fontSize => handleChange({ fontSize }, { fontSize }) }))),
|
|
26
|
+
fontWeight: (React.createElement(FontWeightSelect, { label: "Font Weight", value: settings === null || settings === void 0 ? void 0 : settings.fontWeight, onChange: fontWeight => handleChange({ fontWeight }, { fontWeight }) })),
|
|
27
|
+
lineHeight: (React.createElement(SettingWrapper, { label: "Line Height", vertical: true },
|
|
28
|
+
React.createElement(SliderWithInputNumber, { defaultValue: typeof (settings === null || settings === void 0 ? void 0 : settings.lineHeight) !== 'undefined' ? +settings.lineHeight : 0, min: 1, max: 5, step: 0.1, onAfterChange: lineHeight => handleChange({ lineHeight }, { lineHeight }) }))),
|
|
29
|
+
letterSpacing: (React.createElement(SettingWrapper, { label: "Letter Spacing", vertical: true },
|
|
30
|
+
React.createElement(SliderWithInputNumber, { defaultValue: typeof (settings === null || settings === void 0 ? void 0 : settings.letterSpacing) !== 'undefined' ? +settings.letterSpacing : 0, min: -10, max: 10, onAfterChange: letterSpacing => handleChange({ letterSpacing }, { letterSpacing }) }))),
|
|
31
|
+
textTransform: (React.createElement(TextTransformSelect, { label: "Text Transform", value: settings === null || settings === void 0 ? void 0 : settings.textTransform, onChange: textTransform => handleChange({ textTransform }, { textTransform }) })),
|
|
32
|
+
textDecoration: (React.createElement(TextDecorationSelect, { label: "Text Decoration", value: settings === null || settings === void 0 ? void 0 : settings.textDecoration, onChange: textDecoration => handleChange({ textDecoration }, { textDecoration }) })),
|
|
33
|
+
italic: (React.createElement(SettingWrapper, { label: "Font Style Italic" },
|
|
34
|
+
React.createElement(Switch, { checked: settings === null || settings === void 0 ? void 0 : settings.fontItalic, onChange: fontItalic => handleChange({ fontItalic }, { fontStyle: fontItalic ? 'italic' : 'normal' }) }))),
|
|
35
|
+
}),
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
[settings]);
|
|
38
|
+
const filteredSetting = useMemo(() => {
|
|
39
|
+
if (!showSettings || (showSettings === null || showSettings === void 0 ? void 0 : showSettings.length) === 0) {
|
|
40
|
+
return Object.keys(settingMap).map(keySetting => settingMap[keySetting]);
|
|
41
|
+
}
|
|
42
|
+
return showSettings.map(keySetting => settingMap[keySetting]);
|
|
43
|
+
}, [showSettings, settingMap]);
|
|
44
|
+
return React.createElement(Space, { direction: "vertical" }, filteredSetting);
|
|
46
45
|
};
|
|
47
46
|
export const FontSetting = (props) => {
|
|
48
|
-
const { label, settings, wrapperProps, popoverProps, childrenProps, onChange } = props;
|
|
49
|
-
return (React.createElement(SettingWrapperPopover, { label: label !== null && label !== void 0 ? label : 'Font Settings',
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const { label, settings, styles, wrapperProps, popoverProps, childrenProps, showSettings, onChange, } = props;
|
|
48
|
+
return (React.createElement(SettingWrapperPopover, { label: label !== null && label !== void 0 ? label : 'Font Settings', popoverProps: Object.assign({ overlayStyle: { top: 0 }, placement: 'bottomRight' }, popoverProps), wrapperProps: Object.assign({ containerStyle: { minWidth: '288px' } }, wrapperProps) },
|
|
49
|
+
React.createElement(FontSettingEdit, Object.assign({ settings: settings, styles: styles, showSettings: showSettings, onChange: onChange }, childrenProps))));
|
|
50
|
+
};
|
|
51
|
+
FontSetting.defaultProps = {
|
|
52
|
+
settings: FONT_SETTING_DEFAULT,
|
|
53
|
+
styles: FONT_STYLE_DEFAULT,
|
|
53
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.3.3-beta.
|
|
3
|
+
"version": "1.3.3-beta.5",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"unpkg": "dist/index.js",
|
|
20
20
|
"types": "es/index.d.ts",
|
|
21
21
|
"scripts": {
|
|
22
|
+
"publish": "npm run clean && npm run build:es",
|
|
22
23
|
"build:es": "npm run copy-files && npm run ts-compile",
|
|
23
24
|
"clean": "rimraf dist lib es",
|
|
24
25
|
"dev": "vite",
|