pixel-react 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/AppHeader/types.d.ts +11 -2
- package/lib/components/Avatar/Avatar.d.ts +5 -0
- package/lib/components/Avatar/Avatar.stories.d.ts +10 -0
- package/lib/components/Avatar/index.d.ts +1 -0
- package/lib/components/Avatar/types.d.ts +26 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +6 -7
- package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +49 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +3 -3
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +5 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +6 -6
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +11 -11
- package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +5 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +3 -3
- package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +11 -48
- package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +11 -12
- package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +16 -0
- package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +0 -3
- package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +12 -0
- package/lib/components/ExcelFile/Types.d.ts +2 -49
- package/lib/components/Form/Form.d.ts +1 -15
- package/lib/components/Form/Form.stories.d.ts +6 -5
- package/lib/components/Form/Forms.d.ts +8 -0
- package/lib/components/Form/index.d.ts +1 -1
- package/lib/components/InputWithDropdown/types.d.ts +1 -1
- package/lib/components/LabelEditTextField/LabelEditTextField.d.ts +5 -0
- package/lib/components/LabelEditTextField/LabelEditTextField.stories.d.ts +11 -0
- package/lib/components/LabelEditTextField/index.d.ts +1 -0
- package/lib/components/LabelEditTextField/types.d.ts +38 -0
- package/lib/components/MenuOption/types.d.ts +7 -7
- package/lib/components/ModulesChip/ModuleChip.d.ts +4 -0
- package/lib/components/ModulesChip/ModuleChip.stories.d.ts +6 -0
- package/lib/components/ModulesChip/index.d.ts +1 -0
- package/lib/components/ModulesChip/types.d.ts +14 -0
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +1 -0
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +2 -0
- package/lib/components/Select/types.d.ts +11 -4
- package/lib/components/Toastify/Toastify.d.ts +8 -0
- package/lib/components/Toastify/Toastify.stories.d.ts +6 -0
- package/lib/components/Toastify/index.d.ts +1 -0
- package/lib/components/Toastify/types.d.ts +7 -0
- package/lib/components/Tooltip/types.d.ts +6 -0
- package/lib/components/Typography/types.d.ts +1 -0
- package/lib/index.d.ts +130 -29
- package/lib/index.esm.js +26882 -872
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +26881 -866
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/getSelectOptionValue/getSelectOptionValue.d.ts +8 -0
- package/package.json +1 -1
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
- package/src/assets/Themes/BaseTheme.scss +10 -1
- package/src/assets/Themes/DarkTheme.scss +19 -8
- package/src/assets/icons/client_profile.svg +4 -0
- package/src/assets/icons/fireflink_finder_logo.svg +7 -0
- package/src/assets/icons/fireflink_platform.svg +4 -0
- package/src/assets/icons/license_expired.svg +20 -0
- package/src/components/AppHeader/AppHeader.scss +5 -2
- package/src/components/AppHeader/AppHeader.stories.tsx +24 -3
- package/src/components/AppHeader/AppHeader.tsx +29 -11
- package/src/components/AppHeader/types.ts +11 -3
- package/src/components/Avatar/Avatar.scss +24 -0
- package/src/components/Avatar/Avatar.stories.tsx +56 -0
- package/src/components/Avatar/Avatar.tsx +25 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +27 -0
- package/src/components/Drawer/Drawer.scss +0 -1
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/ExcelFile/ColorBarselector/ColorBarSelector.scss +0 -2
- package/src/components/ExcelFile/ContextMenu/ContextMenu.scss +1 -4
- package/src/components/ExcelFile/ContextMenu/ContextMenu.tsx +0 -1
- package/src/components/ExcelFile/ExcelFile/Excel/ActiveCell.tsx +13 -13
- package/src/components/ExcelFile/ExcelFile/Excel/Cell.tsx +13 -12
- package/src/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.tsx +40 -32
- package/src/components/ExcelFile/ExcelFile/Excel/Copied.tsx +4 -4
- package/src/components/ExcelFile/ExcelFile/Excel/CornerIndicator.tsx +10 -10
- package/src/components/ExcelFile/ExcelFile/Excel/DataEditor.tsx +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/DataViewer.tsx +10 -10
- package/src/components/ExcelFile/ExcelFile/Excel/FloatingRect.tsx +6 -6
- package/src/components/ExcelFile/ExcelFile/Excel/HeaderRow.tsx +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/Row.tsx +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/RowIndicator.tsx +34 -27
- package/src/components/ExcelFile/ExcelFile/Excel/Selected.tsx +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/{Spreadsheet.css → Spreadsheet.scss} +21 -37
- package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.tsx +87 -78
- package/src/components/ExcelFile/ExcelFile/Excel/Table.tsx +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/actions.ts +121 -31
- package/src/components/ExcelFile/ExcelFile/Excel/areModelsEqual.ts +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/context.ts +4 -4
- package/src/components/ExcelFile/ExcelFile/Excel/engine/engine.ts +7 -7
- package/src/components/ExcelFile/ExcelFile/Excel/engine/formula.ts +11 -11
- package/src/components/ExcelFile/ExcelFile/Excel/engine/index.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-graph.ts +3 -3
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-hash.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-set.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/index.ts +12 -11
- package/src/components/ExcelFile/ExcelFile/Excel/matrix.ts +18 -24
- package/src/components/ExcelFile/ExcelFile/Excel/point-range.ts +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +311 -41
- package/src/components/ExcelFile/ExcelFile/Excel/selection.ts +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/types.ts +14 -66
- package/src/components/ExcelFile/ExcelFile/Excel/typings/fast-formula-parser.d.ts +8 -8
- package/src/components/ExcelFile/ExcelFile/Excel/use-dispatch.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/use-selector.ts +3 -3
- package/src/components/ExcelFile/ExcelFile/Excel/util.ts +21 -22
- package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +0 -3
- package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +45 -403
- package/src/components/ExcelFile/ExcelFile.stories.tsx +10 -29
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +1 -12
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +0 -3
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +147 -127
- package/src/components/ExcelFile/Types.ts +3 -70
- package/src/components/ExcelFile/index.ts +1 -1
- package/src/components/Form/Form.d.ts +3 -0
- package/src/components/Form/Form.scss +31 -4
- package/src/components/Form/Form.stories.tsx +172 -138
- package/src/components/Form/Form.ts +2 -0
- package/src/components/Form/Forms.tsx +25 -0
- package/src/components/Form/index.ts +1 -1
- package/src/components/Icon/Icons.scss +1 -0
- package/src/components/Icon/iconList.ts +8 -0
- package/src/components/IconButton/IconButton.scss +1 -1
- package/src/components/InputWithDropdown/types.ts +1 -1
- package/src/components/LabelEditTextField/LabelEditTextField.scss +85 -0
- package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +136 -0
- package/src/components/LabelEditTextField/LabelEditTextField.tsx +207 -0
- package/src/components/LabelEditTextField/index.ts +1 -0
- package/src/components/LabelEditTextField/types.ts +38 -0
- package/src/components/MenuOption/types.ts +7 -6
- package/src/components/ModulesChip/ModuleChip.scss +20 -0
- package/src/components/ModulesChip/ModuleChip.stories.tsx +41 -0
- package/src/components/ModulesChip/ModuleChip.tsx +31 -0
- package/src/components/ModulesChip/index.ts +1 -0
- package/src/components/ModulesChip/types.ts +14 -0
- package/src/components/MultiSelect/Dropdown.tsx +6 -1
- package/src/components/MultiSelect/MultiSelect.scss +17 -10
- package/src/components/MultiSelect/MultiSelect.stories.tsx +16 -4
- package/src/components/MultiSelect/MultiSelect.tsx +11 -4
- package/src/components/MultiSelect/MultiSelectTypes.ts +4 -3
- package/src/components/Select/Select.scss +4 -0
- package/src/components/Select/Select.stories.tsx +5 -3
- package/src/components/Select/Select.tsx +15 -7
- package/src/components/Select/components/Dropdown/Dropdown.tsx +3 -1
- package/src/components/Select/components/Dropdown/dropdownTypes.ts +3 -0
- package/src/components/Select/types.ts +12 -5
- package/src/components/Toastify/Toastify.stories.tsx +52 -0
- package/src/components/Toastify/Toastify.tsx +66 -0
- package/src/components/Toastify/index.ts +1 -0
- package/src/components/Toastify/types.ts +8 -0
- package/src/components/Tooltip/Tooltip.tsx +2 -1
- package/src/components/Tooltip/types.ts +6 -0
- package/src/components/Typography/Typography.scss +12 -4
- package/src/components/Typography/Typography.stories.tsx +2 -0
- package/src/components/Typography/Typography.tsx +2 -0
- package/src/components/Typography/types.ts +1 -0
- package/src/index.ts +12 -2
- package/src/utils/getSelectOptionValue/getSelectOptionValue.ts +31 -0
- package/src/components/ExcelFile/ChangeExcelStyles.tsx +0 -78
- package/src/components/ExcelFile/ImportExcelStyles.tsx +0 -86
- package/src/components/Form/Form.tsx +0 -57
@@ -7,6 +7,7 @@ import Typography from '../../../Typography';
|
|
7
7
|
import { ffid } from '../../../../utils/ffID/ffid';
|
8
8
|
import { ThemeContext } from '../../../ThemeProvider/ThemeProvider';
|
9
9
|
import classNames from 'classnames';
|
10
|
+
import { getLabel } from '../../../../utils/getSelectOptionValue/getSelectOptionValue';
|
10
11
|
|
11
12
|
const Dropdown = ({
|
12
13
|
onSelectBlur,
|
@@ -15,6 +16,7 @@ const Dropdown = ({
|
|
15
16
|
options = [],
|
16
17
|
optionZIndex = 100,
|
17
18
|
inputRef,
|
19
|
+
labelAccessor,
|
18
20
|
}: DropDownListProps) => {
|
19
21
|
const themeContext = useContext(ThemeContext);
|
20
22
|
const currentTheme = themeContext?.currentTheme;
|
@@ -71,7 +73,7 @@ const Dropdown = ({
|
|
71
73
|
color="var(--ff-select-text-color)"
|
72
74
|
onClick={() => onSelectOptionSelector(option)}
|
73
75
|
>
|
74
|
-
{option
|
76
|
+
{getLabel(option, labelAccessor)}
|
75
77
|
</Typography>
|
76
78
|
))
|
77
79
|
) : (
|
@@ -7,6 +7,8 @@ export interface DropDownListProps {
|
|
7
7
|
options?: Option[];
|
8
8
|
optionZIndex?: number;
|
9
9
|
inputRef?: React.RefObject<HTMLInputElement>;
|
10
|
+
labelAccessor?: string;
|
11
|
+
valueAccessor?: string;
|
10
12
|
}
|
11
13
|
|
12
14
|
export const dropdownDefaultCSSData = {
|
@@ -17,3 +19,4 @@ export const dropdownDefaultCSSData = {
|
|
17
19
|
// Future use case if we provide padding-top, padding-bottom for option wrapper
|
18
20
|
dropDownWrapperPadding: 0,
|
19
21
|
};
|
22
|
+
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { ReactNode } from 'react';
|
2
|
-
|
3
1
|
export interface SelectProps {
|
4
2
|
/*
|
5
3
|
* Label for the select dropdown
|
@@ -69,6 +67,15 @@ export interface SelectProps {
|
|
69
67
|
* selectedOptionColor prop provides the custom color for the selected option
|
70
68
|
*/
|
71
69
|
selectedOptionColor?: string;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Label accessor
|
73
|
+
*/
|
74
|
+
labelAccessor?: string;
|
75
|
+
/**
|
76
|
+
* Value accessor
|
77
|
+
*/
|
78
|
+
valueAccessor?: string;
|
72
79
|
}
|
73
80
|
|
74
81
|
export interface DrowdownPosition {
|
@@ -124,8 +131,8 @@ export type SelectAction =
|
|
124
131
|
};
|
125
132
|
};
|
126
133
|
|
134
|
+
type OptionValue = any;
|
135
|
+
|
127
136
|
export interface Option {
|
128
|
-
|
129
|
-
value: string;
|
130
|
-
disabled?: boolean;
|
137
|
+
[key: string]: OptionValue;
|
131
138
|
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
2
|
+
import { Toastify, toast } from './Toastify';
|
3
|
+
import Button from '../Button';
|
4
|
+
|
5
|
+
const meta: Meta<typeof Toastify> = {
|
6
|
+
title: 'Components/Toastify',
|
7
|
+
component: Toastify,
|
8
|
+
parameters: {
|
9
|
+
layout: 'centered',
|
10
|
+
},
|
11
|
+
tags: ['autodocs'],
|
12
|
+
};
|
13
|
+
|
14
|
+
type Story = StoryObj<typeof Toastify>;
|
15
|
+
|
16
|
+
const defaultArgs = {
|
17
|
+
isOpen: false,
|
18
|
+
toastTitle: 'Success',
|
19
|
+
toastMessage: 'Variable name Requested for Review successfully',
|
20
|
+
closeButtonLabel: 'x',
|
21
|
+
displayDuration: 3000,
|
22
|
+
};
|
23
|
+
|
24
|
+
export const Controlled: Story = {
|
25
|
+
args: {
|
26
|
+
...defaultArgs,
|
27
|
+
},
|
28
|
+
// import { Toastify, toast } from 'pixel-react';
|
29
|
+
render: () => (
|
30
|
+
<>
|
31
|
+
{/* Render Toastify to allow toast notifications */}
|
32
|
+
<Toastify />
|
33
|
+
|
34
|
+
{/* Button to trigger a toast notification */}
|
35
|
+
<Button
|
36
|
+
variant="primary"
|
37
|
+
onClick={() => toast.success('Your request was successful!')}
|
38
|
+
>
|
39
|
+
Show Success Toast
|
40
|
+
</Button>
|
41
|
+
<br/>
|
42
|
+
<Button
|
43
|
+
variant="delete"
|
44
|
+
onClick={() => toast.error('Something went wrong!')}
|
45
|
+
>
|
46
|
+
Show Error Toast
|
47
|
+
</Button>
|
48
|
+
</>
|
49
|
+
),
|
50
|
+
};
|
51
|
+
|
52
|
+
export default meta;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { useState, useRef } from 'react';
|
2
|
+
import Toaster from '../Toast/Toast';
|
3
|
+
import { Variant, ToastProps } from './types';
|
4
|
+
|
5
|
+
let openToast: (variant: Variant, message: string) => void;
|
6
|
+
|
7
|
+
export const Toastify = () => {
|
8
|
+
const [toastProps, setToastProps] = useState<ToastProps>({
|
9
|
+
isOpen: false,
|
10
|
+
variant: 'info',
|
11
|
+
toastTitle: '',
|
12
|
+
toastMessage: '',
|
13
|
+
});
|
14
|
+
|
15
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
16
|
+
|
17
|
+
openToast = (variant: Variant, message: string) => {
|
18
|
+
// Clear the previous timeout if it exists
|
19
|
+
if (timeoutRef.current) {
|
20
|
+
clearTimeout(timeoutRef.current);
|
21
|
+
timeoutRef.current = null;
|
22
|
+
}
|
23
|
+
|
24
|
+
const title =
|
25
|
+
variant === 'danger'
|
26
|
+
? 'Error!'
|
27
|
+
: variant.charAt(0).toUpperCase() + variant.slice(1);
|
28
|
+
// Close the existing toast if open, and then immediately show the new one
|
29
|
+
setToastProps((prev) => ({
|
30
|
+
...prev,
|
31
|
+
isOpen: false,
|
32
|
+
}));
|
33
|
+
|
34
|
+
setTimeout(() => {
|
35
|
+
setToastProps({
|
36
|
+
isOpen: true,
|
37
|
+
variant,
|
38
|
+
toastTitle: `${title}!`,
|
39
|
+
toastMessage: message,
|
40
|
+
});
|
41
|
+
}, 10);
|
42
|
+
|
43
|
+
timeoutRef.current = setTimeout(() => {
|
44
|
+
setToastProps((prev) => ({ ...prev, isOpen: false }));
|
45
|
+
}, 3000);
|
46
|
+
};
|
47
|
+
|
48
|
+
return (
|
49
|
+
<Toaster
|
50
|
+
isOpen={toastProps.isOpen}
|
51
|
+
variant={toastProps.variant}
|
52
|
+
toastTitle={toastProps.toastTitle}
|
53
|
+
toastMessage={toastProps.toastMessage}
|
54
|
+
/>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
export default Toastify;
|
59
|
+
|
60
|
+
// Utility to trigger toast messages outside of the Toastify component
|
61
|
+
export const toast = {
|
62
|
+
success: (message: string) => openToast('success', message),
|
63
|
+
error: (message: string) => openToast('danger', message),
|
64
|
+
warning: (message: string) => openToast('warning', message),
|
65
|
+
info: (message: string) => openToast('info', message),
|
66
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Toastify';
|
@@ -17,6 +17,7 @@ const Tooltip: React.FC<TooltipProps> = ({
|
|
17
17
|
children,
|
18
18
|
placement = 'bottom',
|
19
19
|
disabled = false,
|
20
|
+
zIndex = 99,
|
20
21
|
}) => {
|
21
22
|
const [isVisible, setIsVisible] = useState(false);
|
22
23
|
const titleRef: TitleRef = useRef(null);
|
@@ -178,7 +179,7 @@ const Tooltip: React.FC<TooltipProps> = ({
|
|
178
179
|
createPortal(
|
179
180
|
<div
|
180
181
|
ref={titleRef}
|
181
|
-
style={styles[placement]}
|
182
|
+
style={{ ...styles[placement], zIndex }}
|
182
183
|
className={classNames('ff-tooltip', currentTheme, {
|
183
184
|
'ff-tooltip--visible': isVisible,
|
184
185
|
})}
|
@@ -6,28 +6,32 @@
|
|
6
6
|
@font-face {
|
7
7
|
font-family: 'Poppins';
|
8
8
|
font-weight: 400;
|
9
|
-
src:
|
9
|
+
src:
|
10
|
+
local('Poppins-Regular'),
|
10
11
|
url(../../fonts/Poppins/Poppins-Regular.ttf) format('truetype');
|
11
12
|
}
|
12
13
|
|
13
14
|
@font-face {
|
14
15
|
font-family: 'Poppins';
|
15
16
|
font-weight: 500;
|
16
|
-
src:
|
17
|
+
src:
|
18
|
+
local('Poppins-Medium'),
|
17
19
|
url(../../fonts/Poppins/Poppins-Medium.ttf) format('truetype');
|
18
20
|
}
|
19
21
|
|
20
22
|
@font-face {
|
21
23
|
font-family: 'Poppins';
|
22
24
|
font-weight: 600;
|
23
|
-
src:
|
25
|
+
src:
|
26
|
+
local('Poppins-SemiBold'),
|
24
27
|
url(../../fonts/Poppins/Poppins-SemiBold.ttf) format('truetype');
|
25
28
|
}
|
26
29
|
|
27
30
|
@font-face {
|
28
31
|
font-family: 'Poppins';
|
29
32
|
font-weight: 700;
|
30
|
-
src:
|
33
|
+
src:
|
34
|
+
local('Poppins-Bold'),
|
31
35
|
url(../../fonts/Poppins/Poppins-Bold.ttf) format('truetype');
|
32
36
|
}
|
33
37
|
|
@@ -46,4 +50,8 @@
|
|
46
50
|
&--bold {
|
47
51
|
font-weight: 700;
|
48
52
|
}
|
53
|
+
.required-asterisk {
|
54
|
+
color: var(--input-error-text-color);
|
55
|
+
padding-right: 4px;
|
56
|
+
}
|
49
57
|
}
|
@@ -14,6 +14,7 @@ type Story = StoryObj<typeof Typography>;
|
|
14
14
|
|
15
15
|
export const Docs: Story = {
|
16
16
|
args: {
|
17
|
+
required: false,
|
17
18
|
children: 'Typography',
|
18
19
|
},
|
19
20
|
};
|
@@ -51,6 +52,7 @@ export const Bold14px: Story = {
|
|
51
52
|
fontSize: '16px',
|
52
53
|
as: 'h2',
|
53
54
|
children: 'This is Bold text with 700 font weight and 16px font size.',
|
55
|
+
required: true,
|
54
56
|
},
|
55
57
|
};
|
56
58
|
|
@@ -14,6 +14,7 @@ const Typography: React.FC<TypographyProps> = ({
|
|
14
14
|
children,
|
15
15
|
htmlFor = '',
|
16
16
|
onClick = () => {},
|
17
|
+
required = false,
|
17
18
|
}) => {
|
18
19
|
const fontSizeValue =
|
19
20
|
typeof fontSize === 'number' ? `${fontSize}px` : fontSize;
|
@@ -31,6 +32,7 @@ const Typography: React.FC<TypographyProps> = ({
|
|
31
32
|
}}
|
32
33
|
onClick={onClick}
|
33
34
|
>
|
35
|
+
{required && <span className="required-asterisk">*</span>}
|
34
36
|
{children}
|
35
37
|
</Element>
|
36
38
|
);
|
package/src/index.ts
CHANGED
@@ -23,7 +23,7 @@ import LazyLoad from './components/LazyLoad/LazyLoad';
|
|
23
23
|
import ThemeProvider from './components/ThemeProvider';
|
24
24
|
import Typography from './components/Typography';
|
25
25
|
import useTheme from './hooks/useTheme';
|
26
|
-
import
|
26
|
+
import Forms from './components/Form/Forms';
|
27
27
|
import InputWithDropdown from './components/InputWithDropdown';
|
28
28
|
import RadioButton from './components/RadioButton';
|
29
29
|
import RadioGroup from './components/RadioGroup';
|
@@ -50,6 +50,11 @@ import IconRadioGroup from './components/IconRadioGroup';
|
|
50
50
|
import MachineInputField from './components/MachineInputField';
|
51
51
|
import SequentialConnectingBranch from './components/SequentialConnectingBranch';
|
52
52
|
import AttachmentButton from './components/AttachmentButton';
|
53
|
+
import { Toastify, toast } from './components/Toastify/Toastify';
|
54
|
+
|
55
|
+
import LabelEditTextField from './components/LabelEditTextField';
|
56
|
+
import ExcelFile from './components/ExcelFile';
|
57
|
+
import ModuleChip from './components/ModulesChip/ModuleChip';
|
53
58
|
|
54
59
|
// Utils imports
|
55
60
|
import { checkEmpty } from './utils/checkEmpty/checkEmpty';
|
@@ -93,7 +98,7 @@ export {
|
|
93
98
|
Table,
|
94
99
|
RadioButton,
|
95
100
|
RadioGroup,
|
96
|
-
|
101
|
+
Forms,
|
97
102
|
MiniModal,
|
98
103
|
Container,
|
99
104
|
Row,
|
@@ -120,7 +125,12 @@ export {
|
|
120
125
|
MachineInputField,
|
121
126
|
SequentialConnectingBranch,
|
122
127
|
AttachmentButton,
|
128
|
+
LabelEditTextField,
|
129
|
+
ExcelFile,
|
123
130
|
IconRadioGroup,
|
131
|
+
Toastify,
|
132
|
+
toast,
|
133
|
+
ModuleChip,
|
124
134
|
|
125
135
|
// utils exports
|
126
136
|
checkEmpty,
|
@@ -0,0 +1,31 @@
|
|
1
|
+
type DynamicValues = any;
|
2
|
+
|
3
|
+
interface dynamicObject {
|
4
|
+
[key: string]: DynamicValues;
|
5
|
+
}
|
6
|
+
|
7
|
+
type accessorType = string | undefined;
|
8
|
+
|
9
|
+
export const getLabel = (
|
10
|
+
option: dynamicObject,
|
11
|
+
accessor: accessorType = ''
|
12
|
+
) => {
|
13
|
+
if (!accessor) {
|
14
|
+
if (option.hasOwnProperty('label')) {
|
15
|
+
return option.label;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
return option[accessor];
|
19
|
+
};
|
20
|
+
|
21
|
+
export const getValue = (
|
22
|
+
option: dynamicObject,
|
23
|
+
accessor: accessorType = ''
|
24
|
+
) => {
|
25
|
+
if (!accessor) {
|
26
|
+
if (option.hasOwnProperty('value')) {
|
27
|
+
return option.label;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return option[accessor];
|
31
|
+
};
|
@@ -1,78 +0,0 @@
|
|
1
|
-
import { CellBase } from "./ExcelFile/Excel";
|
2
|
-
|
3
|
-
interface ChangeExcelStylesOptions {
|
4
|
-
sheetName: string;
|
5
|
-
styleType: string;
|
6
|
-
value: string;
|
7
|
-
selectedCell: { row: number; column: number }[];
|
8
|
-
}
|
9
|
-
|
10
|
-
export default function ChangeExcelStyles(
|
11
|
-
setWorksheetsData: React.Dispatch<React.SetStateAction<{ [key: string]: Matrix<CellBase>; }>>,
|
12
|
-
options: ChangeExcelStylesOptions
|
13
|
-
) {
|
14
|
-
const { sheetName, styleType, value, selectedCell } = options;
|
15
|
-
|
16
|
-
setWorksheetsData((prev) => {
|
17
|
-
if (!prev[sheetName]) {
|
18
|
-
return prev;
|
19
|
-
}
|
20
|
-
|
21
|
-
const sheetData = prev[sheetName]!;
|
22
|
-
const selectedCells = new Set(
|
23
|
-
selectedCell.map(({ row, column }) => `${row}-${column}`)
|
24
|
-
);
|
25
|
-
|
26
|
-
const updatedSheetData: Matrix<CellBase> = sheetData.map((row, rowIndex) =>
|
27
|
-
row.map((cell, columnIndex) => {
|
28
|
-
const isSelected = selectedCells.has(`${rowIndex}-${columnIndex}`);
|
29
|
-
if (isSelected&&cell!==undefined) {
|
30
|
-
let newStyle = { ...cell.style };
|
31
|
-
|
32
|
-
switch (styleType) {
|
33
|
-
// case 'border':
|
34
|
-
// newStyle = handleBorderChange(newStyle, value);
|
35
|
-
// break;
|
36
|
-
// case 'alignment':
|
37
|
-
// newStyle = handleAlignmentChange(newStyle, value);
|
38
|
-
// break;
|
39
|
-
// case 'bold':
|
40
|
-
// newStyle = handleBoldChange(newStyle);
|
41
|
-
// break;
|
42
|
-
// case 'italic':
|
43
|
-
// newStyle = handleItalicChange(newStyle);
|
44
|
-
// break;
|
45
|
-
case 'color':
|
46
|
-
newStyle = handleColorChange(newStyle, value);
|
47
|
-
break;
|
48
|
-
case 'backgroundColor':
|
49
|
-
newStyle = handleBackgroundColorChange(newStyle, value);
|
50
|
-
break;
|
51
|
-
default:
|
52
|
-
break;
|
53
|
-
}
|
54
|
-
|
55
|
-
const newValue = cell.value ?? "";
|
56
|
-
|
57
|
-
return { ...cell, style: newStyle, value: newValue };
|
58
|
-
}
|
59
|
-
return cell;
|
60
|
-
})
|
61
|
-
);
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
return { ...prev, [sheetName]: updatedSheetData };
|
66
|
-
});
|
67
|
-
}
|
68
|
-
|
69
|
-
function handleColorChange(style: CellStyle, value: string): CellStyle {
|
70
|
-
return { ...style, color: `#${value}` };
|
71
|
-
}
|
72
|
-
|
73
|
-
function handleBackgroundColorChange(
|
74
|
-
style: CellStyle,
|
75
|
-
value: string
|
76
|
-
): CellStyle {
|
77
|
-
return { ...style, backgroundColor: `#${value}` };
|
78
|
-
}
|
@@ -1,86 +0,0 @@
|
|
1
|
-
interface CellStyle {
|
2
|
-
color?: string;
|
3
|
-
backgroundColor?: string;
|
4
|
-
bold?: boolean;
|
5
|
-
italic?: boolean;
|
6
|
-
name?: string;
|
7
|
-
border: {
|
8
|
-
top: string;
|
9
|
-
bottom: string;
|
10
|
-
left: string;
|
11
|
-
right: string;
|
12
|
-
};
|
13
|
-
alignment: {
|
14
|
-
horizontal?: string;
|
15
|
-
vertical?: string;
|
16
|
-
wrapText?: boolean;
|
17
|
-
};
|
18
|
-
}
|
19
|
-
|
20
|
-
interface CellData {
|
21
|
-
style?: CellStyle;
|
22
|
-
}
|
23
|
-
|
24
|
-
type ImportExcelStylesData = Array<Array<CellData>>;
|
25
|
-
|
26
|
-
export default function ImportExcelStyles(data: ImportExcelStylesData | null) {
|
27
|
-
const getTable = document.querySelector(
|
28
|
-
'.Spreadsheet__table'
|
29
|
-
) as HTMLTableElement | null;
|
30
|
-
|
31
|
-
if (!getTable) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
const tableRows = getTable.querySelectorAll('tr');
|
36
|
-
const tableHeader = getTable.querySelectorAll('th');
|
37
|
-
|
38
|
-
tableHeader.forEach((cell) => {
|
39
|
-
const cellText = cell.innerText.trim();
|
40
|
-
const isNumber = !isNaN(Number(cellText));
|
41
|
-
cell.style.width = isNumber ? '50px' : '150px';
|
42
|
-
});
|
43
|
-
|
44
|
-
if (data) {
|
45
|
-
data.forEach((row, rowIndex) => {
|
46
|
-
const rowData = tableRows[rowIndex + 1] as
|
47
|
-
| HTMLTableRowElement
|
48
|
-
| undefined;
|
49
|
-
|
50
|
-
if (!rowData) return;
|
51
|
-
|
52
|
-
const colData = rowData.querySelectorAll('.Spreadsheet__cell');
|
53
|
-
|
54
|
-
row.forEach((column, columnIndex) => {
|
55
|
-
if (colData[columnIndex] && column.style) {
|
56
|
-
const {
|
57
|
-
color,
|
58
|
-
backgroundColor,
|
59
|
-
bold,
|
60
|
-
italic,
|
61
|
-
name,
|
62
|
-
border,
|
63
|
-
alignment,
|
64
|
-
} = column.style;
|
65
|
-
const cell = colData[columnIndex] as HTMLElement;
|
66
|
-
cell.style.color = color ? `#${color}` : '';
|
67
|
-
cell.style.backgroundColor = backgroundColor
|
68
|
-
? `#${backgroundColor}`
|
69
|
-
: 'white';
|
70
|
-
cell.style.fontWeight = bold ? 'bolder' : 'normal';
|
71
|
-
cell.style.fontStyle = italic ? 'italic' : 'normal';
|
72
|
-
cell.style.fontFamily = name || '';
|
73
|
-
cell.style.borderLeft =
|
74
|
-
border.left === 'NONE' ? '' : `2px solid ${'black'}`;
|
75
|
-
cell.style.borderRight =
|
76
|
-
border.right === 'NONE' ? '' : `2px solid ${'black'}`;
|
77
|
-
cell.style.borderBottom =
|
78
|
-
border.bottom === 'NONE' ? '' : `2px solid ${'black'}`;
|
79
|
-
cell.style.borderTop =
|
80
|
-
border.top === 'NONE' ? '' : `2px solid ${'black'}`;
|
81
|
-
cell.style.textAlign = alignment?.horizontal || 'left';
|
82
|
-
}
|
83
|
-
});
|
84
|
-
});
|
85
|
-
}
|
86
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import {
|
3
|
-
useForm,
|
4
|
-
UseFormProps,
|
5
|
-
SubmitHandler,
|
6
|
-
FieldValues,
|
7
|
-
FieldPath,
|
8
|
-
FieldErrors,
|
9
|
-
} from 'react-hook-form';
|
10
|
-
import './Form.scss';
|
11
|
-
|
12
|
-
interface FormProps<T extends FieldValues> extends UseFormProps<T> {
|
13
|
-
onSubmit: SubmitHandler<T>;
|
14
|
-
children: (props: {
|
15
|
-
register: (name: FieldPath<T>, options?: any) => any;
|
16
|
-
errors: FieldErrors<T>;
|
17
|
-
handleBlur: (field: FieldPath<T>) => void;
|
18
|
-
getValues: () => T;
|
19
|
-
watch: (field?: FieldPath<T>) => any;
|
20
|
-
setValue: (field: FieldPath<T>, value: any, options?: object) => void;
|
21
|
-
}) => React.ReactNode;
|
22
|
-
}
|
23
|
-
|
24
|
-
const Form = <T extends FieldValues>({
|
25
|
-
onSubmit,
|
26
|
-
children,
|
27
|
-
...rest
|
28
|
-
}: FormProps<T>) => {
|
29
|
-
const {
|
30
|
-
register,
|
31
|
-
handleSubmit,
|
32
|
-
formState: { errors },
|
33
|
-
trigger,
|
34
|
-
getValues,
|
35
|
-
watch,
|
36
|
-
setValue
|
37
|
-
} = useForm<T>(rest);
|
38
|
-
|
39
|
-
const handleBlur = async (field: FieldPath<T>) => {
|
40
|
-
await trigger(field);
|
41
|
-
};
|
42
|
-
|
43
|
-
return (
|
44
|
-
<form onSubmit={handleSubmit(onSubmit)}>
|
45
|
-
{children({
|
46
|
-
register,
|
47
|
-
errors,
|
48
|
-
handleBlur,
|
49
|
-
getValues,
|
50
|
-
watch,
|
51
|
-
setValue,
|
52
|
-
})}
|
53
|
-
</form>
|
54
|
-
);
|
55
|
-
};
|
56
|
-
|
57
|
-
export default Form;
|