@korsolutions/ui 0.0.17 → 0.0.19

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,4 +1,4 @@
1
- import { B as InputPrimitiveBaseProps, E as SelectRootBaseProps, G as FieldStyles, H as InputStyles, L as ButtonStyles, O as SelectStyles, c as AvatarStyles, p as EmptyStyles, r as ToastStyles, y as CardStyles } from "../index-Bfae0NgJ.mjs";
1
+ import { $ as FieldStyles, D as CardStyles, G as ButtonStyles, I as SelectStyles, J as InputPrimitiveBaseProps, P as SelectRootBaseProps, X as InputStyles, d as ToastStyles, g as AvatarStyles, i as TextareaStyles, n as TextareaPrimitiveBaseProps, s as BadgeStyles, x as EmptyStyles } from "../index-BLsiF42Z.mjs";
2
2
  import React from "react";
3
3
  import { ImageSource, TextProps, TextStyle } from "react-native";
4
4
 
@@ -196,4 +196,32 @@ declare const Toast: typeof ToastComponent & {
196
196
  dismiss: (id: string) => void;
197
197
  };
198
198
  //#endregion
199
- export { Avatar, AvatarProps, Button, Card, Empty, EmptyProps, Field, FieldProps, Input, Link, LinkProps, Select, SelectOption, SelectProps, Toast, Typography, TypographyProps };
199
+ //#region src/components/badge/variants/index.d.ts
200
+ declare const BadgeVariants: {
201
+ default: () => BadgeStyles;
202
+ secondary: () => BadgeStyles;
203
+ };
204
+ //#endregion
205
+ //#region src/components/badge/badge.d.ts
206
+ interface BadgeProps {
207
+ children: string;
208
+ variant?: keyof typeof BadgeVariants;
209
+ color?: string;
210
+ }
211
+ declare function Badge(props: BadgeProps): React.JSX.Element;
212
+ //#endregion
213
+ //#region src/components/textarea/variants/default.d.ts
214
+ declare function useTextareaVariantDefault(): TextareaStyles;
215
+ //#endregion
216
+ //#region src/components/textarea/variants/index.d.ts
217
+ declare const TextareaVariants: {
218
+ default: typeof useTextareaVariantDefault;
219
+ };
220
+ //#endregion
221
+ //#region src/components/textarea/textarea.d.ts
222
+ interface TextareaProps extends TextareaPrimitiveBaseProps {
223
+ variant?: keyof typeof TextareaVariants;
224
+ }
225
+ declare function Textarea(props: TextareaProps): React.JSX.Element;
226
+ //#endregion
227
+ export { Avatar, AvatarProps, Badge, Button, Card, Empty, EmptyProps, Field, FieldProps, Input, Link, LinkProps, Select, SelectOption, SelectProps, Textarea, Toast, Typography, TypographyProps };
@@ -1,5 +1,5 @@
1
- import { i as useThemedStyles, r as ToastComponent, t as ToastAPI } from "../toast-manager-x_SG_xL4.mjs";
2
- import { a as SelectPrimitive, c as FieldPrimitive, i as CardPrimitive, n as AvatarPrimitive, o as ButtonPrimitive, r as EmptyPrimitive, s as InputPrimitive } from "../primitives-B4L9y32H.mjs";
1
+ import { i as useThemedStyles, r as ToastComponent, t as ToastAPI } from "../toast-manager-BOORCQn8.mjs";
2
+ import { a as EmptyPrimitive, c as ButtonPrimitive, i as AvatarPrimitive, l as InputPrimitive, n as BadgePrimitive, o as CardPrimitive, s as SelectPrimitive, t as TextareaPrimitive, u as FieldPrimitive } from "../primitives-CyDqzNcp.mjs";
3
3
  import React, { useState } from "react";
4
4
  import { Linking, Text } from "react-native";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -574,4 +574,109 @@ const Toast = Object.assign(ToastComponent, {
574
574
  });
575
575
 
576
576
  //#endregion
577
- export { Avatar, Button, Card, Empty, Field, Input, Link, Select, Toast, Typography };
577
+ //#region src/components/badge/variants/default.tsx
578
+ const useBadgeVariantDefault = () => {
579
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
580
+ root: { default: {
581
+ backgroundColor: colors.primary,
582
+ paddingVertical: 4,
583
+ paddingHorizontal: 8,
584
+ borderRadius: radius,
585
+ alignSelf: "flex-start"
586
+ } },
587
+ label: { default: {
588
+ color: colors.primaryForeground,
589
+ fontSize: fontSize * .75,
590
+ fontWeight: "600",
591
+ fontFamily
592
+ } }
593
+ }));
594
+ };
595
+
596
+ //#endregion
597
+ //#region src/components/badge/variants/secondary.tsx
598
+ const useBadgeVariantSecondary = () => {
599
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
600
+ root: { default: {
601
+ backgroundColor: colors.secondary,
602
+ paddingVertical: 4,
603
+ paddingHorizontal: 8,
604
+ borderRadius: radius,
605
+ alignSelf: "flex-start"
606
+ } },
607
+ label: { default: {
608
+ color: colors.secondaryForeground,
609
+ fontSize: fontSize * .75,
610
+ fontWeight: "600",
611
+ fontFamily
612
+ } }
613
+ }));
614
+ };
615
+
616
+ //#endregion
617
+ //#region src/components/badge/variants/index.ts
618
+ const BadgeVariants = {
619
+ default: useBadgeVariantDefault,
620
+ secondary: useBadgeVariantSecondary
621
+ };
622
+
623
+ //#endregion
624
+ //#region src/components/badge/badge.tsx
625
+ function Badge(props) {
626
+ const useVariantStyles = BadgeVariants[props.variant || "default"];
627
+ const styles = useVariantStyles();
628
+ const customStyle = props.color ? { backgroundColor: props.color } : void 0;
629
+ return /* @__PURE__ */ jsx(BadgePrimitive.Root, {
630
+ styles,
631
+ style: customStyle,
632
+ children: /* @__PURE__ */ jsx(BadgePrimitive.Label, { children: props.children })
633
+ });
634
+ }
635
+
636
+ //#endregion
637
+ //#region src/components/textarea/variants/default.tsx
638
+ function useTextareaVariantDefault() {
639
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
640
+ default: {
641
+ placeholderTextColor: colors.mutedForeground,
642
+ selectionColor: colors.primary,
643
+ style: {
644
+ borderWidth: 1,
645
+ borderColor: colors.border,
646
+ borderRadius: radius,
647
+ backgroundColor: colors.surface,
648
+ paddingVertical: 12,
649
+ paddingHorizontal: 16,
650
+ outlineWidth: 0,
651
+ fontFamily,
652
+ fontSize,
653
+ minHeight: 120,
654
+ textAlignVertical: "top",
655
+ color: colors.foreground
656
+ }
657
+ },
658
+ focused: { style: { borderColor: colors.primary } },
659
+ disabled: { style: {
660
+ color: colors.mutedForeground,
661
+ backgroundColor: colors.muted
662
+ } }
663
+ }));
664
+ }
665
+
666
+ //#endregion
667
+ //#region src/components/textarea/variants/index.ts
668
+ const TextareaVariants = { default: useTextareaVariantDefault };
669
+
670
+ //#endregion
671
+ //#region src/components/textarea/textarea.tsx
672
+ function Textarea(props) {
673
+ const useVariantStyles = TextareaVariants[props.variant ?? "default"];
674
+ const variantStyles = useVariantStyles();
675
+ return /* @__PURE__ */ jsx(TextareaPrimitive, {
676
+ ...props,
677
+ styles: variantStyles
678
+ });
679
+ }
680
+
681
+ //#endregion
682
+ export { Avatar, Badge, Button, Card, Empty, Field, Input, Link, Select, Textarea, Toast, Typography };
@@ -390,4 +390,49 @@ declare const ToastPrimitive: {
390
390
  Description: typeof ToastDescription;
391
391
  };
392
392
  //#endregion
393
- export { SelectContentProps as A, InputPrimitiveBaseProps as B, CardHeaderProps as C, SelectRootProps as D, SelectRootBaseProps as E, ButtonPrimitiveRootProps as F, FieldStyles as G, InputStyles as H, ButtonState as I, FieldLabelProps as J, FieldErrorProps as K, ButtonStyles as L, SelectValueProps as M, SelectTriggerProps as N, SelectStyles as O, ButtonPrimitive as P, ButtonPrimitiveLabelProps as R, CardTitleProps as S, SelectPortalProps as T, FieldPrimitive as U, InputPrimitiveProps as V, FieldPrimitiveRootProps as W, CardPrimitive as _, ToastTitleProps as a, CardFooterProps as b, AvatarStyles as c, EmptyPrimitive as d, EmptyRootProps as f, EmptyDescriptionProps as g, EmptyMediaProps as h, ToastDescriptionProps as i, SelectOverlayProps as j, SelectOptionProps as k, AvatarImageProps as l, EmptyTitleProps as m, ToastRootProps as n, AvatarPrimitive as o, EmptyStyles as p, FieldDescriptionProps as q, ToastStyles as r, AvatarRootProps as s, ToastPrimitive as t, AvatarFallbackProps as u, CardRootProps as v, SelectPrimitive as w, CardBodyProps as x, CardStyles as y, InputPrimitive as z };
393
+ //#region src/primitives/badge/badge-label.d.ts
394
+ interface BadgeLabelProps {
395
+ children?: string;
396
+ render?: (props: BadgeLabelProps) => React$1.ReactNode;
397
+ style?: StyleProp<TextStyle>;
398
+ }
399
+ declare function BadgeLabel(props: BadgeLabelProps): React$1.JSX.Element;
400
+ //#endregion
401
+ //#region src/primitives/badge/types.d.ts
402
+ type BadgeState = "default";
403
+ interface BadgeStyles {
404
+ root?: Partial<Record<BadgeState, BadgeRootProps["style"]>>;
405
+ label?: Partial<Record<BadgeState, BadgeLabelProps["style"]>>;
406
+ }
407
+ //#endregion
408
+ //#region src/primitives/badge/badge-root.d.ts
409
+ interface BadgeRootProps {
410
+ children?: React$1.ReactNode;
411
+ render?: (props: BadgeRootProps) => React$1.ReactNode;
412
+ style?: StyleProp<ViewStyle>;
413
+ styles?: BadgeStyles;
414
+ }
415
+ declare function BadgeRoot(props: BadgeRootProps): React$1.JSX.Element;
416
+ //#endregion
417
+ //#region src/primitives/badge/index.d.ts
418
+ declare const BadgePrimitive: {
419
+ Root: typeof BadgeRoot;
420
+ Label: typeof BadgeLabel;
421
+ };
422
+ //#endregion
423
+ //#region src/primitives/textarea/types.d.ts
424
+ type TextareaState = "default" | "focused" | "disabled";
425
+ type TextareaStyles = Partial<Record<TextareaState, TextareaPrimitiveBaseProps>>;
426
+ //#endregion
427
+ //#region src/primitives/textarea/textarea.d.ts
428
+ type TextareaPrimitiveBaseProps = Omit<TextInputProps, "onChange"> & {
429
+ onChange?: TextInputProps["onChangeText"];
430
+ isDisabled?: boolean;
431
+ };
432
+ interface TextareaPrimitiveProps extends TextareaPrimitiveBaseProps {
433
+ render?: (props: TextareaPrimitiveProps) => React.ReactNode;
434
+ styles?: TextareaStyles;
435
+ }
436
+ declare function TextareaPrimitive(props: TextareaPrimitiveProps): react2.JSX.Element;
437
+ //#endregion
438
+ export { FieldStyles as $, CardTitleProps as A, SelectValueProps as B, EmptyMediaProps as C, CardStyles as D, CardRootProps as E, SelectRootProps as F, ButtonStyles as G, ButtonPrimitive as H, SelectStyles as I, InputPrimitiveBaseProps as J, ButtonPrimitiveLabelProps as K, SelectOptionProps as L, SelectPrimitive as M, SelectPortalProps as N, CardFooterProps as O, SelectRootBaseProps as P, FieldPrimitiveRootProps as Q, SelectContentProps as R, EmptyTitleProps as S, CardPrimitive as T, ButtonPrimitiveRootProps as U, SelectTriggerProps as V, ButtonState as W, InputStyles as X, InputPrimitiveProps as Y, FieldPrimitive as Z, AvatarImageProps as _, BadgePrimitive as a, EmptyRootProps as b, BadgeLabelProps as c, ToastStyles as d, FieldErrorProps as et, ToastDescriptionProps as f, AvatarStyles as g, AvatarRootProps as h, TextareaStyles as i, CardHeaderProps as j, CardBodyProps as k, ToastPrimitive as l, AvatarPrimitive as m, TextareaPrimitiveBaseProps as n, FieldLabelProps as nt, BadgeRootProps as o, ToastTitleProps as p, InputPrimitive as q, TextareaPrimitiveProps as r, BadgeStyles as s, TextareaPrimitive as t, FieldDescriptionProps as tt, ToastRootProps as u, AvatarFallbackProps as v, EmptyDescriptionProps as w, EmptyStyles as x, EmptyPrimitive as y, SelectOverlayProps as z };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as ThemeProvider, n as ToastContainer, o as useTheme } from "./toast-manager-x_SG_xL4.mjs";
2
- import { l as PortalHost } from "./primitives-B4L9y32H.mjs";
1
+ import { a as ThemeProvider, n as ToastContainer, o as useTheme } from "./toast-manager-BOORCQn8.mjs";
2
+ import { d as PortalHost } from "./primitives-CyDqzNcp.mjs";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/index.tsx
@@ -1,2 +1,2 @@
1
- import { A as SelectContentProps, B as InputPrimitiveBaseProps, C as CardHeaderProps, D as SelectRootProps, E as SelectRootBaseProps, F as ButtonPrimitiveRootProps, G as FieldStyles, H as InputStyles, I as ButtonState, J as FieldLabelProps, K as FieldErrorProps, L as ButtonStyles, M as SelectValueProps, N as SelectTriggerProps, O as SelectStyles, P as ButtonPrimitive, R as ButtonPrimitiveLabelProps, S as CardTitleProps, T as SelectPortalProps, U as FieldPrimitive, V as InputPrimitiveProps, W as FieldPrimitiveRootProps, _ as CardPrimitive, a as ToastTitleProps, b as CardFooterProps, c as AvatarStyles, d as EmptyPrimitive, f as EmptyRootProps, g as EmptyDescriptionProps, h as EmptyMediaProps, i as ToastDescriptionProps, j as SelectOverlayProps, k as SelectOptionProps, l as AvatarImageProps, m as EmptyTitleProps, n as ToastRootProps, o as AvatarPrimitive, p as EmptyStyles, q as FieldDescriptionProps, r as ToastStyles, s as AvatarRootProps, t as ToastPrimitive, u as AvatarFallbackProps, v as CardRootProps, w as SelectPrimitive, x as CardBodyProps, y as CardStyles, z as InputPrimitive } from "../index-Bfae0NgJ.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, ToastDescriptionProps, ToastPrimitive, ToastRootProps, ToastStyles, ToastTitleProps };
1
+ import { $ as FieldStyles, A as CardTitleProps, B as SelectValueProps, C as EmptyMediaProps, D as CardStyles, E as CardRootProps, F as SelectRootProps, G as ButtonStyles, H as ButtonPrimitive, I as SelectStyles, J as InputPrimitiveBaseProps, K as ButtonPrimitiveLabelProps, L as SelectOptionProps, M as SelectPrimitive, N as SelectPortalProps, O as CardFooterProps, P as SelectRootBaseProps, Q as FieldPrimitiveRootProps, R as SelectContentProps, S as EmptyTitleProps, T as CardPrimitive, U as ButtonPrimitiveRootProps, V as SelectTriggerProps, W as ButtonState, X as InputStyles, Y as InputPrimitiveProps, Z as FieldPrimitive, _ as AvatarImageProps, a as BadgePrimitive, b as EmptyRootProps, c as BadgeLabelProps, d as ToastStyles, et as FieldErrorProps, f as ToastDescriptionProps, g as AvatarStyles, h as AvatarRootProps, i as TextareaStyles, j as CardHeaderProps, k as CardBodyProps, l as ToastPrimitive, m as AvatarPrimitive, n as TextareaPrimitiveBaseProps, nt as FieldLabelProps, o as BadgeRootProps, p as ToastTitleProps, q as InputPrimitive, r as TextareaPrimitiveProps, s as BadgeStyles, t as TextareaPrimitive, tt as FieldDescriptionProps, u as ToastRootProps, v as AvatarFallbackProps, w as EmptyDescriptionProps, x as EmptyStyles, y as EmptyPrimitive, z as SelectOverlayProps } from "../index-BLsiF42Z.mjs";
2
+ export { AvatarFallbackProps, AvatarImageProps, AvatarPrimitive, AvatarRootProps, AvatarStyles, BadgeLabelProps, BadgePrimitive, BadgeRootProps, BadgeStyles, 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, TextareaPrimitive, TextareaPrimitiveBaseProps, TextareaPrimitiveProps, TextareaStyles, ToastDescriptionProps, ToastPrimitive, ToastRootProps, ToastStyles, ToastTitleProps };
@@ -1,3 +1,3 @@
1
- import { a as SelectPrimitive, c as FieldPrimitive, i as CardPrimitive, n as AvatarPrimitive, o as ButtonPrimitive, r as EmptyPrimitive, s as InputPrimitive, t as ToastPrimitive } from "../primitives-B4L9y32H.mjs";
1
+ import { a as EmptyPrimitive, c as ButtonPrimitive, i as AvatarPrimitive, l as InputPrimitive, n as BadgePrimitive, o as CardPrimitive, r as ToastPrimitive, s as SelectPrimitive, t as TextareaPrimitive, u as FieldPrimitive } from "../primitives-CyDqzNcp.mjs";
2
2
 
3
- export { AvatarPrimitive, ButtonPrimitive, CardPrimitive, EmptyPrimitive, FieldPrimitive, InputPrimitive, SelectPrimitive, ToastPrimitive };
3
+ export { AvatarPrimitive, BadgePrimitive, ButtonPrimitive, CardPrimitive, EmptyPrimitive, FieldPrimitive, InputPrimitive, SelectPrimitive, TextareaPrimitive, ToastPrimitive };
@@ -122,14 +122,14 @@ const FieldPrimitive = {
122
122
 
123
123
  //#endregion
124
124
  //#region src/primitives/input/input.tsx
125
- const calculateState$3 = (props, isFocused) => {
125
+ const calculateState$4 = (props, isFocused) => {
126
126
  if (props.isDisabled) return "disabled";
127
127
  if (isFocused) return "focused";
128
128
  return "default";
129
129
  };
130
130
  function InputPrimitive(props) {
131
131
  const [isFocused, setIsFocused] = useState(false);
132
- const state = calculateState$3(props, isFocused);
132
+ const state = calculateState$4(props, isFocused);
133
133
  const composedStyles = [
134
134
  props.styles?.default?.style,
135
135
  props.styles?.[state]?.style,
@@ -168,7 +168,7 @@ const useButtonPrimitive = () => {
168
168
 
169
169
  //#endregion
170
170
  //#region src/primitives/button/button-root.tsx
171
- const calculateState$2 = (props, isHovered) => {
171
+ const calculateState$3 = (props, isHovered) => {
172
172
  if (props.isDisabled) return "disabled";
173
173
  if (props.isLoading) return "loading";
174
174
  if (isHovered) return "hovered";
@@ -176,7 +176,7 @@ const calculateState$2 = (props, isHovered) => {
176
176
  };
177
177
  function ButtonRoot(props) {
178
178
  const [isHovered, setIsHovered] = useState(false);
179
- const state = calculateState$2(props, isHovered);
179
+ const state = calculateState$3(props, isHovered);
180
180
  const calculatedStyle = [
181
181
  props.styles?.root?.default,
182
182
  props.styles?.root?.[state],
@@ -246,7 +246,7 @@ const useSelect = () => {
246
246
 
247
247
  //#endregion
248
248
  //#region src/primitives/select/select-root.tsx
249
- const calculateState$1 = (props) => {
249
+ const calculateState$2 = (props) => {
250
250
  if (props.isDisabled) return "disabled";
251
251
  return "default";
252
252
  };
@@ -254,7 +254,7 @@ function SelectRoot(props) {
254
254
  const [isOpen, setIsOpen] = useState(false);
255
255
  const [triggerLayout, setTriggerLayout] = useState(null);
256
256
  const [options, setOptions] = useState([]);
257
- const state = calculateState$1(props);
257
+ const state = calculateState$2(props);
258
258
  const composedStyles = calculateComposedStyles(props.styles, state, "root", props.style);
259
259
  const Component = props.render ?? View;
260
260
  return /* @__PURE__ */ jsx(SelectContext.Provider, {
@@ -370,7 +370,7 @@ function SelectContent(props) {
370
370
 
371
371
  //#endregion
372
372
  //#region src/primitives/select/select-option.tsx
373
- const calculateState = (selectState, hovered, selected) => {
373
+ const calculateState$1 = (selectState, hovered, selected) => {
374
374
  if (selectState === "disabled") return "disabled";
375
375
  if (selected) return "selected";
376
376
  if (hovered) return "hovered";
@@ -380,7 +380,7 @@ function SelectOption(props) {
380
380
  const [isHovered, setIsHovered] = useState(false);
381
381
  const select = useSelect();
382
382
  const isSelected = select.value === props.value;
383
- const optionState = calculateState(select.state, isHovered, isSelected);
383
+ const optionState = calculateState$1(select.state, isHovered, isSelected);
384
384
  const composedStyles = calculateComposedStyles(select.styles, optionState, "option", props.style);
385
385
  useEffect(() => {
386
386
  select.setOptions((prev) => {
@@ -661,4 +661,86 @@ const ToastPrimitive = {
661
661
  };
662
662
 
663
663
  //#endregion
664
- export { SelectPrimitive as a, FieldPrimitive as c, CardPrimitive as i, PortalHost as l, AvatarPrimitive as n, ButtonPrimitive as o, EmptyPrimitive as r, InputPrimitive as s, ToastPrimitive as t };
664
+ //#region src/primitives/badge/context.ts
665
+ const BadgeContext = createContext(void 0);
666
+ const useBadge = () => {
667
+ const context = useContext(BadgeContext);
668
+ if (!context) throw new Error("useBadge must be used within a BadgeProvider");
669
+ return context;
670
+ };
671
+
672
+ //#endregion
673
+ //#region src/primitives/badge/badge-root.tsx
674
+ function BadgeRoot(props) {
675
+ const composedStyle = calculateComposedStyles(props.styles, "default", "root", props.style);
676
+ const Component = props.render ?? View;
677
+ return /* @__PURE__ */ jsx(BadgeContext.Provider, {
678
+ value: {
679
+ state: "default",
680
+ styles: props.styles
681
+ },
682
+ children: /* @__PURE__ */ jsx(Component, {
683
+ ...props,
684
+ style: composedStyle
685
+ })
686
+ });
687
+ }
688
+
689
+ //#endregion
690
+ //#region src/primitives/badge/badge-label.tsx
691
+ function BadgeLabel(props) {
692
+ const badge = useBadge();
693
+ const composedStyle = calculateComposedStyles(badge.styles, badge.state, "label", props.style);
694
+ return /* @__PURE__ */ jsx(props.render ?? Text, {
695
+ ...props,
696
+ style: composedStyle
697
+ });
698
+ }
699
+
700
+ //#endregion
701
+ //#region src/primitives/badge/index.ts
702
+ const BadgePrimitive = {
703
+ Root: BadgeRoot,
704
+ Label: BadgeLabel
705
+ };
706
+
707
+ //#endregion
708
+ //#region src/primitives/textarea/textarea.tsx
709
+ const calculateState = (props, isFocused) => {
710
+ if (props.isDisabled) return "disabled";
711
+ if (isFocused) return "focused";
712
+ return "default";
713
+ };
714
+ function TextareaPrimitive(props) {
715
+ const [isFocused, setIsFocused] = useState(false);
716
+ const state = calculateState(props, isFocused);
717
+ const composedStyles = [
718
+ props.styles?.default?.style,
719
+ props.styles?.[state]?.style,
720
+ props.style
721
+ ];
722
+ const composedProps = {
723
+ ...props.styles?.default,
724
+ ...props.styles?.[state],
725
+ ...props
726
+ };
727
+ return /* @__PURE__ */ jsx(props.render ?? TextInput, {
728
+ ...composedProps,
729
+ multiline: true,
730
+ onChange: void 0,
731
+ onChangeText: props.onChange,
732
+ onFocus: (e) => {
733
+ setIsFocused(true);
734
+ props.onFocus?.(e);
735
+ },
736
+ onBlur: (e) => {
737
+ setIsFocused(false);
738
+ props.onBlur?.(e);
739
+ },
740
+ readOnly: props.isDisabled || props.readOnly,
741
+ style: composedStyles
742
+ });
743
+ }
744
+
745
+ //#endregion
746
+ export { EmptyPrimitive as a, ButtonPrimitive as c, PortalHost as d, AvatarPrimitive as i, InputPrimitive as l, BadgePrimitive as n, CardPrimitive as o, ToastPrimitive as r, SelectPrimitive as s, TextareaPrimitive as t, FieldPrimitive as u };
@@ -1,4 +1,4 @@
1
- import { t as ToastPrimitive } from "./primitives-B4L9y32H.mjs";
1
+ import { r as ToastPrimitive } from "./primitives-CyDqzNcp.mjs";
2
2
  import React, { createContext, useContext, useEffect, useState, useSyncExternalStore } from "react";
3
3
  import { StyleSheet, View, useColorScheme } from "react-native";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -143,13 +143,13 @@ const useToastVariantSuccess = () => {
143
143
  maxWidth: 400
144
144
  },
145
145
  title: {
146
- color: colors.background,
146
+ color: colors.foreground,
147
147
  fontSize,
148
148
  fontWeight: "600",
149
149
  fontFamily
150
150
  },
151
151
  description: {
152
- color: colors.background,
152
+ color: colors.foreground,
153
153
  fontSize: fontSize * .875,
154
154
  fontFamily,
155
155
  opacity: .9
@@ -172,13 +172,13 @@ const useToastVariantDanger = () => {
172
172
  maxWidth: 400
173
173
  },
174
174
  title: {
175
- color: colors.background,
175
+ color: colors.foreground,
176
176
  fontSize,
177
177
  fontWeight: "600",
178
178
  fontFamily
179
179
  },
180
180
  description: {
181
- color: colors.background,
181
+ color: colors.foreground,
182
182
  fontSize: fontSize * .875,
183
183
  fontFamily,
184
184
  opacity: .9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korsolutions/ui",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -0,0 +1,23 @@
1
+ import { BadgePrimitive } from "@/primitives";
2
+ import React from "react";
3
+ import { BadgeVariants } from "./variants";
4
+
5
+ interface BadgeProps {
6
+ children: string;
7
+ variant?: keyof typeof BadgeVariants;
8
+ color?: string;
9
+ }
10
+
11
+ export function Badge(props: BadgeProps) {
12
+ const useVariantStyles = BadgeVariants[props.variant || "default"];
13
+ const styles = useVariantStyles();
14
+
15
+ // Override background color if custom color is provided
16
+ const customStyle = props.color ? { backgroundColor: props.color } : undefined;
17
+
18
+ return (
19
+ <BadgePrimitive.Root styles={styles} style={customStyle}>
20
+ <BadgePrimitive.Label>{props.children}</BadgePrimitive.Label>
21
+ </BadgePrimitive.Root>
22
+ );
23
+ }
@@ -0,0 +1,26 @@
1
+ import { BadgeStyles } from "@/primitives";
2
+ import { useThemedStyles } from "@/utils/use-themed-styles";
3
+
4
+ export const useBadgeVariantDefault = (): BadgeStyles => {
5
+ return useThemedStyles(
6
+ ({ colors, radius, fontFamily, fontSize }): BadgeStyles => ({
7
+ root: {
8
+ default: {
9
+ backgroundColor: colors.primary,
10
+ paddingVertical: 4,
11
+ paddingHorizontal: 8,
12
+ borderRadius: radius,
13
+ alignSelf: "flex-start",
14
+ },
15
+ },
16
+ label: {
17
+ default: {
18
+ color: colors.primaryForeground,
19
+ fontSize: fontSize * 0.75,
20
+ fontWeight: "600",
21
+ fontFamily,
22
+ },
23
+ },
24
+ })
25
+ );
26
+ };
@@ -0,0 +1,7 @@
1
+ import { useBadgeVariantDefault } from "./default";
2
+ import { useBadgeVariantSecondary } from "./secondary";
3
+
4
+ export const BadgeVariants = {
5
+ default: useBadgeVariantDefault,
6
+ secondary: useBadgeVariantSecondary,
7
+ };
@@ -0,0 +1,26 @@
1
+ import { BadgeStyles } from "@/primitives";
2
+ import { useThemedStyles } from "@/utils/use-themed-styles";
3
+
4
+ export const useBadgeVariantSecondary = (): BadgeStyles => {
5
+ return useThemedStyles(
6
+ ({ colors, radius, fontFamily, fontSize }): BadgeStyles => ({
7
+ root: {
8
+ default: {
9
+ backgroundColor: colors.secondary,
10
+ paddingVertical: 4,
11
+ paddingHorizontal: 8,
12
+ borderRadius: radius,
13
+ alignSelf: "flex-start",
14
+ },
15
+ },
16
+ label: {
17
+ default: {
18
+ color: colors.secondaryForeground,
19
+ fontSize: fontSize * 0.75,
20
+ fontWeight: "600",
21
+ fontFamily,
22
+ },
23
+ },
24
+ })
25
+ );
26
+ };
@@ -8,3 +8,5 @@ export * from "./link/link";
8
8
  export * from "./empty/empty";
9
9
  export * from "./avatar/avatar";
10
10
  export * from "./toast/index";
11
+ export * from "./badge/badge";
12
+ export * from "./textarea/textarea";
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { TextareaVariants } from "./variants";
3
+ import { TextareaPrimitive, TextareaPrimitiveBaseProps } from "@/primitives";
4
+
5
+ interface TextareaProps extends TextareaPrimitiveBaseProps {
6
+ variant?: keyof typeof TextareaVariants;
7
+ }
8
+
9
+ export function Textarea(props: TextareaProps) {
10
+ const useVariantStyles = TextareaVariants[props.variant ?? "default"];
11
+ const variantStyles = useVariantStyles();
12
+
13
+ return <TextareaPrimitive {...props} styles={variantStyles} />;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { TextareaStyles } from "@/primitives";
2
+ import { useThemedStyles } from "@/utils/use-themed-styles";
3
+
4
+ export function useTextareaVariantDefault(): TextareaStyles {
5
+ return useThemedStyles(
6
+ ({ colors, radius, fontFamily, fontSize }): TextareaStyles => ({
7
+ default: {
8
+ placeholderTextColor: colors.mutedForeground,
9
+ selectionColor: colors.primary,
10
+ style: {
11
+ borderWidth: 1,
12
+ borderColor: colors.border,
13
+ borderRadius: radius,
14
+ backgroundColor: colors.surface,
15
+ paddingVertical: 12,
16
+ paddingHorizontal: 16,
17
+ outlineWidth: 0,
18
+ fontFamily,
19
+ fontSize,
20
+ minHeight: 120,
21
+ textAlignVertical: "top",
22
+ color: colors.foreground,
23
+ },
24
+ },
25
+ focused: {
26
+ style: {
27
+ borderColor: colors.primary,
28
+ },
29
+ },
30
+ disabled: {
31
+ style: {
32
+ color: colors.mutedForeground,
33
+ backgroundColor: colors.muted,
34
+ },
35
+ },
36
+ })
37
+ );
38
+ }
@@ -0,0 +1,5 @@
1
+ import { useTextareaVariantDefault } from "./default";
2
+
3
+ export const TextareaVariants = {
4
+ default: useTextareaVariantDefault,
5
+ };
@@ -15,13 +15,13 @@ export const useToastVariantDanger = (): ToastStyles => {
15
15
  maxWidth: 400,
16
16
  },
17
17
  title: {
18
- color: colors.background,
18
+ color: colors.foreground,
19
19
  fontSize: fontSize,
20
20
  fontWeight: "600",
21
21
  fontFamily,
22
22
  },
23
23
  description: {
24
- color: colors.background,
24
+ color: colors.foreground,
25
25
  fontSize: fontSize * 0.875,
26
26
  fontFamily,
27
27
  opacity: 0.9,
@@ -15,13 +15,13 @@ export const useToastVariantSuccess = (): ToastStyles => {
15
15
  maxWidth: 400,
16
16
  },
17
17
  title: {
18
- color: colors.background,
18
+ color: colors.foreground,
19
19
  fontSize: fontSize,
20
20
  fontWeight: "600",
21
21
  fontFamily,
22
22
  },
23
23
  description: {
24
- color: colors.background,
24
+ color: colors.foreground,
25
25
  fontSize: fontSize * 0.875,
26
26
  fontFamily,
27
27
  opacity: 0.9,
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { StyleProp, Text, TextStyle } from "react-native";
3
+ import { useBadge } from "./context";
4
+ import { calculateComposedStyles } from "@/utils/calculate-styles";
5
+
6
+ export interface BadgeLabelProps {
7
+ children?: string;
8
+
9
+ render?: (props: BadgeLabelProps) => React.ReactNode;
10
+
11
+ style?: StyleProp<TextStyle>;
12
+ }
13
+
14
+ export function BadgeLabel(props: BadgeLabelProps) {
15
+ const badge = useBadge();
16
+
17
+ const composedStyle = calculateComposedStyles(badge.styles, badge.state, "label", props.style);
18
+
19
+ const Component = props.render ?? Text;
20
+ return <Component {...props} style={composedStyle} />;
21
+ }
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { StyleProp, View, ViewStyle } from "react-native";
3
+ import { BadgeStyles } from "./types";
4
+ import { calculateComposedStyles } from "@/utils/calculate-styles";
5
+ import { BadgeContext } from "./context";
6
+
7
+ export interface BadgeRootProps {
8
+ children?: React.ReactNode;
9
+
10
+ render?: (props: BadgeRootProps) => React.ReactNode;
11
+
12
+ style?: StyleProp<ViewStyle>;
13
+ styles?: BadgeStyles;
14
+ }
15
+
16
+ export function BadgeRoot(props: BadgeRootProps) {
17
+ const composedStyle = calculateComposedStyles(props.styles, "default", "root", props.style);
18
+
19
+ const Component = props.render ?? View;
20
+ return (
21
+ <BadgeContext.Provider
22
+ value={{
23
+ state: "default",
24
+ styles: props.styles,
25
+ }}
26
+ >
27
+ <Component {...props} style={composedStyle} />
28
+ </BadgeContext.Provider>
29
+ );
30
+ }
@@ -0,0 +1,17 @@
1
+ import { createContext, useContext } from "react";
2
+ import { BadgeState, BadgeStyles } from "./types";
3
+
4
+ export interface BadgeContext {
5
+ state: BadgeState;
6
+ styles?: BadgeStyles;
7
+ }
8
+
9
+ export const BadgeContext = createContext<BadgeContext | undefined>(undefined);
10
+
11
+ export const useBadge = () => {
12
+ const context = useContext(BadgeContext);
13
+ if (!context) {
14
+ throw new Error("useBadge must be used within a BadgeProvider");
15
+ }
16
+ return context;
17
+ };
@@ -0,0 +1,11 @@
1
+ import { BadgeRoot } from "./badge-root";
2
+ import { BadgeLabel } from "./badge-label";
3
+
4
+ export const BadgePrimitive = {
5
+ Root: BadgeRoot,
6
+ Label: BadgeLabel,
7
+ };
8
+
9
+ export type { BadgeRootProps } from "./badge-root";
10
+ export type { BadgeLabelProps } from "./badge-label";
11
+ export type { BadgeStyles } from "./types";
@@ -0,0 +1,9 @@
1
+ import { BadgeRootProps } from "./badge-root";
2
+ import { BadgeLabelProps } from "./badge-label";
3
+
4
+ export type BadgeState = "default";
5
+
6
+ export interface BadgeStyles {
7
+ root?: Partial<Record<BadgeState, BadgeRootProps["style"]>>;
8
+ label?: Partial<Record<BadgeState, BadgeLabelProps["style"]>>;
9
+ }
@@ -6,3 +6,5 @@ export * from "./card";
6
6
  export * from "./empty";
7
7
  export * from "./avatar";
8
8
  export * from "./toast";
9
+ export * from "./badge";
10
+ export * from "./textarea";
@@ -0,0 +1,2 @@
1
+ export * from "./textarea";
2
+ export type { TextareaStyles } from "./types";
@@ -0,0 +1,56 @@
1
+ import { TextInput, TextInputProps } from "react-native";
2
+ import { TextareaState, TextareaStyles } from "./types";
3
+ import { useState } from "react";
4
+
5
+ export type TextareaPrimitiveBaseProps = Omit<TextInputProps, "onChange"> & {
6
+ onChange?: TextInputProps["onChangeText"];
7
+
8
+ isDisabled?: boolean;
9
+ };
10
+
11
+ export interface TextareaPrimitiveProps extends TextareaPrimitiveBaseProps {
12
+ render?: (props: TextareaPrimitiveProps) => React.ReactNode;
13
+
14
+ styles?: TextareaStyles;
15
+ }
16
+
17
+ const calculateState = (props: TextareaPrimitiveProps, isFocused: boolean): TextareaState => {
18
+ if (props.isDisabled) {
19
+ return "disabled";
20
+ }
21
+ if (isFocused) {
22
+ return "focused";
23
+ }
24
+ return "default";
25
+ };
26
+
27
+ export function TextareaPrimitive(props: TextareaPrimitiveProps) {
28
+ const [isFocused, setIsFocused] = useState(false);
29
+ const state = calculateState(props, isFocused);
30
+
31
+ const composedStyles = [props.styles?.default?.style, props.styles?.[state]?.style, props.style];
32
+ const composedProps = {
33
+ ...props.styles?.default,
34
+ ...props.styles?.[state],
35
+ ...props,
36
+ };
37
+ const Component = props.render ?? TextInput;
38
+ return (
39
+ <Component
40
+ {...composedProps}
41
+ multiline
42
+ onChange={undefined}
43
+ onChangeText={props.onChange}
44
+ onFocus={(e) => {
45
+ setIsFocused(true);
46
+ props.onFocus?.(e);
47
+ }}
48
+ onBlur={(e) => {
49
+ setIsFocused(false);
50
+ props.onBlur?.(e);
51
+ }}
52
+ readOnly={props.isDisabled || props.readOnly}
53
+ style={composedStyles}
54
+ />
55
+ );
56
+ }
@@ -0,0 +1,5 @@
1
+ import { TextareaPrimitiveBaseProps } from "./textarea";
2
+
3
+ export type TextareaState = "default" | "focused" | "disabled";
4
+
5
+ export type TextareaStyles = Partial<Record<TextareaState, TextareaPrimitiveBaseProps>>;