Skip to content

Commit

Permalink
Merge branch 'develop' into feature/backup
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaLopaeva committed Mar 2, 2022
2 parents 4b59e11 + b7b5907 commit f57cff1
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class HideFilter extends React.Component {
isDefaultMode={false}
manualY="8px"
open={popoverOpen}
fixedDirection={true}
>
{children}
</DropDown>
Expand Down
22 changes: 19 additions & 3 deletions packages/asc-web-components/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,35 @@ class Calendar extends Component {

const openToDateYear = openToDate.getFullYear();

let disabled = false;
const listMonths = [];

let i = 0;
while (i <= 11) {
listMonths.push({
key: `${i}`,
label: `${months[i]}`,
disabled: disabled,
disabled: false,
});
i++;
}

if (openToDateYear < minDateYear) {
i = 0;
while (i != 12) {
if (i != minDateMonth) listMonths[i].disabled = true;
i++;
}
}

if (openToDateYear === minDateYear) {
i = 0;
while (i != minDateMonth) {
listMonths[i].disabled = true;
i++;
}
} else if (openToDateYear === maxDateYear) {
}

if (openToDateYear === maxDateYear) {
i = 11;
while (i != maxDateMonth) {
listMonths[i].disabled = true;
Expand Down Expand Up @@ -502,6 +511,9 @@ class Calendar extends Component {
options={optionsMonth}
isDisabled={false}
name="month-button"
displaySelectedOption
fixedDirection={true}
directionY="bottom"
/>
</ComboBoxMonthStyle>
<ComboBoxDateStyle>
Expand All @@ -514,7 +526,11 @@ class Calendar extends Component {
selectedOption={selectedOptionYear}
options={optionsYear}
isDisabled={false}
showDisabledItems
name="year-button"
displaySelectedOption
fixedDirection={true}
directionY="bottom"
/>
</ComboBoxDateStyle>
</ComboBoxStyle>
Expand Down
34 changes: 23 additions & 11 deletions packages/asc-web-components/combobox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class ComboBox extends React.Component {
manualX,
isDefaultMode,
manualWidth,
displaySelectedOption,
fixedDirection,
} = this.props;
const { isOpen, selectedOption } = this.state;

Expand Down Expand Up @@ -158,20 +160,26 @@ class ComboBox extends React.Component {
{...dropDownManualWidthProp}
showDisabledItems={showDisabledItems}
isDefaultMode={isDefaultMode}
fixedDirection={fixedDirection}
>
{advancedOptions
? advancedOptions
: options.map((option) => (
<DropDownItem
{...option}
textOverflow={textOverflow}
key={option.key}
disabled={
option.disabled || option.label === selectedOption.label
}
onClick={this.optionClick.bind(this, option)}
/>
))}
: options.map((option) => {
const disabled =
option.disabled ||
(!displaySelectedOption &&
option.label === selectedOption.label);

return (
<DropDownItem
{...option}
textOverflow={textOverflow}
key={option.key}
disabled={disabled}
onClick={this.optionClick.bind(this, option)}
/>
);
})}
</DropDown>
)}
</StyledComboBox>
Expand Down Expand Up @@ -233,6 +241,8 @@ ComboBox.propTypes = {
manualX: PropTypes.string,
//** Dropdown manual width */
manualWidth: PropTypes.string,
displaySelectedOption: PropTypes.bool,
fixedDirection: PropTypes.bool,
};

ComboBox.defaultProps = {
Expand All @@ -247,6 +257,8 @@ ComboBox.defaultProps = {
manualY: "102%",
isDefaultMode: true,
manualWidth: "200px",
displaySelectedOption: false,
fixedDirection: false,
};

export default ComboBox;
3 changes: 3 additions & 0 deletions packages/asc-web-components/date-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class DatePicker extends Component {
style,
className,
inputClassName,
fixedDirection,
} = this.props;
const { value, isOpen, mask, hasError, displayType } = this.state;

Expand Down Expand Up @@ -354,6 +355,7 @@ class DatePicker extends Component {
open={isOpen}
clickOutsideAction={this.onClose}
isDefaultMode={false}
fixedDirection={fixedDirection}
>
{this.renderBody()}
</DropDown>
Expand Down Expand Up @@ -424,6 +426,7 @@ DatePicker.propTypes = {
id: PropTypes.string,
/** Accepts css style */
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
fixedDirection: PropTypes.bool,
};

DatePicker.defaultProps = {
Expand Down
39 changes: 33 additions & 6 deletions packages/asc-web-components/drop-down/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DropDown extends React.PureComponent {
this.state = {
directionX: props.directionX,
directionY: props.directionY,
manualY: props.manualY,
};

this.dropDownRef = React.createRef();
Expand Down Expand Up @@ -99,35 +100,58 @@ class DropDown extends React.PureComponent {
}

checkPosition = () => {
if (!this.dropDownRef.current) return;
const { smallSectionWidth } = this.props;
if (!this.dropDownRef.current || this.props.fixedDirection) return;
const { smallSectionWidth, forwardedRef } = this.props;
const { manualY } = this.state;

const rects = this.dropDownRef.current.getBoundingClientRect();
const container = { width: window.innerWidth, height: window.innerHeight };
const parentRects = forwardedRef?.current?.getBoundingClientRect();
const container = DomHelpers.getViewport();

const dimensions = parentRects
? {
toTopCorner: parentRects.top,
parentHeight: parentRects.height,
containerHeight: parentRects.top,
}
: {
toTopCorner: rects.top,
parentHeight: 42,
containerHeight: container.height,
};

const left = rects.left < 0 && rects.width < container.width;
const right =
rects.width &&
rects.left < (rects.width || 250) &&
rects.left > rects.width &&
rects.width < container.width;
const top = rects.bottom > container.height && rects.top > rects.height;
const top =
rects.bottom > dimensions.containerHeight &&
dimensions.toTopCorner > rects.height;
const bottom = rects.top < 0;

const x = left
? "left"
: right || smallSectionWidth
? "right"
: this.state.directionX;
const y = bottom ? "bottom" : top ? "top" : this.state.directionY;

const mY = top ? `${dimensions.parentHeight}px` : manualY;

this.setState({
directionX: x,
directionY: y,
manualY: mY,
width: this.dropDownRef ? this.dropDownRef.current.offsetWidth : 240,
});
};

checkPositionPortal = () => {
const parent = this.props.forwardedRef;
if (!parent.current) return;
if (!parent.current || this.props.fixedDirection) return;

const rects = parent.current.getBoundingClientRect();

let dropDownHeight = this.dropDownRef.current.offsetParent
Expand Down Expand Up @@ -199,7 +223,7 @@ class DropDown extends React.PureComponent {

renderDropDown() {
const { maxHeight, children, showDisabledItems } = this.props;
const { directionX, directionY, width } = this.state;
const { directionX, directionY, width, manualY } = this.state;
let cleanChildren;

const rowHeights = React.Children.map(children, (child) =>
Expand All @@ -221,6 +245,7 @@ class DropDown extends React.PureComponent {
{...this.props}
directionX={directionX}
directionY={directionY}
manualY={manualY}
{...dropDownMaxHeightProp}
>
{maxHeight ? (
Expand Down Expand Up @@ -320,6 +345,7 @@ DropDownContainer.propTypes = {
isDefaultMode: PropTypes.bool,
/** Needed to open correctly people and group selector when the section width is small */
smallSectionWidth: PropTypes.bool,
fixedDirection: PropTypes.bool,
};

DropDownContainer.defaultProps = {
Expand All @@ -328,6 +354,7 @@ DropDownContainer.defaultProps = {
withBackdrop: true,
showDisabledItems: false,
isDefaultMode: true,
fixedDirection: false,
};

export default DropDownContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const EditingWrapper = styled.div`
display: flex;
align-items: center;
`}
${(props) => props.viewAs === "table" && `padding-left: 12px`}
}
.edit-button {
Expand Down Expand Up @@ -141,6 +143,7 @@ const EditingWrapper = styled.div`
.is-edit {
/* margin-top: 4px; */
${(props) => props.viewAs === "table" && `padding-left: 4px;`}
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const AccessComboBox = (props) => {
t,
arrowIconColor,
disableLink,
fixedDirection,
} = props;
const {
FullAccess,
Expand Down Expand Up @@ -119,6 +120,7 @@ const AccessComboBox = (props) => {
disableIconClick={false}
isDisabled={isDisabled}
isDefaultMode={false}
fixedDirection={fixedDirection}
>
<ReactSVG src={accessIconUrl} className="sharing-access-combo-box-icon" />
</ComboBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class SharingRow extends React.Component {
itemId={id}
accessOptions={accessOptions}
isDisabled={isLoading}
fixedDirection={true}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const StyledSimpleFilesRow = styled(Row)`
}
.row_content {
max-width: fit-content;
${(props) => props.sectionWidth > 500 && `max-width: fit-content;`}
min-width: auto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const InfoItemValue = styled.div`
margin-top: 6px;
}
@media (max-width: 1024px) {
padding: 6px 24px 8px 8px;
padding: 6px 8px 8px 8px;
margin-left: -8px;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DateField extends React.Component {
inputOnChange,
inputTabIndex,
calendarMinDate,
calendarMaxDate,
locale,
maxLabelWidth,
} = this.props;
Expand All @@ -43,8 +44,9 @@ class DateField extends React.Component {
displayType="auto"
calendarHeaderContent={calendarHeaderContent}
minDate={calendarMinDate ? calendarMinDate : new Date("1900/01/01")}
maxDate={new Date()}
maxDate={calendarMaxDate ? calendarMaxDate : new Date()}
locale={locale}
fixedDirection={true}
/>
</FieldContainer>
);
Expand Down
Loading

0 comments on commit f57cff1

Please sign in to comment.