@korsolutions/ui 0.0.95 → 0.0.97
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/module/components/description-list/context.js +12 -0
- package/dist/module/components/description-list/context.js.map +1 -0
- package/dist/module/components/description-list/description-list-actions.js +17 -0
- package/dist/module/components/description-list/description-list-actions.js.map +1 -0
- package/dist/module/components/description-list/description-list-details.js +17 -0
- package/dist/module/components/description-list/description-list-details.js.map +1 -0
- package/dist/module/components/description-list/description-list-item.js +17 -0
- package/dist/module/components/description-list/description-list-item.js.map +1 -0
- package/dist/module/components/description-list/description-list-root.js +27 -0
- package/dist/module/components/description-list/description-list-root.js.map +1 -0
- package/dist/module/components/description-list/description-list-term.js +17 -0
- package/dist/module/components/description-list/description-list-term.js.map +1 -0
- package/dist/module/components/description-list/index.js +15 -0
- package/dist/module/components/description-list/index.js.map +1 -0
- package/dist/module/components/description-list/types.js +4 -0
- package/dist/module/components/description-list/types.js.map +1 -0
- package/dist/module/components/description-list/variants/default.js +53 -0
- package/dist/module/components/description-list/variants/default.js.map +1 -0
- package/dist/module/components/description-list/variants/index.js +7 -0
- package/dist/module/components/description-list/variants/index.js.map +1 -0
- package/dist/module/components/full-screen-spinner/index.js +6 -0
- package/dist/module/components/full-screen-spinner/index.js.map +1 -0
- package/dist/module/components/full-screen-spinner/manager.js +91 -0
- package/dist/module/components/full-screen-spinner/manager.js.map +1 -0
- package/dist/module/components/index.js +3 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/item/context.js +12 -0
- package/dist/module/components/item/context.js.map +1 -0
- package/dist/module/components/item/index.js +17 -0
- package/dist/module/components/item/index.js.map +1 -0
- package/dist/module/components/item/item-actions.js +17 -0
- package/dist/module/components/item/item-actions.js.map +1 -0
- package/dist/module/components/item/item-content.js +17 -0
- package/dist/module/components/item/item-content.js.map +1 -0
- package/dist/module/components/item/item-description.js +17 -0
- package/dist/module/components/item/item-description.js.map +1 -0
- package/dist/module/components/item/item-media.js +18 -0
- package/dist/module/components/item/item-media.js.map +1 -0
- package/dist/module/components/item/item-root.js +29 -0
- package/dist/module/components/item/item-root.js.map +1 -0
- package/dist/module/components/item/item-title.js +17 -0
- package/dist/module/components/item/item-title.js.map +1 -0
- package/dist/module/components/item/types.js +4 -0
- package/dist/module/components/item/types.js.map +1 -0
- package/dist/module/components/item/variants/default.js +91 -0
- package/dist/module/components/item/variants/default.js.map +1 -0
- package/dist/module/components/item/variants/index.js +11 -0
- package/dist/module/components/item/variants/index.js.map +1 -0
- package/dist/module/components/item/variants/muted.js +93 -0
- package/dist/module/components/item/variants/muted.js.map +1 -0
- package/dist/module/components/item/variants/outline.js +94 -0
- package/dist/module/components/item/variants/outline.js.map +1 -0
- package/dist/module/index.js +2 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/utils/hsla-utils.js +10 -0
- package/dist/module/utils/hsla-utils.js.map +1 -1
- package/dist/typescript/src/components/description-list/context.d.ts +8 -0
- package/dist/typescript/src/components/description-list/context.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/description-list-actions.d.ts +9 -0
- package/dist/typescript/src/components/description-list/description-list-actions.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/description-list-details.d.ts +9 -0
- package/dist/typescript/src/components/description-list/description-list-details.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/description-list-item.d.ts +9 -0
- package/dist/typescript/src/components/description-list/description-list-item.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/description-list-root.d.ts +11 -0
- package/dist/typescript/src/components/description-list/description-list-root.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/description-list-term.d.ts +10 -0
- package/dist/typescript/src/components/description-list/description-list-term.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/index.d.ts +19 -0
- package/dist/typescript/src/components/description-list/index.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/types.d.ts +14 -0
- package/dist/typescript/src/components/description-list/types.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/variants/default.d.ts +3 -0
- package/dist/typescript/src/components/description-list/variants/default.d.ts.map +1 -0
- package/dist/typescript/src/components/description-list/variants/index.d.ts +5 -0
- package/dist/typescript/src/components/description-list/variants/index.d.ts.map +1 -0
- package/dist/typescript/src/components/full-screen-spinner/index.d.ts +7 -0
- package/dist/typescript/src/components/full-screen-spinner/index.d.ts.map +1 -0
- package/dist/typescript/src/components/full-screen-spinner/manager.d.ts +14 -0
- package/dist/typescript/src/components/full-screen-spinner/manager.d.ts.map +1 -0
- package/dist/typescript/src/components/index.d.ts +3 -0
- package/dist/typescript/src/components/index.d.ts.map +1 -1
- package/dist/typescript/src/components/item/context.d.ts +9 -0
- package/dist/typescript/src/components/item/context.d.ts.map +1 -0
- package/dist/typescript/src/components/item/index.d.ts +22 -0
- package/dist/typescript/src/components/item/index.d.ts.map +1 -0
- package/dist/typescript/src/components/item/item-actions.d.ts +9 -0
- package/dist/typescript/src/components/item/item-actions.d.ts.map +1 -0
- package/dist/typescript/src/components/item/item-content.d.ts +9 -0
- package/dist/typescript/src/components/item/item-content.d.ts.map +1 -0
- package/dist/typescript/src/components/item/item-description.d.ts +11 -0
- package/dist/typescript/src/components/item/item-description.d.ts.map +1 -0
- package/dist/typescript/src/components/item/item-media.d.ts +10 -0
- package/dist/typescript/src/components/item/item-media.d.ts.map +1 -0
- package/dist/typescript/src/components/item/item-root.d.ts +12 -0
- package/dist/typescript/src/components/item/item-root.d.ts.map +1 -0
- package/dist/typescript/src/components/item/item-title.d.ts +11 -0
- package/dist/typescript/src/components/item/item-title.d.ts.map +1 -0
- package/dist/typescript/src/components/item/types.d.ts +17 -0
- package/dist/typescript/src/components/item/types.d.ts.map +1 -0
- package/dist/typescript/src/components/item/variants/default.d.ts +3 -0
- package/dist/typescript/src/components/item/variants/default.d.ts.map +1 -0
- package/dist/typescript/src/components/item/variants/index.d.ts +9 -0
- package/dist/typescript/src/components/item/variants/index.d.ts.map +1 -0
- package/dist/typescript/src/components/item/variants/muted.d.ts +3 -0
- package/dist/typescript/src/components/item/variants/muted.d.ts.map +1 -0
- package/dist/typescript/src/components/item/variants/outline.d.ts +3 -0
- package/dist/typescript/src/components/item/variants/outline.d.ts.map +1 -0
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/themes/types.d.ts +8 -0
- package/dist/typescript/src/themes/types.d.ts.map +1 -1
- package/dist/typescript/src/utils/hsla-utils.d.ts +1 -0
- package/dist/typescript/src/utils/hsla-utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/description-list/context.ts +17 -0
- package/src/components/description-list/description-list-actions.tsx +20 -0
- package/src/components/description-list/description-list-details.tsx +20 -0
- package/src/components/description-list/description-list-item.tsx +20 -0
- package/src/components/description-list/description-list-root.tsx +35 -0
- package/src/components/description-list/description-list-term.tsx +21 -0
- package/src/components/description-list/index.ts +20 -0
- package/src/components/description-list/types.ts +15 -0
- package/src/components/description-list/variants/default.tsx +50 -0
- package/src/components/description-list/variants/index.ts +5 -0
- package/src/components/full-screen-spinner/index.ts +5 -0
- package/src/components/full-screen-spinner/manager.tsx +98 -0
- package/src/components/index.ts +3 -0
- package/src/components/item/context.ts +18 -0
- package/src/components/item/index.ts +23 -0
- package/src/components/item/item-actions.tsx +20 -0
- package/src/components/item/item-content.tsx +20 -0
- package/src/components/item/item-description.tsx +27 -0
- package/src/components/item/item-media.tsx +22 -0
- package/src/components/item/item-root.tsx +38 -0
- package/src/components/item/item-title.tsx +22 -0
- package/src/components/item/types.ts +18 -0
- package/src/components/item/variants/default.tsx +71 -0
- package/src/components/item/variants/index.ts +9 -0
- package/src/components/item/variants/muted.tsx +73 -0
- package/src/components/item/variants/outline.tsx +74 -0
- package/src/index.tsx +2 -0
- package/src/themes/types.ts +8 -0
- package/src/utils/hsla-utils.ts +11 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ItemActions } from "./item-actions";
|
|
2
|
+
import { ItemContent } from "./item-content";
|
|
3
|
+
import { ItemDescription } from "./item-description";
|
|
4
|
+
import { ItemMedia } from "./item-media";
|
|
5
|
+
import { ItemRoot } from "./item-root";
|
|
6
|
+
import { ItemTitle } from "./item-title";
|
|
7
|
+
|
|
8
|
+
export const Item = {
|
|
9
|
+
Root: ItemRoot,
|
|
10
|
+
Media: ItemMedia,
|
|
11
|
+
Content: ItemContent,
|
|
12
|
+
Title: ItemTitle,
|
|
13
|
+
Description: ItemDescription,
|
|
14
|
+
Actions: ItemActions,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { ItemRootProps } from "./item-root";
|
|
18
|
+
export type { ItemMediaProps } from "./item-media";
|
|
19
|
+
export type { ItemContentProps } from "./item-content";
|
|
20
|
+
export type { ItemTitleProps } from "./item-title";
|
|
21
|
+
export type { ItemDescriptionProps } from "./item-description";
|
|
22
|
+
export type { ItemActionsProps } from "./item-actions";
|
|
23
|
+
export type { ItemStyles } from "./types";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
3
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
4
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
5
|
+
import { useItem } from "./context";
|
|
6
|
+
|
|
7
|
+
export interface ItemActionsProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ItemActions(props: PropsWithRender<ItemActionsProps>) {
|
|
14
|
+
const item = useItem();
|
|
15
|
+
|
|
16
|
+
const composedStyle = calculateComposedStyles(item.styles, item.state, "actions", props.style);
|
|
17
|
+
|
|
18
|
+
const Component = props.render ?? View;
|
|
19
|
+
return <Component {...props} style={composedStyle} />;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
3
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
4
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
5
|
+
import { useItem } from "./context";
|
|
6
|
+
|
|
7
|
+
export interface ItemContentProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ItemContent(props: PropsWithRender<ItemContentProps>) {
|
|
14
|
+
const item = useItem();
|
|
15
|
+
|
|
16
|
+
const composedStyle = calculateComposedStyles(item.styles, item.state, "content", props.style);
|
|
17
|
+
|
|
18
|
+
const Component = props.render ?? View;
|
|
19
|
+
return <Component {...props} style={composedStyle} />;
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, Text, type TextStyle } from "react-native";
|
|
3
|
+
import type { TextChildren } from "../../types/element.types";
|
|
4
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
5
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
6
|
+
import { useItem } from "./context";
|
|
7
|
+
|
|
8
|
+
export interface ItemDescriptionProps {
|
|
9
|
+
children?: TextChildren;
|
|
10
|
+
numberOfLines?: number;
|
|
11
|
+
|
|
12
|
+
style?: StyleProp<TextStyle>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ItemDescription(props: PropsWithRender<ItemDescriptionProps>) {
|
|
16
|
+
const item = useItem();
|
|
17
|
+
|
|
18
|
+
const composedStyle = calculateComposedStyles(
|
|
19
|
+
item.styles,
|
|
20
|
+
item.state,
|
|
21
|
+
"description",
|
|
22
|
+
props.style,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const Component = props.render ?? Text;
|
|
26
|
+
return <Component {...props} style={composedStyle} />;
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
3
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
4
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
5
|
+
import { useItem } from "./context";
|
|
6
|
+
|
|
7
|
+
export interface ItemMediaProps {
|
|
8
|
+
variant?: "default" | "icon";
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ItemMedia(props: PropsWithRender<ItemMediaProps>) {
|
|
15
|
+
const item = useItem();
|
|
16
|
+
|
|
17
|
+
const styleKey = props.variant === "icon" ? "mediaIcon" : "media";
|
|
18
|
+
const composedStyle = calculateComposedStyles(item.styles, item.state, styleKey, props.style);
|
|
19
|
+
|
|
20
|
+
const Component = props.render ?? View;
|
|
21
|
+
return <Component {...props} style={composedStyle} />;
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
3
|
+
import { useComponentConfig } from "../../themes/provider";
|
|
4
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
5
|
+
import { calculateComposedStyles, mergeStyles } from "../../utils/calculate-styles";
|
|
6
|
+
import { ItemContext } from "./context";
|
|
7
|
+
import { ItemVariants } from "./variants";
|
|
8
|
+
|
|
9
|
+
export interface ItemRootProps {
|
|
10
|
+
variant?: keyof typeof ItemVariants;
|
|
11
|
+
size?: "default" | "sm" | "xs";
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ItemRoot(props: PropsWithRender<ItemRootProps>) {
|
|
18
|
+
const size = props.size ?? "default";
|
|
19
|
+
const variantStyles = ItemVariants[props.variant || "default"](size);
|
|
20
|
+
const componentConfig = useComponentConfig("item");
|
|
21
|
+
|
|
22
|
+
const mergedStyles = mergeStyles(variantStyles, componentConfig?.styles);
|
|
23
|
+
|
|
24
|
+
const composedStyle = calculateComposedStyles(mergedStyles, "default", "root", props.style);
|
|
25
|
+
|
|
26
|
+
const Component = props.render ?? View;
|
|
27
|
+
return (
|
|
28
|
+
<ItemContext.Provider
|
|
29
|
+
value={{
|
|
30
|
+
state: "default",
|
|
31
|
+
styles: mergedStyles,
|
|
32
|
+
size,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<Component {...props} style={composedStyle} />
|
|
36
|
+
</ItemContext.Provider>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, Text, type TextStyle } from "react-native";
|
|
3
|
+
import type { TextChildren } from "../../types/element.types";
|
|
4
|
+
import type { PropsWithRender } from "../../types/props.types";
|
|
5
|
+
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
6
|
+
import { useItem } from "./context";
|
|
7
|
+
|
|
8
|
+
export interface ItemTitleProps {
|
|
9
|
+
children?: TextChildren;
|
|
10
|
+
numberOfLines?: number;
|
|
11
|
+
|
|
12
|
+
style?: StyleProp<TextStyle>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ItemTitle(props: PropsWithRender<ItemTitleProps>) {
|
|
16
|
+
const item = useItem();
|
|
17
|
+
|
|
18
|
+
const composedStyle = calculateComposedStyles(item.styles, item.state, "title", props.style);
|
|
19
|
+
|
|
20
|
+
const Component = props.render ?? Text;
|
|
21
|
+
return <Component {...props} style={composedStyle} />;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ItemRootProps } from "./item-root";
|
|
2
|
+
import type { ItemMediaProps } from "./item-media";
|
|
3
|
+
import type { ItemContentProps } from "./item-content";
|
|
4
|
+
import type { ItemTitleProps } from "./item-title";
|
|
5
|
+
import type { ItemDescriptionProps } from "./item-description";
|
|
6
|
+
import type { ItemActionsProps } from "./item-actions";
|
|
7
|
+
|
|
8
|
+
export type ItemState = "default";
|
|
9
|
+
|
|
10
|
+
export interface ItemStyles {
|
|
11
|
+
root?: Partial<Record<ItemState, ItemRootProps["style"]>>;
|
|
12
|
+
media?: Partial<Record<ItemState, ItemMediaProps["style"]>>;
|
|
13
|
+
mediaIcon?: Partial<Record<ItemState, ItemMediaProps["style"]>>;
|
|
14
|
+
content?: Partial<Record<ItemState, ItemContentProps["style"]>>;
|
|
15
|
+
title?: Partial<Record<ItemState, ItemTitleProps["style"]>>;
|
|
16
|
+
description?: Partial<Record<ItemState, ItemDescriptionProps["style"]>>;
|
|
17
|
+
actions?: Partial<Record<ItemState, ItemActionsProps["style"]>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
2
|
+
import type { ItemStyles } from "../types";
|
|
3
|
+
|
|
4
|
+
const sizeConfig = {
|
|
5
|
+
default: { padding: 12, gap: 12, iconBox: 40, fontSize: 1, descFontSize: 0.875 },
|
|
6
|
+
sm: { padding: 8, gap: 10, iconBox: 32, fontSize: 0.875, descFontSize: 0.8125 },
|
|
7
|
+
xs: { padding: 6, gap: 8, iconBox: 28, fontSize: 0.8125, descFontSize: 0.75 },
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export function useItemVariantDefault(size: "default" | "sm" | "xs" = "default"): ItemStyles {
|
|
11
|
+
const s = sizeConfig[size];
|
|
12
|
+
|
|
13
|
+
return useThemedStyles(
|
|
14
|
+
({ colors, radius, fontFamily, fontSize }): ItemStyles => ({
|
|
15
|
+
root: {
|
|
16
|
+
default: {
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
padding: s.padding,
|
|
20
|
+
gap: s.gap,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
media: {
|
|
24
|
+
default: {
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
justifyContent: "center",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
mediaIcon: {
|
|
30
|
+
default: {
|
|
31
|
+
width: s.iconBox,
|
|
32
|
+
height: s.iconBox,
|
|
33
|
+
borderRadius: radius,
|
|
34
|
+
backgroundColor: colors.muted,
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
justifyContent: "center",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
content: {
|
|
40
|
+
default: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
gap: 2,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
title: {
|
|
46
|
+
default: {
|
|
47
|
+
fontFamily,
|
|
48
|
+
fontSize: fontSize * s.fontSize,
|
|
49
|
+
lineHeight: Math.round(fontSize * s.fontSize * 1.3),
|
|
50
|
+
fontWeight: "500",
|
|
51
|
+
color: colors.foreground,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
description: {
|
|
55
|
+
default: {
|
|
56
|
+
fontFamily,
|
|
57
|
+
fontSize: fontSize * s.descFontSize,
|
|
58
|
+
lineHeight: Math.round(fontSize * s.descFontSize * 1.4),
|
|
59
|
+
color: colors.mutedForeground,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
actions: {
|
|
63
|
+
default: {
|
|
64
|
+
flexDirection: "row",
|
|
65
|
+
alignItems: "center",
|
|
66
|
+
gap: 8,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useItemVariantDefault } from "./default";
|
|
2
|
+
import { useItemVariantMuted } from "./muted";
|
|
3
|
+
import { useItemVariantOutline } from "./outline";
|
|
4
|
+
|
|
5
|
+
export const ItemVariants = {
|
|
6
|
+
default: useItemVariantDefault,
|
|
7
|
+
outline: useItemVariantOutline,
|
|
8
|
+
muted: useItemVariantMuted,
|
|
9
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
2
|
+
import type { ItemStyles } from "../types";
|
|
3
|
+
|
|
4
|
+
const sizeConfig = {
|
|
5
|
+
default: { padding: 12, gap: 12, iconBox: 40, fontSize: 1, descFontSize: 0.875 },
|
|
6
|
+
sm: { padding: 8, gap: 10, iconBox: 32, fontSize: 0.875, descFontSize: 0.8125 },
|
|
7
|
+
xs: { padding: 6, gap: 8, iconBox: 28, fontSize: 0.8125, descFontSize: 0.75 },
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export function useItemVariantMuted(size: "default" | "sm" | "xs" = "default"): ItemStyles {
|
|
11
|
+
const s = sizeConfig[size];
|
|
12
|
+
|
|
13
|
+
return useThemedStyles(
|
|
14
|
+
({ colors, radius, fontFamily, fontSize }): ItemStyles => ({
|
|
15
|
+
root: {
|
|
16
|
+
default: {
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
padding: s.padding,
|
|
20
|
+
gap: s.gap,
|
|
21
|
+
borderRadius: radius,
|
|
22
|
+
backgroundColor: colors.muted,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
media: {
|
|
26
|
+
default: {
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
justifyContent: "center",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
mediaIcon: {
|
|
32
|
+
default: {
|
|
33
|
+
width: s.iconBox,
|
|
34
|
+
height: s.iconBox,
|
|
35
|
+
borderRadius: radius,
|
|
36
|
+
backgroundColor: colors.background,
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
content: {
|
|
42
|
+
default: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
gap: 2,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
title: {
|
|
48
|
+
default: {
|
|
49
|
+
fontFamily,
|
|
50
|
+
fontSize: fontSize * s.fontSize,
|
|
51
|
+
lineHeight: Math.round(fontSize * s.fontSize * 1.3),
|
|
52
|
+
fontWeight: "500",
|
|
53
|
+
color: colors.foreground,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
description: {
|
|
57
|
+
default: {
|
|
58
|
+
fontFamily,
|
|
59
|
+
fontSize: fontSize * s.descFontSize,
|
|
60
|
+
lineHeight: Math.round(fontSize * s.descFontSize * 1.4),
|
|
61
|
+
color: colors.mutedForeground,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
actions: {
|
|
65
|
+
default: {
|
|
66
|
+
flexDirection: "row",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
gap: 8,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
2
|
+
import type { ItemStyles } from "../types";
|
|
3
|
+
|
|
4
|
+
const sizeConfig = {
|
|
5
|
+
default: { padding: 12, gap: 12, iconBox: 40, fontSize: 1, descFontSize: 0.875 },
|
|
6
|
+
sm: { padding: 8, gap: 10, iconBox: 32, fontSize: 0.875, descFontSize: 0.8125 },
|
|
7
|
+
xs: { padding: 6, gap: 8, iconBox: 28, fontSize: 0.8125, descFontSize: 0.75 },
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export function useItemVariantOutline(size: "default" | "sm" | "xs" = "default"): ItemStyles {
|
|
11
|
+
const s = sizeConfig[size];
|
|
12
|
+
|
|
13
|
+
return useThemedStyles(
|
|
14
|
+
({ colors, radius, fontFamily, fontSize }): ItemStyles => ({
|
|
15
|
+
root: {
|
|
16
|
+
default: {
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
padding: s.padding,
|
|
20
|
+
gap: s.gap,
|
|
21
|
+
borderWidth: 1,
|
|
22
|
+
borderColor: colors.border,
|
|
23
|
+
borderRadius: radius,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
media: {
|
|
27
|
+
default: {
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "center",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
mediaIcon: {
|
|
33
|
+
default: {
|
|
34
|
+
width: s.iconBox,
|
|
35
|
+
height: s.iconBox,
|
|
36
|
+
borderRadius: radius,
|
|
37
|
+
backgroundColor: colors.muted,
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
justifyContent: "center",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
content: {
|
|
43
|
+
default: {
|
|
44
|
+
flex: 1,
|
|
45
|
+
gap: 2,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
title: {
|
|
49
|
+
default: {
|
|
50
|
+
fontFamily,
|
|
51
|
+
fontSize: fontSize * s.fontSize,
|
|
52
|
+
lineHeight: Math.round(fontSize * s.fontSize * 1.3),
|
|
53
|
+
fontWeight: "500",
|
|
54
|
+
color: colors.foreground,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
description: {
|
|
58
|
+
default: {
|
|
59
|
+
fontFamily,
|
|
60
|
+
fontSize: fontSize * s.descFontSize,
|
|
61
|
+
lineHeight: Math.round(fontSize * s.descFontSize * 1.4),
|
|
62
|
+
color: colors.mutedForeground,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
actions: {
|
|
66
|
+
default: {
|
|
67
|
+
flexDirection: "row",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
gap: 8,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { ScrollBar } from "./components";
|
|
|
2
2
|
import { AsyncAlertDialogManager } from "./components/alert-dialog/async-alert-dialog";
|
|
3
3
|
import { PortalHost } from "./components/portal";
|
|
4
4
|
import { type PortalHostProps } from "./components/portal/portal.constants";
|
|
5
|
+
import { FullScreenSpinnerContainer } from "./components/full-screen-spinner/manager";
|
|
5
6
|
import { ToastContainer } from "./components/toast/manager";
|
|
6
7
|
import { useInitializeNavigationContainerRef } from "./hooks/use-is-react-navigation-modal";
|
|
7
8
|
import { SafeAreaProvider, type SafeAreaInsets } from "./safe-area";
|
|
@@ -31,6 +32,7 @@ export const UIProvider = ({
|
|
|
31
32
|
<ThemeProvider theme={theme} components={components}>
|
|
32
33
|
<ScrollBar />
|
|
33
34
|
<ToastContainer />
|
|
35
|
+
<FullScreenSpinnerContainer />
|
|
34
36
|
{children}
|
|
35
37
|
<PortalHost container={portalContainer} />
|
|
36
38
|
<AsyncAlertDialogManager />
|
package/src/themes/types.ts
CHANGED
|
@@ -49,10 +49,12 @@ import type { WeekCalendarStyles } from "../components/calendar/week-calendar/ty
|
|
|
49
49
|
import type { CardStyles } from "../components/card/types";
|
|
50
50
|
import type { CheckboxStyles } from "../components/checkbox/types";
|
|
51
51
|
import type { ComboboxStyles } from "../components/combobox/types";
|
|
52
|
+
import type { DescriptionListStyles } from "../components/description-list/types";
|
|
52
53
|
import type { EmptyStyles } from "../components/empty/types";
|
|
53
54
|
import type { FieldStyles } from "../components/field/types";
|
|
54
55
|
import type { IconButtonStyles } from "../components/icon-button/types";
|
|
55
56
|
import type { InputStyles } from "../components/input/types";
|
|
57
|
+
import type { ItemStyles } from "../components/item/types";
|
|
56
58
|
import type { LinkStyles } from "../components/link";
|
|
57
59
|
import type { MenuStyles } from "../components/menu/types";
|
|
58
60
|
import type { PhoneInputStyles } from "../components/phone-input/types";
|
|
@@ -104,6 +106,9 @@ export interface ComponentsConfig {
|
|
|
104
106
|
combobox?: {
|
|
105
107
|
styles?: ComboboxStyles;
|
|
106
108
|
};
|
|
109
|
+
descriptionList?: {
|
|
110
|
+
styles?: DescriptionListStyles;
|
|
111
|
+
};
|
|
107
112
|
empty?: {
|
|
108
113
|
styles?: EmptyStyles;
|
|
109
114
|
};
|
|
@@ -116,6 +121,9 @@ export interface ComponentsConfig {
|
|
|
116
121
|
input?: {
|
|
117
122
|
styles?: InputStyles;
|
|
118
123
|
};
|
|
124
|
+
item?: {
|
|
125
|
+
styles?: ItemStyles;
|
|
126
|
+
};
|
|
119
127
|
link?: {
|
|
120
128
|
styles?: LinkStyles;
|
|
121
129
|
};
|
package/src/utils/hsla-utils.ts
CHANGED
|
@@ -20,3 +20,14 @@ export const hslaSetRelativeLightness = (hsla: string, delta: number): string =>
|
|
|
20
20
|
if (newLightness < 0) newLightness = 0;
|
|
21
21
|
return hslaSetLightness(hsla, newLightness);
|
|
22
22
|
};
|
|
23
|
+
|
|
24
|
+
export const setHSLAOpacity = (hsla: string, opacity: number): string => {
|
|
25
|
+
const parts = hsla.replace(/^hsla?\(|\s+|\)$/g, "").split(",");
|
|
26
|
+
if (parts[0] === undefined) return hsla;
|
|
27
|
+
if (parts[1] === undefined) return hsla;
|
|
28
|
+
if (parts[2] === undefined) return hsla;
|
|
29
|
+
const h = parseInt(parts[0], 10);
|
|
30
|
+
const s = parseInt(parts[1], 10);
|
|
31
|
+
const l = parseInt(parts[2], 10);
|
|
32
|
+
return `hsla(${h}, ${s}%, ${l}%, ${opacity})`;
|
|
33
|
+
};
|