Skip to content

Commit 3b233eb

Browse files
authored
Merge pull request #3655 from czwe-01/thulasizwe/en/read-only-style
Thulasizwe/en/read only style
2 parents 72d4c0f + c818b3a commit 3b233eb

File tree

58 files changed

+192
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+192
-164
lines changed

shesha-reactjs/src/components/autocomplete/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ const AutocompleteInner: FC<IAutocompleteBaseProps> = (props: IAutocompleteBaseP
244244
};
245245

246246
return (
247-
<div style={{ width: 'fit-content' }}>
248247
<ReadOnlyDisplayFormItem
249248
value={readonlyValue}
250249
type={props.mode === 'multiple' ? 'dropdownMultiple' : 'dropdown'}
@@ -256,7 +255,6 @@ const AutocompleteInner: FC<IAutocompleteBaseProps> = (props: IAutocompleteBaseP
256255
quickviewGetEntityUrl={props.quickviewGetEntityUrl}
257256
quickviewWidth={props.quickviewWidth ? Number(props.quickviewWidth) : null} // quick fix string value of quickviewWidth (from configurator)
258257
/>
259-
</div>
260258
);
261259
}
262260

shesha-reactjs/src/components/autocomplete/models.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ export interface IAutocompleteBaseProps {
126126
* @deprecated
127127
*/
128128
typeShortAlias?: string;
129-
130-
disabledStyleOnReadonly?: boolean;
131129
}
132130

133131
export interface IAutocompleteProps extends Omit<IAutocompleteBaseProps, 'uid'> {

shesha-reactjs/src/components/buttonGroupConfigurator/buttonGroupItem.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const ButtonGroupItem: FC<IButtonGroupItemProps> = ({ item, actionConfigu
3939

4040
const { icon, label, tooltip, iconPosition, size, buttonType, borderColor, borderRadius,
4141
height, width, backgroundColor, fontSize, fontWeight, color, borderStyle, borderWidth,
42-
readOnly, block, danger, disabledStyleOnReadonly } = actualItem;
42+
readOnly, block, danger } = actualItem;
4343

4444
const model = {
4545
...actualItem,
@@ -59,15 +59,14 @@ export const ButtonGroupItem: FC<IButtonGroupItemProps> = ({ item, actionConfigu
5959
const prevStyles = migratePrevStyles(model, initialValues());
6060

6161
const buttonStyles = useFormComponentStyles(prevStyles);
62-
const disableReadonlyStyles = disabledStyleOnReadonly && readOnly;
6362

6463
const newStyles = {
6564
...buttonStyles.dimensionsStyles,
66-
...(['primary', 'default', 'ghost'].includes(item.buttonType) && !disableReadonlyStyles && buttonStyles.borderStyles),
65+
...(['primary', 'default', 'ghost'].includes(item.buttonType) && buttonStyles.borderStyles),
6766
...buttonStyles.fontStyles,
68-
...(['dashed', 'default', 'ghost'].includes(item.buttonType) && !disableReadonlyStyles && buttonStyles.backgroundStyles),
69-
...(['primary', 'default', 'dashed', 'ghost'].includes(item.buttonType) && !disableReadonlyStyles && buttonStyles.shadowStyles),
70-
...(!disableReadonlyStyles && buttonStyles.jsStyle),
67+
...(['dashed', 'default', 'ghost'].includes(item.buttonType) && buttonStyles.backgroundStyles),
68+
...(['primary', 'default', 'dashed', 'ghost'].includes(item.buttonType) && buttonStyles.shadowStyles),
69+
...(buttonStyles.jsStyle),
7170
...buttonStyles.stylingBoxAsCSS,
7271
justifyContent: buttonStyles.fontStyles.textAlign,
7372
};
@@ -85,8 +84,7 @@ export const ButtonGroupItem: FC<IButtonGroupItemProps> = ({ item, actionConfigu
8584
className={classNames('sha-toolbar-btn sha-toolbar-btn-configurable')}
8685
size={size}
8786
block={block}
88-
disabled={readOnly}
89-
style={{ ...newStyles }}
87+
style={{ ...newStyles, ...(readOnly && { cursor: 'not-allowed' }) }}
9088
>
9189
{label}
9290
</Button>

shesha-reactjs/src/components/buttonGroupConfigurator/itemSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ export const getItemSettings = () => {
246246
{
247247
id: nanoid(),
248248
type: 'switch',
249-
propertyName: 'disabledStyleOnReadonly',
250-
label: 'Disable Style On Readonly',
249+
propertyName: 'enableStyleOnReadonly',
250+
label: 'Enable Style On Readonly',
251251
tooltip: 'Removes all visual styling except typography when the component becomes read-only',
252252
jsSetting: true,
253253
hidden: {

shesha-reactjs/src/components/customFile/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface ICustomFileProps extends IInputStyles {
2828
hideFileName?: boolean;
2929
container?: IStyleType;
3030
primaryColor?: string;
31-
disabledStyleOnReadonly?: boolean;
31+
enableStyleOnReadonly?: boolean;
3232
}
3333

3434
export const CustomFile: FC<ICustomFileProps> = (props) => {

shesha-reactjs/src/components/dropdown/dropdown.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export const Dropdown: FC<IDropdownProps> = ({
3434
showItemName,
3535
allowClear = true,
3636
displayStyle,
37-
tagStyle
37+
tagStyle,
38+
enableStyleOnReadonly
3839
}) => {
3940

4041
const { styles } = useStyles({ style });
@@ -143,6 +144,7 @@ export const Dropdown: FC<IDropdownProps> = ({
143144
filterOption={filterOption}
144145
incomeValueFunc={incomeValueFunc}
145146
outcomeValueFunc={outcomeValueFunc}
147+
enableStyleOnReadonly={enableStyleOnReadonly}
146148
/>
147149
);
148150
}
@@ -156,14 +158,13 @@ export const Dropdown: FC<IDropdownProps> = ({
156158
return options?.filter(({ value: currentValue }) => selectedValues.indexOf(currentValue) > -1)?.map(({ label }) => ({ label }));
157159
};
158160

159-
160-
161161
if (readOnly) {
162162
return <ReadOnlyDisplayFormItem
163163
showIcon={showIcon}
164164
solidColor={solidColor}
165165
showItemName={showItemName}
166-
style={displayStyle === 'tags' ? tagStyle : style}
166+
tagStyle={tagStyle}
167+
style={style}
167168
dropdownDisplayMode={displayStyle === 'tags' ? 'tags' : 'raw'}
168169
type={mode === 'multiple' ? 'dropdownMultiple' : 'dropdown'}
169170
value={mode === 'multiple' ?
@@ -224,7 +225,7 @@ export const Dropdown: FC<IDropdownProps> = ({
224225
return (
225226
<Select
226227
{...commonSelectProps}
227-
style={{ ...style }}
228+
style={style}
228229
showSearch
229230
filterOption={filterOption}
230231
placeholder={placeholder}

shesha-reactjs/src/components/dropdown/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ export interface IDropdownProps {
5050
showItemName?: boolean;
5151
showIcon?: boolean;
5252
solidColor?: boolean;
53-
disabledStyleOnReadonly?: boolean;
53+
enableStyleOnReadonly?: boolean;
5454
}

shesha-reactjs/src/components/quickView/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const QuickView: FC<Omit<IQuickViewProps, 'formType'>> = ({
7171
const { backendUrl, httpHeaders } = useSheshaApplication();
7272
const { refetch: fetchForm } = useFormConfiguration({ formId: formIdentifier, lazy: true });
7373
const { notification } = App.useApp();
74-
const {styles, cx} = useStyles();
74+
const { styles, cx } = useStyles();
7575

7676
useEffect(() => {
7777
if (formIdentifier) {
@@ -194,7 +194,7 @@ const QuickView: FC<Omit<IQuickViewProps, 'formType'>> = ({
194194
export const GenericQuickView: FC<IQuickViewProps> = (props) => {
195195
const { getEntityFormId } = useConfigurationItemsLoader();
196196
const [formConfig, setFormConfig] = useState<FormIdentifier>(props.formIdentifier ?? undefined);
197-
const {styles, cx} = useStyles();
197+
const { styles, cx } = useStyles();
198198

199199
useEffect(() => {
200200
if (props.className && !formConfig)

shesha-reactjs/src/components/readOnlyDisplayFormItem/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Space, Switch } from 'antd';
1+
import { Switch } from 'antd';
22
import Checkbox from 'antd/lib/checkbox/Checkbox';
33
import { ValueRenderer } from '@/components/valueRenderer/index';
44
import React, { FC, useMemo } from 'react';
@@ -90,11 +90,10 @@ export const ReadOnlyDisplayFormItem: FC<IReadOnlyDisplayFormItemProps> = (props
9090
solidColor={solidColor}
9191
showItemName={showItemName}
9292
label={displayName}
93-
/>
94-
: <InputField style={style} value={displayName ?? (typeof value === 'object' ? null : value)} />;
93+
/> :
94+
<InputField style={style} value={displayName ?? (typeof value === 'object' ? null : value)} />;
9595
}
9696
}
97-
9897
return null;
9998

10099
case 'dropdownMultiple': {
@@ -103,7 +102,7 @@ export const ReadOnlyDisplayFormItem: FC<IReadOnlyDisplayFormItemProps> = (props
103102

104103
return dropdownDisplayMode === 'raw'
105104
? <InputField style={style} value={values?.join(', ')} />
106-
: <Space size={8}>
105+
: <div style={{ padding: '0px 4px', ...style, display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8, justifyContent: style?.textAlign }}>
107106
{value?.map(({ label, color, icon, value, description }) => {
108107
return <ReflistTag
109108
key={value}
@@ -118,7 +117,7 @@ export const ReadOnlyDisplayFormItem: FC<IReadOnlyDisplayFormItemProps> = (props
118117
label={label}
119118
/>;
120119
})}
121-
</Space>;
120+
</div>;
122121
}
123122

124123
throw new Error(
@@ -135,7 +134,7 @@ export const ReadOnlyDisplayFormItem: FC<IReadOnlyDisplayFormItemProps> = (props
135134
return <Checkbox checked={checked} defaultChecked={defaultChecked} disabled style={style} />;
136135
}
137136
case 'switch': {
138-
return <Switch checked={checked} defaultChecked={defaultChecked} style={{ pointerEvents: 'none', ...style }} />;
137+
return <Switch checked={checked} defaultChecked={defaultChecked} style={{ pointerEvents: 'none', ...style }} size={props.size} />;
139138
}
140139
case 'textArea': {
141140
return <div style={{ ...style, whiteSpace: 'pre-wrap' }}>{value}</div>;

shesha-reactjs/src/components/readOnlyDisplayFormItem/inputField.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { useStyles } from './styles/styles';
33

44
interface IInputFieldProps {
5-
value: string | number | React.ReactNode;
5+
value?: string | number | React.ReactNode;
66
style?: React.CSSProperties;
77
children?: React.ReactNode;
88
}
@@ -14,8 +14,8 @@ function InputField({ value, style, children }: IInputFieldProps) {
1414
const { fontSize, fontWeight, color, fontFamily, textAlign, height, } = style || {};
1515

1616
return value || children ? (
17-
<div style={{ ...style, height: height === 'auto' ? '32px' : height, display: 'flex', alignItems: 'center', justifyContent: textAlign }} >
18-
<div className={styles.inputField} style={{ fontSize, fontWeight, color, fontFamily }}>{value || children}</div>
17+
<div style={{ padding: '4px', ...style, height: height, display: 'flex', alignItems: 'center', justifyContent: textAlign }} >
18+
<div className={styles.inputField} style={{ fontSize, fontWeight, color, fontFamily, whiteSpace: height === 'auto' ? 'pre-wrap' : 'nowrap' }}>{value || children}</div>
1919
</div>
2020
) : null;
2121
}

0 commit comments

Comments
 (0)