@impulse-ui-native/data-state 2.1.0 → 2.1.1
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/dist/components/data-view.d.mts +11 -0
- package/dist/components/data-view.js +55 -0
- package/dist/components/data-view.js.map +1 -0
- package/dist/components/empty-details.d.mts +10 -0
- package/dist/components/empty-details.js +34 -0
- package/dist/components/empty-details.js.map +1 -0
- package/dist/components/empty-view.d.mts +10 -0
- package/dist/components/empty-view.js +22 -0
- package/dist/components/empty-view.js.map +1 -0
- package/dist/components/error-details.d.mts +10 -0
- package/dist/components/error-details.js +34 -0
- package/dist/components/error-details.js.map +1 -0
- package/dist/components/error-view.d.mts +10 -0
- package/dist/components/error-view.js +22 -0
- package/dist/components/error-view.js.map +1 -0
- package/dist/components/index.d.mts +10 -0
- package/dist/components/index.js +11 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/loading-view.d.mts +10 -0
- package/dist/components/loading-view.js +93 -0
- package/dist/components/loading-view.js.map +1 -0
- package/dist/components/state-actions-footer.d.mts +10 -0
- package/dist/components/state-actions-footer.js +32 -0
- package/dist/components/state-actions-footer.js.map +1 -0
- package/dist/index.d.mts +10 -48
- package/dist/index.js +2 -282
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.mts +5 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/state-view.types.d.mts +38 -0
- package/dist/types/state-view.types.js +1 -0
- package/dist/types/state-view.types.js.map +1 -0
- package/package.json +7 -6
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { DataViewProps } from '../types/state-view.types.mjs';
|
|
5
|
+
import 'react-native';
|
|
6
|
+
import '@impulse-ui-native/icon/types';
|
|
7
|
+
import '@impulse-ui-native/primitives';
|
|
8
|
+
|
|
9
|
+
declare const DataView: react.MemoExoticComponent<(props: PropsWithChildren<DataViewProps>) => react_jsx_runtime.JSX.Element>;
|
|
10
|
+
|
|
11
|
+
export { DataView };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { View } from "@impulse-ui-native/primitives";
|
|
4
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
5
|
+
import { EmptyDetails } from "./empty-details";
|
|
6
|
+
import { ErrorDetails } from "./error-details";
|
|
7
|
+
import { LoadingView } from "./loading-view";
|
|
8
|
+
const DataView = memo((props) => {
|
|
9
|
+
const tokens = useComponentsTokens().dataState;
|
|
10
|
+
const {
|
|
11
|
+
error,
|
|
12
|
+
isEmpty,
|
|
13
|
+
loading,
|
|
14
|
+
errorViewProps,
|
|
15
|
+
emptyViewProps,
|
|
16
|
+
LoadingComponent,
|
|
17
|
+
contentContainerStyle,
|
|
18
|
+
children,
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
const content = useMemo(() => {
|
|
22
|
+
if (!error && !isEmpty) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
View,
|
|
27
|
+
{
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "center",
|
|
30
|
+
zIndex: tokens.content.zIndex,
|
|
31
|
+
children: [
|
|
32
|
+
error ? /* @__PURE__ */ jsx(ErrorDetails, { ...errorViewProps }) : null,
|
|
33
|
+
isEmpty ? /* @__PURE__ */ jsx(EmptyDetails, { ...emptyViewProps }) : null
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}, [error, isEmpty, errorViewProps, emptyViewProps, tokens.content.zIndex]);
|
|
38
|
+
return /* @__PURE__ */ jsxs(
|
|
39
|
+
LoadingView,
|
|
40
|
+
{
|
|
41
|
+
...rest,
|
|
42
|
+
LoadingComponent,
|
|
43
|
+
contentContainerStyle,
|
|
44
|
+
loading,
|
|
45
|
+
children: [
|
|
46
|
+
!error && !isEmpty && !loading ? children : null,
|
|
47
|
+
content
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
export {
|
|
53
|
+
DataView
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=data-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/data-view.tsx"],"sourcesContent":["import { memo, PropsWithChildren, useMemo } from \"react\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { DataViewProps } from \"../types\";\nimport { EmptyDetails } from \"./empty-details\";\nimport { ErrorDetails } from \"./error-details\";\nimport { LoadingView } from \"./loading-view\";\n\nexport const DataView = memo((props: PropsWithChildren<DataViewProps>) => {\n const tokens = useComponentsTokens().dataState;\n const {\n error,\n isEmpty,\n loading,\n errorViewProps,\n emptyViewProps,\n LoadingComponent,\n contentContainerStyle,\n children,\n ...rest\n } = props;\n\n const content = useMemo(() => {\n if (!error && !isEmpty) {\n return null;\n }\n\n return (\n <View\n alignItems=\"center\"\n justifyContent=\"center\"\n zIndex={tokens.content.zIndex}\n >\n {error ? <ErrorDetails {...errorViewProps} /> : null}\n {isEmpty ? <EmptyDetails {...emptyViewProps} /> : null}\n </View>\n );\n }, [error, isEmpty, errorViewProps, emptyViewProps, tokens.content.zIndex]);\n\n return (\n <LoadingView\n {...rest}\n LoadingComponent={LoadingComponent}\n contentContainerStyle={contentContainerStyle}\n loading={loading}\n >\n {!error && !isEmpty && !loading ? children : null}\n {content}\n </LoadingView>\n );\n});\n"],"mappings":"AA8BM,SAKW,KALX;AA9BN,SAAS,MAAyB,eAAe;AAEjD,SAAS,YAAY;AACrB,SAAS,2BAA2B;AAGpC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAErB,MAAM,WAAW,KAAK,CAAC,UAA4C;AACxE,QAAM,SAAS,oBAAoB,EAAE;AACrC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,UAAU,QAAQ,MAAM;AAC5B,QAAI,CAAC,SAAS,CAAC,SAAS;AACtB,aAAO;AAAA,IACT;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,YAAW;AAAA,QACX,gBAAe;AAAA,QACf,QAAQ,OAAO,QAAQ;AAAA,QAEtB;AAAA,kBAAQ,oBAAC,gBAAc,GAAG,gBAAgB,IAAK;AAAA,UAC/C,UAAU,oBAAC,gBAAc,GAAG,gBAAgB,IAAK;AAAA;AAAA;AAAA,IACpD;AAAA,EAEJ,GAAG,CAAC,OAAO,SAAS,gBAAgB,gBAAgB,OAAO,QAAQ,MAAM,CAAC;AAE1E,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,SAAC,SAAS,CAAC,WAAW,CAAC,UAAU,WAAW;AAAA,QAC5C;AAAA;AAAA;AAAA,EACH;AAEJ,CAAC;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { StateViewProps } from '../types/state-view.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/icon/types';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
|
|
8
|
+
declare const EmptyDetails: react.MemoExoticComponent<(props: StateViewProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { EmptyDetails };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { EmptyIcon } from "@impulse-ui-native/icon/icons/empty";
|
|
4
|
+
import { Typography, View } from "@impulse-ui-native/primitives";
|
|
5
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
6
|
+
import { StateActionsFooter } from "./state-actions-footer";
|
|
7
|
+
const EmptyDetails = memo(function EmptyDetails2(props) {
|
|
8
|
+
const tokens = useComponentsTokens().dataState.details;
|
|
9
|
+
return /* @__PURE__ */ jsxs(View, { alignItems: "center", justifyContent: "center", gap: tokens.gap, children: [
|
|
10
|
+
/* @__PURE__ */ jsx(
|
|
11
|
+
EmptyIcon,
|
|
12
|
+
{
|
|
13
|
+
width: tokens.iconSize,
|
|
14
|
+
height: tokens.iconSize,
|
|
15
|
+
variant: props.variant,
|
|
16
|
+
color: tokens.iconColor
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
/* @__PURE__ */ jsx(Typography.Body, { children: props.text }),
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
StateActionsFooter,
|
|
22
|
+
{
|
|
23
|
+
onPressPrimaryAction: props.onPressPrimaryAction,
|
|
24
|
+
primaryActionLabel: props.primaryActionLabel,
|
|
25
|
+
onPressSecondaryAction: props.onPressSecondaryAction,
|
|
26
|
+
secondaryActionLabel: props.secondaryActionLabel
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
EmptyDetails
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=empty-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/empty-details.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { EmptyIcon } from \"@impulse-ui-native/icon/icons/empty\";\nimport { Typography, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { StateViewProps } from \"../types\";\nimport { StateActionsFooter } from \"./state-actions-footer\";\n\nexport const EmptyDetails = memo(function EmptyDetails(props: StateViewProps) {\n const tokens = useComponentsTokens().dataState.details;\n\n return (\n <View alignItems=\"center\" justifyContent=\"center\" gap={tokens.gap}>\n <EmptyIcon\n width={tokens.iconSize}\n height={tokens.iconSize}\n variant={props.variant}\n color={tokens.iconColor}\n />\n <Typography.Body>{props.text}</Typography.Body>\n <StateActionsFooter\n onPressPrimaryAction={props.onPressPrimaryAction}\n primaryActionLabel={props.primaryActionLabel}\n onPressSecondaryAction={props.onPressSecondaryAction}\n secondaryActionLabel={props.secondaryActionLabel}\n />\n </View>\n );\n});\n"],"mappings":"AAaI,SACE,KADF;AAbJ,SAAS,YAAY;AAErB,SAAS,iBAAiB;AAC1B,SAAS,YAAY,YAAY;AACjC,SAAS,2BAA2B;AAGpC,SAAS,0BAA0B;AAE5B,MAAM,eAAe,KAAK,SAASA,cAAa,OAAuB;AAC5E,QAAM,SAAS,oBAAoB,EAAE,UAAU;AAE/C,SACE,qBAAC,QAAK,YAAW,UAAS,gBAAe,UAAS,KAAK,OAAO,KAC5D;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,QACf,SAAS,MAAM;AAAA,QACf,OAAO,OAAO;AAAA;AAAA,IAChB;AAAA,IACA,oBAAC,WAAW,MAAX,EAAiB,gBAAM,MAAK;AAAA,IAC7B;AAAA,MAAC;AAAA;AAAA,QACC,sBAAsB,MAAM;AAAA,QAC5B,oBAAoB,MAAM;AAAA,QAC1B,wBAAwB,MAAM;AAAA,QAC9B,sBAAsB,MAAM;AAAA;AAAA,IAC9B;AAAA,KACF;AAEJ,CAAC;","names":["EmptyDetails"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { EmptyViewProps } from '../types/state-view.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/icon/types';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
|
|
8
|
+
declare const EmptyView: react.MemoExoticComponent<(props: EmptyViewProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { EmptyView };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { View } from "@impulse-ui-native/primitives";
|
|
4
|
+
const EmptyView = memo(function EmptyView2(props) {
|
|
5
|
+
const {
|
|
6
|
+
variant,
|
|
7
|
+
text,
|
|
8
|
+
isEmpty,
|
|
9
|
+
onPressPrimaryAction,
|
|
10
|
+
primaryActionLabel,
|
|
11
|
+
onPressSecondaryAction,
|
|
12
|
+
secondaryActionLabel,
|
|
13
|
+
contentContainerStyle,
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
} = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(View, { ...rest, children: /* @__PURE__ */ jsx(View, { style: contentContainerStyle, children }) });
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
EmptyView
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=empty-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/empty-view.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\n\nimport { EmptyViewProps } from \"../types\";\n\nexport const EmptyView = memo(function EmptyView(props: EmptyViewProps) {\n const {\n variant,\n text,\n isEmpty,\n onPressPrimaryAction,\n primaryActionLabel,\n onPressSecondaryAction,\n secondaryActionLabel,\n contentContainerStyle,\n children,\n ...rest\n } = props;\n\n return (\n <View {...rest}>\n <View style={contentContainerStyle}>{children}</View>\n </View>\n );\n});\n"],"mappings":"AAsBM;AAtBN,SAAS,YAAY;AAErB,SAAS,YAAY;AAId,MAAM,YAAY,KAAK,SAASA,WAAU,OAAuB;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,SACE,oBAAC,QAAM,GAAG,MACR,8BAAC,QAAK,OAAO,uBAAwB,UAAS,GAChD;AAEJ,CAAC;","names":["EmptyView"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { StateViewProps } from '../types/state-view.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/icon/types';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
|
|
8
|
+
declare const ErrorDetails: react.MemoExoticComponent<(props: StateViewProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ErrorDetails };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { CloudXIcon } from "@impulse-ui-native/icon/icons/cloud-x";
|
|
4
|
+
import { Typography, View } from "@impulse-ui-native/primitives";
|
|
5
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
6
|
+
import { StateActionsFooter } from "./state-actions-footer";
|
|
7
|
+
const ErrorDetails = memo(function ErrorDetails2(props) {
|
|
8
|
+
const tokens = useComponentsTokens().dataState.details;
|
|
9
|
+
return /* @__PURE__ */ jsxs(View, { alignItems: "center", justifyContent: "center", gap: tokens.gap, children: [
|
|
10
|
+
/* @__PURE__ */ jsx(
|
|
11
|
+
CloudXIcon,
|
|
12
|
+
{
|
|
13
|
+
width: tokens.iconSize,
|
|
14
|
+
height: tokens.iconSize,
|
|
15
|
+
variant: props.variant,
|
|
16
|
+
color: tokens.iconColor
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
/* @__PURE__ */ jsx(Typography.Body, { children: props.text }),
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
StateActionsFooter,
|
|
22
|
+
{
|
|
23
|
+
onPressPrimaryAction: props.onPressPrimaryAction,
|
|
24
|
+
primaryActionLabel: props.primaryActionLabel,
|
|
25
|
+
onPressSecondaryAction: props.onPressSecondaryAction,
|
|
26
|
+
secondaryActionLabel: props.secondaryActionLabel
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
ErrorDetails
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=error-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/error-details.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { CloudXIcon } from \"@impulse-ui-native/icon/icons/cloud-x\";\nimport { Typography, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { StateViewProps } from \"../types\";\nimport { StateActionsFooter } from \"./state-actions-footer\";\n\nexport const ErrorDetails = memo(function ErrorDetails(props: StateViewProps) {\n const tokens = useComponentsTokens().dataState.details;\n\n return (\n <View alignItems=\"center\" justifyContent=\"center\" gap={tokens.gap}>\n <CloudXIcon\n width={tokens.iconSize}\n height={tokens.iconSize}\n variant={props.variant}\n color={tokens.iconColor}\n />\n <Typography.Body>{props.text}</Typography.Body>\n <StateActionsFooter\n onPressPrimaryAction={props.onPressPrimaryAction}\n primaryActionLabel={props.primaryActionLabel}\n onPressSecondaryAction={props.onPressSecondaryAction}\n secondaryActionLabel={props.secondaryActionLabel}\n />\n </View>\n );\n});\n"],"mappings":"AAaI,SACE,KADF;AAbJ,SAAS,YAAY;AAErB,SAAS,kBAAkB;AAC3B,SAAS,YAAY,YAAY;AACjC,SAAS,2BAA2B;AAGpC,SAAS,0BAA0B;AAE5B,MAAM,eAAe,KAAK,SAASA,cAAa,OAAuB;AAC5E,QAAM,SAAS,oBAAoB,EAAE,UAAU;AAE/C,SACE,qBAAC,QAAK,YAAW,UAAS,gBAAe,UAAS,KAAK,OAAO,KAC5D;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,QACf,SAAS,MAAM;AAAA,QACf,OAAO,OAAO;AAAA;AAAA,IAChB;AAAA,IACA,oBAAC,WAAW,MAAX,EAAiB,gBAAM,MAAK;AAAA,IAC7B;AAAA,MAAC;AAAA;AAAA,QACC,sBAAsB,MAAM;AAAA,QAC5B,oBAAoB,MAAM;AAAA,QAC1B,wBAAwB,MAAM;AAAA,QAC9B,sBAAsB,MAAM;AAAA;AAAA,IAC9B;AAAA,KACF;AAEJ,CAAC;","names":["ErrorDetails"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ErrorViewProps } from '../types/state-view.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/icon/types';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
|
|
8
|
+
declare const ErrorView: react.MemoExoticComponent<(props: ErrorViewProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ErrorView };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { View } from "@impulse-ui-native/primitives";
|
|
4
|
+
const ErrorView = memo(function ErrorView2(props) {
|
|
5
|
+
const {
|
|
6
|
+
variant,
|
|
7
|
+
text,
|
|
8
|
+
error,
|
|
9
|
+
onPressPrimaryAction,
|
|
10
|
+
onPressSecondaryAction,
|
|
11
|
+
primaryActionLabel,
|
|
12
|
+
secondaryActionLabel,
|
|
13
|
+
contentContainerStyle,
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
} = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(View, { ...rest, children: /* @__PURE__ */ jsx(View, { style: contentContainerStyle, children }) });
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
ErrorView
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=error-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/error-view.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\n\nimport { ErrorViewProps } from \"../types\";\n\nexport const ErrorView = memo(function ErrorView(props: ErrorViewProps) {\n const {\n variant,\n text,\n error,\n onPressPrimaryAction,\n onPressSecondaryAction,\n primaryActionLabel,\n secondaryActionLabel,\n contentContainerStyle,\n children,\n ...rest\n } = props;\n\n return (\n <View {...rest}>\n <View style={contentContainerStyle}>{children}</View>\n </View>\n );\n});\n"],"mappings":"AAsBM;AAtBN,SAAS,YAAY;AAErB,SAAS,YAAY;AAId,MAAM,YAAY,KAAK,SAASA,WAAU,OAAuB;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,SACE,oBAAC,QAAM,GAAG,MACR,8BAAC,QAAK,OAAO,uBAAwB,UAAS,GAChD;AAEJ,CAAC;","names":["ErrorView"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ErrorView } from './error-view.mjs';
|
|
2
|
+
export { EmptyView } from './empty-view.mjs';
|
|
3
|
+
export { LoadingView } from './loading-view.mjs';
|
|
4
|
+
export { DataView } from './data-view.mjs';
|
|
5
|
+
import '../types/state-view.types.mjs';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import 'react-native';
|
|
9
|
+
import '@impulse-ui-native/icon/types';
|
|
10
|
+
import '@impulse-ui-native/primitives';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorView } from "./error-view";
|
|
2
|
+
import { EmptyView } from "./empty-view";
|
|
3
|
+
import { LoadingView } from "./loading-view";
|
|
4
|
+
import { DataView } from "./data-view";
|
|
5
|
+
export {
|
|
6
|
+
DataView,
|
|
7
|
+
EmptyView,
|
|
8
|
+
ErrorView,
|
|
9
|
+
LoadingView
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["export { ErrorView } from \"./error-view\";\nexport { EmptyView } from \"./empty-view\";\nexport { LoadingView } from \"./loading-view\";\nexport { DataView } from \"./data-view\";\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { LoadingViewProps } from '../types/state-view.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/icon/types';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
|
|
8
|
+
declare const LoadingView: react.MemoExoticComponent<(props: LoadingViewProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { LoadingView };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import Animated, {
|
|
4
|
+
Easing,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
useSharedValue,
|
|
7
|
+
withTiming
|
|
8
|
+
} from "react-native-reanimated";
|
|
9
|
+
import { scheduleOnRN } from "react-native-worklets";
|
|
10
|
+
import { View } from "@impulse-ui-native/primitives";
|
|
11
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
12
|
+
const LoadingView = memo(function LoadingView2(props) {
|
|
13
|
+
const {
|
|
14
|
+
loading,
|
|
15
|
+
children,
|
|
16
|
+
LoadingComponent,
|
|
17
|
+
contentContainerStyle,
|
|
18
|
+
style,
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
const tokens = useComponentsTokens().dataState.loading;
|
|
22
|
+
const [shouldMountLoader, setShouldMountLoader] = useState(loading);
|
|
23
|
+
const [loaderHeight, setLoaderHeight] = useState(0);
|
|
24
|
+
const loaderOpacity = useSharedValue(loading ? 1 : 0);
|
|
25
|
+
const childrenOpacity = useSharedValue(loading ? 0 : 1);
|
|
26
|
+
const onLoaderLayout = useCallback((event) => {
|
|
27
|
+
const height = event.nativeEvent.layout.height;
|
|
28
|
+
setLoaderHeight((prev) => {
|
|
29
|
+
if (prev === height) {
|
|
30
|
+
return prev;
|
|
31
|
+
}
|
|
32
|
+
return height;
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
const containerStyle = useMemo(
|
|
36
|
+
() => [
|
|
37
|
+
{
|
|
38
|
+
position: "relative",
|
|
39
|
+
minHeight: shouldMountLoader ? loaderHeight : void 0
|
|
40
|
+
},
|
|
41
|
+
style
|
|
42
|
+
],
|
|
43
|
+
[loaderHeight, shouldMountLoader, style]
|
|
44
|
+
);
|
|
45
|
+
const loaderStyles = useAnimatedStyle(() => ({
|
|
46
|
+
position: "absolute",
|
|
47
|
+
bottom: 0,
|
|
48
|
+
left: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
top: 0,
|
|
51
|
+
zIndex: tokens.loaderZIndex,
|
|
52
|
+
opacity: loaderOpacity.value
|
|
53
|
+
}));
|
|
54
|
+
const childrenStyles = useAnimatedStyle(() => ({
|
|
55
|
+
opacity: childrenOpacity.value
|
|
56
|
+
}));
|
|
57
|
+
const childrenContainerStyles = useMemo(
|
|
58
|
+
() => [contentContainerStyle, childrenStyles],
|
|
59
|
+
[contentContainerStyle, childrenStyles]
|
|
60
|
+
);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (loading) {
|
|
63
|
+
setShouldMountLoader(true);
|
|
64
|
+
loaderOpacity.value = 1;
|
|
65
|
+
childrenOpacity.value = 0;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
loaderOpacity.value = withTiming(
|
|
69
|
+
0,
|
|
70
|
+
{
|
|
71
|
+
duration: tokens.transitionDuration,
|
|
72
|
+
easing: Easing.linear
|
|
73
|
+
},
|
|
74
|
+
(finished) => {
|
|
75
|
+
if (finished) {
|
|
76
|
+
scheduleOnRN(setShouldMountLoader, false);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
childrenOpacity.value = withTiming(1, {
|
|
81
|
+
duration: tokens.transitionDuration,
|
|
82
|
+
easing: Easing.linear
|
|
83
|
+
});
|
|
84
|
+
}, [loading, loaderOpacity, childrenOpacity, tokens.transitionDuration]);
|
|
85
|
+
return /* @__PURE__ */ jsxs(View, { ...rest, style: containerStyle, children: [
|
|
86
|
+
/* @__PURE__ */ jsx(Animated.View, { style: childrenContainerStyles, children }),
|
|
87
|
+
shouldMountLoader ? /* @__PURE__ */ jsx(Animated.View, { style: loaderStyles, pointerEvents: "auto", children: /* @__PURE__ */ jsx(View, { onLayout: onLoaderLayout, children: /* @__PURE__ */ jsx(LoadingComponent, {}) }) }) : null
|
|
88
|
+
] });
|
|
89
|
+
});
|
|
90
|
+
export {
|
|
91
|
+
LoadingView
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=loading-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/loading-view.tsx"],"sourcesContent":["import { memo, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { LayoutChangeEvent, StyleProp, ViewStyle } from \"react-native\";\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from \"react-native-reanimated\";\nimport { scheduleOnRN } from \"react-native-worklets\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { LoadingViewProps } from \"../types\";\n\nexport const LoadingView = memo(function LoadingView(props: LoadingViewProps) {\n const {\n loading,\n children,\n LoadingComponent,\n contentContainerStyle,\n style,\n ...rest\n } = props;\n\n const tokens = useComponentsTokens().dataState.loading;\n\n const [shouldMountLoader, setShouldMountLoader] = useState(loading);\n const [loaderHeight, setLoaderHeight] = useState(0);\n\n const loaderOpacity = useSharedValue(loading ? 1 : 0);\n const childrenOpacity = useSharedValue(loading ? 0 : 1);\n\n const onLoaderLayout = useCallback((event: LayoutChangeEvent) => {\n const height = event.nativeEvent.layout.height;\n\n setLoaderHeight((prev) => {\n if (prev === height) {\n return prev;\n }\n\n return height;\n });\n }, []);\n\n const containerStyle = useMemo<StyleProp<ViewStyle>>(\n () => [\n {\n position: \"relative\",\n minHeight: shouldMountLoader ? loaderHeight : undefined,\n },\n style,\n ],\n [loaderHeight, shouldMountLoader, style],\n );\n\n const loaderStyles = useAnimatedStyle(() => ({\n position: \"absolute\",\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n zIndex: tokens.loaderZIndex,\n opacity: loaderOpacity.value,\n }));\n\n const childrenStyles = useAnimatedStyle(() => ({\n opacity: childrenOpacity.value,\n }));\n\n const childrenContainerStyles = useMemo(\n () => [contentContainerStyle, childrenStyles],\n [contentContainerStyle, childrenStyles],\n );\n\n useEffect(() => {\n if (loading) {\n setShouldMountLoader(true);\n\n loaderOpacity.value = 1;\n childrenOpacity.value = 0;\n\n return;\n }\n\n loaderOpacity.value = withTiming(\n 0,\n {\n duration: tokens.transitionDuration,\n easing: Easing.linear,\n },\n (finished) => {\n if (finished) {\n scheduleOnRN(setShouldMountLoader, false);\n }\n },\n );\n\n childrenOpacity.value = withTiming(1, {\n duration: tokens.transitionDuration,\n easing: Easing.linear,\n });\n }, [loading, loaderOpacity, childrenOpacity, tokens.transitionDuration]);\n\n return (\n <View {...rest} style={containerStyle}>\n <Animated.View style={childrenContainerStyles}>{children}</Animated.View>\n\n {shouldMountLoader ? (\n <Animated.View style={loaderStyles} pointerEvents=\"auto\">\n <View onLayout={onLoaderLayout}>\n <LoadingComponent />\n </View>\n </Animated.View>\n ) : null}\n </View>\n );\n});\n"],"mappings":"AAyGI,SACE,KADF;AAzGJ,SAAS,MAAM,aAAa,WAAW,SAAS,gBAAgB;AAEhE,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAE7B,SAAS,YAAY;AACrB,SAAS,2BAA2B;AAI7B,MAAM,cAAc,KAAK,SAASA,aAAY,OAAyB;AAC5E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,SAAS,oBAAoB,EAAE,UAAU;AAE/C,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,OAAO;AAClE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAElD,QAAM,gBAAgB,eAAe,UAAU,IAAI,CAAC;AACpD,QAAM,kBAAkB,eAAe,UAAU,IAAI,CAAC;AAEtD,QAAM,iBAAiB,YAAY,CAAC,UAA6B;AAC/D,UAAM,SAAS,MAAM,YAAY,OAAO;AAExC,oBAAgB,CAAC,SAAS;AACxB,UAAI,SAAS,QAAQ;AACnB,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,iBAAiB;AAAA,IACrB,MAAM;AAAA,MACJ;AAAA,QACE,UAAU;AAAA,QACV,WAAW,oBAAoB,eAAe;AAAA,MAChD;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,cAAc,mBAAmB,KAAK;AAAA,EACzC;AAEA,QAAM,eAAe,iBAAiB,OAAO;AAAA,IAC3C,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ,OAAO;AAAA,IACf,SAAS,cAAc;AAAA,EACzB,EAAE;AAEF,QAAM,iBAAiB,iBAAiB,OAAO;AAAA,IAC7C,SAAS,gBAAgB;AAAA,EAC3B,EAAE;AAEF,QAAM,0BAA0B;AAAA,IAC9B,MAAM,CAAC,uBAAuB,cAAc;AAAA,IAC5C,CAAC,uBAAuB,cAAc;AAAA,EACxC;AAEA,YAAU,MAAM;AACd,QAAI,SAAS;AACX,2BAAqB,IAAI;AAEzB,oBAAc,QAAQ;AACtB,sBAAgB,QAAQ;AAExB;AAAA,IACF;AAEA,kBAAc,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,QACE,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,MACjB;AAAA,MACA,CAAC,aAAa;AACZ,YAAI,UAAU;AACZ,uBAAa,sBAAsB,KAAK;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAEA,oBAAgB,QAAQ,WAAW,GAAG;AAAA,MACpC,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,IACjB,CAAC;AAAA,EACH,GAAG,CAAC,SAAS,eAAe,iBAAiB,OAAO,kBAAkB,CAAC;AAEvE,SACE,qBAAC,QAAM,GAAG,MAAM,OAAO,gBACrB;AAAA,wBAAC,SAAS,MAAT,EAAc,OAAO,yBAA0B,UAAS;AAAA,IAExD,oBACC,oBAAC,SAAS,MAAT,EAAc,OAAO,cAAc,eAAc,QAChD,8BAAC,QAAK,UAAU,gBACd,8BAAC,oBAAiB,GACpB,GACF,IACE;AAAA,KACN;AAEJ,CAAC;","names":["LoadingView"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { StateActionsFooterProps } from '../types/state-view.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/icon/types';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
|
|
8
|
+
declare const StateActionsFooter: react.MemoExoticComponent<(props: StateActionsFooterProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { StateActionsFooter };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Button, View } from "@impulse-ui-native/primitives";
|
|
4
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
5
|
+
const StateActionsFooter = memo(function StateActionsFooter2(props) {
|
|
6
|
+
const tokens = useComponentsTokens().dataState.actionsFooter;
|
|
7
|
+
const {
|
|
8
|
+
onPressPrimaryAction,
|
|
9
|
+
onPressSecondaryAction,
|
|
10
|
+
primaryActionLabel,
|
|
11
|
+
secondaryActionLabel,
|
|
12
|
+
...rest
|
|
13
|
+
} = props;
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
View,
|
|
16
|
+
{
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
gap: tokens.gap,
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
...rest,
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Button, { onPress: props.onPressPrimaryAction, children: props.primaryActionLabel }),
|
|
24
|
+
props.onPressSecondaryAction ? /* @__PURE__ */ jsx(Button, { variant: "outlined", onPress: props.onPressSecondaryAction, children: props.secondaryActionLabel }) : null
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
StateActionsFooter
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=state-actions-footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/state-actions-footer.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { Button, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { StateActionsFooterProps } from \"../types\";\n\nexport const StateActionsFooter = memo(function StateActionsFooter(\n props: StateActionsFooterProps,\n) {\n const tokens = useComponentsTokens().dataState.actionsFooter;\n const {\n onPressPrimaryAction,\n onPressSecondaryAction,\n primaryActionLabel,\n secondaryActionLabel,\n ...rest\n } = props;\n\n return (\n <View\n flexDirection=\"row\"\n gap={tokens.gap}\n justifyContent=\"center\"\n alignItems=\"center\"\n {...rest}\n >\n <Button onPress={props.onPressPrimaryAction}>\n {props.primaryActionLabel}\n </Button>\n {props.onPressSecondaryAction ? (\n <Button variant=\"outlined\" onPress={props.onPressSecondaryAction}>\n {props.secondaryActionLabel}\n </Button>\n ) : null}\n </View>\n );\n});\n"],"mappings":"AAoBI,SAOE,KAPF;AApBJ,SAAS,YAAY;AAErB,SAAS,QAAQ,YAAY;AAC7B,SAAS,2BAA2B;AAI7B,MAAM,qBAAqB,KAAK,SAASA,oBAC9C,OACA;AACA,QAAM,SAAS,oBAAoB,EAAE,UAAU;AAC/C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAc;AAAA,MACd,KAAK,OAAO;AAAA,MACZ,gBAAe;AAAA,MACf,YAAW;AAAA,MACV,GAAG;AAAA,MAEJ;AAAA,4BAAC,UAAO,SAAS,MAAM,sBACpB,gBAAM,oBACT;AAAA,QACC,MAAM,yBACL,oBAAC,UAAO,SAAQ,YAAW,SAAS,MAAM,wBACvC,gBAAM,sBACT,IACE;AAAA;AAAA;AAAA,EACN;AAEJ,CAAC;","names":["StateActionsFooter"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,48 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onPressSecondaryAction?: PressableProps["onPress"];
|
|
12
|
-
secondaryActionLabel?: string;
|
|
13
|
-
}
|
|
14
|
-
interface StateViewProps extends StateActionsFooterProps, ViewProps {
|
|
15
|
-
text: string;
|
|
16
|
-
variant?: IconProps["variant"];
|
|
17
|
-
contentContainerStyle?: ViewStyle;
|
|
18
|
-
}
|
|
19
|
-
interface EmptyViewProps extends StateViewProps {
|
|
20
|
-
isEmpty: boolean;
|
|
21
|
-
}
|
|
22
|
-
interface ErrorViewProps extends StateViewProps {
|
|
23
|
-
error: Error | null;
|
|
24
|
-
}
|
|
25
|
-
interface LoadingViewProps extends ViewProps {
|
|
26
|
-
loading: boolean;
|
|
27
|
-
LoadingComponent: ComponentType;
|
|
28
|
-
contentContainerStyle?: ViewStyle;
|
|
29
|
-
}
|
|
30
|
-
interface DataViewProps extends ViewProps {
|
|
31
|
-
error: ErrorViewProps["error"];
|
|
32
|
-
isEmpty: EmptyViewProps["isEmpty"];
|
|
33
|
-
LoadingComponent: ComponentType;
|
|
34
|
-
loading: LoadingViewProps["loading"];
|
|
35
|
-
contentContainerStyle?: ViewStyle;
|
|
36
|
-
errorViewProps: StateViewProps;
|
|
37
|
-
emptyViewProps: StateViewProps;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare const ErrorView: react.MemoExoticComponent<(props: ErrorViewProps) => react_jsx_runtime.JSX.Element>;
|
|
41
|
-
|
|
42
|
-
declare const EmptyView: react.MemoExoticComponent<(props: EmptyViewProps) => react_jsx_runtime.JSX.Element>;
|
|
43
|
-
|
|
44
|
-
declare const LoadingView: react.MemoExoticComponent<(props: LoadingViewProps) => react_jsx_runtime.JSX.Element>;
|
|
45
|
-
|
|
46
|
-
declare const DataView: react.MemoExoticComponent<(props: PropsWithChildren<DataViewProps>) => react_jsx_runtime.JSX.Element>;
|
|
47
|
-
|
|
48
|
-
export { DataView, type DataViewProps, EmptyView, type EmptyViewProps, ErrorView, type ErrorViewProps, LoadingView, type LoadingViewProps, type StateActionsFooterProps, type StateViewProps };
|
|
1
|
+
export { ErrorView } from './components/error-view.mjs';
|
|
2
|
+
export { EmptyView } from './components/empty-view.mjs';
|
|
3
|
+
export { LoadingView } from './components/loading-view.mjs';
|
|
4
|
+
export { DataView } from './components/data-view.mjs';
|
|
5
|
+
export { DataViewProps, EmptyViewProps, ErrorViewProps, LoadingViewProps, StateActionsFooterProps, StateViewProps } from './types/state-view.types.mjs';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import 'react-native';
|
|
9
|
+
import '@impulse-ui-native/icon/types';
|
|
10
|
+
import '@impulse-ui-native/primitives';
|
package/dist/index.js
CHANGED
|
@@ -1,283 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { View } from "@impulse-ui-native/primitives";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var ErrorView = memo(function ErrorView2(props) {
|
|
6
|
-
const {
|
|
7
|
-
variant,
|
|
8
|
-
text,
|
|
9
|
-
error,
|
|
10
|
-
onPressPrimaryAction,
|
|
11
|
-
onPressSecondaryAction,
|
|
12
|
-
primaryActionLabel,
|
|
13
|
-
secondaryActionLabel,
|
|
14
|
-
contentContainerStyle,
|
|
15
|
-
children,
|
|
16
|
-
...rest
|
|
17
|
-
} = props;
|
|
18
|
-
return /* @__PURE__ */ jsx(View, { ...rest, children: /* @__PURE__ */ jsx(View, { style: contentContainerStyle, children }) });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// src/components/empty-view.tsx
|
|
22
|
-
import { memo as memo2 } from "react";
|
|
23
|
-
import { View as View2 } from "@impulse-ui-native/primitives";
|
|
24
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
25
|
-
var EmptyView = memo2(function EmptyView2(props) {
|
|
26
|
-
const {
|
|
27
|
-
variant,
|
|
28
|
-
text,
|
|
29
|
-
isEmpty,
|
|
30
|
-
onPressPrimaryAction,
|
|
31
|
-
primaryActionLabel,
|
|
32
|
-
onPressSecondaryAction,
|
|
33
|
-
secondaryActionLabel,
|
|
34
|
-
contentContainerStyle,
|
|
35
|
-
children,
|
|
36
|
-
...rest
|
|
37
|
-
} = props;
|
|
38
|
-
return /* @__PURE__ */ jsx2(View2, { ...rest, children: /* @__PURE__ */ jsx2(View2, { style: contentContainerStyle, children }) });
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// src/components/loading-view.tsx
|
|
42
|
-
import { memo as memo3, useCallback, useEffect, useMemo, useState } from "react";
|
|
43
|
-
import Animated, {
|
|
44
|
-
Easing,
|
|
45
|
-
useAnimatedStyle,
|
|
46
|
-
useSharedValue,
|
|
47
|
-
withTiming
|
|
48
|
-
} from "react-native-reanimated";
|
|
49
|
-
import { scheduleOnRN } from "react-native-worklets";
|
|
50
|
-
import { View as View3 } from "@impulse-ui-native/primitives";
|
|
51
|
-
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
52
|
-
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
53
|
-
var LoadingView = memo3(function LoadingView2(props) {
|
|
54
|
-
const {
|
|
55
|
-
loading,
|
|
56
|
-
children,
|
|
57
|
-
LoadingComponent,
|
|
58
|
-
contentContainerStyle,
|
|
59
|
-
style,
|
|
60
|
-
...rest
|
|
61
|
-
} = props;
|
|
62
|
-
const tokens = useComponentsTokens().dataState.loading;
|
|
63
|
-
const [shouldMountLoader, setShouldMountLoader] = useState(loading);
|
|
64
|
-
const [loaderHeight, setLoaderHeight] = useState(0);
|
|
65
|
-
const loaderOpacity = useSharedValue(loading ? 1 : 0);
|
|
66
|
-
const childrenOpacity = useSharedValue(loading ? 0 : 1);
|
|
67
|
-
const onLoaderLayout = useCallback((event) => {
|
|
68
|
-
const height = event.nativeEvent.layout.height;
|
|
69
|
-
setLoaderHeight((prev) => {
|
|
70
|
-
if (prev === height) {
|
|
71
|
-
return prev;
|
|
72
|
-
}
|
|
73
|
-
return height;
|
|
74
|
-
});
|
|
75
|
-
}, []);
|
|
76
|
-
const containerStyle = useMemo(
|
|
77
|
-
() => [
|
|
78
|
-
{
|
|
79
|
-
position: "relative",
|
|
80
|
-
minHeight: shouldMountLoader ? loaderHeight : void 0
|
|
81
|
-
},
|
|
82
|
-
style
|
|
83
|
-
],
|
|
84
|
-
[loaderHeight, shouldMountLoader, style]
|
|
85
|
-
);
|
|
86
|
-
const loaderStyles = useAnimatedStyle(() => ({
|
|
87
|
-
position: "absolute",
|
|
88
|
-
bottom: 0,
|
|
89
|
-
left: 0,
|
|
90
|
-
right: 0,
|
|
91
|
-
top: 0,
|
|
92
|
-
zIndex: tokens.loaderZIndex,
|
|
93
|
-
opacity: loaderOpacity.value
|
|
94
|
-
}));
|
|
95
|
-
const childrenStyles = useAnimatedStyle(() => ({
|
|
96
|
-
opacity: childrenOpacity.value
|
|
97
|
-
}));
|
|
98
|
-
const childrenContainerStyles = useMemo(
|
|
99
|
-
() => [contentContainerStyle, childrenStyles],
|
|
100
|
-
[contentContainerStyle, childrenStyles]
|
|
101
|
-
);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (loading) {
|
|
104
|
-
setShouldMountLoader(true);
|
|
105
|
-
loaderOpacity.value = 1;
|
|
106
|
-
childrenOpacity.value = 0;
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
loaderOpacity.value = withTiming(
|
|
110
|
-
0,
|
|
111
|
-
{
|
|
112
|
-
duration: tokens.transitionDuration,
|
|
113
|
-
easing: Easing.linear
|
|
114
|
-
},
|
|
115
|
-
(finished) => {
|
|
116
|
-
if (finished) {
|
|
117
|
-
scheduleOnRN(setShouldMountLoader, false);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
childrenOpacity.value = withTiming(1, {
|
|
122
|
-
duration: tokens.transitionDuration,
|
|
123
|
-
easing: Easing.linear
|
|
124
|
-
});
|
|
125
|
-
}, [loading, loaderOpacity, childrenOpacity, tokens.transitionDuration]);
|
|
126
|
-
return /* @__PURE__ */ jsxs(View3, { ...rest, style: containerStyle, children: [
|
|
127
|
-
/* @__PURE__ */ jsx3(Animated.View, { style: childrenContainerStyles, children }),
|
|
128
|
-
shouldMountLoader ? /* @__PURE__ */ jsx3(Animated.View, { style: loaderStyles, pointerEvents: "auto", children: /* @__PURE__ */ jsx3(View3, { onLayout: onLoaderLayout, children: /* @__PURE__ */ jsx3(LoadingComponent, {}) }) }) : null
|
|
129
|
-
] });
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// src/components/data-view.tsx
|
|
133
|
-
import { memo as memo7, useMemo as useMemo2 } from "react";
|
|
134
|
-
import { View as View7 } from "@impulse-ui-native/primitives";
|
|
135
|
-
import { useComponentsTokens as useComponentsTokens5 } from "@impulse-ui-native/theme";
|
|
136
|
-
|
|
137
|
-
// src/components/empty-details.tsx
|
|
138
|
-
import { memo as memo5 } from "react";
|
|
139
|
-
import { EmptyIcon } from "@impulse-ui-native/icon/icons/empty";
|
|
140
|
-
import { Typography, View as View5 } from "@impulse-ui-native/primitives";
|
|
141
|
-
import { useComponentsTokens as useComponentsTokens3 } from "@impulse-ui-native/theme";
|
|
142
|
-
|
|
143
|
-
// src/components/state-actions-footer.tsx
|
|
144
|
-
import { memo as memo4 } from "react";
|
|
145
|
-
import { Button, View as View4 } from "@impulse-ui-native/primitives";
|
|
146
|
-
import { useComponentsTokens as useComponentsTokens2 } from "@impulse-ui-native/theme";
|
|
147
|
-
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
148
|
-
var StateActionsFooter = memo4(function StateActionsFooter2(props) {
|
|
149
|
-
const tokens = useComponentsTokens2().dataState.actionsFooter;
|
|
150
|
-
const {
|
|
151
|
-
onPressPrimaryAction,
|
|
152
|
-
onPressSecondaryAction,
|
|
153
|
-
primaryActionLabel,
|
|
154
|
-
secondaryActionLabel,
|
|
155
|
-
...rest
|
|
156
|
-
} = props;
|
|
157
|
-
return /* @__PURE__ */ jsxs2(
|
|
158
|
-
View4,
|
|
159
|
-
{
|
|
160
|
-
flexDirection: "row",
|
|
161
|
-
gap: tokens.gap,
|
|
162
|
-
justifyContent: "center",
|
|
163
|
-
alignItems: "center",
|
|
164
|
-
...rest,
|
|
165
|
-
children: [
|
|
166
|
-
/* @__PURE__ */ jsx4(Button, { onPress: props.onPressPrimaryAction, children: props.primaryActionLabel }),
|
|
167
|
-
props.onPressSecondaryAction ? /* @__PURE__ */ jsx4(Button, { variant: "outlined", onPress: props.onPressSecondaryAction, children: props.secondaryActionLabel }) : null
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// src/components/empty-details.tsx
|
|
174
|
-
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
175
|
-
var EmptyDetails = memo5(function EmptyDetails2(props) {
|
|
176
|
-
const tokens = useComponentsTokens3().dataState.details;
|
|
177
|
-
return /* @__PURE__ */ jsxs3(View5, { alignItems: "center", justifyContent: "center", gap: tokens.gap, children: [
|
|
178
|
-
/* @__PURE__ */ jsx5(
|
|
179
|
-
EmptyIcon,
|
|
180
|
-
{
|
|
181
|
-
width: tokens.iconSize,
|
|
182
|
-
height: tokens.iconSize,
|
|
183
|
-
variant: props.variant,
|
|
184
|
-
color: tokens.iconColor
|
|
185
|
-
}
|
|
186
|
-
),
|
|
187
|
-
/* @__PURE__ */ jsx5(Typography.Body, { children: props.text }),
|
|
188
|
-
/* @__PURE__ */ jsx5(
|
|
189
|
-
StateActionsFooter,
|
|
190
|
-
{
|
|
191
|
-
onPressPrimaryAction: props.onPressPrimaryAction,
|
|
192
|
-
primaryActionLabel: props.primaryActionLabel,
|
|
193
|
-
onPressSecondaryAction: props.onPressSecondaryAction,
|
|
194
|
-
secondaryActionLabel: props.secondaryActionLabel
|
|
195
|
-
}
|
|
196
|
-
)
|
|
197
|
-
] });
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// src/components/error-details.tsx
|
|
201
|
-
import { memo as memo6 } from "react";
|
|
202
|
-
import { CloudXIcon } from "@impulse-ui-native/icon/icons/cloud-x";
|
|
203
|
-
import { Typography as Typography2, View as View6 } from "@impulse-ui-native/primitives";
|
|
204
|
-
import { useComponentsTokens as useComponentsTokens4 } from "@impulse-ui-native/theme";
|
|
205
|
-
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
206
|
-
var ErrorDetails = memo6(function ErrorDetails2(props) {
|
|
207
|
-
const tokens = useComponentsTokens4().dataState.details;
|
|
208
|
-
return /* @__PURE__ */ jsxs4(View6, { alignItems: "center", justifyContent: "center", gap: tokens.gap, children: [
|
|
209
|
-
/* @__PURE__ */ jsx6(
|
|
210
|
-
CloudXIcon,
|
|
211
|
-
{
|
|
212
|
-
width: tokens.iconSize,
|
|
213
|
-
height: tokens.iconSize,
|
|
214
|
-
variant: props.variant,
|
|
215
|
-
color: tokens.iconColor
|
|
216
|
-
}
|
|
217
|
-
),
|
|
218
|
-
/* @__PURE__ */ jsx6(Typography2.Body, { children: props.text }),
|
|
219
|
-
/* @__PURE__ */ jsx6(
|
|
220
|
-
StateActionsFooter,
|
|
221
|
-
{
|
|
222
|
-
onPressPrimaryAction: props.onPressPrimaryAction,
|
|
223
|
-
primaryActionLabel: props.primaryActionLabel,
|
|
224
|
-
onPressSecondaryAction: props.onPressSecondaryAction,
|
|
225
|
-
secondaryActionLabel: props.secondaryActionLabel
|
|
226
|
-
}
|
|
227
|
-
)
|
|
228
|
-
] });
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
// src/components/data-view.tsx
|
|
232
|
-
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
233
|
-
var DataView = memo7((props) => {
|
|
234
|
-
const tokens = useComponentsTokens5().dataState;
|
|
235
|
-
const {
|
|
236
|
-
error,
|
|
237
|
-
isEmpty,
|
|
238
|
-
loading,
|
|
239
|
-
errorViewProps,
|
|
240
|
-
emptyViewProps,
|
|
241
|
-
LoadingComponent,
|
|
242
|
-
contentContainerStyle,
|
|
243
|
-
children,
|
|
244
|
-
...rest
|
|
245
|
-
} = props;
|
|
246
|
-
const content = useMemo2(() => {
|
|
247
|
-
if (!error && !isEmpty) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
return /* @__PURE__ */ jsxs5(
|
|
251
|
-
View7,
|
|
252
|
-
{
|
|
253
|
-
alignItems: "center",
|
|
254
|
-
justifyContent: "center",
|
|
255
|
-
zIndex: tokens.content.zIndex,
|
|
256
|
-
children: [
|
|
257
|
-
error ? /* @__PURE__ */ jsx7(ErrorDetails, { ...errorViewProps }) : null,
|
|
258
|
-
isEmpty ? /* @__PURE__ */ jsx7(EmptyDetails, { ...emptyViewProps }) : null
|
|
259
|
-
]
|
|
260
|
-
}
|
|
261
|
-
);
|
|
262
|
-
}, [error, isEmpty, errorViewProps, emptyViewProps, tokens.content.zIndex]);
|
|
263
|
-
return /* @__PURE__ */ jsxs5(
|
|
264
|
-
LoadingView,
|
|
265
|
-
{
|
|
266
|
-
...rest,
|
|
267
|
-
LoadingComponent,
|
|
268
|
-
contentContainerStyle,
|
|
269
|
-
loading,
|
|
270
|
-
children: [
|
|
271
|
-
!error && !isEmpty && !loading ? children : null,
|
|
272
|
-
content
|
|
273
|
-
]
|
|
274
|
-
}
|
|
275
|
-
);
|
|
276
|
-
});
|
|
277
|
-
export {
|
|
278
|
-
DataView,
|
|
279
|
-
EmptyView,
|
|
280
|
-
ErrorView,
|
|
281
|
-
LoadingView
|
|
282
|
-
};
|
|
1
|
+
export * from "./components";
|
|
2
|
+
export * from "./types";
|
|
283
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/error-view.tsx","../src/components/empty-view.tsx","../src/components/loading-view.tsx","../src/components/data-view.tsx","../src/components/empty-details.tsx","../src/components/state-actions-footer.tsx","../src/components/error-details.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\n\nimport { ErrorViewProps } from \"../types\";\n\nexport const ErrorView = memo(function ErrorView(props: ErrorViewProps) {\n const {\n variant,\n text,\n error,\n onPressPrimaryAction,\n onPressSecondaryAction,\n primaryActionLabel,\n secondaryActionLabel,\n contentContainerStyle,\n children,\n ...rest\n } = props;\n\n return (\n <View {...rest}>\n <View style={contentContainerStyle}>{children}</View>\n </View>\n );\n});\n","import { memo } from \"react\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\n\nimport { EmptyViewProps } from \"../types\";\n\nexport const EmptyView = memo(function EmptyView(props: EmptyViewProps) {\n const {\n variant,\n text,\n isEmpty,\n onPressPrimaryAction,\n primaryActionLabel,\n onPressSecondaryAction,\n secondaryActionLabel,\n contentContainerStyle,\n children,\n ...rest\n } = props;\n\n return (\n <View {...rest}>\n <View style={contentContainerStyle}>{children}</View>\n </View>\n );\n});\n","import { memo, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { LayoutChangeEvent, StyleProp, ViewStyle } from \"react-native\";\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from \"react-native-reanimated\";\nimport { scheduleOnRN } from \"react-native-worklets\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { LoadingViewProps } from \"../types\";\n\nexport const LoadingView = memo(function LoadingView(props: LoadingViewProps) {\n const {\n loading,\n children,\n LoadingComponent,\n contentContainerStyle,\n style,\n ...rest\n } = props;\n\n const tokens = useComponentsTokens().dataState.loading;\n\n const [shouldMountLoader, setShouldMountLoader] = useState(loading);\n const [loaderHeight, setLoaderHeight] = useState(0);\n\n const loaderOpacity = useSharedValue(loading ? 1 : 0);\n const childrenOpacity = useSharedValue(loading ? 0 : 1);\n\n const onLoaderLayout = useCallback((event: LayoutChangeEvent) => {\n const height = event.nativeEvent.layout.height;\n\n setLoaderHeight((prev) => {\n if (prev === height) {\n return prev;\n }\n\n return height;\n });\n }, []);\n\n const containerStyle = useMemo<StyleProp<ViewStyle>>(\n () => [\n {\n position: \"relative\",\n minHeight: shouldMountLoader ? loaderHeight : undefined,\n },\n style,\n ],\n [loaderHeight, shouldMountLoader, style],\n );\n\n const loaderStyles = useAnimatedStyle(() => ({\n position: \"absolute\",\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n zIndex: tokens.loaderZIndex,\n opacity: loaderOpacity.value,\n }));\n\n const childrenStyles = useAnimatedStyle(() => ({\n opacity: childrenOpacity.value,\n }));\n\n const childrenContainerStyles = useMemo(\n () => [contentContainerStyle, childrenStyles],\n [contentContainerStyle, childrenStyles],\n );\n\n useEffect(() => {\n if (loading) {\n setShouldMountLoader(true);\n\n loaderOpacity.value = 1;\n childrenOpacity.value = 0;\n\n return;\n }\n\n loaderOpacity.value = withTiming(\n 0,\n {\n duration: tokens.transitionDuration,\n easing: Easing.linear,\n },\n (finished) => {\n if (finished) {\n scheduleOnRN(setShouldMountLoader, false);\n }\n },\n );\n\n childrenOpacity.value = withTiming(1, {\n duration: tokens.transitionDuration,\n easing: Easing.linear,\n });\n }, [loading, loaderOpacity, childrenOpacity, tokens.transitionDuration]);\n\n return (\n <View {...rest} style={containerStyle}>\n <Animated.View style={childrenContainerStyles}>{children}</Animated.View>\n\n {shouldMountLoader ? (\n <Animated.View style={loaderStyles} pointerEvents=\"auto\">\n <View onLayout={onLoaderLayout}>\n <LoadingComponent />\n </View>\n </Animated.View>\n ) : null}\n </View>\n );\n});\n","import { memo, PropsWithChildren, useMemo } from \"react\";\n\nimport { View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { DataViewProps } from \"../types\";\nimport { EmptyDetails } from \"./empty-details\";\nimport { ErrorDetails } from \"./error-details\";\nimport { LoadingView } from \"./loading-view\";\n\nexport const DataView = memo((props: PropsWithChildren<DataViewProps>) => {\n const tokens = useComponentsTokens().dataState;\n const {\n error,\n isEmpty,\n loading,\n errorViewProps,\n emptyViewProps,\n LoadingComponent,\n contentContainerStyle,\n children,\n ...rest\n } = props;\n\n const content = useMemo(() => {\n if (!error && !isEmpty) {\n return null;\n }\n\n return (\n <View\n alignItems=\"center\"\n justifyContent=\"center\"\n zIndex={tokens.content.zIndex}\n >\n {error ? <ErrorDetails {...errorViewProps} /> : null}\n {isEmpty ? <EmptyDetails {...emptyViewProps} /> : null}\n </View>\n );\n }, [error, isEmpty, errorViewProps, emptyViewProps, tokens.content.zIndex]);\n\n return (\n <LoadingView\n {...rest}\n LoadingComponent={LoadingComponent}\n contentContainerStyle={contentContainerStyle}\n loading={loading}\n >\n {!error && !isEmpty && !loading ? children : null}\n {content}\n </LoadingView>\n );\n});\n","import { memo } from \"react\";\n\nimport { EmptyIcon } from \"@impulse-ui-native/icon/icons/empty\";\nimport { Typography, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { StateViewProps } from \"../types\";\nimport { StateActionsFooter } from \"./state-actions-footer\";\n\nexport const EmptyDetails = memo(function EmptyDetails(props: StateViewProps) {\n const tokens = useComponentsTokens().dataState.details;\n\n return (\n <View alignItems=\"center\" justifyContent=\"center\" gap={tokens.gap}>\n <EmptyIcon\n width={tokens.iconSize}\n height={tokens.iconSize}\n variant={props.variant}\n color={tokens.iconColor}\n />\n <Typography.Body>{props.text}</Typography.Body>\n <StateActionsFooter\n onPressPrimaryAction={props.onPressPrimaryAction}\n primaryActionLabel={props.primaryActionLabel}\n onPressSecondaryAction={props.onPressSecondaryAction}\n secondaryActionLabel={props.secondaryActionLabel}\n />\n </View>\n );\n});\n","import { memo } from \"react\";\n\nimport { Button, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { StateActionsFooterProps } from \"../types\";\n\nexport const StateActionsFooter = memo(function StateActionsFooter(\n props: StateActionsFooterProps,\n) {\n const tokens = useComponentsTokens().dataState.actionsFooter;\n const {\n onPressPrimaryAction,\n onPressSecondaryAction,\n primaryActionLabel,\n secondaryActionLabel,\n ...rest\n } = props;\n\n return (\n <View\n flexDirection=\"row\"\n gap={tokens.gap}\n justifyContent=\"center\"\n alignItems=\"center\"\n {...rest}\n >\n <Button onPress={props.onPressPrimaryAction}>\n {props.primaryActionLabel}\n </Button>\n {props.onPressSecondaryAction ? (\n <Button variant=\"outlined\" onPress={props.onPressSecondaryAction}>\n {props.secondaryActionLabel}\n </Button>\n ) : null}\n </View>\n );\n});\n","import { memo } from \"react\";\n\nimport { CloudXIcon } from \"@impulse-ui-native/icon/icons/cloud-x\";\nimport { Typography, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport { StateViewProps } from \"../types\";\nimport { StateActionsFooter } from \"./state-actions-footer\";\n\nexport const ErrorDetails = memo(function ErrorDetails(props: StateViewProps) {\n const tokens = useComponentsTokens().dataState.details;\n\n return (\n <View alignItems=\"center\" justifyContent=\"center\" gap={tokens.gap}>\n <CloudXIcon\n width={tokens.iconSize}\n height={tokens.iconSize}\n variant={props.variant}\n color={tokens.iconColor}\n />\n <Typography.Body>{props.text}</Typography.Body>\n <StateActionsFooter\n onPressPrimaryAction={props.onPressPrimaryAction}\n primaryActionLabel={props.primaryActionLabel}\n onPressSecondaryAction={props.onPressSecondaryAction}\n secondaryActionLabel={props.secondaryActionLabel}\n />\n </View>\n );\n});\n"],"mappings":";AAAA,SAAS,YAAY;AAErB,SAAS,YAAY;AAoBf;AAhBC,IAAM,YAAY,KAAK,SAASA,WAAU,OAAuB;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IA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AAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,UAAUC,SAAQ,MAAM;AAC5B,QAAI,CAAC,SAAS,CAAC,SAAS;AACtB,aAAO;AAAA,IACT;AAEA,WACE,gBAAAH;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,YAAW;AAAA,QACX,gBAAe;AAAA,QACf,QAAQ,OAAO,QAAQ;AAAA,QAEtB;AAAA,kBAAQ,gBAAAL,KAAC,gBAAc,GAAG,gBAAgB,IAAK;AAAA,UAC/C,UAAU,gBAAAA,KAAC,gBAAc,GAAG,gBAAgB,IAAK;AAAA;AAAA;AAAA,IACpD;AAAA,EAEJ,GAAG,CAAC,OAAO,SAAS,gBAAgB,gBAAgB,OAAO,QAAQ,MAAM,CAAC;AAE1E,SACE,gBAAAC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,SAAC,SAAS,CAAC,WAAW,CAAC,UAAU,WAAW;AAAA,QAC5C;AAAA;AAAA;AAAA,EACH;AAEJ,CAAC;","names":["ErrorView","memo","View","jsx","EmptyView","memo","View","jsx","LoadingView","memo","useMemo","View","useComponentsTokens","memo","View","useComponentsTokens","memo","View","useComponentsTokens","jsx","jsxs","StateActionsFooter","jsx","jsxs","memo","EmptyDetails","useComponentsTokens","View","memo","Typography","View","useComponentsTokens","jsx","jsxs","memo","ErrorDetails","useComponentsTokens","View","Typography","jsx","jsxs","memo","useComponentsTokens","useMemo","View"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./types\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DataViewProps, EmptyViewProps, ErrorViewProps, LoadingViewProps, StateActionsFooterProps, StateViewProps } from './state-view.types.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'react-native';
|
|
4
|
+
import '@impulse-ui-native/icon/types';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./state-view.types\";\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { PressableProps, ViewStyle } from 'react-native';
|
|
3
|
+
import { IconProps } from '@impulse-ui-native/icon/types';
|
|
4
|
+
import { ViewProps } from '@impulse-ui-native/primitives';
|
|
5
|
+
|
|
6
|
+
interface StateActionsFooterProps extends ViewProps {
|
|
7
|
+
onPressPrimaryAction: PressableProps["onPress"];
|
|
8
|
+
primaryActionLabel: string;
|
|
9
|
+
onPressSecondaryAction?: PressableProps["onPress"];
|
|
10
|
+
secondaryActionLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
interface StateViewProps extends StateActionsFooterProps, ViewProps {
|
|
13
|
+
text: string;
|
|
14
|
+
variant?: IconProps["variant"];
|
|
15
|
+
contentContainerStyle?: ViewStyle;
|
|
16
|
+
}
|
|
17
|
+
interface EmptyViewProps extends StateViewProps {
|
|
18
|
+
isEmpty: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface ErrorViewProps extends StateViewProps {
|
|
21
|
+
error: Error | null;
|
|
22
|
+
}
|
|
23
|
+
interface LoadingViewProps extends ViewProps {
|
|
24
|
+
loading: boolean;
|
|
25
|
+
LoadingComponent: ComponentType;
|
|
26
|
+
contentContainerStyle?: ViewStyle;
|
|
27
|
+
}
|
|
28
|
+
interface DataViewProps extends ViewProps {
|
|
29
|
+
error: ErrorViewProps["error"];
|
|
30
|
+
isEmpty: EmptyViewProps["isEmpty"];
|
|
31
|
+
LoadingComponent: ComponentType;
|
|
32
|
+
loading: LoadingViewProps["loading"];
|
|
33
|
+
contentContainerStyle?: ViewStyle;
|
|
34
|
+
errorViewProps: StateViewProps;
|
|
35
|
+
emptyViewProps: StateViewProps;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { DataViewProps, EmptyViewProps, ErrorViewProps, LoadingViewProps, StateActionsFooterProps, StateViewProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=state-view.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impulse-ui-native/data-state",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
|
+
"sideEffects": false,
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@impulse-ui-native/
|
|
22
|
-
"@impulse-ui-native/
|
|
23
|
-
"@impulse-ui-native/
|
|
24
|
-
"@impulse-ui-native/
|
|
25
|
-
"@impulse-ui-native/
|
|
22
|
+
"@impulse-ui-native/primitives": "2.1.1",
|
|
23
|
+
"@impulse-ui-native/icon": "2.1.1",
|
|
24
|
+
"@impulse-ui-native/skeleton": "2.1.1",
|
|
25
|
+
"@impulse-ui-native/theme": "2.1.1",
|
|
26
|
+
"@impulse-ui-native/core": "2.1.1"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/react": "~19.2.14",
|