@synerise/ds-field-set 1.1.20 → 1.2.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 +6 -0
- package/dist/FieldSet.d.ts +1 -1
- package/dist/FieldSet.js +29 -21
- package/dist/FieldSet.styles.d.ts +1 -0
- package/dist/FieldSet.styles.js +3 -3
- package/dist/FieldSet.types.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
# [1.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-field-set@1.1.20...@synerise/ds-field-set@1.2.0) (2026-02-26)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **field-set:** add onExpandClick prop ([d5689bc](https://github.com/Synerise/synerise-design/commit/d5689bce6295d3037092d75921a4a3ba4430250e))
|
|
11
|
+
|
|
6
12
|
## [1.1.20](https://github.com/Synerise/synerise-design/compare/@synerise/ds-field-set@1.1.19...@synerise/ds-field-set@1.1.20) (2026-02-23)
|
|
7
13
|
|
|
8
14
|
**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 { type FieldSetProps } from './FieldSet.types';
|
|
3
|
-
declare const FieldSet: ({ className, prefix, title, description, component, button, onTitleClick, divider, expandable, defaultExpanded, triggerType, ...htmlAttributes }: FieldSetProps) => React.JSX.Element;
|
|
3
|
+
declare const FieldSet: ({ className, prefix, title, description, component, button, onTitleClick, onExpandChange, divider, expandable, defaultExpanded, triggerType, ...htmlAttributes }: FieldSetProps) => React.JSX.Element;
|
|
4
4
|
export default FieldSet;
|
package/dist/FieldSet.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var _excluded = ["className", "prefix", "title", "description", "component", "button", "onTitleClick", "divider", "expandable", "defaultExpanded", "triggerType"];
|
|
1
|
+
var _excluded = ["className", "prefix", "title", "description", "component", "button", "onTitleClick", "onExpandChange", "divider", "expandable", "defaultExpanded", "triggerType"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import
|
|
5
|
+
import { Expander } from '@synerise/ds-button';
|
|
6
6
|
import { RawSwitch } from '@synerise/ds-switch';
|
|
7
7
|
import { useResizeObserver } from '@synerise/ds-utils';
|
|
8
8
|
import * as S from './FieldSet.styles';
|
|
@@ -14,6 +14,7 @@ var FieldSet = function FieldSet(_ref) {
|
|
|
14
14
|
component = _ref.component,
|
|
15
15
|
button = _ref.button,
|
|
16
16
|
onTitleClick = _ref.onTitleClick,
|
|
17
|
+
onExpandChange = _ref.onExpandChange,
|
|
17
18
|
_ref$divider = _ref.divider,
|
|
18
19
|
divider = _ref$divider === void 0 ? true : _ref$divider,
|
|
19
20
|
expandable = _ref.expandable,
|
|
@@ -27,44 +28,50 @@ var FieldSet = function FieldSet(_ref) {
|
|
|
27
28
|
var _useState2 = useState(),
|
|
28
29
|
maxHeight = _useState2[0],
|
|
29
30
|
setMaxHeight = _useState2[1];
|
|
30
|
-
var
|
|
31
|
+
var _useState3 = useState(false),
|
|
32
|
+
shouldAnimate = _useState3[0],
|
|
33
|
+
setShouldAnimate = _useState3[1];
|
|
31
34
|
var measureMaxHeightRef = useRef(null);
|
|
32
35
|
useResizeObserver(measureMaxHeightRef, function (dimensions) {
|
|
33
|
-
|
|
36
|
+
setMaxHeight(dimensions.height);
|
|
34
37
|
});
|
|
35
|
-
useEffect(function () {
|
|
36
|
-
var _containerRef$current, _containerRef$current2;
|
|
37
|
-
((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.scrollHeight) && setMaxHeight((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.scrollHeight);
|
|
38
|
-
}, [component, button]);
|
|
39
38
|
useEffect(function () {
|
|
40
39
|
defaultExpanded !== undefined && setExpanded(defaultExpanded);
|
|
41
40
|
}, [defaultExpanded]);
|
|
41
|
+
var handleTransitionEnd = useCallback(function () {
|
|
42
|
+
setShouldAnimate(false);
|
|
43
|
+
}, []);
|
|
44
|
+
var handleExpandedClick = useCallback(function () {
|
|
45
|
+
if (!expandable) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setShouldAnimate(true);
|
|
49
|
+
var newExpanded = !expanded;
|
|
50
|
+
setExpanded(newExpanded);
|
|
51
|
+
onExpandChange == null || onExpandChange(newExpanded);
|
|
52
|
+
}, [expandable, onExpandChange, expanded]);
|
|
42
53
|
var headerPrefix = useMemo(function () {
|
|
43
54
|
if (expandable && (!triggerType || triggerType === 'expander')) {
|
|
44
|
-
return /*#__PURE__*/React.createElement(S.PrefixWrapper, null, /*#__PURE__*/React.createElement(
|
|
55
|
+
return /*#__PURE__*/React.createElement(S.PrefixWrapper, null, /*#__PURE__*/React.createElement(Expander, {
|
|
45
56
|
expanded: expanded,
|
|
46
|
-
onClick:
|
|
47
|
-
return setExpanded(!expanded);
|
|
48
|
-
}
|
|
57
|
+
onClick: handleExpandedClick
|
|
49
58
|
}));
|
|
50
59
|
}
|
|
51
60
|
if (expandable && triggerType === 'switch') {
|
|
52
61
|
return /*#__PURE__*/React.createElement(S.PrefixWrapper, null, /*#__PURE__*/React.createElement(RawSwitch, {
|
|
53
62
|
checked: expanded,
|
|
54
|
-
onClick:
|
|
55
|
-
return setExpanded(!expanded);
|
|
56
|
-
}
|
|
63
|
+
onClick: handleExpandedClick
|
|
57
64
|
}));
|
|
58
65
|
}
|
|
59
66
|
return prefix && /*#__PURE__*/React.createElement(S.PrefixWrapper, null, prefix);
|
|
60
|
-
}, [expandable, prefix, expanded, triggerType]);
|
|
67
|
+
}, [expandable, prefix, expanded, triggerType, handleExpandedClick]);
|
|
61
68
|
var handleTitleClick = useCallback(function (event) {
|
|
62
|
-
|
|
69
|
+
handleExpandedClick();
|
|
63
70
|
onTitleClick && onTitleClick(event);
|
|
64
|
-
}, [
|
|
71
|
+
}, [handleExpandedClick, onTitleClick]);
|
|
65
72
|
var hasTitleAndDescription = Boolean(title && description);
|
|
66
73
|
return /*#__PURE__*/React.createElement(S.ContainerWrapper, _extends({
|
|
67
|
-
className: "ds-field-set " + className
|
|
74
|
+
className: "ds-field-set " + (className != null ? className : '')
|
|
68
75
|
}, htmlAttributes), /*#__PURE__*/React.createElement(S.HeaderWrapper, {
|
|
69
76
|
topAlign: Boolean(hasTitleAndDescription)
|
|
70
77
|
}, headerPrefix, /*#__PURE__*/React.createElement(S.FieldSetTitle, null, title && /*#__PURE__*/React.createElement(S.Title, {
|
|
@@ -73,11 +80,12 @@ var FieldSet = function FieldSet(_ref) {
|
|
|
73
80
|
description: Boolean(description)
|
|
74
81
|
}, title), description && /*#__PURE__*/React.createElement(S.Description, null, description))), divider && /*#__PURE__*/React.createElement(S.StyledDivider, null), (component || button) && /*#__PURE__*/React.createElement(S.CollapsibleContent, {
|
|
75
82
|
"data-testid": "field-set-collapsible",
|
|
76
|
-
ref: containerRef,
|
|
77
83
|
expandable: expandable,
|
|
78
84
|
expanded: expandable && expanded,
|
|
79
85
|
"aria-hidden": expandable && !expanded,
|
|
80
|
-
maxHeight: maxHeight
|
|
86
|
+
maxHeight: maxHeight,
|
|
87
|
+
shouldAnimate: shouldAnimate,
|
|
88
|
+
onTransitionEnd: handleTransitionEnd
|
|
81
89
|
}, /*#__PURE__*/React.createElement(S.CollapsibleContentInner, {
|
|
82
90
|
ref: measureMaxHeightRef
|
|
83
91
|
}, component && /*#__PURE__*/React.createElement(S.ComponentWrapper, null, component), button && /*#__PURE__*/React.createElement(S.ActionButton, null, button))));
|
|
@@ -16,6 +16,7 @@ export declare const CollapsibleContent: import("styled-components").StyledCompo
|
|
|
16
16
|
expandable?: boolean;
|
|
17
17
|
expanded?: boolean;
|
|
18
18
|
maxHeight?: number;
|
|
19
|
+
shouldAnimate?: boolean;
|
|
19
20
|
}, never>;
|
|
20
21
|
export declare const CollapsibleContentInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
21
22
|
export declare const StyledDivider: import("styled-components").StyledComponent<(props: import("@synerise/ds-divider").DividerProps) => React.JSX.Element, any, {}, never>;
|
package/dist/FieldSet.styles.js
CHANGED
|
@@ -15,7 +15,7 @@ export var ContainerWrapper = styled.div.withConfig({
|
|
|
15
15
|
export var HeaderWrapper = styled.div.withConfig({
|
|
16
16
|
displayName: "FieldSetstyles__HeaderWrapper",
|
|
17
17
|
componentId: "sc-1hezedi-2"
|
|
18
|
-
})(["display:flex;
|
|
18
|
+
})(["display:flex;gap:16px;align-items:", ";"], function (props) {
|
|
19
19
|
return props.topAlign ? 'flex-start' : 'center';
|
|
20
20
|
});
|
|
21
21
|
export var PrefixWrapper = styled.div.withConfig({
|
|
@@ -25,7 +25,7 @@ export var PrefixWrapper = styled.div.withConfig({
|
|
|
25
25
|
export var ActionButton = styled.div.withConfig({
|
|
26
26
|
displayName: "FieldSetstyles__ActionButton",
|
|
27
27
|
componentId: "sc-1hezedi-4"
|
|
28
|
-
})(["display:flex;padding
|
|
28
|
+
})(["display:flex;padding:8px;"]);
|
|
29
29
|
export var ExpanderWrapper = styled.div.withConfig({
|
|
30
30
|
displayName: "FieldSetstyles__ExpanderWrapper",
|
|
31
31
|
componentId: "sc-1hezedi-5"
|
|
@@ -46,7 +46,7 @@ export var CollapsibleContent = styled.div.withConfig({
|
|
|
46
46
|
displayName: "FieldSetstyles__CollapsibleContent",
|
|
47
47
|
componentId: "sc-1hezedi-9"
|
|
48
48
|
})(["position:relative;", ""], function (props) {
|
|
49
|
-
return props.expandable && css(["transition:max-height 0.7s ease-in-out;
|
|
49
|
+
return props.expandable && css(["", " overflow:hidden;", ""], props.shouldAnimate && 'transition: max-height 0.7s ease-in-out;', props.expanded ? "\n max-height: " + (props.maxHeight || 9999) + "px;\n " : "\n max-height: 0;\n ");
|
|
50
50
|
});
|
|
51
51
|
export var CollapsibleContentInner = styled.div.withConfig({
|
|
52
52
|
displayName: "FieldSetstyles__CollapsibleContentInner",
|
package/dist/FieldSet.types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-field-set",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "FieldSet UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react": ">=16.9.0 <= 18.3.1",
|
|
47
47
|
"styled-components": "^5.3.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "4ffbd56e9bf6277c4507efeaf000b66b9bb09781"
|
|
50
50
|
}
|