@impulse-ui-native/primitives 2.7.0 → 2.9.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/README.md +58 -4
- package/dist/components/atoms/avatar.d.mts +10 -0
- package/dist/components/atoms/avatar.js +144 -0
- package/dist/components/atoms/avatar.js.map +1 -0
- package/dist/components/atoms/badge/addon.d.mts +19 -0
- package/dist/components/atoms/badge/addon.js +28 -0
- package/dist/components/atoms/badge/addon.js.map +1 -0
- package/dist/components/atoms/badge/index.d.mts +11 -0
- package/dist/components/atoms/badge/index.js +5 -0
- package/dist/components/atoms/badge/index.js.map +1 -0
- package/dist/components/atoms/badge/root.d.mts +14 -0
- package/dist/components/atoms/badge/root.js +113 -0
- package/dist/components/atoms/badge/root.js.map +1 -0
- package/dist/components/atoms/button.js +4 -3
- package/dist/components/atoms/button.js.map +1 -1
- package/dist/components/atoms/circular-progress.d.mts +16 -0
- package/dist/components/atoms/circular-progress.js +144 -0
- package/dist/components/atoms/circular-progress.js.map +1 -0
- package/dist/components/atoms/divider.d.mts +10 -0
- package/dist/components/atoms/divider.js +50 -0
- package/dist/components/atoms/divider.js.map +1 -0
- package/dist/components/atoms/icon-button.js +3 -2
- package/dist/components/atoms/icon-button.js.map +1 -1
- package/dist/components/atoms/index.d.mts +16 -4
- package/dist/components/atoms/index.js +10 -0
- package/dist/components/atoms/index.js.map +1 -1
- package/dist/components/atoms/linear-progress.d.mts +17 -0
- package/dist/components/atoms/linear-progress.js +97 -0
- package/dist/components/atoms/linear-progress.js.map +1 -0
- package/dist/components/atoms/pressable.d.mts +4 -4
- package/dist/components/atoms/pressable.js +48 -43
- package/dist/components/atoms/pressable.js.map +1 -1
- package/dist/components/atoms/progress.d.mts +9 -0
- package/dist/components/atoms/progress.js +94 -0
- package/dist/components/atoms/progress.js.map +1 -0
- package/dist/components/atoms/spinner.d.mts +9 -0
- package/dist/components/atoms/spinner.js +75 -0
- package/dist/components/atoms/spinner.js.map +1 -0
- package/dist/components/card/card.d.mts +17 -0
- package/dist/components/card/card.js +18 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/card/content.d.mts +10 -0
- package/dist/components/card/content.js +30 -0
- package/dist/components/card/content.js.map +1 -0
- package/dist/components/card/footer.d.mts +10 -0
- package/dist/components/card/footer.js +30 -0
- package/dist/components/card/footer.js.map +1 -0
- package/dist/components/card/header.d.mts +10 -0
- package/dist/components/card/header.js +30 -0
- package/dist/components/card/header.js.map +1 -0
- package/dist/components/card/index.d.mts +7 -0
- package/dist/components/card/index.js +5 -0
- package/dist/components/card/index.js.map +1 -0
- package/dist/components/card/media.d.mts +10 -0
- package/dist/components/card/media.js +30 -0
- package/dist/components/card/media.js.map +1 -0
- package/dist/components/card/pressable.d.mts +10 -0
- package/dist/components/card/pressable.js +45 -0
- package/dist/components/card/pressable.js.map +1 -0
- package/dist/components/card/root.d.mts +10 -0
- package/dist/components/card/root.js +21 -0
- package/dist/components/card/root.js.map +1 -0
- package/dist/components/card/root.styles.d.mts +13 -0
- package/dist/components/card/root.styles.js +17 -0
- package/dist/components/card/root.styles.js.map +1 -0
- package/dist/components/controls/addon.d.mts +1 -0
- package/dist/components/controls/container.d.mts +1 -0
- package/dist/components/controls/control.d.mts +3 -2
- package/dist/components/controls/error.d.mts +1 -0
- package/dist/components/controls/index.d.mts +1 -0
- package/dist/components/controls/input.d.mts +1 -0
- package/dist/components/controls/label.d.mts +1 -0
- package/dist/components/controls/loader.d.mts +7 -1
- package/dist/components/controls/loader.js +3 -3
- package/dist/components/controls/loader.js.map +1 -1
- package/dist/components/controls/placeholder.d.mts +1 -0
- package/dist/components/controls/provider.d.mts +1 -0
- package/dist/components/controls/value.d.mts +1 -0
- package/dist/components/index.d.mts +18 -6
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/use-indeterminate-progress-animation.hook.d.mts +5 -0
- package/dist/hooks/use-indeterminate-progress-animation.hook.js +47 -0
- package/dist/hooks/use-indeterminate-progress-animation.hook.js.map +1 -0
- package/dist/index.d.mts +13 -1
- package/dist/types/avatar.types.d.mts +20 -0
- package/dist/types/avatar.types.js +1 -0
- package/dist/types/avatar.types.js.map +1 -0
- package/dist/types/badge.types.d.mts +24 -0
- package/dist/types/badge.types.js +1 -0
- package/dist/types/badge.types.js.map +1 -0
- package/dist/types/card.types.d.mts +21 -0
- package/dist/types/card.types.js +1 -0
- package/dist/types/card.types.js.map +1 -0
- package/dist/types/control-components.types.d.mts +3 -2
- package/dist/types/divider.types.d.mts +14 -0
- package/dist/types/divider.types.js +1 -0
- package/dist/types/divider.types.js.map +1 -0
- package/dist/types/index.d.mts +7 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/progress.types.d.mts +15 -0
- package/dist/types/progress.types.js +1 -0
- package/dist/types/progress.types.js.map +1 -0
- package/dist/types/spinner.types.d.mts +9 -0
- package/dist/types/spinner.types.js +1 -0
- package/dist/types/spinner.types.js.map +1 -0
- package/dist/utils/progress.utils.d.mts +9 -0
- package/dist/utils/progress.utils.js +27 -0
- package/dist/utils/progress.utils.js.map +1 -0
- package/package.json +7 -5
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { Animated, StyleSheet, View } from "react-native";
|
|
4
|
+
import Svg, { Circle, G } from "react-native-svg";
|
|
5
|
+
import { useIndeterminateProgressAnimation } from "../../hooks/use-indeterminate-progress-animation.hook";
|
|
6
|
+
const CircularProgress = memo(function CircularProgress2({
|
|
7
|
+
animationDuration,
|
|
8
|
+
fraction,
|
|
9
|
+
indicatorColor,
|
|
10
|
+
indeterminate,
|
|
11
|
+
strokeWidth,
|
|
12
|
+
style,
|
|
13
|
+
trackColor,
|
|
14
|
+
width,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
17
|
+
const rootStyle = useMemo(
|
|
18
|
+
() => [styles.root, { height: width, width }, style],
|
|
19
|
+
[style, width]
|
|
20
|
+
);
|
|
21
|
+
return /* @__PURE__ */ jsx(View, { ...props, style: rootStyle, children: indeterminate ? /* @__PURE__ */ jsx(
|
|
22
|
+
CircularIndeterminateIndicator,
|
|
23
|
+
{
|
|
24
|
+
animationDuration,
|
|
25
|
+
color: indicatorColor,
|
|
26
|
+
strokeWidth,
|
|
27
|
+
trackColor,
|
|
28
|
+
width
|
|
29
|
+
}
|
|
30
|
+
) : /* @__PURE__ */ jsx(
|
|
31
|
+
ProgressCircle,
|
|
32
|
+
{
|
|
33
|
+
color: indicatorColor,
|
|
34
|
+
fraction,
|
|
35
|
+
strokeWidth,
|
|
36
|
+
trackColor,
|
|
37
|
+
width
|
|
38
|
+
}
|
|
39
|
+
) });
|
|
40
|
+
});
|
|
41
|
+
const ProgressCircle = memo(function ProgressCircle2({
|
|
42
|
+
color,
|
|
43
|
+
fraction,
|
|
44
|
+
strokeWidth,
|
|
45
|
+
trackColor,
|
|
46
|
+
width
|
|
47
|
+
}) {
|
|
48
|
+
const center = width / 2;
|
|
49
|
+
const radius = (width - strokeWidth) / 2;
|
|
50
|
+
const circumference = 2 * Math.PI * radius;
|
|
51
|
+
const strokeDasharray = useMemo(
|
|
52
|
+
() => [circumference, circumference],
|
|
53
|
+
[circumference]
|
|
54
|
+
);
|
|
55
|
+
return /* @__PURE__ */ jsxs(Svg, { accessible: false, height: width, width, children: [
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
Circle,
|
|
58
|
+
{
|
|
59
|
+
cx: center,
|
|
60
|
+
cy: center,
|
|
61
|
+
fill: "none",
|
|
62
|
+
r: radius,
|
|
63
|
+
stroke: trackColor,
|
|
64
|
+
strokeWidth
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx(G, { origin: `${center}, ${center}`, rotation: -90, children: /* @__PURE__ */ jsx(
|
|
68
|
+
Circle,
|
|
69
|
+
{
|
|
70
|
+
cx: center,
|
|
71
|
+
cy: center,
|
|
72
|
+
fill: "none",
|
|
73
|
+
r: radius,
|
|
74
|
+
stroke: color,
|
|
75
|
+
strokeDasharray,
|
|
76
|
+
strokeDashoffset: circumference * (1 - fraction),
|
|
77
|
+
strokeLinecap: fraction === 0 ? "butt" : "round",
|
|
78
|
+
strokeWidth
|
|
79
|
+
}
|
|
80
|
+
) })
|
|
81
|
+
] });
|
|
82
|
+
});
|
|
83
|
+
const CircularIndeterminateIndicator = memo(
|
|
84
|
+
function CircularIndeterminateIndicator2({
|
|
85
|
+
animationDuration,
|
|
86
|
+
color,
|
|
87
|
+
strokeWidth,
|
|
88
|
+
trackColor,
|
|
89
|
+
width
|
|
90
|
+
}) {
|
|
91
|
+
const progress = useIndeterminateProgressAnimation(animationDuration);
|
|
92
|
+
const rotation = progress.interpolate({
|
|
93
|
+
inputRange: [0, 1],
|
|
94
|
+
outputRange: ["0deg", "360deg"]
|
|
95
|
+
});
|
|
96
|
+
const center = width / 2;
|
|
97
|
+
const radius = (width - strokeWidth) / 2;
|
|
98
|
+
const circumference = 2 * Math.PI * radius;
|
|
99
|
+
const animatedStyle = useMemo(
|
|
100
|
+
() => ({ transform: [{ rotate: rotation }] }),
|
|
101
|
+
[rotation]
|
|
102
|
+
);
|
|
103
|
+
const strokeDasharray = useMemo(
|
|
104
|
+
() => [circumference * 0.25, circumference * 0.75],
|
|
105
|
+
[circumference]
|
|
106
|
+
);
|
|
107
|
+
return /* @__PURE__ */ jsx(Animated.View, { style: animatedStyle, children: /* @__PURE__ */ jsxs(Svg, { accessible: false, height: width, width, children: [
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
Circle,
|
|
110
|
+
{
|
|
111
|
+
cx: center,
|
|
112
|
+
cy: center,
|
|
113
|
+
fill: "none",
|
|
114
|
+
r: radius,
|
|
115
|
+
stroke: trackColor,
|
|
116
|
+
strokeWidth
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
Circle,
|
|
121
|
+
{
|
|
122
|
+
cx: center,
|
|
123
|
+
cy: center,
|
|
124
|
+
fill: "none",
|
|
125
|
+
r: radius,
|
|
126
|
+
stroke: color,
|
|
127
|
+
strokeDasharray,
|
|
128
|
+
strokeLinecap: "round",
|
|
129
|
+
strokeWidth
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] }) });
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
const styles = StyleSheet.create({
|
|
136
|
+
root: {
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
justifyContent: "center"
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
export {
|
|
142
|
+
CircularProgress
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=circular-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/circular-progress.tsx"],"sourcesContent":["import type { ColorValue, ViewProps } from \"react-native\";\nimport { memo, useMemo } from \"react\";\nimport { Animated, StyleSheet, View } from \"react-native\";\nimport Svg, { Circle, G } from \"react-native-svg\";\n\nimport { useIndeterminateProgressAnimation } from \"../../hooks/use-indeterminate-progress-animation.hook\";\n\ninterface CircularProgressProps extends ViewProps {\n animationDuration: number;\n fraction: number;\n indicatorColor: ColorValue;\n indeterminate: boolean;\n strokeWidth: number;\n trackColor: ColorValue;\n width: number;\n}\n\nexport const CircularProgress = memo(function CircularProgress({\n animationDuration,\n fraction,\n indicatorColor,\n indeterminate,\n strokeWidth,\n style,\n trackColor,\n width,\n ...props\n}: CircularProgressProps) {\n const rootStyle = useMemo(\n () => [styles.root, { height: width, width }, style],\n [style, width],\n );\n\n return (\n <View {...props} style={rootStyle}>\n {indeterminate ? (\n <CircularIndeterminateIndicator\n animationDuration={animationDuration}\n color={indicatorColor}\n strokeWidth={strokeWidth}\n trackColor={trackColor}\n width={width}\n />\n ) : (\n <ProgressCircle\n color={indicatorColor}\n fraction={fraction}\n strokeWidth={strokeWidth}\n trackColor={trackColor}\n width={width}\n />\n )}\n </View>\n );\n});\n\ninterface ProgressCircleProps {\n color: ColorValue;\n fraction: number;\n strokeWidth: number;\n trackColor: ColorValue;\n width: number;\n}\n\nconst ProgressCircle = memo(function ProgressCircle({\n color,\n fraction,\n strokeWidth,\n trackColor,\n width,\n}: ProgressCircleProps) {\n const center = width / 2;\n const radius = (width - strokeWidth) / 2;\n const circumference = 2 * Math.PI * radius;\n const strokeDasharray = useMemo(\n () => [circumference, circumference],\n [circumference],\n );\n\n return (\n <Svg accessible={false} height={width} width={width}>\n <Circle\n cx={center}\n cy={center}\n fill=\"none\"\n r={radius}\n stroke={trackColor}\n strokeWidth={strokeWidth}\n />\n <G origin={`${center}, ${center}`} rotation={-90}>\n <Circle\n cx={center}\n cy={center}\n fill=\"none\"\n r={radius}\n stroke={color}\n strokeDasharray={strokeDasharray}\n strokeDashoffset={circumference * (1 - fraction)}\n strokeLinecap={fraction === 0 ? \"butt\" : \"round\"}\n strokeWidth={strokeWidth}\n />\n </G>\n </Svg>\n );\n});\n\ninterface CircularIndeterminateIndicatorProps {\n animationDuration: number;\n color: ColorValue;\n strokeWidth: number;\n trackColor: ColorValue;\n width: number;\n}\n\nconst CircularIndeterminateIndicator = memo(\n function CircularIndeterminateIndicator({\n animationDuration,\n color,\n strokeWidth,\n trackColor,\n width,\n }: CircularIndeterminateIndicatorProps) {\n const progress = useIndeterminateProgressAnimation(animationDuration);\n const rotation = progress.interpolate({\n inputRange: [0, 1],\n outputRange: [\"0deg\", \"360deg\"],\n });\n const center = width / 2;\n const radius = (width - strokeWidth) / 2;\n const circumference = 2 * Math.PI * radius;\n const animatedStyle = useMemo(\n () => ({ transform: [{ rotate: rotation }] }),\n [rotation],\n );\n const strokeDasharray = useMemo(\n () => [circumference * 0.25, circumference * 0.75],\n [circumference],\n );\n\n return (\n <Animated.View style={animatedStyle}>\n <Svg accessible={false} height={width} width={width}>\n <Circle\n cx={center}\n cy={center}\n fill=\"none\"\n r={radius}\n stroke={trackColor}\n strokeWidth={strokeWidth}\n />\n <Circle\n cx={center}\n cy={center}\n fill=\"none\"\n r={radius}\n stroke={color}\n strokeDasharray={strokeDasharray}\n strokeLinecap=\"round\"\n strokeWidth={strokeWidth}\n />\n </Svg>\n </Animated.View>\n );\n },\n);\n\nconst styles = StyleSheet.create({\n root: {\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n});\n"],"mappings":"AAoCQ,cA4CJ,YA5CI;AAnCR,SAAS,MAAM,eAAe;AAC9B,SAAS,UAAU,YAAY,YAAY;AAC3C,OAAO,OAAO,QAAQ,SAAS;AAE/B,SAAS,yCAAyC;AAY3C,MAAM,mBAAmB,KAAK,SAASA,kBAAiB;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA0B;AACxB,QAAM,YAAY;AAAA,IAChB,MAAM,CAAC,OAAO,MAAM,EAAE,QAAQ,OAAO,MAAM,GAAG,KAAK;AAAA,IACnD,CAAC,OAAO,KAAK;AAAA,EACf;AAEA,SACE,oBAAC,QAAM,GAAG,OAAO,OAAO,WACrB,0BACC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF,IAEA;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF,GAEJ;AAEJ,CAAC;AAUD,MAAM,iBAAiB,KAAK,SAASC,gBAAe;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAwB;AACtB,QAAM,SAAS,QAAQ;AACvB,QAAM,UAAU,QAAQ,eAAe;AACvC,QAAM,gBAAgB,IAAI,KAAK,KAAK;AACpC,QAAM,kBAAkB;AAAA,IACtB,MAAM,CAAC,eAAe,aAAa;AAAA,IACnC,CAAC,aAAa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AAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,MAAK;AAAA,UACL,GAAG;AAAA,UACH,QAAQ;AAAA,UACR;AAAA;AAAA,MACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,MAAK;AAAA,UACL,GAAG;AAAA,UACH,QAAQ;AAAA,UACR;AAAA,UACA,eAAc;AAAA,UACd;AAAA;AAAA,MACF;AAAA,OACF,GACF;AAAA,EAEJ;AACF;AAEA,MAAM,SAAS,WAAW,OAAO;AAAA,EAC/B,MAAM;AAAA,IACJ,YAAY;AAAA,IACZ,gBAAgB;AAAA,EAClB;AACF,CAAC;","names":["CircularProgress","ProgressCircle","CircularIndeterminateIndicator"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { DividerProps } from '../../types/divider.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/theme';
|
|
6
|
+
import '../../types/view.types.mjs';
|
|
7
|
+
|
|
8
|
+
declare const Divider: react.MemoExoticComponent<({ accessible, color, inset, orientation, role, style, tone, ...props }: DividerProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { Divider };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { useStyleProps, useThemedStyles } from "@impulse-ui-native/theme";
|
|
5
|
+
import { View } from "./view";
|
|
6
|
+
const Divider = memo(function Divider2({
|
|
7
|
+
accessible = true,
|
|
8
|
+
color,
|
|
9
|
+
inset = "none",
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
role = "separator",
|
|
12
|
+
style,
|
|
13
|
+
tone = "subtle",
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
const extractedStyleProps = useStyleProps(props);
|
|
17
|
+
const styles = useThemedStyles(
|
|
18
|
+
themedStyles,
|
|
19
|
+
{ color, inset, orientation, tone },
|
|
20
|
+
[color, inset, orientation, tone]
|
|
21
|
+
);
|
|
22
|
+
const dividerStyle = useMemo(
|
|
23
|
+
() => [styles.divider, extractedStyleProps, style],
|
|
24
|
+
[extractedStyleProps, style, styles.divider]
|
|
25
|
+
);
|
|
26
|
+
return /* @__PURE__ */ jsx(View, { ...props, accessible, role, style: dividerStyle });
|
|
27
|
+
});
|
|
28
|
+
function themedStyles(theme, props) {
|
|
29
|
+
const { color, inset, orientation, tone } = props;
|
|
30
|
+
const dividerTokens = theme.components.divider;
|
|
31
|
+
const insetStart = inset === "start" || inset === "both";
|
|
32
|
+
const insetEnd = inset === "end" || inset === "both";
|
|
33
|
+
return StyleSheet.create({
|
|
34
|
+
divider: {
|
|
35
|
+
alignSelf: "stretch",
|
|
36
|
+
flexShrink: 0,
|
|
37
|
+
height: orientation === "horizontal" ? dividerTokens.thickness : void 0,
|
|
38
|
+
marginBottom: orientation === "vertical" && insetEnd ? dividerTokens.inset : 0,
|
|
39
|
+
marginEnd: orientation === "horizontal" && insetEnd ? dividerTokens.inset : 0,
|
|
40
|
+
marginStart: orientation === "horizontal" && insetStart ? dividerTokens.inset : 0,
|
|
41
|
+
marginTop: orientation === "vertical" && insetStart ? dividerTokens.inset : 0,
|
|
42
|
+
width: orientation === "vertical" ? dividerTokens.thickness : void 0,
|
|
43
|
+
backgroundColor: color ?? dividerTokens.colors[tone]
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
Divider
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/divider.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { useStyleProps, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { DividerProps } from \"../../types\";\nimport { View } from \"./view\";\n\nexport const Divider = memo(function Divider({\n accessible = true,\n color,\n inset = \"none\",\n orientation = \"horizontal\",\n role = \"separator\",\n style,\n tone = \"subtle\",\n ...props\n}: DividerProps) {\n const extractedStyleProps = useStyleProps(props);\n const styles = useThemedStyles(\n themedStyles,\n { color, inset, orientation, tone },\n [color, inset, orientation, tone],\n );\n const dividerStyle = useMemo(\n () => [styles.divider, extractedStyleProps, style],\n [extractedStyleProps, style, styles.divider],\n );\n\n return (\n <View {...props} accessible={accessible} role={role} style={dividerStyle} />\n );\n});\n\ninterface DividerThemeProps {\n color: DividerProps[\"color\"];\n inset: NonNullable<DividerProps[\"inset\"]>;\n orientation: NonNullable<DividerProps[\"orientation\"]>;\n tone: NonNullable<DividerProps[\"tone\"]>;\n}\n\nfunction themedStyles(theme: AppTheme, props: DividerThemeProps) {\n const { color, inset, orientation, tone } = props;\n const dividerTokens = theme.components.divider;\n const insetStart = inset === \"start\" || inset === \"both\";\n const insetEnd = inset === \"end\" || inset === \"both\";\n\n return StyleSheet.create({\n divider: {\n alignSelf: \"stretch\",\n flexShrink: 0,\n height:\n orientation === \"horizontal\" ? dividerTokens.thickness : undefined,\n marginBottom:\n orientation === \"vertical\" && insetEnd ? dividerTokens.inset : 0,\n marginEnd:\n orientation === \"horizontal\" && insetEnd ? dividerTokens.inset : 0,\n marginStart:\n orientation === \"horizontal\" && insetStart ? dividerTokens.inset : 0,\n marginTop:\n orientation === \"vertical\" && insetStart ? dividerTokens.inset : 0,\n width: orientation === \"vertical\" ? dividerTokens.thickness : undefined,\n backgroundColor: color ?? dividerTokens.colors[tone],\n },\n });\n}\n"],"mappings":"AA+BI;AA/BJ,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAG3B,SAAS,eAAe,uBAAuB;AAG/C,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|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useMemo } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
4
|
import { Icon } from "@impulse-ui-native/icon/components/icon";
|
|
5
5
|
import { useThemedStyles } from "@impulse-ui-native/theme";
|
|
6
6
|
import { Pressable } from "./pressable";
|
|
7
|
+
import { Spinner } from "./spinner";
|
|
7
8
|
const IconButton = memo(function IconButton2({
|
|
8
9
|
accessibilityState,
|
|
9
10
|
size = "medium",
|
|
@@ -39,7 +40,7 @@ const IconButton = memo(function IconButton2({
|
|
|
39
40
|
accessibilityState: resolvedAccessibilityState,
|
|
40
41
|
disabled: interactionDisabled,
|
|
41
42
|
style: iconButtonStyles,
|
|
42
|
-
children: loading ? /* @__PURE__ */ jsx(
|
|
43
|
+
children: loading ? /* @__PURE__ */ jsx(Spinner, { accessible: false, color: styles.icon.color, size }) : /* @__PURE__ */ jsx(Icon, { size, icon, color: styles.icon.color })
|
|
43
44
|
}
|
|
44
45
|
);
|
|
45
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/atoms/icon-button.tsx"],"sourcesContent":["import type { AccessibilityState } from \"react-native\";\nimport { memo, PropsWithChildren, useMemo } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/icon-button.tsx"],"sourcesContent":["import type { AccessibilityState } from \"react-native\";\nimport { memo, PropsWithChildren, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport { Icon } from \"@impulse-ui-native/icon/components/icon\";\nimport { AppTheme, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport { IconButtonProps, IconButtonThemeProps } from \"../../types\";\nimport { Pressable } from \"./pressable\";\nimport { Spinner } from \"./spinner\";\n\nexport const IconButton = memo(function IconButton({\n accessibilityState,\n size = \"medium\",\n variant = \"filled\",\n disabled,\n loading = false,\n style,\n icon,\n ...props\n}: PropsWithChildren<IconButtonProps>) {\n const styles = useThemedStyles(themedStyles, { size, variant, disabled }, [\n size,\n variant,\n disabled,\n ]);\n\n const interactionDisabled = disabled === true || loading;\n\n const resolvedAccessibilityState = useMemo<AccessibilityState>(\n () => ({\n ...accessibilityState,\n busy: loading,\n disabled: interactionDisabled,\n }),\n [accessibilityState, interactionDisabled, loading],\n );\n\n const iconButtonStyles = useMemo(\n () => [styles.button, style],\n [styles.button, style],\n );\n\n return (\n <Pressable\n {...props}\n accessibilityState={resolvedAccessibilityState}\n disabled={interactionDisabled}\n style={iconButtonStyles}\n >\n {loading ? (\n <Spinner accessible={false} color={styles.icon.color} size={size} />\n ) : (\n <Icon size={size} icon={icon} color={styles.icon.color} />\n )}\n </Pressable>\n );\n});\n\nfunction themedStyles(theme: AppTheme, props: IconButtonThemeProps) {\n const { size, variant, disabled } = props;\n\n const iconButtonTokens = theme.components.iconButton;\n const sizeTokens = iconButtonTokens.sizes[size];\n const variantTokens = iconButtonTokens.variants[variant];\n\n return StyleSheet.create({\n button: {\n alignItems: \"center\",\n justifyContent: \"center\",\n\n height: sizeTokens.size,\n width: sizeTokens.size,\n padding: sizeTokens.padding,\n\n borderWidth: iconButtonTokens.borderWidth,\n borderRadius: iconButtonTokens.borderRadius,\n\n borderColor: disabled\n ? variantTokens.disabledBorderColor\n : variantTokens.borderColor,\n\n backgroundColor: disabled\n ? variantTokens.disabledBackgroundColor\n : variantTokens.backgroundColor,\n },\n\n icon: {\n color: disabled ? variantTokens.disabledColor : variantTokens.color,\n },\n });\n}\n"],"mappings":"AAmDQ;AAlDR,SAAS,MAAyB,eAAe;AACjD,SAAS,kBAAkB;AAE3B,SAAS,YAAY;AACrB,SAAmB,uBAAuB;AAG1C,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAEjB,MAAM,aAAa,KAAK,SAASA,YAAW;AAAA,EACjD;AAAA,EACA,OAAO;AAAA,EACP,UAAU;AAAA,EACV;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,GA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,cAAc,gBAAgB,cAAc;AAAA,IAChE;AAAA,EACF,CAAC;AACH;","names":["IconButton"]}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
+
export { Avatar } from './avatar.mjs';
|
|
2
|
+
export { BadgeRoot as Badge } from './badge/root.mjs';
|
|
1
3
|
export { View } from './view.mjs';
|
|
2
4
|
export { SafeAreaView } from './safe-area-view.mjs';
|
|
3
5
|
export { Typography, TypographyComponent } from './typography.mjs';
|
|
4
6
|
export { Button } from './button.mjs';
|
|
7
|
+
export { Divider } from './divider.mjs';
|
|
5
8
|
export { IconButton } from './icon-button.mjs';
|
|
6
9
|
export { Pressable } from './pressable.mjs';
|
|
10
|
+
export { Progress } from './progress.mjs';
|
|
11
|
+
export { Spinner } from './spinner.mjs';
|
|
7
12
|
export { Tag } from './tag.mjs';
|
|
8
13
|
import 'react';
|
|
9
|
-
import '@impulse-ui-native/theme';
|
|
10
|
-
import 'react-native';
|
|
11
14
|
import 'react/jsx-runtime';
|
|
15
|
+
import '../../types/avatar.types.mjs';
|
|
16
|
+
import 'react-native';
|
|
17
|
+
import '@impulse-ui-native/theme';
|
|
18
|
+
import '../../types/view.types.mjs';
|
|
19
|
+
import '../../types/badge.types.mjs';
|
|
20
|
+
import '../../types/control-components.types.mjs';
|
|
21
|
+
import '@impulse-ui-native/icon/types';
|
|
22
|
+
import '../../types/spinner.types.mjs';
|
|
23
|
+
import '../../types/button.types.mjs';
|
|
12
24
|
import '../../types/safe-area-view.types.mjs';
|
|
13
25
|
import 'react-native-safe-area-context';
|
|
14
26
|
import '../../types/typography.types.mjs';
|
|
15
|
-
import '../../types/
|
|
27
|
+
import '../../types/divider.types.mjs';
|
|
16
28
|
import '../../types/icon-button.types.mjs';
|
|
17
|
-
import '
|
|
29
|
+
import '../../types/progress.types.mjs';
|
|
18
30
|
import '../../types/tag.types.mjs';
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
import { Avatar } from "./avatar";
|
|
2
|
+
import { Badge } from "./badge";
|
|
1
3
|
import { View } from "./view";
|
|
2
4
|
import { SafeAreaView } from "./safe-area-view";
|
|
3
5
|
import { Typography } from "./typography";
|
|
4
6
|
import { Button } from "./button";
|
|
7
|
+
import { Divider } from "./divider";
|
|
5
8
|
import { IconButton } from "./icon-button";
|
|
6
9
|
import { Pressable } from "./pressable";
|
|
10
|
+
import { Progress } from "./progress";
|
|
11
|
+
import { Spinner } from "./spinner";
|
|
7
12
|
import { Tag } from "./tag";
|
|
8
13
|
export {
|
|
14
|
+
Avatar,
|
|
15
|
+
Badge,
|
|
9
16
|
Button,
|
|
17
|
+
Divider,
|
|
10
18
|
IconButton,
|
|
11
19
|
Pressable,
|
|
20
|
+
Progress,
|
|
12
21
|
SafeAreaView,
|
|
22
|
+
Spinner,
|
|
13
23
|
Tag,
|
|
14
24
|
Typography,
|
|
15
25
|
View
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/atoms/index.ts"],"sourcesContent":["export { View } from \"./view\";\nexport { SafeAreaView } from \"./safe-area-view\";\nexport { Typography, type TypographyComponent } from \"./typography\";\nexport { Button } from \"./button\";\nexport { IconButton } from \"./icon-button\";\nexport { Pressable } from \"./pressable\";\nexport { Tag } from \"./tag\";\n"],"mappings":"AAAA,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,kBAA4C;AACrD,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,WAAW;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/index.ts"],"sourcesContent":["export { Avatar } from \"./avatar\";\nexport { Badge } from \"./badge\";\nexport { View } from \"./view\";\nexport { SafeAreaView } from \"./safe-area-view\";\nexport { Typography, type TypographyComponent } from \"./typography\";\nexport { Button } from \"./button\";\nexport { Divider } from \"./divider\";\nexport { IconButton } from \"./icon-button\";\nexport { Pressable } from \"./pressable\";\nexport { Progress } from \"./progress\";\nexport { Spinner } from \"./spinner\";\nexport { Tag } from \"./tag\";\n"],"mappings":"AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,kBAA4C;AACrD,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,WAAW;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ViewProps, ColorValue } from 'react-native';
|
|
4
|
+
|
|
5
|
+
interface LinearProgressProps extends ViewProps {
|
|
6
|
+
animationDuration: number;
|
|
7
|
+
borderRadius: number;
|
|
8
|
+
fraction: number;
|
|
9
|
+
indicatorColor: ColorValue;
|
|
10
|
+
indeterminate: boolean;
|
|
11
|
+
indeterminateWidth: number;
|
|
12
|
+
trackColor: ColorValue;
|
|
13
|
+
trackHeight: number;
|
|
14
|
+
}
|
|
15
|
+
declare const LinearProgress: react.MemoExoticComponent<({ animationDuration, borderRadius, fraction, indicatorColor, indeterminate, indeterminateWidth, onLayout, style, trackColor, trackHeight, ...props }: LinearProgressProps) => react_jsx_runtime.JSX.Element>;
|
|
16
|
+
|
|
17
|
+
export { LinearProgress };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useMemo, useState } from "react";
|
|
3
|
+
import { Animated, I18nManager, StyleSheet, View } from "react-native";
|
|
4
|
+
import { useIndeterminateProgressAnimation } from "../../hooks/use-indeterminate-progress-animation.hook";
|
|
5
|
+
const LinearProgress = memo(function LinearProgress2({
|
|
6
|
+
animationDuration,
|
|
7
|
+
borderRadius,
|
|
8
|
+
fraction,
|
|
9
|
+
indicatorColor,
|
|
10
|
+
indeterminate,
|
|
11
|
+
indeterminateWidth,
|
|
12
|
+
onLayout,
|
|
13
|
+
style,
|
|
14
|
+
trackColor,
|
|
15
|
+
trackHeight,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const [trackWidth, setTrackWidth] = useState(0);
|
|
19
|
+
const handleLayout = useCallback(
|
|
20
|
+
(event) => {
|
|
21
|
+
setTrackWidth(event.nativeEvent.layout.width);
|
|
22
|
+
onLayout?.(event);
|
|
23
|
+
},
|
|
24
|
+
[onLayout]
|
|
25
|
+
);
|
|
26
|
+
const trackStyle = useMemo(
|
|
27
|
+
() => [
|
|
28
|
+
styles.track,
|
|
29
|
+
{
|
|
30
|
+
backgroundColor: trackColor,
|
|
31
|
+
borderRadius,
|
|
32
|
+
height: trackHeight
|
|
33
|
+
},
|
|
34
|
+
style
|
|
35
|
+
],
|
|
36
|
+
[borderRadius, style, trackColor, trackHeight]
|
|
37
|
+
);
|
|
38
|
+
const determinateIndicatorStyle = useMemo(
|
|
39
|
+
() => ({
|
|
40
|
+
alignSelf: I18nManager.isRTL ? "flex-end" : "flex-start",
|
|
41
|
+
backgroundColor: indicatorColor,
|
|
42
|
+
borderRadius,
|
|
43
|
+
height: trackHeight,
|
|
44
|
+
width: `${fraction * 100}%`
|
|
45
|
+
}),
|
|
46
|
+
[borderRadius, fraction, indicatorColor, trackHeight]
|
|
47
|
+
);
|
|
48
|
+
return /* @__PURE__ */ jsx(View, { ...props, onLayout: handleLayout, style: trackStyle, children: indeterminate ? /* @__PURE__ */ jsx(
|
|
49
|
+
LinearIndeterminateIndicator,
|
|
50
|
+
{
|
|
51
|
+
animationDuration,
|
|
52
|
+
borderRadius,
|
|
53
|
+
color: indicatorColor,
|
|
54
|
+
ratio: indeterminateWidth,
|
|
55
|
+
trackHeight,
|
|
56
|
+
trackWidth
|
|
57
|
+
}
|
|
58
|
+
) : /* @__PURE__ */ jsx(View, { style: determinateIndicatorStyle }) });
|
|
59
|
+
});
|
|
60
|
+
const LinearIndeterminateIndicator = memo(
|
|
61
|
+
function LinearIndeterminateIndicator2({
|
|
62
|
+
animationDuration,
|
|
63
|
+
borderRadius,
|
|
64
|
+
color,
|
|
65
|
+
ratio,
|
|
66
|
+
trackHeight,
|
|
67
|
+
trackWidth
|
|
68
|
+
}) {
|
|
69
|
+
const progress = useIndeterminateProgressAnimation(animationDuration);
|
|
70
|
+
const indicatorWidth = trackWidth * ratio;
|
|
71
|
+
const translateX = progress.interpolate({
|
|
72
|
+
inputRange: [0, 1],
|
|
73
|
+
outputRange: I18nManager.isRTL ? [trackWidth, -indicatorWidth] : [-indicatorWidth, trackWidth]
|
|
74
|
+
});
|
|
75
|
+
const indicatorStyle = useMemo(
|
|
76
|
+
() => ({
|
|
77
|
+
backgroundColor: color,
|
|
78
|
+
borderRadius,
|
|
79
|
+
height: trackHeight,
|
|
80
|
+
transform: [{ translateX }],
|
|
81
|
+
width: `${ratio * 100}%`
|
|
82
|
+
}),
|
|
83
|
+
[borderRadius, color, ratio, trackHeight, translateX]
|
|
84
|
+
);
|
|
85
|
+
return /* @__PURE__ */ jsx(Animated.View, { style: indicatorStyle });
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
const styles = StyleSheet.create({
|
|
89
|
+
track: {
|
|
90
|
+
overflow: "hidden",
|
|
91
|
+
width: "100%"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
export {
|
|
95
|
+
LinearProgress
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=linear-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/linear-progress.tsx"],"sourcesContent":["import type { ColorValue, LayoutChangeEvent, ViewProps } from \"react-native\";\nimport { memo, useCallback, useMemo, useState } from \"react\";\nimport { Animated, I18nManager, StyleSheet, View } from \"react-native\";\n\nimport { useIndeterminateProgressAnimation } from \"../../hooks/use-indeterminate-progress-animation.hook\";\n\ninterface LinearProgressProps extends ViewProps {\n animationDuration: number;\n borderRadius: number;\n fraction: number;\n indicatorColor: ColorValue;\n indeterminate: boolean;\n indeterminateWidth: number;\n trackColor: ColorValue;\n trackHeight: number;\n}\n\nexport const LinearProgress = memo(function LinearProgress({\n animationDuration,\n borderRadius,\n fraction,\n indicatorColor,\n indeterminate,\n indeterminateWidth,\n onLayout,\n style,\n trackColor,\n trackHeight,\n ...props\n}: LinearProgressProps) {\n const [trackWidth, setTrackWidth] = useState(0);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n setTrackWidth(event.nativeEvent.layout.width);\n onLayout?.(event);\n },\n [onLayout],\n );\n\n const trackStyle = useMemo(\n () => [\n styles.track,\n {\n backgroundColor: trackColor,\n borderRadius,\n height: trackHeight,\n },\n style,\n ],\n [borderRadius, style, trackColor, trackHeight],\n );\n\n const determinateIndicatorStyle = useMemo(\n () => ({\n alignSelf: I18nManager.isRTL\n ? (\"flex-end\" as const)\n : (\"flex-start\" as const),\n backgroundColor: indicatorColor,\n borderRadius,\n height: trackHeight,\n width: `${fraction * 100}%` as const,\n }),\n [borderRadius, fraction, indicatorColor, trackHeight],\n );\n\n return (\n <View {...props} onLayout={handleLayout} style={trackStyle}>\n {indeterminate ? (\n <LinearIndeterminateIndicator\n animationDuration={animationDuration}\n borderRadius={borderRadius}\n color={indicatorColor}\n ratio={indeterminateWidth}\n trackHeight={trackHeight}\n trackWidth={trackWidth}\n />\n ) : (\n <View style={determinateIndicatorStyle} />\n )}\n </View>\n );\n});\n\ninterface LinearIndeterminateIndicatorProps {\n animationDuration: number;\n borderRadius: number;\n color: ColorValue;\n ratio: number;\n trackHeight: number;\n trackWidth: number;\n}\n\nconst LinearIndeterminateIndicator = memo(\n function LinearIndeterminateIndicator({\n animationDuration,\n borderRadius,\n color,\n ratio,\n trackHeight,\n trackWidth,\n }: LinearIndeterminateIndicatorProps) {\n const progress = useIndeterminateProgressAnimation(animationDuration);\n const indicatorWidth = trackWidth * ratio;\n const translateX = progress.interpolate({\n inputRange: [0, 1],\n outputRange: I18nManager.isRTL\n ? [trackWidth, -indicatorWidth]\n : [-indicatorWidth, trackWidth],\n });\n\n const indicatorStyle = useMemo(\n () => ({\n backgroundColor: color,\n borderRadius,\n height: trackHeight,\n transform: [{ translateX }],\n width: `${ratio * 100}%` as const,\n }),\n [borderRadius, color, ratio, trackHeight, translateX],\n );\n\n return <Animated.View style={indicatorStyle} />;\n },\n);\n\nconst styles = StyleSheet.create({\n track: {\n overflow: \"hidden\",\n width: \"100%\",\n },\n});\n"],"mappings":"AAqEQ;AApER,SAAS,MAAM,aAAa,SAAS,gBAAgB;AACrD,SAAS,UAAU,aAAa,YAAY,YAAY;AAExD,SAAS,yCAAyC;AAa3C,MAAM,iBAAiB,KAAK,SAASA,gBAAe;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAwB;AACtB,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC;AAE9C,QAAM,eAAe;AAAA,IACnB,CAAC,UAA6B;AAC5B,oBAAc,MAAM,YAAY,OAAO,KAAK;AAC5C,iBAAW,KAAK;AAAA,IAClB;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,aAAa;AAAA,IACjB,MAAM;AAAA,MACJ,OAAO;AAAA,MACP;AAAA,QACE,iBAAiB;AAAA,QACjB;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,cAAc,OAAO,YAAY,WAAW;AAAA,EAC/C;AAEA,QAAM,4BAA4B;AAAA,IAChC,OAAO;AAAA,MACL,WAAW,YAAY,QAClB,aACA;AAAA,MACL,iBAAiB;AAAA,MACjB;AAAA,MACA,QAAQ;AAAA,MACR,OAAO,GAAG,WAAW,GAAG;AAAA,IAC1B;AAAA,IACA,CAAC,cAAc,UAAU,gBAAgB,WAAW;AAAA,EACtD;AAEA,SACE,oBAAC,QAAM,GAAG,OAAO,UAAU,cAAc,OAAO,YAC7C,0BACC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,OAAO;AAAA,MACP;AAAA,MACA;AAAA;AAAA,EACF,IAEA,oBAAC,QAAK,OAAO,2BAA2B,GAE5C;AAEJ,CAAC;AAWD,MAAM,+BAA+B;AAAA,EACnC,SAASC,8BAA6B;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAsC;AACpC,UAAM,WAAW,kCAAkC,iBAAiB;AACpE,UAAM,iBAAiB,aAAa;AACpC,UAAM,aAAa,SAAS,YAAY;AAAA,MACtC,YAAY,CAAC,GAAG,CAAC;AAAA,MACjB,aAAa,YAAY,QACrB,CAAC,YAAY,CAAC,cAAc,IAC5B,CAAC,CAAC,gBAAgB,UAAU;AAAA,IAClC,CAAC;AAED,UAAM,iBAAiB;AAAA,MACrB,OAAO;AAAA,QACL,iBAAiB;AAAA,QACjB;AAAA,QACA,QAAQ;AAAA,QACR,WAAW,CAAC,EAAE,WAAW,CAAC;AAAA,QAC1B,OAAO,GAAG,QAAQ,GAAG;AAAA,MACvB;AAAA,MACA,CAAC,cAAc,OAAO,OAAO,aAAa,UAAU;AAAA,IACtD;AAEA,WAAO,oBAAC,SAAS,MAAT,EAAc,OAAO,gBAAgB;AAAA,EAC/C;AACF;AAEA,MAAM,SAAS,WAAW,OAAO;AAAA,EAC/B,OAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AACF,CAAC;","names":["LinearProgress","LinearIndeterminateIndicator"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import * as react_native from 'react-native';
|
|
1
2
|
import * as react from 'react';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
3
|
import { PressableCoreProps } from '../../types/button.types.mjs';
|
|
5
|
-
import 'react-native';
|
|
6
4
|
import '@impulse-ui-native/theme';
|
|
7
5
|
|
|
8
|
-
declare const Pressable: react.
|
|
6
|
+
declare const Pressable: react.NamedExoticComponent<PressableCoreProps & {
|
|
7
|
+
children?: react.ReactNode | undefined;
|
|
8
|
+
} & react.RefAttributes<react_native.View>>;
|
|
9
9
|
|
|
10
10
|
export { Pressable };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useCallback } from "react";
|
|
2
|
+
import { forwardRef, memo, useCallback } from "react";
|
|
3
3
|
import {
|
|
4
4
|
Pressable as RNPressable,
|
|
5
5
|
StyleSheet
|
|
@@ -10,49 +10,54 @@ import {
|
|
|
10
10
|
useComponentsTokens,
|
|
11
11
|
useStyleProps
|
|
12
12
|
} from "@impulse-ui-native/theme";
|
|
13
|
-
const Pressable = memo(
|
|
14
|
-
children,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
const Pressable = memo(
|
|
14
|
+
forwardRef(function PressableCore({ children, disabled, pressedStyle, style, ...props }, ref) {
|
|
15
|
+
const colors = useColors();
|
|
16
|
+
const tokens = useComponentsTokens();
|
|
17
|
+
const pressableTokens = tokens.pressable;
|
|
18
|
+
const extractedStyleProps = useStyleProps(props);
|
|
19
|
+
const pressableStyles = useCallback(
|
|
20
|
+
(state) => {
|
|
21
|
+
let overrideStyle;
|
|
22
|
+
if (typeof style === "function") {
|
|
23
|
+
overrideStyle = style(state);
|
|
24
|
+
} else {
|
|
25
|
+
overrideStyle = style;
|
|
26
|
+
}
|
|
27
|
+
return StyleSheet.flatten([
|
|
28
|
+
{
|
|
29
|
+
opacity: disabled ? pressableTokens.disabledOpacity : state.pressed ? pressableTokens.pressedOpacity : 1
|
|
30
|
+
},
|
|
31
|
+
getShadowStyle(props.shadow, props.shadowPosition, colors),
|
|
32
|
+
extractedStyleProps,
|
|
33
|
+
overrideStyle,
|
|
34
|
+
state.pressed ? pressedStyle : void 0
|
|
35
|
+
]);
|
|
36
|
+
},
|
|
37
|
+
[
|
|
38
|
+
style,
|
|
39
|
+
pressedStyle,
|
|
40
|
+
disabled,
|
|
37
41
|
extractedStyleProps,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
42
|
+
props.shadow,
|
|
43
|
+
props.shadowPosition,
|
|
44
|
+
colors,
|
|
45
|
+
pressableTokens.disabledOpacity,
|
|
46
|
+
pressableTokens.pressedOpacity
|
|
47
|
+
]
|
|
48
|
+
);
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
RNPressable,
|
|
51
|
+
{
|
|
52
|
+
...props,
|
|
53
|
+
ref,
|
|
54
|
+
style: pressableStyles,
|
|
55
|
+
disabled,
|
|
56
|
+
children
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
})
|
|
60
|
+
);
|
|
56
61
|
export {
|
|
57
62
|
Pressable
|
|
58
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/atoms/pressable.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/pressable.tsx"],"sourcesContent":["import type { ComponentRef, PropsWithChildren } from \"react\";\nimport { forwardRef, memo, useCallback } from \"react\";\nimport {\n PressableStateCallbackType,\n Pressable as RNPressable,\n StyleProp,\n StyleSheet,\n ViewStyle,\n} from \"react-native\";\n\nimport {\n getShadowStyle,\n useColors,\n useComponentsTokens,\n useStyleProps,\n} from \"@impulse-ui-native/theme\";\n\nimport { PressableCoreProps } from \"../../types\";\n\nexport const Pressable = memo(\n forwardRef<\n ComponentRef<typeof RNPressable>,\n PropsWithChildren<PressableCoreProps>\n >(function PressableCore(\n { children, disabled, pressedStyle, style, ...props },\n ref,\n ) {\n const colors = useColors();\n const tokens = useComponentsTokens();\n const pressableTokens = tokens.pressable;\n const extractedStyleProps = useStyleProps(props);\n\n const pressableStyles = useCallback(\n (state: PressableStateCallbackType): StyleProp<ViewStyle> => {\n let overrideStyle: StyleProp<ViewStyle>;\n\n if (typeof style === \"function\") {\n overrideStyle = style(state);\n } else {\n overrideStyle = style;\n }\n\n return StyleSheet.flatten([\n {\n opacity: disabled\n ? pressableTokens.disabledOpacity\n : state.pressed\n ? pressableTokens.pressedOpacity\n : 1,\n },\n getShadowStyle(props.shadow, props.shadowPosition, colors),\n extractedStyleProps,\n overrideStyle,\n state.pressed ? pressedStyle : undefined,\n ]);\n },\n [\n style,\n pressedStyle,\n disabled,\n extractedStyleProps,\n props.shadow,\n props.shadowPosition,\n colors,\n pressableTokens.disabledOpacity,\n pressableTokens.pressedOpacity,\n ],\n );\n\n return (\n <RNPressable\n {...props}\n ref={ref}\n style={pressableStyles}\n disabled={disabled}\n >\n {children}\n </RNPressable>\n );\n }),\n);\n"],"mappings":"AAsEM;AArEN,SAAS,YAAY,MAAM,mBAAmB;AAC9C;AAAA,EAEE,aAAa;AAAA,EAEb;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIA,MAAM,YAAY;AAAA,EACvB,WAGE,SAAS,cACT,EAAE,UAAU,UAAU,cAAc,OAAO,GAAG,MAAM,GACpD,KACA;AACA,UAAM,SAAS,UAAU;AACzB,UAAM,SAAS,oBAAoB;AACnC,UAAM,kBAAkB,OAAO;AAC/B,UAAM,sBAAsB,cAAc,KAAK;AAE/C,UAAM,kBAAkB;AAAA,MACtB,CAAC,UAA4D;AAC3D,YAAI;AAEJ,YAAI,OAAO,UAAU,YAAY;AAC/B,0BAAgB,MAAM,KAAK;AAAA,QAC7B,OAAO;AACL,0BAAgB;AAAA,QAClB;AAEA,eAAO,WAAW,QAAQ;AAAA,UACxB;AAAA,YACE,SAAS,WACL,gBAAgB,kBAChB,MAAM,UACJ,gBAAgB,iBAChB;AAAA,UACR;AAAA,UACA,eAAe,MAAM,QAAQ,MAAM,gBAAgB,MAAM;AAAA,UACzD;AAAA,UACA;AAAA,UACA,MAAM,UAAU,eAAe;AAAA,QACjC,CAAC;AAAA,MACH;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA,gBAAgB;AAAA,QAChB,gBAAgB;AAAA,MAClB;AAAA,IACF;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,OAAO;AAAA,QACP;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ProgressProps } from '../../types/progress.types.mjs';
|
|
4
|
+
import 'react-native';
|
|
5
|
+
import '@impulse-ui-native/theme';
|
|
6
|
+
|
|
7
|
+
declare const Progress: react.MemoExoticComponent<({ accessibilityRole, accessibilityState, accessibilityValue, accessible, color, max, min, size, tone, trackColor, value, variant, ...props }: ProgressProps) => react_jsx_runtime.JSX.Element>;
|
|
8
|
+
|
|
9
|
+
export { Progress };
|