@vitus-labs/elements 0.37.0 → 0.40.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.
- package/lib/analysis/vitus-labs-elements.browser.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.module.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.native.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.umd.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.umd.min.js.html +1 -1
- package/lib/index.d.ts +27 -20
- package/lib/types/Util/component.d.ts +2 -2
- package/lib/types/helpers/Iterator/types.d.ts +1 -1
- package/lib/types/index.d.ts +4 -3
- package/lib/vitus-labs-elements.browser.js +82 -63
- package/lib/vitus-labs-elements.browser.js.map +1 -1
- package/lib/vitus-labs-elements.js +87 -67
- package/lib/vitus-labs-elements.js.map +1 -1
- package/lib/vitus-labs-elements.module.js +80 -61
- package/lib/vitus-labs-elements.module.js.map +1 -1
- package/lib/vitus-labs-elements.native.js +80 -61
- package/lib/vitus-labs-elements.native.js.map +1 -1
- package/lib/vitus-labs-elements.umd.js +90 -71
- package/lib/vitus-labs-elements.umd.js.map +1 -1
- package/lib/vitus-labs-elements.umd.min.js +6 -6
- package/lib/vitus-labs-elements.umd.min.js.map +1 -1
- package/package.json +8 -5
|
@@ -2,6 +2,7 @@ import { makeItResponsive, alignContent, extendCss, value } from '@vitus-labs/un
|
|
|
2
2
|
export { Provider } from '@vitus-labs/unistyle';
|
|
3
3
|
import React, { forwardRef, memo, useMemo, createRef, useCallback, Children, useState, useEffect, createContext, useContext, useRef } from 'react';
|
|
4
4
|
import { config, renderContent, get, isEmpty, pick, omit, context as context$1, throttle } from '@vitus-labs/core';
|
|
5
|
+
import { isFragment } from 'react-is';
|
|
5
6
|
import { createPortal } from 'react-dom';
|
|
6
7
|
|
|
7
8
|
// eslint-disable-next-line import/prefer-default-export
|
|
@@ -72,7 +73,7 @@ var Styled$2 = config.styled(config.component) `
|
|
|
72
73
|
})};
|
|
73
74
|
`;
|
|
74
75
|
|
|
75
|
-
const component$
|
|
76
|
+
const component$b = forwardRef(({ children, tag, block, extendCss, direction, alignX, alignY, equalCols, isInline, ...props }, ref) => {
|
|
76
77
|
const debugProps = process.env.NODE_ENV !== 'production'
|
|
77
78
|
? {
|
|
78
79
|
'data-vl-element': 'Element',
|
|
@@ -180,7 +181,7 @@ var Styled$1 = config.styled(config.component) `
|
|
|
180
181
|
})};
|
|
181
182
|
`;
|
|
182
183
|
|
|
183
|
-
const component$
|
|
184
|
+
const component$9 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
|
|
184
185
|
const debugProps = process.env.NODE_ENV !== 'production'
|
|
185
186
|
? {
|
|
186
187
|
'data-vl-element': contentType,
|
|
@@ -196,7 +197,7 @@ const component$8 = ({ contentType, tag, parentDirection, direction, alignX, ali
|
|
|
196
197
|
extraStyles: extendCss,
|
|
197
198
|
}, ...debugProps, ...props }));
|
|
198
199
|
};
|
|
199
|
-
var component$
|
|
200
|
+
var component$a = memo(component$9);
|
|
200
201
|
|
|
201
202
|
const INLINE_ELEMENTS = {
|
|
202
203
|
span: true,
|
|
@@ -256,7 +257,7 @@ const defaultDirection = 'inline';
|
|
|
256
257
|
const defaultContentDirection = 'rows';
|
|
257
258
|
const defaultAlignX = 'left';
|
|
258
259
|
const defaultAlignY = 'center';
|
|
259
|
-
const component$
|
|
260
|
+
const component$8 = forwardRef(({ innerRef, tag, label, content, children, beforeContent, afterContent, block, equalCols, gap, direction, alignX = defaultAlignX, alignY = defaultAlignY, css, contentCss, beforeContentCss, afterContentCss, contentDirection = defaultContentDirection, contentAlignX = defaultAlignX, contentAlignY = defaultAlignY, beforeContentDirection = defaultDirection, beforeContentAlignX = defaultAlignX, beforeContentAlignY = defaultAlignY, afterContentDirection = defaultDirection, afterContentAlignX = defaultAlignX, afterContentAlignY = defaultAlignY, ...props }, ref) => {
|
|
260
261
|
// --------------------------------------------------------
|
|
261
262
|
// check if should render only single element
|
|
262
263
|
// --------------------------------------------------------
|
|
@@ -317,18 +318,18 @@ const component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
|
|
|
317
318
|
// return simple/empty element like input or image etc.
|
|
318
319
|
// --------------------------------------------------------
|
|
319
320
|
if (shouldBeEmpty) {
|
|
320
|
-
return React.createElement(component$
|
|
321
|
+
return React.createElement(component$b, { ...props, ...WRAPPER_PROPS });
|
|
321
322
|
}
|
|
322
323
|
const contentRenderOutput = renderContent(CHILDREN);
|
|
323
|
-
return (React.createElement(component$
|
|
324
|
-
beforeContent && (React.createElement(component$
|
|
325
|
-
isSimpleElement ? (contentRenderOutput) : (React.createElement(component$
|
|
326
|
-
afterContent && (React.createElement(component$
|
|
324
|
+
return (React.createElement(component$b, { ...props, ...WRAPPER_PROPS, isInline: isInline },
|
|
325
|
+
beforeContent && (React.createElement(component$a, { tag: SUB_TAG, contentType: "before", parentDirection: wrapperDirection, extendCss: beforeContentCss, direction: beforeContentDirection, alignX: beforeContentAlignX, alignY: beforeContentAlignY, equalCols: equalCols, gap: gap }, renderContent(beforeContent))),
|
|
326
|
+
isSimpleElement ? (contentRenderOutput) : (React.createElement(component$a, { tag: SUB_TAG, contentType: "content", parentDirection: wrapperDirection, extendCss: contentCss, direction: contentDirection, alignX: contentAlignX, alignY: contentAlignY, equalCols: equalCols }, contentRenderOutput)),
|
|
327
|
+
afterContent && (React.createElement(component$a, { tag: SUB_TAG, contentType: "after", parentDirection: wrapperDirection, extendCss: afterContentCss, direction: afterContentDirection, alignX: afterContentAlignX, alignY: afterContentAlignY, equalCols: equalCols, gap: gap }, renderContent(afterContent)))));
|
|
327
328
|
});
|
|
328
|
-
const name$
|
|
329
|
-
component$
|
|
330
|
-
component$
|
|
331
|
-
component$
|
|
329
|
+
const name$5 = `${PKG_NAME}/Element`;
|
|
330
|
+
component$8.displayName = name$5;
|
|
331
|
+
component$8.pkgName = PKG_NAME;
|
|
332
|
+
component$8.VITUS_LABS__COMPONENT = name$5;
|
|
332
333
|
|
|
333
334
|
/* eslint-disable no-param-reassign */
|
|
334
335
|
const isNumber = (a, b) => Number.isInteger(a) && Number.isInteger(b);
|
|
@@ -393,7 +394,7 @@ const attachItemProps = ({ i, length, }) => {
|
|
|
393
394
|
position,
|
|
394
395
|
};
|
|
395
396
|
};
|
|
396
|
-
const component$
|
|
397
|
+
const component$7 = (props) => {
|
|
397
398
|
const { itemKey, valueName, children, component, data, wrapComponent: Wrapper, wrapProps, itemProps, } = props;
|
|
398
399
|
const renderedElement = renderContent;
|
|
399
400
|
const injectItemProps = useMemo(() => (typeof itemProps === 'function' ? itemProps : () => itemProps), [itemProps]);
|
|
@@ -403,34 +404,46 @@ const component$6 = (props) => {
|
|
|
403
404
|
return itemKey(item, index);
|
|
404
405
|
return index;
|
|
405
406
|
}, []);
|
|
407
|
+
const renderChild = (child, total = 1, i = 0) => {
|
|
408
|
+
const extendedProps = attachItemProps({
|
|
409
|
+
i,
|
|
410
|
+
length: total,
|
|
411
|
+
});
|
|
412
|
+
const finalItemProps = itemProps ? injectItemProps({}, extendedProps) : {};
|
|
413
|
+
const finalWrapProps = wrapProps
|
|
414
|
+
? injectWrapItemProps({}, extendedProps)
|
|
415
|
+
: {};
|
|
416
|
+
// if no props extension is required, just return children
|
|
417
|
+
if (!itemProps && !Wrapper)
|
|
418
|
+
return child;
|
|
419
|
+
if (Wrapper) {
|
|
420
|
+
return (React.createElement(Wrapper, { key: i, ...finalWrapProps }, renderedElement(child, finalItemProps)));
|
|
421
|
+
}
|
|
422
|
+
return renderContent(child, {
|
|
423
|
+
key: i,
|
|
424
|
+
...finalItemProps,
|
|
425
|
+
});
|
|
426
|
+
};
|
|
406
427
|
// --------------------------------------------------------
|
|
407
428
|
// render children
|
|
408
429
|
// --------------------------------------------------------
|
|
409
430
|
const renderChildren = () => {
|
|
410
431
|
if (!children)
|
|
411
432
|
return null;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const finalItemProps = itemProps ? injectItemProps({}, extendedProps) : {};
|
|
423
|
-
const finalWrapProps = wrapProps
|
|
424
|
-
? injectWrapItemProps({}, extendedProps)
|
|
425
|
-
: {};
|
|
426
|
-
if (Wrapper) {
|
|
427
|
-
return (React.createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(item, finalItemProps)));
|
|
428
|
-
}
|
|
429
|
-
return renderContent(item, {
|
|
430
|
-
key: i,
|
|
431
|
-
...finalItemProps,
|
|
433
|
+
// if children is Array
|
|
434
|
+
if (Array.isArray(children)) {
|
|
435
|
+
return Children.map(children, (item, i) => renderChild(item, children.length, i));
|
|
436
|
+
}
|
|
437
|
+
// if children is Fragment
|
|
438
|
+
if (isFragment(children)) {
|
|
439
|
+
const fragmentChildren = children.props.children;
|
|
440
|
+
return fragmentChildren.map((item, i) => {
|
|
441
|
+
console.log(item);
|
|
442
|
+
return renderChild(item, fragmentChildren.length, i);
|
|
432
443
|
});
|
|
433
|
-
}
|
|
444
|
+
}
|
|
445
|
+
// if single child
|
|
446
|
+
return renderChild(children);
|
|
434
447
|
};
|
|
435
448
|
// --------------------------------------------------------
|
|
436
449
|
// render array of strings or numbers
|
|
@@ -531,19 +544,19 @@ const component$6 = (props) => {
|
|
|
531
544
|
};
|
|
532
545
|
return renderItems();
|
|
533
546
|
};
|
|
534
|
-
component$
|
|
535
|
-
component$
|
|
547
|
+
component$7.isIterator = true;
|
|
548
|
+
component$7.RESERVED_PROPS = RESERVED_PROPS;
|
|
536
549
|
|
|
537
|
-
const component$
|
|
538
|
-
const renderedList = React.createElement(component$
|
|
550
|
+
const component$6 = forwardRef(({ rootElement = false, ...props }, ref) => {
|
|
551
|
+
const renderedList = React.createElement(component$7, { ...pick(props, component$7.RESERVED_PROPS) });
|
|
539
552
|
if (!rootElement)
|
|
540
553
|
return renderedList;
|
|
541
|
-
return (React.createElement(component$
|
|
554
|
+
return (React.createElement(component$8, { ref: ref, ...omit(props, component$7.RESERVED_PROPS) }, renderedList));
|
|
542
555
|
});
|
|
543
|
-
const name$
|
|
544
|
-
component$
|
|
545
|
-
component$
|
|
546
|
-
component$
|
|
556
|
+
const name$4 = `${PKG_NAME}/List`;
|
|
557
|
+
component$6.displayName = name$4;
|
|
558
|
+
component$6.pkgName = PKG_NAME;
|
|
559
|
+
component$6.VITUS_LABS__COMPONENT = name$4;
|
|
547
560
|
|
|
548
561
|
const RESERVED_KEYS = [
|
|
549
562
|
'type',
|
|
@@ -551,7 +564,7 @@ const RESERVED_KEYS = [
|
|
|
551
564
|
'itemProps',
|
|
552
565
|
'activeItemRequired',
|
|
553
566
|
];
|
|
554
|
-
const component$
|
|
567
|
+
const component$5 = (WrappedComponent) => {
|
|
555
568
|
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
556
569
|
const Enhanced = (props) => {
|
|
557
570
|
const { type = 'single', activeItemRequired, activeItems, itemProps = {}, ...rest } = props;
|
|
@@ -674,7 +687,7 @@ const component$4 = (WrappedComponent) => {
|
|
|
674
687
|
return Enhanced;
|
|
675
688
|
};
|
|
676
689
|
|
|
677
|
-
const component$
|
|
690
|
+
const component$4 = ({ position = undefined, tag = 'div', children, }) => {
|
|
678
691
|
const [element] = useState(undefined);
|
|
679
692
|
if (!position || !element)
|
|
680
693
|
return null;
|
|
@@ -686,15 +699,15 @@ const component$3 = ({ position = undefined, tag = 'div', children, }) => {
|
|
|
686
699
|
}, []);
|
|
687
700
|
return createPortal(children, element);
|
|
688
701
|
};
|
|
689
|
-
const name$
|
|
690
|
-
component$
|
|
691
|
-
component$
|
|
692
|
-
component$
|
|
702
|
+
const name$3 = `${PKG_NAME}/Portal`;
|
|
703
|
+
component$4.displayName = name$3;
|
|
704
|
+
component$4.pkgName = PKG_NAME;
|
|
705
|
+
component$4.VITUS_LABS__COMPONENT = name$3;
|
|
693
706
|
|
|
694
707
|
const context = createContext({});
|
|
695
708
|
const { Provider } = context;
|
|
696
709
|
const useOverlayContext = () => useContext(context);
|
|
697
|
-
const component$
|
|
710
|
+
const component$3 = ({ children, blocked, setBlocked, setUnblocked, }) => (React.createElement(Provider, { value: { blocked, setBlocked, setUnblocked } }, children));
|
|
698
711
|
|
|
699
712
|
/* eslint-disable no-console */
|
|
700
713
|
var useOverlay = ({ isOpen = false, openOn = 'click', // click | hover
|
|
@@ -1014,7 +1027,7 @@ offsetX = 0, offsetY = 0, throttleDelay = 200, customScrollListener, closeOnEsc
|
|
|
1014
1027
|
};
|
|
1015
1028
|
};
|
|
1016
1029
|
|
|
1017
|
-
const component$
|
|
1030
|
+
const component$2 = ({ children, trigger, DOMLocation, triggerRefName = 'ref', contentRefName = 'ref', ...props }) => {
|
|
1018
1031
|
const { active, triggerRef, contentRef, showContent, hideContent, align, alignX, alignY, ...ctx } = useOverlay(props);
|
|
1019
1032
|
const { openOn, closeOn } = props;
|
|
1020
1033
|
const passHandlers = useMemo(() => openOn === 'manual' ||
|
|
@@ -1028,10 +1041,10 @@ const component$1 = ({ children, trigger, DOMLocation, triggerRefName = 'ref', c
|
|
|
1028
1041
|
}),
|
|
1029
1042
|
false ));
|
|
1030
1043
|
};
|
|
1031
|
-
const name$
|
|
1032
|
-
component$
|
|
1033
|
-
component$
|
|
1034
|
-
component$
|
|
1044
|
+
const name$2 = `${PKG_NAME}/Overlay`;
|
|
1045
|
+
component$2.displayName = name$2;
|
|
1046
|
+
component$2.pkgName = PKG_NAME;
|
|
1047
|
+
component$2.VITUS_LABS__COMPONENT = name$2;
|
|
1035
1048
|
|
|
1036
1049
|
const styles = ({ css, theme: t }) => css `
|
|
1037
1050
|
${t.extraStyles && extendCss(t.extraStyles)};
|
|
@@ -1049,17 +1062,23 @@ var Styled = config.styled(config.textComponent) `
|
|
|
1049
1062
|
})};
|
|
1050
1063
|
`;
|
|
1051
1064
|
|
|
1052
|
-
const component = forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
|
|
1065
|
+
const component$1 = forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
|
|
1053
1066
|
const renderContent = (as = undefined) => (React.createElement(Styled, { ref: ref, as: as, "$text": { extraStyles: extendCss }, ...props }, children || label));
|
|
1054
1067
|
// eslint-disable-next-line no-nested-ternary
|
|
1055
1068
|
const finalTag = (paragraph ? 'p' : tag) ;
|
|
1056
1069
|
return renderContent(finalTag);
|
|
1057
1070
|
});
|
|
1058
|
-
const name = `${PKG_NAME}/Text`;
|
|
1071
|
+
const name$1 = `${PKG_NAME}/Text`;
|
|
1072
|
+
component$1.displayName = name$1;
|
|
1073
|
+
component$1.pkgName = PKG_NAME;
|
|
1074
|
+
component$1.VITUS_LABS__COMPONENT = name$1;
|
|
1075
|
+
component$1.isText = true;
|
|
1076
|
+
|
|
1077
|
+
const component = ({ children, className = '', style = { color: 'blue' }, }) => renderContent(children, { className, style });
|
|
1078
|
+
const name = `${PKG_NAME}/Util`;
|
|
1059
1079
|
component.displayName = name;
|
|
1060
1080
|
component.pkgName = PKG_NAME;
|
|
1061
|
-
component.VITUS_LABS__COMPONENT = name;
|
|
1062
|
-
component.isText = true;
|
|
1081
|
+
component.VITUS_LABS__COMPONENT = name;
|
|
1063
1082
|
|
|
1064
|
-
export { component$
|
|
1083
|
+
export { component$8 as Element, component$6 as List, component$2 as Overlay, component$3 as OverlayProvider, component$4 as Portal, component$1 as Text, component as Util, useOverlay, component$5 as withActiveState, withEqualBeforeAfter as withEqualSizeBeforeAfter };
|
|
1065
1084
|
//# sourceMappingURL=vitus-labs-elements.module.js.map
|