2022-01-18 07:52:24 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { WidgetState } from "widgets/BaseWidget";
|
2022-04-08 17:39:05 +00:00
|
|
|
import { WidgetType } from "constants/WidgetConstants";
|
2022-01-18 07:52:24 +00:00
|
|
|
import CurrencyInputComponent, {
|
|
|
|
|
CurrencyInputComponentProps,
|
|
|
|
|
} from "../component";
|
2022-02-09 12:03:10 +00:00
|
|
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
2022-01-18 07:52:24 +00:00
|
|
|
import {
|
|
|
|
|
ValidationTypes,
|
|
|
|
|
ValidationResponse,
|
|
|
|
|
} from "constants/WidgetValidation";
|
2022-02-11 18:08:46 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
FIELD_REQUIRED_ERROR,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2022-01-18 07:52:24 +00:00
|
|
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
|
|
|
|
import {
|
|
|
|
|
CurrencyDropdownOptions,
|
|
|
|
|
getCountryCodeFromCurrencyCode,
|
|
|
|
|
} from "../component/CurrencyCodeDropdown";
|
2022-11-27 06:11:01 +00:00
|
|
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
2022-01-18 07:52:24 +00:00
|
|
|
import _ from "lodash";
|
|
|
|
|
import derivedProperties from "./parsedDerivedProperties";
|
|
|
|
|
import BaseInputWidget from "widgets/BaseInputWidget";
|
|
|
|
|
import { BaseInputWidgetProps } from "widgets/BaseInputWidget/widget";
|
|
|
|
|
import * as Sentry from "@sentry/react";
|
|
|
|
|
import log from "loglevel";
|
|
|
|
|
import {
|
|
|
|
|
formatCurrencyNumber,
|
|
|
|
|
limitDecimalValue,
|
|
|
|
|
} from "../component/utilities";
|
2022-11-02 10:32:45 +00:00
|
|
|
import { getLocale, mergeWidgetConfig } from "utils/helpers";
|
feat: Controls for labels in widgets to align the widgets in forms and other places (#10600)
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Create a new property control for a label position
-- Create a new property control for a label alignment
-- Prototype a label section for Input widget
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Add a property, labelWidth in the property pane
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Input widget: Implement all the requirements in case its type is Text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adapt the functionalty on other types of the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into DropdownWidget
-- Clean up for the input widget and DRY
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectWidget
-- Eliminate unnecessary component prop, columns
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalties into Tree Select widget
-- Add styles for alignment between lable and input control over the widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectTreeWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Introduce label functionalities into DatePickerWidget2
-- Use width instead of columns prop in InputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RichTextEditorWidget
-- Eliminate compactMode from StyledLabel
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into CheckboxGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement switch group for the correct meaning of right alignment
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RadioGroupWidget
-- Add new properties, alignment and inline for consistency
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adjust cols and rows for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused StyledRadioProps
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete first MVP of enhanced SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete the first MVP of enhanced RadioGroupWidget
-- Eliminate unused StyledSwitch component for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add min-height, align-self rules for LabelContainer
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Use original label property for RadioGroupWidget
-- Add a migration for adding isInline and alignment properties for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Update version to latest one in DSLMigrationsUtils.test.ts
* fix failing jest test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement label functionalities on BaseInputWidget, InputWidgetV2, CurrencyInputWidget, PhoneInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DSLMigrationsUtils
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the label related test case which is failed in Input_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on #10119: The label text truncates on resizing the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix scroll issue when shrink with MultiSelectWidget and MultiSelectTreeWidget
* fix: Widget Popup test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement width and alginment features on the level of label element
-- Prevent actual inputs from DropdownWidget, MultiSelectWidget, SingleSelectTreeWidget, MultiSelectTreeWidget from overflow when resizing
-- Enable label feature on a RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set label container's default width to 33% when width is not set
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix crash issue when labelWidth is filled by non-numeric value, eliminating passing NaN as its value
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set flex-grow to zero on input types other than TEXT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label features on newly created MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate LabelPositionTypes, directly using enum LabelPosition
-- Add a comment for a constant LABEL_MAX_WIDTH_RATE
-- Directly import React for LabelAlignmentOptionsControl
-- Remove unnecessary constructor for LabelAlignmentOptionsControl
-- Define handleAlign instance method as a higher-order function
-- Only migrate alignment property for RadioGroupWidget
-- Use Object.hasOwnProperty instead of in operator
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Migrate alignment property of RadioGroupWidget in case of currentDSL.version is 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Revert currentDSL.version to 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a Jest test case for RadioGroupWidget's alignment property migration
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Replace all nested ternary operators with if statements
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label feature on new version of SelectWidget
-- Add Cypress tests for widgets' label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor code for BaseInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change CSS selector for step buttons for Numeric BaseInputWidget
-- Directly use migrateRadioGroupAlignmentProperty migration function without using transformDSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on typo about migrateRadioGroupAlignmentProperty
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add data-testid attributes for Cypress selectors
* feat: Deprecate form button widget
-- Assert flex-direction to row in CheckboxGroup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a missing data-testid for SelectWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on failed test cases: CheckboxGroup_spec, DatePicker_2_spec, MultiSelectWidgetV2
* fix: Select popup DSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new property control, NumericInputControl
-- Replace all the label properties with the newly created controls
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new Cypress command, checkLabelWidth and apply to all related test cases
-- Increase width in checkboxgroupDsl.json
-- Rename className for label in MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement the tooltip feature for labels
-- Add missing props for labels in DateField, MultiSelectField, RadioGroupField, SelectField fields for JSONFormWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor property controls, including LabelPositionOptionsControl, LabelAlignmentOptionsControl, NumericInputControl to keep consistency
-- Apply default values into label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract the label related parts from the various widgets as an independent component
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate TypeScript any type from BaseInputComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change labelPosition property type to DROP_DOWN
-- Modify LabelAlignmentOptionsControl to use ButtonTabComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Define getLabelWidth method into BaseWidget
-- Extract the common CSS rules for the widget containers
-- Revert rows and columns for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed test case in DSLMigrationsUtils.test.ts
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on overflow issue on CheckboxGroupWidget
-- Create a distinctive spec file for label feature
-- Eliminate the redundant label specs with the relevant widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Delete unnecessary files, including Select_spec.js, LabelButton.tsx and LabelPositionOptionsControl.tsx
-- Revise wrong comment for checkLabelForWidget Cypress command
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Do not set the label width only if its value is 0
-- Clean up the component for DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Make RadioGroupWidget's layout flexible in all modes
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on Cypress test case for RadioGroupWidget in Widgets_Labels_spec
-- Change Cypress commands, including addAction, addSuccessMessage, enterActionValue to accept parentSelector
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change getLabelWidth method to not have any argument
-- Define some constants for label numbers
-- Extract the common styles for SwitchGroupWidget and RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor some constants
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused width prop from RadioGroupWidget
-- Get labelWidth from getLabelWidth
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate the min-height restriction on a label
-- Eliminate the scroll on the earlier InputWidgetV2 which was not in compact mode
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add one more condition checking if the current input type is text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract common code base for MultiSelectTreeWidget and MultiSelectWidgetV2
-- Apply a few CSS fixes on the scrollbar issue select related widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply some tweaks for earlier widgets with labels so as not to be broken UX
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed Cypress test case in Widget_Popup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add constants, LABEL_DEFAULT_WIDTH_RATE, SELECT_DEFAULT_HEIGHT, LABEL_MARGIN_OLD_SELECT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Increase the widths of CheckboxGroupWidget and SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set the font size to 14px for NumericInputControl
Co-authored-by: ohansFavour <fohanekwu@gmail.com>
Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com>
2022-04-14 08:47:25 +00:00
|
|
|
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
2022-11-02 10:32:45 +00:00
|
|
|
import {
|
|
|
|
|
getLocaleDecimalSeperator,
|
|
|
|
|
getLocaleThousandSeparator,
|
2022-11-23 09:48:23 +00:00
|
|
|
isAutoHeightEnabledForWidget,
|
2022-11-02 10:32:45 +00:00
|
|
|
} from "widgets/WidgetUtils";
|
2022-11-28 04:44:31 +00:00
|
|
|
import { Stylesheet } from "entities/AppTheming";
|
2022-01-18 07:52:24 +00:00
|
|
|
|
|
|
|
|
export function defaultValueValidation(
|
|
|
|
|
value: any,
|
|
|
|
|
props: CurrencyInputWidgetProps,
|
|
|
|
|
_?: any,
|
|
|
|
|
): ValidationResponse {
|
|
|
|
|
const NUMBER_ERROR_MESSAGE = "This value must be number";
|
2022-11-02 10:32:45 +00:00
|
|
|
const DECIMAL_SEPARATOR_ERROR_MESSAGE =
|
|
|
|
|
"Please use . as the decimal separator for default values.";
|
2022-01-18 07:52:24 +00:00
|
|
|
const EMPTY_ERROR_MESSAGE = "";
|
2022-11-02 10:32:45 +00:00
|
|
|
const localeLang = navigator.languages?.[0] || "en-US";
|
|
|
|
|
|
|
|
|
|
function getLocaleDecimalSeperator() {
|
|
|
|
|
return Intl.NumberFormat(localeLang)
|
|
|
|
|
.format(1.1)
|
|
|
|
|
.replace(/\p{Number}/gu, "");
|
|
|
|
|
}
|
|
|
|
|
const decimalSeperator = getLocaleDecimalSeperator();
|
|
|
|
|
const defaultDecimalSeperator = ".";
|
2022-01-18 07:52:24 +00:00
|
|
|
if (_.isObject(value)) {
|
|
|
|
|
return {
|
|
|
|
|
isValid: false,
|
|
|
|
|
parsed: JSON.stringify(value, null, 2),
|
|
|
|
|
messages: [NUMBER_ERROR_MESSAGE],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let parsed: any = Number(value);
|
|
|
|
|
let isValid, messages;
|
|
|
|
|
|
|
|
|
|
if (_.isString(value) && value.trim() === "") {
|
|
|
|
|
/*
|
|
|
|
|
* When value is emtpy string
|
|
|
|
|
*/
|
|
|
|
|
isValid = true;
|
|
|
|
|
messages = [EMPTY_ERROR_MESSAGE];
|
|
|
|
|
parsed = undefined;
|
|
|
|
|
} else if (!Number.isFinite(parsed)) {
|
|
|
|
|
/*
|
|
|
|
|
* When parsed value is not a finite numer
|
|
|
|
|
*/
|
|
|
|
|
isValid = false;
|
|
|
|
|
parsed = undefined;
|
2022-11-02 10:32:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check whether value contains the locale decimal separator apart from "."
|
|
|
|
|
* We only allow "." as a decimal separator inside default value
|
|
|
|
|
*/
|
|
|
|
|
if (
|
|
|
|
|
String(value).indexOf(defaultDecimalSeperator) === -1 &&
|
|
|
|
|
String(value).indexOf(decimalSeperator) > 0
|
|
|
|
|
) {
|
|
|
|
|
messages = [DECIMAL_SEPARATOR_ERROR_MESSAGE];
|
|
|
|
|
} else {
|
|
|
|
|
messages = [NUMBER_ERROR_MESSAGE];
|
|
|
|
|
}
|
2022-01-18 07:52:24 +00:00
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* When parsed value is a Number
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Check whether value is honoring the decimals property
|
|
|
|
|
if (parsed !== Number(parsed.toFixed(props.decimals))) {
|
|
|
|
|
isValid = false;
|
|
|
|
|
messages = [
|
|
|
|
|
"No. of decimals are higher than the decimals field set. Please update the default or the decimals field",
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
isValid = true;
|
|
|
|
|
messages = [EMPTY_ERROR_MESSAGE];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parsed = String(parsed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
isValid,
|
|
|
|
|
parsed,
|
|
|
|
|
messages,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CurrencyInputWidget extends BaseInputWidget<
|
|
|
|
|
CurrencyInputWidgetProps,
|
|
|
|
|
WidgetState
|
|
|
|
|
> {
|
2022-08-11 11:20:09 +00:00
|
|
|
static getPropertyPaneContentConfig() {
|
|
|
|
|
return mergeWidgetConfig(
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
sectionName: "Data",
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
helpText:
|
|
|
|
|
"Sets the default text of the widget. The text is updated if the default text changes",
|
|
|
|
|
propertyName: "defaultText",
|
|
|
|
|
label: "Default Value",
|
|
|
|
|
controlType: "INPUT_TEXT",
|
|
|
|
|
placeholderText: "100",
|
|
|
|
|
isBindProperty: true,
|
|
|
|
|
isTriggerProperty: false,
|
|
|
|
|
validation: {
|
|
|
|
|
type: ValidationTypes.FUNCTION,
|
|
|
|
|
params: {
|
|
|
|
|
fn: defaultValueValidation,
|
|
|
|
|
expected: {
|
|
|
|
|
type: "number",
|
|
|
|
|
example: `100`,
|
|
|
|
|
autocompleteDataType: AutocompleteDataType.STRING,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
dependencies: ["decimals"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
helpText: "Changes the type of currency",
|
|
|
|
|
propertyName: "defaultCurrencyCode",
|
|
|
|
|
label: "Currency",
|
|
|
|
|
enableSearch: true,
|
|
|
|
|
dropdownHeight: "156px",
|
|
|
|
|
controlType: "DROP_DOWN",
|
|
|
|
|
searchPlaceholderText: "Search by code or name",
|
|
|
|
|
options: CurrencyDropdownOptions,
|
|
|
|
|
isJSConvertible: true,
|
|
|
|
|
isBindProperty: true,
|
|
|
|
|
isTriggerProperty: false,
|
|
|
|
|
validation: {
|
|
|
|
|
type: ValidationTypes.TEXT,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
propertyName: "allowCurrencyChange",
|
|
|
|
|
label: "Allow Currency Change",
|
|
|
|
|
helpText: "Search by currency or country",
|
|
|
|
|
controlType: "SWITCH",
|
2022-11-01 08:29:19 +00:00
|
|
|
isJSConvertible: true,
|
2022-08-11 11:20:09 +00:00
|
|
|
isBindProperty: true,
|
|
|
|
|
isTriggerProperty: false,
|
|
|
|
|
validation: { type: ValidationTypes.BOOLEAN },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
helpText: "No. of decimals in currency input",
|
|
|
|
|
propertyName: "decimals",
|
|
|
|
|
label: "Decimals Allowed",
|
|
|
|
|
controlType: "DROP_DOWN",
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "0",
|
|
|
|
|
value: 0,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "1",
|
|
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "2",
|
|
|
|
|
value: 2,
|
|
|
|
|
},
|
|
|
|
|
],
|
2022-11-01 08:29:19 +00:00
|
|
|
isJSConvertible: true,
|
|
|
|
|
isBindProperty: true,
|
2022-08-11 11:20:09 +00:00
|
|
|
isTriggerProperty: false,
|
2022-11-01 08:29:19 +00:00
|
|
|
validation: {
|
|
|
|
|
type: ValidationTypes.NUMBER,
|
|
|
|
|
params: {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 2,
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-08-11 11:20:09 +00:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
sectionName: "Label",
|
|
|
|
|
children: [],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
sectionName: "Validation",
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
propertyName: "isRequired",
|
|
|
|
|
label: "Required",
|
|
|
|
|
helpText: "Makes input to the widget mandatory",
|
|
|
|
|
controlType: "SWITCH",
|
|
|
|
|
isJSConvertible: true,
|
|
|
|
|
isBindProperty: true,
|
|
|
|
|
isTriggerProperty: false,
|
|
|
|
|
validation: { type: ValidationTypes.BOOLEAN },
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
super.getPropertyPaneContentConfig(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getPropertyPaneStyleConfig() {
|
|
|
|
|
return super.getPropertyPaneStyleConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 07:52:24 +00:00
|
|
|
static getDerivedPropertiesMap(): DerivedPropertiesMap {
|
|
|
|
|
return {
|
|
|
|
|
isValid: `{{(()=>{${derivedProperties.isValid}})()}}`,
|
|
|
|
|
value: `{{(()=>{${derivedProperties.value}})()}}`,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getMetaPropertiesMap(): Record<string, any> {
|
|
|
|
|
return _.merge(super.getMetaPropertiesMap(), {
|
|
|
|
|
text: undefined,
|
2022-04-08 17:39:05 +00:00
|
|
|
currencyCode: undefined,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getDefaultPropertiesMap(): Record<string, string> {
|
|
|
|
|
return _.merge(super.getDefaultPropertiesMap(), {
|
|
|
|
|
currencyCode: "defaultCurrencyCode",
|
2022-01-18 07:52:24 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-28 04:44:31 +00:00
|
|
|
static getStylesheetConfig(): Stylesheet {
|
|
|
|
|
return {
|
|
|
|
|
accentColor: "{{appsmith.theme.colors.primaryColor}}",
|
|
|
|
|
borderRadius: "{{appsmith.theme.borderRadius.appBorderRadius}}",
|
|
|
|
|
boxShadow: "none",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 07:52:24 +00:00
|
|
|
componentDidMount() {
|
|
|
|
|
//format the defaultText and store it in text
|
|
|
|
|
this.formatText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps: CurrencyInputWidgetProps) {
|
|
|
|
|
if (
|
|
|
|
|
prevProps.text !== this.props.text &&
|
|
|
|
|
!this.props.isFocused &&
|
|
|
|
|
this.props.text === String(this.props.defaultText)
|
|
|
|
|
) {
|
|
|
|
|
this.formatText();
|
2022-03-01 19:02:10 +00:00
|
|
|
}
|
|
|
|
|
// If defaultText property has changed, reset isDirty to false
|
|
|
|
|
if (
|
|
|
|
|
this.props.defaultText !== prevProps.defaultText &&
|
|
|
|
|
this.props.isDirty
|
|
|
|
|
) {
|
feat: Internal property to detect changes in a form
-- Implement dirty check logic for a form
-- Expose an form property, hasChanges for checking if the user has changed any values in the form
-- Add isDirty derived property for the following widgets: AudioRecorderWidget, CameraWidget, CheckboxGroupWidget, CheckboxWidget, CurrencyInputWidget, DatePickerWidget2, FilePickerWidgetV2, InputWidgetV2, MultiSelectTreeWidget, MultiSelectWidgetV2, PhoneInputWidget, RadioGroupWidget, RichTextEditorWidget, SelectWidget, SingleSelectTreeWidget, SwitchGroupWidget, SwitchWidget
2022-02-23 08:03:51 +00:00
|
|
|
this.props.updateWidgetMetaProperty("isDirty", false);
|
2022-01-18 07:52:24 +00:00
|
|
|
}
|
2022-04-08 17:39:05 +00:00
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
this.props.currencyCode === this.props.defaultCurrencyCode &&
|
|
|
|
|
prevProps.currencyCode !== this.props.currencyCode
|
|
|
|
|
) {
|
|
|
|
|
this.onCurrencyTypeChange(this.props.currencyCode);
|
|
|
|
|
}
|
2022-01-18 07:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
formatText() {
|
|
|
|
|
if (!!this.props.text) {
|
|
|
|
|
try {
|
2022-11-02 10:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Since we are restricting default value to only have "." decimal separator,
|
|
|
|
|
* hence we directly convert it to the current locale
|
|
|
|
|
*/
|
|
|
|
|
const floatVal = parseFloat(this.props.text);
|
|
|
|
|
|
|
|
|
|
const formattedValue = Intl.NumberFormat(getLocale(), {
|
|
|
|
|
style: "decimal",
|
|
|
|
|
minimumFractionDigits: this.props.decimals,
|
|
|
|
|
maximumFractionDigits: this.props.decimals,
|
|
|
|
|
}).format(floatVal);
|
2022-01-18 07:52:24 +00:00
|
|
|
this.props.updateWidgetMetaProperty("text", formattedValue);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onValueChange = (value: string) => {
|
|
|
|
|
let formattedValue = "";
|
|
|
|
|
const decimalSeperator = getLocaleDecimalSeperator();
|
|
|
|
|
try {
|
|
|
|
|
if (value && value.includes(decimalSeperator)) {
|
|
|
|
|
formattedValue = limitDecimalValue(this.props.decimals, value);
|
|
|
|
|
} else {
|
|
|
|
|
formattedValue = value;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
formattedValue = value;
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// text is stored as what user has typed
|
|
|
|
|
this.props.updateWidgetMetaProperty("text", String(formattedValue), {
|
|
|
|
|
triggerPropertyName: "onTextChanged",
|
|
|
|
|
dynamicString: this.props.onTextChanged,
|
|
|
|
|
event: {
|
|
|
|
|
type: EventType.ON_TEXT_CHANGE,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!this.props.isDirty) {
|
|
|
|
|
this.props.updateWidgetMetaProperty("isDirty", true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleFocusChange = (isFocused?: boolean) => {
|
|
|
|
|
try {
|
|
|
|
|
if (isFocused) {
|
2022-03-31 03:01:04 +00:00
|
|
|
const text = this.props.text || "";
|
|
|
|
|
const deFormattedValue = text.replace(
|
|
|
|
|
new RegExp("\\" + getLocaleThousandSeparator(), "g"),
|
|
|
|
|
"",
|
2022-01-18 07:52:24 +00:00
|
|
|
);
|
2022-03-31 03:01:04 +00:00
|
|
|
this.props.updateWidgetMetaProperty("text", deFormattedValue);
|
2022-01-18 07:52:24 +00:00
|
|
|
} else {
|
|
|
|
|
if (this.props.text) {
|
|
|
|
|
const formattedValue = formatCurrencyNumber(
|
|
|
|
|
this.props.decimals,
|
2022-03-31 03:01:04 +00:00
|
|
|
this.props.text,
|
2022-01-18 07:52:24 +00:00
|
|
|
);
|
|
|
|
|
this.props.updateWidgetMetaProperty("text", formattedValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
this.props.updateWidgetMetaProperty("text", this.props.text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.handleFocusChange(!!isFocused);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onCurrencyTypeChange = (currencyCode?: string) => {
|
|
|
|
|
const countryCode = getCountryCodeFromCurrencyCode(currencyCode);
|
|
|
|
|
|
|
|
|
|
this.props.updateWidgetMetaProperty("countryCode", countryCode);
|
2022-04-08 17:39:05 +00:00
|
|
|
this.props.updateWidgetMetaProperty("currencyCode", currencyCode);
|
2022-01-18 07:52:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleKeyDown = (
|
|
|
|
|
e:
|
|
|
|
|
| React.KeyboardEvent<HTMLTextAreaElement>
|
|
|
|
|
| React.KeyboardEvent<HTMLInputElement>,
|
|
|
|
|
) => {
|
2022-02-09 12:03:10 +00:00
|
|
|
super.handleKeyDown(e);
|
2022-01-18 07:52:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onStep = (direction: number) => {
|
|
|
|
|
const value = Number(this.props.value) + direction;
|
2022-11-02 10:32:45 +00:00
|
|
|
|
|
|
|
|
// Since value is always going to be a number therefore, directly converting it to the current locale
|
|
|
|
|
const formattedValue = Intl.NumberFormat(getLocale()).format(value);
|
2022-03-01 19:02:10 +00:00
|
|
|
if (!this.props.isDirty) {
|
|
|
|
|
this.props.updateWidgetMetaProperty("isDirty", true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 07:52:24 +00:00
|
|
|
this.props.updateWidgetMetaProperty("text", String(formattedValue), {
|
|
|
|
|
triggerPropertyName: "onTextChanged",
|
|
|
|
|
dynamicString: this.props.onTextChanged,
|
|
|
|
|
event: {
|
|
|
|
|
type: EventType.ON_TEXT_CHANGE,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getPageView() {
|
|
|
|
|
const value = this.props.text ?? "";
|
|
|
|
|
const isInvalid =
|
|
|
|
|
"isValid" in this.props && !this.props.isValid && !!this.props.isDirty;
|
|
|
|
|
const currencyCode = this.props.currencyCode;
|
|
|
|
|
const conditionalProps: Partial<CurrencyInputComponentProps> = {};
|
|
|
|
|
conditionalProps.errorMessage = this.props.errorMessage;
|
|
|
|
|
if (this.props.isRequired && value.length === 0) {
|
|
|
|
|
conditionalProps.errorMessage = createMessage(FIELD_REQUIRED_ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<CurrencyInputComponent
|
2022-05-04 09:45:57 +00:00
|
|
|
accentColor={this.props.accentColor}
|
2022-01-18 07:52:24 +00:00
|
|
|
allowCurrencyChange={this.props.allowCurrencyChange}
|
|
|
|
|
autoFocus={this.props.autoFocus}
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius={this.props.borderRadius}
|
|
|
|
|
boxShadow={this.props.boxShadow}
|
feat: Controls for labels in widgets to align the widgets in forms and other places (#10600)
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Create a new property control for a label position
-- Create a new property control for a label alignment
-- Prototype a label section for Input widget
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Add a property, labelWidth in the property pane
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Input widget: Implement all the requirements in case its type is Text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adapt the functionalty on other types of the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into DropdownWidget
-- Clean up for the input widget and DRY
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectWidget
-- Eliminate unnecessary component prop, columns
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalties into Tree Select widget
-- Add styles for alignment between lable and input control over the widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectTreeWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Introduce label functionalities into DatePickerWidget2
-- Use width instead of columns prop in InputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RichTextEditorWidget
-- Eliminate compactMode from StyledLabel
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into CheckboxGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement switch group for the correct meaning of right alignment
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RadioGroupWidget
-- Add new properties, alignment and inline for consistency
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adjust cols and rows for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused StyledRadioProps
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete first MVP of enhanced SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete the first MVP of enhanced RadioGroupWidget
-- Eliminate unused StyledSwitch component for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add min-height, align-self rules for LabelContainer
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Use original label property for RadioGroupWidget
-- Add a migration for adding isInline and alignment properties for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Update version to latest one in DSLMigrationsUtils.test.ts
* fix failing jest test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement label functionalities on BaseInputWidget, InputWidgetV2, CurrencyInputWidget, PhoneInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DSLMigrationsUtils
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the label related test case which is failed in Input_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on #10119: The label text truncates on resizing the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix scroll issue when shrink with MultiSelectWidget and MultiSelectTreeWidget
* fix: Widget Popup test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement width and alginment features on the level of label element
-- Prevent actual inputs from DropdownWidget, MultiSelectWidget, SingleSelectTreeWidget, MultiSelectTreeWidget from overflow when resizing
-- Enable label feature on a RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set label container's default width to 33% when width is not set
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix crash issue when labelWidth is filled by non-numeric value, eliminating passing NaN as its value
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set flex-grow to zero on input types other than TEXT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label features on newly created MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate LabelPositionTypes, directly using enum LabelPosition
-- Add a comment for a constant LABEL_MAX_WIDTH_RATE
-- Directly import React for LabelAlignmentOptionsControl
-- Remove unnecessary constructor for LabelAlignmentOptionsControl
-- Define handleAlign instance method as a higher-order function
-- Only migrate alignment property for RadioGroupWidget
-- Use Object.hasOwnProperty instead of in operator
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Migrate alignment property of RadioGroupWidget in case of currentDSL.version is 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Revert currentDSL.version to 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a Jest test case for RadioGroupWidget's alignment property migration
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Replace all nested ternary operators with if statements
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label feature on new version of SelectWidget
-- Add Cypress tests for widgets' label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor code for BaseInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change CSS selector for step buttons for Numeric BaseInputWidget
-- Directly use migrateRadioGroupAlignmentProperty migration function without using transformDSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on typo about migrateRadioGroupAlignmentProperty
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add data-testid attributes for Cypress selectors
* feat: Deprecate form button widget
-- Assert flex-direction to row in CheckboxGroup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a missing data-testid for SelectWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on failed test cases: CheckboxGroup_spec, DatePicker_2_spec, MultiSelectWidgetV2
* fix: Select popup DSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new property control, NumericInputControl
-- Replace all the label properties with the newly created controls
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new Cypress command, checkLabelWidth and apply to all related test cases
-- Increase width in checkboxgroupDsl.json
-- Rename className for label in MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement the tooltip feature for labels
-- Add missing props for labels in DateField, MultiSelectField, RadioGroupField, SelectField fields for JSONFormWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor property controls, including LabelPositionOptionsControl, LabelAlignmentOptionsControl, NumericInputControl to keep consistency
-- Apply default values into label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract the label related parts from the various widgets as an independent component
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate TypeScript any type from BaseInputComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change labelPosition property type to DROP_DOWN
-- Modify LabelAlignmentOptionsControl to use ButtonTabComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Define getLabelWidth method into BaseWidget
-- Extract the common CSS rules for the widget containers
-- Revert rows and columns for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed test case in DSLMigrationsUtils.test.ts
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on overflow issue on CheckboxGroupWidget
-- Create a distinctive spec file for label feature
-- Eliminate the redundant label specs with the relevant widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Delete unnecessary files, including Select_spec.js, LabelButton.tsx and LabelPositionOptionsControl.tsx
-- Revise wrong comment for checkLabelForWidget Cypress command
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Do not set the label width only if its value is 0
-- Clean up the component for DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Make RadioGroupWidget's layout flexible in all modes
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on Cypress test case for RadioGroupWidget in Widgets_Labels_spec
-- Change Cypress commands, including addAction, addSuccessMessage, enterActionValue to accept parentSelector
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change getLabelWidth method to not have any argument
-- Define some constants for label numbers
-- Extract the common styles for SwitchGroupWidget and RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor some constants
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused width prop from RadioGroupWidget
-- Get labelWidth from getLabelWidth
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate the min-height restriction on a label
-- Eliminate the scroll on the earlier InputWidgetV2 which was not in compact mode
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add one more condition checking if the current input type is text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract common code base for MultiSelectTreeWidget and MultiSelectWidgetV2
-- Apply a few CSS fixes on the scrollbar issue select related widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply some tweaks for earlier widgets with labels so as not to be broken UX
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed Cypress test case in Widget_Popup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add constants, LABEL_DEFAULT_WIDTH_RATE, SELECT_DEFAULT_HEIGHT, LABEL_MARGIN_OLD_SELECT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Increase the widths of CheckboxGroupWidget and SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set the font size to 14px for NumericInputControl
Co-authored-by: ohansFavour <fohanekwu@gmail.com>
Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com>
2022-04-14 08:47:25 +00:00
|
|
|
compactMode={
|
|
|
|
|
!(
|
|
|
|
|
(this.props.bottomRow - this.props.topRow) /
|
|
|
|
|
GRID_DENSITY_MIGRATION_V1 >
|
|
|
|
|
1
|
|
|
|
|
)
|
|
|
|
|
}
|
2022-01-18 07:52:24 +00:00
|
|
|
currencyCode={currencyCode}
|
|
|
|
|
decimals={this.props.decimals}
|
|
|
|
|
defaultValue={this.props.defaultText}
|
|
|
|
|
disableNewLineOnPressEnterKey={!!this.props.onSubmit}
|
|
|
|
|
disabled={this.props.isDisabled}
|
|
|
|
|
iconAlign={this.props.iconAlign}
|
|
|
|
|
iconName={this.props.iconName}
|
|
|
|
|
inputType={this.props.inputType}
|
2022-11-23 09:48:23 +00:00
|
|
|
isDynamicHeightEnabled={isAutoHeightEnabledForWidget(this.props)}
|
2022-01-18 07:52:24 +00:00
|
|
|
isInvalid={isInvalid}
|
|
|
|
|
isLoading={this.props.isLoading}
|
|
|
|
|
label={this.props.label}
|
feat: Controls for labels in widgets to align the widgets in forms and other places (#10600)
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Create a new property control for a label position
-- Create a new property control for a label alignment
-- Prototype a label section for Input widget
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Add a property, labelWidth in the property pane
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Input widget: Implement all the requirements in case its type is Text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adapt the functionalty on other types of the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into DropdownWidget
-- Clean up for the input widget and DRY
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectWidget
-- Eliminate unnecessary component prop, columns
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalties into Tree Select widget
-- Add styles for alignment between lable and input control over the widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectTreeWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Introduce label functionalities into DatePickerWidget2
-- Use width instead of columns prop in InputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RichTextEditorWidget
-- Eliminate compactMode from StyledLabel
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into CheckboxGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement switch group for the correct meaning of right alignment
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RadioGroupWidget
-- Add new properties, alignment and inline for consistency
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adjust cols and rows for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused StyledRadioProps
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete first MVP of enhanced SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete the first MVP of enhanced RadioGroupWidget
-- Eliminate unused StyledSwitch component for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add min-height, align-self rules for LabelContainer
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Use original label property for RadioGroupWidget
-- Add a migration for adding isInline and alignment properties for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Update version to latest one in DSLMigrationsUtils.test.ts
* fix failing jest test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement label functionalities on BaseInputWidget, InputWidgetV2, CurrencyInputWidget, PhoneInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DSLMigrationsUtils
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the label related test case which is failed in Input_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on #10119: The label text truncates on resizing the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix scroll issue when shrink with MultiSelectWidget and MultiSelectTreeWidget
* fix: Widget Popup test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement width and alginment features on the level of label element
-- Prevent actual inputs from DropdownWidget, MultiSelectWidget, SingleSelectTreeWidget, MultiSelectTreeWidget from overflow when resizing
-- Enable label feature on a RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set label container's default width to 33% when width is not set
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix crash issue when labelWidth is filled by non-numeric value, eliminating passing NaN as its value
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set flex-grow to zero on input types other than TEXT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label features on newly created MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate LabelPositionTypes, directly using enum LabelPosition
-- Add a comment for a constant LABEL_MAX_WIDTH_RATE
-- Directly import React for LabelAlignmentOptionsControl
-- Remove unnecessary constructor for LabelAlignmentOptionsControl
-- Define handleAlign instance method as a higher-order function
-- Only migrate alignment property for RadioGroupWidget
-- Use Object.hasOwnProperty instead of in operator
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Migrate alignment property of RadioGroupWidget in case of currentDSL.version is 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Revert currentDSL.version to 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a Jest test case for RadioGroupWidget's alignment property migration
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Replace all nested ternary operators with if statements
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label feature on new version of SelectWidget
-- Add Cypress tests for widgets' label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor code for BaseInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change CSS selector for step buttons for Numeric BaseInputWidget
-- Directly use migrateRadioGroupAlignmentProperty migration function without using transformDSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on typo about migrateRadioGroupAlignmentProperty
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add data-testid attributes for Cypress selectors
* feat: Deprecate form button widget
-- Assert flex-direction to row in CheckboxGroup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a missing data-testid for SelectWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on failed test cases: CheckboxGroup_spec, DatePicker_2_spec, MultiSelectWidgetV2
* fix: Select popup DSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new property control, NumericInputControl
-- Replace all the label properties with the newly created controls
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new Cypress command, checkLabelWidth and apply to all related test cases
-- Increase width in checkboxgroupDsl.json
-- Rename className for label in MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement the tooltip feature for labels
-- Add missing props for labels in DateField, MultiSelectField, RadioGroupField, SelectField fields for JSONFormWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor property controls, including LabelPositionOptionsControl, LabelAlignmentOptionsControl, NumericInputControl to keep consistency
-- Apply default values into label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract the label related parts from the various widgets as an independent component
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate TypeScript any type from BaseInputComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change labelPosition property type to DROP_DOWN
-- Modify LabelAlignmentOptionsControl to use ButtonTabComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Define getLabelWidth method into BaseWidget
-- Extract the common CSS rules for the widget containers
-- Revert rows and columns for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed test case in DSLMigrationsUtils.test.ts
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on overflow issue on CheckboxGroupWidget
-- Create a distinctive spec file for label feature
-- Eliminate the redundant label specs with the relevant widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Delete unnecessary files, including Select_spec.js, LabelButton.tsx and LabelPositionOptionsControl.tsx
-- Revise wrong comment for checkLabelForWidget Cypress command
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Do not set the label width only if its value is 0
-- Clean up the component for DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Make RadioGroupWidget's layout flexible in all modes
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on Cypress test case for RadioGroupWidget in Widgets_Labels_spec
-- Change Cypress commands, including addAction, addSuccessMessage, enterActionValue to accept parentSelector
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change getLabelWidth method to not have any argument
-- Define some constants for label numbers
-- Extract the common styles for SwitchGroupWidget and RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor some constants
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused width prop from RadioGroupWidget
-- Get labelWidth from getLabelWidth
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate the min-height restriction on a label
-- Eliminate the scroll on the earlier InputWidgetV2 which was not in compact mode
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add one more condition checking if the current input type is text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract common code base for MultiSelectTreeWidget and MultiSelectWidgetV2
-- Apply a few CSS fixes on the scrollbar issue select related widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply some tweaks for earlier widgets with labels so as not to be broken UX
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed Cypress test case in Widget_Popup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add constants, LABEL_DEFAULT_WIDTH_RATE, SELECT_DEFAULT_HEIGHT, LABEL_MARGIN_OLD_SELECT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Increase the widths of CheckboxGroupWidget and SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set the font size to 14px for NumericInputControl
Co-authored-by: ohansFavour <fohanekwu@gmail.com>
Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com>
2022-04-14 08:47:25 +00:00
|
|
|
labelAlignment={this.props.labelAlignment}
|
|
|
|
|
labelPosition={this.props.labelPosition}
|
2022-01-18 07:52:24 +00:00
|
|
|
labelStyle={this.props.labelStyle}
|
|
|
|
|
labelTextColor={this.props.labelTextColor}
|
|
|
|
|
labelTextSize={this.props.labelTextSize}
|
feat: Controls for labels in widgets to align the widgets in forms and other places (#10600)
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Create a new property control for a label position
-- Create a new property control for a label alignment
-- Prototype a label section for Input widget
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Add a property, labelWidth in the property pane
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Input widget: Implement all the requirements in case its type is Text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adapt the functionalty on other types of the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into DropdownWidget
-- Clean up for the input widget and DRY
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectWidget
-- Eliminate unnecessary component prop, columns
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalties into Tree Select widget
-- Add styles for alignment between lable and input control over the widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectTreeWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Introduce label functionalities into DatePickerWidget2
-- Use width instead of columns prop in InputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RichTextEditorWidget
-- Eliminate compactMode from StyledLabel
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into CheckboxGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement switch group for the correct meaning of right alignment
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RadioGroupWidget
-- Add new properties, alignment and inline for consistency
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adjust cols and rows for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused StyledRadioProps
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete first MVP of enhanced SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete the first MVP of enhanced RadioGroupWidget
-- Eliminate unused StyledSwitch component for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add min-height, align-self rules for LabelContainer
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Use original label property for RadioGroupWidget
-- Add a migration for adding isInline and alignment properties for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Update version to latest one in DSLMigrationsUtils.test.ts
* fix failing jest test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement label functionalities on BaseInputWidget, InputWidgetV2, CurrencyInputWidget, PhoneInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DSLMigrationsUtils
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the label related test case which is failed in Input_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on #10119: The label text truncates on resizing the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix scroll issue when shrink with MultiSelectWidget and MultiSelectTreeWidget
* fix: Widget Popup test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement width and alginment features on the level of label element
-- Prevent actual inputs from DropdownWidget, MultiSelectWidget, SingleSelectTreeWidget, MultiSelectTreeWidget from overflow when resizing
-- Enable label feature on a RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set label container's default width to 33% when width is not set
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix crash issue when labelWidth is filled by non-numeric value, eliminating passing NaN as its value
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set flex-grow to zero on input types other than TEXT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label features on newly created MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate LabelPositionTypes, directly using enum LabelPosition
-- Add a comment for a constant LABEL_MAX_WIDTH_RATE
-- Directly import React for LabelAlignmentOptionsControl
-- Remove unnecessary constructor for LabelAlignmentOptionsControl
-- Define handleAlign instance method as a higher-order function
-- Only migrate alignment property for RadioGroupWidget
-- Use Object.hasOwnProperty instead of in operator
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Migrate alignment property of RadioGroupWidget in case of currentDSL.version is 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Revert currentDSL.version to 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a Jest test case for RadioGroupWidget's alignment property migration
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Replace all nested ternary operators with if statements
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label feature on new version of SelectWidget
-- Add Cypress tests for widgets' label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor code for BaseInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change CSS selector for step buttons for Numeric BaseInputWidget
-- Directly use migrateRadioGroupAlignmentProperty migration function without using transformDSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on typo about migrateRadioGroupAlignmentProperty
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add data-testid attributes for Cypress selectors
* feat: Deprecate form button widget
-- Assert flex-direction to row in CheckboxGroup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a missing data-testid for SelectWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on failed test cases: CheckboxGroup_spec, DatePicker_2_spec, MultiSelectWidgetV2
* fix: Select popup DSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new property control, NumericInputControl
-- Replace all the label properties with the newly created controls
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new Cypress command, checkLabelWidth and apply to all related test cases
-- Increase width in checkboxgroupDsl.json
-- Rename className for label in MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement the tooltip feature for labels
-- Add missing props for labels in DateField, MultiSelectField, RadioGroupField, SelectField fields for JSONFormWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor property controls, including LabelPositionOptionsControl, LabelAlignmentOptionsControl, NumericInputControl to keep consistency
-- Apply default values into label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract the label related parts from the various widgets as an independent component
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate TypeScript any type from BaseInputComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change labelPosition property type to DROP_DOWN
-- Modify LabelAlignmentOptionsControl to use ButtonTabComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Define getLabelWidth method into BaseWidget
-- Extract the common CSS rules for the widget containers
-- Revert rows and columns for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed test case in DSLMigrationsUtils.test.ts
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on overflow issue on CheckboxGroupWidget
-- Create a distinctive spec file for label feature
-- Eliminate the redundant label specs with the relevant widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Delete unnecessary files, including Select_spec.js, LabelButton.tsx and LabelPositionOptionsControl.tsx
-- Revise wrong comment for checkLabelForWidget Cypress command
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Do not set the label width only if its value is 0
-- Clean up the component for DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Make RadioGroupWidget's layout flexible in all modes
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on Cypress test case for RadioGroupWidget in Widgets_Labels_spec
-- Change Cypress commands, including addAction, addSuccessMessage, enterActionValue to accept parentSelector
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change getLabelWidth method to not have any argument
-- Define some constants for label numbers
-- Extract the common styles for SwitchGroupWidget and RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor some constants
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused width prop from RadioGroupWidget
-- Get labelWidth from getLabelWidth
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate the min-height restriction on a label
-- Eliminate the scroll on the earlier InputWidgetV2 which was not in compact mode
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add one more condition checking if the current input type is text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract common code base for MultiSelectTreeWidget and MultiSelectWidgetV2
-- Apply a few CSS fixes on the scrollbar issue select related widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply some tweaks for earlier widgets with labels so as not to be broken UX
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed Cypress test case in Widget_Popup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add constants, LABEL_DEFAULT_WIDTH_RATE, SELECT_DEFAULT_HEIGHT, LABEL_MARGIN_OLD_SELECT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Increase the widths of CheckboxGroupWidget and SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set the font size to 14px for NumericInputControl
Co-authored-by: ohansFavour <fohanekwu@gmail.com>
Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com>
2022-04-14 08:47:25 +00:00
|
|
|
labelWidth={this.getLabelWidth()}
|
2022-01-18 07:52:24 +00:00
|
|
|
onCurrencyTypeChange={this.onCurrencyTypeChange}
|
|
|
|
|
onFocusChange={this.handleFocusChange}
|
|
|
|
|
onKeyDown={this.handleKeyDown}
|
|
|
|
|
onStep={this.onStep}
|
|
|
|
|
onValueChange={this.onValueChange}
|
|
|
|
|
placeholder={this.props.placeholderText}
|
|
|
|
|
renderMode={this.props.renderMode}
|
|
|
|
|
showError={!!this.props.isFocused}
|
|
|
|
|
tooltip={this.props.tooltip}
|
|
|
|
|
value={value}
|
|
|
|
|
widgetId={this.props.widgetId}
|
|
|
|
|
{...conditionalProps}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getWidgetType(): WidgetType {
|
|
|
|
|
return "CURRENCY_INPUT_WIDGET";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CurrencyInputWidgetProps extends BaseInputWidgetProps {
|
|
|
|
|
countryCode?: string;
|
|
|
|
|
currencyCode?: string;
|
|
|
|
|
noOfDecimals?: number;
|
|
|
|
|
allowCurrencyChange?: boolean;
|
|
|
|
|
decimals?: number;
|
|
|
|
|
defaultText?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default CurrencyInputWidget;
|