@taikai/rocket-kit 3.0.7 → 3.0.9

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.
@@ -1,8 +1,12 @@
1
1
  import React, { CSSProperties } from 'react';
2
+ import { CheckboxProps } from '../../atoms/checkbox';
2
3
  export declare type CheckboxItem = {
3
4
  value: string;
4
5
  label?: string | React.ReactNode;
5
- checked?: boolean;
6
+ checked?: boolean | null;
7
+ /** The item changes can be tracked here
8
+ * or inside the `CheckboxGroup' onChange`
9
+ */
6
10
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
7
11
  error?: string;
8
12
  disabled?: boolean;
@@ -16,7 +20,10 @@ export interface CheckboxGroupProps {
16
20
  children?: React.ReactNode;
17
21
  options?: CheckboxItem[];
18
22
  error?: string;
19
- onChange?: () => {};
23
+ /** The item changes can be tracked here
24
+ * or inside the `CheckboxItem' onChange`
25
+ */
26
+ onChange?: CheckboxProps['onChange'];
20
27
  disabled?: boolean;
21
28
  }
22
29
  declare const CheckboxGroup: (props: CheckboxGroupProps) => React.JSX.Element;
@@ -1,9 +1,3 @@
1
1
  import React from 'react';
2
- export interface HorizontalNavInterface {
3
- className?: string;
4
- customColor?: string;
5
- items: any;
6
- startsOpen?: boolean;
7
- }
8
- declare const HorizontalNav: (props: HorizontalNavInterface) => React.JSX.Element;
9
- export default HorizontalNav;
2
+ import { HorizontalNavInterface } from './types';
3
+ export default function HorizontalNav(props: HorizontalNavInterface): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ export interface ItemInterface {
2
+ icon?: string;
3
+ label: string;
4
+ url: string;
5
+ active?: boolean;
6
+ }
7
+ export interface HorizontalNavInterface {
8
+ id?: string;
9
+ items: ItemInterface[];
10
+ }
@@ -0,0 +1,97 @@
1
+ .styles-module_wrapper__Q2-ac {
2
+ position: relative;
3
+ height: 5rem; /* 80px */
4
+ display: flex;
5
+ align-items: center;
6
+ }
7
+
8
+ .styles-module_wrapper__Q2-ac > div {
9
+ display: flex;
10
+ overflow-x: auto;
11
+ scrollbar-width: none;
12
+ -webkit-overflow-scrolling: touch;
13
+ -ms-overflow-style: -ms-autohiding-scrollbar;
14
+ }
15
+
16
+ .styles-module_wrapper__Q2-ac > div::-webkit-scrollbar {
17
+ display: none;
18
+ }
19
+
20
+ .styles-module_wrapper__Q2-ac ul {
21
+ list-style: none;
22
+ margin: 0;
23
+ padding: 0;
24
+ display: flex;
25
+ }
26
+
27
+ .styles-module_wrapper__Q2-ac ul li:not(:last-child) {
28
+ margin-right: 0.625rem; /* 10px */
29
+ }
30
+
31
+ .styles-module_wrapper__Q2-ac ul li:last-child {
32
+ margin-right: 0.0625rem; /* 1px */
33
+ }
34
+
35
+ .styles-module_wrapper__Q2-ac ul li a {
36
+ display: flex;
37
+ align-items: center;
38
+ padding: 0.625rem; /* 10px */
39
+ color: var(--black);
40
+ text-transform: capitalize;
41
+ text-decoration: none;
42
+ white-space: nowrap;
43
+ transition-duration: var(--transitionDurationDefault);
44
+ }
45
+
46
+ .styles-module_wrapper__Q2-ac ul li a svg {
47
+ margin-right: 0.3125rem; /* 5px */
48
+ width: auto;
49
+ height: 1.5rem; /* 24px */
50
+ min-width: 1.5rem; /* 24px */
51
+ fill: var(--grey200);
52
+ transition-duration: var(--transitionDurationDefault);
53
+ }
54
+
55
+ .styles-module_wrapper__Q2-ac ul li a:hover {
56
+ color: var(--purple500);
57
+ }
58
+
59
+ .styles-module_wrapper__Q2-ac ul li a:hover svg {
60
+ fill: var(--purple500);
61
+ }
62
+
63
+ .styles-module_wrapper__Q2-ac ul li.styles-module_active__0DuQB {
64
+ font-weight: var(--fontWeightSemiBold);
65
+ }
66
+
67
+ .styles-module_wrapper__Q2-ac ul li.styles-module_active__0DuQB a {
68
+ color: var(--purple500);
69
+ pointer-events: none;
70
+ }
71
+
72
+ .styles-module_wrapper__Q2-ac ul li.styles-module_active__0DuQB a svg {
73
+ fill: var(--purple500);
74
+ }
75
+
76
+ .styles-module_wrapper__Q2-ac button {
77
+ position: absolute;
78
+ top: 0;
79
+ border-radius: 0;
80
+ height: 100%;
81
+ border-style: solid;
82
+ border-color: var(--grey150);
83
+ }
84
+
85
+ .styles-module_wrapper__Q2-ac button:hover {
86
+ background-color: var(--white);
87
+ }
88
+
89
+ .styles-module_wrapper__Q2-ac button.styles-module_back__AE3bY {
90
+ left: 0;
91
+ border-right-width: 0.0625rem; /* 1px */
92
+ }
93
+
94
+ .styles-module_wrapper__Q2-ac button.styles-module_forward__sOwh3 {
95
+ right: 0;
96
+ border-left-width: 0.0625rem; /* 1px */
97
+ }
@@ -17,6 +17,7 @@ var ReactPlayer = _interopDefault(require('react-player'));
17
17
  var uuid = require('uuid');
18
18
  var reactBeautifulDnd = require('react-beautiful-dnd');
19
19
  var ReactPaginate = _interopDefault(require('react-paginate'));
20
+ var reactIntersectionObserver = require('react-intersection-observer');
20
21
  var throttle = _interopDefault(require('lodash.throttle'));
21
22
  var ReactDOM = _interopDefault(require('react-dom'));
22
23
  var Tabs = _interopDefault(require('react-responsive-tabs'));
@@ -5277,8 +5278,12 @@ const CheckboxGroup = props => {
5277
5278
  }, /*#__PURE__*/React__default.createElement(Checkbox, {
5278
5279
  label: value.label,
5279
5280
  value: value.value,
5280
- checked: value.checked,
5281
- onChange: onChange,
5281
+ checked: value.checked ?? undefined,
5282
+ onChange: event => {
5283
+ var _value$onChange;
5284
+ onChange === null || onChange === void 0 ? void 0 : onChange(event);
5285
+ (_value$onChange = value.onChange) === null || _value$onChange === void 0 ? void 0 : _value$onChange.call(value, event);
5286
+ },
5282
5287
  error: !!error,
5283
5288
  disabled: disabled
5284
5289
  }))) : null, error ? /*#__PURE__*/React__default.createElement(ErrorField, {
@@ -5401,80 +5406,77 @@ const FieldWidthButton = ({
5401
5406
  })));
5402
5407
  };
5403
5408
 
5404
- const Wrapper$f = /*#__PURE__*/_styled__default.div.withConfig({
5405
- displayName: "styles__Wrapper",
5406
- componentId: "sc-znznmm-0"
5407
- })(["display:flex;align-items:center;ul.menu{width:0;animation:showAnimation 1s forwards;animation-delay:0.5s;overflow:hidden;}@keyframes showAnimation{0%{width:0%;}100%{width:100%;}}ul{margin:0;max-width:max-content;padding:0;&.menu{display:flex;li:not(:last-child){margin-right:", ";}}li{position:relative;list-style:none;a{display:flex;align-items:center;padding:", ";color:", ";text-transform:capitalize;text-decoration:none;white-space:nowrap;transition-duration:", ";svg{margin-right:", ";width:auto;height:", ";min-width:", ";fill:", ";transition-duration:", ";}&:hover{color:", ";svg{fill:", ";}}}&.active{font-weight:", ";a{color:", ";pointer-events:none;svg{fill:", ";}}}}}"], /*#__PURE__*/polished.rem('10px'), /*#__PURE__*/polished.rem('10px'), colors.black, misc.transitionDuration, /*#__PURE__*/polished.rem('5px'), /*#__PURE__*/polished.rem('24px'), /*#__PURE__*/polished.rem('24px'), colors.grey200, misc.transitionDuration, props => props.customColor ? props.customColor : colors.purple500, props => props.customColor ? props.customColor : colors.purple500, typography.medium, props => props.customColor ? props.customColor : colors.purple500, props => props.customColor ? props.customColor : colors.purple500);
5408
- const More = /*#__PURE__*/_styled__default.div.withConfig({
5409
- displayName: "styles__More",
5410
- componentId: "sc-znznmm-1"
5411
- })(["position:relative;display:none;&.hide{display:initial;}ul{position:absolute;right:0;border:", " solid ", ";border-radius:", ";background-color:", ";margin-top:", ";padding:0;-moz-box-shadow:", ";-webkit-box-shadow:", ";box-shadow:", ";z-index:1;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;&.more{display:none;}&.is-open{display:inherit;}li{list-style:none;transition-duration:", ";&:hover{background-color:", ";cursor:pointer;a{color:", ";svg{fill:", ";}}}&:first-child{border-radius:", " ", " 0 0;}&:last-child{border-radius:0 0 ", " ", ";}a{width:100%;height:100%;padding:", ";}}}"], field.borderWidth, field.borderColor, field.borderRadius, field.backgroundColor, /*#__PURE__*/polished.rem('5px'), field.boxShadow, field.boxShadow, field.boxShadow, misc.transitionDuration, field.borderColor, colors.black, colors.black, field.borderRadius, field.borderRadius, field.borderRadius, field.borderRadius, /*#__PURE__*/polished.rem('15px'));
5412
-
5413
- const HorizontalNav = props => {
5414
- const [showMore, setShowMore] = React.useState(false);
5415
- const moreMenu = React.useRef(null);
5416
- const visibleMenuRef = React.useRef(null);
5409
+ var styles = {"wrapper":"styles-module_wrapper__Q2-ac","active":"styles-module_active__0DuQB","back":"styles-module_back__AE3bY","forward":"styles-module_forward__sOwh3"};
5410
+
5411
+ function scroll(container, direction, speed, distance, step) {
5412
+ let scrollAmount = 0;
5413
+ const slideTimer = setInterval(function () {
5414
+ if (container && direction === 'left') {
5415
+ container.scrollLeft -= step;
5416
+ } else {
5417
+ container ? container.scrollLeft += step : null;
5418
+ }
5419
+ scrollAmount += step;
5420
+ if (scrollAmount >= distance) {
5421
+ window.clearInterval(slideTimer);
5422
+ }
5423
+ }, speed);
5424
+ }
5425
+ function HorizontalNav(props) {
5417
5426
  const {
5418
- className = 'horizontal-nav',
5419
- customColor = '',
5420
- items,
5421
- startsOpen = false
5427
+ id = 'horizontal-nav',
5428
+ items
5422
5429
  } = props;
5423
- const {
5424
- ref,
5425
- isVisible,
5426
- setIsVisible
5427
- } = useVisible(startsOpen);
5428
- React.useEffect(() => {
5429
- if (!ref || !ref.current) return;
5430
- const visible = document.querySelector('ul.menu').getElementsByTagName('li');
5431
- const more = document.querySelector('.more').getElementsByTagName('li');
5432
- const moreVisibility = () => more.length > 0 ? setShowMore(true) : setShowMore(false);
5433
- const removeItem = () => {
5434
- if (visible.length === 1) return;
5435
- let last = visible[visible.length - 1];
5436
- document.querySelector('ul.more').prepend(last);
5437
- };
5438
- const addItem = () => {
5439
- if (more.length === 0) return;
5440
- let first = more[0];
5441
- document.querySelector('ul.menu').append(first);
5442
- };
5443
- const checkOverflow = () => {
5444
- moreVisibility();
5445
- for (let i = 0; i < visible.length + 20; i++) {
5446
- visibleMenuRef.current.scrollWidth + 50 > ref.current.offsetWidth ? removeItem() : addItem();
5447
- }
5448
- };
5449
- checkOverflow();
5450
- if (typeof window !== 'undefined') {
5451
- moreVisibility();
5452
- window.addEventListener('resize', checkOverflow);
5453
- return () => window.removeEventListener('resize', checkOverflow);
5454
- }
5455
- return;
5456
- }, [ref]);
5457
- return /*#__PURE__*/React__default.createElement(Wrapper$f, {
5458
- ref: ref,
5459
- className: className,
5460
- customColor: customColor
5430
+ const [showBackButton, setShowBackButton] = React.useState(false);
5431
+ const [showForwardButton, setShowForwardButton] = React.useState(true);
5432
+ const forward = () => {
5433
+ const container = document.getElementById(id);
5434
+ scroll(container, 'right', 10, 200, 10);
5435
+ };
5436
+ const back = () => {
5437
+ const container = document.getElementById(id);
5438
+ scroll(container, 'left', 10, 200, 10);
5439
+ };
5440
+ return /*#__PURE__*/React__default.createElement("div", {
5441
+ className: styles.wrapper
5442
+ }, showBackButton && /*#__PURE__*/React__default.createElement(Button, {
5443
+ className: styles.back,
5444
+ variant: "solid",
5445
+ color: "white",
5446
+ txtColor: "black",
5447
+ icon: "caret-left",
5448
+ action: back
5449
+ }), /*#__PURE__*/React__default.createElement("div", {
5450
+ id: id
5461
5451
  }, /*#__PURE__*/React__default.createElement("ul", {
5462
- className: "menu",
5463
- ref: visibleMenuRef
5464
- }, items), /*#__PURE__*/React__default.createElement(More, {
5465
- className: showMore ? 'hide' : '',
5466
- ref: moreMenu
5467
- }, /*#__PURE__*/React__default.createElement(Button, {
5468
- variant: "text",
5469
- color: "dark",
5470
- icon: "menuVert",
5471
- action: () => {
5472
- setIsVisible(!isVisible);
5452
+ className: "menu"
5453
+ }, items.map((item, index) =>
5454
+ /*#__PURE__*/
5455
+ // @ts-ignore
5456
+ React__default.createElement(reactIntersectionObserver.InView, {
5457
+ key: index,
5458
+ as: "li",
5459
+ className: item.active ? styles.active : undefined,
5460
+ threshold: 1,
5461
+ onChange: inView => {
5462
+ if (index === 0 && inView) setShowBackButton(false);
5463
+ if (index === 0 && !inView) setShowBackButton(true);
5464
+ if (index === items.length - 1 && inView) setShowForwardButton(false);
5465
+ if (index === items.length - 1 && !inView) setShowForwardButton(true);
5473
5466
  }
5474
- }), /*#__PURE__*/React__default.createElement("ul", {
5475
- className: isVisible ? 'more is-open' : 'more'
5476
- })));
5477
- };
5467
+ }, /*#__PURE__*/React__default.createElement("a", {
5468
+ href: item.url
5469
+ }, item.icon && /*#__PURE__*/React__default.createElement(Icon, {
5470
+ icon: item.icon
5471
+ }), item.label))))), showForwardButton && /*#__PURE__*/React__default.createElement(Button, {
5472
+ className: styles.forward,
5473
+ variant: "solid",
5474
+ color: "white",
5475
+ txtColor: "black",
5476
+ icon: "caret-right",
5477
+ action: forward
5478
+ }));
5479
+ }
5478
5480
 
5479
5481
  const ModalOverlay = /*#__PURE__*/_styled__default.div.withConfig({
5480
5482
  displayName: "styles__ModalOverlay",
@@ -5517,7 +5519,7 @@ const Modal = props => {
5517
5519
  return;
5518
5520
  }
5519
5521
  }, []);
5520
- return isShowing ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ModalOverlay, {
5522
+ return isShowing ? ( /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ModalOverlay, {
5521
5523
  zIndex: zIndex
5522
5524
  }), /*#__PURE__*/React__default.createElement(ModalWrapper, {
5523
5525
  "aria-modal": true,
@@ -5539,7 +5541,7 @@ const Modal = props => {
5539
5541
  })), children, footer && /*#__PURE__*/React__default.createElement(ModalFooter, {
5540
5542
  closeAction: hide,
5541
5543
  closeValue: closeValue
5542
- })))), document.body) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
5544
+ })))), document.body)) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
5543
5545
  };
5544
5546
 
5545
5547
  const slideInLeft = _styled.keyframes`
@@ -5607,7 +5609,7 @@ const ModalDrawer = props => {
5607
5609
  }
5608
5610
  return;
5609
5611
  }, []);
5610
- return isShowing ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ModalOverlay$1, {
5612
+ return isShowing ? ( /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ModalOverlay$1, {
5611
5613
  zIndex: zIndex
5612
5614
  }), /*#__PURE__*/React__default.createElement(ModalWrapper$1, {
5613
5615
  "aria-modal": true,
@@ -5620,10 +5622,10 @@ const ModalDrawer = props => {
5620
5622
  }, /*#__PURE__*/React__default.createElement(ModalHeader$1, null, title && /*#__PURE__*/React__default.createElement("h2", null, title)), /*#__PURE__*/React__default.createElement(ModalContent, null, children), !footerHidden && (footer ? footer : /*#__PURE__*/React__default.createElement(ModalFooter, {
5621
5623
  closeAction: hide,
5622
5624
  closeValue: closeValue
5623
- }))))), document.body) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
5625
+ }))))), document.body)) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
5624
5626
  };
5625
5627
 
5626
- const Wrapper$g = _styled__default.div`
5628
+ const Wrapper$f = _styled__default.div`
5627
5629
  div {
5628
5630
  width: 100%;
5629
5631
  height: 100%;
@@ -5786,12 +5788,12 @@ const LoadingState = props => {
5786
5788
  className: "subtitle"
5787
5789
  }), paragraphs));
5788
5790
  }
5789
- return /*#__PURE__*/React__default.createElement(Wrapper$g, {
5791
+ return /*#__PURE__*/React__default.createElement(Wrapper$f, {
5790
5792
  type: type
5791
5793
  }, loadingType);
5792
5794
  };
5793
5795
 
5794
- const Wrapper$h = _styled__default.div`
5796
+ const Wrapper$g = _styled__default.div`
5795
5797
  .tab {
5796
5798
  border-color: ${field.borderColor};
5797
5799
 
@@ -5969,7 +5971,7 @@ const TabsPanel = props => {
5969
5971
  getContent: () => tab.renderer
5970
5972
  }));
5971
5973
  };
5972
- return /*#__PURE__*/React__default.createElement(Wrapper$h, null, /*#__PURE__*/React__default.createElement(Tabs, {
5974
+ return /*#__PURE__*/React__default.createElement(Wrapper$g, null, /*#__PURE__*/React__default.createElement(Tabs, {
5973
5975
  transform: false,
5974
5976
  unmountOnExit: unmountOnExit,
5975
5977
  selectedTabKey: selectedTabKey,
@@ -5979,7 +5981,7 @@ const TabsPanel = props => {
5979
5981
  }));
5980
5982
  };
5981
5983
 
5982
- const Wrapper$i = _styled__default.div`
5984
+ const Wrapper$h = _styled__default.div`
5983
5985
  display: flex;
5984
5986
  flex-direction: column;
5985
5987
  `;
@@ -5999,7 +6001,7 @@ const TabsPanel$1 = props => {
5999
6001
  className = 'grid-container',
6000
6002
  children
6001
6003
  } = props;
6002
- return /*#__PURE__*/React__default.createElement(Wrapper$i, {
6004
+ return /*#__PURE__*/React__default.createElement(Wrapper$h, {
6003
6005
  className: className
6004
6006
  }, children);
6005
6007
  };