untitledui 0.1.2 → 0.1.4

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.
Files changed (88) hide show
  1. package/dist/index.mjs +19 -0
  2. package/package.json +10 -8
  3. package/templates/default/package.json +20 -21
  4. package/templates/default/src/app/home-screen.tsx +3 -4
  5. package/templates/default/src/app/layout.tsx +6 -14
  6. package/templates/default/src/components/foundations/featured-icon/featured-icons.tsx +1 -1
  7. package/templates/default/src/components/marketing/header-navigation/base-components/nav-menu-item.tsx +1 -1
  8. package/templates/default/src/components/marketing/header-navigation/components/header.tsx +1 -1
  9. package/templates/default/src/components/marketing/header-navigation/dropdown-header-navigation.tsx +1 -1
  10. package/templates/default/src/components/shared/avatar/avatar-label-group.tsx +1 -1
  11. package/templates/default/src/components/shared/avatar/avatar-profile-photo.tsx +1 -1
  12. package/templates/default/src/components/shared/avatar/avatar.tsx +1 -1
  13. package/templates/default/src/components/shared/avatar/base-components/avatar-add-button.tsx +1 -1
  14. package/templates/default/src/components/shared/avatar/base-components/avatar-company-icon.tsx +1 -1
  15. package/templates/default/src/components/shared/avatar/base-components/avatar-online-indicator.tsx +1 -1
  16. package/templates/default/src/components/shared/avatar/base-components/verified-tick.tsx +1 -1
  17. package/templates/default/src/components/shared/badges/badge-groups.tsx +1 -1
  18. package/templates/default/src/components/shared/badges/badges.tsx +1 -1
  19. package/templates/default/src/components/shared/button-group/button-group.tsx +1 -1
  20. package/templates/default/src/components/shared/buttons/app-store-buttons-outline.tsx +1 -1
  21. package/templates/default/src/components/shared/buttons/app-store-buttons.tsx +1 -1
  22. package/templates/default/src/components/shared/buttons/button-utility.tsx +1 -1
  23. package/templates/default/src/components/shared/buttons/button.tsx +3 -2
  24. package/templates/default/src/components/shared/buttons/close-button.tsx +1 -1
  25. package/templates/default/src/components/shared/buttons/social-button.tsx +1 -1
  26. package/templates/default/src/components/shared/checkbox/checkbox.tsx +1 -1
  27. package/templates/default/src/components/shared/dropdown/dropdown.tsx +28 -19
  28. package/templates/default/src/components/shared/form/hook-form.tsx +75 -0
  29. package/templates/default/src/components/shared/{inputs → input}/hint-text.tsx +1 -1
  30. package/templates/default/src/components/shared/{inputs/input → input}/index.tsx +4 -4
  31. package/templates/default/src/components/shared/{inputs/input → input}/input-payment.tsx +5 -5
  32. package/templates/default/src/components/shared/{inputs/input → input}/input-with-button.tsx +5 -5
  33. package/templates/default/src/components/shared/{inputs/input → input}/input-with-dropdown.tsx +5 -5
  34. package/templates/default/src/components/shared/{inputs/input → input}/input-with-prefix.tsx +5 -5
  35. package/templates/default/src/components/shared/{inputs → input}/label.tsx +1 -1
  36. package/templates/default/src/components/shared/progress-indicators/progress-circles.tsx +1 -1
  37. package/templates/default/src/components/shared/progress-indicators/progress-indicators.tsx +1 -1
  38. package/templates/default/src/components/shared/radio-buttons/radio-buttons.tsx +1 -1
  39. package/templates/default/src/components/shared/radio-groups/radio-group-avatar.tsx +1 -1
  40. package/templates/default/src/components/shared/radio-groups/radio-group-checkbox.tsx +1 -1
  41. package/templates/default/src/components/shared/radio-groups/radio-group-icon-card.tsx +1 -1
  42. package/templates/default/src/components/shared/radio-groups/radio-group-icon-simple.tsx +1 -1
  43. package/templates/default/src/components/shared/radio-groups/radio-group-payment-icon.tsx +1 -1
  44. package/templates/default/src/components/shared/radio-groups/radio-group-radio-button.tsx +1 -1
  45. package/templates/default/src/components/shared/{input-dropdown → select}/combobox.tsx +10 -10
  46. package/templates/default/src/components/shared/{input-dropdown → select}/multi-select.tsx +167 -167
  47. package/templates/default/src/components/shared/{input-dropdown → select}/popover.tsx +3 -3
  48. package/templates/default/src/components/shared/select/select-item.tsx +70 -0
  49. package/templates/default/src/components/shared/{input-dropdown/select.tsx → select/select-native.tsx} +2 -2
  50. package/templates/default/src/components/shared/select/select.tsx +143 -0
  51. package/templates/default/src/components/shared/slider/slider.tsx +1 -1
  52. package/templates/default/src/components/shared/tags/base-components/tag-checkbox.tsx +1 -1
  53. package/templates/default/src/components/shared/tags/base-components/tag-close-x.tsx +1 -1
  54. package/templates/default/src/components/shared/tags/tags.tsx +1 -1
  55. package/templates/default/src/components/shared/{inputs/textarea → textarea}/textarea.tsx +3 -3
  56. package/templates/default/src/components/shared/toggle/toggle.tsx +1 -1
  57. package/templates/default/src/components/shared/tooltips/tooltips.tsx +1 -1
  58. package/templates/default/src/providers/theme.tsx +1 -1
  59. package/templates/default/src/styles/globals.css +3 -1
  60. package/templates/default/src/styles/theme.css +392 -380
  61. package/templates/default/src/styles/typography.css +20 -20
  62. package/dist/commands/add.js +0 -339
  63. package/dist/commands/init.js +0 -436
  64. package/dist/helper/download-tar-api.js +0 -129
  65. package/dist/helper/download-tar.js +0 -81
  66. package/dist/helper/find-css-file.js +0 -19
  67. package/dist/helper/formatText.js +0 -37
  68. package/dist/helper/get-components-api.js +0 -47
  69. package/dist/helper/get-components-list.js +0 -62
  70. package/dist/helper/get-components.js +0 -19
  71. package/dist/helper/get-config.js +0 -163
  72. package/dist/helper/get-package-info.js +0 -99
  73. package/dist/helper/get-pkg-manager.js +0 -16
  74. package/dist/helper/get-project.js +0 -176
  75. package/dist/helper/install-template.js +0 -29
  76. package/dist/helper/match-color-css.js +0 -82
  77. package/dist/helper/update-color-css.js +0 -134
  78. package/dist/index.js +0 -25
  79. package/dist/package.json +0 -50
  80. package/dist/res/components.json +0 -520
  81. package/dist/res/config.json +0 -3
  82. package/templates/default/src/components/shared/input-dropdown/dropdown-item.tsx +0 -98
  83. package/templates/default/src/components/shared/input-dropdown/input-dropdown.tsx +0 -172
  84. package/templates/default/src/fonts/GeistMonoVF.woff +0 -0
  85. package/templates/default/src/fonts/GeistVF.woff +0 -0
  86. package/templates/default/src/styles/colors.css +0 -805
  87. /package/templates/default/src/components/shared/{inputs → file-upload-trigger}/file-upload-trigger.tsx +0 -0
  88. /package/templates/default/src/components/shared/{inputs/form → form}/form.tsx +0 -0
@@ -0,0 +1,75 @@
1
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
2
+ import { createContext, useContext, useId } from "react";
3
+ import { Form as AriaForm } from "react-aria-components";
4
+ import type { Control, FieldPath, FieldValues, UseControllerReturn, UseFormReturn } from "react-hook-form";
5
+ import { FormProvider, useController, useFormContext } from "react-hook-form";
6
+
7
+ interface FormProps<TFieldValues extends FieldValues = FieldValues> extends ComponentPropsWithoutRef<typeof AriaForm> {
8
+ form: UseFormReturn<TFieldValues>;
9
+ children: ReactNode;
10
+ }
11
+
12
+ interface FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
13
+ name: TName;
14
+ control: Control<TFieldValues>;
15
+ children: ReactNode | ((control: UseControllerReturn<TFieldValues, TName>) => ReactNode);
16
+ }
17
+
18
+ interface FormFieldContextValues<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
19
+ id: string;
20
+ name: TName;
21
+ control?: UseControllerReturn<TFieldValues, TName>;
22
+ }
23
+
24
+ const FormFieldContext = createContext<FormFieldContextValues>({} as FormFieldContextValues);
25
+
26
+ export const useFormFieldContext = () => {
27
+ const context = useContext(FormFieldContext);
28
+ const { getFieldState, formState } = useFormContext();
29
+ const fieldState = getFieldState(context.name, formState);
30
+
31
+ if (!context) {
32
+ throw new Error("The 'useFormContext' hook must be used within a '<FormField />'");
33
+ }
34
+
35
+ return { ...context, ...fieldState };
36
+ };
37
+
38
+ export const HookForm = <TFieldValues extends FieldValues = FieldValues>({ form, ...props }: FormProps<TFieldValues>) => {
39
+ return (
40
+ <FormProvider {...form}>
41
+ <AriaForm {...props} />
42
+ </FormProvider>
43
+ );
44
+ };
45
+
46
+ HookForm.displayName = "HookForm";
47
+
48
+ export const FormField = <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
49
+ children,
50
+ ...props
51
+ }: FormFieldProps<TFieldValues, TName>) => {
52
+ const id = "form-item-" + useId();
53
+ const control = useController(props);
54
+ const withValidationBehavior = {
55
+ ...control,
56
+ field: {
57
+ ...control.field,
58
+ validationBehavior: "aria",
59
+ },
60
+ };
61
+
62
+ return (
63
+ <FormFieldContext.Provider
64
+ value={{
65
+ id,
66
+ name: props.name,
67
+ control: control as UseControllerReturn<FieldValues, TName>,
68
+ }}
69
+ >
70
+ {children && (typeof children === "function" ? children(withValidationBehavior) : children)}
71
+ </FormFieldContext.Provider>
72
+ );
73
+ };
74
+
75
+ FormField.displayName = "FormField";
@@ -3,7 +3,7 @@
3
3
  import type { ReactNode, Ref } from "react";
4
4
  import type { TextProps as AriaTextProps } from "react-aria-components";
5
5
  import { Text as AriaText } from "react-aria-components";
6
- import { cx } from "@/components/utils";
6
+ import { cx } from "@/components/utils/cx";
7
7
 
8
8
  interface HintTextProps extends AriaTextProps {
9
9
  children: ReactNode;
@@ -4,10 +4,10 @@ import type { ComponentType, HTMLAttributes, ReactNode, Ref } from "react";
4
4
  import { HelpCircle, InfoCircle } from "@untitledui/icons";
5
5
  import type { TextFieldProps as AriaTextFieldProps } from "react-aria-components";
6
6
  import { Input as AriaInput, TextField as AriaTextField, Group } from "react-aria-components";
7
- import HintText from "@/components/shared/inputs/hint-text";
8
- import Label from "@/components/shared/inputs/label";
7
+ import HintText from "@/components/shared/input/hint-text";
8
+ import Label from "@/components/shared/input/label";
9
9
  import { Tooltip, TooltipTrigger } from "@/components/shared/tooltips/tooltips";
10
- import { cx, sortCx } from "@/components/utils";
10
+ import { cx, sortCx } from "@/components/utils/cx";
11
11
 
12
12
  export interface InputBaseProps extends TextFieldProps {
13
13
  label?: string;
@@ -130,7 +130,7 @@ export const InputBase = ({ size = "sm", placeholder, icon: Icon, isDisabled, is
130
130
  )}
131
131
  aria-hidden="true"
132
132
  >
133
- {shortcut || "⌘K"}
133
+ {typeof shortcut === "string" ? shortcut : "⌘K"}
134
134
  </span>
135
135
  </div>
136
136
  )}
@@ -3,11 +3,11 @@
3
3
  import React, { useState } from "react";
4
4
  import { TextField } from "react-aria-components";
5
5
  import { AmexIcon, DiscoverIcon, MastercardIcon, UnionPayIcon, VisaIcon } from "@/components/foundations/payment-icons";
6
- import HintText from "@/components/shared/inputs/hint-text";
7
- import type { InputBaseProps } from "@/components/shared/inputs/input";
8
- import { InputBase } from "@/components/shared/inputs/input";
9
- import Label from "@/components/shared/inputs/label";
10
- import { cx } from "@/components/utils";
6
+ import type { InputBaseProps } from "@/components/shared/input";
7
+ import { InputBase } from "@/components/shared/input";
8
+ import HintText from "@/components/shared/input/hint-text";
9
+ import Label from "@/components/shared/input/label";
10
+ import { cx } from "@/components/utils/cx";
11
11
 
12
12
  const cardTypes = [
13
13
  {
@@ -6,11 +6,11 @@ import { Copy01 } from "@untitledui/icons";
6
6
  import { TextField } from "react-aria-components";
7
7
  import type { CommonProps } from "@/components/shared/buttons/button";
8
8
  import Button from "@/components/shared/buttons/button";
9
- import HintText from "@/components/shared/inputs/hint-text";
10
- import type { InputBaseProps } from "@/components/shared/inputs/input";
11
- import { InputBase } from "@/components/shared/inputs/input";
12
- import Label from "@/components/shared/inputs/label";
13
- import { cx } from "@/components/utils";
9
+ import type { InputBaseProps } from "@/components/shared/input";
10
+ import { InputBase } from "@/components/shared/input";
11
+ import HintText from "@/components/shared/input/hint-text";
12
+ import Label from "@/components/shared/input/label";
13
+ import { cx } from "@/components/utils/cx";
14
14
 
15
15
  interface InputWithButtonProps extends Omit<InputBaseProps, "icon"> {
16
16
  buttonText: string;
@@ -4,11 +4,11 @@ import React from "react";
4
4
  import { ChevronDown } from "@untitledui/icons";
5
5
  import type { Key } from "react-aria-components";
6
6
  import { TextField } from "react-aria-components";
7
- import HintText from "@/components/shared/inputs/hint-text";
8
- import type { InputBaseProps } from "@/components/shared/inputs/input";
9
- import { InputBase } from "@/components/shared/inputs/input";
10
- import Label from "@/components/shared/inputs/label";
11
- import { cx, sortCx } from "@/components/utils";
7
+ import type { InputBaseProps } from "@/components/shared/input";
8
+ import { InputBase } from "@/components/shared/input";
9
+ import HintText from "@/components/shared/input/hint-text";
10
+ import Label from "@/components/shared/input/label";
11
+ import { cx, sortCx } from "@/components/utils/cx";
12
12
 
13
13
  interface SelectorComponentProps {
14
14
  size: "sm" | "md";
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
 
3
3
  import type { HTMLAttributes } from "react";
4
- import HintText from "@/components/shared/inputs/hint-text";
5
- import type { InputBaseProps } from "@/components/shared/inputs/input";
6
- import { InputBase, TextField } from "@/components/shared/inputs/input";
7
- import Label from "@/components/shared/inputs/label";
8
- import { cx } from "@/components/utils";
4
+ import type { InputBaseProps } from "@/components/shared/input";
5
+ import { InputBase, TextField } from "@/components/shared/input";
6
+ import HintText from "@/components/shared/input/hint-text";
7
+ import Label from "@/components/shared/input/label";
8
+ import { cx } from "@/components/utils/cx";
9
9
 
10
10
  interface InputPrefixProps extends HTMLAttributes<HTMLDivElement> {
11
11
  position?: "leading" | "trailing";
@@ -5,7 +5,7 @@ import { HelpCircle } from "@untitledui/icons";
5
5
  import type { LabelProps as AriaLabelProps } from "react-aria-components";
6
6
  import { Label as AriaLabel } from "react-aria-components";
7
7
  import { Tooltip, TooltipTrigger } from "@/components/shared/tooltips/tooltips";
8
- import { cx } from "@/components/utils";
8
+ import { cx } from "@/components/utils/cx";
9
9
 
10
10
  interface LabelProps extends AriaLabelProps {
11
11
  children: ReactNode;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { cx as clx, sortCx } from "@/components/utils";
3
+ import { cx as clx, sortCx } from "@/components/utils/cx";
4
4
 
5
5
  interface ProgressBarProps {
6
6
  value: number;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { cx } from "@/components/utils";
3
+ import { cx } from "@/components/utils/cx";
4
4
 
5
5
  export interface ProgressBarProps {
6
6
  value: number;
@@ -3,7 +3,7 @@
3
3
  import { type ReactNode, type Ref, createContext, useContext } from "react";
4
4
  import type { RadioGroupProps as AriaRadioGroupProps } from "react-aria-components";
5
5
  import { type RadioProps as AriaRadioProps, Radio, RadioGroup } from "react-aria-components";
6
- import { cx } from "@/components/utils";
6
+ import { cx } from "@/components/utils/cx";
7
7
 
8
8
  export interface RadioButtonGroupContextType {
9
9
  size?: "sm" | "md";
@@ -4,7 +4,7 @@ import type { RadioGroupProps } from "react-aria-components";
4
4
  import { Label, Radio, RadioGroup, Text } from "react-aria-components";
5
5
  import AvatarComponent from "@/components/shared/avatar/avatar";
6
6
  import { CheckboxBase } from "@/components/shared/checkbox/checkbox";
7
- import { cx } from "@/components/utils";
7
+ import { cx } from "@/components/utils/cx";
8
8
 
9
9
  interface AvatarItemType {
10
10
  id: string;
@@ -4,7 +4,7 @@ import type { FC } from "react";
4
4
  import type { RadioGroupProps } from "react-aria-components";
5
5
  import { Label, Radio, RadioGroup, Text } from "react-aria-components";
6
6
  import { CheckboxBase } from "@/components/shared/checkbox/checkbox";
7
- import { cx } from "@/components/utils";
7
+ import { cx } from "@/components/utils/cx";
8
8
 
9
9
  type RadioGroupItemType = {
10
10
  value: string;
@@ -6,7 +6,7 @@ import { Radio, RadioGroup } from "react-aria-components";
6
6
  import { FeaturedIcon } from "@/components/foundations/featured-icon/featured-icons";
7
7
  import { BadgeWithDot } from "@/components/shared/badges/badges";
8
8
  import { CheckboxBase } from "@/components/shared/checkbox/checkbox";
9
- import { cx } from "@/components/utils";
9
+ import { cx } from "@/components/utils/cx";
10
10
 
11
11
  type IconCardItemType = {
12
12
  value: string;
@@ -5,7 +5,7 @@ import type { RadioGroupProps } from "react-aria-components";
5
5
  import { Label, Radio, RadioGroup, Text } from "react-aria-components";
6
6
  import { FeaturedIcon } from "@/components/foundations/featured-icon/featured-icons";
7
7
  import { CheckboxBase } from "@/components/shared/checkbox/checkbox";
8
- import { cx } from "@/components/utils";
8
+ import { cx } from "@/components/utils/cx";
9
9
 
10
10
  type RadioGroupItemType = {
11
11
  value: string;
@@ -5,7 +5,7 @@ import type { RadioGroupProps } from "react-aria-components";
5
5
  import { Label, Radio, RadioGroup, Text } from "react-aria-components";
6
6
  import Button from "@/components/shared/buttons/button";
7
7
  import { CheckboxBase } from "@/components/shared/checkbox/checkbox";
8
- import { cx } from "@/components/utils";
8
+ import { cx } from "@/components/utils/cx";
9
9
 
10
10
  interface PaymentCardItemType {
11
11
  value: string;
@@ -3,7 +3,7 @@
3
3
  import type { FC } from "react";
4
4
  import type { RadioGroupProps } from "react-aria-components";
5
5
  import { Label, Radio, RadioGroup, Text } from "react-aria-components";
6
- import { cx } from "@/components/utils";
6
+ import { cx } from "@/components/utils/cx";
7
7
 
8
8
  type RadioGroupItemType = {
9
9
  value: string;
@@ -13,23 +13,23 @@ import {
13
13
  ComboBoxStateContext,
14
14
  } from "react-aria-components";
15
15
  import { useHotkeys } from "react-hotkeys-hook";
16
- import { cx } from "@/components/utils";
16
+ import { cx } from "@/components/utils/cx";
17
17
  import { useResizeObserver } from "@/hooks/use-resize-observer";
18
- import HintText from "../inputs/hint-text";
19
- import Label from "../inputs/label";
20
- import { type CommonProps, SelectContext, type SelectValueType, sizes } from "./input-dropdown";
18
+ import HintText from "../input/hint-text";
19
+ import Label from "../input/label";
21
20
  import { ComboBoxTagsValue } from "./multi-select";
22
21
  import { Popover } from "./popover";
22
+ import { type CommonProps, SelectContext, type SelectItemType, sizes } from "./select";
23
23
 
24
24
  type ComboBoxTypes = "search" | "tags";
25
25
 
26
- interface ComboBoxProps extends Omit<AriaComboBoxProps<SelectValueType>, "children" | "items">, RefAttributes<HTMLDivElement>, CommonProps {
26
+ interface ComboBoxProps extends Omit<AriaComboBoxProps<SelectItemType>, "children" | "items">, RefAttributes<HTMLDivElement>, CommonProps {
27
27
  shortcut?: boolean;
28
28
  type?: ComboBoxTypes;
29
- items?: SelectValueType[];
29
+ items?: SelectItemType[];
30
30
  popoverClassName?: string;
31
31
  shortcutClassName?: string;
32
- children: AriaListBoxProps<SelectValueType>["children"];
32
+ children: AriaListBoxProps<SelectItemType>["children"];
33
33
  }
34
34
 
35
35
  interface ComboBoxValueProps extends RefAttributes<HTMLDivElement> {
@@ -109,8 +109,6 @@ export const ComboBox = ({ type = "search", placeholder = "Select", shortcut = t
109
109
  const placeholderRef = useRef<HTMLDivElement>(null);
110
110
  const [popoverWidth, setPopoverWidth] = useState("");
111
111
 
112
- const itemsWithId = items?.map((item) => ({ ...item, id: item.value }));
113
-
114
112
  // Resize observer for popover width
115
113
  const onResize = useCallback(() => {
116
114
  if (!placeholderRef.current) return;
@@ -149,7 +147,9 @@ export const ComboBox = ({ type = "search", placeholder = "Select", shortcut = t
149
147
  />
150
148
 
151
149
  <Popover size={size} triggerRef={placeholderRef} style={{ width: popoverWidth }} className={rest.popoverClassName}>
152
- <AriaListBox {...{ items: itemsWithId, children }} className="size-full outline-hidden" />
150
+ <AriaListBox items={items} className="size-full outline-hidden">
151
+ {children}
152
+ </AriaListBox>
153
153
  </Popover>
154
154
 
155
155
  {rest.hint && <HintText isInvalid={state.isInvalid}>{rest.hint}</HintText>}