untitledui 0.1.2 → 0.1.3
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/index.mjs +19 -0
- package/package.json +10 -8
- package/templates/default/package.json +20 -21
- package/templates/default/src/app/home-screen.tsx +2 -3
- package/templates/default/src/app/layout.tsx +5 -13
- package/templates/default/src/components/marketing/header-navigation/dropdown-header-navigation.tsx +1 -1
- package/templates/default/src/components/shared/buttons/button.tsx +2 -1
- package/templates/default/src/components/shared/dropdown/dropdown.tsx +27 -18
- package/templates/default/src/components/shared/form/hook-form.tsx +75 -0
- package/templates/default/src/components/shared/{inputs/input → input}/index.tsx +3 -3
- package/templates/default/src/components/shared/{inputs/input → input}/input-payment.tsx +4 -4
- package/templates/default/src/components/shared/{inputs/input → input}/input-with-button.tsx +4 -4
- package/templates/default/src/components/shared/{inputs/input → input}/input-with-dropdown.tsx +4 -4
- package/templates/default/src/components/shared/{inputs/input → input}/input-with-prefix.tsx +4 -4
- package/templates/default/src/components/shared/progress-indicators/progress-indicators.tsx +2 -2
- package/templates/default/src/components/shared/{input-dropdown → select}/combobox.tsx +9 -9
- package/templates/default/src/components/shared/{input-dropdown → select}/multi-select.tsx +166 -166
- package/templates/default/src/components/shared/{input-dropdown → select}/popover.tsx +2 -2
- package/templates/default/src/components/shared/select/select-item.tsx +70 -0
- package/templates/default/src/components/shared/{input-dropdown/select.tsx → select/select-native.tsx} +2 -2
- package/templates/default/src/components/shared/select/select.tsx +143 -0
- package/templates/default/src/components/shared/slider/slider.tsx +2 -2
- package/templates/default/src/components/shared/{inputs/textarea → textarea}/textarea.tsx +2 -2
- package/templates/default/src/providers/theme.tsx +1 -1
- package/templates/default/src/styles/globals.css +3 -1
- package/templates/default/src/styles/theme.css +392 -380
- package/templates/default/src/styles/typography.css +20 -20
- package/dist/commands/add.js +0 -339
- package/dist/commands/init.js +0 -436
- package/dist/helper/download-tar-api.js +0 -129
- package/dist/helper/download-tar.js +0 -81
- package/dist/helper/find-css-file.js +0 -19
- package/dist/helper/formatText.js +0 -37
- package/dist/helper/get-components-api.js +0 -47
- package/dist/helper/get-components-list.js +0 -62
- package/dist/helper/get-components.js +0 -19
- package/dist/helper/get-config.js +0 -163
- package/dist/helper/get-package-info.js +0 -99
- package/dist/helper/get-pkg-manager.js +0 -16
- package/dist/helper/get-project.js +0 -176
- package/dist/helper/install-template.js +0 -29
- package/dist/helper/match-color-css.js +0 -82
- package/dist/helper/update-color-css.js +0 -134
- package/dist/index.js +0 -25
- package/dist/package.json +0 -50
- package/dist/res/components.json +0 -520
- package/dist/res/config.json +0 -3
- package/templates/default/src/components/shared/input-dropdown/dropdown-item.tsx +0 -98
- package/templates/default/src/components/shared/input-dropdown/input-dropdown.tsx +0 -172
- package/templates/default/src/fonts/GeistMonoVF.woff +0 -0
- package/templates/default/src/fonts/GeistVF.woff +0 -0
- package/templates/default/src/styles/colors.css +0 -805
- /package/templates/default/src/components/shared/{inputs → file-upload-trigger}/file-upload-trigger.tsx +0 -0
- /package/templates/default/src/components/shared/{inputs/form → form}/form.tsx +0 -0
- /package/templates/default/src/components/shared/{inputs → input}/hint-text.tsx +0 -0
- /package/templates/default/src/components/shared/{inputs → input}/label.tsx +0 -0
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { ReactNode, Ref, RefAttributes } from "react";
|
|
4
|
-
import { createContext } from "react";
|
|
5
|
-
import { ChevronDown, User01 } from "@untitledui/icons";
|
|
6
|
-
import type { SelectProps as AriaSelectProps } from "react-aria-components";
|
|
7
|
-
import { Button as AriaButton, ListBox as AriaListBox, Select as AriaSelect, SelectValue as AriaSelectValue } from "react-aria-components";
|
|
8
|
-
import Dot from "@/components/foundations/dot-icon";
|
|
9
|
-
import { cx } from "@/components/utils";
|
|
10
|
-
import Avatar from "../avatar/avatar";
|
|
11
|
-
import type { IconComponentType } from "../badges/badge-types";
|
|
12
|
-
import HintText from "../inputs/hint-text";
|
|
13
|
-
import Label from "../inputs/label";
|
|
14
|
-
import { ComboBox } from "./combobox";
|
|
15
|
-
import type { ListBoxItemIconProps } from "./dropdown-item";
|
|
16
|
-
import Item from "./dropdown-item";
|
|
17
|
-
import { Popover } from "./popover";
|
|
18
|
-
|
|
19
|
-
export type SelectValueType = {
|
|
20
|
-
label: string;
|
|
21
|
-
value: string;
|
|
22
|
-
avatarUrl?: string;
|
|
23
|
-
isDisabled?: boolean;
|
|
24
|
-
supportingText?: string;
|
|
25
|
-
icon?: IconComponentType;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type Types = "default" | "iconLeading" | "avatarLeading" | "dotLeading" | "search" | "tags";
|
|
29
|
-
type SelectTypes = "default" | "iconLeading" | "avatarLeading" | "dotLeading";
|
|
30
|
-
|
|
31
|
-
export interface CommonProps {
|
|
32
|
-
hint?: string;
|
|
33
|
-
label?: string;
|
|
34
|
-
tooltip?: string;
|
|
35
|
-
size?: "sm" | "md";
|
|
36
|
-
placeholder?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface SelectProps extends Omit<AriaSelectProps<SelectValueType>, "children" | "items">, RefAttributes<HTMLDivElement>, CommonProps {
|
|
40
|
-
type?: SelectTypes;
|
|
41
|
-
items?: SelectValueType[];
|
|
42
|
-
popoverClassName?: string;
|
|
43
|
-
placeholderIcon?: IconComponentType;
|
|
44
|
-
children: ReactNode | ((item: SelectValueType) => ReactNode);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface SelectValueProps {
|
|
48
|
-
isOpen: boolean;
|
|
49
|
-
size: "sm" | "md";
|
|
50
|
-
type: SelectTypes;
|
|
51
|
-
isFocused: boolean;
|
|
52
|
-
isDisabled: boolean;
|
|
53
|
-
placeholder?: string;
|
|
54
|
-
ref?: Ref<HTMLButtonElement>;
|
|
55
|
-
placeholderIcon?: IconComponentType;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const sizes = {
|
|
59
|
-
sm: { root: "py-2 px-3", shortcut: "pr-2.5" },
|
|
60
|
-
md: { root: "py-2.5 px-3.5", shortcut: "pr-3" },
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const selectIcons = {
|
|
64
|
-
default: () => <></>,
|
|
65
|
-
avatarLeading: ({ isDisabled }: ListBoxItemIconProps) => (
|
|
66
|
-
<User01 aria-hidden="true" className={cx("size-5 shrink-0 text-fg-quaternary", isDisabled && "text-fg-disabled")} />
|
|
67
|
-
),
|
|
68
|
-
iconLeading: ({ icon: Icon = User01, isDisabled }: ListBoxItemIconProps) => (
|
|
69
|
-
<Icon aria-hidden="true" className={cx("size-5 shrink-0 text-fg-quaternary", isDisabled && "text-fg-disabled")} />
|
|
70
|
-
),
|
|
71
|
-
dotLeading: ({ icon: Icon, isDisabled }: ListBoxItemIconProps) =>
|
|
72
|
-
Icon ? (
|
|
73
|
-
<Icon aria-hidden="true" className={cx("flex size-min shrink-0 text-fg-success-secondary", isDisabled && "text-fg-disabled_subtle")} />
|
|
74
|
-
) : (
|
|
75
|
-
<Dot size="md" className={cx("flex size-min shrink-0 text-fg-success-secondary", isDisabled && "text-fg-disabled_subtle")} />
|
|
76
|
-
),
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const SelectValue = (props: SelectValueProps) => {
|
|
80
|
-
const Icon = selectIcons[props.type];
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<AriaButton
|
|
84
|
-
className={cx(
|
|
85
|
-
"relative flex w-full cursor-pointer items-center rounded-lg bg-primary shadow-xs ring-1 ring-border-primary outline-hidden transition duration-100 ease-linear ring-inset",
|
|
86
|
-
(props.isFocused || props.isOpen) && "ring-2 ring-border-brand",
|
|
87
|
-
props.isDisabled && "cursor-not-allowed bg-disabled_subtle text-disabled",
|
|
88
|
-
)}
|
|
89
|
-
>
|
|
90
|
-
<AriaSelectValue<SelectValueType>
|
|
91
|
-
className={cx("flex h-max w-full items-center justify-start gap-2 truncate text-left align-middle", sizes[props.size].root)}
|
|
92
|
-
>
|
|
93
|
-
{(state) => (
|
|
94
|
-
<>
|
|
95
|
-
{state?.selectedItem?.avatarUrl ? (
|
|
96
|
-
<Avatar size="xs" src={state.selectedItem.avatarUrl} alt={state.selectedItem.label} />
|
|
97
|
-
) : (
|
|
98
|
-
<Icon {...state?.selectedItem} icon={state?.selectedItem?.icon || props.placeholderIcon} {...props} />
|
|
99
|
-
)}
|
|
100
|
-
|
|
101
|
-
{state.selectedItem ? (
|
|
102
|
-
<section className="flex w-full gap-2 truncate">
|
|
103
|
-
<p className="truncate tt-md-md text-primary">{state.selectedItem?.label}</p>
|
|
104
|
-
{state.selectedItem?.supportingText && <p className="tt-md text-tertiary">{state.selectedItem?.supportingText}</p>}
|
|
105
|
-
</section>
|
|
106
|
-
) : (
|
|
107
|
-
<p className={cx("tt-md text-placeholder", props.isDisabled && "text-disabled")}>{props.placeholder}</p>
|
|
108
|
-
)}
|
|
109
|
-
|
|
110
|
-
<ChevronDown size={20} aria-hidden="true" className="ml-auto shrink-0 text-fg-quaternary" />
|
|
111
|
-
</>
|
|
112
|
-
)}
|
|
113
|
-
</AriaSelectValue>
|
|
114
|
-
</AriaButton>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const SelectContext = createContext<{ type: Types; size: "sm" | "md" }>({ type: "default", size: "sm" });
|
|
119
|
-
|
|
120
|
-
export const Select = ({
|
|
121
|
-
type = "default",
|
|
122
|
-
placeholder = "Select",
|
|
123
|
-
placeholderIcon,
|
|
124
|
-
size = "sm",
|
|
125
|
-
children,
|
|
126
|
-
items,
|
|
127
|
-
label,
|
|
128
|
-
hint,
|
|
129
|
-
tooltip,
|
|
130
|
-
...rest
|
|
131
|
-
}: SelectProps) => {
|
|
132
|
-
const itemsWithId = items?.map((item) => ({ ...item, id: item.value }));
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<SelectContext.Provider value={{ type, size }}>
|
|
136
|
-
<AriaSelect {...rest}>
|
|
137
|
-
{(state) => (
|
|
138
|
-
<div className="flex flex-col gap-1.5">
|
|
139
|
-
{label && (
|
|
140
|
-
<Label isRequired={state.isRequired} tooltip={tooltip}>
|
|
141
|
-
{label}
|
|
142
|
-
</Label>
|
|
143
|
-
)}
|
|
144
|
-
|
|
145
|
-
<SelectValue
|
|
146
|
-
{...state}
|
|
147
|
-
{...{ type, size, placeholder }}
|
|
148
|
-
placeholderIcon={type === "avatarLeading" || type === "iconLeading" ? placeholderIcon || User01 : undefined}
|
|
149
|
-
/>
|
|
150
|
-
|
|
151
|
-
<Popover size={size} className={rest.popoverClassName}>
|
|
152
|
-
<AriaListBox items={itemsWithId} className="size-full outline-hidden">
|
|
153
|
-
{children}
|
|
154
|
-
</AriaListBox>
|
|
155
|
-
</Popover>
|
|
156
|
-
|
|
157
|
-
{hint && <HintText isInvalid={state.isInvalid}>{hint}</HintText>}
|
|
158
|
-
</div>
|
|
159
|
-
)}
|
|
160
|
-
</AriaSelect>
|
|
161
|
-
</SelectContext.Provider>
|
|
162
|
-
);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const InputDropdown = Select as typeof Select & {
|
|
166
|
-
ComboBox: typeof ComboBox;
|
|
167
|
-
Item: typeof Item;
|
|
168
|
-
};
|
|
169
|
-
InputDropdown.ComboBox = ComboBox;
|
|
170
|
-
InputDropdown.Item = Item;
|
|
171
|
-
|
|
172
|
-
export { InputDropdown };
|
|
Binary file
|
|
Binary file
|