@korsolutions/ui 0.0.4 → 0.0.6
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/components/index.d.mts +84 -0
- package/dist/components/index.mjs +288 -0
- package/dist/index-Dafk8ZGv.d.mts +265 -0
- package/dist/index.d.mts +45 -0
- package/dist/index.mjs +11 -0
- package/dist/portal-DoPaAohb.mjs +61 -0
- package/dist/primitives/index.d.mts +2 -0
- package/dist/primitives/index.mjs +4 -0
- package/dist/primitives-C2enZ5Ku.mjs +441 -0
- package/dist/themes-BrLbh9h6.mjs +86 -0
- package/package.json +20 -8
- package/src/components/button/button.tsx +24 -0
- package/src/components/button/variants/default.tsx +52 -0
- package/src/components/button/variants/index.ts +5 -0
- package/src/components/card/card.tsx +26 -0
- package/src/components/card/variants/default.tsx +38 -0
- package/src/components/card/variants/index.ts +5 -0
- package/src/components/field/field.tsx +27 -0
- package/src/components/field/variants/default.tsx +29 -0
- package/src/components/field/variants/index.ts +5 -0
- package/src/components/index.ts +5 -0
- package/src/components/input/input.tsx +14 -0
- package/src/components/input/variants/default.tsx +34 -0
- package/src/components/input/variants/index.ts +5 -0
- package/src/components/select/select.tsx +35 -0
- package/src/components/select/variants/default.tsx +81 -0
- package/src/components/select/variants/index.ts +5 -0
- package/src/index.tsx +13 -0
- package/src/primitives/button/button-context.tsx +5 -5
- package/src/primitives/button/button-label.tsx +7 -5
- package/src/primitives/button/button-root.tsx +12 -8
- package/src/primitives/button/button-spinner.tsx +14 -0
- package/src/primitives/button/index.ts +5 -3
- package/src/primitives/button/types.ts +6 -5
- package/src/primitives/card/card-body.tsx +1 -1
- package/src/primitives/card/card-footer.tsx +1 -1
- package/src/primitives/card/card-header.tsx +1 -1
- package/src/primitives/card/card-root.tsx +1 -1
- package/src/primitives/card/card-title.tsx +1 -1
- package/src/primitives/card/index.ts +1 -1
- package/src/primitives/field/context.ts +5 -19
- package/src/primitives/field/field-description.tsx +17 -0
- package/src/primitives/field/field-error.tsx +17 -0
- package/src/primitives/field/field-label.tsx +7 -3
- package/src/primitives/field/field-root.tsx +13 -59
- package/src/primitives/field/index.ts +9 -6
- package/src/primitives/field/types.ts +8 -7
- package/src/primitives/index.ts +0 -2
- package/src/primitives/input/index.ts +1 -1
- package/src/primitives/input/input.tsx +48 -13
- package/src/primitives/input/types.ts +2 -4
- package/src/primitives/select/context.ts +3 -3
- package/src/primitives/select/index.ts +2 -2
- package/src/primitives/select/select-content.tsx +2 -2
- package/src/primitives/select/select-option.tsx +27 -4
- package/src/primitives/select/select-overlay.tsx +1 -1
- package/src/primitives/select/select-root.tsx +13 -11
- package/src/primitives/select/select-trigger.tsx +3 -2
- package/src/primitives/select/select-value.tsx +4 -1
- package/src/primitives/select/types.ts +3 -1
- package/src/themes/default/colors.ts +45 -0
- package/src/themes/default/index.ts +11 -0
- package/src/themes/index.ts +2 -0
- package/src/themes/provider.tsx +56 -0
- package/src/themes/themes.ts +6 -0
- package/src/themes/types.ts +30 -0
- package/src/utils/hsla-utils.ts +10 -0
- package/src/utils/use-themed-styles.ts +13 -0
- package/tsconfig.json +8 -0
- package/tsdown.config.ts +8 -0
- package/src/composites/card.tsx +0 -23
- package/src/composites/index.ts +0 -1
- package/src/index.ts +0 -1
- package/src/primitives/field/field-control.tsx +0 -29
- package/src/primitives/provider.tsx +0 -10
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useTheme } from "@/themes";
|
|
2
|
+
import { Colors, FontFamily, Radius } from "@/themes/types";
|
|
3
|
+
|
|
4
|
+
interface CallbackProps {
|
|
5
|
+
colors: Colors;
|
|
6
|
+
radius: Radius;
|
|
7
|
+
fontFamily: FontFamily;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useThemedStyles = <T>(callback: (props: CallbackProps) => T): T => {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
return callback({ colors: theme.colors, radius: theme.radius, fontFamily: theme.fontFamily });
|
|
13
|
+
};
|
package/tsconfig.json
CHANGED
package/tsdown.config.ts
ADDED
package/src/composites/card.tsx
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Card as CardPrimitive, CardStyles } from "../primitives/card";
|
|
3
|
-
|
|
4
|
-
export interface CompositeCardProps {
|
|
5
|
-
title?: string;
|
|
6
|
-
footer?: React.ReactNode;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
styles?: CardStyles;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function Card({ title, footer, children, styles }: CompositeCardProps) {
|
|
12
|
-
return (
|
|
13
|
-
<CardPrimitive.Root styles={styles}>
|
|
14
|
-
{title && (
|
|
15
|
-
<CardPrimitive.Header>
|
|
16
|
-
<CardPrimitive.Title>{title}</CardPrimitive.Title>
|
|
17
|
-
</CardPrimitive.Header>
|
|
18
|
-
)}
|
|
19
|
-
<CardPrimitive.Body>{children}</CardPrimitive.Body>
|
|
20
|
-
{footer && <CardPrimitive.Footer>{footer}</CardPrimitive.Footer>}
|
|
21
|
-
</CardPrimitive.Root>
|
|
22
|
-
);
|
|
23
|
-
}
|
package/src/composites/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./card";
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./primitives";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useField } from "./context";
|
|
3
|
-
import { FieldRootProps } from "./field-root";
|
|
4
|
-
|
|
5
|
-
interface FieldControlInjectedProps<TControlStyles> {
|
|
6
|
-
value: FieldRootProps["value"];
|
|
7
|
-
onChange: FieldRootProps["onChange"];
|
|
8
|
-
|
|
9
|
-
onFocus?: () => void;
|
|
10
|
-
onBlur?: () => void;
|
|
11
|
-
|
|
12
|
-
styles?: TControlStyles;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type FieldControlProps<T> = {
|
|
16
|
-
render: (props: FieldControlInjectedProps<T>) => React.ReactElement;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function FieldControl<T>(props: FieldControlProps<T>) {
|
|
20
|
-
const { value, onChange, setFocused, state, styles } = useField<T>();
|
|
21
|
-
|
|
22
|
-
const controlStyles = styles?.control;
|
|
23
|
-
const composedStyles = controlStyles ? { ...controlStyles.default, ...controlStyles[state] } : undefined;
|
|
24
|
-
|
|
25
|
-
const Component = props.render;
|
|
26
|
-
return (
|
|
27
|
-
<Component value={value} onChange={onChange} onBlur={() => setFocused(false)} onFocus={() => setFocused(true)} styles={composedStyles as T} />
|
|
28
|
-
);
|
|
29
|
-
}
|