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 {
|
2023-02-03 05:47:40 +00:00
|
|
|
MouseEventHandler,
|
|
|
|
|
PropsWithChildren,
|
|
|
|
|
ReactNode,
|
|
|
|
|
RefObject,
|
|
|
|
|
} 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 React, { useCallback, useEffect, useRef } from "react";
|
2023-02-03 05:47:40 +00:00
|
|
|
import styled from "styled-components";
|
2023-02-14 16:07:31 +00:00
|
|
|
import tinycolor from "tinycolor2";
|
|
|
|
|
import fastdom from "fastdom";
|
2020-03-27 09:02:11 +00:00
|
|
|
import { generateClassName, getCanvasClassName } from "utils/generators";
|
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 { WidgetStyleContainerProps } from "components/designSystems/appsmith/WidgetStyleContainer";
|
|
|
|
|
import WidgetStyleContainer from "components/designSystems/appsmith/WidgetStyleContainer";
|
|
|
|
|
import type { WidgetType } from "utils/WidgetFactory";
|
2023-02-03 05:47:40 +00:00
|
|
|
import { scrollCSS } from "widgets/WidgetUtils";
|
2023-04-07 13:51:35 +00:00
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
import { getCurrentAppPositioningType } from "selectors/editorSelectors";
|
|
|
|
|
import { AppPositioningTypes } from "reducers/entityReducers/pageListReducer";
|
|
|
|
|
import { MAIN_CONTAINER_WIDGET_ID } from "constants/WidgetConstants";
|
2020-03-27 09:02:11 +00:00
|
|
|
|
|
|
|
|
const StyledContainerComponent = styled.div<
|
2023-02-03 05:47:40 +00:00
|
|
|
Omit<ContainerWrapperProps, "widgetId">
|
2020-03-27 09:02:11 +00:00
|
|
|
>`
|
2019-10-01 20:07:43 +00:00
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
2023-02-03 05:47:40 +00:00
|
|
|
overflow: hidden;
|
2023-05-19 18:37:06 +00:00
|
|
|
outline: none;
|
feat: Non auto height invisible widgets (#20118)
## Description
This PR adds another feature update we had planned for Auto Height
- [ ] For new applications, in View and Preview mode, any widget which
is invisible will let go of its space and collapse if it's either on the
main Canvas or a container-like widget which has Auto-height enabled.
- [ ] Widgets within a container-like Widget, say Tabs, that doesn't
have Auto-height enabled, will now let go of their space if they're
invisible.
- [ ] The experience in Edit mode has not changed.
TL;DR: In new applications, in the Preview and Published _AKA_ View
modes, if a widget is invisible and within an Auto-height-enabled
container like a Tab, a Modal, a Form, or the main Canvas, it will fully
collapse, allowing widgets below it to move up and take its space. This
changes the behavior today prior to the release of this PR for
Auto-height-enabled widgets.
Fixes #19983
Fixes #18681
2023-02-14 13:36:19 +00:00
|
|
|
${(props) => (!!props.dropDisabled ? `position: relative;` : ``)}
|
2023-03-04 07:25:54 +00:00
|
|
|
|
2023-02-24 07:52:53 +00:00
|
|
|
${(props) =>
|
|
|
|
|
props.shouldScrollContents && !props.$noScroll ? scrollCSS : ``}
|
2021-05-27 06:41:38 +00:00
|
|
|
opacity: ${(props) => (props.resizeDisabled ? "0.8" : "1")};
|
|
|
|
|
|
2023-02-03 05:47:40 +00:00
|
|
|
background: ${(props) => props.backgroundColor};
|
2021-05-27 06:41:38 +00:00
|
|
|
&:hover {
|
2023-02-03 05:47:40 +00:00
|
|
|
background-color: ${(props) => {
|
2021-06-18 07:42:57 +00:00
|
|
|
return props.onClickCapture && props.backgroundColor
|
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
|
|
|
? tinycolor(props.backgroundColor).darken(5).toString()
|
2021-06-18 07:42:57 +00:00
|
|
|
: props.backgroundColor;
|
|
|
|
|
}};
|
2023-02-03 05:47:40 +00:00
|
|
|
z-index: ${(props) => (props.onClickCapture ? "2" : "1")};
|
|
|
|
|
cursor: ${(props) => (props.onClickCapture ? "pointer" : "inherit")};
|
2021-05-27 06:41:38 +00:00
|
|
|
}
|
2022-06-23 17:55:03 +00:00
|
|
|
`;
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
|
2023-02-03 05:47:40 +00:00
|
|
|
interface ContainerWrapperProps {
|
2023-02-14 16:07:31 +00:00
|
|
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
2023-02-03 05:47:40 +00:00
|
|
|
onClickCapture?: MouseEventHandler<HTMLDivElement>;
|
|
|
|
|
resizeDisabled?: boolean;
|
|
|
|
|
shouldScrollContents?: boolean;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
widgetId: string;
|
|
|
|
|
type: WidgetType;
|
feat: Non auto height invisible widgets (#20118)
## Description
This PR adds another feature update we had planned for Auto Height
- [ ] For new applications, in View and Preview mode, any widget which
is invisible will let go of its space and collapse if it's either on the
main Canvas or a container-like widget which has Auto-height enabled.
- [ ] Widgets within a container-like Widget, say Tabs, that doesn't
have Auto-height enabled, will now let go of their space if they're
invisible.
- [ ] The experience in Edit mode has not changed.
TL;DR: In new applications, in the Preview and Published _AKA_ View
modes, if a widget is invisible and within an Auto-height-enabled
container like a Tab, a Modal, a Form, or the main Canvas, it will fully
collapse, allowing widgets below it to move up and take its space. This
changes the behavior today prior to the release of this PR for
Auto-height-enabled widgets.
Fixes #19983
Fixes #18681
2023-02-14 13:36:19 +00:00
|
|
|
dropDisabled?: boolean;
|
2023-02-24 07:52:53 +00:00
|
|
|
$noScroll: boolean;
|
2023-02-03 05:47:40 +00:00
|
|
|
}
|
|
|
|
|
function ContainerComponentWrapper(
|
|
|
|
|
props: PropsWithChildren<ContainerWrapperProps>,
|
|
|
|
|
) {
|
2020-03-27 09:02:11 +00:00
|
|
|
const containerRef: RefObject<HTMLDivElement> = useRef<HTMLDivElement>(null);
|
2023-04-07 13:51:35 +00:00
|
|
|
const appPositioningType = useSelector(getCurrentAppPositioningType);
|
2023-02-14 16:07:31 +00:00
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (!props.shouldScrollContents) {
|
2021-01-07 05:06:25 +00:00
|
|
|
const supportsNativeSmoothScroll =
|
|
|
|
|
"scrollBehavior" in document.documentElement.style;
|
2023-02-14 16:07:31 +00:00
|
|
|
|
|
|
|
|
fastdom.mutate(() => {
|
|
|
|
|
if (supportsNativeSmoothScroll) {
|
|
|
|
|
containerRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
|
|
|
|
} else {
|
|
|
|
|
if (containerRef.current) {
|
|
|
|
|
containerRef.current.scrollTop = 0;
|
|
|
|
|
}
|
2021-01-07 05:06:25 +00:00
|
|
|
}
|
2023-02-14 16:07:31 +00:00
|
|
|
});
|
2020-03-27 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
}, [props.shouldScrollContents]);
|
2023-02-14 16:07:31 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is for all the container widgets that have the onClickCapture method.
|
|
|
|
|
* The mouse over event makes sure to add the class `hover-styles` so that a
|
|
|
|
|
* darker shade of the background color takes effect to induce the hover effect.
|
|
|
|
|
*
|
|
|
|
|
* Why not use the :hover css selector?
|
|
|
|
|
* For cases like List widget, it can have inner list widgets; so there can be
|
|
|
|
|
* containers inside containers. When the inner container is hovered, the parent container's
|
|
|
|
|
* :hover selector is also triggered making the outer and inner container both having this
|
|
|
|
|
* hover effect.
|
|
|
|
|
*/
|
|
|
|
|
const onMouseOver = useCallback(
|
|
|
|
|
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
|
|
const el = e.currentTarget;
|
|
|
|
|
const widgetType = el.getAttribute("type");
|
|
|
|
|
const widgetId = el.dataset.widgetid;
|
|
|
|
|
const isMainContainer = widgetId === "0";
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
(widgetType === "CONTAINER_WIDGET" && props.onClickCapture) ||
|
|
|
|
|
isMainContainer
|
|
|
|
|
) {
|
|
|
|
|
const elementsHovered = document.getElementsByClassName(
|
|
|
|
|
"hover-styles",
|
|
|
|
|
) as HTMLCollectionOf<HTMLDivElement>;
|
|
|
|
|
|
|
|
|
|
fastdom.mutate(() => {
|
|
|
|
|
for (const elHovered of elementsHovered) {
|
|
|
|
|
elHovered.classList.remove("hover-styles");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isMainContainer) {
|
|
|
|
|
el.classList.add("hover-styles");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
[props.onClickCapture],
|
|
|
|
|
);
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
return (
|
2021-09-16 16:54:12 +00:00
|
|
|
<StyledContainerComponent
|
2022-12-30 14:52:11 +00:00
|
|
|
// Before you remove: generateClassName is used for bounding the resizables within this canvas
|
|
|
|
|
// getCanvasClassName is used to add a scrollable parent.
|
2023-02-24 07:52:53 +00:00
|
|
|
$noScroll={props.$noScroll}
|
2023-02-03 05:47:40 +00:00
|
|
|
backgroundColor={props.backgroundColor}
|
2021-09-16 16:54:12 +00:00
|
|
|
className={`${
|
|
|
|
|
props.shouldScrollContents ? getCanvasClassName() : ""
|
2023-04-07 13:51:35 +00:00
|
|
|
} ${generateClassName(props.widgetId)} container-with-scrollbar ${
|
|
|
|
|
appPositioningType === AppPositioningTypes.AUTO &&
|
|
|
|
|
props.widgetId === MAIN_CONTAINER_WIDGET_ID
|
|
|
|
|
? "auto-layout"
|
|
|
|
|
: ""
|
|
|
|
|
}`}
|
2023-02-14 16:07:31 +00:00
|
|
|
data-widgetId={props.widgetId}
|
feat: Non auto height invisible widgets (#20118)
## Description
This PR adds another feature update we had planned for Auto Height
- [ ] For new applications, in View and Preview mode, any widget which
is invisible will let go of its space and collapse if it's either on the
main Canvas or a container-like widget which has Auto-height enabled.
- [ ] Widgets within a container-like Widget, say Tabs, that doesn't
have Auto-height enabled, will now let go of their space if they're
invisible.
- [ ] The experience in Edit mode has not changed.
TL;DR: In new applications, in the Preview and Published _AKA_ View
modes, if a widget is invisible and within an Auto-height-enabled
container like a Tab, a Modal, a Form, or the main Canvas, it will fully
collapse, allowing widgets below it to move up and take its space. This
changes the behavior today prior to the release of this PR for
Auto-height-enabled widgets.
Fixes #19983
Fixes #18681
2023-02-14 13:36:19 +00:00
|
|
|
dropDisabled={props.dropDisabled}
|
2023-02-14 16:07:31 +00:00
|
|
|
onClick={props.onClick}
|
2023-02-03 05:47:40 +00:00
|
|
|
onClickCapture={props.onClickCapture}
|
2023-02-14 16:07:31 +00:00
|
|
|
onMouseOver={onMouseOver}
|
2021-09-16 16:54:12 +00:00
|
|
|
ref={containerRef}
|
2023-02-03 05:47:40 +00:00
|
|
|
resizeDisabled={props.resizeDisabled}
|
|
|
|
|
shouldScrollContents={!!props.shouldScrollContents}
|
2022-12-30 14:52:11 +00:00
|
|
|
tabIndex={props.shouldScrollContents ? undefined : 0}
|
2023-02-03 05:47:40 +00:00
|
|
|
type={props.type}
|
2021-09-16 16:54:12 +00:00
|
|
|
>
|
|
|
|
|
{props.children}
|
|
|
|
|
</StyledContainerComponent>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ContainerComponent(props: ContainerComponentProps) {
|
2023-02-03 05:47:40 +00:00
|
|
|
if (props.detachFromLayout) {
|
|
|
|
|
return (
|
|
|
|
|
<ContainerComponentWrapper
|
2023-02-24 07:52:53 +00:00
|
|
|
$noScroll={!!props.noScroll}
|
feat: Non auto height invisible widgets (#20118)
## Description
This PR adds another feature update we had planned for Auto Height
- [ ] For new applications, in View and Preview mode, any widget which
is invisible will let go of its space and collapse if it's either on the
main Canvas or a container-like widget which has Auto-height enabled.
- [ ] Widgets within a container-like Widget, say Tabs, that doesn't
have Auto-height enabled, will now let go of their space if they're
invisible.
- [ ] The experience in Edit mode has not changed.
TL;DR: In new applications, in the Preview and Published _AKA_ View
modes, if a widget is invisible and within an Auto-height-enabled
container like a Tab, a Modal, a Form, or the main Canvas, it will fully
collapse, allowing widgets below it to move up and take its space. This
changes the behavior today prior to the release of this PR for
Auto-height-enabled widgets.
Fixes #19983
Fixes #18681
2023-02-14 13:36:19 +00:00
|
|
|
dropDisabled={props.dropDisabled}
|
2023-02-14 16:07:31 +00:00
|
|
|
onClick={props.onClick}
|
2023-02-03 05:47:40 +00:00
|
|
|
onClickCapture={props.onClickCapture}
|
|
|
|
|
resizeDisabled={props.resizeDisabled}
|
2023-04-26 17:39:11 +00:00
|
|
|
shouldScrollContents={
|
|
|
|
|
props.shouldScrollContents &&
|
|
|
|
|
props.appPositioningType !== AppPositioningTypes.AUTO
|
|
|
|
|
}
|
2023-02-03 05:47:40 +00:00
|
|
|
type={props.type}
|
|
|
|
|
widgetId={props.widgetId}
|
|
|
|
|
>
|
|
|
|
|
{props.children}
|
|
|
|
|
</ContainerComponentWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
2021-09-16 04:21:31 +00:00
|
|
|
<WidgetStyleContainer
|
2023-02-03 05:47:40 +00:00
|
|
|
backgroundColor={props.backgroundColor}
|
|
|
|
|
borderColor={props.borderColor}
|
|
|
|
|
borderRadius={props.borderRadius}
|
|
|
|
|
borderWidth={props.borderWidth}
|
|
|
|
|
boxShadow={props.boxShadow}
|
|
|
|
|
className="style-container"
|
|
|
|
|
containerStyle={props.containerStyle}
|
2023-02-14 16:07:31 +00:00
|
|
|
selected={props.selected}
|
2023-02-03 05:47:40 +00:00
|
|
|
widgetId={props.widgetId}
|
2020-03-27 09:02:11 +00:00
|
|
|
>
|
2023-02-03 05:47:40 +00:00
|
|
|
<ContainerComponentWrapper
|
2023-02-24 07:52:53 +00:00
|
|
|
$noScroll={!!props.noScroll}
|
2023-02-03 05:47:40 +00:00
|
|
|
backgroundColor={props.backgroundColor}
|
feat: Non auto height invisible widgets (#20118)
## Description
This PR adds another feature update we had planned for Auto Height
- [ ] For new applications, in View and Preview mode, any widget which
is invisible will let go of its space and collapse if it's either on the
main Canvas or a container-like widget which has Auto-height enabled.
- [ ] Widgets within a container-like Widget, say Tabs, that doesn't
have Auto-height enabled, will now let go of their space if they're
invisible.
- [ ] The experience in Edit mode has not changed.
TL;DR: In new applications, in the Preview and Published _AKA_ View
modes, if a widget is invisible and within an Auto-height-enabled
container like a Tab, a Modal, a Form, or the main Canvas, it will fully
collapse, allowing widgets below it to move up and take its space. This
changes the behavior today prior to the release of this PR for
Auto-height-enabled widgets.
Fixes #19983
Fixes #18681
2023-02-14 13:36:19 +00:00
|
|
|
dropDisabled={props.dropDisabled}
|
2023-02-14 16:07:31 +00:00
|
|
|
onClick={props.onClick}
|
2023-02-03 05:47:40 +00:00
|
|
|
onClickCapture={props.onClickCapture}
|
|
|
|
|
resizeDisabled={props.resizeDisabled}
|
2023-04-26 17:39:11 +00:00
|
|
|
shouldScrollContents={
|
|
|
|
|
props.shouldScrollContents &&
|
2023-05-11 04:45:14 +00:00
|
|
|
// Disable scrollbar on autolayout canvas as it meddles with canvas drag and highlight position.
|
|
|
|
|
(props.appPositioningType !== AppPositioningTypes.AUTO ||
|
|
|
|
|
// We need to allow scrollbars for list items as they don't have auto-height
|
|
|
|
|
props.isListItemContainer)
|
2023-04-26 17:39:11 +00:00
|
|
|
}
|
2023-02-03 05:47:40 +00:00
|
|
|
type={props.type}
|
|
|
|
|
widgetId={props.widgetId}
|
|
|
|
|
>
|
|
|
|
|
{props.children}
|
|
|
|
|
</ContainerComponentWrapper>
|
2021-09-16 04:21:31 +00:00
|
|
|
</WidgetStyleContainer>
|
2020-03-27 09:02:11 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-10-01 20:07:43 +00:00
|
|
|
|
2019-11-22 14:02:55 +00:00
|
|
|
export type ContainerStyle = "border" | "card" | "rounded-border" | "none";
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2023-02-03 05:47:40 +00:00
|
|
|
export interface ContainerComponentProps extends WidgetStyleContainerProps {
|
2019-11-13 07:00:25 +00:00
|
|
|
children?: ReactNode;
|
2020-03-27 09:02:11 +00:00
|
|
|
shouldScrollContents?: boolean;
|
2021-04-23 05:43:13 +00:00
|
|
|
resizeDisabled?: boolean;
|
2023-02-14 16:07:31 +00:00
|
|
|
selected?: boolean;
|
|
|
|
|
focused?: boolean;
|
2023-02-03 05:47:40 +00:00
|
|
|
detachFromLayout?: boolean;
|
2023-02-14 16:07:31 +00:00
|
|
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
2023-02-03 05:47:40 +00:00
|
|
|
onClickCapture?: MouseEventHandler<HTMLDivElement>;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
type: WidgetType;
|
|
|
|
|
noScroll?: boolean;
|
2023-03-04 07:25:54 +00:00
|
|
|
minHeight?: number;
|
|
|
|
|
useAutoLayout?: boolean;
|
|
|
|
|
direction?: string;
|
|
|
|
|
justifyContent?: string;
|
|
|
|
|
alignItems?: string;
|
feat: Non auto height invisible widgets (#20118)
## Description
This PR adds another feature update we had planned for Auto Height
- [ ] For new applications, in View and Preview mode, any widget which
is invisible will let go of its space and collapse if it's either on the
main Canvas or a container-like widget which has Auto-height enabled.
- [ ] Widgets within a container-like Widget, say Tabs, that doesn't
have Auto-height enabled, will now let go of their space if they're
invisible.
- [ ] The experience in Edit mode has not changed.
TL;DR: In new applications, in the Preview and Published _AKA_ View
modes, if a widget is invisible and within an Auto-height-enabled
container like a Tab, a Modal, a Form, or the main Canvas, it will fully
collapse, allowing widgets below it to move up and take its space. This
changes the behavior today prior to the release of this PR for
Auto-height-enabled widgets.
Fixes #19983
Fixes #18681
2023-02-14 13:36:19 +00:00
|
|
|
dropDisabled?: boolean;
|
2023-04-26 17:39:11 +00:00
|
|
|
appPositioningType?: AppPositioningTypes;
|
2023-05-11 04:45:14 +00:00
|
|
|
isListItemContainer?: boolean;
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export default ContainerComponent;
|