@korsolutions/ui 0.0.11 → 0.0.13
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 +2 -0
- package/dist/components/index.d.mts +70 -15
- package/dist/components/index.mjs +269 -38
- package/dist/{index-Cq_-PiOm.d.mts → index-_E4x_kNB.d.mts} +95 -6
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +1 -1
- package/dist/primitives/index.d.mts +2 -2
- package/dist/primitives/index.mjs +2 -2
- package/dist/{primitives-C2enZ5Ku.mjs → primitives-DQMWXbuX.mjs} +121 -4
- package/dist/{themes-D5iq6sfL.mjs → themes-DXcjBdO2.mjs} +4 -2
- package/package.json +7 -4
- package/src/components/avatar/avatar.tsx +23 -0
- package/src/components/avatar/variants/default.tsx +30 -0
- package/src/components/avatar/variants/index.ts +5 -0
- package/src/components/button/variants/default.tsx +9 -3
- package/src/components/button/variants/index.ts +2 -0
- package/src/components/button/variants/secondary.tsx +58 -0
- package/src/components/card/variants/default.tsx +2 -2
- package/src/components/empty/empty.tsx +26 -0
- package/src/components/empty/variants/default.tsx +35 -0
- package/src/components/empty/variants/index.ts +5 -0
- package/src/components/field/variants/default.tsx +4 -4
- package/src/components/index.ts +3 -1
- package/src/components/input/variants/default.tsx +2 -1
- package/src/components/link/variants/default.tsx +2 -2
- package/src/components/select/variants/default.tsx +4 -4
- package/src/components/typography/typography.tsx +13 -0
- package/src/components/typography/variants/body-lg.tsx +13 -0
- package/src/components/{text/variants/default.tsx → typography/variants/body-md.tsx} +3 -3
- package/src/components/typography/variants/body-sm.tsx +13 -0
- package/src/components/typography/variants/heading-lg.tsx +14 -0
- package/src/components/typography/variants/heading-md.tsx +14 -0
- package/src/components/typography/variants/heading-sm.tsx +14 -0
- package/src/components/typography/variants/index.ts +15 -0
- package/src/primitives/avatar/avatar-fallback.tsx +16 -0
- package/src/primitives/avatar/avatar-image.tsx +17 -0
- package/src/primitives/avatar/avatar-root.tsx +21 -0
- package/src/primitives/avatar/context.ts +16 -0
- package/src/primitives/avatar/index.ts +14 -0
- package/src/primitives/avatar/types.ts +9 -0
- package/src/primitives/button/button-root.tsx +9 -4
- package/src/primitives/button/types.ts +1 -1
- package/src/primitives/empty/context.ts +16 -0
- package/src/primitives/empty/empty-description.tsx +16 -0
- package/src/primitives/empty/empty-media.tsx +16 -0
- package/src/primitives/empty/empty-root.tsx +21 -0
- package/src/primitives/empty/empty-title.tsx +16 -0
- package/src/primitives/empty/index.ts +17 -0
- package/src/primitives/empty/types.ts +11 -0
- package/src/primitives/index.ts +2 -0
- package/src/themes/default/index.ts +1 -0
- package/src/themes/provider.tsx +3 -1
- package/src/themes/types.ts +2 -0
- package/src/utils/hsla-utils.ts +26 -0
- package/src/utils/use-themed-styles.ts +3 -1
- package/tsconfig.json +1 -0
- package/src/components/text/text.tsx +0 -13
- package/src/components/text/variants/index.ts +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react0 from "react";
|
|
2
2
|
import React$1 from "react";
|
|
3
|
-
import { StyleProp, TextInputProps, TextProps, TextStyle, ViewStyle } from "react-native";
|
|
3
|
+
import { ImageSource, ImageStyle, StyleProp, TextInputProps, TextProps, TextStyle, ViewStyle } from "react-native";
|
|
4
4
|
|
|
5
5
|
//#region src/primitives/field/field-label.d.ts
|
|
6
6
|
interface FieldLabelProps {
|
|
@@ -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):
|
|
68
|
+
declare function InputPrimitive(props: InputPrimitiveProps): react0.JSX.Element;
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/primitives/button/button-label.d.ts
|
|
71
71
|
interface ButtonPrimitiveLabelProps {
|
|
@@ -76,7 +76,7 @@ interface ButtonPrimitiveLabelProps {
|
|
|
76
76
|
declare function ButtonLabel(props: ButtonPrimitiveLabelProps): React$1.JSX.Element;
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/primitives/button/types.d.ts
|
|
79
|
-
type ButtonState = "default" | "disabled" | "loading";
|
|
79
|
+
type ButtonState = "default" | "disabled" | "loading" | "hovered";
|
|
80
80
|
interface ButtonStyles {
|
|
81
81
|
root?: Partial<Record<ButtonState, ButtonPrimitiveRootProps["style"]>>;
|
|
82
82
|
label?: Partial<Record<ButtonState, ButtonPrimitiveLabelProps["style"]>>;
|
|
@@ -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):
|
|
155
|
+
declare function SelectOption(props: SelectOptionProps): react0.JSX.Element;
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/primitives/select/types.d.ts
|
|
158
158
|
type SelectState = "default" | "disabled";
|
|
@@ -262,4 +262,93 @@ declare const CardPrimitive: {
|
|
|
262
262
|
Footer: typeof CardFooter;
|
|
263
263
|
};
|
|
264
264
|
//#endregion
|
|
265
|
-
|
|
265
|
+
//#region src/primitives/empty/empty-description.d.ts
|
|
266
|
+
interface EmptyDescriptionProps {
|
|
267
|
+
children: string;
|
|
268
|
+
render?: (props: EmptyDescriptionProps) => React$1.ReactNode;
|
|
269
|
+
style?: StyleProp<TextStyle>;
|
|
270
|
+
}
|
|
271
|
+
declare function EmptyDescription(props: EmptyDescriptionProps): React$1.JSX.Element;
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/primitives/empty/empty-media.d.ts
|
|
274
|
+
interface EmptyMediaProps {
|
|
275
|
+
children: React$1.ReactNode;
|
|
276
|
+
render?: (props: EmptyMediaProps) => React$1.ReactNode;
|
|
277
|
+
style?: StyleProp<ViewStyle>;
|
|
278
|
+
}
|
|
279
|
+
declare function EmptyMedia(props: EmptyMediaProps): React$1.JSX.Element;
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/primitives/empty/empty-title.d.ts
|
|
282
|
+
interface EmptyTitleProps {
|
|
283
|
+
children: string;
|
|
284
|
+
render?: (props: EmptyTitleProps) => React$1.ReactNode;
|
|
285
|
+
style?: StyleProp<TextStyle>;
|
|
286
|
+
}
|
|
287
|
+
declare function EmptyTitle(props: EmptyTitleProps): React$1.JSX.Element;
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/primitives/empty/types.d.ts
|
|
290
|
+
type EmptyStyles = {
|
|
291
|
+
root?: EmptyRootProps["style"];
|
|
292
|
+
media?: EmptyMediaProps["style"];
|
|
293
|
+
title?: EmptyTitleProps["style"];
|
|
294
|
+
description?: EmptyDescriptionProps["style"];
|
|
295
|
+
};
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/primitives/empty/empty-root.d.ts
|
|
298
|
+
interface EmptyRootProps {
|
|
299
|
+
children: React$1.ReactNode;
|
|
300
|
+
render?: (props: EmptyRootProps) => React$1.ReactNode;
|
|
301
|
+
style?: StyleProp<ViewStyle>;
|
|
302
|
+
styles?: EmptyStyles;
|
|
303
|
+
}
|
|
304
|
+
declare function EmptyRoot(props: EmptyRootProps): React$1.JSX.Element;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/primitives/empty/index.d.ts
|
|
307
|
+
declare const EmptyPrimitive: {
|
|
308
|
+
Root: typeof EmptyRoot;
|
|
309
|
+
Media: typeof EmptyMedia;
|
|
310
|
+
Title: typeof EmptyTitle;
|
|
311
|
+
Description: typeof EmptyDescription;
|
|
312
|
+
};
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/primitives/avatar/avatar-fallback.d.ts
|
|
315
|
+
interface AvatarFallbackProps {
|
|
316
|
+
children: string;
|
|
317
|
+
render?: (props: AvatarFallbackProps) => React$1.ReactNode;
|
|
318
|
+
style?: StyleProp<TextStyle>;
|
|
319
|
+
}
|
|
320
|
+
declare function AvatarFallback(props: AvatarFallbackProps): React$1.JSX.Element;
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/primitives/avatar/avatar-image.d.ts
|
|
323
|
+
interface AvatarImageProps {
|
|
324
|
+
source: ImageSource;
|
|
325
|
+
onError: () => void;
|
|
326
|
+
render?: (props: AvatarImageProps) => React$1.ReactNode;
|
|
327
|
+
style?: StyleProp<ImageStyle>;
|
|
328
|
+
}
|
|
329
|
+
declare function AvatarImage(props: AvatarImageProps): React$1.JSX.Element;
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/primitives/avatar/types.d.ts
|
|
332
|
+
type AvatarStyles = {
|
|
333
|
+
root?: AvatarRootProps["style"];
|
|
334
|
+
image?: AvatarImageProps["style"];
|
|
335
|
+
fallback?: AvatarFallbackProps["style"];
|
|
336
|
+
};
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/primitives/avatar/avatar-root.d.ts
|
|
339
|
+
interface AvatarRootProps {
|
|
340
|
+
children: React$1.ReactNode;
|
|
341
|
+
render?: (props: AvatarRootProps) => React$1.ReactNode;
|
|
342
|
+
style?: StyleProp<ViewStyle>;
|
|
343
|
+
styles?: AvatarStyles;
|
|
344
|
+
}
|
|
345
|
+
declare function AvatarRoot(props: AvatarRootProps): React$1.JSX.Element;
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/primitives/avatar/index.d.ts
|
|
348
|
+
declare const AvatarPrimitive: {
|
|
349
|
+
Root: typeof AvatarRoot;
|
|
350
|
+
Image: typeof AvatarImage;
|
|
351
|
+
Fallback: typeof AvatarFallback;
|
|
352
|
+
};
|
|
353
|
+
//#endregion
|
|
354
|
+
export { ButtonPrimitiveRootProps as A, FieldStyles as B, SelectStyles as C, SelectValueProps as D, SelectOverlayProps as E, InputPrimitiveBaseProps as F, FieldDescriptionProps as H, InputPrimitiveProps as I, InputStyles as L, ButtonStyles as M, ButtonPrimitiveLabelProps as N, SelectTriggerProps as O, InputPrimitive as P, FieldPrimitive as R, SelectRootProps as S, SelectContentProps as T, FieldLabelProps as U, FieldErrorProps as V, CardTitleProps as _, AvatarFallbackProps as a, SelectPortalProps as b, EmptyStyles as c, EmptyDescriptionProps as d, CardPrimitive as f, CardBodyProps as g, CardFooterProps as h, AvatarImageProps as i, ButtonState as j, ButtonPrimitive as k, EmptyTitleProps as l, CardStyles as m, AvatarRootProps as n, EmptyPrimitive as o, CardRootProps as p, AvatarStyles as r, EmptyRootProps as s, AvatarPrimitive as t, EmptyMediaProps as u, CardHeaderProps as v, SelectOptionProps as w, SelectRootBaseProps as x, SelectPrimitive as y, FieldPrimitiveRootProps as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react2 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/themes/types.d.ts
|
|
4
4
|
type ThemeName = "default";
|
|
@@ -23,6 +23,7 @@ interface Colors {
|
|
|
23
23
|
type Radius = number;
|
|
24
24
|
type FontFamily = string;
|
|
25
25
|
type LetterSpacing = number;
|
|
26
|
+
type FontSize = number;
|
|
26
27
|
//#endregion
|
|
27
28
|
//#region src/themes/provider.d.ts
|
|
28
29
|
interface ThemeContext {
|
|
@@ -31,11 +32,12 @@ interface ThemeContext {
|
|
|
31
32
|
fontFamily: FontFamily;
|
|
32
33
|
colorScheme: ColorScheme;
|
|
33
34
|
letterSpacing: LetterSpacing;
|
|
35
|
+
fontSize: FontSize;
|
|
34
36
|
setColorScheme: (scheme: ColorScheme) => void;
|
|
35
37
|
setTheme: (themeName: ThemeName) => void;
|
|
36
38
|
themeName: ThemeName;
|
|
37
39
|
}
|
|
38
|
-
declare const ThemeContext:
|
|
40
|
+
declare const ThemeContext: react2.Context<ThemeContext | null>;
|
|
39
41
|
declare const useTheme: () => ThemeContext;
|
|
40
42
|
//#endregion
|
|
41
43
|
//#region src/index.d.ts
|
|
@@ -43,6 +45,6 @@ declare const UniversalUIProvider: ({
|
|
|
43
45
|
children
|
|
44
46
|
}: {
|
|
45
47
|
children: React.ReactNode;
|
|
46
|
-
}) =>
|
|
48
|
+
}) => react2.JSX.Element;
|
|
47
49
|
//#endregion
|
|
48
50
|
export { UniversalUIProvider, useTheme };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
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 };
|
|
1
|
+
import { A as ButtonPrimitiveRootProps, B as FieldStyles, C as SelectStyles, D as SelectValueProps, E as SelectOverlayProps, F as InputPrimitiveBaseProps, H as FieldDescriptionProps, I as InputPrimitiveProps, L as InputStyles, M as ButtonStyles, N as ButtonPrimitiveLabelProps, O as SelectTriggerProps, P as InputPrimitive, R as FieldPrimitive, S as SelectRootProps, T as SelectContentProps, U as FieldLabelProps, V as FieldErrorProps, _ as CardTitleProps, a as AvatarFallbackProps, b as SelectPortalProps, c as EmptyStyles, d as EmptyDescriptionProps, f as CardPrimitive, g as CardBodyProps, h as CardFooterProps, i as AvatarImageProps, j as ButtonState, k as ButtonPrimitive, l as EmptyTitleProps, m as CardStyles, n as AvatarRootProps, o as EmptyPrimitive, p as CardRootProps, r as AvatarStyles, s as EmptyRootProps, t as AvatarPrimitive, u as EmptyMediaProps, v as CardHeaderProps, w as SelectOptionProps, x as SelectRootBaseProps, y as SelectPrimitive, z as FieldPrimitiveRootProps } from "../index-_E4x_kNB.mjs";
|
|
2
|
+
export { AvatarFallbackProps, AvatarImageProps, AvatarPrimitive, AvatarRootProps, AvatarStyles, ButtonPrimitive, ButtonPrimitiveLabelProps, ButtonPrimitiveRootProps, ButtonState, ButtonStyles, CardBodyProps, CardFooterProps, CardHeaderProps, CardPrimitive, CardRootProps, CardStyles, CardTitleProps, EmptyDescriptionProps, EmptyMediaProps, EmptyPrimitive, EmptyRootProps, EmptyStyles, EmptyTitleProps, FieldDescriptionProps, FieldErrorProps, FieldLabelProps, FieldPrimitive, FieldPrimitiveRootProps, FieldStyles, InputPrimitive, InputPrimitiveBaseProps, InputPrimitiveProps, InputStyles, SelectContentProps, SelectOptionProps, SelectOverlayProps, SelectPortalProps, SelectPrimitive, SelectRootBaseProps, SelectRootProps, SelectStyles, SelectTriggerProps, SelectValueProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../portal-DoPaAohb.mjs";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as ButtonPrimitive, i as SelectPrimitive, n as EmptyPrimitive, o as InputPrimitive, r as CardPrimitive, s as FieldPrimitive, t as AvatarPrimitive } from "../primitives-DQMWXbuX.mjs";
|
|
3
3
|
|
|
4
|
-
export { ButtonPrimitive, CardPrimitive, FieldPrimitive, InputPrimitive, SelectPrimitive };
|
|
4
|
+
export { AvatarPrimitive, ButtonPrimitive, CardPrimitive, EmptyPrimitive, FieldPrimitive, InputPrimitive, SelectPrimitive };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as Portal } from "./portal-DoPaAohb.mjs";
|
|
2
2
|
import React, { createContext, useContext, useEffect, useState } from "react";
|
|
3
|
-
import { ActivityIndicator, Pressable, StyleSheet, Text, TextInput, View } from "react-native";
|
|
3
|
+
import { ActivityIndicator, Image, Pressable, StyleSheet, Text, TextInput, View } from "react-native";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/primitives/field/context.ts
|
|
@@ -113,13 +113,15 @@ const useButtonPrimitive = () => {
|
|
|
113
113
|
|
|
114
114
|
//#endregion
|
|
115
115
|
//#region src/primitives/button/button-root.tsx
|
|
116
|
-
const calculateState$2 = (props) => {
|
|
116
|
+
const calculateState$2 = (props, isHovered) => {
|
|
117
117
|
if (props.isDisabled) return "disabled";
|
|
118
118
|
if (props.isLoading) return "loading";
|
|
119
|
+
if (isHovered) return "hovered";
|
|
119
120
|
return "default";
|
|
120
121
|
};
|
|
121
122
|
function ButtonRoot(props) {
|
|
122
|
-
const
|
|
123
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
124
|
+
const state = calculateState$2(props, isHovered);
|
|
123
125
|
const calculatedStyle = [
|
|
124
126
|
props.styles?.root?.default,
|
|
125
127
|
props.styles?.root?.[state],
|
|
@@ -134,6 +136,8 @@ function ButtonRoot(props) {
|
|
|
134
136
|
},
|
|
135
137
|
children: /* @__PURE__ */ jsx(Container, {
|
|
136
138
|
...props,
|
|
139
|
+
onHoverIn: () => setIsHovered(true),
|
|
140
|
+
onHoverOut: () => setIsHovered(false),
|
|
137
141
|
style: calculatedStyle
|
|
138
142
|
})
|
|
139
143
|
});
|
|
@@ -438,4 +442,117 @@ const CardPrimitive = {
|
|
|
438
442
|
};
|
|
439
443
|
|
|
440
444
|
//#endregion
|
|
441
|
-
|
|
445
|
+
//#region src/primitives/empty/context.ts
|
|
446
|
+
const EmptyContext = createContext({});
|
|
447
|
+
const useEmpty = () => {
|
|
448
|
+
const context = useContext(EmptyContext);
|
|
449
|
+
if (!context) throw new Error("useEmptyContext must be used within a EmptyProvider");
|
|
450
|
+
return context;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/primitives/empty/empty-root.tsx
|
|
455
|
+
function EmptyRoot(props) {
|
|
456
|
+
const composedStyles = [props.styles?.root, props.style];
|
|
457
|
+
const Component = props.render ?? View;
|
|
458
|
+
return /* @__PURE__ */ jsx(EmptyContext.Provider, {
|
|
459
|
+
value: { styles: props.styles },
|
|
460
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
461
|
+
...props,
|
|
462
|
+
style: composedStyles
|
|
463
|
+
})
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/primitives/empty/empty-media.tsx
|
|
469
|
+
function EmptyMedia(props) {
|
|
470
|
+
const composedStyles = [useEmpty().styles?.media, props.style];
|
|
471
|
+
return /* @__PURE__ */ jsx(props.render ?? View, {
|
|
472
|
+
...props,
|
|
473
|
+
style: composedStyles
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/primitives/empty/empty-title.tsx
|
|
479
|
+
function EmptyTitle(props) {
|
|
480
|
+
const composedStyles = [useEmpty().styles?.title, props.style];
|
|
481
|
+
return /* @__PURE__ */ jsx(props.render ?? Text, {
|
|
482
|
+
...props,
|
|
483
|
+
style: composedStyles
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/primitives/empty/empty-description.tsx
|
|
489
|
+
function EmptyDescription(props) {
|
|
490
|
+
const composedStyles = [useEmpty().styles?.description, props.style];
|
|
491
|
+
return /* @__PURE__ */ jsx(props.render ?? Text, {
|
|
492
|
+
...props,
|
|
493
|
+
style: composedStyles
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/primitives/empty/index.ts
|
|
499
|
+
const EmptyPrimitive = {
|
|
500
|
+
Root: EmptyRoot,
|
|
501
|
+
Media: EmptyMedia,
|
|
502
|
+
Title: EmptyTitle,
|
|
503
|
+
Description: EmptyDescription
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/primitives/avatar/context.ts
|
|
508
|
+
const AvatarContext = createContext(void 0);
|
|
509
|
+
const useAvatar = () => {
|
|
510
|
+
const context = useContext(AvatarContext);
|
|
511
|
+
if (!context) throw new Error("useAvatarContext must be used within a AvatarProvider");
|
|
512
|
+
return context;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/primitives/avatar/avatar-root.tsx
|
|
517
|
+
function AvatarRoot(props) {
|
|
518
|
+
const composedStyles = [props.styles?.root, props.style];
|
|
519
|
+
const Component = props.render ?? View;
|
|
520
|
+
return /* @__PURE__ */ jsx(AvatarContext.Provider, {
|
|
521
|
+
value: { styles: props.styles },
|
|
522
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
523
|
+
...props,
|
|
524
|
+
style: composedStyles
|
|
525
|
+
})
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/primitives/avatar/avatar-fallback.tsx
|
|
531
|
+
function AvatarFallback(props) {
|
|
532
|
+
const composedStyles = [useAvatar().styles?.fallback, props.style];
|
|
533
|
+
return /* @__PURE__ */ jsx(props.render ?? View, {
|
|
534
|
+
...props,
|
|
535
|
+
style: composedStyles
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/primitives/avatar/avatar-image.tsx
|
|
541
|
+
function AvatarImage(props) {
|
|
542
|
+
const composedStyles = [useAvatar().styles?.image, props.style];
|
|
543
|
+
return /* @__PURE__ */ jsx(props.render ?? Image, {
|
|
544
|
+
...props,
|
|
545
|
+
style: composedStyles
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/primitives/avatar/index.ts
|
|
551
|
+
const AvatarPrimitive = {
|
|
552
|
+
Root: AvatarRoot,
|
|
553
|
+
Image: AvatarImage,
|
|
554
|
+
Fallback: AvatarFallback
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
//#endregion
|
|
558
|
+
export { ButtonPrimitive as a, SelectPrimitive as i, EmptyPrimitive as n, InputPrimitive as o, CardPrimitive as r, FieldPrimitive as s, AvatarPrimitive as t };
|
|
@@ -45,7 +45,8 @@ const defaultThemeAssets = {
|
|
|
45
45
|
},
|
|
46
46
|
radius: 10,
|
|
47
47
|
fontFamily: "System",
|
|
48
|
-
letterSpacing: 0
|
|
48
|
+
letterSpacing: 0,
|
|
49
|
+
fontSize: 16
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
//#endregion
|
|
@@ -73,7 +74,8 @@ const ThemeProvider = (props) => {
|
|
|
73
74
|
colors,
|
|
74
75
|
radius: themesAssets.radius,
|
|
75
76
|
fontFamily: themesAssets.fontFamily,
|
|
76
|
-
letterSpacing: themesAssets.letterSpacing
|
|
77
|
+
letterSpacing: themesAssets.letterSpacing,
|
|
78
|
+
fontSize: themesAssets.fontSize
|
|
77
79
|
},
|
|
78
80
|
children: props.children
|
|
79
81
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korsolutions/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -8,15 +8,18 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"default": "./dist/index.mjs",
|
|
11
|
-
"types": "./dist/index.d.mts"
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"dev-source": "./src/index.ts"
|
|
12
13
|
},
|
|
13
14
|
"./primitives": {
|
|
14
15
|
"default": "./dist/primitives/index.mjs",
|
|
15
|
-
"types": "./dist/primitives/index.d.mts"
|
|
16
|
+
"types": "./dist/primitives/index.d.mts",
|
|
17
|
+
"dev-source": "./src/primitives/index.ts"
|
|
16
18
|
},
|
|
17
19
|
"./components": {
|
|
18
20
|
"default": "./dist/components/index.mjs",
|
|
19
|
-
"types": "./dist/components/index.d.mts"
|
|
21
|
+
"types": "./dist/components/index.d.mts",
|
|
22
|
+
"dev-source": "./src/components/index.ts"
|
|
20
23
|
}
|
|
21
24
|
},
|
|
22
25
|
"scripts": {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AvatarPrimitive } from "@/primitives";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { ImageSource } from "react-native";
|
|
4
|
+
import { AvatarVariants } from "./variants";
|
|
5
|
+
|
|
6
|
+
export interface AvatarProps {
|
|
7
|
+
source?: ImageSource;
|
|
8
|
+
fallback: string;
|
|
9
|
+
|
|
10
|
+
variant?: keyof typeof AvatarVariants;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function Avatar(props: AvatarProps) {
|
|
14
|
+
const useVariantStyles = AvatarVariants[props.variant || "default"];
|
|
15
|
+
const styles = useVariantStyles();
|
|
16
|
+
const [imageError, setImageError] = useState(false);
|
|
17
|
+
return (
|
|
18
|
+
<AvatarPrimitive.Root styles={styles}>
|
|
19
|
+
{props.source && <AvatarPrimitive.Image source={props.source} onError={() => setImageError(true)} />}
|
|
20
|
+
{(!props.source || imageError) && <AvatarPrimitive.Fallback>{props.fallback}</AvatarPrimitive.Fallback>}
|
|
21
|
+
</AvatarPrimitive.Root>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AvatarStyles } from "@/primitives";
|
|
2
|
+
import { useThemedStyles } from "@/utils/use-themed-styles";
|
|
3
|
+
|
|
4
|
+
export function useAvatarVariantDefault(): AvatarStyles {
|
|
5
|
+
return useThemedStyles(
|
|
6
|
+
({ colors, fontFamily, fontSize }): AvatarStyles => ({
|
|
7
|
+
root: {
|
|
8
|
+
backgroundColor: colors.surface,
|
|
9
|
+
borderRadius: "50%",
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
width: 64,
|
|
12
|
+
height: 64,
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
},
|
|
16
|
+
image: {
|
|
17
|
+
width: "100%",
|
|
18
|
+
height: "100%",
|
|
19
|
+
resizeMode: "cover",
|
|
20
|
+
},
|
|
21
|
+
fallback: {
|
|
22
|
+
fontFamily,
|
|
23
|
+
fontSize,
|
|
24
|
+
color: colors.foreground,
|
|
25
|
+
textAlign: "center",
|
|
26
|
+
verticalAlign: "middle",
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ButtonStyles } from "@/primitives";
|
|
2
|
+
import { hslaSetRelativeLightness } from "@/utils/hsla-utils";
|
|
2
3
|
import { useThemedStyles } from "@/utils/use-themed-styles";
|
|
3
4
|
|
|
4
5
|
export const useButtonVariantDefault = (): ButtonStyles => {
|
|
5
6
|
return useThemedStyles(
|
|
6
|
-
({ colors, radius, fontFamily }): ButtonStyles => ({
|
|
7
|
+
({ colors, radius, fontFamily, fontSize }): ButtonStyles => ({
|
|
7
8
|
root: {
|
|
8
9
|
default: {
|
|
9
10
|
flexDirection: "row",
|
|
10
|
-
backgroundColor: colors.primary,
|
|
11
11
|
paddingVertical: 12,
|
|
12
12
|
paddingHorizontal: 16,
|
|
13
13
|
borderRadius: radius,
|
|
14
14
|
gap: 8,
|
|
15
15
|
alignItems: "center",
|
|
16
16
|
justifyContent: "center",
|
|
17
|
+
backgroundColor: colors.primary,
|
|
18
|
+
borderWidth: 1,
|
|
19
|
+
borderColor: colors.border,
|
|
17
20
|
},
|
|
18
21
|
disabled: {
|
|
19
22
|
opacity: 0.5,
|
|
@@ -21,11 +24,14 @@ export const useButtonVariantDefault = (): ButtonStyles => {
|
|
|
21
24
|
loading: {
|
|
22
25
|
opacity: 0.8,
|
|
23
26
|
},
|
|
27
|
+
hovered: {
|
|
28
|
+
backgroundColor: hslaSetRelativeLightness(colors.primary, -10),
|
|
29
|
+
},
|
|
24
30
|
},
|
|
25
31
|
label: {
|
|
26
32
|
default: {
|
|
27
33
|
color: colors.primaryForeground,
|
|
28
|
-
fontSize
|
|
34
|
+
fontSize,
|
|
29
35
|
fontWeight: "bold",
|
|
30
36
|
fontFamily,
|
|
31
37
|
},
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ButtonStyles } from "@/primitives";
|
|
2
|
+
import { hslaSetRelativeLightness } from "@/utils/hsla-utils";
|
|
3
|
+
import { useThemedStyles } from "@/utils/use-themed-styles";
|
|
4
|
+
|
|
5
|
+
export const useButtonVariantSecondary = (): ButtonStyles => {
|
|
6
|
+
return useThemedStyles(
|
|
7
|
+
({ colors, radius, fontFamily, fontSize }): ButtonStyles => ({
|
|
8
|
+
root: {
|
|
9
|
+
default: {
|
|
10
|
+
flexDirection: "row",
|
|
11
|
+
paddingVertical: 12,
|
|
12
|
+
paddingHorizontal: 16,
|
|
13
|
+
borderRadius: radius,
|
|
14
|
+
gap: 8,
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
borderWidth: 1,
|
|
18
|
+
borderColor: colors.border,
|
|
19
|
+
backgroundColor: colors.secondary,
|
|
20
|
+
},
|
|
21
|
+
disabled: {
|
|
22
|
+
opacity: 0.5,
|
|
23
|
+
},
|
|
24
|
+
loading: {
|
|
25
|
+
opacity: 0.8,
|
|
26
|
+
},
|
|
27
|
+
hovered: {
|
|
28
|
+
backgroundColor: hslaSetRelativeLightness(colors.secondary, -1),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
label: {
|
|
32
|
+
default: {
|
|
33
|
+
color: colors.foreground,
|
|
34
|
+
fontSize,
|
|
35
|
+
fontWeight: "bold",
|
|
36
|
+
fontFamily,
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
color: colors.mutedForeground,
|
|
40
|
+
},
|
|
41
|
+
loading: {
|
|
42
|
+
color: colors.mutedForeground,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
spinner: {
|
|
46
|
+
default: {
|
|
47
|
+
color: colors.primaryForeground,
|
|
48
|
+
},
|
|
49
|
+
disabled: {
|
|
50
|
+
color: colors.mutedForeground,
|
|
51
|
+
},
|
|
52
|
+
loading: {
|
|
53
|
+
color: colors.mutedForeground,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -3,7 +3,7 @@ import { useThemedStyles } from "@/utils/use-themed-styles";
|
|
|
3
3
|
|
|
4
4
|
export function useCardVariantDefault(): CardStyles {
|
|
5
5
|
return useThemedStyles(
|
|
6
|
-
({ colors, radius, fontFamily }): CardStyles => ({
|
|
6
|
+
({ colors, radius, fontFamily, fontSize }): CardStyles => ({
|
|
7
7
|
root: {
|
|
8
8
|
default: {
|
|
9
9
|
borderWidth: 1,
|
|
@@ -22,7 +22,7 @@ export function useCardVariantDefault(): CardStyles {
|
|
|
22
22
|
title: {
|
|
23
23
|
default: {
|
|
24
24
|
fontFamily,
|
|
25
|
-
fontSize:
|
|
25
|
+
fontSize: fontSize * 1.25,
|
|
26
26
|
fontWeight: "600",
|
|
27
27
|
color: colors.foreground,
|
|
28
28
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EmptyPrimitive } from "@/primitives";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { EmptyVariants } from "./variants";
|
|
4
|
+
|
|
5
|
+
export interface EmptyProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
media?: React.ReactNode;
|
|
8
|
+
title: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
|
|
11
|
+
variant?: keyof typeof EmptyVariants;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function Empty(props: EmptyProps) {
|
|
15
|
+
const useVariantStyles = EmptyVariants[props.variant || "default"];
|
|
16
|
+
const styles = useVariantStyles();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<EmptyPrimitive.Root styles={styles}>
|
|
20
|
+
{!!props.media && <EmptyPrimitive.Media>{props.media}</EmptyPrimitive.Media>}
|
|
21
|
+
<EmptyPrimitive.Title>{props.title}</EmptyPrimitive.Title>
|
|
22
|
+
{props.description && <EmptyPrimitive.Description>{props.description}</EmptyPrimitive.Description>}
|
|
23
|
+
{props.children}
|
|
24
|
+
</EmptyPrimitive.Root>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EmptyStyles } from "@/primitives";
|
|
2
|
+
import { useThemedStyles } from "@/utils/use-themed-styles";
|
|
3
|
+
|
|
4
|
+
export function useEmptyVariantDefault(): EmptyStyles {
|
|
5
|
+
return useThemedStyles(
|
|
6
|
+
({ colors, fontFamily, fontSize }): EmptyStyles => ({
|
|
7
|
+
root: {
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
padding: 32,
|
|
10
|
+
gap: 32,
|
|
11
|
+
},
|
|
12
|
+
media: {
|
|
13
|
+
backgroundColor: colors.muted,
|
|
14
|
+
width: 64,
|
|
15
|
+
height: 64,
|
|
16
|
+
borderRadius: "50%",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
},
|
|
20
|
+
title: {
|
|
21
|
+
fontFamily: fontFamily,
|
|
22
|
+
fontSize: fontSize,
|
|
23
|
+
color: colors.foreground,
|
|
24
|
+
textAlign: "center",
|
|
25
|
+
fontWeight: "600",
|
|
26
|
+
},
|
|
27
|
+
description: {
|
|
28
|
+
fontFamily: fontFamily,
|
|
29
|
+
fontSize: fontSize * 0.875,
|
|
30
|
+
color: colors.mutedForeground,
|
|
31
|
+
textAlign: "center",
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|