@vitus-labs/elements 0.15.3 → 0.17.0

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 (33) hide show
  1. package/lib/analysis/vitus-labs-elements.browser.js.html +1 -1
  2. package/lib/analysis/vitus-labs-elements.js.html +1 -1
  3. package/lib/analysis/vitus-labs-elements.module.js.html +1 -1
  4. package/lib/analysis/vitus-labs-elements.native.js.html +1 -1
  5. package/lib/analysis/vitus-labs-elements.umd.js.html +1 -1
  6. package/lib/analysis/vitus-labs-elements.umd.min.js.html +1 -1
  7. package/lib/index.d.ts +48 -89
  8. package/lib/types/Element/component.d.ts +3 -31
  9. package/lib/types/Element/types.d.ts +7 -8
  10. package/lib/types/Element/utils.d.ts +1 -1
  11. package/lib/types/List/component.d.ts +2 -38
  12. package/lib/types/List/withActiveState.d.ts +1 -1
  13. package/lib/types/Overlay/component.d.ts +4 -4
  14. package/lib/types/Portal/component.d.ts +4 -3
  15. package/lib/types/Text/component.d.ts +4 -4
  16. package/lib/types/Util/component.d.ts +3 -2
  17. package/lib/types/constants.d.ts +1 -1
  18. package/lib/types/helpers/Content/component.d.ts +1 -1
  19. package/lib/types/helpers/Wrapper/component.d.ts +1 -1
  20. package/lib/types/types.d.ts +25 -2
  21. package/lib/vitus-labs-elements.browser.js +50 -64
  22. package/lib/vitus-labs-elements.browser.js.map +1 -1
  23. package/lib/vitus-labs-elements.js +67 -83
  24. package/lib/vitus-labs-elements.js.map +1 -1
  25. package/lib/vitus-labs-elements.module.js +49 -63
  26. package/lib/vitus-labs-elements.module.js.map +1 -1
  27. package/lib/vitus-labs-elements.native.js +47 -61
  28. package/lib/vitus-labs-elements.native.js.map +1 -1
  29. package/lib/vitus-labs-elements.umd.js +69 -85
  30. package/lib/vitus-labs-elements.umd.js.map +1 -1
  31. package/lib/vitus-labs-elements.umd.min.js +6 -6
  32. package/lib/vitus-labs-elements.umd.min.js.map +1 -1
  33. package/package.json +9 -9
@@ -84,7 +84,7 @@ var Styled$2 = core.config.styled(core.config.component) `
84
84
  `;
85
85
 
86
86
  /* eslint-disable @typescript-eslint/no-explicit-any */
87
- const component$4 = React.forwardRef(({ children, tag, block, extendCss, direction, alignX, alignY, equalCols, isInline, ...props }, ref) => {
87
+ const component$6 = React.forwardRef(({ children, tag, block, extendCss, direction, alignX, alignY, equalCols, isInline, ...props }, ref) => {
88
88
  const debugProps = process.env.NODE_ENV !== 'production'
89
89
  ? {
90
90
  'data-element': 'Element',
@@ -99,7 +99,7 @@ const component$4 = React.forwardRef(({ children, tag, block, extendCss, directi
99
99
  const needsFix = !props.dangerouslySetInnerHTML && tag && isWebFixNeeded(tag)
100
100
  ;
101
101
  if (!needsFix || false) {
102
- return (React__default['default'].createElement(Styled$2, { ...COMMON_PROPS, "$element": {
102
+ return (React__default["default"].createElement(Styled$2, { ...COMMON_PROPS, "$element": {
103
103
  block,
104
104
  direction,
105
105
  alignX,
@@ -108,11 +108,11 @@ const component$4 = React.forwardRef(({ children, tag, block, extendCss, directi
108
108
  extraStyles: extendCss,
109
109
  } }, children));
110
110
  }
111
- return (React__default['default'].createElement(Styled$2, { ...COMMON_PROPS, "$needsFix": true, "$element": {
111
+ return (React__default["default"].createElement(Styled$2, { ...COMMON_PROPS, "$needsFix": true, "$element": {
112
112
  block,
113
113
  extraStyles: extendCss,
114
114
  } },
115
- React__default['default'].createElement(Styled$2, { as: isInline ? 'span' : 'div', "$isInner": true, "$element": {
115
+ React__default["default"].createElement(Styled$2, { as: isInline ? 'span' : 'div', "$isInner": true, "$element": {
116
116
  direction,
117
117
  alignX,
118
118
  alignY,
@@ -190,14 +190,13 @@ var Styled$1 = core.config.styled(core.config.component) `
190
190
  })};
191
191
  `;
192
192
 
193
- /* eslint-disable @typescript-eslint/no-explicit-any */
194
- const component$2 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
193
+ const component$4 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
195
194
  const debugProps = process.env.NODE_ENV !== 'production'
196
195
  ? {
197
196
  'data-vl-element': contentType,
198
197
  }
199
198
  : {};
200
- return (React__default['default'].createElement(Styled$1, { as: tag, "$contentType": contentType, "$element": {
199
+ return (React__default["default"].createElement(Styled$1, { as: tag, "$contentType": contentType, "$element": {
201
200
  parentDirection,
202
201
  direction,
203
202
  alignX,
@@ -207,7 +206,7 @@ const component$2 = ({ contentType, tag, parentDirection, direction, alignX, ali
207
206
  extraStyles: extendCss,
208
207
  }, ...debugProps, ...props }));
209
208
  };
210
- var component$3 = React.memo(component$2);
209
+ var component$5 = React.memo(component$4);
211
210
 
212
211
  const INLINE_ELEMENTS = {
213
212
  span: true,
@@ -281,13 +280,13 @@ const transformVerticalProp = (vertical) => {
281
280
  }
282
281
  return undefined;
283
282
  };
284
- const isInlineElement = (tag) => INLINE_ELEMENTS[tag];
285
- const getShouldBeEmpty = (tag) => EMPTY_ELEMENTS[tag];
283
+ const isInlineElement = (tag) => tag ? INLINE_ELEMENTS[tag] : false;
284
+ const getShouldBeEmpty = (tag) => tag ? EMPTY_ELEMENTS[tag] : false;
286
285
 
287
286
  const defaultDirection = 'inline';
288
287
  const defaultAlignX = 'left';
289
288
  const defaultAlignY = 'center';
290
- const component$1 = React.forwardRef(({ innerRef, tag, label, content, children, beforeContent, afterContent, block, equalCols, gap, vertical, direction, alignX = defaultAlignX, alignY = defaultAlignY, css, contentCss, beforeContentCss, afterContentCss, contentDirection = defaultDirection, contentAlignX = defaultAlignX, contentAlignY = defaultAlignY, beforeContentDirection = defaultDirection, beforeContentAlignX = defaultAlignX, beforeContentAlignY = defaultAlignY, afterContentDirection = defaultDirection, afterContentAlignX = defaultAlignX, afterContentAlignY = defaultAlignY, ...props }, ref) => {
289
+ const component$3 = React.forwardRef(({ innerRef, tag, label, content, children, beforeContent, afterContent, block, equalCols, gap, vertical, direction, alignX = defaultAlignX, alignY = defaultAlignY, css, contentCss, beforeContentCss, afterContentCss, contentDirection = defaultDirection, contentAlignX = defaultAlignX, contentAlignY = defaultAlignY, beforeContentDirection = defaultDirection, beforeContentAlignX = defaultAlignX, beforeContentAlignY = defaultAlignY, afterContentDirection = defaultDirection, afterContentAlignX = defaultAlignX, afterContentAlignY = defaultAlignY, ...props }, ref) => {
291
290
  // --------------------------------------------------------
292
291
  // check if should render only single element
293
292
  // --------------------------------------------------------
@@ -310,7 +309,7 @@ const component$1 = React.forwardRef(({ innerRef, tag, label, content, children,
310
309
  // return simple/empty element like input
311
310
  // --------------------------------------------------------
312
311
  if (shouldBeEmpty)
313
- return React__default['default'].createElement(component$4, { ...WRAPPER_PROPS, ...props });
312
+ return React__default["default"].createElement(component$6, { ...WRAPPER_PROPS, ...props });
314
313
  // --------------------------------------------------------
315
314
  // if not single element, calculate values
316
315
  // --------------------------------------------------------
@@ -347,19 +346,15 @@ const component$1 = React.forwardRef(({ innerRef, tag, label, content, children,
347
346
  const { wrapperDirection, wrapperAlignX, wrapperAlignY } = calculateDirection();
348
347
  const beforeContentRender = React.useMemo(() => core.renderContent(beforeContent), [beforeContent]);
349
348
  const afterContentRender = React.useMemo(() => core.renderContent(afterContent), [afterContent]);
350
- return (React__default['default'].createElement(component$4, { ...props, ...WRAPPER_PROPS, isInline: isInline, direction: wrapperDirection, alignX: wrapperAlignX, alignY: wrapperAlignY },
351
- beforeContent && (React__default['default'].createElement(component$3, { tag: SUB_TAG, contentType: "before", parentDirection: wrapperDirection, extendCss: beforeContentCss, direction: beforeContentDirection, alignX: beforeContentAlignX, alignY: beforeContentAlignY, equalCols: equalCols, gap: gap }, beforeContentRender)),
352
- isSimple ? (core.renderContent(CHILDREN)) : (React__default['default'].createElement(component$3, { tag: SUB_TAG, contentType: "content", parentDirection: wrapperDirection, extendCss: contentCss, direction: contentDirection, alignX: contentAlignX, alignY: contentAlignY, equalCols: equalCols }, core.renderContent(CHILDREN))),
353
- afterContent && (React__default['default'].createElement(component$3, { tag: SUB_TAG, contentType: "after", parentDirection: wrapperDirection, extendCss: afterContentCss, direction: afterContentDirection, alignX: afterContentAlignX, alignY: afterContentAlignY, equalCols: equalCols, gap: gap }, core.renderContent(afterContentRender)))));
349
+ return (React__default["default"].createElement(component$6, { ...props, ...WRAPPER_PROPS, isInline: isInline, direction: wrapperDirection, alignX: wrapperAlignX, alignY: wrapperAlignY },
350
+ beforeContent && (React__default["default"].createElement(component$5, { tag: SUB_TAG, contentType: "before", parentDirection: wrapperDirection, extendCss: beforeContentCss, direction: beforeContentDirection, alignX: beforeContentAlignX, alignY: beforeContentAlignY, equalCols: equalCols, gap: gap }, beforeContentRender)),
351
+ isSimple ? (core.renderContent(CHILDREN)) : (React__default["default"].createElement(component$5, { tag: SUB_TAG, contentType: "content", parentDirection: wrapperDirection, extendCss: contentCss, direction: contentDirection, alignX: contentAlignX, alignY: contentAlignY, equalCols: equalCols }, core.renderContent(CHILDREN))),
352
+ afterContent && (React__default["default"].createElement(component$5, { tag: SUB_TAG, contentType: "after", parentDirection: wrapperDirection, extendCss: afterContentCss, direction: afterContentDirection, alignX: afterContentAlignX, alignY: afterContentAlignY, equalCols: equalCols, gap: gap }, core.renderContent(afterContentRender)))));
354
353
  });
355
354
  const name$4 = `${PKG_NAME}/Element`;
356
- component$1.displayName = name$4;
357
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
358
- // @ts-ignore
359
- component$1.pkgName = PKG_NAME;
360
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
361
- // @ts-ignore
362
- component$1.VITUS_LABS__COMPONENT = name$4;
355
+ component$3.displayName = name$4;
356
+ component$3.pkgName = PKG_NAME;
357
+ component$3.VITUS_LABS__COMPONENT = name$4;
363
358
 
364
359
  /* eslint-disable no-param-reassign */
365
360
  const isNumber = (a, b) => Number.isInteger(a) && Number.isInteger(b);
@@ -397,7 +392,7 @@ const withEqualBeforeAfter = (WrappedComponent) => {
397
392
  };
398
393
  if (equalBeforeAfter)
399
394
  calculateSize();
400
- return (React__default['default'].createElement(WrappedComponent, { ...rest, afterContent: afterContent, beforeContent: beforeContent, ref: elementRef }));
395
+ return (React__default["default"].createElement(WrappedComponent, { ...rest, afterContent: afterContent, beforeContent: beforeContent, ref: elementRef }));
401
396
  };
402
397
  Enhanced.displayName = `withEqualSizeBeforeAfter(${displayName})`;
403
398
  return Enhanced;
@@ -424,7 +419,7 @@ const attachItemProps = ({ i, length, }) => {
424
419
  position,
425
420
  };
426
421
  };
427
- const component = (props) => {
422
+ const component$2 = (props) => {
428
423
  const { itemKey, valueName, children, component, data, wrapComponent: Wrapper, wrapProps, itemProps, } = props;
429
424
  const renderedElement = (component, props) => core.renderContent(component, props);
430
425
  const injectItemProps = typeof itemProps === 'function'
@@ -437,6 +432,8 @@ const component = (props) => {
437
432
  // render children
438
433
  // --------------------------------------------------------
439
434
  const renderChildren = () => {
435
+ if (!children)
436
+ return null;
440
437
  const { length } = children;
441
438
  // if no props extension is required, just return children
442
439
  if (!itemProps && !Wrapper)
@@ -452,7 +449,7 @@ const component = (props) => {
452
449
  ? injectWrapItemProps({}, extendedProps)
453
450
  : {};
454
451
  if (Wrapper) {
455
- return (React__default['default'].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(item, finalItemProps)));
452
+ return (React__default["default"].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(item, finalItemProps)));
456
453
  }
457
454
  return core.renderContent(item, {
458
455
  key: i,
@@ -492,7 +489,7 @@ const component = (props) => {
492
489
  ? injectWrapItemProps({ [keyName]: item }, extendedProps)
493
490
  : {};
494
491
  if (Wrapper) {
495
- return (React__default['default'].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(component, finalItemProps)));
492
+ return (React__default["default"].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(component, finalItemProps)));
496
493
  }
497
494
  return renderedElement(component, { key, ...finalItemProps });
498
495
  });
@@ -531,7 +528,7 @@ const component = (props) => {
531
528
  ? injectWrapItemProps(item, extendedProps)
532
529
  : {};
533
530
  if (Wrapper && !itemComponent) {
534
- return (React__default['default'].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(renderItem, finalItemProps)));
531
+ return (React__default["default"].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(renderItem, finalItemProps)));
535
532
  }
536
533
  return renderedElement(renderItem, { key, ...finalItemProps });
537
534
  });
@@ -566,23 +563,20 @@ const component = (props) => {
566
563
  };
567
564
  return renderItems();
568
565
  };
569
- component.isIterator = true;
570
- component.RESERVED_PROPS = RESERVED_PROPS;
571
- component.displayName = 'vitus-labs/elements/Iterator';
566
+ component$2.isIterator = true;
567
+ component$2.RESERVED_PROPS = RESERVED_PROPS;
568
+ component$2.displayName = 'vitus-labs/elements/Iterator';
572
569
 
573
- /* eslint-disable @typescript-eslint/ban-ts-comment */
574
- const Component$4 = React.forwardRef(({ rootElement = false, ...props }, ref) => {
575
- const renderedList = React__default['default'].createElement(component, { ...core.pick(props, component.RESERVED_PROPS) });
570
+ const Component$2 = React.forwardRef(({ rootElement = false, ...props }, ref) => {
571
+ const renderedList = React__default["default"].createElement(component$2, { ...core.pick(props, component$2.RESERVED_PROPS) });
576
572
  if (!rootElement)
577
573
  return renderedList;
578
- return (React__default['default'].createElement(component$1, { ref: ref, ...core.omit(props, component.RESERVED_PROPS) }, renderedList));
574
+ return (React__default["default"].createElement(component$3, { ref: ref, ...core.omit(props, component$2.RESERVED_PROPS) }, renderedList));
579
575
  });
580
576
  const name$3 = `${PKG_NAME}/List`;
581
- Component$4.displayName = name$3;
582
- // @ts-ignore
583
- Component$4.pkgName = PKG_NAME;
584
- // @ts-ignore
585
- Component$4.VITUS_LABS__COMPONENT = name$3;
577
+ Component$2.displayName = name$3;
578
+ Component$2.pkgName = PKG_NAME;
579
+ Component$2.VITUS_LABS__COMPONENT = name$3;
586
580
 
587
581
  const RESERVED_KEYS = [
588
582
  'type',
@@ -590,7 +584,7 @@ const RESERVED_KEYS = [
590
584
  'itemProps',
591
585
  'activeItemRequired',
592
586
  ];
593
- const Component$3 = (WrappedComponent) => {
587
+ const Component$1 = (WrappedComponent) => {
594
588
  const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
595
589
  const Enhanced = (props) => {
596
590
  const { type = 'single', activeItemRequired, activeItems, itemProps = {}, ...rest } = props;
@@ -672,10 +666,13 @@ const Component$3 = (WrappedComponent) => {
672
666
  updateAllItemsState(false);
673
667
  };
674
668
  const isItemActive = (key) => {
669
+ if (!innerActiveItems)
670
+ return false;
675
671
  if (type === 'single')
676
672
  return innerActiveItems === key;
677
- if (type === 'multi')
678
- return innerActiveItems.get(key);
673
+ if (type === 'multi' && innerActiveItems instanceof Map) {
674
+ return !!innerActiveItems.get(key);
675
+ }
679
676
  return false;
680
677
  };
681
678
  const attachMultipleProps = {
@@ -703,30 +700,28 @@ const Component$3 = (WrappedComponent) => {
703
700
  }
704
701
  }
705
702
  }, [type, activeItems]);
706
- return React__default['default'].createElement(WrappedComponent, { ...rest, itemProps: attachItemProps });
703
+ return React__default["default"].createElement(WrappedComponent, { ...rest, itemProps: attachItemProps });
707
704
  };
708
705
  Enhanced.RESERVED_KEYS = RESERVED_KEYS;
709
706
  Enhanced.displayName = `vitus-labs/elements/List/withActiveState(${displayName})`;
710
707
  return Enhanced;
711
708
  };
712
709
 
713
- const Component$2 = ({ position = document.body, tag = 'div', children, }) => {
710
+ const component$1 = ({ position = undefined, tag = 'div', children, }) => {
714
711
  const [element] = React.useState(undefined);
712
+ if (!position || !element)
713
+ return null;
715
714
  React.useEffect(() => {
716
715
  return undefined;
717
- }, [tag, position]);
718
- return ReactDOM__default['default'].createPortal(children, element);
716
+ }, []);
717
+ return ReactDOM__default["default"].createPortal(children, element);
719
718
  };
720
719
  const name$2 = `${PKG_NAME}/Portal`;
721
- Component$2.displayName = name$2;
722
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
723
- // @ts-ignore
724
- Component$2.pkgName = PKG_NAME;
725
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
726
- // @ts-ignore
727
- Component$2.VITUS_LABS__COMPONENT = name$2;
720
+ component$1.displayName = name$2;
721
+ component$1.pkgName = PKG_NAME;
722
+ component$1.VITUS_LABS__COMPONENT = name$2;
728
723
 
729
- const Component$1 = ({ children, trigger, DOMLocation, refName = 'ref', triggerRefName, contentRefName, isOpen = false, openOn = 'click', // click | hover
724
+ const Component = ({ children, trigger, DOMLocation, refName = 'ref', triggerRefName, contentRefName, isOpen = false, openOn = 'click', // click | hover
730
725
  closeOn = 'click', // click | triggerClick | hover | manual
731
726
  type = 'dropdown', // dropdown | tooltip | popover | modal
732
727
  align = 'bottom', // * main align prop * top | left | bottom | right
@@ -947,7 +942,7 @@ offsetX = 0, offsetY = 0, throttleDelay = 200, }) => {
947
942
  const handleWindow = core.throttle(calculateContentPosition, throttleDelay);
948
943
  const handleMouseMove = core.throttle(handleDocumentClick, throttleDelay);
949
944
  const passHandlers = openOn === 'manual' || closeOn === 'manual';
950
- return (React__default['default'].createElement(React__default['default'].Fragment, null,
945
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
951
946
  core.renderContent(trigger, {
952
947
  [triggerRefName || refName]: triggerRef,
953
948
  active: visible,
@@ -956,13 +951,9 @@ offsetX = 0, offsetY = 0, throttleDelay = 200, }) => {
956
951
  false ));
957
952
  };
958
953
  const name$1 = `${PKG_NAME}/Ovelay`;
959
- Component$1.displayName = name$1;
960
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
961
- // @ts-ignore
962
- Component$1.pkgName = PKG_NAME;
963
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
964
- // @ts-ignore
965
- Component$1.VITUS_LABS__COMPONENT = name$1;
954
+ Component.displayName = name$1;
955
+ Component.pkgName = PKG_NAME;
956
+ Component.VITUS_LABS__COMPONENT = name$1;
966
957
 
967
958
  const styles = ({ css, theme: t }) => css `
968
959
  ${t.extraStyles && unistyle.extendCss(t.extraStyles)};
@@ -980,34 +971,27 @@ var Styled = core.config.styled(core.config.textComponent) `
980
971
  })};
981
972
  `;
982
973
 
983
- /* eslint-disable @typescript-eslint/no-explicit-any */
984
- const Component = React.forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
985
- const renderContent = (as = undefined) => (React__default['default'].createElement(Styled, { ref: ref, as: as, "$text": { extraStyles: extendCss }, ...props }, children || label));
974
+ const component = React.forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
975
+ const renderContent = (as = undefined) => (React__default["default"].createElement(Styled, { ref: ref, as: as, "$text": { extraStyles: extendCss }, ...props }, children || label));
986
976
  // eslint-disable-next-line no-nested-ternary
987
977
  const finalTag = (paragraph ? 'p' : tag) ;
988
978
  return renderContent(finalTag);
989
979
  });
990
980
  const name = `${PKG_NAME}/Text`;
991
- Component.displayName = name;
992
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
993
- // @ts-ignore
994
- Component.pkgName = PKG_NAME;
995
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
996
- // @ts-ignore
997
- Component.VITUS_LABS__COMPONENT = name;
998
- Component.isText = true;
981
+ component.displayName = name;
982
+ component.pkgName = PKG_NAME;
983
+ component.VITUS_LABS__COMPONENT = name;
984
+ component.isText = true;
999
985
 
1000
986
  Object.defineProperty(exports, 'Provider', {
1001
987
  enumerable: true,
1002
- get: function () {
1003
- return unistyle.Provider;
1004
- }
988
+ get: function () { return unistyle.Provider; }
1005
989
  });
1006
- exports.Element = component$1;
1007
- exports.List = Component$4;
1008
- exports.Overlay = Component$1;
1009
- exports.Portal = Component$2;
1010
- exports.Text = Component;
1011
- exports.withActiveState = Component$3;
990
+ exports.Element = component$3;
991
+ exports.List = Component$2;
992
+ exports.Overlay = Component;
993
+ exports.Portal = component$1;
994
+ exports.Text = component;
995
+ exports.withActiveState = Component$1;
1012
996
  exports.withEqualSizeBeforeAfter = withEqualBeforeAfter;
1013
997
  //# sourceMappingURL=vitus-labs-elements.js.map