@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@vitus-labs/unistyle'), require('react'), require('@vitus-labs/core'), require('react-dom')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@vitus-labs/unistyle', 'react', '@vitus-labs/core', 'react-dom'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vitusLabsElements = {}, global.unistyle, global.React, global.core, global.ReactDOM));
|
|
5
|
-
})(this, (function (exports, unistyle, React, core, reactDom) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@vitus-labs/unistyle'), require('react'), require('@vitus-labs/core'), require('react-is'), require('react-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@vitus-labs/unistyle', 'react', '@vitus-labs/core', 'react-is', 'react-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vitusLabsElements = {}, global.unistyle, global.React, global.core, global.ReactIs, global.ReactDOM));
|
|
5
|
+
})(this, (function (exports, unistyle, React, core, reactIs, reactDom) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
})};
|
|
77
77
|
`;
|
|
78
78
|
|
|
79
|
-
const component$
|
|
79
|
+
const component$b = React.forwardRef(({ children, tag, block, extendCss, direction, alignX, alignY, equalCols, isInline, ...props }, ref) => {
|
|
80
80
|
const debugProps = process.env.NODE_ENV !== 'production'
|
|
81
81
|
? {
|
|
82
82
|
'data-vl-element': 'Element',
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
})};
|
|
185
185
|
`;
|
|
186
186
|
|
|
187
|
-
const component$
|
|
187
|
+
const component$9 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
|
|
188
188
|
const debugProps = process.env.NODE_ENV !== 'production'
|
|
189
189
|
? {
|
|
190
190
|
'data-vl-element': contentType,
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
extraStyles: extendCss,
|
|
201
201
|
}, ...debugProps, ...props }));
|
|
202
202
|
};
|
|
203
|
-
var component$
|
|
203
|
+
var component$a = React.memo(component$9);
|
|
204
204
|
|
|
205
205
|
const INLINE_ELEMENTS = {
|
|
206
206
|
span: true,
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
const defaultContentDirection = 'rows';
|
|
261
261
|
const defaultAlignX = 'left';
|
|
262
262
|
const defaultAlignY = 'center';
|
|
263
|
-
const component$
|
|
263
|
+
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) => {
|
|
264
264
|
// --------------------------------------------------------
|
|
265
265
|
// check if should render only single element
|
|
266
266
|
// --------------------------------------------------------
|
|
@@ -321,18 +321,18 @@
|
|
|
321
321
|
// return simple/empty element like input or image etc.
|
|
322
322
|
// --------------------------------------------------------
|
|
323
323
|
if (shouldBeEmpty) {
|
|
324
|
-
return React__default["default"].createElement(component$
|
|
324
|
+
return React__default["default"].createElement(component$b, { ...props, ...WRAPPER_PROPS });
|
|
325
325
|
}
|
|
326
326
|
const contentRenderOutput = core.renderContent(CHILDREN);
|
|
327
|
-
return (React__default["default"].createElement(component$
|
|
328
|
-
beforeContent && (React__default["default"].createElement(component$
|
|
329
|
-
isSimpleElement ? (contentRenderOutput) : (React__default["default"].createElement(component$
|
|
330
|
-
afterContent && (React__default["default"].createElement(component$
|
|
327
|
+
return (React__default["default"].createElement(component$b, { ...props, ...WRAPPER_PROPS, isInline: isInline },
|
|
328
|
+
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))),
|
|
329
|
+
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)),
|
|
330
|
+
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)))));
|
|
331
331
|
});
|
|
332
|
-
const name$
|
|
333
|
-
component$
|
|
334
|
-
component$
|
|
335
|
-
component$
|
|
332
|
+
const name$5 = `${PKG_NAME}/Element`;
|
|
333
|
+
component$8.displayName = name$5;
|
|
334
|
+
component$8.pkgName = PKG_NAME;
|
|
335
|
+
component$8.VITUS_LABS__COMPONENT = name$5;
|
|
336
336
|
|
|
337
337
|
/* eslint-disable no-param-reassign */
|
|
338
338
|
const isNumber = (a, b) => Number.isInteger(a) && Number.isInteger(b);
|
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
position,
|
|
398
398
|
};
|
|
399
399
|
};
|
|
400
|
-
const component$
|
|
400
|
+
const component$7 = (props) => {
|
|
401
401
|
const { itemKey, valueName, children, component, data, wrapComponent: Wrapper, wrapProps, itemProps, } = props;
|
|
402
402
|
const renderedElement = core.renderContent;
|
|
403
403
|
const injectItemProps = React.useMemo(() => (typeof itemProps === 'function' ? itemProps : () => itemProps), [itemProps]);
|
|
@@ -407,34 +407,46 @@
|
|
|
407
407
|
return itemKey(item, index);
|
|
408
408
|
return index;
|
|
409
409
|
}, []);
|
|
410
|
+
const renderChild = (child, total = 1, i = 0) => {
|
|
411
|
+
const extendedProps = attachItemProps({
|
|
412
|
+
i,
|
|
413
|
+
length: total,
|
|
414
|
+
});
|
|
415
|
+
const finalItemProps = itemProps ? injectItemProps({}, extendedProps) : {};
|
|
416
|
+
const finalWrapProps = wrapProps
|
|
417
|
+
? injectWrapItemProps({}, extendedProps)
|
|
418
|
+
: {};
|
|
419
|
+
// if no props extension is required, just return children
|
|
420
|
+
if (!itemProps && !Wrapper)
|
|
421
|
+
return child;
|
|
422
|
+
if (Wrapper) {
|
|
423
|
+
return (React__default["default"].createElement(Wrapper, { key: i, ...finalWrapProps }, renderedElement(child, finalItemProps)));
|
|
424
|
+
}
|
|
425
|
+
return core.renderContent(child, {
|
|
426
|
+
key: i,
|
|
427
|
+
...finalItemProps,
|
|
428
|
+
});
|
|
429
|
+
};
|
|
410
430
|
// --------------------------------------------------------
|
|
411
431
|
// render children
|
|
412
432
|
// --------------------------------------------------------
|
|
413
433
|
const renderChildren = () => {
|
|
414
434
|
if (!children)
|
|
415
435
|
return null;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const finalItemProps = itemProps ? injectItemProps({}, extendedProps) : {};
|
|
427
|
-
const finalWrapProps = wrapProps
|
|
428
|
-
? injectWrapItemProps({}, extendedProps)
|
|
429
|
-
: {};
|
|
430
|
-
if (Wrapper) {
|
|
431
|
-
return (React__default["default"].createElement(Wrapper, { key: key, ...finalWrapProps }, renderedElement(item, finalItemProps)));
|
|
432
|
-
}
|
|
433
|
-
return core.renderContent(item, {
|
|
434
|
-
key: i,
|
|
435
|
-
...finalItemProps,
|
|
436
|
+
// if children is Array
|
|
437
|
+
if (Array.isArray(children)) {
|
|
438
|
+
return React.Children.map(children, (item, i) => renderChild(item, children.length, i));
|
|
439
|
+
}
|
|
440
|
+
// if children is Fragment
|
|
441
|
+
if (reactIs.isFragment(children)) {
|
|
442
|
+
const fragmentChildren = children.props.children;
|
|
443
|
+
return fragmentChildren.map((item, i) => {
|
|
444
|
+
console.log(item);
|
|
445
|
+
return renderChild(item, fragmentChildren.length, i);
|
|
436
446
|
});
|
|
437
|
-
}
|
|
447
|
+
}
|
|
448
|
+
// if single child
|
|
449
|
+
return renderChild(children);
|
|
438
450
|
};
|
|
439
451
|
// --------------------------------------------------------
|
|
440
452
|
// render array of strings or numbers
|
|
@@ -535,19 +547,19 @@
|
|
|
535
547
|
};
|
|
536
548
|
return renderItems();
|
|
537
549
|
};
|
|
538
|
-
component$
|
|
539
|
-
component$
|
|
550
|
+
component$7.isIterator = true;
|
|
551
|
+
component$7.RESERVED_PROPS = RESERVED_PROPS;
|
|
540
552
|
|
|
541
|
-
const component$
|
|
542
|
-
const renderedList = React__default["default"].createElement(component$
|
|
553
|
+
const component$6 = React.forwardRef(({ rootElement = false, ...props }, ref) => {
|
|
554
|
+
const renderedList = React__default["default"].createElement(component$7, { ...core.pick(props, component$7.RESERVED_PROPS) });
|
|
543
555
|
if (!rootElement)
|
|
544
556
|
return renderedList;
|
|
545
|
-
return (React__default["default"].createElement(component$
|
|
557
|
+
return (React__default["default"].createElement(component$8, { ref: ref, ...core.omit(props, component$7.RESERVED_PROPS) }, renderedList));
|
|
546
558
|
});
|
|
547
|
-
const name$
|
|
548
|
-
component$
|
|
549
|
-
component$
|
|
550
|
-
component$
|
|
559
|
+
const name$4 = `${PKG_NAME}/List`;
|
|
560
|
+
component$6.displayName = name$4;
|
|
561
|
+
component$6.pkgName = PKG_NAME;
|
|
562
|
+
component$6.VITUS_LABS__COMPONENT = name$4;
|
|
551
563
|
|
|
552
564
|
const RESERVED_KEYS = [
|
|
553
565
|
'type',
|
|
@@ -555,7 +567,7 @@
|
|
|
555
567
|
'itemProps',
|
|
556
568
|
'activeItemRequired',
|
|
557
569
|
];
|
|
558
|
-
const component$
|
|
570
|
+
const component$5 = (WrappedComponent) => {
|
|
559
571
|
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
560
572
|
const Enhanced = (props) => {
|
|
561
573
|
const { type = 'single', activeItemRequired, activeItems, itemProps = {}, ...rest } = props;
|
|
@@ -678,7 +690,7 @@
|
|
|
678
690
|
return Enhanced;
|
|
679
691
|
};
|
|
680
692
|
|
|
681
|
-
const component$
|
|
693
|
+
const component$4 = ({ position = undefined, tag = 'div', children, }) => {
|
|
682
694
|
const [element] = React.useState(undefined);
|
|
683
695
|
if (!position || !element)
|
|
684
696
|
return null;
|
|
@@ -687,15 +699,15 @@
|
|
|
687
699
|
}, []);
|
|
688
700
|
return reactDom.createPortal(children, element);
|
|
689
701
|
};
|
|
690
|
-
const name$
|
|
691
|
-
component$
|
|
692
|
-
component$
|
|
693
|
-
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;
|
|
694
706
|
|
|
695
707
|
const context = React.createContext({});
|
|
696
708
|
const { Provider } = context;
|
|
697
709
|
const useOverlayContext = () => React.useContext(context);
|
|
698
|
-
const component$
|
|
710
|
+
const component$3 = ({ children, blocked, setBlocked, setUnblocked, }) => (React__default["default"].createElement(Provider, { value: { blocked, setBlocked, setUnblocked } }, children));
|
|
699
711
|
|
|
700
712
|
/* eslint-disable no-console */
|
|
701
713
|
var useOverlay = ({ isOpen = false, openOn = 'click', // click | hover
|
|
@@ -1015,7 +1027,7 @@
|
|
|
1015
1027
|
};
|
|
1016
1028
|
};
|
|
1017
1029
|
|
|
1018
|
-
const component$
|
|
1030
|
+
const component$2 = ({ children, trigger, DOMLocation, triggerRefName = 'ref', contentRefName = 'ref', ...props }) => {
|
|
1019
1031
|
const { active, triggerRef, contentRef, showContent, hideContent, align, alignX, alignY, ...ctx } = useOverlay(props);
|
|
1020
1032
|
const { openOn, closeOn } = props;
|
|
1021
1033
|
const passHandlers = React.useMemo(() => openOn === 'manual' ||
|
|
@@ -1029,10 +1041,10 @@
|
|
|
1029
1041
|
}),
|
|
1030
1042
|
false ));
|
|
1031
1043
|
};
|
|
1032
|
-
const name$
|
|
1033
|
-
component$
|
|
1034
|
-
component$
|
|
1035
|
-
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;
|
|
1036
1048
|
|
|
1037
1049
|
const styles = ({ css, theme: t }) => css `
|
|
1038
1050
|
${t.extraStyles && unistyle.extendCss(t.extraStyles)};
|
|
@@ -1050,30 +1062,37 @@
|
|
|
1050
1062
|
})};
|
|
1051
1063
|
`;
|
|
1052
1064
|
|
|
1053
|
-
const component = React.forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
|
|
1065
|
+
const component$1 = React.forwardRef(({ paragraph, label, children, tag, extendCss, ...props }, ref) => {
|
|
1054
1066
|
const renderContent = (as = undefined) => (React__default["default"].createElement(Styled, { ref: ref, as: as, "$text": { extraStyles: extendCss }, ...props }, children || label));
|
|
1055
1067
|
// eslint-disable-next-line no-nested-ternary
|
|
1056
1068
|
const finalTag = (paragraph ? 'p' : tag) ;
|
|
1057
1069
|
return renderContent(finalTag);
|
|
1058
1070
|
});
|
|
1059
|
-
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' }, }) => core.renderContent(children, { className, style });
|
|
1078
|
+
const name = `${PKG_NAME}/Util`;
|
|
1060
1079
|
component.displayName = name;
|
|
1061
1080
|
component.pkgName = PKG_NAME;
|
|
1062
|
-
component.VITUS_LABS__COMPONENT = name;
|
|
1063
|
-
component.isText = true;
|
|
1081
|
+
component.VITUS_LABS__COMPONENT = name;
|
|
1064
1082
|
|
|
1065
1083
|
Object.defineProperty(exports, 'Provider', {
|
|
1066
1084
|
enumerable: true,
|
|
1067
1085
|
get: function () { return unistyle.Provider; }
|
|
1068
1086
|
});
|
|
1069
|
-
exports.Element = component$
|
|
1070
|
-
exports.List = component$
|
|
1071
|
-
exports.Overlay = component$
|
|
1072
|
-
exports.OverlayProvider = component$
|
|
1073
|
-
exports.Portal = component$
|
|
1074
|
-
exports.Text = component;
|
|
1087
|
+
exports.Element = component$8;
|
|
1088
|
+
exports.List = component$6;
|
|
1089
|
+
exports.Overlay = component$2;
|
|
1090
|
+
exports.OverlayProvider = component$3;
|
|
1091
|
+
exports.Portal = component$4;
|
|
1092
|
+
exports.Text = component$1;
|
|
1093
|
+
exports.Util = component;
|
|
1075
1094
|
exports.useOverlay = useOverlay;
|
|
1076
|
-
exports.withActiveState = component$
|
|
1095
|
+
exports.withActiveState = component$5;
|
|
1077
1096
|
exports.withEqualSizeBeforeAfter = withEqualBeforeAfter;
|
|
1078
1097
|
|
|
1079
1098
|
Object.defineProperty(exports, '__esModule', { value: true });
|