* fix style bugs * fix select styles * test: fix font size issue for cypress tests * incorporate ashit feedback * test: addresed review comments for cypress tests * add analytics events * height issue in view mode * incorporate code review feedbacks * incorporate code review feedbacks * refactor: addressed review comments; removed border radius and box shadow for text widget; Updated migrations * feat: Makes shadow and radius controls keyboard accessible (#11547) * makes shadow and radius controls keyboard accessible * removes unused imports * moves options out of render method * fix: changed the misnomer background property name to the relevant property name * fix: border radius issue for the map widget * address qa bugs * address qa bugs * fix ux of theming pane when widget is selected * fix: * added backgroundColor to the video widget * restricted pop-over border radius to 0.375rem * added box shadow for the input group for select widget * fix: added delete icon in the delete theme modal * address qa bugs * change checkbox column size in config * add js convertible to button color * remove unused imports * test: fixed jest tests * fix primary color typo * fix: migrations for the theming * fix: * Removed background color from MultiTreeSelect and TreeSelect component. * grouped button's menu button pop over border radius restricting to 0.375rem. * test: updated Dsl migration UT * address qa bugs * address qa bugs * fix: address qa comments * address qa bugs * fix: * migration issue; * unit test cases; * fix rating widget scroll issue * fix youtube video border radius bug * fix select widget * fix select widgets styles * address qa bugs * merge conflicts * makes the reset button keyboard accessible (#12134) * -resolved merge conflicts * address qa bugs * fix: labelTextSize migration fixes * refactor: * made changes to the fontSizeUtils function * fixed the issue related to unit tests * fix button group widget * remove unused imports * fix: fixed the text size migration for the table widget * refactor: addressed review comments for the table widget theming migration * fix button group widget * add init calls for view mode * json form init theme changes * fix: added migration for boxShadow, borderRadius and textSizes for table widget * fix broken fields * test: fixed unit tests * wip * inconsistancy fixes and schemaItem update in updateHook/fieldConfiguration * feat: init json form migration theming * json form primaryColor -> accentColor * update table widget * update table widget * object field label styling * fix: migration related to the JSON form * fix: fixed labelTextSize migration for JSON form nested widgets * property control nested stylesheet lookup * JSONForm label styles form array items * show label for checkbox field array item * fix button group widget * wip * refactor: addressed table widget review comments * refactor: addressed ashit review comments; * added childStylesheet for widgets * feat: Keyboard navigable Color Picker control (#11797) * Makes ColorPicker keyboard accessible * seperate out keyboard and mouse interactions * fix issue with not focusing back to input * Adds test for Color picker * chore: added comment for the boxShadow property * fix: * added unit test cases for the widget and property utils * resolved warning messages * wip * theme config update * fix merge conflicts * refactor: moved theming migration inside the migrations folder * fix qa bugs * fix jest test * fix: unit test cases * fix table column creation logic * refactor: addressed review comments for migrations * fix: Overriding margin and padding for custom render in the dropdown component (#12875) * * fix for custom render padding and margin in ADS dropdown * * fix for removing padding from normal render options * refactor: moved the boxShadow condition to the variable * fix qa bugs * fix: migration QA callouts for audio recorder widget * refactor: added updated comments for boxShadow migration for table widget * fix theme binfings for JSONForm fields under Object * fix table widget theming bug * fix: addressed code review comments * fix: unit test cases * fix: qa migration callouts * fix table widget theming bug * fix JSONForm currency input dropdown not submit form * Added new tests - AppThemingSpec * fix qa bugs * fix unit test * fix JSONForm cellBorderWidth to have default value post migration * fix unit test * fix qa bugs * remove unused imports * fix qa bugs * fix JSONForm input height issue * fix qa bugs * Updating Theming spec * * dropdown color fixes (#13249) * fix caching issue ; * Fixed Theming tests * fix tests * fix tab widget tests * fix: json form children level migration issue * fix table widget tests * Updated test * updated tests * updated test * updated tests * updated tests * updated pageload * fix cypress tests * remove cypress created files * fix color picker issues * Failure fixes * Fixed some more tests * fix: cypress test failures * fix tests * remove consoles * fix table tests * fix qa bugs * updating snapshots for AppPageLayout_spec as per new UI * fix rating widget bug * fix qa bugs * fix: * cypress failing tests * Migration QA callouts * Removed unused imports * update constract check algo * fix color contrast issue * fix: cypress failure test cases * update font sizes labels * fix regression bugs * fix: * JSON form labelTextSize issue fix * Updated comment for the fontSizeUtility function * migrations issues related to table widget borderRadius and boxShadow * fix: default labelTextSize issue for the Input and Select families * fix regression bugs * fix regression bugs * PassingParams spec - added wait time * fix: font family default value issue on JS toggle * fix js toggle issue in text widget * fix tests * fix tests * fix tests * fix cypress tests * fix regression bugs * fix regression bugs * fix: * refactored table widget migration function as per review comments, * added default value to the widget * fix: failing unit test cases * fix theming spec * fix cypress tests * test: fixed failed cypress test * incorporate ashit feedback * fix cypress tests * fix: addressed review comments * comment out table cypress test * fix merge conflicts * comment out color picker tests Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro.local> Co-authored-by: keyurparalkar <keyur@appsmith.com> Co-authored-by: Aswath K <aswath@appsmith.com> Co-authored-by: Nayan <nayan@appsmith.com> Co-authored-by: Ashit Rath <ashit@appsmith.com> Co-authored-by: balajisoundar <balaji@appsmith.com> Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: apple <nandan@thinkify.io> Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
615 lines
22 KiB
TypeScript
615 lines
22 KiB
TypeScript
import { ButtonBorderRadiusTypes } from "components/constants";
|
|
import { BoxShadowTypes } from "components/designSystems/appsmith/WidgetStyleContainer";
|
|
import { Colors } from "constants/Colors";
|
|
import {
|
|
DEFAULT_BOXSHADOW,
|
|
THEMEING_TEXT_SIZES,
|
|
THEMING_BORDER_RADIUS,
|
|
} from "constants/ThemeConstants";
|
|
import { TextSizes } from "constants/WidgetConstants";
|
|
import { clone, get, has, set } from "lodash";
|
|
import { isDynamicValue } from "utils/DynamicBindingUtils";
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
import {
|
|
BUTTON_GROUP_CHILD_STYLESHEET,
|
|
JSON_FORM_WIDGET_CHILD_STYLESHEET,
|
|
rgbaMigrationConstantV56,
|
|
TABLE_WIDGET_CHILD_STYLESHEET,
|
|
} from "widgets/constants";
|
|
import { ContainerWidgetProps } from "widgets/ContainerWidget/widget";
|
|
import { ROOT_SCHEMA_KEY } from "widgets/JSONFormWidget/constants";
|
|
import { parseSchemaItem } from "widgets/WidgetUtils";
|
|
|
|
export const migrateStylingPropertiesForTheming = (
|
|
currentDSL: ContainerWidgetProps<WidgetProps>,
|
|
) => {
|
|
const widgetsWithPrimaryColorProp = [
|
|
"DATE_PICKER_WIDGET2",
|
|
"INPUT_WIDGET",
|
|
"INPUT_WIDGET_V2",
|
|
"LIST_WIDGET",
|
|
"MULTI_SELECT_TREE_WIDGET",
|
|
"DROP_DOWN_WIDGET",
|
|
"TABS_WIDGET",
|
|
"SINGLE_SELECT_TREE_WIDGET",
|
|
"TABLE_WIDGET",
|
|
"BUTTON_GROUP_WIDGET",
|
|
"PHONE_INPUT_WIDGET",
|
|
"CURRENCY_INPUT_WIDGET",
|
|
"SELECT_WIDGET",
|
|
"MULTI_SELECT_WIDGET_V2",
|
|
"MULTI_SELECT_WIDGET",
|
|
];
|
|
|
|
currentDSL.children = currentDSL.children?.map((child) => {
|
|
switch (child.borderRadius) {
|
|
case ButtonBorderRadiusTypes.SHARP:
|
|
child.borderRadius = THEMING_BORDER_RADIUS.none;
|
|
break;
|
|
case ButtonBorderRadiusTypes.ROUNDED:
|
|
child.borderRadius = THEMING_BORDER_RADIUS.rounded;
|
|
break;
|
|
case ButtonBorderRadiusTypes.CIRCLE:
|
|
child.borderRadius = THEMING_BORDER_RADIUS.circle;
|
|
addPropertyToDynamicPropertyPathList("borderRadius", child);
|
|
break;
|
|
default:
|
|
if (
|
|
(child.type === "CONTAINER_WIDGET" ||
|
|
child.type === "FORM_WIDGET" ||
|
|
child.type === "JSON_FORM_WIDGET") &&
|
|
child.borderRadius
|
|
) {
|
|
child.borderRadius = `${child.borderRadius}px`;
|
|
addPropertyToDynamicPropertyPathList("borderRadius", child);
|
|
} else {
|
|
child.borderRadius = THEMING_BORDER_RADIUS.none;
|
|
}
|
|
}
|
|
|
|
switch (child.boxShadow) {
|
|
case BoxShadowTypes.VARIANT1:
|
|
child.boxShadow = `0px 0px 4px 3px ${child.boxShadowColor ||
|
|
"rgba(0, 0, 0, 0.25)"}`;
|
|
addPropertyToDynamicPropertyPathList("boxShadow", child);
|
|
break;
|
|
case BoxShadowTypes.VARIANT2:
|
|
child.boxShadow = `3px 3px 4px ${child.boxShadowColor ||
|
|
"rgba(0, 0, 0, 0.25)"}`;
|
|
addPropertyToDynamicPropertyPathList("boxShadow", child);
|
|
break;
|
|
case BoxShadowTypes.VARIANT3:
|
|
child.boxShadow = `0px 1px 3px ${child.boxShadowColor ||
|
|
"rgba(0, 0, 0, 0.25)"}`;
|
|
addPropertyToDynamicPropertyPathList("boxShadow", child);
|
|
break;
|
|
case BoxShadowTypes.VARIANT4:
|
|
child.boxShadow = `2px 2px 0px ${child.boxShadowColor ||
|
|
"rgba(0, 0, 0, 0.25)"}`;
|
|
addPropertyToDynamicPropertyPathList("boxShadow", child);
|
|
break;
|
|
case BoxShadowTypes.VARIANT5:
|
|
child.boxShadow = `-2px -2px 0px ${child.boxShadowColor ||
|
|
"rgba(0, 0, 0, 0.25)"}`;
|
|
addPropertyToDynamicPropertyPathList("boxShadow", child);
|
|
break;
|
|
default:
|
|
child.boxShadow = DEFAULT_BOXSHADOW;
|
|
}
|
|
|
|
/**
|
|
* Migrates the textSize property present at the table level.
|
|
*/
|
|
if (child.type === "TABLE_WIDGET") {
|
|
switch (child.textSize) {
|
|
case TextSizes.PARAGRAPH2:
|
|
child.textSize = THEMEING_TEXT_SIZES.xs;
|
|
addPropertyToDynamicPropertyPathList("textSize", child);
|
|
break;
|
|
case TextSizes.PARAGRAPH:
|
|
child.textSize = THEMEING_TEXT_SIZES.sm;
|
|
break;
|
|
case TextSizes.HEADING3:
|
|
child.textSize = THEMEING_TEXT_SIZES.base;
|
|
break;
|
|
case TextSizes.HEADING2:
|
|
child.textSize = THEMEING_TEXT_SIZES.md;
|
|
addPropertyToDynamicPropertyPathList("textSize", child);
|
|
break;
|
|
case TextSizes.HEADING1:
|
|
child.textSize = THEMEING_TEXT_SIZES.lg;
|
|
addPropertyToDynamicPropertyPathList("textSize", child);
|
|
break;
|
|
default:
|
|
child.textSize = THEMEING_TEXT_SIZES.sm;
|
|
}
|
|
if (child.hasOwnProperty("primaryColumns")) {
|
|
Object.keys(child.primaryColumns).forEach((key: string) => {
|
|
/**
|
|
* Migrates the textSize property present at the primaryColumn and derivedColumn level.
|
|
*/
|
|
const column = child.primaryColumns[key];
|
|
const isDerivedColumn =
|
|
child.hasOwnProperty("derivedColumns") &&
|
|
key in child.derivedColumns;
|
|
const derivedColumn = child.derivedColumns[key];
|
|
switch (column.textSize) {
|
|
case TextSizes.PARAGRAPH2:
|
|
column.textSize = THEMEING_TEXT_SIZES.xs;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.textSize = THEMEING_TEXT_SIZES.xs;
|
|
}
|
|
addPropertyToDynamicPropertyPathList(
|
|
`primaryColumns.${key}.textSize`,
|
|
child,
|
|
);
|
|
break;
|
|
case TextSizes.PARAGRAPH:
|
|
column.textSize = THEMEING_TEXT_SIZES.sm;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.textSize = THEMEING_TEXT_SIZES.sm;
|
|
}
|
|
break;
|
|
case TextSizes.HEADING3:
|
|
column.textSize = THEMEING_TEXT_SIZES.base;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.textSize = THEMEING_TEXT_SIZES.base;
|
|
}
|
|
break;
|
|
case TextSizes.HEADING2:
|
|
column.textSize = THEMEING_TEXT_SIZES.md;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.textSize = THEMEING_TEXT_SIZES.md;
|
|
}
|
|
addPropertyToDynamicPropertyPathList(
|
|
`primaryColumns.${key}.textSize`,
|
|
child,
|
|
);
|
|
break;
|
|
case TextSizes.HEADING1:
|
|
column.textSize = THEMEING_TEXT_SIZES.lg;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.textSize = THEMEING_TEXT_SIZES.lg;
|
|
}
|
|
addPropertyToDynamicPropertyPathList(
|
|
`primaryColumns.${key}.textSize`,
|
|
child,
|
|
);
|
|
break;
|
|
}
|
|
|
|
/**
|
|
* Migrate the borderRadius if exists for the primary columns and derived columns
|
|
*/
|
|
if (!column.borderRadius) {
|
|
column.borderRadius = THEMING_BORDER_RADIUS.none;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.borderRadius = THEMING_BORDER_RADIUS.none;
|
|
}
|
|
}
|
|
switch (column.borderRadius) {
|
|
case ButtonBorderRadiusTypes.SHARP:
|
|
column.borderRadius = THEMING_BORDER_RADIUS.none;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.borderRadius = THEMING_BORDER_RADIUS.none;
|
|
}
|
|
break;
|
|
case ButtonBorderRadiusTypes.ROUNDED:
|
|
column.borderRadius = THEMING_BORDER_RADIUS.rounded;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.borderRadius = THEMING_BORDER_RADIUS.rounded;
|
|
}
|
|
break;
|
|
case ButtonBorderRadiusTypes.CIRCLE:
|
|
column.borderRadius = THEMING_BORDER_RADIUS.circle;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.borderRadius = THEMING_BORDER_RADIUS.circle;
|
|
}
|
|
break;
|
|
}
|
|
|
|
/**
|
|
* Migrate the boxShadow if exists for the primary columns and derived columns:
|
|
*/
|
|
const isBoxShadowColorDynamic = isDynamicValue(column.boxShadowColor);
|
|
const newBoxShadowColor =
|
|
column.boxShadowColor || rgbaMigrationConstantV56;
|
|
|
|
if (column.boxShadow) {
|
|
addPropertyToDynamicPropertyPathList(
|
|
`primaryColumns.${key}.boxShadow`,
|
|
child,
|
|
);
|
|
} else {
|
|
column.boxShadow = "none";
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = "none";
|
|
}
|
|
}
|
|
|
|
switch (column.boxShadow) {
|
|
case BoxShadowTypes.VARIANT1:
|
|
if (!isBoxShadowColorDynamic) {
|
|
// Checks is boxShadowColor is not dynamic
|
|
column.boxShadow = `0px 0px 4px 3px ${newBoxShadowColor}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `0px 0px 4px 3px ${newBoxShadowColor}`;
|
|
}
|
|
delete column.boxShadowColor;
|
|
} else {
|
|
// Dynamic
|
|
column.boxShadow = `0px 0px 4px 3px ${rgbaMigrationConstantV56}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `0px 0px 4px 3px ${rgbaMigrationConstantV56}`;
|
|
}
|
|
}
|
|
break;
|
|
case BoxShadowTypes.VARIANT2:
|
|
if (!isBoxShadowColorDynamic) {
|
|
// Checks is boxShadowColor is not dynamic
|
|
column.boxShadow = `3px 3px 4px ${newBoxShadowColor}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `3px 3px 4px ${newBoxShadowColor}`;
|
|
}
|
|
delete column.boxShadowColor;
|
|
} else {
|
|
// Dynamic
|
|
column.boxShadow = `3px 3px 4px ${rgbaMigrationConstantV56}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `3px 3px 4px ${rgbaMigrationConstantV56}`;
|
|
}
|
|
}
|
|
break;
|
|
case BoxShadowTypes.VARIANT3:
|
|
if (!isBoxShadowColorDynamic) {
|
|
// Checks is boxShadowColor is not dynamic
|
|
column.boxShadow = `0px 1px 3px ${newBoxShadowColor}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `0px 1px 3px ${newBoxShadowColor}`;
|
|
}
|
|
delete column.boxShadowColor;
|
|
} else {
|
|
// Dynamic
|
|
column.boxShadow = `0px 1px 3px ${rgbaMigrationConstantV56}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `0px 1px 3px ${rgbaMigrationConstantV56}`;
|
|
}
|
|
}
|
|
break;
|
|
case BoxShadowTypes.VARIANT4:
|
|
if (!isBoxShadowColorDynamic) {
|
|
// Checks is boxShadowColor is not dynamic
|
|
column.boxShadow = `2px 2px 0px ${newBoxShadowColor}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `2px 2px 0px ${newBoxShadowColor}`;
|
|
}
|
|
delete column.boxShadowColor;
|
|
} else {
|
|
column.boxShadow = `2px 2px 0px ${rgbaMigrationConstantV56}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `2px 2px 0px ${rgbaMigrationConstantV56}`;
|
|
}
|
|
}
|
|
break;
|
|
case BoxShadowTypes.VARIANT5:
|
|
if (!isBoxShadowColorDynamic) {
|
|
// Checks is boxShadowColor is not dynamic
|
|
column.boxShadow = `-2px -2px 0px ${newBoxShadowColor}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `-2px -2px 0px ${newBoxShadowColor}`;
|
|
}
|
|
delete column.boxShadowColor;
|
|
} else {
|
|
// Dynamic
|
|
column.boxShadow = `-2px -2px 0px ${rgbaMigrationConstantV56}`;
|
|
if (isDerivedColumn) {
|
|
derivedColumn.boxShadow = `-2px -2px 0px ${rgbaMigrationConstantV56}`;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Migrate the parent level properties for JSON Form
|
|
*/
|
|
if (child.type === "JSON_FORM_WIDGET") {
|
|
const parentLevelProperties = ["submitButtonStyles", "resetButtonStyles"];
|
|
parentLevelProperties.forEach((propertyName: string) => {
|
|
const propertyPathBorderRadius = `${propertyName}.borderRadius`;
|
|
const propertyPathBoxShadow = `${propertyName}.boxShadow`;
|
|
const propertyPathBoxShadowColor = `${propertyName}.boxShadowColor`;
|
|
|
|
if (has(child, propertyPathBorderRadius)) {
|
|
const jsonFormBorderRadius = get(child, propertyPathBorderRadius);
|
|
switch (jsonFormBorderRadius) {
|
|
case ButtonBorderRadiusTypes.SHARP:
|
|
set(child, propertyPathBorderRadius, THEMING_BORDER_RADIUS.none);
|
|
break;
|
|
case ButtonBorderRadiusTypes.ROUNDED:
|
|
set(
|
|
child,
|
|
propertyPathBorderRadius,
|
|
THEMING_BORDER_RADIUS.rounded,
|
|
);
|
|
break;
|
|
case ButtonBorderRadiusTypes.CIRCLE:
|
|
set(
|
|
child,
|
|
propertyPathBorderRadius,
|
|
THEMING_BORDER_RADIUS.circle,
|
|
);
|
|
addPropertyToDynamicPropertyPathList(
|
|
propertyPathBorderRadius,
|
|
child,
|
|
);
|
|
break;
|
|
default:
|
|
set(child, propertyPathBorderRadius, THEMING_BORDER_RADIUS.none);
|
|
}
|
|
} else {
|
|
set(child, propertyPathBorderRadius, THEMING_BORDER_RADIUS.none);
|
|
}
|
|
|
|
if (has(child, propertyPathBoxShadow)) {
|
|
const jsonFormBoxShadow = get(child, propertyPathBoxShadow);
|
|
const boxShadowColor =
|
|
(has(child, propertyPathBoxShadowColor) &&
|
|
get(child, propertyPathBoxShadowColor)) ||
|
|
"rgba(0, 0, 0, 0.25)";
|
|
switch (jsonFormBoxShadow) {
|
|
case BoxShadowTypes.VARIANT1:
|
|
set(
|
|
child,
|
|
propertyPathBoxShadow,
|
|
`0px 0px 4px 3px ${boxShadowColor}`,
|
|
);
|
|
addPropertyToDynamicPropertyPathList(
|
|
propertyPathBoxShadow,
|
|
child,
|
|
);
|
|
break;
|
|
case BoxShadowTypes.VARIANT2:
|
|
set(
|
|
child,
|
|
propertyPathBoxShadow,
|
|
`3px 3px 4px ${boxShadowColor}`,
|
|
);
|
|
addPropertyToDynamicPropertyPathList(
|
|
propertyPathBoxShadow,
|
|
child,
|
|
);
|
|
break;
|
|
case BoxShadowTypes.VARIANT3:
|
|
set(
|
|
child,
|
|
propertyPathBoxShadow,
|
|
`0px 1px 3px ${boxShadowColor}`,
|
|
);
|
|
addPropertyToDynamicPropertyPathList(
|
|
propertyPathBoxShadow,
|
|
child,
|
|
);
|
|
break;
|
|
case BoxShadowTypes.VARIANT4:
|
|
set(
|
|
child,
|
|
propertyPathBoxShadow,
|
|
`2px 2px 0px ${boxShadowColor}`,
|
|
);
|
|
addPropertyToDynamicPropertyPathList(
|
|
propertyPathBoxShadow,
|
|
child,
|
|
);
|
|
break;
|
|
case BoxShadowTypes.VARIANT5:
|
|
set(
|
|
child,
|
|
propertyPathBoxShadow,
|
|
`-2px -2px 0px ${boxShadowColor}`,
|
|
);
|
|
addPropertyToDynamicPropertyPathList(
|
|
propertyPathBoxShadow,
|
|
child,
|
|
);
|
|
break;
|
|
default:
|
|
set(child, propertyPathBoxShadow, DEFAULT_BOXSHADOW);
|
|
}
|
|
} else {
|
|
set(child, propertyPathBoxShadow, DEFAULT_BOXSHADOW);
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Migrate the children level properties for JSON form
|
|
*/
|
|
if (has(child, "schema")) {
|
|
const clonedSchema = clone(child.schema);
|
|
parseSchemaItem(
|
|
clonedSchema[ROOT_SCHEMA_KEY],
|
|
`schema.${ROOT_SCHEMA_KEY}`,
|
|
(schemaItem, propertyPath) => {
|
|
if (schemaItem) {
|
|
switch (schemaItem.labelTextSize) {
|
|
case TextSizes.PARAGRAPH2:
|
|
schemaItem.labelTextSize = THEMEING_TEXT_SIZES.xs;
|
|
addPropertyToDynamicPropertyPathList(
|
|
`${propertyPath}.labelTextSize`,
|
|
child,
|
|
);
|
|
break;
|
|
case TextSizes.PARAGRAPH:
|
|
schemaItem.labelTextSize = THEMEING_TEXT_SIZES.sm;
|
|
break;
|
|
case TextSizes.HEADING3:
|
|
schemaItem.labelTextSize = THEMEING_TEXT_SIZES.base;
|
|
break;
|
|
case TextSizes.HEADING2:
|
|
schemaItem.labelTextSize = THEMEING_TEXT_SIZES.md;
|
|
addPropertyToDynamicPropertyPathList(
|
|
`${propertyPath}.labelTextSize`,
|
|
child,
|
|
);
|
|
break;
|
|
case TextSizes.HEADING1:
|
|
schemaItem.labelTextSize = THEMEING_TEXT_SIZES.lg;
|
|
addPropertyToDynamicPropertyPathList(
|
|
`${propertyPath}.labelTextSize`,
|
|
child,
|
|
);
|
|
break;
|
|
default:
|
|
schemaItem.labelTextSize = THEMEING_TEXT_SIZES.sm;
|
|
}
|
|
|
|
// Set the default borderRadius
|
|
!has(schemaItem, "borderRadius") &&
|
|
set(schemaItem, "borderRadius", THEMING_BORDER_RADIUS.none);
|
|
// Set the default borderRadius for the Item styles in an array type:
|
|
!has(schemaItem, "cellBorderRadius") &&
|
|
set(schemaItem, "cellBorderRadius", THEMING_BORDER_RADIUS.none);
|
|
|
|
// Sets the default value for the boxShadow
|
|
!has(schemaItem, "boxShadow") &&
|
|
set(schemaItem, "boxShadow", DEFAULT_BOXSHADOW);
|
|
|
|
// Sets the default value for the boxShadow property of Item styles inside an array:
|
|
!has(schemaItem, "cellBoxShadow") &&
|
|
set(schemaItem, "cellBoxShadow", DEFAULT_BOXSHADOW);
|
|
|
|
// Sets default value as green for the accentColor(Most of the widgets require the below property):
|
|
!has(schemaItem, "accentColor") &&
|
|
set(schemaItem, "accentColor", Colors.GREEN);
|
|
}
|
|
},
|
|
);
|
|
|
|
child.schema = clonedSchema;
|
|
}
|
|
}
|
|
|
|
switch (child.fontSize) {
|
|
case TextSizes.PARAGRAPH2:
|
|
child.fontSize = THEMEING_TEXT_SIZES.xs;
|
|
addPropertyToDynamicPropertyPathList("fontSize", child);
|
|
break;
|
|
case TextSizes.PARAGRAPH:
|
|
child.fontSize = THEMEING_TEXT_SIZES.sm;
|
|
break;
|
|
case TextSizes.HEADING3:
|
|
child.fontSize = THEMEING_TEXT_SIZES.base;
|
|
break;
|
|
case TextSizes.HEADING2:
|
|
child.fontSize = THEMEING_TEXT_SIZES.md;
|
|
addPropertyToDynamicPropertyPathList("fontSize", child);
|
|
break;
|
|
case TextSizes.HEADING1:
|
|
child.fontSize = THEMEING_TEXT_SIZES.lg;
|
|
addPropertyToDynamicPropertyPathList("fontSize", child);
|
|
break;
|
|
}
|
|
|
|
switch (child.labelTextSize) {
|
|
case TextSizes.PARAGRAPH2:
|
|
child.labelTextSize = THEMEING_TEXT_SIZES.xs;
|
|
addPropertyToDynamicPropertyPathList("labelTextSize", child);
|
|
break;
|
|
case TextSizes.PARAGRAPH:
|
|
child.labelTextSize = THEMEING_TEXT_SIZES.sm;
|
|
break;
|
|
case TextSizes.HEADING3:
|
|
child.labelTextSize = THEMEING_TEXT_SIZES.base;
|
|
break;
|
|
case TextSizes.HEADING2:
|
|
child.labelTextSize = THEMEING_TEXT_SIZES.md;
|
|
addPropertyToDynamicPropertyPathList("labelTextSize", child);
|
|
break;
|
|
case TextSizes.HEADING1:
|
|
child.labelTextSize = THEMEING_TEXT_SIZES.lg;
|
|
addPropertyToDynamicPropertyPathList("labelTextSize", child);
|
|
break;
|
|
default:
|
|
child.labelTextSize = THEMEING_TEXT_SIZES.sm;
|
|
}
|
|
|
|
/**
|
|
* Add primaryColor color to missing widgets
|
|
*/
|
|
if (widgetsWithPrimaryColorProp.includes(child.type)) {
|
|
child.accentColor = "{{appsmith.theme.colors.primaryColor}}";
|
|
|
|
child.dynamicBindingPathList = [
|
|
...(child.dynamicBindingPathList || []),
|
|
{
|
|
key: "accentColor",
|
|
},
|
|
];
|
|
}
|
|
|
|
// specific fixes
|
|
if (child.type === "AUDIO_RECORDER_WIDGET") {
|
|
child.borderRadius = THEMING_BORDER_RADIUS.circle;
|
|
child.accentColor = child.backgroundColor;
|
|
}
|
|
|
|
if (child.type === "FILE_PICKER_WIDGET_V2") {
|
|
child.buttonColor = Colors.GREEN;
|
|
}
|
|
|
|
if (
|
|
child.type === "CHECKBOX_WIDGET" ||
|
|
child.type === "CHECKBOX_GROUP_WIDGET" ||
|
|
child.type === "SWITCH_WIDGET" ||
|
|
child.type === "SWITCH_GROUP_WIDGET"
|
|
) {
|
|
child.accentColor = Colors.GREEN;
|
|
}
|
|
|
|
if (child.type === "TEXT_WIDGET") {
|
|
child.fontFamily = "System Default";
|
|
}
|
|
// Adds childStyleSheets
|
|
switch (child.type) {
|
|
case "BUTTON_GROUP_WIDGET":
|
|
child.childStylesheet = BUTTON_GROUP_CHILD_STYLESHEET;
|
|
break;
|
|
case "JSON_FORM_WIDGET":
|
|
child.childStylesheet = JSON_FORM_WIDGET_CHILD_STYLESHEET;
|
|
break;
|
|
case "TABLE_WIDGET":
|
|
child.childStylesheet = TABLE_WIDGET_CHILD_STYLESHEET;
|
|
break;
|
|
}
|
|
|
|
if (child.children && child.children.length > 0) {
|
|
child = migrateStylingPropertiesForTheming(child);
|
|
}
|
|
return child;
|
|
});
|
|
|
|
return currentDSL;
|
|
};
|
|
|
|
/**
|
|
* This function will add the given propertyName into the dynamicPropertyPathList.
|
|
* @param propertyName
|
|
* @param child
|
|
*/
|
|
export const addPropertyToDynamicPropertyPathList = (
|
|
propertyName: string,
|
|
child: WidgetProps,
|
|
) => {
|
|
const isPropertyPathPresent = (child.dynamicPropertyPathList || []).find(
|
|
(property) => property.key === propertyName,
|
|
);
|
|
if (!isPropertyPathPresent) {
|
|
child.dynamicPropertyPathList = [
|
|
...(child.dynamicPropertyPathList || []),
|
|
{ key: propertyName },
|
|
];
|
|
}
|
|
};
|