@commercetools-uikit/collapsible-panel 12.2.1 → 12.2.5
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/README.md +28 -21
- package/dist/commercetools-uikit-collapsible-panel.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-collapsible-panel.cjs.dev.js +184 -253
- package/dist/commercetools-uikit-collapsible-panel.cjs.prod.js +148 -123
- package/dist/commercetools-uikit-collapsible-panel.esm.js +178 -248
- package/dist/declarations/src/collapsible-panel-header.d.ts +9 -0
- package/dist/declarations/src/collapsible-panel.d.ts +34 -0
- package/dist/declarations/src/collapsible-panel.styles.d.ts +18 -0
- package/dist/declarations/src/header-icon.d.ts +14 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +20 -17
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _styled = require('@emotion/styled/base');
|
|
6
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
7
|
-
require('react');
|
|
8
6
|
require('prop-types');
|
|
9
|
-
require('
|
|
7
|
+
require('react');
|
|
8
|
+
var isNil = require('lodash/isNil');
|
|
10
9
|
var uniqueId = require('lodash/uniqueId');
|
|
11
10
|
var utils = require('@commercetools-uikit/utils');
|
|
12
11
|
var AccessibleButton = require('@commercetools-uikit/accessible-button');
|
|
@@ -17,17 +16,20 @@ var Constraints = require('@commercetools-uikit/constraints');
|
|
|
17
16
|
var react = require('@emotion/react');
|
|
18
17
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
19
18
|
var icons = require('@commercetools-uikit/icons');
|
|
19
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
20
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
20
21
|
|
|
21
22
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
23
|
|
|
23
24
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
24
|
-
var
|
|
25
|
+
var isNil__default = /*#__PURE__*/_interopDefault(isNil);
|
|
25
26
|
var uniqueId__default = /*#__PURE__*/_interopDefault(uniqueId);
|
|
26
27
|
var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
|
|
27
28
|
var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
28
29
|
var Text__default = /*#__PURE__*/_interopDefault(Text);
|
|
29
30
|
var CollapsibleMotion__default = /*#__PURE__*/_interopDefault(CollapsibleMotion);
|
|
30
31
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
32
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
31
33
|
|
|
32
34
|
var sizeIconContainer = '22px';
|
|
33
35
|
var sizeIconContainerSmall = '14px';
|
|
@@ -42,35 +44,36 @@ var getArrowColor = function getArrowColor(_ref) {
|
|
|
42
44
|
|
|
43
45
|
var HeaderIcon = function HeaderIcon(props) {
|
|
44
46
|
var backgroundColor = props.tone === 'urgent' ? designSystem.customProperties.colorWarning : designSystem.customProperties.colorSurface;
|
|
45
|
-
return
|
|
46
|
-
css: [/*#__PURE__*/react.css("display:flex;align-items:center;justify-content:center;height:", props.size === 'small' ? sizeIconContainerSmall : sizeIconContainer, ";width:", props.size === 'small' ? sizeIconContainerSmall : sizeIconContainer, ";border-radius:50%;flex-shrink:0;box-shadow:", designSystem.customProperties.shadow7, ";background-color:", backgroundColor, ";border:1px solid ", backgroundColor, ";" + ("" )), props.isDisabled && /*#__PURE__*/react.css("box-shadow:none;border:1px solid ", designSystem.customProperties.colorNeutral, ";background-color:", designSystem.customProperties.colorAccent98, ";" + ("" )), "" ]
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
return jsxRuntime.jsx("div", {
|
|
48
|
+
css: [/*#__PURE__*/react.css("display:flex;align-items:center;justify-content:center;height:", props.size === 'small' ? sizeIconContainerSmall : sizeIconContainer, ";width:", props.size === 'small' ? sizeIconContainerSmall : sizeIconContainer, ";border-radius:50%;flex-shrink:0;box-shadow:", designSystem.customProperties.shadow7, ";background-color:", backgroundColor, ";border:1px solid ", backgroundColor, ";" + ("" ), "" ), props.isDisabled && /*#__PURE__*/react.css("box-shadow:none;border:1px solid ", designSystem.customProperties.colorNeutral, ";background-color:", designSystem.customProperties.colorAccent98, ";" + ("" ), "" ), "" , "" ],
|
|
49
|
+
children: props.isClosed ? jsxRuntime.jsx(icons.AngleRightIcon, {
|
|
50
|
+
color: getArrowColor({
|
|
51
|
+
tone: props.tone,
|
|
52
|
+
isDisabled: props.isDisabled
|
|
53
|
+
}),
|
|
54
|
+
size: props.size
|
|
55
|
+
}) : jsxRuntime.jsx(icons.AngleDownIcon, {
|
|
56
|
+
color: getArrowColor({
|
|
57
|
+
tone: props.tone,
|
|
58
|
+
isDisabled: props.isDisabled
|
|
59
|
+
}),
|
|
60
|
+
size: props.size
|
|
61
|
+
})
|
|
62
|
+
});
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
HeaderIcon.displayName = 'HeaderIcon';
|
|
63
|
-
HeaderIcon.propTypes = {};
|
|
64
66
|
HeaderIcon.defaultProps = {
|
|
65
67
|
tone: 'primary'
|
|
66
68
|
};
|
|
69
|
+
var HeaderIcon$1 = HeaderIcon;
|
|
67
70
|
|
|
68
71
|
function getThemeStyle(theme) {
|
|
69
72
|
if (theme === 'light') {
|
|
70
|
-
return /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorSurface, ";" + ("" ));
|
|
73
|
+
return /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorSurface, ";" + ("" ), "" );
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
return /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorNeutral95, ";" + ("" ));
|
|
76
|
+
return /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorNeutral95, ";" + ("" ), "" );
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
var _ref = {
|
|
@@ -81,139 +84,161 @@ var _ref = {
|
|
|
81
84
|
var getHeaderContainerStyles = function getHeaderContainerStyles(props, isOpen) {
|
|
82
85
|
var _context, _context2;
|
|
83
86
|
|
|
84
|
-
var baseStyles = /*#__PURE__*/react.css("position:relative;border-top-left-radius:", designSystem.customProperties.borderRadius6, ";border-top-right-radius:", designSystem.customProperties.borderRadius6, ";display:flex;flex:1;align-items:center;list-style-type:none;justify-content:", props.headerControlsAlignment === 'left' ? 'flex-start' : 'space-between', ";padding:", props.condensed ? _concatInstanceProperty__default[
|
|
85
|
-
return [baseStyles, props.isDisabled && _ref, props.isSticky && isOpen && /*#__PURE__*/react.css("z-index:1;position:sticky;top:0;border-top-right-radius:", designSystem.customProperties.borderRadius6, ";border-top-left-radius:", designSystem.customProperties.borderRadius6, ";" + ("" )), !props.condensed &&
|
|
87
|
+
var baseStyles = /*#__PURE__*/react.css("position:relative;border-top-left-radius:", designSystem.customProperties.borderRadius6, ";border-top-right-radius:", designSystem.customProperties.borderRadius6, ";display:flex;flex:1;align-items:center;list-style-type:none;justify-content:", props.headerControlsAlignment === 'left' ? 'flex-start' : 'space-between', ";padding:", props.condensed ? _concatInstanceProperty__default["default"](_context = "".concat(designSystem.customProperties.spacingXs, " ")).call(_context, designSystem.customProperties.spacingS) : _concatInstanceProperty__default["default"](_context2 = "".concat(designSystem.customProperties.spacingS, " ")).call(_context2, designSystem.customProperties.spacingM), ";" + ("" ), "" );
|
|
88
|
+
return [baseStyles, props.isDisabled && _ref, props.isSticky && isOpen && /*#__PURE__*/react.css("z-index:1;position:sticky;top:0;border-top-right-radius:", designSystem.customProperties.borderRadius6, ";border-top-left-radius:", designSystem.customProperties.borderRadius6, ";" + ("" ), "" ), !props.condensed &&
|
|
86
89
|
/*#__PURE__*/
|
|
87
90
|
// To understand why this min-height see: https://github.com/commercetools/ui-kit/pull/616
|
|
88
|
-
react.css("min-height:", designSystem.customProperties.bigButtonHeight, ";box-sizing:content-box;" + ("" ))];
|
|
91
|
+
react.css("min-height:", designSystem.customProperties.bigButtonHeight, ";box-sizing:content-box;" + ("" ), "" )];
|
|
89
92
|
};
|
|
90
93
|
|
|
91
|
-
var baseContainerStyles = /*#__PURE__*/react.css("position:relative;min-width:", designSystem.customProperties.constraint6, ";padding:0;display:flex;flex-direction:column;box-shadow:", designSystem.customProperties.shadow1, ";border-radius:", designSystem.customProperties.borderRadius6, ";color:", designSystem.customProperties.colorSolid, ";font-family:inherit;font-size:", designSystem.customProperties.fontSizeDefault, ";" + ("" ));
|
|
94
|
+
var baseContainerStyles = /*#__PURE__*/react.css("position:relative;min-width:", designSystem.customProperties.constraint6, ";padding:0;display:flex;flex-direction:column;box-shadow:", designSystem.customProperties.shadow1, ";border-radius:", designSystem.customProperties.borderRadius6, ";color:", designSystem.customProperties.colorSolid, ";font-family:inherit;font-size:", designSystem.customProperties.fontSizeDefault, ";" + ("" ), "" );
|
|
92
95
|
|
|
93
|
-
var HeaderControlsWrapper = _styled__default[
|
|
94
|
-
target: "
|
|
95
|
-
} )("margin-left:", designSystem.customProperties.spacingM, ";display:flex;align-items:center;cursor:auto;");
|
|
96
|
+
var HeaderControlsWrapper = _styled__default["default"]("div", {
|
|
97
|
+
target: "em5v1nl2"
|
|
98
|
+
} )("margin-left:", designSystem.customProperties.spacingM, ";display:flex;align-items:center;cursor:auto;" + ("" ));
|
|
96
99
|
|
|
97
|
-
var SectionContent = _styled__default[
|
|
98
|
-
target: "
|
|
100
|
+
var SectionContent = _styled__default["default"]("div", {
|
|
101
|
+
target: "em5v1nl1"
|
|
99
102
|
} )({
|
|
100
103
|
name: "esy9f9",
|
|
101
104
|
styles: "width:100%;display:flex;flex-wrap:wrap;align-items:flex-start"
|
|
102
105
|
} );
|
|
103
106
|
|
|
104
|
-
var SectionWrapper = _styled__default[
|
|
105
|
-
target: "
|
|
106
|
-
} )("border-top:1px solid ", designSystem.customProperties.colorNeutral60, ";");
|
|
107
|
+
var SectionWrapper = _styled__default["default"]("div", {
|
|
108
|
+
target: "em5v1nl0"
|
|
109
|
+
} )("border-top:1px solid ", designSystem.customProperties.colorNeutral60, ";" + ("" ));
|
|
107
110
|
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
var CollapsiblePanelHeader = function CollapsiblePanelHeader(props) {
|
|
112
|
+
return jsxRuntime.jsx(Text__default["default"].Subheadline, {
|
|
113
|
+
as: "h4",
|
|
114
|
+
isBold: true,
|
|
115
|
+
truncate: true,
|
|
116
|
+
children: props.children
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
CollapsiblePanelHeader.propTypes = {};
|
|
121
|
+
CollapsiblePanelHeader.displayName = 'CollapsiblePanelHeader';
|
|
122
|
+
var CollapsiblePanelHeader$1 = CollapsiblePanelHeader;
|
|
123
|
+
|
|
124
|
+
var HeaderContainer = /*#__PURE__*/_styled__default["default"](AccessibleButton__default["default"], {
|
|
125
|
+
target: "e1923bli0"
|
|
126
|
+
} )("" );
|
|
111
127
|
|
|
112
128
|
var panelContentIdPrefix = 'panel-content-';
|
|
113
129
|
|
|
114
130
|
var getPanelContentId = function getPanelContentId(id) {
|
|
115
131
|
return panelContentIdPrefix + id;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
var defaultProps = {
|
|
135
|
+
id: uniqueId__default["default"](),
|
|
136
|
+
theme: 'dark',
|
|
137
|
+
condensed: false,
|
|
138
|
+
isDisabled: false,
|
|
139
|
+
headerControlsAlignment: 'right',
|
|
140
|
+
horizontalConstraint: 'scale'
|
|
116
141
|
}; // When `isClosed` is provided the component behaves as a controlled component,
|
|
117
142
|
// otherwise it will behave like an uncontrolled component.
|
|
118
143
|
|
|
119
|
-
|
|
120
144
|
var CollapsiblePanel = function CollapsiblePanel(props) {
|
|
121
145
|
var panelContentId = getPanelContentId(props.id); // Pass only `data-*` props
|
|
122
146
|
|
|
123
147
|
var dataProps = utils.filterDataAttributes(props);
|
|
124
148
|
var scale = props.condensed ? 's' : 'm';
|
|
125
|
-
|
|
149
|
+
!isNil__default["default"](props.isClosed) && !isNil__default["default"](props.isDefaultClosed);
|
|
150
|
+
!isNil__default["default"](props.onToggle);
|
|
151
|
+
!isNil__default["default"](props.isClosed); // controlled
|
|
152
|
+
|
|
153
|
+
return jsxRuntime.jsx(CollapsibleMotion__default["default"], {
|
|
126
154
|
isClosed: props.isClosed,
|
|
127
155
|
onToggle: props.onToggle,
|
|
128
|
-
isDefaultClosed: props.isDefaultClosed
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
156
|
+
isDefaultClosed: props.isDefaultClosed,
|
|
157
|
+
children: function children(_ref) {
|
|
158
|
+
var isOpen = _ref.isOpen,
|
|
159
|
+
toggle = _ref.toggle,
|
|
160
|
+
containerStyles = _ref.containerStyles,
|
|
161
|
+
registerContentNode = _ref.registerContentNode;
|
|
162
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
163
|
+
max: props.horizontalConstraint,
|
|
164
|
+
children: jsxRuntime.jsxs("div", {
|
|
165
|
+
css: [baseContainerStyles, getThemeStyle(props.theme), "" , "" ] // Allow to override the styles by passing a `className` prop.
|
|
166
|
+
// Custom styles can also be passed using the `css` prop from emotion.
|
|
167
|
+
// https://emotion.sh/docs/css-prop#style-precedence
|
|
168
|
+
,
|
|
169
|
+
className: props.className,
|
|
170
|
+
children: [jsxRuntime.jsxs(HeaderContainer, {
|
|
171
|
+
as: "div",
|
|
172
|
+
css: [getHeaderContainerStyles(props, isOpen), getThemeStyle(props.theme), "" , "" ],
|
|
173
|
+
id: props.id,
|
|
174
|
+
label: "",
|
|
175
|
+
onClick: props.isDisabled ? undefined : toggle,
|
|
176
|
+
isDisabled: props.isDisabled,
|
|
177
|
+
buttonAttributes: dataProps,
|
|
178
|
+
"aria-controls": panelContentId,
|
|
179
|
+
"aria-expanded": isOpen ? 'true' : 'false',
|
|
180
|
+
children: [jsxRuntime.jsxs(Spacings__default["default"].Inline, {
|
|
181
|
+
alignItems: "center",
|
|
182
|
+
scale: "s",
|
|
183
|
+
children: [!props.hideExpansionControls && jsxRuntime.jsx(HeaderIcon$1, {
|
|
184
|
+
isClosed: !isOpen,
|
|
185
|
+
isDisabled: props.isDisabled || false,
|
|
186
|
+
tone: props.tone,
|
|
187
|
+
size: props.condensed ? 'small' : 'medium'
|
|
188
|
+
}), jsxRuntime.jsxs(Spacings__default["default"].Inline, {
|
|
189
|
+
alignItems: "center",
|
|
190
|
+
scale: scale,
|
|
191
|
+
children: [props.condensed ? jsxRuntime.jsx(Text__default["default"].Detail, {
|
|
192
|
+
as: "span",
|
|
193
|
+
isBold: true,
|
|
194
|
+
truncate: true,
|
|
195
|
+
children: props.header
|
|
196
|
+
}) : props.header, props.secondaryHeader && jsxRuntime.jsx(Text__default["default"].Detail, {
|
|
197
|
+
tone: "secondary",
|
|
198
|
+
truncate: true,
|
|
199
|
+
children: props.secondaryHeader
|
|
200
|
+
})]
|
|
201
|
+
})]
|
|
202
|
+
}), props.headerControls && jsxRuntime.jsx(HeaderControlsWrapper, {
|
|
203
|
+
onClick: function onClick(event) {
|
|
204
|
+
return event.stopPropagation();
|
|
205
|
+
},
|
|
206
|
+
children: props.headerControls
|
|
207
|
+
})]
|
|
208
|
+
}), jsxRuntime.jsx("div", {
|
|
209
|
+
style: containerStyles,
|
|
210
|
+
children: jsxRuntime.jsxs(SectionWrapper, {
|
|
211
|
+
ref: registerContentNode,
|
|
212
|
+
children: [props.description && jsxRuntime.jsx(Spacings__default["default"].Inset, {
|
|
213
|
+
scale: scale,
|
|
214
|
+
children: jsxRuntime.jsx(Text__default["default"].Detail, {
|
|
215
|
+
children: props.description
|
|
216
|
+
})
|
|
217
|
+
}), jsxRuntime.jsx(Spacings__default["default"].Inset, {
|
|
218
|
+
scale: scale,
|
|
219
|
+
children: jsxRuntime.jsx(SectionContent, {
|
|
220
|
+
id: panelContentId,
|
|
221
|
+
"aria-hidden": isOpen ? 'false' : 'true',
|
|
222
|
+
children: props.children
|
|
223
|
+
})
|
|
224
|
+
})]
|
|
225
|
+
})
|
|
226
|
+
})]
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
}
|
|
187
230
|
});
|
|
188
231
|
};
|
|
189
232
|
|
|
233
|
+
CollapsiblePanel.propTypes = {};
|
|
190
234
|
CollapsiblePanel.getPanelContentId = getPanelContentId;
|
|
191
235
|
CollapsiblePanel.displayName = 'CollapsiblePanel';
|
|
192
|
-
CollapsiblePanel.
|
|
193
|
-
CollapsiblePanel.
|
|
194
|
-
|
|
195
|
-
theme: 'dark',
|
|
196
|
-
condensed: false,
|
|
197
|
-
isDisabled: false,
|
|
198
|
-
headerControlsAlignment: 'right',
|
|
199
|
-
horizontalConstraint: 'scale'
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
var CollapsiblePanelHeader = function CollapsiblePanelHeader(props) {
|
|
203
|
-
return react.jsx(Text__default['default'].Subheadline, {
|
|
204
|
-
as: "h4",
|
|
205
|
-
isBold: true,
|
|
206
|
-
truncate: true
|
|
207
|
-
}, props.children);
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
CollapsiblePanelHeader.displayName = 'CollapsiblePanelHeader';
|
|
211
|
-
CollapsiblePanelHeader.propTypes = {};
|
|
212
|
-
|
|
213
|
-
// NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
|
|
214
|
-
var version = '12.2.1';
|
|
236
|
+
CollapsiblePanel.defaultProps = defaultProps;
|
|
237
|
+
CollapsiblePanel.Header = CollapsiblePanelHeader$1;
|
|
238
|
+
var CollapsiblePanel$1 = CollapsiblePanel;
|
|
215
239
|
|
|
216
|
-
|
|
240
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
241
|
+
var version = "12.2.5";
|
|
217
242
|
|
|
218
|
-
exports
|
|
243
|
+
exports["default"] = CollapsiblePanel$1;
|
|
219
244
|
exports.version = version;
|