2021-07-08 12:02:08 +00:00
|
|
|
import React, { useRef, useState } from "react";
|
2022-03-30 09:51:07 +00:00
|
|
|
import styled, { createGlobalStyle, css } from "styled-components";
|
2021-11-03 03:54:19 +00:00
|
|
|
import Interweave from "interweave";
|
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 { IButtonProps, MaybeElement } from "@blueprintjs/core";
|
|
|
|
|
import { Button, Alignment, Position, Classes } from "@blueprintjs/core";
|
2021-11-03 03:54:19 +00:00
|
|
|
import { Popover2 } from "@blueprintjs/popover2";
|
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 { IconName } from "@blueprintjs/icons";
|
2021-08-24 13:53:15 +00:00
|
|
|
|
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 { ComponentProps } from "widgets/BaseComponent";
|
2021-09-09 15:10:22 +00:00
|
|
|
|
2022-01-31 15:55:58 +00:00
|
|
|
import { useScript, ScriptStatus, AddScriptTo } from "utils/hooks/useScript";
|
2020-10-12 13:01:19 +00:00
|
|
|
import {
|
|
|
|
|
GOOGLE_RECAPTCHA_KEY_ERROR,
|
|
|
|
|
GOOGLE_RECAPTCHA_DOMAIN_ERROR,
|
2021-03-13 14:24:45 +00:00
|
|
|
createMessage,
|
2022-02-11 18:08:46 +00:00
|
|
|
} from "@appsmith/constants/messages";
|
2021-09-09 15:10:22 +00:00
|
|
|
|
2021-07-08 12:02:08 +00:00
|
|
|
import ReCAPTCHA from "react-google-recaptcha";
|
2022-04-12 10:50:01 +00:00
|
|
|
import { Colors } from "constants/Colors";
|
2021-09-07 13:12:04 +00:00
|
|
|
import _ from "lodash";
|
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 {
|
2022-05-04 09:45:57 +00:00
|
|
|
ButtonPlacement,
|
2021-09-09 15:10:22 +00:00
|
|
|
ButtonVariant,
|
2022-01-02 16:27:39 +00:00
|
|
|
RecaptchaType,
|
2021-09-09 15:10:22 +00:00
|
|
|
} from "components/constants";
|
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 { ButtonVariantTypes, RecaptchaTypes } from "components/constants";
|
2021-10-06 12:57:05 +00:00
|
|
|
import {
|
|
|
|
|
getCustomBackgroundColor,
|
|
|
|
|
getCustomBorderColor,
|
2021-12-08 13:11:13 +00:00
|
|
|
getCustomJustifyContent,
|
|
|
|
|
getAlignText,
|
2022-05-04 09:45:57 +00:00
|
|
|
getComplementaryGrayscaleColor,
|
2021-10-06 12:57:05 +00:00
|
|
|
} from "widgets/WidgetUtils";
|
2022-03-13 17:21:04 +00:00
|
|
|
import { DragContainer } from "./DragContainer";
|
|
|
|
|
import { buttonHoverActiveStyles } from "./utils";
|
2023-09-06 12:15:04 +00:00
|
|
|
import type { ThemeProp } from "WidgetProvider/constants";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { toast } from "design-system";
|
2021-08-24 13:53:15 +00:00
|
|
|
|
|
|
|
|
const RecaptchaWrapper = styled.div`
|
|
|
|
|
position: relative;
|
|
|
|
|
.grecaptcha-badge {
|
|
|
|
|
visibility: hidden;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2021-08-17 11:26:05 +00:00
|
|
|
const ToolTipWrapper = styled.div`
|
|
|
|
|
height: 100%;
|
2021-11-03 03:54:19 +00:00
|
|
|
&& .bp3-popover2-target {
|
2021-08-17 11:26:05 +00:00
|
|
|
height: 100%;
|
2021-11-03 03:54:19 +00:00
|
|
|
width: 100%;
|
2021-08-17 11:26:05 +00:00
|
|
|
& > div {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2021-11-03 03:54:19 +00:00
|
|
|
const TooltipStyles = createGlobalStyle`
|
|
|
|
|
.btnTooltipContainer {
|
|
|
|
|
.bp3-popover2-content {
|
|
|
|
|
max-width: 350px;
|
|
|
|
|
overflow-wrap: anywhere;
|
|
|
|
|
padding: 10px 12px;
|
|
|
|
|
border-radius: 0px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2022-03-30 09:51:07 +00:00
|
|
|
const buttonBaseStyle = css<ThemeProp & ButtonStyleProps>`
|
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
|
|
|
height: 100%;
|
|
|
|
|
background-image: none !important;
|
|
|
|
|
font-weight: ${(props) => props.theme.fontWeights[2]};
|
|
|
|
|
outline: none;
|
|
|
|
|
padding: 0px 10px;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
|
&:active,
|
|
|
|
|
&:focus {
|
|
|
|
|
${buttonHoverActiveStyles}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
${({ buttonColor, buttonVariant, theme }) => `
|
2022-05-04 09:45:57 +00:00
|
|
|
background: ${
|
|
|
|
|
getCustomBackgroundColor(buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? getCustomBackgroundColor(buttonVariant, buttonColor)
|
|
|
|
|
: buttonVariant === ButtonVariantTypes.PRIMARY
|
2024-04-22 09:17:28 +00:00
|
|
|
? theme.colors.button.primary.primary.bgColor
|
|
|
|
|
: "none"
|
2022-05-04 09:45:57 +00:00
|
|
|
} !important;
|
2022-03-13 17:21:04 +00:00
|
|
|
|
2021-08-24 13:53:15 +00:00
|
|
|
|
2022-03-30 09:51:07 +00:00
|
|
|
&:disabled, &.${Classes.DISABLED} {
|
2022-05-04 09:45:57 +00:00
|
|
|
cursor: not-allowed;
|
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
|
|
|
background-color: ${
|
|
|
|
|
buttonVariant !== ButtonVariantTypes.TERTIARY &&
|
|
|
|
|
"var(--wds-color-bg-disabled)"
|
|
|
|
|
} !important;
|
2022-09-30 11:24:21 +00:00
|
|
|
color: var(--wds-color-text-disabled) !important;
|
2022-05-04 09:45:57 +00:00
|
|
|
box-shadow: none !important;
|
|
|
|
|
pointer-events: none;
|
2022-09-30 11:24:21 +00:00
|
|
|
border-color: var(--wds-color-border-disabled) !important;
|
2022-05-04 09:45:57 +00:00
|
|
|
|
|
|
|
|
> span {
|
2022-09-30 11:24:21 +00:00
|
|
|
color: var(--wds-color-text-disabled) !important;
|
2021-08-24 13:53:15 +00:00
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
}
|
2021-08-24 13:53:15 +00:00
|
|
|
|
2022-05-04 09:45:57 +00:00
|
|
|
border: ${
|
|
|
|
|
getCustomBorderColor(buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? `1px solid ${getCustomBorderColor(buttonVariant, buttonColor)}`
|
|
|
|
|
: buttonVariant === ButtonVariantTypes.SECONDARY
|
2024-04-22 09:17:28 +00:00
|
|
|
? `1px solid ${theme.colors.button.primary.secondary.borderColor}`
|
|
|
|
|
: "none"
|
2022-05-04 09:45:57 +00:00
|
|
|
} !important;
|
|
|
|
|
|
|
|
|
|
& > * {
|
|
|
|
|
margin-right: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& > span {
|
2023-04-07 13:51:35 +00:00
|
|
|
display: inline-block;
|
2022-05-04 09:45:57 +00:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
overflow: hidden;
|
2023-04-07 13:51:35 +00:00
|
|
|
white-space: nowrap;
|
2022-05-04 09:45:57 +00:00
|
|
|
line-height: normal;
|
|
|
|
|
|
|
|
|
|
color: ${
|
|
|
|
|
buttonVariant === ButtonVariantTypes.PRIMARY
|
|
|
|
|
? getComplementaryGrayscaleColor(buttonColor)
|
|
|
|
|
: getCustomBackgroundColor(ButtonVariantTypes.PRIMARY, buttonColor)
|
2021-08-24 13:53:15 +00:00
|
|
|
} !important;
|
2022-05-04 09:45:57 +00:00
|
|
|
}
|
|
|
|
|
`}
|
2021-08-24 13:53:15 +00:00
|
|
|
|
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
|
|
|
border-radius: ${({ borderRadius }) => borderRadius};
|
|
|
|
|
box-shadow: ${({ boxShadow }) => `${boxShadow ?? "none"}`} !important;
|
2022-05-04 09:45:57 +00:00
|
|
|
|
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
|
|
|
${({ placement }) =>
|
|
|
|
|
placement
|
|
|
|
|
? `
|
2022-05-04 09:45:57 +00:00
|
|
|
justify-content: ${getCustomJustifyContent(placement)};
|
|
|
|
|
& > span.bp3-button-text {
|
|
|
|
|
flex: unset !important;
|
2019-10-21 15:12:45 +00:00
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
`
|
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
|
|
|
: ""}
|
2021-08-24 13:53:15 +00:00
|
|
|
`;
|
2019-10-21 15:12:45 +00:00
|
|
|
|
2022-05-04 09:45:57 +00:00
|
|
|
export const StyledButton = styled((props) => (
|
2022-03-30 09:51:07 +00:00
|
|
|
<Button
|
|
|
|
|
{..._.omit(props, [
|
|
|
|
|
"borderRadius",
|
|
|
|
|
"boxShadow",
|
|
|
|
|
"boxShadowColor",
|
|
|
|
|
"buttonColor",
|
|
|
|
|
"buttonVariant",
|
|
|
|
|
])}
|
|
|
|
|
/>
|
|
|
|
|
))<ThemeProp & ButtonStyleProps>`
|
|
|
|
|
${buttonBaseStyle}
|
|
|
|
|
`;
|
|
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
export interface ButtonStyleProps {
|
2021-08-24 13:53:15 +00:00
|
|
|
buttonColor?: string;
|
|
|
|
|
buttonVariant?: ButtonVariant;
|
2022-05-04 09:45:57 +00:00
|
|
|
boxShadow?: string;
|
2021-08-24 13:53:15 +00:00
|
|
|
boxShadowColor?: string;
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
2021-08-24 13:53:15 +00:00
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
2023-07-04 14:12:00 +00:00
|
|
|
shouldFitContent?: boolean;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2023-07-04 14:12:00 +00:00
|
|
|
maxWidth?: number;
|
|
|
|
|
minWidth?: number;
|
|
|
|
|
minHeight?: number;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2019-10-21 15:12:45 +00:00
|
|
|
|
|
|
|
|
// To be used in any other part of the app
|
2021-04-28 10:28:39 +00:00
|
|
|
export function BaseButton(props: IButtonProps & ButtonStyleProps) {
|
2021-08-24 13:53:15 +00:00
|
|
|
const {
|
|
|
|
|
borderRadius,
|
|
|
|
|
boxShadow,
|
|
|
|
|
boxShadowColor,
|
|
|
|
|
buttonColor,
|
|
|
|
|
buttonVariant,
|
|
|
|
|
className,
|
|
|
|
|
disabled,
|
|
|
|
|
icon,
|
|
|
|
|
iconAlign,
|
|
|
|
|
iconName,
|
|
|
|
|
loading,
|
2023-07-04 14:12:00 +00:00
|
|
|
maxWidth,
|
|
|
|
|
minHeight,
|
|
|
|
|
minWidth,
|
2021-08-24 13:53:15 +00:00
|
|
|
onClick,
|
2021-12-08 13:11:13 +00:00
|
|
|
placement,
|
2021-08-24 13:53:15 +00:00
|
|
|
rightIcon,
|
|
|
|
|
text,
|
|
|
|
|
} = props;
|
|
|
|
|
|
2021-12-08 13:11:13 +00:00
|
|
|
const isRightAlign = iconAlign === Alignment.RIGHT;
|
2021-08-24 13:53:15 +00:00
|
|
|
|
|
|
|
|
return (
|
2022-03-13 17:21:04 +00:00
|
|
|
<DragContainer
|
2021-08-24 13:53:15 +00:00
|
|
|
buttonColor={buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
loading={loading}
|
2023-07-04 14:12:00 +00:00
|
|
|
maxWidth={maxWidth}
|
|
|
|
|
minHeight={minHeight}
|
|
|
|
|
minWidth={minWidth}
|
2021-08-24 13:53:15 +00:00
|
|
|
onClick={onClick}
|
2023-07-04 14:12:00 +00:00
|
|
|
shouldFitContent={props.shouldFitContent}
|
2022-04-04 07:13:04 +00:00
|
|
|
showInAllModes
|
2022-03-13 17:21:04 +00:00
|
|
|
>
|
2022-04-04 07:13:04 +00:00
|
|
|
<StyledButton
|
|
|
|
|
alignText={getAlignText(isRightAlign, iconName)}
|
|
|
|
|
borderRadius={borderRadius}
|
|
|
|
|
boxShadow={boxShadow}
|
|
|
|
|
boxShadowColor={boxShadowColor}
|
|
|
|
|
buttonColor={buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
|
|
|
|
className={className}
|
|
|
|
|
data-test-variant={buttonVariant}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
fill
|
|
|
|
|
icon={isRightAlign ? icon : iconName || icon}
|
|
|
|
|
loading={loading}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
placement={placement}
|
|
|
|
|
rightIcon={isRightAlign ? iconName || rightIcon : rightIcon}
|
|
|
|
|
text={text}
|
|
|
|
|
/>
|
2022-03-13 17:21:04 +00:00
|
|
|
</DragContainer>
|
2021-08-24 13:53:15 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-10-21 15:12:45 +00:00
|
|
|
|
|
|
|
|
BaseButton.defaultProps = {
|
2021-09-23 15:14:24 +00:00
|
|
|
buttonColor: Colors.GREEN,
|
2021-10-12 08:04:51 +00:00
|
|
|
buttonVariant: ButtonVariantTypes.PRIMARY,
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
disabled: false,
|
2019-10-21 15:12:45 +00:00
|
|
|
text: "Button Text",
|
|
|
|
|
minimal: true,
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-06 09:45:21 +00:00
|
|
|
export enum ButtonType {
|
|
|
|
|
SUBMIT = "submit",
|
|
|
|
|
RESET = "reset",
|
|
|
|
|
BUTTON = "button",
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 13:01:19 +00:00
|
|
|
interface RecaptchaProps {
|
|
|
|
|
googleRecaptchaKey?: string;
|
|
|
|
|
clickWithRecaptcha: (token: string) => void;
|
2021-08-03 13:36:03 +00:00
|
|
|
handleRecaptchaV2Loading?: (isLoading: boolean) => void;
|
2022-01-02 16:27:39 +00:00
|
|
|
recaptchaType?: RecaptchaType;
|
2020-10-12 13:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 13:53:15 +00:00
|
|
|
interface ButtonComponentProps extends ComponentProps {
|
2020-01-03 13:40:31 +00:00
|
|
|
text?: string;
|
2021-08-24 13:53:15 +00:00
|
|
|
icon?: IconName | MaybeElement;
|
2021-08-17 11:26:05 +00:00
|
|
|
tooltip?: string;
|
2019-10-21 15:12:45 +00:00
|
|
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
2021-08-24 13:53:15 +00:00
|
|
|
isDisabled?: boolean;
|
2019-12-03 04:41:10 +00:00
|
|
|
isLoading: boolean;
|
2023-07-04 14:12:00 +00:00
|
|
|
shouldFitContent: boolean;
|
2020-02-12 08:23:50 +00:00
|
|
|
rightIcon?: IconName | MaybeElement;
|
2020-03-06 09:45:21 +00:00
|
|
|
type: ButtonType;
|
2021-08-24 13:53:15 +00:00
|
|
|
buttonColor?: string;
|
|
|
|
|
buttonVariant?: ButtonVariant;
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
|
|
|
|
boxShadow?: string;
|
2021-08-24 13:53:15 +00:00
|
|
|
boxShadowColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2022-07-14 07:02:35 +00:00
|
|
|
className?: string;
|
2023-07-04 14:12:00 +00:00
|
|
|
minWidth?: number;
|
|
|
|
|
minHeight?: number;
|
|
|
|
|
maxWidth?: number;
|
2019-10-21 15:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
interface RecaptchaV2ComponentPropType {
|
2022-07-14 07:02:35 +00:00
|
|
|
children: any;
|
|
|
|
|
className?: string;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
recaptchaType?: RecaptchaType;
|
|
|
|
|
isLoading: boolean;
|
|
|
|
|
handleError: (event: React.MouseEvent<HTMLElement>, error: string) => void;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2022-07-14 07:02:35 +00:00
|
|
|
|
2021-07-08 12:02:08 +00:00
|
|
|
function RecaptchaV2Component(
|
2022-07-14 07:02:35 +00:00
|
|
|
props: RecaptchaV2ComponentPropType & RecaptchaProps,
|
2021-04-28 10:28:39 +00:00
|
|
|
) {
|
2021-07-08 12:02:08 +00:00
|
|
|
const recaptchaRef = useRef<ReCAPTCHA>(null);
|
|
|
|
|
const [isInvalidKey, setInvalidKey] = useState(false);
|
2021-08-03 13:36:03 +00:00
|
|
|
const handleRecaptchaLoading = (isloading: boolean) => {
|
|
|
|
|
props.handleRecaptchaV2Loading && props.handleRecaptchaV2Loading(isloading);
|
|
|
|
|
};
|
2021-07-08 12:02:08 +00:00
|
|
|
const handleBtnClick = async (event: React.MouseEvent<HTMLElement>) => {
|
2022-03-22 06:52:39 +00:00
|
|
|
if (props.isDisabled) return;
|
2022-05-03 05:25:31 +00:00
|
|
|
if (props.isLoading) return;
|
2021-07-08 12:02:08 +00:00
|
|
|
if (isInvalidKey) {
|
|
|
|
|
// Handle incorrent google recaptcha site key
|
|
|
|
|
props.handleError(event, createMessage(GOOGLE_RECAPTCHA_KEY_ERROR));
|
|
|
|
|
} else {
|
2021-08-03 13:36:03 +00:00
|
|
|
handleRecaptchaLoading(true);
|
2021-07-08 12:02:08 +00:00
|
|
|
try {
|
2021-08-03 13:36:03 +00:00
|
|
|
await recaptchaRef?.current?.reset();
|
2021-07-08 12:02:08 +00:00
|
|
|
const token = await recaptchaRef?.current?.executeAsync();
|
|
|
|
|
if (token) {
|
|
|
|
|
props.clickWithRecaptcha(token);
|
|
|
|
|
} else {
|
|
|
|
|
// Handle incorrent google recaptcha site key
|
|
|
|
|
props.handleError(event, createMessage(GOOGLE_RECAPTCHA_KEY_ERROR));
|
|
|
|
|
}
|
2021-08-03 13:36:03 +00:00
|
|
|
handleRecaptchaLoading(false);
|
2021-07-08 12:02:08 +00:00
|
|
|
} catch (err) {
|
2021-08-03 13:36:03 +00:00
|
|
|
handleRecaptchaLoading(false);
|
2021-07-08 12:02:08 +00:00
|
|
|
// Handle error due to google recaptcha key of different domain
|
|
|
|
|
props.handleError(event, createMessage(GOOGLE_RECAPTCHA_DOMAIN_ERROR));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return (
|
2022-07-14 07:02:35 +00:00
|
|
|
<RecaptchaWrapper className={props.className} onClick={handleBtnClick}>
|
2021-07-08 12:02:08 +00:00
|
|
|
{props.children}
|
|
|
|
|
<ReCAPTCHA
|
|
|
|
|
onErrored={() => setInvalidKey(true)}
|
|
|
|
|
ref={recaptchaRef}
|
|
|
|
|
sitekey={props.googleRecaptchaKey || ""}
|
|
|
|
|
size="invisible"
|
|
|
|
|
/>
|
|
|
|
|
</RecaptchaWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-05-20 19:28:02 +00:00
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
interface RecaptchaV3ComponentPropType {
|
2022-07-14 07:02:35 +00:00
|
|
|
children: any;
|
|
|
|
|
className?: string;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
recaptchaType?: RecaptchaType;
|
|
|
|
|
isLoading: boolean;
|
|
|
|
|
handleError: (event: React.MouseEvent<HTMLElement>, error: string) => void;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2022-07-14 07:02:35 +00:00
|
|
|
|
2021-07-08 12:02:08 +00:00
|
|
|
function RecaptchaV3Component(
|
2022-07-14 07:02:35 +00:00
|
|
|
props: RecaptchaV3ComponentPropType & RecaptchaProps,
|
2021-07-08 12:02:08 +00:00
|
|
|
) {
|
2021-05-20 19:28:02 +00:00
|
|
|
// Check if a string is a valid JSON string
|
|
|
|
|
const checkValidJson = (inputString: string): boolean => {
|
2021-08-09 12:18:58 +00:00
|
|
|
return !inputString.includes('"');
|
2021-05-20 19:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
2021-07-08 12:02:08 +00:00
|
|
|
const handleBtnClick = (event: React.MouseEvent<HTMLElement>) => {
|
2022-03-22 06:52:39 +00:00
|
|
|
if (props.isDisabled) return;
|
2022-05-03 05:25:31 +00:00
|
|
|
if (props.isLoading) return;
|
2021-07-08 12:02:08 +00:00
|
|
|
if (status === ScriptStatus.READY) {
|
|
|
|
|
(window as any).grecaptcha.ready(() => {
|
|
|
|
|
try {
|
|
|
|
|
(window as any).grecaptcha
|
|
|
|
|
.execute(props.googleRecaptchaKey, {
|
|
|
|
|
action: "submit",
|
|
|
|
|
})
|
|
|
|
|
.then((token: any) => {
|
|
|
|
|
props.clickWithRecaptcha(token);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
// Handle incorrent google recaptcha site key
|
|
|
|
|
props.handleError(
|
|
|
|
|
event,
|
|
|
|
|
createMessage(GOOGLE_RECAPTCHA_KEY_ERROR),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// Handle error due to google recaptcha key of different domain
|
|
|
|
|
props.handleError(
|
|
|
|
|
event,
|
|
|
|
|
createMessage(GOOGLE_RECAPTCHA_DOMAIN_ERROR),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-20 19:28:02 +00:00
|
|
|
let validGoogleRecaptchaKey = props.googleRecaptchaKey;
|
2021-08-09 12:18:58 +00:00
|
|
|
if (validGoogleRecaptchaKey && !checkValidJson(validGoogleRecaptchaKey)) {
|
2021-05-20 19:28:02 +00:00
|
|
|
validGoogleRecaptchaKey = undefined;
|
|
|
|
|
}
|
2020-10-12 13:01:19 +00:00
|
|
|
const status = useScript(
|
2021-05-20 19:28:02 +00:00
|
|
|
`https://www.google.com/recaptcha/api.js?render=${validGoogleRecaptchaKey}`,
|
2022-01-31 15:55:58 +00:00
|
|
|
AddScriptTo.HEAD,
|
2020-10-12 13:01:19 +00:00
|
|
|
);
|
2022-07-14 07:02:35 +00:00
|
|
|
return (
|
|
|
|
|
<div className={props.className} onClick={handleBtnClick}>
|
|
|
|
|
{props.children}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2020-10-12 13:01:19 +00:00
|
|
|
|
2023-02-03 05:47:40 +00:00
|
|
|
const Wrapper = styled.div`
|
|
|
|
|
height: 100%;
|
|
|
|
|
`;
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function BtnWrapper(
|
2020-10-12 13:01:19 +00:00
|
|
|
props: {
|
|
|
|
|
children: any;
|
2022-07-14 07:02:35 +00:00
|
|
|
className?: string;
|
2022-03-22 06:52:39 +00:00
|
|
|
isDisabled?: boolean;
|
2022-05-03 05:25:31 +00:00
|
|
|
isLoading: boolean;
|
2020-10-12 13:01:19 +00:00
|
|
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
|
|
|
} & RecaptchaProps,
|
2021-04-28 10:28:39 +00:00
|
|
|
) {
|
2023-04-14 13:55:44 +00:00
|
|
|
const hasOnClick = Boolean(
|
|
|
|
|
props.onClick && !props.isLoading && !props.isDisabled,
|
|
|
|
|
);
|
2022-05-03 05:25:31 +00:00
|
|
|
if (!props.googleRecaptchaKey) {
|
|
|
|
|
return (
|
2023-02-03 05:47:40 +00:00
|
|
|
<Wrapper
|
2022-07-14 07:02:35 +00:00
|
|
|
className={props.className}
|
2023-04-14 13:55:44 +00:00
|
|
|
onClick={hasOnClick ? props.onClick : undefined}
|
2022-05-03 05:25:31 +00:00
|
|
|
>
|
|
|
|
|
{props.children}
|
2023-02-03 05:47:40 +00:00
|
|
|
</Wrapper>
|
2022-05-03 05:25:31 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
2021-07-08 12:02:08 +00:00
|
|
|
const handleError = (
|
|
|
|
|
event: React.MouseEvent<HTMLElement>,
|
|
|
|
|
error: string,
|
|
|
|
|
) => {
|
2023-05-19 18:37:06 +00:00
|
|
|
toast.show(error, {
|
|
|
|
|
kind: "error",
|
2021-07-08 12:02:08 +00:00
|
|
|
});
|
2022-05-03 05:25:31 +00:00
|
|
|
props.onClick && !props.isLoading && props.onClick(event);
|
2021-07-08 12:02:08 +00:00
|
|
|
};
|
2022-01-02 16:27:39 +00:00
|
|
|
if (props.recaptchaType === RecaptchaTypes.V2) {
|
2021-07-08 12:02:08 +00:00
|
|
|
return <RecaptchaV2Component {...props} handleError={handleError} />;
|
|
|
|
|
} else {
|
|
|
|
|
return <RecaptchaV3Component {...props} handleError={handleError} />;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2020-10-12 13:01:19 +00:00
|
|
|
|
2019-10-21 15:12:45 +00:00
|
|
|
// To be used with the canvas
|
2021-08-24 13:53:15 +00:00
|
|
|
function ButtonComponent(props: ButtonComponentProps & RecaptchaProps) {
|
2021-08-17 11:26:05 +00:00
|
|
|
const btnWrapper = (
|
2020-10-12 13:01:19 +00:00
|
|
|
<BtnWrapper
|
2022-07-14 07:02:35 +00:00
|
|
|
className={props.className}
|
2020-10-12 13:01:19 +00:00
|
|
|
clickWithRecaptcha={props.clickWithRecaptcha}
|
2021-04-28 10:28:39 +00:00
|
|
|
googleRecaptchaKey={props.googleRecaptchaKey}
|
2021-08-03 13:36:03 +00:00
|
|
|
handleRecaptchaV2Loading={props.handleRecaptchaV2Loading}
|
2022-03-22 06:52:39 +00:00
|
|
|
isDisabled={props.isDisabled}
|
2022-05-03 05:25:31 +00:00
|
|
|
isLoading={props.isLoading}
|
2019-11-13 07:00:25 +00:00
|
|
|
onClick={props.onClick}
|
2022-01-02 16:27:39 +00:00
|
|
|
recaptchaType={props.recaptchaType}
|
2020-10-12 13:01:19 +00:00
|
|
|
>
|
2022-03-13 17:21:04 +00:00
|
|
|
<BaseButton
|
|
|
|
|
borderRadius={props.borderRadius}
|
|
|
|
|
boxShadow={props.boxShadow}
|
|
|
|
|
boxShadowColor={props.boxShadowColor}
|
|
|
|
|
buttonColor={props.buttonColor}
|
|
|
|
|
buttonVariant={props.buttonVariant}
|
|
|
|
|
disabled={props.isDisabled}
|
|
|
|
|
icon={props.icon}
|
|
|
|
|
iconAlign={props.iconAlign}
|
|
|
|
|
iconName={props.iconName}
|
|
|
|
|
loading={props.isLoading}
|
2023-07-04 14:12:00 +00:00
|
|
|
maxWidth={props.maxWidth}
|
|
|
|
|
minHeight={props.minHeight}
|
|
|
|
|
minWidth={props.minWidth}
|
2022-03-13 17:21:04 +00:00
|
|
|
placement={props.placement}
|
|
|
|
|
rightIcon={props.rightIcon}
|
2023-07-04 14:12:00 +00:00
|
|
|
shouldFitContent={props.shouldFitContent}
|
2022-03-13 17:21:04 +00:00
|
|
|
text={props.text}
|
|
|
|
|
type={props.type}
|
|
|
|
|
/>
|
2020-10-12 13:01:19 +00:00
|
|
|
</BtnWrapper>
|
2019-10-21 15:12:45 +00:00
|
|
|
);
|
2021-08-17 11:26:05 +00:00
|
|
|
if (props.tooltip) {
|
|
|
|
|
return (
|
|
|
|
|
<ToolTipWrapper>
|
2021-11-03 03:54:19 +00:00
|
|
|
<TooltipStyles />
|
|
|
|
|
<Popover2
|
|
|
|
|
autoFocus={false}
|
|
|
|
|
content={<Interweave content={props.tooltip} />}
|
2021-08-17 11:26:05 +00:00
|
|
|
hoverOpenDelay={200}
|
2021-11-03 03:54:19 +00:00
|
|
|
interactionKind="hover"
|
|
|
|
|
portalClassName="btnTooltipContainer"
|
2021-08-17 11:26:05 +00:00
|
|
|
position={Position.TOP}
|
|
|
|
|
>
|
|
|
|
|
{btnWrapper}
|
2021-11-03 03:54:19 +00:00
|
|
|
</Popover2>
|
2021-08-17 11:26:05 +00:00
|
|
|
</ToolTipWrapper>
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return btnWrapper;
|
|
|
|
|
}
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-10-21 15:12:45 +00:00
|
|
|
|
2021-08-24 13:53:15 +00:00
|
|
|
export default ButtonComponent;
|