## Description Grouping the widgets into categories to make it easier for people to find widgets. This will be behind the feature flag `release_widgetdiscovery_enabled` <img src="https://github.com/appsmithorg/appsmith/assets/22471214/4932a091-1831-4d95-b722-3301580fb6be" height="300px" /> Project home [here on Notion](https://www.notion.so/appsmith/Widget-Discoverability-755cf059a1904950888304b90b74106f?d=8bc3059134984787900a69963dd13d90#27967092cfa74505bab55bd163d28c18). #### PR fixes following issue(s) #24865 #24867 #24868 #24869 #### 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 > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] Jest - [x] Cypress > > #### Test Plan > (https://github.com/appsmithorg/TestSmith/issues/2440) > > #### 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 - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [x] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [x] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
255 lines
6.4 KiB
TypeScript
255 lines
6.4 KiB
TypeScript
import type { SupportedLayouts } from "reducers/entityReducers/pageListReducer";
|
|
import type { WidgetType as FactoryWidgetType } from "utils/WidgetFactory";
|
|
import { THEMEING_TEXT_SIZES } from "./ThemeConstants";
|
|
import type { WidgetCardProps } from "widgets/BaseWidget";
|
|
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 enum RenderModes {
|
|
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 = 80;
|
|
|
|
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;
|
|
|
|
export const DefaultDimensionMap = {
|
|
leftColumn: "leftColumn",
|
|
rightColumn: "rightColumn",
|
|
topRow: "topRow",
|
|
bottomRow: "bottomRow",
|
|
};
|
|
|
|
// 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;
|
|
|
|
/**
|
|
* Padding introduced by container-like widgets in AutoLayout mode.
|
|
* FlexComponent - margin: 2px (2 * 2 = 4px) [Deploy mode = 4px ( 4 * 2 = 8px)]
|
|
* ResizeWrapper - padding: 1px, border: 1px (2 * 2 = 4px) [Deploy mode = 0px]
|
|
* ContainerComponent - border: 1px (1 * 2 = 2px) [Deploy mode = 2px]
|
|
* Total - 5px (5 * 2 = 10px)
|
|
*/
|
|
export const AUTO_LAYOUT_CONTAINER_PADDING = 5;
|
|
|
|
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,
|
|
mobileTopRow: true,
|
|
mobileBottomRow: true,
|
|
mobileLeftColumn: true,
|
|
mobileRightColumn: 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,
|
|
topRowBeforeCollapse: false,
|
|
bottomRowBeforeCollapse: false,
|
|
};
|
|
|
|
export const WIDGET_DSL_STRUCTURE_PROPS = {
|
|
bottomRow: true,
|
|
children: true,
|
|
requiresFlatWidgetChildren: true,
|
|
hasMetaWidgets: true,
|
|
isMetaWidget: true,
|
|
parentId: true,
|
|
referencedWidgetId: true,
|
|
topRow: true,
|
|
type: true,
|
|
widgetId: 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,
|
|
topRowBeforeCollapse: false,
|
|
bottomRowBeforeCollapse: false,
|
|
tags: false,
|
|
};
|
|
|
|
/**
|
|
* This is the padding that is applied to the flexbox container.
|
|
* It is also used to calculate widget positions and highlight placements.
|
|
*/
|
|
export const FLEXBOX_PADDING = 4;
|
|
|
|
/**
|
|
* max width of modal widget constant as a multiplier of Main canvasWidth
|
|
*/
|
|
export const MAX_MODAL_WIDTH_FROM_MAIN_WIDTH = 0.95;
|
|
|
|
export const FILE_SIZE_LIMIT_FOR_BLOBS = 5000 * 1024; // 5MB
|
|
|
|
export const WIDGET_TAGS = {
|
|
SUGGESTED_WIDGETS: "Suggested",
|
|
INPUTS: "Inputs",
|
|
BUTTONS: "Buttons",
|
|
SELECT: "Select",
|
|
DISPLAY: "Display",
|
|
LAYOUT: "Layout",
|
|
MEDIA: "Media",
|
|
TOGGLES: "Toggles",
|
|
SLIDERS: "Sliders",
|
|
CONTENT: "Content",
|
|
EXTERNAL: "External",
|
|
} as const;
|
|
|
|
export type WidgetTags = (typeof WIDGET_TAGS)[keyof typeof WIDGET_TAGS];
|
|
|
|
export type WidgetCardsGroupedByTags = Record<WidgetTags, WidgetCardProps[]>;
|
|
|
|
export const SUGGESTED_WIDGETS_ORDER: Record<WidgetType, number> = {
|
|
TABLE_WIDGET_V2: 1,
|
|
JSON_FORM_WIDGET: 2,
|
|
INPUT_WIDGET_V2: 3,
|
|
TEXT_WIDGET: 4,
|
|
SELECT_WIDGET: 5,
|
|
LIST_WIDGET_V2: 6,
|
|
};
|