@ntbjs/react-components 1.2.0-rc.8 → 1.2.0-rc.80

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.
Files changed (34) hide show
  1. package/{ActionButton-06df3d6c.js → ActionButton-46735b89.js} +13 -5
  2. package/{AssetGallery-46f5cbef.js → AssetGallery-71d9aeac.js} +127 -52
  3. package/{AssetPreviewTopBar-c28715f7.js → AssetPreviewTopBar-912c3469.js} +8 -3
  4. package/{Button-353f5bbc.js → Button-49f82b31.js} +1 -1
  5. package/{CompactAutocompleteSelect-e99629df.js → CompactAutocompleteSelect-9425bd2e.js} +111 -78
  6. package/{CompactStarRating-5dc2131c.js → CompactStarRating-7d7ad40e.js} +85 -46
  7. package/{CompactTextInput-fa11fda0.js → CompactTextInput-86d0b82c.js} +77 -77
  8. package/{ContextMenuItem-1fe17ed5.js → ContextMenuItem-ba2b697e.js} +3 -3
  9. package/{Instructions-6c9498a9.js → Instructions-d6d5b998.js} +20 -7
  10. package/{MultiLevelCheckboxSelect-418de626.js → MultiLevelCheckboxSelect-24c88aaa.js} +36 -66
  11. package/{Popover-6afb3779.js → Popover-569cd272.js} +31 -5
  12. package/{Tabs-c2261e7e.js → Tabs-ea48ce3e.js} +46 -42
  13. package/TextArea-a215d377.js +436 -0
  14. package/{Tooltip-6b6f0b0a.js → Tooltip-66daf6e3.js} +2 -2
  15. package/{VerificationStatusIcon-b574fd21.js → VerificationStatusIcon-6fe95a92.js} +24 -12
  16. package/data/Popover/index.js +2 -1
  17. package/data/Tabs/index.js +1 -1
  18. package/data/Tooltip/index.js +1 -1
  19. package/data/index.js +5 -4
  20. package/inputs/ActionButton/index.js +1 -1
  21. package/inputs/Button/index.js +3 -2
  22. package/inputs/CompactAutocompleteSelect/index.js +12 -2
  23. package/inputs/CompactStarRating/index.js +13 -2
  24. package/inputs/CompactTextInput/index.js +6 -6
  25. package/inputs/TextArea/index.js +13 -2
  26. package/inputs/index.js +15 -15
  27. package/package.json +2 -1
  28. package/widgets/AssetGallery/index.js +14 -14
  29. package/widgets/AssetPreview/AssetPreviewTopBar/index.js +1 -1
  30. package/widgets/ContextMenu/ContextMenuItem/index.js +1 -1
  31. package/widgets/Instructions/index.js +14 -4
  32. package/widgets/index.js +16 -16
  33. package/TextArea-1689b8d8.js +0 -348
  34. package/check-555d831b.js +0 -213
@@ -7,15 +7,17 @@ var styled = require('styled-components');
7
7
  var polished = require('polished');
8
8
  var TippyTooltip = require('@tippyjs/react');
9
9
  require('./shift-away-subtle-0bed9a3c.js');
10
+ var maxSize = require('popper-max-size-modifier');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
13
 
13
14
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
15
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
15
16
  var TippyTooltip__default = /*#__PURE__*/_interopDefaultLegacy(TippyTooltip);
17
+ var maxSize__default = /*#__PURE__*/_interopDefaultLegacy(maxSize);
16
18
 
17
19
  var _templateObject, _templateObject2, _templateObject3;
18
- var Popover$1 = styled__default['default'](TippyTooltip__default['default']).attrs(defaultTheme.applyDefaultTheme)(_templateObject || (_templateObject = defaultTheme._taggedTemplateLiteral(["\n font-family: ", ";\n font-size: 1rem;\n font-weight: 400;\n color: inherit;\n border-radius: 0;\n line-height: inherit;\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n .tippy-content {\n padding: 0;\n }\n\n .tippy-arrow {\n ", "\n }\n\n && > .tippy-arrow::before {\n position: absolute;\n border-color: transparent;\n border-style: solid;\n }\n\n & > .tippy-arrow::after {\n content: '';\n position: absolute;\n border-color: transparent;\n border-style: solid;\n }\n\n &[data-placement^='top'] {\n & > .tippy-arrow:before {\n bottom: -16px;\n left: -5px;\n border-width: 15px 13px 0;\n ", "\n }\n\n & > .tippy-arrow:after {\n bottom: -15px;\n left: -5px;\n border-width: 15px 13px 0;\n border-top-color: initial;\n transform-origin: center top;\n }\n }\n\n &[data-placement^='right'] {\n & > .tippy-arrow:before {\n bottom: -5px;\n left: -16px;\n border-width: 13px 15px 13px 0;\n ", "\n }\n\n & > .tippy-arrow:after {\n bottom: -5px;\n left: -15px;\n border-width: 13px 15px 13px 0;\n border-right-color: initial;\n transform-origin: center top;\n }\n }\n\n &[data-placement^='bottom'] {\n & > .tippy-arrow:before {\n top: -16px;\n left: -5px;\n border-width: 0 13px 15px 13px;\n ", "\n }\n\n & > .tippy-arrow:after {\n top: -14.5px;\n left: -5px;\n border-width: 0 13px 15px 13px;\n border-bottom-color: initial;\n transform-origin: center top;\n }\n }\n\n &[data-placement^='left'] {\n & > .tippy-arrow::before {\n bottom: -5px;\n right: -16px;\n border-width: 13px 0 13px 15px;\n ", "\n }\n\n & > .tippy-arrow::after {\n bottom: -5px;\n right: -15px;\n border-width: 13px 0 13px 15px;\n border-left-color: initial;\n transform-origin: center top;\n }\n }\n"])), function (props) {
20
+ var Popover$1 = styled__default['default'](TippyTooltip__default['default']).attrs(defaultTheme.applyDefaultTheme)(_templateObject || (_templateObject = defaultTheme._taggedTemplateLiteral(["\n font-family: ", ";\n font-size: 1rem;\n font-weight: 400;\n color: inherit;\n border-radius: 0;\n line-height: inherit;\n max-height: inherit;\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n .tippy-content {\n padding: 0;\n max-height: inherit;\n\n > div {\n max-height: inherit;\n }\n }\n\n .tippy-arrow {\n ", "\n }\n\n && > .tippy-arrow::before {\n position: absolute;\n border-color: transparent;\n border-style: solid;\n }\n\n & > .tippy-arrow::after {\n content: '';\n position: absolute;\n border-color: transparent;\n border-style: solid;\n }\n\n &[data-placement^='top'] {\n & > .tippy-arrow:before {\n bottom: -16px;\n left: -5px;\n border-width: 15px 13px 0;\n ", "\n }\n\n & > .tippy-arrow:after {\n bottom: -15px;\n left: -5px;\n border-width: 15px 13px 0;\n border-top-color: initial;\n transform-origin: center top;\n }\n }\n\n &[data-placement^='right'] {\n & > .tippy-arrow:before {\n bottom: -5px;\n left: -16px;\n border-width: 13px 15px 13px 0;\n ", "\n }\n\n & > .tippy-arrow:after {\n bottom: -5px;\n left: -15px;\n border-width: 13px 15px 13px 0;\n border-right-color: initial;\n transform-origin: center top;\n }\n }\n\n &[data-placement^='bottom'] {\n & > .tippy-arrow:before {\n top: -16px;\n left: -5px;\n border-width: 0 13px 15px 13px;\n ", "\n }\n\n & > .tippy-arrow:after {\n top: -14.5px;\n left: -5px;\n border-width: 0 13px 15px 13px;\n border-bottom-color: initial;\n transform-origin: center top;\n }\n }\n\n &[data-placement^='left'] {\n & > .tippy-arrow::before {\n bottom: -5px;\n right: -16px;\n border-width: 13px 0 13px 15px;\n ", "\n }\n\n & > .tippy-arrow::after {\n bottom: -5px;\n right: -15px;\n border-width: 13px 0 13px 15px;\n border-left-color: initial;\n transform-origin: center top;\n }\n }\n"])), function (props) {
19
21
  return props.theme.primaryFontFamily;
20
22
  }, function (props) {
21
23
  return props.theme.themeProp('background', props.theme.getColor('gray-700'), props.theme.getColor('white'));
@@ -55,7 +57,8 @@ var Popover = React__default['default'].forwardRef(function Popover(_ref, ref) {
55
57
  contextMenu = _ref.contextMenu,
56
58
  contextMenuSublevel = _ref.contextMenuSublevel,
57
59
  children = _ref.children,
58
- props = defaultTheme._objectWithoutProperties(_ref, ["content", "interactive", "placement", "duration", "trigger", "offset", "arrow", "visible", "contextMenu", "contextMenuSublevel", "children"]);
60
+ modifiers = _ref.modifiers,
61
+ props = defaultTheme._objectWithoutProperties(_ref, ["content", "interactive", "placement", "duration", "trigger", "offset", "arrow", "visible", "contextMenu", "contextMenuSublevel", "children", "modifiers"]);
59
62
 
60
63
  var errorOffset = React.useMemo(function () {
61
64
  return arrow ? 15 : 0;
@@ -76,7 +79,7 @@ var Popover = React__default['default'].forwardRef(function Popover(_ref, ref) {
76
79
  });
77
80
  };
78
81
 
79
- return React__default['default'].createElement(Popover$1, defaultTheme._extends({
82
+ return React__default['default'].createElement("div", null, React__default['default'].createElement(Popover$1, defaultTheme._extends({
80
83
  ref: ref,
81
84
  content: content,
82
85
  interactive: interactive,
@@ -87,8 +90,29 @@ var Popover = React__default['default'].forwardRef(function Popover(_ref, ref) {
87
90
  offset: [offset[0], offset[1] + errorOffset],
88
91
  arrow: contextMenu ? false : arrow,
89
92
  visible: visible,
93
+ popperOptions: {
94
+ modifiers: [defaultTheme._objectSpread2(defaultTheme._objectSpread2({}, maxSize__default['default']), {}, {
95
+ options: {
96
+ boundary: 'viewport',
97
+ rootBoundary: 'viewport',
98
+ padding: 10
99
+ }
100
+ }), {
101
+ name: 'applyMaxSize',
102
+ enabled: true,
103
+ phase: 'beforeWrite',
104
+ requires: ['maxSize'],
105
+ fn: function fn(_ref2) {
106
+ var state = _ref2.state;
107
+ var height = state.modifiersData.maxSize.height;
108
+ state.styles.popper = defaultTheme._objectSpread2(defaultTheme._objectSpread2({}, state.styles.popper), {}, {
109
+ maxHeight: "".concat(height, "px")
110
+ });
111
+ }
112
+ }].concat(defaultTheme._toConsumableArray(modifiers))
113
+ },
90
114
  onShown: contextMenu ? handleContextMenuItemClick : undefined
91
- }, props), children);
115
+ }, props), children));
92
116
  });
93
117
  Popover.propTypes = process.env.NODE_ENV !== "production" ? {
94
118
  content: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.string, defaultTheme.PropTypes.element]).isRequired,
@@ -99,6 +123,7 @@ Popover.propTypes = process.env.NODE_ENV !== "production" ? {
99
123
  offset: defaultTheme.PropTypes.arrayOf(defaultTheme.PropTypes.number),
100
124
  arrow: defaultTheme.PropTypes.bool,
101
125
  visible: defaultTheme.PropTypes.bool,
126
+ modifiers: defaultTheme.PropTypes.array,
102
127
  contextMenu: defaultTheme.PropTypes.bool,
103
128
  contextMenuSublevel: defaultTheme.PropTypes.bool,
104
129
  children: defaultTheme.PropTypes.node.isRequired
@@ -114,7 +139,8 @@ Popover.defaultProps = {
114
139
  arrow: true,
115
140
  visible: undefined,
116
141
  contextMenu: false,
117
- contextMenuSublevel: false
142
+ contextMenuSublevel: false,
143
+ modifiers: []
118
144
  };
119
145
 
120
146
  exports.Popover = Popover;
@@ -43,9 +43,9 @@ var TabContent = styled__default['default'].div.attrs(defaultTheme.applyDefaultT
43
43
 
44
44
  var Tabs = React__default['default'].forwardRef(function Tabs(_ref, forwardedRef) {
45
45
  var children = _ref.children,
46
- minHeight = _ref.minHeight,
47
46
  defaultMinHeight = _ref.defaultMinHeight,
48
- props = defaultTheme._objectWithoutProperties(_ref, ["children", "minHeight", "defaultMinHeight"]);
47
+ onChangeTabCallback = _ref.onChangeTabCallback,
48
+ props = defaultTheme._objectWithoutProperties(_ref, ["children", "defaultMinHeight", "onChangeTabCallback"]);
49
49
 
50
50
  var _useState = React.useState(0),
51
51
  _useState2 = defaultTheme._slicedToArray(_useState, 2),
@@ -54,66 +54,70 @@ var Tabs = React__default['default'].forwardRef(function Tabs(_ref, forwardedRef
54
54
 
55
55
  var _useState3 = React.useState(),
56
56
  _useState4 = defaultTheme._slicedToArray(_useState3, 2),
57
- firstTab = _useState4[0],
58
- setFirstTab = _useState4[1];
59
-
60
- var _useState5 = React.useState(),
61
- _useState6 = defaultTheme._slicedToArray(_useState5, 2),
62
- minTabHeight = _useState6[0],
63
- setMinTabHeight = _useState6[1];
64
-
65
- var _useState7 = React.useState(),
66
- _useState8 = defaultTheme._slicedToArray(_useState7, 2),
67
- defaultHeight = _useState8[0],
68
- setDefaultHeight = _useState8[1];
57
+ defaultHeight = _useState4[0],
58
+ setDefaultHeight = _useState4[1];
69
59
 
70
60
  var contentRef = React.useRef(null);
71
- var visibleTabs = [];
72
- React.useEffect(function () {
73
- if ((visibleTabs === null || visibleTabs === void 0 ? void 0 : visibleTabs.length) > 0) {
74
- setActiveTab(visibleTabs[0].key);
75
- setFirstTab(visibleTabs[0]);
76
- }
77
- }, []);
78
- React.useLayoutEffect(function () {
79
- if (contentRef.current) {
80
- var height = contentRef.current.offsetHeight;
81
- setMinTabHeight(height);
82
- }
83
- }, [firstTab]);
84
61
  React.useEffect(function () {
85
62
  setDefaultHeight(defaultMinHeight);
86
63
  }, []);
64
+ React.useEffect(function () {
65
+ onChangeTabCallback(activeTab);
66
+ }, [activeTab]);
87
67
  var tabs = React.useMemo(function () {
88
68
  var tabs = [];
89
69
 
90
70
  function extractChildren(children) {
91
71
  React.Children.forEach(children, function (child, index) {
72
+ var _child$props2;
73
+
74
+ if (lodash.isNil(child)) {
75
+ return null;
76
+ }
77
+
92
78
  if (child.type === React.Fragment) {
93
- extractChildren(child.props.children);
79
+ var _child$props;
80
+
81
+ extractChildren((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.children);
94
82
  }
95
83
 
96
- if (child.props.hidden) {
84
+ if ((_child$props2 = child.props) !== null && _child$props2 !== void 0 && _child$props2.hidden) {
97
85
  return null;
98
86
  }
99
87
 
100
- if (child.type === Tab.Tab && !lodash.isEmpty(child.props.trigger)) {
101
- visibleTabs.push({
102
- key: index,
103
- content: child.props.children
104
- });
88
+ if (child.type === Tab.Tab) {
89
+ var _child$props3, _child$props4;
90
+
105
91
  tabs.push({
106
92
  key: index,
107
- trigger: child.props.trigger,
108
- content: child.props.children
93
+ trigger: (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.trigger,
94
+ content: (_child$props4 = child.props) === null || _child$props4 === void 0 ? void 0 : _child$props4.children
109
95
  });
110
96
  }
111
97
  });
112
98
  }
113
99
 
114
100
  extractChildren(children);
101
+
102
+ if (!tabs.some(function (tab) {
103
+ return (tab === null || tab === void 0 ? void 0 : tab.key) === activeTab;
104
+ })) {
105
+ var _tabs$;
106
+
107
+ setActiveTab((_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.key);
108
+ }
109
+
115
110
  return tabs;
116
111
  }, [children]);
112
+ React.useEffect(function () {
113
+ if (!tabs.some(function (tab) {
114
+ return tab.key === activeTab;
115
+ })) {
116
+ var _tabs$2;
117
+
118
+ setActiveTab(((_tabs$2 = tabs[0]) === null || _tabs$2 === void 0 ? void 0 : _tabs$2.key) || 0);
119
+ }
120
+ }, [tabs, activeTab]);
117
121
  return React__default['default'].createElement(Tabs$1, defaultTheme._extends({
118
122
  ref: forwardedRef
119
123
  }, props, {
@@ -130,25 +134,25 @@ var Tabs = React__default['default'].forwardRef(function Tabs(_ref, forwardedRef
130
134
  }, tab.trigger);
131
135
  })), React__default['default'].createElement(TabContent, null, tabs.map(function (tab) {
132
136
  return React__default['default'].createElement("div", {
133
- ref: tab.key === (firstTab === null || firstTab === void 0 ? void 0 : firstTab.key) ? contentRef : null,
137
+ ref: tab.key === (activeTab === null || activeTab === void 0 ? void 0 : activeTab.key) ? contentRef : null,
134
138
  key: tab.key,
135
139
  role: "tabpanel",
136
140
  hidden: tab.key !== activeTab,
137
141
  style: {
138
- minHeight: minHeight ? minTabHeight : !lodash.isEmpty(defaultHeight) ? defaultHeight : ''
142
+ minHeight: !lodash.isEmpty(defaultHeight) ? defaultHeight : ''
139
143
  }
140
144
  }, tab.content);
141
145
  })));
142
146
  });
143
147
  Tabs.defaultProps = {
144
- minHeight: false,
145
- defaultMinHeight: ''
148
+ defaultMinHeight: '',
149
+ onChangeTabCallback: function onChangeTabCallback() {}
146
150
  };
147
151
  Tabs.propTypes = process.env.NODE_ENV !== "production" ? {
148
152
  children: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.array, defaultTheme.PropTypes.object]),
149
153
  backgroundColor: defaultTheme.PropTypes.string,
150
- minHeight: defaultTheme.PropTypes.bool,
151
- defaultMinHeight: defaultTheme.PropTypes.string
154
+ defaultMinHeight: defaultTheme.PropTypes.string,
155
+ onChangeTabCallback: defaultTheme.PropTypes.func
152
156
  } : {};
153
157
 
154
158
  exports.Tabs = Tabs;