@commercetools-uikit/primary-action-dropdown 12.2.3 → 12.2.7

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.
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
6
  var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
7
7
  var _styled = require('@emotion/styled/base');
8
+ require('prop-types');
8
9
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
9
10
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
10
- var react$1 = require('react');
11
- var PropTypes = require('prop-types');
12
- var react = require('@emotion/react');
11
+ var react = require('react');
12
+ var react$1 = require('@emotion/react');
13
13
  var AccessibleButton = require('@commercetools-uikit/accessible-button');
14
14
  var designSystem = require('@commercetools-uikit/design-system');
15
15
  var Text = require('@commercetools-uikit/text');
@@ -23,18 +23,17 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
23
23
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
24
24
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
25
25
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
26
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
27
26
  var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
28
27
  var Text__default = /*#__PURE__*/_interopDefault(Text);
29
28
 
30
29
  var getButtonStyles = function getButtonStyles(isDisabled) {
31
- var baseButtonStyles = /*#__PURE__*/react.css("display:flex;align-items:center;height:", designSystem.customProperties.bigButtonHeight, ";" + ("" ), "" );
30
+ var baseButtonStyles = /*#__PURE__*/react$1.css("display:flex;align-items:center;height:", designSystem.customProperties.bigButtonHeight, ";" + ("" ), "" );
32
31
 
33
32
  if (isDisabled) {
34
- return [baseButtonStyles, /*#__PURE__*/react.css("box-shadow:none;background-color:", designSystem.customProperties.colorAccent98, ";" + ("" ), "" )];
33
+ return [baseButtonStyles, /*#__PURE__*/react$1.css("box-shadow:none;background-color:", designSystem.customProperties.colorAccent98, ";" + ("" ), "" )];
35
34
  }
36
35
 
37
- return [baseButtonStyles, /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorSurface, ";box-shadow:", designSystem.customProperties.shadow7, ";&:hover{box-shadow:", designSystem.customProperties.shadow8, ";}&:active{box-shadow:", designSystem.customProperties.shadow9, ";background-color:", designSystem.customProperties.colorNeutral95, ";}" + ("" ), "" )];
36
+ return [baseButtonStyles, /*#__PURE__*/react$1.css("background-color:", designSystem.customProperties.colorSurface, ";box-shadow:", designSystem.customProperties.shadow7, ";&:hover{box-shadow:", designSystem.customProperties.shadow8, ";}&:active{box-shadow:", designSystem.customProperties.shadow9, ";background-color:", designSystem.customProperties.colorNeutral95, ";}" + ("" ), "" )];
38
37
  };
39
38
 
40
39
  var _ref3 = {
@@ -47,20 +46,20 @@ var DropdownHead = function DropdownHead(props) {
47
46
 
48
47
  return jsxRuntime.jsxs("div", {
49
48
  css: _ref3,
50
- children: [jsxRuntime.jsxs(AccessibleButton__default['default'], {
49
+ children: [jsxRuntime.jsxs(AccessibleButton__default["default"], {
51
50
  label: props.children,
52
51
  onClick: props.onClick,
53
52
  isDisabled: props.isDisabled,
54
- css: _concatInstanceProperty__default['default'](_context = []).call(_context, _toConsumableArray(getButtonStyles(props.isDisabled)), [/*#__PURE__*/react.css("padding:0 ", designSystem.customProperties.spacingS, ";border-radius:", designSystem.customProperties.borderRadius6, " 0 0 ", designSystem.customProperties.borderRadius6, ";" + ("" ), "" ), "" ]),
53
+ css: _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray(getButtonStyles(props.isDisabled)), [/*#__PURE__*/react$1.css("padding:0 ", designSystem.customProperties.spacingS, ";border-radius:", designSystem.customProperties.borderRadius6, " 0 0 ", designSystem.customProperties.borderRadius6, ";" + ("" ), "" ), "" ]),
55
54
  children: [jsxRuntime.jsx("span", {
56
- css: /*#__PURE__*/react.css("margin:0 ", designSystem.customProperties.spacingXs, " 0 0;display:flex;align-items:center;justify-content:center;" + ("" ), "" ),
57
- children: /*#__PURE__*/react$1.cloneElement(props.iconLeft, {
55
+ css: /*#__PURE__*/react$1.css("margin:0 ", designSystem.customProperties.spacingXs, " 0 0;display:flex;align-items:center;justify-content:center;" + ("" ), "" ),
56
+ children: /*#__PURE__*/react.cloneElement(props.iconLeft, {
58
57
  size: 'big',
59
58
  color: props.isDisabled ? 'neutral60' : 'solid'
60
59
  })
61
60
  }), jsxRuntime.jsx("span", {
62
- css: /*#__PURE__*/react.css("margin:0 ", designSystem.customProperties.spacingXs, " 0 0;display:flex;align-items:center;justify-content:center;" + ("" ), "" ),
63
- children: jsxRuntime.jsx(Text__default['default'].Detail, {
61
+ css: /*#__PURE__*/react$1.css("margin:0 ", designSystem.customProperties.spacingXs, " 0 0;display:flex;align-items:center;justify-content:center;" + ("" ), "" ),
62
+ children: jsxRuntime.jsx(Text__default["default"].Detail, {
64
63
  tone: props.isDisabled ? 'secondary' : undefined,
65
64
  children: props.children
66
65
  })
@@ -69,28 +68,27 @@ var DropdownHead = function DropdownHead(props) {
69
68
  });
70
69
  };
71
70
 
72
- DropdownHead.displayName = 'DropdownHead';
73
71
  DropdownHead.propTypes = {};
72
+ DropdownHead.displayName = 'DropdownHead';
74
73
 
75
74
  var _ref2 = {
76
75
  name: "1jklb6q",
77
76
  styles: "pointer-events:none;margin-top:3px"
78
77
  } ;
79
78
 
80
- var DropdownChevron = /*#__PURE__*/react$1.forwardRef(function (props, ref) {
79
+ var DropdownChevron = /*#__PURE__*/react.forwardRef(function (props, ref) {
81
80
  var _context2;
82
81
 
83
- return jsxRuntime.jsx(AccessibleButton__default['default'], {
82
+ return jsxRuntime.jsx(AccessibleButton__default["default"], {
84
83
  ref: ref,
85
84
  label: "Open Dropdown",
86
85
  onClick: props.onClick,
87
86
  isDisabled: props.isDisabled,
88
- isOpen: props.isOpen,
89
- css: _concatInstanceProperty__default['default'](_context2 = []).call(_context2, _toConsumableArray(getButtonStyles(props.isDisabled)), [/*#__PURE__*/react.css("padding:0 ", designSystem.customProperties.spacingXs, ";border-left:1px solid ", designSystem.customProperties.colorNeutral, ";border-radius:0 ", designSystem.customProperties.borderRadius6, " ", designSystem.customProperties.borderRadius6, " 0;" + ("" ), "" ), "" ]),
87
+ css: _concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(getButtonStyles(props.isDisabled)), [/*#__PURE__*/react$1.css("padding:0 ", designSystem.customProperties.spacingXs, ";border-left:1px solid ", designSystem.customProperties.colorNeutral, ";border-radius:0 ", designSystem.customProperties.borderRadius6, " ", designSystem.customProperties.borderRadius6, " 0;" + ("" ), "" ), "" ]),
90
88
  children: jsxRuntime.jsx("div", {
91
89
  // The margin-top is to center the icon as the caret visually looks too high otherwise
92
90
  css: _ref2,
93
- children: /*#__PURE__*/react$1.cloneElement(props.isOpen && !props.isDisabled ? jsxRuntime.jsx(icons.CaretUpIcon, {}) : jsxRuntime.jsx(icons.CaretDownIcon, {}), {
91
+ children: /*#__PURE__*/react.cloneElement(props.isOpen && !props.isDisabled ? jsxRuntime.jsx(icons.CaretUpIcon, {}) : jsxRuntime.jsx(icons.CaretDownIcon, {}), {
94
92
  color: props.isDisabled ? 'neutral60' : 'solid',
95
93
  size: 'small'
96
94
  })
@@ -98,30 +96,10 @@ var DropdownChevron = /*#__PURE__*/react$1.forwardRef(function (props, ref) {
98
96
  });
99
97
  });
100
98
  DropdownChevron.displayName = 'DropdownChevron';
101
- DropdownChevron.propTypes = {
102
- onClick: PropTypes__default['default'].func.isRequired,
103
- isDisabled: PropTypes__default['default'].bool.isRequired,
104
- isOpen: PropTypes__default['default'].bool.isRequired
105
- };
106
99
 
107
- var Options = _styled__default['default']("div", {
108
- target: "e102bf7i0"
100
+ var Options = _styled__default["default"]("div", {
101
+ target: "eb24b7r0"
109
102
  } )("position:absolute;z-index:5;width:100%;top:calc(", designSystem.customProperties.spacingS, " + ", designSystem.customProperties.bigButtonHeight, ");left:0;border:1px solid ", designSystem.customProperties.colorNeutral, ";border-radius:", designSystem.customProperties.borderRadius6, ";box-shadow:", designSystem.customProperties.shadow1, ";" + ("" ));
110
-
111
- var Option = function Option(props) {
112
- return jsxRuntime.jsx(AccessibleButton__default['default'], {
113
- label: props.children,
114
- onClick: props.onClick,
115
- isDisabled: props.isDisabled,
116
- css: [/*#__PURE__*/react.css("display:block;text-align:left;width:100%;padding:", designSystem.customProperties.spacingS, ";background-color:", designSystem.customProperties.colorSurface, ";&:first-of-type{border-radius:", designSystem.customProperties.borderRadius6, " ", designSystem.customProperties.borderRadius6, " 0 0;}&:last-of-type{border-radius:0 0 ", designSystem.customProperties.borderRadius6, " ", designSystem.customProperties.borderRadius6, ";}&:hover{background-color:", designSystem.customProperties.colorNeutral95, ";}" + ("" ), "" ), props.isDisabled && /*#__PURE__*/react.css("color:", designSystem.customProperties.colorNeutral, ";" + ("" ), "" ), "" , "" ],
117
- children: props.children
118
- });
119
- };
120
- Option.displayName = 'Option';
121
- Option.propTypes = {};
122
- Option.defaultProps = {
123
- isDisabled: false
124
- };
125
103
  /*
126
104
  This component registers a global click event listener to close the dropdown.
127
105
  It uses this global listener to close when:
@@ -133,45 +111,46 @@ Option.defaultProps = {
133
111
  immediately.
134
112
  */
135
113
 
114
+
136
115
  var _ref = {
137
116
  name: "47yzp9",
138
117
  styles: "position:relative;display:inline-flex;align-items:column"
139
118
  } ;
140
119
 
141
120
  var PrimaryActionDropdown = function PrimaryActionDropdown(props) {
142
- var ref = react$1.useRef();
121
+ var ref = react.useRef();
143
122
 
144
123
  var _useToggleState = hooks.useToggleState(false),
145
124
  _useToggleState2 = _slicedToArray(_useToggleState, 2),
146
125
  isOpen = _useToggleState2[0],
147
126
  toggle = _useToggleState2[1];
148
127
 
149
- var handleGlobalClick = react$1.useCallback(function (event) {
128
+ var handleGlobalClick = react.useCallback(function (event) {
150
129
  var dropdownButton = ref.current;
151
130
 
152
131
  if (dropdownButton && event.target !== dropdownButton && !dropdownButton.contains(event.target)) {
153
132
  toggle(false);
154
133
  }
155
134
  }, [ref, toggle]);
156
- react$1.useEffect(function () {
135
+ react.useEffect(function () {
157
136
  window.addEventListener('click', handleGlobalClick);
158
137
  return function () {
159
138
  window.removeEventListener('click', handleGlobalClick);
160
139
  };
161
140
  }, [handleGlobalClick]);
162
- var childrenAsArray = react$1.Children.toArray(props.children);
163
- var primaryOption = _findInstanceProperty__default['default'](childrenAsArray).call(childrenAsArray, function (option) {
164
- return !option.props.isDisabled;
141
+ var childrenAsArray = react.Children.toArray(props.children);
142
+ var primaryOption = _findInstanceProperty__default["default"](childrenAsArray).call(childrenAsArray, function (option) {
143
+ return /*#__PURE__*/react.isValidElement(option) && !option.props.isDisabled;
165
144
  }) || childrenAsArray[0];
166
145
  var onClick = primaryOption.props.onClick;
167
- var handleClickOnHead = react$1.useCallback(function (event) {
146
+ var handleClickOnHead = react.useCallback(function (event) {
168
147
  if (isOpen) {
169
148
  toggle(true);
170
149
  } else {
171
150
  onClick(event);
172
151
  }
173
152
  }, [isOpen, onClick, toggle]);
174
- var handleClickOnChevron = react$1.useCallback(function () {
153
+ var handleClickOnChevron = react.useCallback(function () {
175
154
  toggle();
176
155
  }, [toggle]);
177
156
  return jsxRuntime.jsxs("div", {
@@ -193,13 +172,30 @@ var PrimaryActionDropdown = function PrimaryActionDropdown(props) {
193
172
  });
194
173
  };
195
174
 
196
- PrimaryActionDropdown.displayName = 'PrimaryActionDropdown';
197
175
  PrimaryActionDropdown.propTypes = {};
176
+ PrimaryActionDropdown.displayName = 'PrimaryActionDropdown';
198
177
  var PrimaryActionDropdown$1 = PrimaryActionDropdown;
199
178
 
200
- // NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
201
- var version = '12.2.3';
179
+ var Option = function Option(props) {
180
+ return jsxRuntime.jsx(AccessibleButton__default["default"], {
181
+ label: props.children,
182
+ onClick: props.onClick,
183
+ isDisabled: props.isDisabled,
184
+ css: [/*#__PURE__*/react$1.css("display:block;text-align:left;width:100%;padding:", designSystem.customProperties.spacingS, ";background-color:", designSystem.customProperties.colorSurface, ";&:first-of-type{border-radius:", designSystem.customProperties.borderRadius6, " ", designSystem.customProperties.borderRadius6, " 0 0;}&:last-of-type{border-radius:0 0 ", designSystem.customProperties.borderRadius6, " ", designSystem.customProperties.borderRadius6, ";}&:hover{background-color:", designSystem.customProperties.colorNeutral95, ";}" + ("" ), "" ), props.isDisabled && /*#__PURE__*/react$1.css("color:", designSystem.customProperties.colorNeutral, ";" + ("" ), "" ), "" , "" ],
185
+ children: props.children
186
+ });
187
+ };
188
+
189
+ Option.propTypes = {};
190
+ Option.displayName = 'Option';
191
+ Option.defaultProps = {
192
+ isDisabled: false
193
+ };
194
+ var Option$1 = Option;
195
+
196
+ // NOTE: This string will be replaced on build time with the package version.
197
+ var version = "12.2.7";
202
198
 
203
- exports.Option = Option;
204
- exports['default'] = PrimaryActionDropdown$1;
199
+ exports.Option = Option$1;
200
+ exports["default"] = PrimaryActionDropdown$1;
205
201
  exports.version = version;