## Description Features:- 1. Created a new AutoResizeTextArea component in the editorComponents. Textarea does not increase its height on adding text, but it increases its scroll height. To accommodate Auto Height with the textarea/Multi-line InputWidget, I have created a new TextArea component which changes its height when its content changes based on its scrollHeight. This is done by creating another hidden similar proxy Textarea with contents equal to the widget's value, and whenever this value changes we run a layout effect that sets the main text area height equal to the scrollHeight of the proxy textarea. 2. Added a new configuration `Multi-line` for InputWidget in the Data-Type which will decide whether to replace the `input` element with `textarea`. Currently, the way to decide whether we should display a textarea or not is based on whether widget's height is greater than 8 rows or not. To fix it, I added a proper configuration which will user to select whether he/she wants a Single-line input or Multi-line textarea. 3. Replaced the label of `Text` configuration to `Single-line` which remains a simple `input` element as before. Changed the label of the Text configuration to Single-line in contrast with Multi-line. 4. Migration Added migration number 75 for the InputWidgetsV2. Used the same previous logic to detect whether the input type should be multiple-line or not and set the `inputType` to `MULTI_LINE_TEXT` if it's true. 5. Changed a lot of CSS styling in Input components (Currency and Phone too) so that they look similar to other components like DatePicker and Select. Currently the input component take containers height which is different from other components. 6. The onSubmit behaviour of the Multi-line input has also changed. Now the line-break will happen on Enter and submit will be triggered on Cmd + Enter. 7. Added an updateHook in the Input widget which when selected the Multi-line input will set its dynamic height property to AutoHeight. Fixes #19655 Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest ### Test Plan https://github.com/appsmithorg/TestSmith/issues/2151 ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [x] Test plan has been approved by relevant developers - [x] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test Co-authored-by: Apple <nandan@thinkify.io> Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
185 lines
4.5 KiB
TypeScript
185 lines
4.5 KiB
TypeScript
import { SupportedLayouts } from "reducers/entityReducers/pageListReducer";
|
|
import { WidgetType as FactoryWidgetType } from "utils/WidgetFactory";
|
|
import { THEMEING_TEXT_SIZES } from "./ThemeConstants";
|
|
export type WidgetType = FactoryWidgetType;
|
|
|
|
export const SKELETON_WIDGET_TYPE = "SKELETON_WIDGET";
|
|
|
|
export type ContainerOrientation = "HORIZONTAL" | "VERTICAL";
|
|
|
|
export const PositionTypes: { [id: string]: string } = {
|
|
ABSOLUTE: "ABSOLUTE",
|
|
CONTAINER_DIRECTION: "CONTAINER_DIRECTION",
|
|
};
|
|
export type PositionType = typeof PositionTypes[keyof typeof PositionTypes];
|
|
|
|
export type CSSUnit =
|
|
| "px"
|
|
| "cm"
|
|
| "mm"
|
|
| "in"
|
|
| "pt"
|
|
| "pc"
|
|
| "em"
|
|
| "ex"
|
|
| "ch"
|
|
| "rem"
|
|
| "vw"
|
|
| "vh"
|
|
| "vmin"
|
|
| "vmax"
|
|
| "%";
|
|
|
|
export type RenderMode =
|
|
| "COMPONENT_PANE"
|
|
| "CANVAS"
|
|
| "PAGE"
|
|
| "CANVAS_SELECTED";
|
|
|
|
export const RenderModes: { [id: string]: RenderMode } = {
|
|
COMPONENT_PANE: "COMPONENT_PANE",
|
|
CANVAS: "CANVAS",
|
|
PAGE: "PAGE",
|
|
CANVAS_SELECTED: "CANVAS_SELECTED",
|
|
};
|
|
|
|
export const CSSUnits: { [id: string]: CSSUnit } = {
|
|
PIXEL: "px",
|
|
RELATIVE_FONTSIZE: "rem",
|
|
RELATIVE_PARENT: "%",
|
|
};
|
|
|
|
export interface LayoutConfig {
|
|
minWidth: number;
|
|
maxWidth: number;
|
|
}
|
|
|
|
type LayoutConfigurations = Record<SupportedLayouts, LayoutConfig>;
|
|
export const DefaultLayoutType: SupportedLayouts = "FLUID";
|
|
export const layoutConfigurations: LayoutConfigurations = {
|
|
TABLET_LARGE: {
|
|
minWidth: 960,
|
|
maxWidth: 1080,
|
|
},
|
|
MOBILE: {
|
|
minWidth: 350,
|
|
maxWidth: 450,
|
|
},
|
|
DESKTOP: { minWidth: 1160, maxWidth: 1280 },
|
|
TABLET: { minWidth: 650, maxWidth: 800 },
|
|
FLUID: { minWidth: -1, maxWidth: -1 },
|
|
};
|
|
|
|
export const LATEST_PAGE_VERSION = 76;
|
|
|
|
export const GridDefaults = {
|
|
DEFAULT_CELL_SIZE: 1,
|
|
DEFAULT_WIDGET_WIDTH: 200,
|
|
DEFAULT_WIDGET_HEIGHT: 100,
|
|
DEFAULT_GRID_COLUMNS: 64,
|
|
DEFAULT_GRID_ROW_HEIGHT: 10,
|
|
CANVAS_EXTENSION_OFFSET: 2,
|
|
VIEW_MODE_MAIN_CANVAS_EXTENSION_OFFSET: 5,
|
|
MAIN_CANVAS_EXTENSION_OFFSET: 8,
|
|
};
|
|
|
|
export const CANVAS_MIN_HEIGHT = 380;
|
|
|
|
// Note: Widget Padding + Container Padding === DEFAULT_GRID_ROW_HEIGHT to gracefully lose one row when a container is used,
|
|
// which wud allow the user to place elements centered inside a container(columns are rendered proportionally so it take cares of itself).
|
|
|
|
export const CONTAINER_GRID_PADDING =
|
|
GridDefaults.DEFAULT_GRID_ROW_HEIGHT * 0.6;
|
|
|
|
export const WIDGET_PADDING = GridDefaults.DEFAULT_GRID_ROW_HEIGHT * 0.4;
|
|
|
|
export const WIDGET_CLASSNAME_PREFIX = "WIDGET_";
|
|
export const MAIN_CONTAINER_WIDGET_ID = "0";
|
|
export const MAIN_CONTAINER_WIDGET_NAME = "MainContainer";
|
|
export const MODAL_PORTAL_CLASSNAME = "bp3-modal-widget";
|
|
export const MODAL_PORTAL_OVERLAY_CLASSNAME = "bp3-overlay-zindex";
|
|
export const CANVAS_SELECTOR = "canvas";
|
|
|
|
export const DEFAULT_CENTER = { lat: -34.397, lng: 150.644 };
|
|
|
|
export enum FontStyleTypes {
|
|
BOLD = "BOLD",
|
|
ITALIC = "ITALIC",
|
|
REGULAR = "REGULAR",
|
|
UNDERLINE = "UNDERLINE",
|
|
}
|
|
|
|
export enum TextSizes {
|
|
HEADING1 = "HEADING1",
|
|
HEADING2 = "HEADING2",
|
|
HEADING3 = "HEADING3",
|
|
PARAGRAPH = "PARAGRAPH",
|
|
PARAGRAPH2 = "PARAGRAPH2",
|
|
}
|
|
|
|
export const TEXT_SIZES = {
|
|
HEADING1: "24px",
|
|
HEADING2: "18px",
|
|
HEADING3: "16px",
|
|
PARAGRAPH: "14px",
|
|
PARAGRAPH2: "12px",
|
|
};
|
|
|
|
export const WIDGET_STATIC_PROPS = {
|
|
leftColumn: true,
|
|
rightColumn: true,
|
|
topRow: true,
|
|
bottomRow: true,
|
|
minHeight: true,
|
|
parentColumnSpace: true,
|
|
parentRowSpace: true,
|
|
children: true,
|
|
type: true,
|
|
widgetId: true,
|
|
widgetName: true,
|
|
parentId: true,
|
|
renderMode: true,
|
|
detachFromLayout: true,
|
|
noContainerOffset: false,
|
|
height: false,
|
|
};
|
|
|
|
export const WIDGET_DSL_STRUCTURE_PROPS = {
|
|
children: true,
|
|
type: true,
|
|
widgetId: true,
|
|
parentId: true,
|
|
topRow: true,
|
|
bottomRow: true,
|
|
};
|
|
|
|
export type TextSize = keyof typeof TextSizes;
|
|
|
|
export const DEFAULT_FONT_SIZE = THEMEING_TEXT_SIZES.base;
|
|
|
|
// The max and min height limits for widgets in rows.
|
|
// 9000 is an arbitrarily large value for the height of a widget
|
|
// In pixels this would be 90000px, which is a fairly large number.
|
|
|
|
// 4 is the minimum for any widget, as we donot support zero height widgets today.
|
|
// This also makes sure that widgets have sufficient area in which users can interact.
|
|
export const WidgetHeightLimits = {
|
|
MAX_HEIGHT_IN_ROWS: 9000,
|
|
MIN_HEIGHT_IN_ROWS: 4,
|
|
MIN_CANVAS_HEIGHT_IN_ROWS: 10,
|
|
};
|
|
|
|
export const WIDGET_PROPS_TO_SKIP_FROM_EVAL = {
|
|
children: true,
|
|
parentId: true,
|
|
renderMode: true,
|
|
detachFromLayout: true,
|
|
noContainerOffset: false,
|
|
hideCard: true,
|
|
isDeprecated: true,
|
|
searchTags: true,
|
|
iconSVG: true,
|
|
version: true,
|
|
displayName: true,
|
|
};
|