@homecode/ui 4.22.7 → 4.22.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.
@@ -2,7 +2,19 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import S from './Flex.styl.js';
3
3
 
4
4
  const Flex = ({ children, ...props }) => {
5
- return (jsx("div", { className: S.root, ...props, children: children }));
5
+ return (jsx("div", { className: S.root, ...props, style: {
6
+ justifyContent: props.justifyContent,
7
+ alignItems: props.alignItems,
8
+ flexDirection: props.flexDirection,
9
+ flexWrap: props.flexWrap,
10
+ flexGrow: props.flexGrow,
11
+ flexShrink: props.flexShrink,
12
+ flexBasis: props.flexBasis,
13
+ flex: props.flex,
14
+ order: props.order,
15
+ alignSelf: props.alignSelf,
16
+ flexFlow: props.flexFlow,
17
+ }, children: children }));
6
18
  };
7
19
 
8
20
  export { Flex };
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+
3
+ var _path;
4
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
+ var SvgDragHandlerHorizontal = function SvgDragHandlerHorizontal(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ fill: "currentColor",
9
+ viewBox: "0 0 24 24"
10
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
11
+ d: "M16 9.293a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 20 9.297a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 16 9.293m-2-.003a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 10 9.286a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 14 9.29m-6-.007a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 4 9.28a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 8 9.283m8 6.01a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 20 15.297a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 16 15.293m-2-.003a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 10 15.286a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 14 15.29m-6-.007a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 4 15.28a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 8 15.283"
12
+ })));
13
+ };
14
+
15
+ export { SvgDragHandlerHorizontal as default };
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+
3
+ var _path;
4
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
+ var SvgDragHandlerVertical = function SvgDragHandlerVertical(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ fill: "currentColor",
9
+ viewBox: "0 0 24 24"
10
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
11
+ d: "M14.995 16.288a2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002 2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002m.003-2A2.006 2.006 0 0 0 17 12.29a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 13 12.286a2.006 2.006 0 0 0 1.998 2.002m.007-6a2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002 2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002m-6.01 8a2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002 2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002m.003-2A2.006 2.006 0 0 0 11 12.29a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 7 12.286a2.006 2.006 0 0 0 1.998 2.002m.007-6a2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002 2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002"
12
+ })));
13
+ };
14
+
15
+ export { SvgDragHandlerVertical as default };
@@ -18,6 +18,8 @@ var ICONS = {
18
18
  clearAll: () => import('./clearAll.svg.js'),
19
19
  delete: () => import('./delete.svg.js'),
20
20
  draft: () => import('./draft.svg.js'),
21
+ dragHandlerHorizontal: () => import('./dragHandlerHorizontal.svg.js'),
22
+ dragHandlerVertical: () => import('./dragHandlerVertical.svg.js'),
21
23
  edit: () => import('./edit.svg.js'),
22
24
  email: () => import('./email.svg.js'),
23
25
  externalLink: () => import('./externalLink.svg.js'),
@@ -2,8 +2,8 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import { Component } from 'react';
3
3
  import Time from 'timen';
4
4
  import { createStore } from 'justorm/react';
5
- import { Container } from '../Container/Container.js';
6
5
  import { Spinner } from '../Spinner/Spinner.js';
6
+ import { Flex } from '../Flex/Flex.js';
7
7
 
8
8
  function compare(cb1, cb2) {
9
9
  return cb1?.toString() === cb2?.toString();
@@ -11,23 +11,25 @@ function compare(cb1, cb2) {
11
11
  const loaded = new Map();
12
12
  class Lazy extends Component {
13
13
  store;
14
- Node;
15
- hasNode = false;
14
+ importData;
15
+ DefaultNode;
16
+ isLoaded = false;
16
17
  clearSpinnerTimeout;
17
18
  static defaultProps = {
18
19
  size: 'm',
19
20
  };
20
21
  constructor(props) {
21
22
  super(props);
22
- this.Node = loaded.get(this.props.loader);
23
- this.hasNode = Boolean(this.Node);
23
+ this.importData = loaded.get(this.props.loader);
24
+ this.DefaultNode = this.importData?.default;
25
+ const isLoaded = !!this.importData;
24
26
  this.store = createStore(this, {
25
- loading: !this.hasNode,
26
- spinnerTimeout: this.hasNode,
27
+ loading: !isLoaded,
28
+ spinnerTimeout: isLoaded,
27
29
  });
28
30
  }
29
31
  componentDidMount() {
30
- if (!this.hasNode)
32
+ if (!this.importData)
31
33
  this.update();
32
34
  }
33
35
  componentDidUpdate({ loader }) {
@@ -38,27 +40,32 @@ class Lazy extends Component {
38
40
  }
39
41
  }
40
42
  update() {
41
- const { loader } = this.props;
42
- this.clearSpinnerTimeout = Time.after(500, () => this.setState({ spinnerTimeout: false }));
43
+ const { loader, spinnerTimeout = 500 } = this.props;
44
+ this.clearSpinnerTimeout = Time.after(spinnerTimeout, () => this.setState({ spinnerTimeout: false }));
43
45
  this.store.loading = true;
44
- loader().then(({ default: Node }) => {
46
+ loader().then((data) => {
45
47
  if (!compare(this.props.loader, loader))
46
48
  return;
47
- this.Node = Node;
48
- loaded.set(loader, Node);
49
+ this.importData = data;
50
+ this.DefaultNode = data.default;
51
+ loaded.set(loader, data);
49
52
  this.store.loading = false;
50
53
  });
51
54
  }
52
55
  render() {
53
- const { Node } = this;
54
- const { progressElem, loader, hideSpinner, ...props } = this.props;
56
+ const { DefaultNode, importData } = this;
57
+ const { progressElem, loader, render, children, hideSpinner, ...props } = this.props;
55
58
  const { loading, spinnerTimeout } = this.store;
56
- if (Node)
57
- return jsx(Node, { ...props });
58
- if (!spinnerTimeout && loading && !hideSpinner) {
59
- return (progressElem ?? (jsx(Container, { fullHeight: true, fullWidth: true, children: jsx(Spinner, { size: props.size }) })));
59
+ if (loading && !spinnerTimeout && !hideSpinner) {
60
+ return (progressElem ?? (jsx(Flex, { justifyContent: "center", alignItems: "center", flexGrow: 1, width: "100%", height: "100%", children: jsx(Spinner, { size: props.size }) })));
60
61
  }
61
- return null;
62
+ if (render)
63
+ return render(importData);
64
+ if (typeof children === 'function')
65
+ return children(importData);
66
+ if (DefaultNode)
67
+ return jsx(DefaultNode, { ...props });
68
+ return children;
62
69
  }
63
70
  }
64
71
 
@@ -1,5 +1,5 @@
1
- import { HTMLAttributes } from 'react';
2
- type FlexProps = HTMLAttributes<HTMLDivElement> & {
1
+ import { CSSProperties, HTMLAttributes } from 'react';
2
+ type FlexProps = HTMLAttributes<HTMLDivElement> & CSSProperties & {
3
3
  children: React.ReactNode;
4
4
  };
5
5
  export declare const Flex: ({ children, ...props }: FlexProps) => JSX.Element;
@@ -18,6 +18,8 @@ declare const _default: {
18
18
  clearAll: () => Promise<any>;
19
19
  delete: () => Promise<any>;
20
20
  draft: () => Promise<any>;
21
+ dragHandlerHorizontal: () => Promise<any>;
22
+ dragHandlerVertical: () => Promise<any>;
21
23
  edit: () => Promise<any>;
22
24
  email: () => Promise<any>;
23
25
  externalLink: () => Promise<any>;
@@ -3,8 +3,9 @@ import * as T from './Lazy.types';
3
3
  export type LazyProps = T.Props;
4
4
  export declare class Lazy extends Component<T.Props> {
5
5
  store: T.State;
6
- Node?: ComponentType<any>;
7
- hasNode: boolean;
6
+ importData?: T.ImportData;
7
+ DefaultNode?: ComponentType<any>;
8
+ isLoaded: boolean;
8
9
  clearSpinnerTimeout: null;
9
10
  static defaultProps: {
10
11
  size: string;
@@ -1,10 +1,13 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { Size } from 'uilib/types';
3
- export type Loader = () => Promise<{
4
- default: ReactNode;
5
- }>;
3
+ export type ImportData = Record<string | 'default', any>;
4
+ export type Loader = () => Promise<ImportData>;
5
+ type RenderFunction = (importData: ImportData) => ReactNode;
6
6
  export type Props = {
7
7
  loader: Loader;
8
+ render?: RenderFunction;
9
+ children?: ReactNode | RenderFunction;
10
+ spinnerTimeout?: number;
8
11
  size?: Size;
9
12
  progressElem?: ReactNode;
10
13
  hideSpinner?: boolean;
@@ -13,3 +16,4 @@ export type State = {
13
16
  loading: boolean;
14
17
  spinnerTimeout: boolean;
15
18
  };
19
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.22.7",
3
+ "version": "4.22.9",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",