@synerise/ds-layout 0.13.45 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.14.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-layout@0.13.45...@synerise/ds-layout@0.14.0) (2024-02-19)
7
+
8
+
9
+ ### Features
10
+
11
+ * **layout:** add useNativeScroll prop for main content column ([699f3b2](https://github.com/synerise/synerise-design/commit/699f3b2980f816905046b69c36f1cc0ca7a2d98b))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.13.45](https://github.com/synerise/synerise-design/compare/@synerise/ds-layout@0.13.44...@synerise/ds-layout@0.13.45) (2024-02-15)
7
18
 
8
19
 
package/README.md CHANGED
@@ -50,6 +50,10 @@ import Layout from '@synerise/ds-layout'
50
50
  | leftSidebarWithDnd | Set withDnd in left sidebar scrollbar | boolean | false |
51
51
  | mainSidebarWithDnd | Set withDnd in main sidebar scrollbar | boolean | false |
52
52
  | rightSidebarWithDnd | Set withDnd in right sidebar scrollbar | boolean | false |
53
+ | nativeScroll | Set main column to use native browser scroll | boolean | false |
54
+ | nativeScrollRef | ref to pass to scrollable element | Ref<HTMLDivElement> | - |
55
+ | fillViewport | sets layout to absolute with calc(100vh - viewportTopOffset) height | boolean | false |
56
+ | viewportTopOffset | top viewport offset (if fillViewport is true) | number | 55 |
53
57
 
54
58
  ### SidebarProps
55
59
 
package/dist/Layout.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import * as T from './Layout.types';
3
- declare const Layout: React.FC<T.LayoutProps>;
2
+ declare const Layout: ({ header, left, right, children, className, styles, subheader, fullPage, nativeScroll, nativeScrollRef, fillViewport, viewportTopOffset, sidebarAnimationDisabled, renderLeftSidebarControls, renderRightSidebarControls, leftSidebarWithDnd, rightSidebarWithDnd, mainSidebarWithDnd, }: T.LayoutProps) => JSX.Element;
4
3
  export default Layout;
package/dist/Layout.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import Scrollbar from '@synerise/ds-scrollbar';
3
3
  import { AngleLeftS, AngleRightS, CloseS } from '@synerise/ds-icon';
4
4
  import { theme } from '@synerise/ds-core';
@@ -15,6 +15,10 @@ var Layout = function Layout(_ref) {
15
15
  subheader = _ref.subheader,
16
16
  _ref$fullPage = _ref.fullPage,
17
17
  fullPage = _ref$fullPage === void 0 ? false : _ref$fullPage,
18
+ nativeScroll = _ref.nativeScroll,
19
+ nativeScrollRef = _ref.nativeScrollRef,
20
+ fillViewport = _ref.fillViewport,
21
+ viewportTopOffset = _ref.viewportTopOffset,
18
22
  sidebarAnimationDisabled = _ref.sidebarAnimationDisabled,
19
23
  _ref$renderLeftSideba = _ref.renderLeftSidebarControls,
20
24
  renderLeftSidebarControls = _ref$renderLeftSideba === void 0 ? false : _ref$renderLeftSideba,
@@ -26,19 +30,33 @@ var Layout = function Layout(_ref) {
26
30
  rightSidebarWithDnd = _ref$rightSidebarWith === void 0 ? false : _ref$rightSidebarWith,
27
31
  _ref$mainSidebarWithD = _ref.mainSidebarWithDnd,
28
32
  mainSidebarWithDnd = _ref$mainSidebarWithD === void 0 ? false : _ref$mainSidebarWithD;
29
- var leftSidebarWidth = React.useMemo(function () {
33
+ var leftSidebarWidth = useMemo(function () {
30
34
  return (left == null ? void 0 : left.width) || DEFAULT_SIDEBAR_WIDTH;
31
35
  }, [left]);
32
- var rightSidebarWidth = React.useMemo(function () {
36
+ var rightSidebarWidth = useMemo(function () {
33
37
  return (right == null ? void 0 : right.width) || DEFAULT_SIDEBAR_WIDTH;
34
38
  }, [right]);
35
- var showLeftSidebar = React.useMemo(function () {
39
+ var showLeftSidebar = useMemo(function () {
36
40
  return (left == null ? void 0 : left.opened) || !renderLeftSidebarControls;
37
41
  }, [left, renderLeftSidebarControls]);
38
- var showRightSidebar = React.useMemo(function () {
42
+ var showRightSidebar = useMemo(function () {
39
43
  return (right == null ? void 0 : right.opened) || !renderRightSidebarControls;
40
44
  }, [right, renderRightSidebarControls]);
45
+ var mainColumnInner = nativeScroll ? /*#__PURE__*/React.createElement(S.LayoutMainInner, {
46
+ fullPage: fullPage,
47
+ style: styles && styles.mainInner,
48
+ ref: nativeScrollRef
49
+ }, children) : /*#__PURE__*/React.createElement(Scrollbar, {
50
+ absolute: true,
51
+ withDnd: mainSidebarWithDnd
52
+ }, /*#__PURE__*/React.createElement(S.LayoutMainInner, {
53
+ fullPage: fullPage,
54
+ style: styles && styles.mainInner
55
+ }, children));
41
56
  return /*#__PURE__*/React.createElement(S.LayoutContainer, {
57
+ fillViewport: fillViewport,
58
+ viewportTopOffset: viewportTopOffset,
59
+ nativeScroll: nativeScroll,
42
60
  className: "ds-layout " + (className || '')
43
61
  }, header ? /*#__PURE__*/React.createElement(S.LayoutHeader, {
44
62
  className: "ds-layout__header"
@@ -78,13 +96,7 @@ var Layout = function Layout(_ref) {
78
96
  rightOpened: showRightSidebar,
79
97
  leftSidebarWidth: leftSidebarWidth,
80
98
  rightSidebarWidth: rightSidebarWidth
81
- }, /*#__PURE__*/React.createElement(S.LayoutSubheader, null, subheader), /*#__PURE__*/React.createElement(Scrollbar, {
82
- absolute: true,
83
- withDnd: mainSidebarWithDnd
84
- }, /*#__PURE__*/React.createElement(S.LayoutMainInner, {
85
- fullPage: fullPage,
86
- style: styles && styles.mainInner
87
- }, children))), /*#__PURE__*/React.createElement(React.Fragment, null, right ? /*#__PURE__*/React.createElement(S.LayoutSidebarWrapper, {
99
+ }, /*#__PURE__*/React.createElement(S.LayoutSubheader, null, subheader), mainColumnInner), /*#__PURE__*/React.createElement(React.Fragment, null, right ? /*#__PURE__*/React.createElement(S.LayoutSidebarWrapper, {
88
100
  opened: showRightSidebar,
89
101
  right: true,
90
102
  openedWidth: rightSidebarWidth,
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const ArrowIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
3
3
  export declare const CloseIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
4
- export declare const LayoutContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
5
4
  export declare const LayoutContent: import("styled-components").StyledComponent<"div", any, {}, never>;
6
5
  export declare const LayoutHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
7
6
  export declare const LayoutSubheader: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -15,6 +14,11 @@ export declare const LayoutMain: import("styled-components").StyledComponent<"di
15
14
  export declare const LayoutMainInner: import("styled-components").StyledComponent<"div", any, {
16
15
  fullPage: boolean;
17
16
  }, never>;
17
+ export declare const LayoutContainer: import("styled-components").StyledComponent<"div", any, {
18
+ nativeScroll?: boolean | undefined;
19
+ fillViewport?: boolean | undefined;
20
+ viewportTopOffset?: number | undefined;
21
+ }, never>;
18
22
  type SidebarButtonProps = {
19
23
  right?: boolean;
20
24
  opened: boolean;
@@ -6,6 +6,7 @@ import styled, { css } from 'styled-components';
6
6
  import { hexToRgba } from '@synerise/ds-utils';
7
7
  import { mediaQuery } from '@synerise/ds-core';
8
8
  import Icon from '@synerise/ds-icon';
9
+ var DEFAULT_TOP_OFFSET = 55;
9
10
  export var ArrowIcon = styled(Icon).withConfig({
10
11
  displayName: "Layoutstyles__ArrowIcon",
11
12
  componentId: "i053aj-0"
@@ -14,17 +15,13 @@ export var CloseIcon = styled(Icon).withConfig({
14
15
  displayName: "Layoutstyles__CloseIcon",
15
16
  componentId: "i053aj-1"
16
17
  })(["display:none;"]);
17
- export var LayoutContainer = styled.div.withConfig({
18
- displayName: "Layoutstyles__LayoutContainer",
19
- componentId: "i053aj-2"
20
- })(["height:100%;overflow:hidden;"]);
21
18
  export var LayoutContent = styled.div.withConfig({
22
19
  displayName: "Layoutstyles__LayoutContent",
23
- componentId: "i053aj-3"
20
+ componentId: "i053aj-2"
24
21
  })(["overflow:hidden;width:100%;height:100%;", ";"], mediaQuery.to.small(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["overflow-x: auto;"]))));
25
22
  export var LayoutHeader = styled.div.withConfig({
26
23
  displayName: "Layoutstyles__LayoutHeader",
27
- componentId: "i053aj-4"
24
+ componentId: "i053aj-3"
28
25
  })(["&&&{margin:0;display:block;width:100%;}z-index:1;box-shadow:0 2px 6px ", ";border-bottom:1px solid ", ";"], function (props) {
29
26
  return hexToRgba(props.theme.palette['grey-400'], 0.12);
30
27
  }, function (props) {
@@ -32,22 +29,34 @@ export var LayoutHeader = styled.div.withConfig({
32
29
  });
33
30
  export var LayoutSubheader = styled.div.withConfig({
34
31
  displayName: "Layoutstyles__LayoutSubheader",
35
- componentId: "i053aj-5"
32
+ componentId: "i053aj-4"
36
33
  })(["position:relative;max-width:100%;top:0;z-index:1;box-shadow:0 4px 12px 0 rgba(35,41,54,0.04);"]);
37
34
  export var LayoutBody = styled.div.withConfig({
38
35
  displayName: "Layoutstyles__LayoutBody",
39
- componentId: "i053aj-6"
36
+ componentId: "i053aj-5"
40
37
  })(["flex:1;display:flex;flex-direction:column;min-height:0;min-width:0;position:relative;overflow:hidden;height:100%;", ";", ";"], mediaQuery.from.medium(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["flex-direction: row;"]))), mediaQuery.to.small(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["min-width: 704px;"]))));
41
38
  export var LayoutMain = styled.div.withConfig({
42
39
  displayName: "Layoutstyles__LayoutMain",
43
- componentId: "i053aj-7"
40
+ componentId: "i053aj-6"
44
41
  })(["position:relative;max-width:100%;width:100%;", ";", ";"], mediaQuery.to.small(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["min-width: 704px;"]))), mediaQuery.to.medium(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["height: 100%;"]))));
45
42
  export var LayoutMainInner = styled.div.withConfig({
46
43
  displayName: "Layoutstyles__LayoutMainInner",
47
- componentId: "i053aj-8"
44
+ componentId: "i053aj-7"
48
45
  })(["", ";", ";&&{padding:", ";}"], mediaQuery.to.medium(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["flex: 0 0 auto;"]))), mediaQuery.from.medium(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["padding: 24px;"]))), function (props) {
49
46
  return props.fullPage ? '0' : '24px';
50
47
  });
48
+ export var LayoutContainer = styled.div.withConfig({
49
+ displayName: "Layoutstyles__LayoutContainer",
50
+ componentId: "i053aj-8"
51
+ })(["height:100%;display:flex;flex-direction:column;overflow:hidden;", ";", "{", ";}", "{overflow:", ";", ";}"], function (props) {
52
+ return props.fillViewport && css(["position:absolute;width:100%;height:calc(100vh - ", "px);"], props.viewportTopOffset !== undefined ? props.viewportTopOffset : DEFAULT_TOP_OFFSET);
53
+ }, LayoutMain, function (props) {
54
+ return props.nativeScroll && css(["display:flex;flex-direction:column;overflow:hidden;"]);
55
+ }, LayoutMainInner, function (props) {
56
+ return props.nativeScroll ? 'auto' : 'hidden';
57
+ }, function (props) {
58
+ return props.nativeScroll && 'flex-grow: 1';
59
+ });
51
60
  export var SidebarButton = styled.button.withConfig({
52
61
  displayName: "Layoutstyles__SidebarButton",
53
62
  componentId: "i053aj-9"
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- export interface Style<T> {
1
+ import { ReactNode, CSSProperties, Ref } from 'react';
2
+ export interface ColumnProps<T> {
3
3
  left?: T;
4
4
  leftInner?: T;
5
5
  main?: T;
@@ -8,29 +8,33 @@ export interface Style<T> {
8
8
  rightInner?: T;
9
9
  }
10
10
  export type SidebarProps = {
11
- content: React.ReactNode;
11
+ content: ReactNode;
12
12
  opened: boolean;
13
13
  onChange: (isOpened: boolean) => void;
14
14
  width?: number;
15
15
  };
16
16
  export type LayoutProps = {
17
- header?: React.ReactNode;
18
- subheader?: React.ReactNode;
17
+ nativeScroll?: boolean;
18
+ nativeScrollRef?: Ref<HTMLDivElement>;
19
+ header?: ReactNode;
20
+ subheader?: ReactNode;
19
21
  left?: SidebarProps;
20
22
  right?: SidebarProps;
21
- children: React.ReactNode;
23
+ children: ReactNode;
22
24
  className?: string;
23
- styles?: Style<React.CSSProperties>;
25
+ styles?: ColumnProps<CSSProperties>;
24
26
  fullPage?: boolean;
27
+ fillViewport?: boolean;
28
+ viewportTopOffset?: number;
25
29
  sidebarAnimationDisabled?: boolean;
26
30
  /**
27
31
  * Left sidebar: render visibility of show/hide button. Accepts function returning `ReactNode` (see source code).
28
32
  */
29
- renderLeftSidebarControls?: boolean | (() => React.ReactNode);
33
+ renderLeftSidebarControls?: boolean | (() => ReactNode);
30
34
  /**
31
35
  * Right sidebar: render visibility of show/hide button. Accepts function returning `ReactNode` (see source code).
32
36
  */
33
- renderRightSidebarControls?: boolean | (() => React.ReactNode);
37
+ renderRightSidebarControls?: boolean | (() => ReactNode);
34
38
  leftSidebarWithDnd?: boolean;
35
39
  rightSidebarWithDnd?: boolean;
36
40
  mainSidebarWithDnd?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-layout",
3
- "version": "0.13.45",
3
+ "version": "0.14.0",
4
4
  "description": "Layout UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -34,7 +34,7 @@
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
36
  "@synerise/ds-icon": "^0.60.0",
37
- "@synerise/ds-scrollbar": "^0.7.3",
37
+ "@synerise/ds-scrollbar": "^0.8.0",
38
38
  "@synerise/ds-utils": "^0.24.24"
39
39
  },
40
40
  "peerDependencies": {
@@ -42,5 +42,5 @@
42
42
  "react": ">=16.9.0 < 17.0.0",
43
43
  "styled-components": "5.0.1"
44
44
  },
45
- "gitHead": "a61bf46e0ab1fdb9154808bbdd3c7163aa7b0576"
45
+ "gitHead": "17e3bca1d4d134a28aaa186f0e2637616ca86174"
46
46
  }