@synerise/ds-field-set 0.3.6 → 0.4.1
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 +19 -0
- package/dist/FieldSet.d.ts +1 -1
- package/dist/FieldSet.js +51 -7
- package/dist/FieldSet.styles.d.ts +4 -0
- package/dist/FieldSet.styles.js +7 -1
- package/dist/FieldSet.types.d.ts +5 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,25 @@
|
|
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.4.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-field-set@0.4.0...@synerise/ds-field-set@0.4.1) (2025-03-07)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @synerise/ds-field-set
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [0.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-field-set@0.3.6...@synerise/ds-field-set@0.4.0) (2025-03-07)
|
15
|
+
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
* **field-set:** add expandable prop ([3c918ca](https://github.com/Synerise/synerise-design/commit/3c918ca5092321eb75dd8e5ed78458ebe2f1f445))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
6
25
|
## [0.3.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-field-set@0.3.5...@synerise/ds-field-set@0.3.6) (2025-03-04)
|
7
26
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-field-set
|
package/dist/FieldSet.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { FieldSetProps } from './FieldSet.types';
|
3
|
-
declare const FieldSet: ({ className, prefix, title, description, component, button, onTitleClick, divider, }: FieldSetProps) => React.JSX.Element;
|
3
|
+
declare const FieldSet: ({ className, prefix, title, description, component, button, onTitleClick, divider, expandable, defaultExpanded, ...htmlAttributes }: FieldSetProps) => React.JSX.Element;
|
4
4
|
export default FieldSet;
|
package/dist/FieldSet.js
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
|
1
|
+
var _excluded = ["className", "prefix", "title", "description", "component", "button", "onTitleClick", "divider", "expandable", "defaultExpanded"];
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
4
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
2
5
|
import Divider from '@synerise/ds-divider';
|
6
|
+
import Button from '@synerise/ds-button';
|
3
7
|
import * as S from './FieldSet.styles';
|
4
8
|
var FieldSet = function FieldSet(_ref) {
|
5
9
|
var className = _ref.className,
|
@@ -10,15 +14,55 @@ var FieldSet = function FieldSet(_ref) {
|
|
10
14
|
button = _ref.button,
|
11
15
|
onTitleClick = _ref.onTitleClick,
|
12
16
|
_ref$divider = _ref.divider,
|
13
|
-
divider = _ref$divider === void 0 ? true : _ref$divider
|
14
|
-
|
17
|
+
divider = _ref$divider === void 0 ? true : _ref$divider,
|
18
|
+
expandable = _ref.expandable,
|
19
|
+
defaultExpanded = _ref.defaultExpanded,
|
20
|
+
htmlAttributes = _objectWithoutPropertiesLoose(_ref, _excluded);
|
21
|
+
var _useState = useState(!!defaultExpanded),
|
22
|
+
expanded = _useState[0],
|
23
|
+
setExpanded = _useState[1];
|
24
|
+
var _useState2 = useState(),
|
25
|
+
maxHeight = _useState2[0],
|
26
|
+
setMaxHeight = _useState2[1];
|
27
|
+
var containerRef = useRef(null);
|
28
|
+
useEffect(function () {
|
29
|
+
var _containerRef$current, _containerRef$current2;
|
30
|
+
((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.scrollHeight) && setMaxHeight((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.scrollHeight);
|
31
|
+
}, [component, button]);
|
32
|
+
useEffect(function () {
|
33
|
+
defaultExpanded !== undefined && setExpanded(defaultExpanded);
|
34
|
+
}, [defaultExpanded]);
|
35
|
+
var headerPrefix = useMemo(function () {
|
36
|
+
if (expandable) {
|
37
|
+
return /*#__PURE__*/React.createElement(S.ButtonWrapper, null, /*#__PURE__*/React.createElement(S.ExpanderWrapper, {
|
38
|
+
description: !!description
|
39
|
+
}, /*#__PURE__*/React.createElement(Button.Expander, {
|
40
|
+
expanded: expanded,
|
41
|
+
onClick: function onClick() {
|
42
|
+
return setExpanded(!expanded);
|
43
|
+
}
|
44
|
+
})));
|
45
|
+
}
|
46
|
+
return prefix && /*#__PURE__*/React.createElement(S.ButtonWrapper, null, prefix);
|
47
|
+
}, [expandable, prefix, description, expanded]);
|
48
|
+
var handleTitleClick = useCallback(function (event) {
|
49
|
+
expandable && setExpanded(!expanded);
|
50
|
+
onTitleClick && onTitleClick(event);
|
51
|
+
}, [onTitleClick, expandable, expanded]);
|
52
|
+
return /*#__PURE__*/React.createElement(S.ContainerWrapper, _extends({
|
15
53
|
className: "ds-field-set " + className
|
16
|
-
},
|
54
|
+
}, htmlAttributes), /*#__PURE__*/React.createElement(S.HeaderWrapper, null, headerPrefix, /*#__PURE__*/React.createElement(S.FieldSetTitle, {
|
17
55
|
description: Boolean(description)
|
18
56
|
}, /*#__PURE__*/React.createElement(S.Title, {
|
19
|
-
onClick:
|
20
|
-
isClickable: Boolean(onTitleClick),
|
57
|
+
onClick: handleTitleClick,
|
58
|
+
isClickable: Boolean(onTitleClick || expandable),
|
21
59
|
description: Boolean(description)
|
22
|
-
}, title), /*#__PURE__*/React.createElement(S.Description, null, description))), divider && /*#__PURE__*/React.createElement(Divider, null), component
|
60
|
+
}, title), /*#__PURE__*/React.createElement(S.Description, null, description))), divider && /*#__PURE__*/React.createElement(Divider, null), (component || button) && /*#__PURE__*/React.createElement(S.CollapsibleContent, {
|
61
|
+
"data-testid": "field-set-collapsible",
|
62
|
+
ref: containerRef,
|
63
|
+
expanded: !expandable || expanded,
|
64
|
+
"aria-hidden": expandable && !expanded,
|
65
|
+
maxHeight: maxHeight
|
66
|
+
}, component && /*#__PURE__*/React.createElement(S.ComponentWrapper, null, component), button && /*#__PURE__*/React.createElement(S.ActionButton, null, button)));
|
23
67
|
};
|
24
68
|
export default FieldSet;
|
@@ -14,3 +14,7 @@ export declare const FieldSetTitle: import("styled-components").StyledComponent<
|
|
14
14
|
}, never>;
|
15
15
|
export declare const ComponentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
16
16
|
export declare const Description: import("styled-components").StyledComponent<"div", any, {}, never>;
|
17
|
+
export declare const CollapsibleContent: import("styled-components").StyledComponent<"div", any, {
|
18
|
+
expanded: boolean;
|
19
|
+
maxHeight?: number | undefined;
|
20
|
+
}, never>;
|
package/dist/FieldSet.styles.js
CHANGED
@@ -46,4 +46,10 @@ export var ComponentWrapper = styled.div.withConfig({
|
|
46
46
|
export var Description = styled.div.withConfig({
|
47
47
|
displayName: "FieldSetstyles__Description",
|
48
48
|
componentId: "sc-1hezedi-8"
|
49
|
-
})(["display:flex;line-height:16px;font-size:13px;word-wrap:break-word;"]);
|
49
|
+
})(["display:flex;line-height:16px;font-size:13px;word-wrap:break-word;"]);
|
50
|
+
export var CollapsibleContent = styled.div.withConfig({
|
51
|
+
displayName: "FieldSetstyles__CollapsibleContent",
|
52
|
+
componentId: "sc-1hezedi-9"
|
53
|
+
})(["transition:max-height 0.7s ease-in-out;overflow:hidden;", ""], function (props) {
|
54
|
+
return props.expanded ? "\n max-height: " + (props.maxHeight || 9999) + "px;\n " : "\n max-height: 0;\n ";
|
55
|
+
});
|
package/dist/FieldSet.types.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
1
2
|
import { ReactNode, MouseEvent as ReactMouseEvent } from 'react';
|
2
|
-
export type FieldSetProps = {
|
3
|
+
export type FieldSetProps = WithHTMLAttributes<HTMLDivElement, {
|
3
4
|
component?: ReactNode;
|
4
5
|
prefix?: ReactNode;
|
5
6
|
title?: ReactNode;
|
@@ -8,4 +9,6 @@ export type FieldSetProps = {
|
|
8
9
|
onTitleClick?: (ev: ReactMouseEvent<HTMLElement, MouseEvent>) => void;
|
9
10
|
className?: string;
|
10
11
|
divider?: boolean;
|
11
|
-
|
12
|
+
expandable?: boolean;
|
13
|
+
defaultExpanded?: boolean;
|
14
|
+
}>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@synerise/ds-field-set",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.1",
|
4
4
|
"description": "FieldSet UI Component for the Synerise Design System",
|
5
5
|
"license": "ISC",
|
6
6
|
"repository": "Synerise/synerise-design",
|
@@ -43,5 +43,5 @@
|
|
43
43
|
"react": ">=16.9.0 <= 18.3.1",
|
44
44
|
"styled-components": "^5.3.3"
|
45
45
|
},
|
46
|
-
"gitHead": "
|
46
|
+
"gitHead": "e2daf4a742bb045c43773146d2347c3d093911e2"
|
47
47
|
}
|