@impulse-ui-native/primitives 4.0.0 → 5.0.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 +62 -20
- package/dist/components/atoms/avatar.d.mts +1 -1
- package/dist/components/atoms/avatar.js +14 -30
- package/dist/components/atoms/avatar.js.map +1 -1
- package/dist/components/atoms/badge/root.d.mts +1 -1
- package/dist/components/atoms/badge/root.js +25 -38
- package/dist/components/atoms/badge/root.js.map +1 -1
- package/dist/components/atoms/button.d.mts +1 -1
- package/dist/components/atoms/button.js +2 -20
- package/dist/components/atoms/button.js.map +1 -1
- package/dist/components/atoms/circular-progress.js +2 -2
- package/dist/components/atoms/circular-progress.js.map +1 -1
- package/dist/components/atoms/divider.d.mts +1 -1
- package/dist/components/atoms/divider.js +18 -14
- package/dist/components/atoms/divider.js.map +1 -1
- package/dist/components/atoms/icon-button.d.mts +1 -1
- package/dist/components/atoms/icon-button.js +1 -11
- package/dist/components/atoms/icon-button.js.map +1 -1
- package/dist/components/atoms/progress.d.mts +1 -1
- package/dist/components/atoms/progress.js +0 -28
- package/dist/components/atoms/progress.js.map +1 -1
- package/dist/components/atoms/spinner.d.mts +1 -1
- package/dist/components/atoms/spinner.js +8 -29
- package/dist/components/atoms/spinner.js.map +1 -1
- package/dist/components/atoms/typography.js +25 -1
- package/dist/components/atoms/typography.js.map +1 -1
- package/dist/components/card/card.d.mts +1 -1
- package/dist/components/card/pressable.d.mts +1 -1
- package/dist/components/card/pressable.js +2 -20
- package/dist/components/card/pressable.js.map +1 -1
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/list/content.d.mts +11 -0
- package/dist/components/list/content.js +27 -0
- package/dist/components/list/content.js.map +1 -0
- package/dist/components/list/index.d.mts +8 -0
- package/dist/components/list/index.js +5 -0
- package/dist/components/list/index.js.map +1 -0
- package/dist/components/list/item.d.mts +11 -0
- package/dist/components/list/item.js +32 -0
- package/dist/components/list/item.js.map +1 -0
- package/dist/components/list/leading.d.mts +11 -0
- package/dist/components/list/leading.js +32 -0
- package/dist/components/list/leading.js.map +1 -0
- package/dist/components/list/list.d.mts +18 -0
- package/dist/components/list/list.js +18 -0
- package/dist/components/list/list.js.map +1 -0
- package/dist/components/list/pressable.d.mts +11 -0
- package/dist/components/list/pressable.js +37 -0
- package/dist/components/list/pressable.js.map +1 -0
- package/dist/components/list/root.d.mts +11 -0
- package/dist/components/list/root.js +33 -0
- package/dist/components/list/root.js.map +1 -0
- package/dist/components/list/trailing.d.mts +11 -0
- package/dist/components/list/trailing.js +32 -0
- package/dist/components/list/trailing.js.map +1 -0
- package/dist/hocs/create-preset.hoc.d.mts +1 -1
- package/dist/hocs/create-preset.hoc.js +23 -8
- package/dist/hocs/create-preset.hoc.js.map +1 -1
- package/dist/hooks/use-indeterminate-progress-animation.hook.js +3 -24
- package/dist/hooks/use-indeterminate-progress-animation.hook.js.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/types/avatar.types.d.mts +1 -1
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/list.types.d.mts +21 -0
- package/dist/types/list.types.js +1 -0
- package/dist/types/list.types.js.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ pnpm add react-native-safe-area-context react-native-svg
|
|
|
25
25
|
- `Tag` labels categories, filters, and metadata, with optional press and close behavior.
|
|
26
26
|
- `Badge` provides compact semantic labels with visual variants and Input-style prefix and suffix addons.
|
|
27
27
|
- `Spinner` provides token-aware sizes and semantic colors for indeterminate loading states.
|
|
28
|
-
- `Progress` provides
|
|
28
|
+
- `Progress` provides linear and circular determinate or indeterminate progress.
|
|
29
29
|
- `Card` provides compound `Root`, `Pressable`, `Header`, `Content`, `Footer`, and `Media` surfaces.
|
|
30
30
|
- `Divider` separates content horizontally or vertically with logical insets and semantic colors.
|
|
31
31
|
- `Avatar` represents identity with shared visual variants, images, initials, custom fallbacks, and semantic presence status.
|
|
@@ -33,6 +33,19 @@ pnpm add react-native-safe-area-context react-native-svg
|
|
|
33
33
|
- `createPreset` creates reusable themed typography presets.
|
|
34
34
|
- Public prop types describe every primitive and control part.
|
|
35
35
|
|
|
36
|
+
Typography presets update their colors with the active theme:
|
|
37
|
+
|
|
38
|
+
- `Subtitle1`, `Subtitle2`, `BodySmall`, `Caption`, `Helper`, `Overline`, and
|
|
39
|
+
`Eyebrow` use `theme.colors.text.secondary` for supporting text.
|
|
40
|
+
- The other presets use `theme.colors.text.primary` for headings and main content.
|
|
41
|
+
|
|
42
|
+
`createPreset` accepts a theme-based `color` in its configuration and falls back
|
|
43
|
+
to `text.primary` when omitted. Explicit `color` props override the preset color;
|
|
44
|
+
`style.color` takes precedence over both. Use tertiary, disabled, inverse, and
|
|
45
|
+
feedback colors explicitly when the surrounding component or state requires them.
|
|
46
|
+
Preset and explicit `fontFamily` and `fontVariant` values are honored, including
|
|
47
|
+
monospace Code. `numeric` selects tabular numbers; style overrides apply last.
|
|
48
|
+
|
|
36
49
|
## Example
|
|
37
50
|
|
|
38
51
|
```tsx
|
|
@@ -48,27 +61,21 @@ import {
|
|
|
48
61
|
Typography,
|
|
49
62
|
View,
|
|
50
63
|
} from "@impulse-ui-native/primitives";
|
|
64
|
+
import { useSpace } from "@impulse-ui-native/theme";
|
|
51
65
|
|
|
52
66
|
export function ProfileSummary() {
|
|
67
|
+
const space = useSpace();
|
|
68
|
+
|
|
53
69
|
return (
|
|
54
|
-
<View gap=
|
|
70
|
+
<View gap={space.md} padding={space.lg}>
|
|
55
71
|
<Typography.Title3>Profile</Typography.Title3>
|
|
56
|
-
<Avatar
|
|
57
|
-
initials="AK"
|
|
58
|
-
status="online"
|
|
59
|
-
variant="soft"
|
|
60
|
-
accessibilityLabel="Alex Kim, online"
|
|
61
|
-
/>
|
|
72
|
+
<Avatar initials="AK" status="online" variant="soft" />
|
|
62
73
|
<Tag label="Active" color="success" />
|
|
63
74
|
<Badge tone="success" variant="soft">
|
|
64
75
|
Active
|
|
65
76
|
</Badge>
|
|
66
|
-
<Spinner
|
|
67
|
-
|
|
68
|
-
tone="secondary"
|
|
69
|
-
accessibilityLabel="Loading profile"
|
|
70
|
-
/>
|
|
71
|
-
<Progress value={65} accessibilityLabel="Profile completion" />
|
|
77
|
+
<Spinner size="small" tone="secondary" />
|
|
78
|
+
<Progress value={65} />
|
|
72
79
|
<Card.Root>
|
|
73
80
|
<Card.Header>
|
|
74
81
|
<Typography.Title4>Account activity</Typography.Title4>
|
|
@@ -88,16 +95,51 @@ export function ProfileSummary() {
|
|
|
88
95
|
|
|
89
96
|
Use the compound `Control` when building a custom field that should share the same label, addon, error, size, and variant behavior as `Input` and `Select`.
|
|
90
97
|
|
|
91
|
-
`Button` and `IconButton` replace their content with a loading indicator when `loading` is true. Loading controls block interaction
|
|
98
|
+
`Button` and `IconButton` replace their content with a loading indicator when `loading` is true. Loading controls block interaction until loading ends.
|
|
92
99
|
|
|
93
|
-
`Spinner` defaults to the primary theme tone and medium size. Use `tone="inverse"` on inverse surfaces, or provide `color` when the indicator must match contextual content.
|
|
100
|
+
`Spinner` defaults to the primary theme tone and medium size. Use `tone="inverse"` on inverse surfaces, or provide `color` when the indicator must match contextual content.
|
|
94
101
|
|
|
95
|
-
`Progress` defaults to a medium linear indicator. Provide `value` for determinate progress or omit it for an indeterminate animation. Values are clamped between `min` and `max`, defaulting to `0` and `100`.
|
|
102
|
+
`Progress` defaults to a medium linear indicator. Provide `value` for determinate progress or omit it for an indeterminate animation. Values are clamped between `min` and `max`, defaulting to `0` and `100`.
|
|
96
103
|
|
|
97
|
-
Use `Card.Root` for a static surface and `Card.Pressable` when the whole card has one action.
|
|
104
|
+
Use `Card.Root` for a static surface and `Card.Pressable` when the whole card has one action. Avoid placing independently pressable controls inside `Card.Pressable`; use `Card.Root` with actions in `Card.Footer` instead.
|
|
98
105
|
|
|
99
|
-
`Divider` defaults to a subtle horizontal separator
|
|
106
|
+
`Divider` defaults to a subtle horizontal separator. Use logical start/end insets to preserve RTL alignment, switch to vertical orientation inside a container with a defined height, and use `color` only when the semantic tones do not fit the surrounding surface.
|
|
100
107
|
|
|
101
|
-
`Avatar` supports `filled`, `outlined`, and `soft` display variants. It renders fallback content below its image so initials or a custom fallback remain visible while the image loads or when it fails.
|
|
108
|
+
`Avatar` supports `filled`, `outlined`, and `soft` display variants. It renders fallback content below its image so initials or a custom fallback remain visible while the image loads or when it fails. Avatar grouping and overflow counts are intentionally handled separately.
|
|
102
109
|
|
|
103
110
|
Use `Badge` for compact states and metadata. It supports `filled`, `outlined`, and `soft` display variants and semantic tones. Its addons follow Input: use `PrefixIcon` or `Prefix`, `SuffixIcon` or `Suffix`, and optionally `onPressPrefix` or `onPressSuffix`. A custom component takes precedence over its corresponding icon. Use `Tag` when the whole label needs built-in press or close behavior.
|
|
111
|
+
|
|
112
|
+
## List
|
|
113
|
+
|
|
114
|
+
List is a presentation-focused compound component, exported through primitives
|
|
115
|
+
and the toolkit. It uses the existing theme provider and adds no runtime peers.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { Divider, List, Typography } from "@impulse-ui-native/primitives";
|
|
119
|
+
|
|
120
|
+
<List.Root>
|
|
121
|
+
<List.Item>
|
|
122
|
+
<List.Leading>{/* Icon, avatar, or custom content */}</List.Leading>
|
|
123
|
+
<List.Content>
|
|
124
|
+
<Typography.Title6>Account</Typography.Title6>
|
|
125
|
+
<Typography.BodySmall>Personal details</Typography.BodySmall>
|
|
126
|
+
</List.Content>
|
|
127
|
+
<List.Trailing>{/* Badge, metadata, or indicator */}</List.Trailing>
|
|
128
|
+
</List.Item>
|
|
129
|
+
<Divider inset="both" />
|
|
130
|
+
<List.Pressable onPress={openPreferences}>
|
|
131
|
+
<List.Content>
|
|
132
|
+
<Typography.Body>Preferences</Typography.Body>
|
|
133
|
+
</List.Content>
|
|
134
|
+
</List.Pressable>
|
|
135
|
+
</List.Root>;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Root supplies the surface; Item supplies a static row; Pressable supplies the
|
|
139
|
+
same row layout with native press and disabled behavior. Leading and Trailing
|
|
140
|
+
keep custom content at its natural size while Content fills the remaining width.
|
|
141
|
+
All parts accept their underlying primitive props and style overrides. Use
|
|
142
|
+
Typography for titles and descriptions and Divider for explicit separators.
|
|
143
|
+
Parts may also be composed without Root for standalone rows. Selection and
|
|
144
|
+
indicators remain application-owned; no context, selection state, or automatic
|
|
145
|
+
separator insertion is included. Theme defaults live in components.list.
|
|
@@ -5,6 +5,6 @@ import 'react-native';
|
|
|
5
5
|
import '@impulse-ui-native/theme';
|
|
6
6
|
import '../../types/view.types.mjs';
|
|
7
7
|
|
|
8
|
-
declare const Avatar: react.MemoExoticComponent<({
|
|
8
|
+
declare const Avatar: react.MemoExoticComponent<({ fallback, imageProps, initials, size, source, status, statusColor, style, variant, ...props }: AvatarProps) => react_jsx_runtime.JSX.Element>;
|
|
9
9
|
|
|
10
10
|
export { Avatar };
|
|
@@ -4,12 +4,9 @@ import { Image, StyleSheet, Text } from "react-native";
|
|
|
4
4
|
import { useStyleProps, useThemedStyles } from "@impulse-ui-native/theme";
|
|
5
5
|
import { View } from "./view";
|
|
6
6
|
const Avatar = memo(function Avatar2({
|
|
7
|
-
accessibilityLabel,
|
|
8
|
-
accessible,
|
|
9
7
|
fallback,
|
|
10
8
|
imageProps,
|
|
11
9
|
initials,
|
|
12
|
-
role,
|
|
13
10
|
size = "medium",
|
|
14
11
|
source,
|
|
15
12
|
status,
|
|
@@ -24,37 +21,25 @@ const Avatar = memo(function Avatar2({
|
|
|
24
21
|
{ size, status, statusColor, variant },
|
|
25
22
|
[size, status, statusColor, variant]
|
|
26
23
|
);
|
|
27
|
-
const resolvedAccessible = accessible ?? Boolean(accessibilityLabel);
|
|
28
|
-
const resolvedRole = role ?? (resolvedAccessible ? "img" : "none");
|
|
29
24
|
const sourceKey = useMemo(() => JSON.stringify(source), [source]);
|
|
30
25
|
const containerStyle = useMemo(
|
|
31
26
|
() => [styles.container, extractedStyleProps, style],
|
|
32
27
|
[extractedStyleProps, style, styles.container]
|
|
33
28
|
);
|
|
34
|
-
return /* @__PURE__ */ jsxs(
|
|
35
|
-
View,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
imageProps,
|
|
49
|
-
source
|
|
50
|
-
},
|
|
51
|
-
sourceKey
|
|
52
|
-
) : null
|
|
53
|
-
] }),
|
|
54
|
-
status ? /* @__PURE__ */ jsx(View, { accessible: false, style: styles.status }) : null
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
);
|
|
29
|
+
return /* @__PURE__ */ jsxs(View, { ...props, style: containerStyle, children: [
|
|
30
|
+
/* @__PURE__ */ jsxs(View, { style: styles.content, children: [
|
|
31
|
+
fallback ?? (initials ? /* @__PURE__ */ jsx(Text, { style: styles.initials, children: initials }) : null),
|
|
32
|
+
source ? /* @__PURE__ */ jsx(
|
|
33
|
+
AvatarImageLayer,
|
|
34
|
+
{
|
|
35
|
+
imageProps,
|
|
36
|
+
source
|
|
37
|
+
},
|
|
38
|
+
sourceKey
|
|
39
|
+
) : null
|
|
40
|
+
] }),
|
|
41
|
+
status ? /* @__PURE__ */ jsx(View, { style: styles.status }) : null
|
|
42
|
+
] });
|
|
58
43
|
});
|
|
59
44
|
const AvatarImageLayer = memo(function AvatarImageLayer2({
|
|
60
45
|
imageProps,
|
|
@@ -78,7 +63,6 @@ const AvatarImageLayer = memo(function AvatarImageLayer2({
|
|
|
78
63
|
{
|
|
79
64
|
resizeMode: "cover",
|
|
80
65
|
...imageProps,
|
|
81
|
-
accessible: false,
|
|
82
66
|
onError: handleError,
|
|
83
67
|
source,
|
|
84
68
|
style: imageStyle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/atoms/avatar.tsx"],"sourcesContent":["import type { ImageProps } from \"react-native\";\nimport { memo, useCallback, useMemo, useState } from \"react\";\nimport { Image, StyleSheet, Text } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { useStyleProps, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { AvatarProps } from \"../../types\";\nimport { View } from \"./view\";\n\nexport const Avatar = memo(function Avatar({\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/avatar.tsx"],"sourcesContent":["import type { ImageProps } from \"react-native\";\nimport { memo, useCallback, useMemo, useState } from \"react\";\nimport { Image, StyleSheet, Text } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { useStyleProps, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { AvatarProps } from \"../../types\";\nimport { View } from \"./view\";\n\nexport const Avatar = memo(function Avatar({\n fallback,\n imageProps,\n initials,\n size = \"medium\",\n source,\n status,\n statusColor,\n style,\n variant = \"filled\",\n ...props\n}: AvatarProps) {\n const extractedStyleProps = useStyleProps(props);\n const styles = useThemedStyles(\n themedStyles,\n { size, status, statusColor, variant },\n [size, status, statusColor, variant],\n );\n const sourceKey = useMemo(() => JSON.stringify(source), [source]);\n\n const containerStyle = useMemo(\n () => [styles.container, extractedStyleProps, style],\n [extractedStyleProps, style, styles.container],\n );\n\n return (\n <View {...props} style={containerStyle}>\n <View style={styles.content}>\n {fallback ??\n (initials ? <Text style={styles.initials}>{initials}</Text> : null)}\n\n {source ? (\n <AvatarImageLayer\n key={sourceKey}\n imageProps={imageProps}\n source={source}\n />\n ) : null}\n </View>\n\n {status ? <View style={styles.status} /> : null}\n </View>\n );\n});\n\ninterface AvatarImageLayerProps {\n imageProps: AvatarProps[\"imageProps\"];\n source: NonNullable<AvatarProps[\"source\"]>;\n}\n\nconst AvatarImageLayer = memo(function AvatarImageLayer({\n imageProps,\n source,\n}: AvatarImageLayerProps) {\n const [hasError, setHasError] = useState(false);\n\n const handleError = useCallback<NonNullable<ImageProps[\"onError\"]>>(\n (event) => {\n setHasError(true);\n imageProps?.onError?.(event);\n },\n [imageProps],\n );\n\n const imageStyle = useMemo(\n () => [staticStyles.image, imageProps?.style],\n [imageProps?.style],\n );\n\n if (hasError) return null;\n\n return (\n <Image\n resizeMode=\"cover\"\n {...imageProps}\n onError={handleError}\n source={source}\n style={imageStyle}\n />\n );\n});\n\ninterface AvatarThemeProps {\n size: NonNullable<AvatarProps[\"size\"]>;\n status: AvatarProps[\"status\"];\n statusColor: AvatarProps[\"statusColor\"];\n variant: NonNullable<AvatarProps[\"variant\"]>;\n}\n\nfunction themedStyles(theme: AppTheme, props: AvatarThemeProps) {\n const { size, status, statusColor, variant } = props;\n const avatarTokens = theme.components.avatar;\n const sizeTokens = avatarTokens.sizes[size];\n const variantTokens = avatarTokens.variants[variant];\n\n return StyleSheet.create({\n container: {\n flexShrink: 0,\n height: sizeTokens.size,\n position: \"relative\",\n width: sizeTokens.size,\n },\n content: {\n alignItems: \"center\",\n backgroundColor: variantTokens.backgroundColor,\n borderColor: variantTokens.borderColor,\n borderRadius: sizeTokens.size / 2,\n borderWidth: avatarTokens.borderWidth,\n height: \"100%\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n width: \"100%\",\n },\n initials: {\n color: variantTokens.color,\n fontFamily: avatarTokens.fontFamily,\n fontSize: sizeTokens.fontSize,\n textAlign: \"center\",\n },\n status: {\n backgroundColor:\n statusColor ?? (status ? avatarTokens.statusColors[status] : undefined),\n borderColor: avatarTokens.statusBorderColor,\n borderRadius: sizeTokens.statusSize / 2,\n borderWidth: sizeTokens.statusBorderWidth,\n bottom: 0,\n height: sizeTokens.statusSize,\n position: \"absolute\",\n right: 0,\n width: sizeTokens.statusSize,\n },\n });\n}\n\nconst staticStyles = StyleSheet.create({\n image: {\n bottom: 0,\n height: \"100%\",\n left: 0,\n position: \"absolute\",\n right: 0,\n top: 0,\n width: \"100%\",\n },\n});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ACP,OAAO,WAAW;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEA,MAAM,eAAe,WAAW,OAAO;AAAA,EACrC,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AACF,CAAC;","names":["Avatar","AvatarImageLayer"]}
|
|
@@ -9,6 +9,6 @@ import '../../../types/spinner.types.mjs';
|
|
|
9
9
|
import '../../../types/button.types.mjs';
|
|
10
10
|
import '../../../types/view.types.mjs';
|
|
11
11
|
|
|
12
|
-
declare const BadgeRoot: react.MemoExoticComponent<({
|
|
12
|
+
declare const BadgeRoot: react.MemoExoticComponent<({ backgroundColor, children, color, Prefix, PrefixIcon, onPressPrefix, onPressSuffix, size, style, Suffix, SuffixIcon, tone, variant, ...props }: BadgeProps) => react_jsx_runtime.JSX.Element>;
|
|
13
13
|
|
|
14
14
|
export { BadgeRoot };
|
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
import { View } from "../view";
|
|
10
10
|
import { BadgeAddon } from "./addon";
|
|
11
11
|
const BadgeRoot = memo(function BadgeRoot2({
|
|
12
|
-
accessible,
|
|
13
|
-
accessibilityLabel,
|
|
14
12
|
backgroundColor,
|
|
15
13
|
children,
|
|
16
14
|
color,
|
|
@@ -18,7 +16,6 @@ const BadgeRoot = memo(function BadgeRoot2({
|
|
|
18
16
|
PrefixIcon,
|
|
19
17
|
onPressPrefix,
|
|
20
18
|
onPressSuffix,
|
|
21
|
-
role,
|
|
22
19
|
size = "medium",
|
|
23
20
|
style,
|
|
24
21
|
Suffix,
|
|
@@ -41,41 +38,31 @@ const BadgeRoot = memo(function BadgeRoot2({
|
|
|
41
38
|
[extractedStyleProps, style, styles.container]
|
|
42
39
|
);
|
|
43
40
|
const affixColor = typeof styles.label.color === "string" ? styles.label.color : void 0;
|
|
44
|
-
return /* @__PURE__ */ jsxs(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
IconComponent: SuffixIcon,
|
|
70
|
-
color: affixColor,
|
|
71
|
-
hitSlop: badgeTokens.addonHitSlop,
|
|
72
|
-
iconSize: sizeTokens.iconSize,
|
|
73
|
-
onPress: onPressSuffix
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
);
|
|
41
|
+
return /* @__PURE__ */ jsxs(View, { ...props, style: containerStyle, children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
BadgeAddon,
|
|
44
|
+
{
|
|
45
|
+
Content: Prefix,
|
|
46
|
+
IconComponent: PrefixIcon,
|
|
47
|
+
color: affixColor,
|
|
48
|
+
hitSlop: badgeTokens.addonHitSlop,
|
|
49
|
+
iconSize: sizeTokens.iconSize,
|
|
50
|
+
onPress: onPressPrefix
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.label, children }) : children,
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
BadgeAddon,
|
|
56
|
+
{
|
|
57
|
+
Content: Suffix,
|
|
58
|
+
IconComponent: SuffixIcon,
|
|
59
|
+
color: affixColor,
|
|
60
|
+
hitSlop: badgeTokens.addonHitSlop,
|
|
61
|
+
iconSize: sizeTokens.iconSize,
|
|
62
|
+
onPress: onPressSuffix
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] });
|
|
79
66
|
});
|
|
80
67
|
function themedStyles(theme, props) {
|
|
81
68
|
const { backgroundColor, color, size, tone, variant } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/badge/root.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport { StyleSheet, Text } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport {\n useComponentsTokens,\n useStyleProps,\n useThemedStyles,\n} from \"@impulse-ui-native/theme\";\n\nimport type { BadgeProps, BadgeThemeProps } from \"../../../types\";\nimport { View } from \"../view\";\nimport { BadgeAddon } from \"./addon\";\n\nexport const BadgeRoot = memo(function BadgeRoot({\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/badge/root.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport { StyleSheet, Text } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport {\n useComponentsTokens,\n useStyleProps,\n useThemedStyles,\n} from \"@impulse-ui-native/theme\";\n\nimport type { BadgeProps, BadgeThemeProps } from \"../../../types\";\nimport { View } from \"../view\";\nimport { BadgeAddon } from \"./addon\";\n\nexport const BadgeRoot = memo(function BadgeRoot({\n backgroundColor,\n children,\n color,\n Prefix,\n PrefixIcon,\n onPressPrefix,\n onPressSuffix,\n size = \"medium\",\n style,\n Suffix,\n SuffixIcon,\n tone = \"primary\",\n variant = \"filled\",\n ...props\n}: BadgeProps) {\n const tokens = useComponentsTokens();\n const badgeTokens = tokens.badge;\n const sizeTokens = badgeTokens.sizes[size];\n const extractedStyleProps = useStyleProps(props);\n const styles = useThemedStyles(\n themedStyles,\n { backgroundColor, color, size, tone, variant },\n [backgroundColor, color, size, tone, variant],\n );\n\n const containerStyle = useMemo(\n () => [styles.container, extractedStyleProps, style],\n [extractedStyleProps, style, styles.container],\n );\n const affixColor =\n typeof styles.label.color === \"string\" ? styles.label.color : undefined;\n\n return (\n <View {...props} style={containerStyle}>\n <BadgeAddon\n Content={Prefix}\n IconComponent={PrefixIcon}\n color={affixColor}\n hitSlop={badgeTokens.addonHitSlop}\n iconSize={sizeTokens.iconSize}\n onPress={onPressPrefix}\n />\n\n {typeof children === \"string\" || typeof children === \"number\" ? (\n <Text numberOfLines={1} style={styles.label}>\n {children}\n </Text>\n ) : (\n children\n )}\n\n <BadgeAddon\n Content={Suffix}\n IconComponent={SuffixIcon}\n color={affixColor}\n hitSlop={badgeTokens.addonHitSlop}\n iconSize={sizeTokens.iconSize}\n onPress={onPressSuffix}\n />\n </View>\n );\n});\n\nfunction themedStyles(theme: AppTheme, props: BadgeThemeProps) {\n const { backgroundColor, color, size, tone, variant } = props;\n\n const badgeTokens = theme.components.badge;\n const sizeTokens = badgeTokens.sizes[size];\n const variantTokens = badgeTokens.colors[tone][variant];\n\n return StyleSheet.create({\n container: {\n alignItems: \"center\",\n alignSelf: \"flex-start\",\n flexDirection: \"row\",\n flexShrink: 0,\n justifyContent: \"center\",\n\n borderRadius: badgeTokens.borderRadius,\n borderWidth: badgeTokens.borderWidth,\n gap: badgeTokens.gap,\n height: sizeTokens.height,\n minWidth: sizeTokens.minWidth,\n paddingHorizontal: sizeTokens.paddingHorizontal,\n\n backgroundColor: backgroundColor ?? variantTokens.backgroundColor,\n borderColor: variantTokens.borderColor,\n },\n\n label: {\n textAlign: \"center\",\n\n fontFamily: badgeTokens.fontFamily,\n fontSize: sizeTokens.fontSize,\n lineHeight: sizeTokens.lineHeight,\n\n color: color ?? variantTokens.color,\n },\n });\n}\n"],"mappings":"AAgDI,SACE,KADF;AAhDJ,SAAS,MAAM,eAAe;AAC9B,SAAS,YAAY,YAAY;AAGjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAEpB,MAAM,YAAY,KAAK,SAASA,WAAU;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;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,EAAE,OAAO;AAEtD,SAAO,WAAW,OAAO;AAAA,IACvB,WAAW;AAAA,MACT,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAEhB,cAAc,YAAY;AAAA,MAC1B,aAAa,YAAY;AAAA,MACzB,KAAK,YAAY;AAAA,MACjB,QAAQ,WAAW;AAAA,MACnB,UAAU,WAAW;AAAA,MACrB,mBAAmB,WAAW;AAAA,MAE9B,iBAAiB,mBAAmB,cAAc;AAAA,MAClD,aAAa,cAAc;AAAA,IAC7B;AAAA,IAEA,OAAO;AAAA,MACL,WAAW;AAAA,MAEX,YAAY,YAAY;AAAA,MACxB,UAAU,WAAW;AAAA,MACrB,YAAY,WAAW;AAAA,MAEvB,OAAO,SAAS,cAAc;AAAA,IAChC;AAAA,EACF,CAAC;AACH;","names":["BadgeRoot"]}
|
|
@@ -5,6 +5,6 @@ import { ButtonProps } from '../../types/button.types.mjs';
|
|
|
5
5
|
import 'react-native';
|
|
6
6
|
import '@impulse-ui-native/theme';
|
|
7
7
|
|
|
8
|
-
declare const Button: react.MemoExoticComponent<({
|
|
8
|
+
declare const Button: react.MemoExoticComponent<({ size, variant, disabled, loading, children, style, ...props }: PropsWithChildren<ButtonProps>) => react_jsx_runtime.JSX.Element>;
|
|
9
9
|
|
|
10
10
|
export { Button };
|
|
@@ -9,7 +9,6 @@ import { Pressable } from "./pressable";
|
|
|
9
9
|
import { Spinner } from "./spinner";
|
|
10
10
|
import { Typography } from "./typography";
|
|
11
11
|
const Button = memo(function Button2({
|
|
12
|
-
accessibilityState,
|
|
13
12
|
size = "medium",
|
|
14
13
|
variant = "filled",
|
|
15
14
|
disabled,
|
|
@@ -24,34 +23,17 @@ const Button = memo(function Button2({
|
|
|
24
23
|
[size, variant, disabled, loading]
|
|
25
24
|
);
|
|
26
25
|
const interactionDisabled = disabled === true || loading;
|
|
27
|
-
const resolvedAccessibilityState = useMemo(
|
|
28
|
-
() => ({
|
|
29
|
-
...accessibilityState,
|
|
30
|
-
busy: loading,
|
|
31
|
-
disabled: interactionDisabled
|
|
32
|
-
}),
|
|
33
|
-
[accessibilityState, interactionDisabled, loading]
|
|
34
|
-
);
|
|
35
26
|
const buttonStyles = useMemo(
|
|
36
27
|
() => [styles.button, style],
|
|
37
28
|
[styles.button, style]
|
|
38
29
|
);
|
|
39
30
|
const content = useMemo(() => {
|
|
40
31
|
if (loading) {
|
|
41
|
-
return /* @__PURE__ */ jsx(Spinner, {
|
|
32
|
+
return /* @__PURE__ */ jsx(Spinner, { color: styles.text.color, size });
|
|
42
33
|
}
|
|
43
34
|
return typeof children === "string" ? /* @__PURE__ */ jsx(Typography.Master, { style: styles.text, children }) : children;
|
|
44
35
|
}, [children, loading, size, styles.text]);
|
|
45
|
-
return /* @__PURE__ */ jsx(
|
|
46
|
-
Pressable,
|
|
47
|
-
{
|
|
48
|
-
...props,
|
|
49
|
-
accessibilityState: resolvedAccessibilityState,
|
|
50
|
-
disabled: interactionDisabled,
|
|
51
|
-
style: buttonStyles,
|
|
52
|
-
children: content
|
|
53
|
-
}
|
|
54
|
-
);
|
|
36
|
+
return /* @__PURE__ */ jsx(Pressable, { ...props, disabled: interactionDisabled, style: buttonStyles, children: content });
|
|
55
37
|
});
|
|
56
38
|
function themedStyles(theme, props) {
|
|
57
39
|
const { size, variant, disabled, loading } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/atoms/button.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/components/atoms/button.tsx"],"sourcesContent":["import { memo, PropsWithChildren, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport {\n AppTheme,\n getActionStateTokens,\n useThemedStyles,\n} from \"@impulse-ui-native/theme\";\n\nimport { ButtonProps, ButtonThemeProps } from \"../../types\";\nimport { Pressable } from \"./pressable\";\nimport { Spinner } from \"./spinner\";\nimport { Typography } from \"./typography\";\n\nexport const Button = memo(function Button({\n size = \"medium\",\n variant = \"filled\",\n disabled,\n loading = false,\n children,\n style,\n ...props\n}: PropsWithChildren<ButtonProps>) {\n const styles = useThemedStyles(\n themedStyles,\n { size, variant, disabled, loading },\n [size, variant, disabled, loading],\n );\n\n const interactionDisabled = disabled === true || loading;\n\n const buttonStyles = useMemo(\n () => [styles.button, style],\n [styles.button, style],\n );\n\n const content = useMemo(() => {\n if (loading) {\n return <Spinner color={styles.text.color} size={size} />;\n }\n\n return typeof children === \"string\" ? (\n <Typography.Master style={styles.text}>{children}</Typography.Master>\n ) : (\n children\n );\n }, [children, loading, size, styles.text]);\n\n return (\n <Pressable {...props} disabled={interactionDisabled} style={buttonStyles}>\n {content}\n </Pressable>\n );\n});\n\nfunction themedStyles(theme: AppTheme, props: ButtonThemeProps) {\n const { size, variant, disabled, loading } = props;\n\n const buttonTokens = theme.components.button;\n const sizeTokens = buttonTokens.sizes[size];\n const appearanceTokens = getActionStateTokens(\n buttonTokens.variants[variant],\n {\n disabled,\n loading,\n },\n );\n\n return StyleSheet.create({\n button: {\n alignItems: \"center\",\n justifyContent: \"center\",\n\n height: sizeTokens.height,\n paddingVertical: sizeTokens.paddingVertical,\n paddingHorizontal: sizeTokens.paddingHorizontal,\n\n borderWidth: buttonTokens.borderWidth,\n borderRadius: buttonTokens.borderRadius,\n\n borderColor: appearanceTokens.borderColor,\n backgroundColor: appearanceTokens.backgroundColor,\n },\n\n text: {\n width: \"100%\",\n textAlign: \"center\",\n\n fontSize: sizeTokens.fontSize,\n\n color: appearanceTokens.color,\n },\n });\n}\n"],"mappings":"AAsCa;AAtCb,SAAS,MAAyB,eAAe;AACjD,SAAS,kBAAkB;AAE3B;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAEpB,MAAM,SAAS,KAAK,SAASA,QAAO;AAAA,EACzC,OAAO;AAAA,EACP,UAAU;AAAA,EACV;AAAA,EAC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MAAM;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,MAEX,UAAU,WAAW;AAAA,MAErB,OAAO,iBAAiB;AAAA,IAC1B;AAAA,EACF,CAAC;AACH;","names":["Button"]}
|
|
@@ -52,7 +52,7 @@ const ProgressCircle = memo(function ProgressCircle2({
|
|
|
52
52
|
() => [circumference, circumference],
|
|
53
53
|
[circumference]
|
|
54
54
|
);
|
|
55
|
-
return /* @__PURE__ */ jsxs(Svg, {
|
|
55
|
+
return /* @__PURE__ */ jsxs(Svg, { height: width, width, children: [
|
|
56
56
|
/* @__PURE__ */ jsx(
|
|
57
57
|
Circle,
|
|
58
58
|
{
|
|
@@ -104,7 +104,7 @@ const CircularIndeterminateIndicator = memo(
|
|
|
104
104
|
() => [circumference * 0.25, circumference * 0.75],
|
|
105
105
|
[circumference]
|
|
106
106
|
);
|
|
107
|
-
return /* @__PURE__ */ jsx(Animated.View, { style: animatedStyle, children: /* @__PURE__ */ jsxs(Svg, {
|
|
107
|
+
return /* @__PURE__ */ jsx(Animated.View, { style: animatedStyle, children: /* @__PURE__ */ jsxs(Svg, { height: width, width, children: [
|
|
108
108
|
/* @__PURE__ */ jsx(
|
|
109
109
|
Circle,
|
|
110
110
|
{
|
|
@@ -1 +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
|
|
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 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 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,I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C,SAAS,MAAT,EAAc,OAAO,eACpB,+BAAC,OAAI,QAAQ,OAAO,OAClB;AAAA;AAAA,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"]}
|
|
@@ -5,6 +5,6 @@ import 'react-native';
|
|
|
5
5
|
import '@impulse-ui-native/theme';
|
|
6
6
|
import '../../types/view.types.mjs';
|
|
7
7
|
|
|
8
|
-
declare const Divider: react.MemoExoticComponent<({
|
|
8
|
+
declare const Divider: react.MemoExoticComponent<({ color, inset, orientation, style, tone, ...props }: DividerProps) => react_jsx_runtime.JSX.Element>;
|
|
9
9
|
|
|
10
10
|
export { Divider };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useMemo } from "react";
|
|
3
3
|
import { StyleSheet } from "react-native";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getDividerTokens,
|
|
6
|
+
useStyleProps,
|
|
7
|
+
useThemedStyles
|
|
8
|
+
} from "@impulse-ui-native/theme";
|
|
5
9
|
import { View } from "./view";
|
|
6
10
|
const Divider = memo(function Divider2({
|
|
7
|
-
accessible = true,
|
|
8
11
|
color,
|
|
9
12
|
inset = "none",
|
|
10
13
|
orientation = "horizontal",
|
|
11
|
-
role = "separator",
|
|
12
14
|
style,
|
|
13
15
|
tone = "subtle",
|
|
14
16
|
...props
|
|
@@ -23,24 +25,26 @@ const Divider = memo(function Divider2({
|
|
|
23
25
|
() => [styles.divider, extractedStyleProps, style],
|
|
24
26
|
[extractedStyleProps, style, styles.divider]
|
|
25
27
|
);
|
|
26
|
-
return /* @__PURE__ */ jsx(View, { ...props,
|
|
28
|
+
return /* @__PURE__ */ jsx(View, { ...props, style: dividerStyle });
|
|
27
29
|
});
|
|
28
30
|
function themedStyles(theme, props) {
|
|
29
31
|
const { color, inset, orientation, tone } = props;
|
|
30
|
-
const dividerTokens = theme.components.divider
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const dividerTokens = getDividerTokens(theme.components.divider, {
|
|
33
|
+
inset,
|
|
34
|
+
orientation,
|
|
35
|
+
tone
|
|
36
|
+
});
|
|
33
37
|
return StyleSheet.create({
|
|
34
38
|
divider: {
|
|
35
39
|
alignSelf: "stretch",
|
|
36
40
|
flexShrink: 0,
|
|
37
|
-
height:
|
|
38
|
-
marginBottom:
|
|
39
|
-
marginEnd:
|
|
40
|
-
marginStart:
|
|
41
|
-
marginTop:
|
|
42
|
-
width:
|
|
43
|
-
backgroundColor: color ?? dividerTokens.
|
|
41
|
+
height: dividerTokens.height,
|
|
42
|
+
marginBottom: dividerTokens.marginBottom,
|
|
43
|
+
marginEnd: dividerTokens.marginEnd,
|
|
44
|
+
marginStart: dividerTokens.marginStart,
|
|
45
|
+
marginTop: dividerTokens.marginTop,
|
|
46
|
+
width: dividerTokens.width,
|
|
47
|
+
backgroundColor: color ?? dividerTokens.backgroundColor
|
|
44
48
|
}
|
|
45
49
|
});
|
|
46
50
|
}
|
|
@@ -1 +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 {
|
|
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 {\n getDividerTokens,\n useStyleProps,\n useThemedStyles,\n} from \"@impulse-ui-native/theme\";\n\nimport type { DividerProps } from \"../../types\";\nimport { View } from \"./view\";\n\nexport const Divider = memo(function Divider({\n color,\n inset = \"none\",\n orientation = \"horizontal\",\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 <View {...props} style={dividerStyle} />;\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 = getDividerTokens(theme.components.divider, {\n inset,\n orientation,\n tone,\n });\n\n return StyleSheet.create({\n divider: {\n alignSelf: \"stretch\",\n flexShrink: 0,\n height: dividerTokens.height,\n marginBottom: dividerTokens.marginBottom,\n marginEnd: dividerTokens.marginEnd,\n marginStart: dividerTokens.marginStart,\n marginTop: dividerTokens.marginTop,\n width: dividerTokens.width,\n backgroundColor: color ?? dividerTokens.backgroundColor,\n },\n });\n}\n"],"mappings":"AAgCS;AAhCT,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAG3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,YAAY;AAEd,MAAM,UAAU,KAAK,SAASA,SAAQ;AAAA,EAC3C;AAAA,EACA,QAAQ;AAAA,EACR,cAAc;AAAA,EACd;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAiB;AACf,QAAM,sBAAsB,cAAc,KAAK;AAC/C,QAAM,SAAS;AAAA,IACb;AAAA,IACA,EAAE,OAAO,OAAO,aAAa,KAAK;AAAA,IAClC,CAAC,OAAO,OAAO,aAAa,IAAI;AAAA,EAClC;AACA,QAAM,eAAe;AAAA,IACnB,MAAM,CAAC,OAAO,SAAS,qBAAqB,KAAK;AAAA,IACjD,CAAC,qBAAqB,OAAO,OAAO,OAAO;AAAA,EAC7C;AAEA,SAAO,oBAAC,QAAM,GAAG,OAAO,OAAO,cAAc;AAC/C,CAAC;AASD,SAAS,aAAa,OAAiB,OAA0B;AAC/D,QAAM,EAAE,OAAO,OAAO,aAAa,KAAK,IAAI;AAC5C,QAAM,gBAAgB,iBAAiB,MAAM,WAAW,SAAS;AAAA,IAC/D;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,WAAW,OAAO;AAAA,IACvB,SAAS;AAAA,MACP,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,QAAQ,cAAc;AAAA,MACtB,cAAc,cAAc;AAAA,MAC5B,WAAW,cAAc;AAAA,MACzB,aAAa,cAAc;AAAA,MAC3B,WAAW,cAAc;AAAA,MACzB,OAAO,cAAc;AAAA,MACrB,iBAAiB,SAAS,cAAc;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;","names":["Divider"]}
|
|
@@ -7,6 +7,6 @@ import '@impulse-ui-native/theme';
|
|
|
7
7
|
import '../../types/button.types.mjs';
|
|
8
8
|
import 'react-native';
|
|
9
9
|
|
|
10
|
-
declare const IconButton: react.MemoExoticComponent<({
|
|
10
|
+
declare const IconButton: react.MemoExoticComponent<({ size, variant, disabled, loading, style, icon, ...props }: PropsWithChildren<IconButtonProps>) => react_jsx_runtime.JSX.Element>;
|
|
11
11
|
|
|
12
12
|
export { IconButton };
|