2022-01-18 07:52:24 +00:00
|
|
|
import React from "react";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### 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
- [ ] 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
- [x] 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:
- [ ] Test plan has been approved by relevant developers
- [ ] 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: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { WidgetState } from "widgets/BaseWidget";
|
|
|
|
|
import type { CurrencyInputComponentProps } from "../component";
|
|
|
|
|
import CurrencyInputComponent from "../component";
|
2022-02-09 12:03:10 +00:00
|
|
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### 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
- [ ] 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
- [x] 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:
- [ ] Test plan has been approved by relevant developers
- [ ] 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: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ValidationResponse } from "constants/WidgetValidation";
|
|
|
|
|
import { ValidationTypes } from "constants/WidgetValidation";
|
2022-02-11 18:08:46 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
FIELD_REQUIRED_ERROR,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-09-06 12:15:04 +00:00
|
|
|
import type { DerivedPropertiesMap } from "WidgetProvider/factory";
|
2022-01-18 07:52:24 +00:00
|
|
|
import {
|
|
|
|
|
CurrencyDropdownOptions,
|
|
|
|
|
getCountryCodeFromCurrencyCode,
|
|
|
|
|
} from "../component/CurrencyCodeDropdown";
|
2023-05-11 05:26:03 +00:00
|
|
|
import { AutocompleteDataType } from "utils/autocomplete/AutocompleteDataType";
|
2022-01-18 07:52:24 +00:00
|
|
|
import _ from "lodash";
|
|
|
|
|
import derivedProperties from "./parsedDerivedProperties";
|
|
|
|
|
import BaseInputWidget from "widgets/BaseInputWidget";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### 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
- [ ] 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
- [x] 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:
- [ ] Test plan has been approved by relevant developers
- [ ] 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: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { BaseInputWidgetProps } from "widgets/BaseInputWidget/widget";
|
2022-01-18 07:52:24 +00:00
|
|
|
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";
|
|
|
|
|
import {
|
|
|
|
|
getLocaleDecimalSeperator,
|
|
|
|
|
getLocaleThousandSeparator,
|
2022-11-23 09:48:23 +00:00
|
|
|
isAutoHeightEnabledForWidget,
|
2023-04-14 06:27:49 +00:00
|
|
|
DefaultAutocompleteDefinitions,
|
2023-09-13 13:57:42 +00:00
|
|
|
isCompactMode,
|
2022-11-02 10:32:45 +00:00
|
|
|
} from "widgets/WidgetUtils";
|
2023-07-08 14:07:26 +00:00
|
|
|
import type { SetterConfig, Stylesheet } from "entities/AppTheming";
|
2022-12-21 17:07:15 +00:00
|
|
|
import { NumberInputStepButtonPosition } from "widgets/BaseInputWidget/constants";
|
2023-09-06 12:15:04 +00:00
|
|
|
import type { AutocompletionDefinitions } from "WidgetProvider/constants";
|
|
|
|
|
import { LabelPosition } from "components/constants";
|
|
|
|
|
import { FILL_WIDGET_MIN_WIDTH } from "constants/minWidthConstants";
|
2023-09-11 15:55:11 +00:00
|
|
|
import { ResponsiveBehavior } from "layoutSystems/autolayout/utils/constants";
|
2023-09-06 12:15:04 +00:00
|
|
|
import { DynamicHeight } from "utils/WidgetFeatures";
|
|
|
|
|
import { getDefaultCurrency } from "../component/CurrencyCodeDropdown";
|
|
|
|
|
import IconSVG from "../icon.svg";
|
|
|
|
|
import { WIDGET_TAGS } from "constants/WidgetConstants";
|
2022-01-18 07:52:24 +00:00
|
|
|
|
|
|
|
|
export function defaultValueValidation(
|
|
|
|
|
value: any,
|
|
|
|
|
props: CurrencyInputWidgetProps,
|
|
|
|
|
_?: any,
|
|
|
|
|
): ValidationResponse {
|
2023-02-18 12:55:46 +00:00
|
|
|
const NUMBER_ERROR_MESSAGE = {
|
|
|
|
|
name: "TypeError",
|
|
|
|
|
message: "This value must be number",
|
|
|
|
|
};
|
|
|
|
|
const DECIMAL_SEPARATOR_ERROR_MESSAGE = {
|
|
|
|
|
name: "ValidationError",
|
|
|
|
|
message: "Please use . as the decimal separator for default values.",
|
|
|
|
|
};
|
|
|
|
|
const EMPTY_ERROR_MESSAGE = {
|
|
|
|
|
name: "",
|
|
|
|
|
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],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-08 14:07:26 +00:00
|
|
|
if (_.isBoolean(value) || _.isUndefined(value) || _.isNull(value)) {
|
|
|
|
|
return {
|
|
|
|
|
isValid: false,
|
|
|
|
|
parsed: value,
|
|
|
|
|
messages: [NUMBER_ERROR_MESSAGE],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 07:52:24 +00:00
|
|
|
let parsed: any = Number(value);
|
|
|
|
|
let isValid, messages;
|
|
|
|
|
|
|
|
|
|
if (_.isString(value) && value.trim() === "") {
|
|
|
|
|
/*
|
2023-07-08 14:07:26 +00:00
|
|
|
* When value is empty string
|
2022-01-18 07:52:24 +00:00
|
|
|
*/
|
|
|
|
|
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 = [
|
2023-02-18 12:55:46 +00:00
|
|
|
{
|
|
|
|
|
name: "RangeError",
|
|
|
|
|
message:
|
|
|
|
|
"No. of decimals are higher than the decimals field set. Please update the default or the decimals field",
|
|
|
|
|
},
|
2022-01-18 07:52:24 +00:00
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
isValid = true;
|
|
|
|
|
messages = [EMPTY_ERROR_MESSAGE];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parsed = String(parsed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
isValid,
|
|
|
|
|
parsed,
|
|
|
|
|
messages,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CurrencyInputWidget extends BaseInputWidget<
|
|
|
|
|
CurrencyInputWidgetProps,
|
|
|
|
|
WidgetState
|
|
|
|
|
> {
|
2023-09-06 12:15:04 +00:00
|
|
|
static type = "CURRENCY_INPUT_WIDGET";
|
|
|
|
|
|
|
|
|
|
static getConfig() {
|
|
|
|
|
return {
|
|
|
|
|
name: "Currency Input",
|
|
|
|
|
iconSVG: IconSVG,
|
|
|
|
|
tags: [WIDGET_TAGS.INPUTS],
|
|
|
|
|
needsMeta: true,
|
|
|
|
|
searchTags: ["amount", "total"],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getFeatures() {
|
|
|
|
|
return {
|
|
|
|
|
dynamicHeight: {
|
|
|
|
|
sectionIndex: 3,
|
|
|
|
|
defaultValue: DynamicHeight.FIXED,
|
|
|
|
|
active: true,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getDefaults() {
|
|
|
|
|
return {
|
|
|
|
|
...BaseInputWidget.getDefaults(),
|
|
|
|
|
widgetName: "CurrencyInput",
|
|
|
|
|
version: 1,
|
|
|
|
|
rows: 7,
|
|
|
|
|
labelPosition: LabelPosition.Top,
|
|
|
|
|
allowCurrencyChange: false,
|
|
|
|
|
defaultCurrencyCode: getDefaultCurrency().currency,
|
|
|
|
|
decimals: 0,
|
|
|
|
|
showStepArrows: false,
|
|
|
|
|
responsiveBehavior: ResponsiveBehavior.Fill,
|
|
|
|
|
minWidth: FILL_WIDGET_MIN_WIDTH,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getAutoLayoutConfig() {
|
|
|
|
|
return {
|
|
|
|
|
disabledPropsDefaults: {
|
|
|
|
|
labelPosition: LabelPosition.Top,
|
|
|
|
|
labelTextSize: "0.875rem",
|
|
|
|
|
},
|
|
|
|
|
defaults: {
|
|
|
|
|
rows: 6.6,
|
|
|
|
|
},
|
|
|
|
|
autoDimension: {
|
|
|
|
|
height: true,
|
|
|
|
|
},
|
|
|
|
|
widgetSize: [
|
|
|
|
|
{
|
|
|
|
|
viewportMinWidth: 0,
|
|
|
|
|
configuration: () => {
|
|
|
|
|
return {
|
|
|
|
|
minWidth: "120px",
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
disableResizeHandles: {
|
|
|
|
|
vertical: true,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-04-14 06:27:49 +00:00
|
|
|
static getAutocompleteDefinitions(): AutocompletionDefinitions {
|
|
|
|
|
return {
|
|
|
|
|
"!doc":
|
|
|
|
|
"An input text field is used to capture a currency value. Inputs are used in forms and can have custom validations.",
|
|
|
|
|
"!url": "https://docs.appsmith.com/widget-reference/currency-input",
|
|
|
|
|
text: {
|
|
|
|
|
"!type": "string",
|
|
|
|
|
"!doc": "The formatted text value of the input",
|
|
|
|
|
"!url": "https://docs.appsmith.com/widget-reference/currency-input",
|
|
|
|
|
},
|
|
|
|
|
value: {
|
|
|
|
|
"!type": "number",
|
|
|
|
|
"!doc": "The value of the input",
|
|
|
|
|
"!url": "https://docs.appsmith.com/widget-reference/currency-input",
|
|
|
|
|
},
|
|
|
|
|
isValid: "bool",
|
|
|
|
|
isVisible: DefaultAutocompleteDefinitions.isVisible,
|
|
|
|
|
isDisabled: "bool",
|
|
|
|
|
countryCode: {
|
|
|
|
|
"!type": "string",
|
|
|
|
|
"!doc": "Selected country code for Currency",
|
|
|
|
|
},
|
|
|
|
|
currencyCode: {
|
|
|
|
|
"!type": "string",
|
|
|
|
|
"!doc": "Selected Currency code",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-07-08 14:07:26 +00:00
|
|
|
|
|
|
|
|
static getSetterConfig(): SetterConfig {
|
|
|
|
|
return {
|
|
|
|
|
__setters: {
|
|
|
|
|
setVisibility: {
|
|
|
|
|
path: "isVisible",
|
|
|
|
|
type: "boolean",
|
|
|
|
|
},
|
|
|
|
|
setDisabled: {
|
|
|
|
|
path: "isDisabled",
|
|
|
|
|
type: "boolean",
|
|
|
|
|
},
|
|
|
|
|
setRequired: {
|
|
|
|
|
path: "isRequired",
|
|
|
|
|
type: "boolean",
|
|
|
|
|
},
|
|
|
|
|
setValue: {
|
|
|
|
|
path: "defaultText",
|
|
|
|
|
type: "string",
|
2023-07-24 06:53:45 +00:00
|
|
|
accessor: "text",
|
2023-07-08 14:07:26 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
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",
|
2023-05-19 18:37:06 +00:00
|
|
|
label: "Default value",
|
2022-08-11 11:20:09 +00:00
|
|
|
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,
|
2023-05-19 18:37:06 +00:00
|
|
|
virtual: true,
|
2022-08-11 11:20:09 +00:00
|
|
|
isJSConvertible: true,
|
|
|
|
|
isBindProperty: true,
|
|
|
|
|
isTriggerProperty: false,
|
|
|
|
|
validation: {
|
|
|
|
|
type: ValidationTypes.TEXT,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
propertyName: "allowCurrencyChange",
|
2023-05-19 18:37:06 +00:00
|
|
|
label: "Allow currency change",
|
2022-08-11 11:20:09 +00:00
|
|
|
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",
|
2023-05-19 18:37:06 +00:00
|
|
|
label: "Decimals allowed",
|
2022-08-11 11:20:09 +00:00
|
|
|
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() {
|
2023-02-14 16:07:31 +00:00
|
|
|
if (!!this.props.text && !this.isTextFormatted()) {
|
2022-01-18 07:52:24 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-14 16:07:31 +00:00
|
|
|
isTextFormatted = () => {
|
|
|
|
|
return this.props.text.includes(getLocaleThousandSeparator());
|
|
|
|
|
};
|
|
|
|
|
|
2022-01-18 07:52:24 +00:00
|
|
|
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-12-12 07:09:22 +00:00
|
|
|
this.props.updateWidgetMetaProperty("isFocused", isFocused, {
|
|
|
|
|
triggerPropertyName: "onFocus",
|
|
|
|
|
dynamicString: this.props.onFocus,
|
|
|
|
|
event: {
|
|
|
|
|
type: EventType.ON_FOCUS,
|
|
|
|
|
},
|
|
|
|
|
});
|
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);
|
|
|
|
|
}
|
2022-12-12 07:09:22 +00:00
|
|
|
this.props.updateWidgetMetaProperty("isFocused", isFocused, {
|
|
|
|
|
triggerPropertyName: "onBlur",
|
|
|
|
|
dynamicString: this.props.onBlur,
|
|
|
|
|
event: {
|
|
|
|
|
type: EventType.ON_BLUR,
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-01-18 07:52:24 +00:00
|
|
|
}
|
|
|
|
|
} 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,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-11 15:55:11 +00:00
|
|
|
getWidgetView() {
|
2022-01-18 07:52:24 +00:00
|
|
|
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);
|
|
|
|
|
}
|
2023-09-13 13:57:42 +00:00
|
|
|
const { componentHeight } = this.props;
|
2022-01-18 07:52:24 +00:00
|
|
|
|
2022-12-21 17:07:15 +00:00
|
|
|
if (this.props.showStepArrows) {
|
|
|
|
|
conditionalProps.buttonPosition = NumberInputStepButtonPosition.RIGHT;
|
|
|
|
|
} else {
|
|
|
|
|
conditionalProps.buttonPosition = NumberInputStepButtonPosition.NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 07:52:24 +00:00
|
|
|
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}
|
2023-09-13 13:57:42 +00:00
|
|
|
compactMode={isCompactMode(componentHeight)}
|
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}
|
2023-09-13 13:57:42 +00:00
|
|
|
labelWidth={this.props.labelComponentWidth}
|
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}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CurrencyInputWidgetProps extends BaseInputWidgetProps {
|
|
|
|
|
countryCode?: string;
|
|
|
|
|
currencyCode?: string;
|
|
|
|
|
noOfDecimals?: number;
|
|
|
|
|
allowCurrencyChange?: boolean;
|
|
|
|
|
decimals?: number;
|
|
|
|
|
defaultText?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default CurrencyInputWidget;
|