@vitus-labs/elements 0.39.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
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var unistyle = require('@vitus-labs/unistyle');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var core = require('@vitus-labs/core');
|
|
8
|
+
var reactIs = require('react-is');
|
|
8
9
|
var reactDom = require('react-dom');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -79,7 +80,7 @@ var Styled$2 = core.config.styled(core.config.component) `
|
|
|
79
80
|
})};
|
|
80
81
|
`;
|
|
81
82
|
|
|
82
|
-
const component$
|
|
83
|
+
const component$b = React.forwardRef(({ children, tag, block, extendCss, direction, alignX, alignY, equalCols, isInline, ...props }, ref) => {
|
|
83
84
|
const debugProps = process.env.NODE_ENV !== 'production'
|
|
84
85
|
? {
|
|
85
86
|
'data-vl-element': 'Element',
|
|
@@ -187,7 +188,7 @@ var Styled$1 = core.config.styled(core.config.component) `
|
|
|
187
188
|
})};
|
|
188
189
|
`;
|
|
189
190
|
|
|
190
|
-
const component$
|
|
191
|
+
const component$9 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
|
|
191
192
|
const debugProps = process.env.NODE_ENV !== 'production'
|
|
192
193
|
? {
|
|
193
194
|
'data-vl-element': contentType,
|
|
@@ -203,7 +204,7 @@ const component$8 = ({ contentType, tag, parentDirection, direction, alignX, ali
|
|
|
203
204
|
extraStyles: extendCss,
|
|
204
205
|
}, ...debugProps, ...props }));
|
|
205
206
|
};
|
|
206
|
-
var component$
|
|
207
|
+
var component$a = React.memo(component$9);
|
|
207
208
|
|
|
208
209
|
const INLINE_ELEMENTS = {
|
|
209
210
|
span: true,
|
|
@@ -263,7 +264,7 @@ const defaultDirection = 'inline';
|
|
|
263
264
|
const defaultContentDirection = 'rows';
|
|
264
265
|
const defaultAlignX = 'left';
|
|
265
266
|
const defaultAlignY = 'center';
|
|
266
|
-
const component$
|
|
267
|
+
const component$8 = React.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) => {
|
|
267
268
|
// --------------------------------------------------------
|
|
268
269
|
// check if should render only single element
|
|
269
270
|
// --------------------------------------------------------
|
|
@@ -324,18 +325,18 @@ const component$7 = React.forwardRef(({ innerRef, tag, label, content, children,
|
|
|
324
325
|
// return simple/empty element like input or image etc.
|
|
325
326
|
// --------------------------------------------------------
|
|
326
327
|
if (shouldBeEmpty) {
|
|
327
|
-
return React__default["default"].createElement(component$
|
|
328
|
+
return React__default["default"].createElement(component$b, { ...props, ...WRAPPER_PROPS });
|
|
328
329
|
}
|
|
329
330
|
const contentRenderOutput = core.renderContent(CHILDREN);
|
|
330
|
-
return (React__default["default"].createElement(component$
|
|
331
|
-
beforeContent && (React__default["default"].createElement(component$
|
|
332
|
-
isSimpleElement ? (contentRenderOutput) : (React__default["default"].createElement(component$
|
|
333
|
-
afterContent && (React__default["default"].createElement(component$
|
|
331
|
+
return (React__default["default"].createElement(component$b, { ...props, ...WRAPPER_PROPS, isInline: isInline },
|
|
332
|
+
beforeContent && (React__default["default"].createElement(component$a, { tag: SUB_TAG, contentType: "before", parentDirection: wrapperDirection, extendCss: beforeContentCss, direction: beforeContentDirection, alignX: beforeContentAlignX, alignY: beforeContentAlignY, equalCols: equalCols, gap: gap }, core.renderContent(beforeContent))),
|
|
333
|
+
isSimpleElement ? (contentRenderOutput) : (React__default["default"].createElement(component$a, { tag: SUB_TAG, contentType: "content", parentDirection: wrapperDirection, extendCss: contentCss, direction: contentDirection, alignX: contentAlignX, alignY: contentAlignY, equalCols: equalCols }, contentRenderOutput)),
|
|
334
|
+
afterContent && (React__default["default"].createElement(component$a, { tag: SUB_TAG, contentType: "after", parentDirection: wrapperDirection, extendCss: afterContentCss, direction: afterContentDirection, alignX: afterContentAlignX, alignY: afterContentAlignY, equalCols: equalCols, gap: gap }, core.renderContent(afterContent)))));
|
|
334
335
|
});
|
|
335
|
-
const name$
|
|
336
|
-
component$
|
|
337
|
-
component$
|
|
338
|
-
component$
|
|
336
|
+
const name$5 = `${PKG_NAME}/Element`;
|
|
337
|
+
component$8.displayName = name$5;
|
|
338
|
+
component$8.pkgName = PKG_NAME;
|
|
339
|
+
component$8.VITUS_LABS__COMPONENT = name$5;
|
|
339
340
|
|
|
340
341
|
/* eslint-disable no-param-reassign */
|
|
341
342
|
const isNumber = (a, b) => Number.isInteger(a) && Number.isInteger(b);
|
|
@@ -400,7 +401,7 @@ const attachItemProps = ({ i, length, }) => {
|
|
|
400
401
|
position,
|
|
401
402
|
};
|
|
402
403
|
};
|
|
403
|
-
const component$
|
|
404
|
+
const component$7 = (props) => {
|
|
404
405
|
const { itemKey, valueName, children, component, data, wrapComponent: Wrapper, wrapProps, itemProps, } = props;
|
|
405
406
|
const renderedElement = core.renderContent;
|
|
406
407
|
const injectItemProps = React.useMemo(() => (typeof itemProps === 'function' ? itemProps : () => itemProps), [itemProps]);
|
|
@@ -410,34 +411,46 @@ const component$6 = (props) => {
|
|
|
410
411
|
return itemKey(item, index);
|
|
411
412
|
return index;
|
|
412
413
|
}, []);
|
|
414
|
+
const renderChild = (child, total = 1, i = 0) => {
|
|
415
|
+
const extendedProps = attachItemProps({
|
|
416
|
+
i,
|
|
417
|
+
length: total,
|
|
418
|
+
});
|
|
419
|
+
const finalItemProps = itemProps ? injectItemProps({}, extendedProps) : {};
|
|
420
|
+
const finalWrapProps = wrapProps
|
|
421
|
+
? injectWrapItemProps({}, extendedProps)
|
|
422
|
+
: {};
|
|
423
|
+
// if no props extension is required, just return children
|
|
424
|
+
if (!itemProps && !Wrapper)
|
|
425
|
+
return child;
|
|
426
|
+
if (Wrapper) {
|
|
427
|
+
return (React__default["default"].createElement(Wrapper, { key: i, ...finalWrapProps }, renderedElement(child, finalItemProps)));
|
|
428
|
+
}
|
|
429
|
+
return core.renderContent(child, {
|
|
430
|
+
key: i,
|
|
431
|
+
...finalItemProps,
|
|
432
|
+
});
|
|
433
|
+
};
|
|
413
434
|
// --------------------------------------------------------
|
|
414
435
|
// render children
|
|
415
436
|
// --------------------------------------------------------
|
|
416
437
|
const renderChildren = () => {
|
|
417
438
|
if (!children)
|
|
418
439
|
return null;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const finalItemProps = itemProps ? injectItemProps({}, extendedProps) : {};
|
|
430
|
-
const finalWrapProps = wrapProps
|
|
431
|
-
? injectWrapItemProps({}, extendedProps)
|
|
432
|
-
: {};
|
|
433
|
-
if (Wrapper) {
|
|
434
|
-
return (React__default["default"].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(item, finalItemProps)));
|
|
435
|
-
}
|
|
436
|
-
return core.renderContent(item, {
|
|
437
|
-
key: i,
|
|
438
|
-
...finalItemProps,
|
|
440
|
+
// if children is Array
|
|
441
|
+
if (Array.isArray(children)) {
|
|
442
|
+
return React.Children.map(children, (item, i) => renderChild(item, children.length, i));
|
|
443
|
+
}
|
|
444
|
+
// if children is Fragment
|
|
445
|
+
if (reactIs.isFragment(children)) {
|
|
446
|
+
const fragmentChildren = children.props.children;
|
|
447
|
+
return fragmentChildren.map((item, i) => {
|
|
448
|
+
console.log(item);
|
|
449
|
+
return renderChild(item, fragmentChildren.length, i);
|
|
439
450
|
});
|
|
440
|
-
}
|
|
451
|
+
}
|
|
452
|
+
// if single child
|
|
453
|
+
return renderChild(children);
|
|
441
454
|
};
|
|
442
455
|
// --------------------------------------------------------
|
|
443
456
|
// render array of strings or numbers
|
|
@@ -538,19 +551,19 @@ const component$6 = (props) => {
|
|
|
538
551
|
};
|
|
539
552
|
return renderItems();
|
|
540
553
|
};
|
|
541
|
-
component$
|
|
542
|
-
component$
|
|
554
|
+
component$7.isIterator = true;
|
|
555
|
+
component$7.RESERVED_PROPS = RESERVED_PROPS;
|
|
543
556
|
|
|
544
|
-
const component$
|
|
545
|
-
const renderedList = React__default["default"].createElement(component$
|
|
557
|
+
const component$6 = React.forwardRef(({ rootElement = false, ...props }, ref) => {
|
|
558
|
+
const renderedList = React__default["default"].createElement(component$7, { ...core.pick(props, component$7.RESERVED_PROPS) });
|
|
546
559
|
if (!rootElement)
|
|
547
560
|
return renderedList;
|
|
548
|
-
return (React__default["default"].createElement(component$
|
|
561
|
+
return (React__default["default"].createElement(component$8, { ref: ref, ...core.omit(props, component$7.RESERVED_PROPS) }, renderedList));
|
|
549
562
|
});
|
|
550
|
-
const name$
|
|
551
|
-
component$
|
|
552
|
-
component$
|
|
553
|
-
component$
|
|
563
|
+
const name$4 = `${PKG_NAME}/List`;
|
|
564
|
+
component$6.displayName = name$4;
|
|
565
|
+
component$6.pkgName = PKG_NAME;
|
|
566
|
+
component$6.VITUS_LABS__COMPONENT = name$4;
|
|
554
567
|
|
|
555
568
|
const RESERVED_KEYS = [
|
|
556
569
|
'type',
|
|
@@ -558,7 +571,7 @@ const RESERVED_KEYS = [
|
|
|
558
571
|
'itemProps',
|
|
559
572
|
'activeItemRequired',
|
|
560
573
|
];
|
|
561
|
-
const component$
|
|
574
|
+
const component$5 = (WrappedComponent) => {
|
|
562
575
|
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
563
576
|
const Enhanced = (props) => {
|
|
564
577
|
const { type = 'single', activeItemRequired, activeItems, itemProps = {}, ...rest } = props;
|
|
@@ -681,7 +694,7 @@ const component$4 = (WrappedComponent) => {
|
|
|
681
694
|
return Enhanced;
|
|
682
695
|
};
|
|
683
696
|
|
|
684
|
-
const component$
|
|
697
|
+
const component$4 = ({ position = undefined, tag = 'div', children, }) => {
|
|
685
698
|
const [element] = React.useState(undefined);
|
|
686
699
|
if (!position || !element)
|
|
687
700
|
return null;
|
|
@@ -690,15 +703,15 @@ const component$3 = ({ position = undefined, tag = 'div', children, }) => {
|
|
|
690
703
|
}, []);
|
|
691
704
|
return reactDom.createPortal(children, element);
|
|
692
705
|
};
|
|
693
|
-
const name$
|
|
694
|
-
component$
|
|
695
|
-
component$
|
|
696
|
-
component$
|
|
706
|
+
const name$3 = `${PKG_NAME}/Portal`;
|
|
707
|
+
component$4.displayName = name$3;
|
|
708
|
+
component$4.pkgName = PKG_NAME;
|
|
709
|
+
component$4.VITUS_LABS__COMPONENT = name$3;
|
|
697
710
|
|
|
698
711
|
const context = React.createContext({});
|
|
699
712
|
const { Provider } = context;
|
|
700
713
|
const useOverlayContext = () => React.useContext(context);
|
|
701
|
-
const component$
|
|
714
|
+
const component$3 = ({ children, blocked, setBlocked, setUnblocked, }) => (React__default["default"].createElement(Provider, { value: { blocked, setBlocked, setUnblocked } }, children));
|
|
702
715
|
|
|
703
716
|
/* eslint-disable no-console */
|
|
704
717
|
var useOverlay = ({ isOpen = false, openOn = 'click', // click | hover
|
|
@@ -1018,7 +1031,7 @@ offsetX = 0, offsetY = 0, throttleDelay = 200, customScrollListener, closeOnEsc
|
|
|
1018
1031
|
};
|
|
1019
1032
|
};
|
|
1020
1033
|
|
|
1021
|
-
const component$
|
|
1034
|
+
const component$2 = ({ children, trigger, DOMLocation, triggerRefName = 'ref', contentRefName = 'ref', ...props }) => {
|
|
1022
1035
|
const { active, triggerRef, contentRef, showContent, hideContent, align, alignX, alignY, ...ctx } = useOverlay(props);
|
|
1023
1036
|
const { openOn, closeOn } = props;
|
|
1024
1037
|
const passHandlers = React.useMemo(() => openOn === 'manual' ||
|
|
@@ -1032,10 +1045,10 @@ const component$1 = ({ children, trigger, DOMLocation, triggerRefName = 'ref', c
|
|
|
1032
1045
|
}),
|
|
1033
1046
|
false ));
|
|
1034
1047
|
};
|
|
1035
|
-
const name$
|
|
1036
|
-
component$
|
|
1037
|
-
component$
|
|
1038
|
-
component$
|
|
1048
|
+
const name$2 = `${PKG_NAME}/Overlay`;
|
|
1049
|
+
component$2.displayName = name$2;
|
|
1050
|
+
component$2.pkgName = PKG_NAME;
|
|
1051
|
+
component$2.VITUS_LABS__COMPONENT = name$2;
|
|
1039
1052
|
|
|
1040
1053
|
const styles = ({ css, theme: t }) => css `
|
|
1041
1054
|
${t.extraStyles && unistyle.extendCss(t.extraStyles)};
|
|
@@ -1053,29 +1066,36 @@ var Styled = core.config.styled(core.config.textComponent) `
|
|
|
1053
1066
|
})};
|
|
1054
1067
|
`;
|
|
1055
1068
|
|
|
1056
|
-
const component = React.forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
|
|
1069
|
+
const component$1 = React.forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
|
|
1057
1070
|
const renderContent = (as = undefined) => (React__default["default"].createElement(Styled, { ref: ref, as: as, "$text": { extraStyles: extendCss }, ...props }, children || label));
|
|
1058
1071
|
// eslint-disable-next-line no-nested-ternary
|
|
1059
1072
|
const finalTag = (paragraph ? 'p' : tag) ;
|
|
1060
1073
|
return renderContent(finalTag);
|
|
1061
1074
|
});
|
|
1062
|
-
const name = `${PKG_NAME}/Text`;
|
|
1075
|
+
const name$1 = `${PKG_NAME}/Text`;
|
|
1076
|
+
component$1.displayName = name$1;
|
|
1077
|
+
component$1.pkgName = PKG_NAME;
|
|
1078
|
+
component$1.VITUS_LABS__COMPONENT = name$1;
|
|
1079
|
+
component$1.isText = true;
|
|
1080
|
+
|
|
1081
|
+
const component = ({ children, className = '', style = { color: 'blue' }, }) => core.renderContent(children, { className, style });
|
|
1082
|
+
const name = `${PKG_NAME}/Util`;
|
|
1063
1083
|
component.displayName = name;
|
|
1064
1084
|
component.pkgName = PKG_NAME;
|
|
1065
|
-
component.VITUS_LABS__COMPONENT = name;
|
|
1066
|
-
component.isText = true;
|
|
1085
|
+
component.VITUS_LABS__COMPONENT = name;
|
|
1067
1086
|
|
|
1068
1087
|
Object.defineProperty(exports, 'Provider', {
|
|
1069
1088
|
enumerable: true,
|
|
1070
1089
|
get: function () { return unistyle.Provider; }
|
|
1071
1090
|
});
|
|
1072
|
-
exports.Element = component$
|
|
1073
|
-
exports.List = component$
|
|
1074
|
-
exports.Overlay = component$
|
|
1075
|
-
exports.OverlayProvider = component$
|
|
1076
|
-
exports.Portal = component$
|
|
1077
|
-
exports.Text = component;
|
|
1091
|
+
exports.Element = component$8;
|
|
1092
|
+
exports.List = component$6;
|
|
1093
|
+
exports.Overlay = component$2;
|
|
1094
|
+
exports.OverlayProvider = component$3;
|
|
1095
|
+
exports.Portal = component$4;
|
|
1096
|
+
exports.Text = component$1;
|
|
1097
|
+
exports.Util = component;
|
|
1078
1098
|
exports.useOverlay = useOverlay;
|
|
1079
|
-
exports.withActiveState = component$
|
|
1099
|
+
exports.withActiveState = component$5;
|
|
1080
1100
|
exports.withEqualSizeBeforeAfter = withEqualBeforeAfter;
|
|
1081
1101
|
//# sourceMappingURL=vitus-labs-elements.js.map
|