@bigbinary/neeto-molecules 1.4.6-beta.1 → 1.4.7-beta

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/dist/Builder.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import React, { useState, useMemo, memo, useRef, useEffect } from 'react';
2
- import classnames from 'classnames';
3
2
  import { noop, isPresent, isNotEmpty, findById, hyphenate } from '@bigbinary/neeto-cist';
4
- import { useBreakpoints, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
5
- import { Search, MenuVertical, MenuHorizontal, Flash, Collapse, DownArrow, Close } from '@bigbinary/neeto-icons';
6
- import { Typography, Button, Input, Dropdown, Tooltip } from '@bigbinary/neetoui';
7
3
  import { isEmpty, mergeRight } from 'ramda';
8
4
  import { joinHyphenCase, withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
5
+ import { Search, MenuVertical, MenuHorizontal, Flash, DownArrow } from '@bigbinary/neeto-icons';
6
+ import { Typography, Button, Input, Dropdown, Tooltip } from '@bigbinary/neetoui';
9
7
  import { useTranslation } from 'react-i18next';
8
+ import classnames from 'classnames';
10
9
  import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
11
10
  import { PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
11
+ import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
12
12
 
13
13
  function _arrayWithHoles(arr) {
14
14
  if (Array.isArray(arr)) return arr;
@@ -106,6 +106,18 @@ function _defineProperty(obj, key, value) {
106
106
  return obj;
107
107
  }
108
108
 
109
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
110
+
111
+ var css = ":root{--neeto-molecule-builder-left-sidebar-width:360px;--neeto-molecule-builder-left-sidebar-header-height:70px;--neeto-molecule-builder-left-sidebar-search-height:40px;--neeto-molecule-builder-right-sidebar-width:420px}.neeto-molecules-builder-elements-list-panel{height:100%;min-width:360px;min-width:var(--neeto-molecule-builder-left-sidebar-width);width:360px;width:var(--neeto-molecule-builder-left-sidebar-width)}.neeto-molecules-builder-questions-list-panel__scroll{height:calc(100% - 70px);height:calc(100% - var(--neeto-molecule-builder-left-sidebar-header-height));overflow-y:auto;padding:8px 24px}.neeto-molecules-builder-questions-list-panel__scroll.neeto-molecules-builder-questions-list-panel__scroll--small{height:calc(100% - 110px);height:calc(100% - var(--neeto-molecule-builder-left-sidebar-header-height) - var(--neeto-molecule-builder-left-sidebar-search-height))}.neeto-molecules-builder-elements-list{margin-bottom:24px}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper{border-bottom:none}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item{padding:12px 0}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item .neeto-ui-accordion__item-handle{color:rgb(var(--neeto-ui-gray-600));font-size:var(--neeto-ui-text-xs);font-weight:var(--neeto-ui-font-semibold);text-transform:uppercase;transition:var(--neeto-ui-transition)}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item .neeto-ui-accordion__item-toggle-icon{transform:rotate(90deg)!important}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item:hover{background-color:transparent}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item.neeto-ui-accordion__item--open .neeto-ui-accordion__item-handle,.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item:hover .neeto-ui-accordion__item-handle{color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__item.neeto-ui-accordion__item--open .neeto-ui-accordion__item-toggle-icon{transform:rotate(270deg)!important}.neeto-molecules-builder-elements-list .neeto-ui-accordion__wrapper .neeto-ui-accordion__drop{padding:0}.neeto-molecules-builder-element-properties-panel{height:100%;min-width:420px;min-width:var(--neeto-molecule-builder-right-sidebar-width);padding-left:24px;padding-top:24px;width:420px;width:var(--neeto-molecule-builder-right-sidebar-width)}.neeto-molecules-builder-element--active{border-color:rgb(var(--neeto-ui-primary-500))!important;box-shadow:0 0 0 1px rgb(var(--neeto-ui-primary-500))!important}";
112
+ n(css,{});
113
+
114
+ var Body = function Body(props) {
115
+ return /*#__PURE__*/React.createElement("div", {
116
+ className: "neeto-molecules-builder-questions-list-panel__scroll neeto-molecules-builder-questions-list-panel__scroll--small",
117
+ "data-testid": props["data-testid"]
118
+ }, props.children);
119
+ };
120
+
109
121
  function _extends() {
110
122
  _extends = Object.assign ? Object.assign.bind() : function (target) {
111
123
  for (var i = 1; i < arguments.length; i++) {
@@ -121,51 +133,6 @@ function _extends() {
121
133
  return _extends.apply(this, arguments);
122
134
  }
123
135
 
124
- function _objectWithoutPropertiesLoose(source, excluded) {
125
- if (source == null) return {};
126
- var target = {};
127
- var sourceKeys = Object.keys(source);
128
- var key, i;
129
- for (i = 0; i < sourceKeys.length; i++) {
130
- key = sourceKeys[i];
131
- if (excluded.indexOf(key) >= 0) continue;
132
- target[key] = source[key];
133
- }
134
- return target;
135
- }
136
-
137
- function _objectWithoutProperties(source, excluded) {
138
- if (source == null) return {};
139
- var target = _objectWithoutPropertiesLoose(source, excluded);
140
- var key, i;
141
- if (Object.getOwnPropertySymbols) {
142
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
143
- for (i = 0; i < sourceSymbolKeys.length; i++) {
144
- key = sourceSymbolKeys[i];
145
- if (excluded.indexOf(key) >= 0) continue;
146
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
147
- target[key] = source[key];
148
- }
149
- }
150
- return target;
151
- }
152
-
153
- var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
154
-
155
- var css = ":root{--neeto-molecule-builder-left-sidebar-width:288px;--neeto-molecule-builder-left-sidebar-width-lg:360px;--neeto-molecule-builder-left-sidebar-header-height:70px;--neeto-molecule-builder-left-sidebar-search-height:40px;--neeto-molecule-builder-right-sidebar-width:420px}.neeto-molecules-builder-elements-list-panel__wrapper{height:100%;min-width:360px;min-width:var(--neeto-molecule-builder-left-sidebar-width-lg);position:relative;transition:all .15s;width:360px;width:var(--neeto-molecule-builder-left-sidebar-width-lg);z-index:51}@media screen and (min-width:768px) and (max-width:1279px){.neeto-molecules-builder-elements-list-panel__wrapper{min-width:288px;min-width:var(--neeto-molecule-builder-left-sidebar-width);width:288px;width:var(--neeto-molecule-builder-left-sidebar-width)}}@media screen and (max-width:767px){.neeto-molecules-builder-elements-list-panel__wrapper{left:0;position:fixed;top:0;transition:none}}@media screen and (max-width:576px){.neeto-molecules-builder-elements-list-panel__wrapper{height:100%;max-width:100%;min-width:0;width:100%}}.neeto-molecules-builder-elements-list-panel__wrapper--collapsed{max-width:0;min-width:0;width:0}.neeto-molecules-builder-elements-list-panel__wrapper--collapsed .neeto-molecules-builder-elements-list-panel__toggler{transform:scale(-1)}@media screen and (max-width:767px){.neeto-molecules-builder-elements-list-panel__wrapper--collapsed .neeto-molecules-builder-elements-list-panel__toggler{top:72px}}@media screen and (max-width:576px){.neeto-molecules-builder-elements-list-panel__wrapper--collapsed .neeto-molecules-builder-elements-list-panel__toggler{left:8px;right:auto}}.neeto-molecules-builder-elements-list-panel__container{height:100%;overflow:hidden;width:100%}.neeto-molecules-builder-elements-list-panel{height:100%;min-width:360px;min-width:var(--neeto-molecule-builder-left-sidebar-width-lg);width:360px;width:var(--neeto-molecule-builder-left-sidebar-width-lg)}@media screen and (min-width:768px) and (max-width:1279px){.neeto-molecules-builder-elements-list-panel{min-width:288px;min-width:var(--neeto-molecule-builder-left-sidebar-width);width:288px;width:var(--neeto-molecule-builder-left-sidebar-width)}}@media screen and (max-width:576px){.neeto-molecules-builder-elements-list-panel{padding-top:24px;width:100%}}.neeto-molecules-builder-elements-list-panel__toggler{flex-shrink:0;left:calc(100% + 8px);position:absolute;top:8px;transition:color .3s ease-in-out}@media screen and (min-width:1024px){.neeto-molecules-builder-elements-list-panel__toggler{opacity:0;pointer-events:none}}@media screen and (max-width:576px){.neeto-molecules-builder-elements-list-panel__toggler{left:24px}}.neeto-molecules-builder-questions-list-panel__scroll{height:calc(100% - 70px);height:calc(100% - var(--neeto-molecule-builder-left-sidebar-header-height));overflow-y:auto;padding:8px 24px;width:100%}.neeto-molecules-builder-questions-list-panel__scroll.neeto-molecules-builder-questions-list-panel__scroll--small{height:calc(100% - 110px);height:calc(100% - var(--neeto-molecule-builder-left-sidebar-header-height) - var(--neeto-molecule-builder-left-sidebar-search-height))}.neeto-molecules-builder-element-properties-panel__wrapper{height:100%;min-width:420px;min-width:var(--neeto-molecule-builder-right-sidebar-width);position:relative;transition:all .15s;width:420px;width:var(--neeto-molecule-builder-right-sidebar-width);z-index:51}.neeto-molecules-builder-element-properties-panel__wrapper .neeto-molecules-builder-properties-panel__close{opacity:0;pointer-events:none;position:absolute;right:8px;top:8px}@media screen and (max-width:1279px){.neeto-molecules-builder-element-properties-panel__wrapper .neeto-molecules-builder-properties-panel__close{opacity:1;pointer-events:all}.neeto-molecules-builder-element-properties-panel__wrapper{position:fixed;right:0;top:0;transition:none}}@media screen and (max-width:576px){.neeto-molecules-builder-element-properties-panel__wrapper{height:100%;max-width:100%;min-width:0;width:100%}}.neeto-molecules-builder-element-properties-panel__wrapper--collapsed{max-width:0;min-width:0;width:0}.neeto-molecules-builder-element-properties-panel{display:flex;flex-direction:column;height:100%;min-width:0;overflow-y:auto;padding-left:24px;padding-top:24px;width:100%}.neeto-molecules-builder-element-properties-panel--collapsed{max-width:0;min-width:0;padding:0;width:0}@media screen and (max-width:1279px){.neeto-molecules-builder-element-properties-panel{padding-top:48px}}.neeto-molecules-builder-element--active{border-color:rgb(var(--neeto-ui-primary-500))!important;box-shadow:0 0 0 1px rgb(var(--neeto-ui-primary-500))!important}.neeto-molecules-builder-panel__backdrop{background-color:rgba(var(--neeto-ui-black),.4);display:none;height:100%;left:0;position:absolute;top:0;visibility:hidden;width:100%;z-index:51}@media screen and (max-width:767px){.neeto-molecules-builder-panel__backdrop{display:block;visibility:visible}}@media screen and (max-width:1279px){.neeto-molecules-builder-panel__backdrop--extended{display:block;visibility:visible}}";
156
- n(css,{});
157
-
158
- var _excluded$4 = ["size"];
159
- var Body = function Body(_ref) {
160
- var size = _ref.size,
161
- props = _objectWithoutProperties(_ref, _excluded$4);
162
- return /*#__PURE__*/React.createElement("div", _extends({}, props, {
163
- className: classnames("neeto-molecules-builder-questions-list-panel__scroll", {
164
- "neeto-molecules-builder-questions-list-panel__scroll--small": size === "small"
165
- })
166
- }));
167
- };
168
-
169
136
  var Element = function Element(_ref) {
170
137
  var label = _ref.label,
171
138
  Icon = _ref.icon,
@@ -274,19 +241,49 @@ var ElementList = function ElementList(_ref) {
274
241
  value: searchString,
275
242
  onChange: withEventTargetValue(setSearchString)
276
243
  })), /*#__PURE__*/React.createElement(Body, {
277
- "data-testid": "elements-container",
278
- size: "small"
244
+ "data-testid": "elements-container"
245
+ }, /*#__PURE__*/React.createElement("div", {
246
+ className: "neeto-molecules-builder-questions-list-panel__scroll--small"
279
247
  }, filteredSections.map(function (section) {
280
248
  return /*#__PURE__*/React.createElement(Section, {
281
- onSelect: onSelect,
282
249
  elements: section.elements,
283
250
  isCreatable: section.isCreatable,
284
251
  key: section.key,
285
- title: section.title
252
+ title: section.title,
253
+ onSelect: onSelect
286
254
  });
287
- })));
255
+ }))));
288
256
  };
289
257
 
258
+ function _objectWithoutPropertiesLoose(source, excluded) {
259
+ if (source == null) return {};
260
+ var target = {};
261
+ var sourceKeys = Object.keys(source);
262
+ var key, i;
263
+ for (i = 0; i < sourceKeys.length; i++) {
264
+ key = sourceKeys[i];
265
+ if (excluded.indexOf(key) >= 0) continue;
266
+ target[key] = source[key];
267
+ }
268
+ return target;
269
+ }
270
+
271
+ function _objectWithoutProperties(source, excluded) {
272
+ if (source == null) return {};
273
+ var target = _objectWithoutPropertiesLoose(source, excluded);
274
+ var key, i;
275
+ if (Object.getOwnPropertySymbols) {
276
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
277
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
278
+ key = sourceSymbolKeys[i];
279
+ if (excluded.indexOf(key) >= 0) continue;
280
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
281
+ target[key] = source[key];
282
+ }
283
+ }
284
+ return target;
285
+ }
286
+
290
287
  var MENU_ITEM_TYPES = {
291
288
  menuItem: "menuItem",
292
289
  divider: "divider"
@@ -626,34 +623,13 @@ var ElementsPanel = function ElementsPanel(_ref) {
626
623
  _useState2 = _slicedToArray(_useState, 2),
627
624
  isElementsListVisible = _useState2[0],
628
625
  setIsElementsListVisible = _useState2[1];
629
- var _useBreakpoints = useBreakpoints(),
630
- isSize = _useBreakpoints.isSize;
631
- var isLargerScreen = !isSize("mobile");
632
- var _useState3 = useState(!isLargerScreen),
633
- _useState4 = _slicedToArray(_useState3, 2),
634
- isElementsPanelCollapsed = _useState4[0],
635
- setIsElementsPanelCollapsed = _useState4[1];
636
626
  var isSelectedElementsEmpty = isEmpty(selectedElements);
637
627
  var shouldShowElementsList = isSelectedElementsEmpty || isElementsListVisible;
638
628
  var handleElementSelect = function handleElementSelect(element) {
639
629
  setIsElementsListVisible(false);
640
630
  handleAddElement(element);
641
631
  };
642
- useEffect(function () {
643
- setIsElementsPanelCollapsed(!isLargerScreen);
644
- }, [isLargerScreen]);
645
- return /*#__PURE__*/React.createElement(React.Fragment, null, !isElementsPanelCollapsed && /*#__PURE__*/React.createElement("div", {
646
- className: "neeto-molecules-builder-panel__backdrop",
647
- onClick: function onClick() {
648
- setIsElementsPanelCollapsed(!isElementsPanelCollapsed);
649
- }
650
- }), /*#__PURE__*/React.createElement("div", {
651
- className: classnames("neeto-molecules-builder-elements-list-panel__wrapper", {
652
- "neeto-molecules-builder-elements-list-panel__wrapper--collapsed": isElementsPanelCollapsed
653
- })
654
- }, /*#__PURE__*/React.createElement("div", {
655
- className: "neeto-molecules-builder-elements-list-panel__container"
656
- }, /*#__PURE__*/React.createElement("div", {
632
+ return /*#__PURE__*/React.createElement("div", {
657
633
  className: "neeto-molecules-builder-elements-list-panel neeto-ui-bg-gray-100",
658
634
  onClick: function onClick(event) {
659
635
  return event.stopPropagation();
@@ -680,20 +656,13 @@ var ElementsPanel = function ElementsPanel(_ref) {
680
656
  selectedElements: selectedElements,
681
657
  setIsElementsListVisible: setIsElementsListVisible,
682
658
  showElementsFillButton: showElementsFillButton
683
- }))), /*#__PURE__*/React.createElement(Button, {
684
- className: "neeto-molecules-builder-elements-list-panel__toggler",
685
- icon: Collapse,
686
- style: "secondary",
687
- onClick: function onClick() {
688
- setIsElementsPanelCollapsed(!isElementsPanelCollapsed);
689
- }
690
- })));
659
+ }));
691
660
  };
692
661
 
693
662
  var EmptyProperty = withT(function (_ref) {
694
663
  var t = _ref.t;
695
664
  return /*#__PURE__*/React.createElement("div", {
696
- className: "space-y-4 pr-6 pb-6"
665
+ className: "space-y-4 "
697
666
  }, /*#__PURE__*/React.createElement("div", {
698
667
  className: "neeto-ui-bg-gray-200 neeto-ui-text-gray-600 neeto-ui-rounded-lg flex w-full flex-col items-center justify-center space-y-2 px-16 py-8"
699
668
  }, /*#__PURE__*/React.createElement(Typography, {
@@ -711,7 +680,7 @@ var EmptyProperty = withT(function (_ref) {
711
680
  var Skeleton = withT(function (_ref) {
712
681
  var t = _ref.t;
713
682
  return /*#__PURE__*/React.createElement("div", {
714
- className: "space-y-4 pr-6 pb-6"
683
+ className: "space-y-4 pr-6"
715
684
  }, /*#__PURE__*/React.createElement("div", {
716
685
  className: "neeto-ui-bg-gray-200 neeto-ui-rounded-lg h-12 w-full"
717
686
  }), /*#__PURE__*/React.createElement("div", {
@@ -729,45 +698,10 @@ var Skeleton = withT(function (_ref) {
729
698
  });
730
699
 
731
700
  var PropertiesPanel = function PropertiesPanel(_ref) {
732
- var id = _ref.id,
733
- children = _ref.children;
734
- var _useBreakpoints = useBreakpoints(function (window) {
735
- return {
736
- largeDesktop: window.innerWidth >= 1280
737
- };
738
- }),
739
- isSize = _useBreakpoints.isSize;
740
- var isLargerScreen = isSize("largeDesktop");
741
- var _useState = useState(!isLargerScreen),
742
- _useState2 = _slicedToArray(_useState, 2),
743
- isPropertiesPanelCollapsed = _useState2[0],
744
- setIsPropertiesPanelCollapsed = _useState2[1];
745
- useEffect(function () {
746
- setIsPropertiesPanelCollapsed(!isLargerScreen);
747
- }, [isLargerScreen]);
748
- useEffect(function () {
749
- if (!id) return;
750
- setIsPropertiesPanelCollapsed(false);
751
- }, [id]);
752
- return /*#__PURE__*/React.createElement(React.Fragment, null, !isPropertiesPanelCollapsed && /*#__PURE__*/React.createElement("div", {
753
- className: "neeto-molecules-builder-panel__backdrop neeto-molecules-builder-panel__backdrop--extended",
754
- onClick: function onClick() {
755
- setIsPropertiesPanelCollapsed(!isPropertiesPanelCollapsed);
756
- }
757
- }), /*#__PURE__*/React.createElement("div", {
758
- className: classnames("neeto-molecules-builder-element-properties-panel__wrapper", {
759
- "neeto-molecules-builder-element-properties-panel__wrapper--collapsed": isPropertiesPanelCollapsed
760
- })
761
- }, /*#__PURE__*/React.createElement("div", {
701
+ var children = _ref.children;
702
+ return /*#__PURE__*/React.createElement("div", {
762
703
  className: "neeto-molecules-builder-element-properties-panel neeto-ui-bg-gray-100"
763
- }, children !== null && children !== void 0 ? children : /*#__PURE__*/React.createElement(Skeleton, null)), !isPropertiesPanelCollapsed && /*#__PURE__*/React.createElement(Button, {
764
- className: "neeto-molecules-builder-properties-panel__close",
765
- icon: Close,
766
- style: "secondary",
767
- onClick: function onClick() {
768
- setIsPropertiesPanelCollapsed(!isPropertiesPanelCollapsed);
769
- }
770
- })));
704
+ }, children !== null && children !== void 0 ? children : /*#__PURE__*/React.createElement(Skeleton, null));
771
705
  };
772
706
  PropertiesPanel.EmptyProperty = EmptyProperty;
773
707