@korsolutions/ui 0.0.10 → 0.0.11

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.
@@ -1,5 +1,6 @@
1
- import { E as InputStyles, f as SelectStyles, k as FieldStyles, r as CardStyles, u as SelectRootBaseProps, w as InputPrimitiveBaseProps, x as ButtonStyles } from "../index-Dafk8ZGv.mjs";
1
+ import { E as InputStyles, f as SelectStyles, k as FieldStyles, r as CardStyles, u as SelectRootBaseProps, w as InputPrimitiveBaseProps, x as ButtonStyles } from "../index-Cq_-PiOm.mjs";
2
2
  import React from "react";
3
+ import { TextProps as TextProps$1, TextStyle } from "react-native";
3
4
 
4
5
  //#region src/components/button/variants/index.d.ts
5
6
  declare const ButtonVariants: {
@@ -33,11 +34,11 @@ interface CardProps {
33
34
  declare function Card(props: CardProps): React.JSX.Element;
34
35
  //#endregion
35
36
  //#region src/components/input/variants/default.d.ts
36
- declare function useInputVariantDefault(): InputStyles;
37
+ declare function useInputVariantDefault$1(): InputStyles;
37
38
  //#endregion
38
39
  //#region src/components/input/variants/index.d.ts
39
40
  declare const InputVariants: {
40
- default: typeof useInputVariantDefault;
41
+ default: typeof useInputVariantDefault$1;
41
42
  };
42
43
  //#endregion
43
44
  //#region src/components/input/input.d.ts
@@ -81,4 +82,33 @@ interface SelectProps<T> extends SelectRootBaseProps {
81
82
  }
82
83
  declare function Select<T>(props: SelectProps<T>): React.JSX.Element;
83
84
  //#endregion
84
- export { Button, Card, Field, FieldProps, Input, Select, SelectOption, SelectProps };
85
+ //#region src/components/text/variants/default.d.ts
86
+ declare function useInputVariantDefault(): TextStyle;
87
+ //#endregion
88
+ //#region src/components/text/variants/index.d.ts
89
+ declare const TextVariants: {
90
+ default: typeof useInputVariantDefault;
91
+ };
92
+ //#endregion
93
+ //#region src/components/text/text.d.ts
94
+ interface TextProps extends TextProps$1 {
95
+ variant?: keyof typeof TextVariants;
96
+ }
97
+ declare function Text(props: TextProps): React.JSX.Element;
98
+ //#endregion
99
+ //#region src/components/link/variants/default.d.ts
100
+ declare function useLinkVariantDefault(): TextStyle;
101
+ //#endregion
102
+ //#region src/components/link/variants/index.d.ts
103
+ declare const LinkVariants: {
104
+ default: typeof useLinkVariantDefault;
105
+ };
106
+ //#endregion
107
+ //#region src/components/link/link.d.ts
108
+ interface LinkProps extends TextProps$1 {
109
+ href?: string;
110
+ variant?: keyof typeof LinkVariants;
111
+ }
112
+ declare function Link(props: LinkProps): React.JSX.Element;
113
+ //#endregion
114
+ export { Button, Card, Field, FieldProps, Input, Link, LinkProps, Select, SelectOption, SelectProps, Text, TextProps };
@@ -1,7 +1,8 @@
1
- import { n as useTheme } from "../themes-BrLbh9h6.mjs";
1
+ import { n as useTheme } from "../themes-D5iq6sfL.mjs";
2
2
  import "../portal-DoPaAohb.mjs";
3
3
  import { a as FieldPrimitive, i as InputPrimitive, n as SelectPrimitive, r as ButtonPrimitive, t as CardPrimitive } from "../primitives-C2enZ5Ku.mjs";
4
4
  import React from "react";
5
+ import { Linking, Text as Text$1 } from "react-native";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
 
7
8
  //#region src/utils/use-themed-styles.ts
@@ -10,7 +11,8 @@ const useThemedStyles = (callback) => {
10
11
  return callback({
11
12
  colors: theme.colors,
12
13
  radius: theme.radius,
13
- fontFamily: theme.fontFamily
14
+ fontFamily: theme.fontFamily,
15
+ letterSpacing: theme.letterSpacing
14
16
  });
15
17
  };
16
18
 
@@ -110,7 +112,7 @@ function Card(props) {
110
112
 
111
113
  //#endregion
112
114
  //#region src/components/input/variants/default.tsx
113
- function useInputVariantDefault() {
115
+ function useInputVariantDefault$1() {
114
116
  return useThemedStyles(({ colors, radius, fontFamily }) => ({
115
117
  default: {
116
118
  placeholderTextColor: colors.mutedForeground,
@@ -138,12 +140,13 @@ function useInputVariantDefault() {
138
140
 
139
141
  //#endregion
140
142
  //#region src/components/input/variants/index.ts
141
- const InputVariants = { default: useInputVariantDefault };
143
+ const InputVariants = { default: useInputVariantDefault$1 };
142
144
 
143
145
  //#endregion
144
146
  //#region src/components/input/input.tsx
145
147
  function Input(props) {
146
- const variantStyles = (props.variant ? InputVariants[props.variant] : InputVariants["default"])();
148
+ const useVariantStyles = InputVariants[props.variant ?? "default"];
149
+ const variantStyles = useVariantStyles();
147
150
  return /* @__PURE__ */ jsx(InputPrimitive, {
148
151
  ...props,
149
152
  styles: variantStyles
@@ -287,4 +290,64 @@ function Select(props) {
287
290
  }
288
291
 
289
292
  //#endregion
290
- export { Button, Card, Field, Input, Select };
293
+ //#region src/components/text/variants/default.tsx
294
+ function useInputVariantDefault() {
295
+ return useThemedStyles(({ colors, fontFamily, letterSpacing }) => ({
296
+ color: colors.foreground,
297
+ fontSize: 16,
298
+ fontFamily,
299
+ letterSpacing
300
+ }));
301
+ }
302
+
303
+ //#endregion
304
+ //#region src/components/text/variants/index.ts
305
+ const TextVariants = { default: useInputVariantDefault };
306
+
307
+ //#endregion
308
+ //#region src/components/text/text.tsx
309
+ function Text(props) {
310
+ const useVariantStyles = TextVariants[props.variant ?? "default"];
311
+ const variantStyles = useVariantStyles();
312
+ return /* @__PURE__ */ jsx(Text$1, {
313
+ ...props,
314
+ style: variantStyles
315
+ });
316
+ }
317
+
318
+ //#endregion
319
+ //#region src/components/link/variants/default.tsx
320
+ function useLinkVariantDefault() {
321
+ return useThemedStyles(({ colors, fontFamily, letterSpacing }) => ({
322
+ color: colors.primary,
323
+ fontSize: 16,
324
+ fontFamily,
325
+ textDecorationLine: "underline",
326
+ letterSpacing
327
+ }));
328
+ }
329
+
330
+ //#endregion
331
+ //#region src/components/link/variants/index.ts
332
+ const LinkVariants = { default: useLinkVariantDefault };
333
+
334
+ //#endregion
335
+ //#region src/components/link/link.tsx
336
+ function Link(props) {
337
+ const useVariantStyles = LinkVariants[props.variant ?? "default"];
338
+ const variantStyles = useVariantStyles();
339
+ const handlePress = async (e) => {
340
+ if (props.href) {
341
+ if (await Linking.canOpenURL(props.href)) await Linking.openURL(props.href);
342
+ }
343
+ props.onPress?.(e);
344
+ };
345
+ return /* @__PURE__ */ jsx(Text$1, {
346
+ ...props,
347
+ style: variantStyles,
348
+ onPress: handlePress
349
+ });
350
+ }
351
+
352
+ //#endregion
353
+ export { Button, Card, Field, Input, Link, Select, Text };
@@ -1,4 +1,4 @@
1
- import * as react2 from "react";
1
+ import * as react3 from "react";
2
2
  import React$1 from "react";
3
3
  import { StyleProp, TextInputProps, TextProps, TextStyle, ViewStyle } from "react-native";
4
4
 
@@ -65,7 +65,7 @@ interface InputPrimitiveProps extends InputPrimitiveBaseProps {
65
65
  render?: (props: InputPrimitiveProps) => React.ReactNode;
66
66
  styles?: InputStyles;
67
67
  }
68
- declare function InputPrimitive(props: InputPrimitiveProps): react2.JSX.Element;
68
+ declare function InputPrimitive(props: InputPrimitiveProps): react3.JSX.Element;
69
69
  //#endregion
70
70
  //#region src/primitives/button/button-label.d.ts
71
71
  interface ButtonPrimitiveLabelProps {
@@ -152,7 +152,7 @@ interface SelectOptionProps {
152
152
  render?: (props: SelectOptionProps) => React.ReactElement;
153
153
  style?: StyleProp<TextStyle>;
154
154
  }
155
- declare function SelectOption(props: SelectOptionProps): react2.JSX.Element;
155
+ declare function SelectOption(props: SelectOptionProps): react3.JSX.Element;
156
156
  //#endregion
157
157
  //#region src/primitives/select/types.d.ts
158
158
  type SelectState = "default" | "disabled";
package/dist/index.d.mts CHANGED
@@ -21,13 +21,16 @@ interface Colors {
21
21
  info: Color;
22
22
  }
23
23
  type Radius = number;
24
+ type FontFamily = string;
25
+ type LetterSpacing = number;
24
26
  //#endregion
25
27
  //#region src/themes/provider.d.ts
26
28
  interface ThemeContext {
27
29
  colors: Colors;
28
30
  radius: Radius;
29
- fontFamily: string;
31
+ fontFamily: FontFamily;
30
32
  colorScheme: ColorScheme;
33
+ letterSpacing: LetterSpacing;
31
34
  setColorScheme: (scheme: ColorScheme) => void;
32
35
  setTheme: (themeName: ThemeName) => void;
33
36
  themeName: ThemeName;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as useTheme, t as ThemeProvider } from "./themes-BrLbh9h6.mjs";
1
+ import { n as useTheme, t as ThemeProvider } from "./themes-D5iq6sfL.mjs";
2
2
  import { n as PortalHost } from "./portal-DoPaAohb.mjs";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
@@ -1,2 +1,2 @@
1
- import { A as FieldErrorProps, C as InputPrimitive, D as FieldPrimitive, E as InputStyles, M as FieldLabelProps, O as FieldPrimitiveRootProps, S as ButtonPrimitiveLabelProps, T as InputPrimitiveProps, _ as SelectTriggerProps, a as CardBodyProps, b as ButtonState, c as SelectPrimitive, d as SelectRootProps, f as SelectStyles, g as SelectValueProps, h as SelectOverlayProps, i as CardFooterProps, j as FieldDescriptionProps, k as FieldStyles, l as SelectPortalProps, m as SelectContentProps, n as CardRootProps, o as CardTitleProps, p as SelectOptionProps, r as CardStyles, s as CardHeaderProps, t as CardPrimitive, u as SelectRootBaseProps, v as ButtonPrimitive, w as InputPrimitiveBaseProps, x as ButtonStyles, y as ButtonPrimitiveRootProps } from "../index-Dafk8ZGv.mjs";
1
+ import { A as FieldErrorProps, C as InputPrimitive, D as FieldPrimitive, E as InputStyles, M as FieldLabelProps, O as FieldPrimitiveRootProps, S as ButtonPrimitiveLabelProps, T as InputPrimitiveProps, _ as SelectTriggerProps, a as CardBodyProps, b as ButtonState, c as SelectPrimitive, d as SelectRootProps, f as SelectStyles, g as SelectValueProps, h as SelectOverlayProps, i as CardFooterProps, j as FieldDescriptionProps, k as FieldStyles, l as SelectPortalProps, m as SelectContentProps, n as CardRootProps, o as CardTitleProps, p as SelectOptionProps, r as CardStyles, s as CardHeaderProps, t as CardPrimitive, u as SelectRootBaseProps, v as ButtonPrimitive, w as InputPrimitiveBaseProps, x as ButtonStyles, y as ButtonPrimitiveRootProps } from "../index-Cq_-PiOm.mjs";
2
2
  export { ButtonPrimitive, ButtonPrimitiveLabelProps, ButtonPrimitiveRootProps, ButtonState, ButtonStyles, CardBodyProps, CardFooterProps, CardHeaderProps, CardPrimitive, CardRootProps, CardStyles, CardTitleProps, FieldDescriptionProps, FieldErrorProps, FieldLabelProps, FieldPrimitive, FieldPrimitiveRootProps, FieldStyles, InputPrimitive, InputPrimitiveBaseProps, InputPrimitiveProps, InputStyles, SelectContentProps, SelectOptionProps, SelectOverlayProps, SelectPortalProps, SelectPrimitive, SelectRootBaseProps, SelectRootProps, SelectStyles, SelectTriggerProps, SelectValueProps };
@@ -44,7 +44,8 @@ const defaultThemeAssets = {
44
44
  dark: darkColors
45
45
  },
46
46
  radius: 10,
47
- fontFamily: "System"
47
+ fontFamily: "System",
48
+ letterSpacing: 0
48
49
  };
49
50
 
50
51
  //#endregion
@@ -71,7 +72,8 @@ const ThemeProvider = (props) => {
71
72
  setColorScheme,
72
73
  colors,
73
74
  radius: themesAssets.radius,
74
- fontFamily: themesAssets.fontFamily
75
+ fontFamily: themesAssets.fontFamily,
76
+ letterSpacing: themesAssets.letterSpacing
75
77
  },
76
78
  children: props.children
77
79
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korsolutions/ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -3,3 +3,5 @@ export * from "./card/card";
3
3
  export * from "./input/input";
4
4
  export * from "./field/field";
5
5
  export * from "./select/select";
6
+ export * from "./text/text";
7
+ export * from "./link/link";
@@ -7,7 +7,7 @@ interface InputProps extends InputPrimitiveBaseProps {
7
7
  }
8
8
 
9
9
  export function Input(props: InputProps) {
10
- const useVariantStyles = props.variant ? InputVariants[props.variant] : InputVariants["default"];
10
+ const useVariantStyles = InputVariants[props.variant ?? "default"];
11
11
  const variantStyles = useVariantStyles();
12
12
 
13
13
  return <InputPrimitive {...props} styles={variantStyles} />;
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { Text as RnText, TextProps as RnTextProps, Linking } from "react-native";
3
+ import { LinkVariants } from "./variants";
4
+
5
+ export interface LinkProps extends RnTextProps {
6
+ href?: string;
7
+
8
+ variant?: keyof typeof LinkVariants;
9
+ }
10
+
11
+ export function Link(props: LinkProps) {
12
+ const useVariantStyles = LinkVariants[props.variant ?? "default"];
13
+ const variantStyles = useVariantStyles();
14
+
15
+ const handlePress: RnTextProps["onPress"] = async (e) => {
16
+ if (props.href) {
17
+ const supported = await Linking.canOpenURL(props.href);
18
+ if (supported) {
19
+ await Linking.openURL(props.href);
20
+ }
21
+ }
22
+ props.onPress?.(e);
23
+ };
24
+
25
+ return <RnText {...props} style={variantStyles} onPress={handlePress} />;
26
+ }
@@ -0,0 +1,14 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useLinkVariantDefault(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing }): TextStyle => ({
7
+ color: colors.primary,
8
+ fontSize: 16,
9
+ fontFamily,
10
+ textDecorationLine: "underline",
11
+ letterSpacing,
12
+ })
13
+ );
14
+ }
@@ -0,0 +1,5 @@
1
+ import { useLinkVariantDefault } from "./default";
2
+
3
+ export const LinkVariants = {
4
+ default: useLinkVariantDefault,
5
+ };
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { Text as RnText, TextProps as RnTextProps } from "react-native";
3
+ import { TextVariants } from "./variants";
4
+
5
+ export interface TextProps extends RnTextProps {
6
+ variant?: keyof typeof TextVariants;
7
+ }
8
+
9
+ export function Text(props: TextProps) {
10
+ const useVariantStyles = TextVariants[props.variant ?? "default"];
11
+ const variantStyles = useVariantStyles();
12
+ return <RnText {...props} style={variantStyles} />;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useInputVariantDefault(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize: 16,
9
+ fontFamily,
10
+ letterSpacing,
11
+ })
12
+ );
13
+ }
@@ -0,0 +1,5 @@
1
+ import { useInputVariantDefault } from "./default";
2
+
3
+ export const TextVariants = {
4
+ default: useInputVariantDefault,
5
+ };
@@ -8,4 +8,5 @@ export const defaultThemeAssets: ThemeAssets = {
8
8
  },
9
9
  radius: 10,
10
10
  fontFamily: "System",
11
+ letterSpacing: 0,
11
12
  };
@@ -1,13 +1,14 @@
1
1
  import { createContext, PropsWithChildren, useContext, useEffect, useState } from "react";
2
- import { Colors, ColorScheme, Radius, ThemeName } from "./types";
2
+ import { Colors, ColorScheme, FontFamily, LetterSpacing, Radius, ThemeName } from "./types";
3
3
  import { themes } from "./themes";
4
4
  import { useColorScheme } from "react-native";
5
5
 
6
6
  interface ThemeContext {
7
7
  colors: Colors;
8
8
  radius: Radius;
9
- fontFamily: string;
9
+ fontFamily: FontFamily;
10
10
  colorScheme: ColorScheme;
11
+ letterSpacing: LetterSpacing;
11
12
  setColorScheme: (scheme: ColorScheme) => void;
12
13
  setTheme: (themeName: ThemeName) => void;
13
14
  themeName: ThemeName;
@@ -40,6 +41,7 @@ export const ThemeProvider = (props: PropsWithChildren) => {
40
41
  colors,
41
42
  radius: themesAssets.radius,
42
43
  fontFamily: themesAssets.fontFamily,
44
+ letterSpacing: themesAssets.letterSpacing,
43
45
  }}
44
46
  >
45
47
  {props.children}
@@ -22,9 +22,11 @@ export interface Colors {
22
22
 
23
23
  export type Radius = number;
24
24
  export type FontFamily = string;
25
+ export type LetterSpacing = number;
25
26
 
26
27
  export interface ThemeAssets {
27
28
  colors: Record<ColorScheme, Colors>;
28
29
  radius: Radius;
29
30
  fontFamily: FontFamily;
31
+ letterSpacing: LetterSpacing;
30
32
  }
@@ -1,13 +1,19 @@
1
1
  import { useTheme } from "@/themes";
2
- import { Colors, FontFamily, Radius } from "@/themes/types";
2
+ import { Colors, FontFamily, LetterSpacing, Radius } from "@/themes/types";
3
3
 
4
4
  interface CallbackProps {
5
5
  colors: Colors;
6
6
  radius: Radius;
7
7
  fontFamily: FontFamily;
8
+ letterSpacing: LetterSpacing;
8
9
  }
9
10
 
10
11
  export const useThemedStyles = <T>(callback: (props: CallbackProps) => T): T => {
11
12
  const theme = useTheme();
12
- return callback({ colors: theme.colors, radius: theme.radius, fontFamily: theme.fontFamily });
13
+ return callback({
14
+ colors: theme.colors,
15
+ radius: theme.radius,
16
+ fontFamily: theme.fontFamily,
17
+ letterSpacing: theme.letterSpacing,
18
+ });
13
19
  };