@ekanos/ui 0.1.0
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/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/ai-prompt-input.d.ts +187 -0
- package/dist/ai-prompt-input.js +2411 -0
- package/dist/alert.d.ts +12 -0
- package/dist/alert.js +92 -0
- package/dist/badge.d.ts +12 -0
- package/dist/badge.js +60 -0
- package/dist/button.d.ts +13 -0
- package/dist/button.js +64 -0
- package/dist/card.d.ts +18 -0
- package/dist/card.js +108 -0
- package/dist/dialog.d.ts +19 -0
- package/dist/dialog.js +897 -0
- package/dist/dropdown-menu.d.ts +27 -0
- package/dist/dropdown-menu.js +941 -0
- package/dist/form.d.ts +27 -0
- package/dist/form.js +156 -0
- package/dist/icon.d.ts +47 -0
- package/dist/icon.js +763 -0
- package/dist/if.d.ts +38 -0
- package/dist/if.js +15 -0
- package/dist/input.d.ts +5 -0
- package/dist/input.js +28 -0
- package/dist/label.d.ts +5 -0
- package/dist/label.js +27 -0
- package/dist/select.d.ts +25 -0
- package/dist/select.js +944 -0
- package/dist/separator.d.ts +6 -0
- package/dist/separator.js +35 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.js +22 -0
- package/dist/spinner.d.ts +27 -0
- package/dist/spinner.js +49 -0
- package/dist/tooltip.d.ts +9 -0
- package/dist/tooltip.js +74 -0
- package/dist/trans.d.ts +39 -0
- package/dist/trans.js +9 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +83 -0
- package/package.json +150 -0
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_hook_form from 'react-hook-form';
|
|
2
|
+
import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
import { Label } from './label.js';
|
|
6
|
+
|
|
7
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
8
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => React.JSX.Element;
|
|
9
|
+
declare const useFormField: () => {
|
|
10
|
+
invalid: boolean;
|
|
11
|
+
isDirty: boolean;
|
|
12
|
+
isTouched: boolean;
|
|
13
|
+
isValidating: boolean;
|
|
14
|
+
error?: react_hook_form.FieldError;
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
formItemId: string;
|
|
18
|
+
formDescriptionId: string;
|
|
19
|
+
formMessageId: string;
|
|
20
|
+
};
|
|
21
|
+
declare function FormItem({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
22
|
+
declare function FormLabel({ className, ...props }: React.ComponentProps<typeof Label>): React.JSX.Element;
|
|
23
|
+
declare function FormControl({ render, children, ...props }: useRender.ComponentProps<'div'>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
24
|
+
declare function FormDescription({ className, ...props }: React.ComponentProps<'p'>): React.JSX.Element;
|
|
25
|
+
declare function FormMessage({ className, ...props }: React.ComponentProps<'p'>): React.JSX.Element | null;
|
|
26
|
+
|
|
27
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
|
package/dist/form.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// ../ui/src/shadcn/form.tsx
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import {
|
|
8
|
+
Controller,
|
|
9
|
+
FormProvider,
|
|
10
|
+
useFormContext,
|
|
11
|
+
useFormState
|
|
12
|
+
} from "react-hook-form";
|
|
13
|
+
|
|
14
|
+
// ../ui/src/lib/utils/cn.ts
|
|
15
|
+
import { clsx } from "clsx";
|
|
16
|
+
import { twMerge } from "tailwind-merge";
|
|
17
|
+
function cn(...inputs) {
|
|
18
|
+
return twMerge(clsx(inputs));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ../ui/src/shadcn/label.tsx
|
|
22
|
+
import { jsx } from "react/jsx-runtime";
|
|
23
|
+
function Label({ className, ...props }) {
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
"label",
|
|
26
|
+
{
|
|
27
|
+
"data-slot": "label",
|
|
28
|
+
className: cn(
|
|
29
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
30
|
+
className
|
|
31
|
+
),
|
|
32
|
+
...props
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ../ui/src/shadcn/form.tsx
|
|
38
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
39
|
+
var Form = FormProvider;
|
|
40
|
+
var FormFieldContext = React.createContext(
|
|
41
|
+
{}
|
|
42
|
+
);
|
|
43
|
+
var FormField = ({
|
|
44
|
+
...props
|
|
45
|
+
}) => {
|
|
46
|
+
return /* @__PURE__ */ jsx2(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx2(Controller, { ...props }) });
|
|
47
|
+
};
|
|
48
|
+
var useFormField = () => {
|
|
49
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
50
|
+
const itemContext = React.useContext(FormItemContext);
|
|
51
|
+
const { getFieldState } = useFormContext();
|
|
52
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
53
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
54
|
+
if (!fieldContext) {
|
|
55
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
56
|
+
}
|
|
57
|
+
const { id } = itemContext;
|
|
58
|
+
return {
|
|
59
|
+
id,
|
|
60
|
+
name: fieldContext.name,
|
|
61
|
+
formItemId: `${id}-form-item`,
|
|
62
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
63
|
+
formMessageId: `${id}-form-item-message`,
|
|
64
|
+
...fieldState
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
var FormItemContext = React.createContext(
|
|
68
|
+
{}
|
|
69
|
+
);
|
|
70
|
+
function FormItem({ className, ...props }) {
|
|
71
|
+
const id = React.useId();
|
|
72
|
+
return /* @__PURE__ */ jsx2(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx2(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
"data-slot": "form-item",
|
|
76
|
+
className: cn("grid gap-2", className),
|
|
77
|
+
...props
|
|
78
|
+
}
|
|
79
|
+
) });
|
|
80
|
+
}
|
|
81
|
+
function FormLabel({
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}) {
|
|
85
|
+
const { error, formItemId } = useFormField();
|
|
86
|
+
return /* @__PURE__ */ jsx2(
|
|
87
|
+
Label,
|
|
88
|
+
{
|
|
89
|
+
"data-slot": "form-label",
|
|
90
|
+
"data-error": !!error,
|
|
91
|
+
className: cn("data-[error=true]:text-destructive", className),
|
|
92
|
+
htmlFor: formItemId,
|
|
93
|
+
...props
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
function FormControl({
|
|
98
|
+
render,
|
|
99
|
+
children,
|
|
100
|
+
...props
|
|
101
|
+
}) {
|
|
102
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
103
|
+
const childAsRender = render ?? (React.isValidElement(children) ? children : void 0);
|
|
104
|
+
return useRender({
|
|
105
|
+
defaultTagName: "div",
|
|
106
|
+
render: childAsRender,
|
|
107
|
+
props: mergeProps(
|
|
108
|
+
{
|
|
109
|
+
"data-slot": "form-control",
|
|
110
|
+
id: formItemId,
|
|
111
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
112
|
+
"aria-invalid": !!error
|
|
113
|
+
},
|
|
114
|
+
childAsRender && !render ? props : { ...props, children }
|
|
115
|
+
)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function FormDescription({ className, ...props }) {
|
|
119
|
+
const { formDescriptionId } = useFormField();
|
|
120
|
+
return /* @__PURE__ */ jsx2(
|
|
121
|
+
"p",
|
|
122
|
+
{
|
|
123
|
+
"data-slot": "form-description",
|
|
124
|
+
id: formDescriptionId,
|
|
125
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
126
|
+
...props
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function FormMessage({ className, ...props }) {
|
|
131
|
+
const { error, formMessageId } = useFormField();
|
|
132
|
+
const body = error ? String(error?.message ?? "") : props.children;
|
|
133
|
+
if (!body) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return /* @__PURE__ */ jsx2(
|
|
137
|
+
"p",
|
|
138
|
+
{
|
|
139
|
+
"data-slot": "form-message",
|
|
140
|
+
id: formMessageId,
|
|
141
|
+
className: cn("text-destructive text-sm", className),
|
|
142
|
+
...props,
|
|
143
|
+
children: body
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
Form,
|
|
149
|
+
FormControl,
|
|
150
|
+
FormDescription,
|
|
151
|
+
FormField,
|
|
152
|
+
FormItem,
|
|
153
|
+
FormLabel,
|
|
154
|
+
FormMessage,
|
|
155
|
+
useFormField
|
|
156
|
+
};
|
package/dist/icon.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CSSProperties, ComponentType, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const FA_ICON_STYLES: readonly ["solid", "regular", "light", "duotone", "brands"];
|
|
5
|
+
type FaIconStyle = (typeof FA_ICON_STYLES)[number];
|
|
6
|
+
/**
|
|
7
|
+
* Styles a tenant can force across *every* icon. Brands is excluded — brand
|
|
8
|
+
* glyphs only exist in the brands family, so it's not a meaningful global
|
|
9
|
+
* family to render arbitrary icons in.
|
|
10
|
+
*/
|
|
11
|
+
declare const FA_OVERRIDE_STYLES: readonly ["solid", "regular", "light", "duotone"];
|
|
12
|
+
type FaIconOverrideStyle = (typeof FA_OVERRIDE_STYLES)[number];
|
|
13
|
+
/** True when a stored icon value is a Font Awesome class string. */
|
|
14
|
+
declare function isFaIcon(name: string | null | undefined): name is string;
|
|
15
|
+
/** Build the stored value for a picked Font Awesome icon. */
|
|
16
|
+
declare function buildFaIconValue(style: FaIconStyle, iconName: string): string;
|
|
17
|
+
|
|
18
|
+
type IconProps = {
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The shape every icon renders through. Exported so call sites that used to
|
|
24
|
+
* hold a `LucideIcon` component value (config maps, `icon` props) have a
|
|
25
|
+
* Font Awesome-native type to declare instead.
|
|
26
|
+
*/
|
|
27
|
+
type IconRenderer = ComponentType<IconProps>;
|
|
28
|
+
declare function IconStyleOverrideProvider({ value, children, }: {
|
|
29
|
+
value: FaIconOverrideStyle | null | undefined;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}): React.JSX.Element;
|
|
32
|
+
declare function useIconStyleOverride(): "solid" | "regular" | "light" | "duotone" | null;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a stored icon value to a component that accepts `{ className }`.
|
|
35
|
+
* Keeps the historical call signature so existing render sites
|
|
36
|
+
* (`const Icon = resolveIcon(name); <Icon className="h-4 w-4" />`) keep working.
|
|
37
|
+
* Legacy Lucide names are translated to Font Awesome; unknown names fall back.
|
|
38
|
+
*/
|
|
39
|
+
declare function resolveIcon(name: string): IconRenderer;
|
|
40
|
+
/** Ergonomic single-shot renderer for new code. */
|
|
41
|
+
declare function Icon({ name, className, style }: {
|
|
42
|
+
name: string;
|
|
43
|
+
} & IconProps): React.JSX.Element;
|
|
44
|
+
/** Render an icon by value, returning `null` for an empty name. */
|
|
45
|
+
declare function renderIcon(name: string | null | undefined, className?: string): React.JSX.Element | null;
|
|
46
|
+
|
|
47
|
+
export { FA_ICON_STYLES, FA_OVERRIDE_STYLES, type FaIconOverrideStyle, type FaIconStyle, Icon, type IconRenderer, IconStyleOverrideProvider, buildFaIconValue, isFaIcon, renderIcon, resolveIcon, useIconStyleOverride };
|