@you-agent-factory/components 0.0.0 → 0.0.2

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 (182) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +38 -7
  3. package/dist/category-paths.d.ts +3 -0
  4. package/dist/charts/chart-state-panel.d.ts +11 -0
  5. package/dist/charts/chart.d.ts +35 -0
  6. package/dist/charts/index.d.ts +5 -0
  7. package/dist/charts/index.js +287 -0
  8. package/dist/chunks/action-row.js +39 -0
  9. package/dist/chunks/alert-panel.js +182 -0
  10. package/dist/chunks/button.js +193 -0
  11. package/dist/chunks/cn.js +6 -0
  12. package/dist/chunks/factory-emulator-controls.js +123 -0
  13. package/dist/chunks/package-form-field.js +546 -0
  14. package/dist/chunks/scroll-area.js +261 -0
  15. package/dist/chunks/surface-panel.js +73 -0
  16. package/dist/chunks/table-layout.js +292 -0
  17. package/dist/chunks/typography-roles.js +26 -0
  18. package/dist/chunks/typography.js +129 -0
  19. package/dist/chunks/widget-frame.js +344 -0
  20. package/dist/data-display/code-panel.d.ts +12 -0
  21. package/dist/data-display/data-table.d.ts +27 -0
  22. package/dist/data-display/description-list.d.ts +4 -0
  23. package/{src/data-display/index.ts → dist/data-display/index.d.ts} +4 -26
  24. package/dist/data-display/index.js +20 -0
  25. package/dist/data-display/table-layout.d.ts +8 -0
  26. package/dist/data-display/table.d.ts +14 -0
  27. package/dist/factory-emulator/factory-emulator-controls.d.ts +23 -0
  28. package/dist/factory-emulator/index.d.ts +6 -0
  29. package/dist/factory-emulator/index.js +6 -0
  30. package/dist/feedback/alert-panel-semantics.d.ts +11 -0
  31. package/dist/feedback/alert-panel.d.ts +29 -0
  32. package/dist/feedback/index.d.ts +6 -0
  33. package/dist/feedback/index.js +10 -0
  34. package/dist/feedback/skeleton.d.ts +2 -0
  35. package/dist/forms/index.d.ts +19 -0
  36. package/dist/forms/index.js +37 -0
  37. package/dist/forms/package-checkbox.d.ts +3 -0
  38. package/dist/forms/package-enum-select.d.ts +42 -0
  39. package/dist/forms/package-file-input.d.ts +3 -0
  40. package/dist/forms/package-form-field.d.ts +49 -0
  41. package/dist/forms/package-input.d.ts +6 -0
  42. package/dist/forms/package-native-select.d.ts +3 -0
  43. package/dist/forms/package-select.d.ts +32 -0
  44. package/dist/forms/package-textarea.d.ts +10 -0
  45. package/dist/forms/select-icons.d.ts +3 -0
  46. package/dist/graphs/graph-edge-path.d.ts +18 -0
  47. package/dist/graphs/graph-edge.d.ts +15 -0
  48. package/dist/graphs/graph-node-button.d.ts +11 -0
  49. package/dist/graphs/graph-node-handle-badge.d.ts +5 -0
  50. package/dist/graphs/graph-node-handle.d.ts +18 -0
  51. package/dist/graphs/graph-node-shell.d.ts +13 -0
  52. package/dist/graphs/graph-node-state-indicator.d.ts +6 -0
  53. package/dist/graphs/graph-node-state.d.ts +23 -0
  54. package/dist/graphs/graph-viewport-surface.d.ts +5 -0
  55. package/dist/graphs/index.d.ts +13 -0
  56. package/dist/graphs/index.js +614 -0
  57. package/{src/icons/index.ts → dist/icons/index.d.ts} +1 -2
  58. package/dist/icons/index.js +4 -0
  59. package/dist/index.d.ts +26 -0
  60. package/dist/index.js +145 -0
  61. package/dist/layout/action-row.d.ts +8 -0
  62. package/{src/layout/index.ts → dist/layout/index.d.ts} +1 -3
  63. package/dist/layout/index.js +9 -0
  64. package/dist/layout/surface-panel.d.ts +15 -0
  65. package/{src/navigation/index.ts → dist/navigation/index.d.ts} +1 -2
  66. package/dist/navigation/index.js +4 -0
  67. package/dist/overlays/collapsible.d.ts +5 -0
  68. package/dist/overlays/dialog.d.ts +16 -0
  69. package/dist/overlays/index.d.ts +10 -0
  70. package/dist/overlays/index.js +27 -0
  71. package/dist/overlays/overlay-layout.d.ts +6 -0
  72. package/dist/overlays/popover.d.ts +6 -0
  73. package/dist/overlays/scroll-area.d.ts +9 -0
  74. package/dist/primitives/button-link.d.ts +5 -0
  75. package/dist/primitives/button.d.ts +9 -0
  76. package/dist/primitives/icon-button-shell.d.ts +10 -0
  77. package/{src/primitives/index.ts → dist/primitives/index.d.ts} +2 -19
  78. package/dist/primitives/index.js +49 -0
  79. package/dist/primitives/package-text.d.ts +6 -0
  80. package/dist/primitives/typography-roles.d.ts +12 -0
  81. package/dist/primitives/typography.d.ts +36 -0
  82. package/dist/recipes/index.d.ts +14 -0
  83. package/dist/recipes/index.js +32 -0
  84. package/dist/recipes/widget-frame-content.d.ts +24 -0
  85. package/dist/recipes/widget-frame-disclosure.d.ts +33 -0
  86. package/dist/recipes/widget-frame-layout.d.ts +12 -0
  87. package/dist/recipes/widget-frame-skeleton.d.ts +2 -0
  88. package/dist/recipes/widget-frame-states.d.ts +15 -0
  89. package/dist/recipes/widget-frame-typography.d.ts +10 -0
  90. package/dist/recipes/widget-frame.d.ts +12 -0
  91. package/{src → dist}/styles.css +36 -0
  92. package/dist/testing/index.d.ts +4 -0
  93. package/dist/testing/index.js +16 -0
  94. package/dist/testing/render.d.ts +5 -0
  95. package/{src/tokens/index.ts → dist/tokens/index.d.ts} +1 -2
  96. package/dist/tokens/index.js +4 -0
  97. package/dist/utilities/cn.d.ts +1 -0
  98. package/{src/utilities/index.ts → dist/utilities/index.d.ts} +1 -3
  99. package/dist/utilities/index.js +6 -0
  100. package/package.json +65 -64
  101. package/docs/README.md +0 -83
  102. package/docs/button.md +0 -119
  103. package/docs/charts.md +0 -325
  104. package/docs/data-display-code-panel.md +0 -120
  105. package/docs/feedback-alert-panel.md +0 -117
  106. package/docs/feedback-skeleton.md +0 -54
  107. package/docs/forms-form-field.md +0 -490
  108. package/docs/forms-input-primitives.md +0 -311
  109. package/docs/forms-select-primitives.md +0 -362
  110. package/docs/graphs.md +0 -250
  111. package/docs/layout-display-primitives.md +0 -211
  112. package/docs/overlays.md +0 -414
  113. package/docs/table-data-table.md +0 -331
  114. package/docs/typography-roles.md +0 -182
  115. package/docs/widget-frame-recipes.md +0 -273
  116. package/src/category-paths.ts +0 -20
  117. package/src/charts/chart-state-panel.tsx +0 -103
  118. package/src/charts/chart.tsx +0 -287
  119. package/src/charts/index.ts +0 -21
  120. package/src/data-display/code-panel.tsx +0 -67
  121. package/src/data-display/data-table.tsx +0 -180
  122. package/src/data-display/description-list.tsx +0 -24
  123. package/src/data-display/table-layout.ts +0 -12
  124. package/src/data-display/table.tsx +0 -131
  125. package/src/feedback/alert-panel-semantics.ts +0 -75
  126. package/src/feedback/alert-panel.tsx +0 -187
  127. package/src/feedback/index.ts +0 -21
  128. package/src/feedback/skeleton.tsx +0 -16
  129. package/src/forms/index.ts +0 -73
  130. package/src/forms/package-checkbox.tsx +0 -50
  131. package/src/forms/package-enum-select.tsx +0 -185
  132. package/src/forms/package-file-input.tsx +0 -25
  133. package/src/forms/package-form-field.tsx +0 -202
  134. package/src/forms/package-input.tsx +0 -25
  135. package/src/forms/package-native-select.tsx +0 -25
  136. package/src/forms/package-select.tsx +0 -209
  137. package/src/forms/package-textarea.tsx +0 -35
  138. package/src/forms/select-icons.tsx +0 -35
  139. package/src/graphs/graph-edge-path.ts +0 -241
  140. package/src/graphs/graph-edge.tsx +0 -130
  141. package/src/graphs/graph-interactive-example.tsx +0 -187
  142. package/src/graphs/graph-node-button.tsx +0 -51
  143. package/src/graphs/graph-node-handle-badge.tsx +0 -108
  144. package/src/graphs/graph-node-handle.ts +0 -28
  145. package/src/graphs/graph-node-shell.tsx +0 -111
  146. package/src/graphs/graph-node-state-indicator.tsx +0 -47
  147. package/src/graphs/graph-node-state.ts +0 -111
  148. package/src/graphs/graph-viewport-surface.tsx +0 -27
  149. package/src/graphs/index.ts +0 -41
  150. package/src/index.ts +0 -209
  151. package/src/layout/action-row.tsx +0 -53
  152. package/src/layout/surface-panel.tsx +0 -91
  153. package/src/overlays/collapsible.tsx +0 -22
  154. package/src/overlays/dialog.tsx +0 -148
  155. package/src/overlays/index.ts +0 -31
  156. package/src/overlays/overlay-layout.ts +0 -9
  157. package/src/overlays/popover.tsx +0 -29
  158. package/src/overlays/scroll-area.tsx +0 -78
  159. package/src/primitives/button-link.tsx +0 -22
  160. package/src/primitives/button.tsx +0 -258
  161. package/src/primitives/icon-button-shell.tsx +0 -49
  162. package/src/primitives/package-text.tsx +0 -29
  163. package/src/primitives/typography-roles.ts +0 -12
  164. package/src/primitives/typography.tsx +0 -165
  165. package/src/recipes/index.ts +0 -61
  166. package/src/recipes/widget-frame-content.tsx +0 -114
  167. package/src/recipes/widget-frame-disclosure.tsx +0 -161
  168. package/src/recipes/widget-frame-layout.ts +0 -40
  169. package/src/recipes/widget-frame-skeleton.tsx +0 -16
  170. package/src/recipes/widget-frame-states.tsx +0 -99
  171. package/src/recipes/widget-frame-typography.ts +0 -19
  172. package/src/recipes/widget-frame.tsx +0 -84
  173. package/src/testing/index.ts +0 -13
  174. package/src/testing/render.tsx +0 -16
  175. package/src/utilities/cn.ts +0 -5
  176. /package/{src → dist}/styles/color-palette-presets.css +0 -0
  177. /package/{src → dist}/styles/color-role-tokens.css +0 -0
  178. /package/{src → dist}/styles/layout-role-tokens.css +0 -0
  179. /package/{src → dist}/styles/text-color-role-tokens.css +0 -0
  180. /package/{src → dist}/styles/typography-role-tokens.css +0 -0
  181. /package/{src → dist}/styles/typography-role-utilities.css +0 -0
  182. /package/{src → dist}/styles/typography-roles.css +0 -0
@@ -1,16 +0,0 @@
1
- import type { HTMLAttributes } from "react";
2
-
3
- import { cn } from "../utilities/cn";
4
-
5
- export function Skeleton({
6
- className,
7
- ...props
8
- }: HTMLAttributes<HTMLDivElement>) {
9
- return (
10
- <div
11
- aria-hidden="true"
12
- className={cn("animate-pulse rounded-xl bg-af-overlay", className)}
13
- {...props}
14
- />
15
- );
16
- }
@@ -1,73 +0,0 @@
1
- /** Stable category path for `@you-agent-factory/components/forms`. */
2
- export const COMPONENTS_CATEGORY = "forms" as const;
3
-
4
- export type ComponentsCategory = typeof COMPONENTS_CATEGORY;
5
-
6
- export { PackageCheckbox } from "./package-checkbox";
7
- export type { PackageCheckboxProps } from "./package-checkbox";
8
- export {
9
- EnumSelect,
10
- ENUM_SELECT_EMPTY_VALUE,
11
- OptionalEnumSelect,
12
- ResetEnumSelect,
13
- } from "./package-enum-select";
14
- export type {
15
- EnumSelectOption,
16
- EnumSelectProps,
17
- OptionalEnumSelectProps,
18
- ResetEnumSelectProps,
19
- } from "./package-enum-select";
20
- export { PackageFileInput } from "./package-file-input";
21
- export type { PackageFileInputProps } from "./package-file-input";
22
- export { PackageInput, inputVariants } from "./package-input";
23
- export type { PackageInputProps } from "./package-input";
24
- export { NativeSelect } from "./package-native-select";
25
- export type { NativeSelectProps } from "./package-native-select";
26
- export {
27
- Select,
28
- SELECT_EMPTY_STATE_VALUE,
29
- SelectContent,
30
- SelectEmpty,
31
- SelectField,
32
- SelectGroup,
33
- SelectItem,
34
- SelectLabel,
35
- SelectSeparator,
36
- SelectTrigger,
37
- SelectValue,
38
- } from "./package-select";
39
- export type {
40
- SelectContentProps,
41
- SelectEmptyProps,
42
- SelectFieldProps,
43
- SelectItemProps,
44
- SelectLabelProps,
45
- SelectSeparatorProps,
46
- SelectTriggerProps,
47
- } from "./package-select";
48
- export { PackageTextarea, textareaVariants } from "./package-textarea";
49
- export type { PackageTextareaProps } from "./package-textarea";
50
- export {
51
- buildFormFieldAriaDescribedBy,
52
- FormDescription,
53
- FormError,
54
- FormField,
55
- FormFieldGroup,
56
- FormFieldGroupLabel,
57
- FormHelperText,
58
- FormLabel,
59
- FormSuccess,
60
- FormWarning,
61
- } from "./package-form-field";
62
- export type {
63
- FormDescriptionProps,
64
- FormErrorProps,
65
- FormFieldGroupLabelProps,
66
- FormFieldGroupProps,
67
- FormFieldMessageIds,
68
- FormFieldProps,
69
- FormHelperTextProps,
70
- FormLabelProps,
71
- FormSuccessProps,
72
- FormWarningProps,
73
- } from "./package-form-field";
@@ -1,50 +0,0 @@
1
- import { forwardRef, type InputHTMLAttributes } from "react";
2
-
3
- import { cn } from "../utilities/cn";
4
-
5
- export type PackageCheckboxProps = Omit<
6
- InputHTMLAttributes<HTMLInputElement>,
7
- "type"
8
- >;
9
-
10
- const CHECKBOX_ROOT_CLASS =
11
- "relative inline-flex size-4 shrink-0 items-center justify-center [&:has(:disabled)]:cursor-not-allowed";
12
-
13
- function CheckboxCheckIcon() {
14
- return (
15
- <svg
16
- aria-hidden="true"
17
- className="size-3 opacity-0"
18
- fill="none"
19
- stroke="currentColor"
20
- strokeLinecap="round"
21
- strokeLinejoin="round"
22
- strokeWidth={2.5}
23
- viewBox="0 0 24 24"
24
- >
25
- <path d="M20 6 9 17l-5-5" />
26
- </svg>
27
- );
28
- }
29
-
30
- export const PackageCheckbox = forwardRef<
31
- HTMLInputElement,
32
- PackageCheckboxProps
33
- >(function PackageCheckbox({ className, ...props }, ref) {
34
- return (
35
- <span className={cn(CHECKBOX_ROOT_CLASS, className)}>
36
- <input
37
- className="peer sr-only"
38
- ref={ref}
39
- type="checkbox"
40
- {...props}
41
- />
42
- <span
43
- aria-hidden="true"
44
- className="pointer-events-none flex size-4 items-center justify-center rounded border border-outline bg-surface-container-high text-on-primary transition-colors peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-af-focus-ring peer-disabled:border-outline peer-disabled:bg-surface-container-low peer-checked:border-primary peer-checked:bg-primary peer-aria-invalid:ring-2 peer-aria-invalid:ring-af-danger-border peer-checked:[&_svg]:opacity-100"
45
- >
46
- <CheckboxCheckIcon />
47
- </span>
48
- </span>
49
- );
50
- });
@@ -1,185 +0,0 @@
1
- import { type ComponentProps, useState } from "react";
2
-
3
- import {
4
- Select,
5
- SELECT_EMPTY_STATE_VALUE,
6
- SelectContent,
7
- SelectEmpty,
8
- SelectItem,
9
- SelectTrigger,
10
- SelectValue,
11
- } from "./package-select";
12
-
13
- export const ENUM_SELECT_EMPTY_VALUE = "__enum-select-empty__";
14
-
15
- export interface EnumSelectOption {
16
- disabled?: boolean;
17
- label: string;
18
- value: string;
19
- }
20
-
21
- type EnumSelectAriaProps = Pick<
22
- ComponentProps<typeof SelectTrigger>,
23
- "aria-describedby" | "aria-invalid" | "aria-label" | "aria-labelledby"
24
- >;
25
-
26
- export interface EnumSelectProps extends EnumSelectAriaProps {
27
- className?: string;
28
- disabled?: boolean;
29
- emptyOptionsLabel?: string;
30
- id: string;
31
- loading?: boolean;
32
- loadingLabel?: string;
33
- onValueChange: (value: string) => void;
34
- options: readonly EnumSelectOption[];
35
- placeholder?: string;
36
- value: string;
37
- }
38
-
39
- export function EnumSelect({
40
- className,
41
- disabled,
42
- emptyOptionsLabel = "No options available",
43
- id,
44
- loading = false,
45
- loadingLabel = "Loading options...",
46
- onValueChange,
47
- options,
48
- placeholder,
49
- value,
50
- ...aria
51
- }: EnumSelectProps) {
52
- const isEmpty = !loading && options.length === 0;
53
- const resolvedPlaceholder = loading ? loadingLabel : placeholder;
54
-
55
- return (
56
- <Select
57
- disabled={disabled || loading}
58
- onValueChange={onValueChange}
59
- value={loading ? SELECT_EMPTY_STATE_VALUE : value}
60
- >
61
- <SelectTrigger
62
- aria-busy={loading || undefined}
63
- className={className}
64
- id={id}
65
- {...aria}
66
- >
67
- <SelectValue placeholder={resolvedPlaceholder} />
68
- </SelectTrigger>
69
- <SelectContent>
70
- {loading ? (
71
- <SelectEmpty>{loadingLabel}</SelectEmpty>
72
- ) : isEmpty ? (
73
- <SelectEmpty>{emptyOptionsLabel}</SelectEmpty>
74
- ) : (
75
- options.map((option) => (
76
- <SelectItem
77
- disabled={option.disabled}
78
- key={option.value}
79
- value={option.value}
80
- >
81
- {option.label}
82
- </SelectItem>
83
- ))
84
- )}
85
- </SelectContent>
86
- </Select>
87
- );
88
- }
89
-
90
- export interface OptionalEnumSelectProps extends EnumSelectAriaProps {
91
- className?: string;
92
- disabled?: boolean;
93
- emptyOptionLabel: string;
94
- id: string;
95
- onValueChange: (value: string | null) => void;
96
- options: readonly EnumSelectOption[];
97
- value: string | null | undefined;
98
- }
99
-
100
- export function OptionalEnumSelect({
101
- className,
102
- disabled,
103
- emptyOptionLabel,
104
- id,
105
- onValueChange,
106
- options,
107
- value,
108
- ...aria
109
- }: OptionalEnumSelectProps) {
110
- return (
111
- <Select
112
- disabled={disabled}
113
- onValueChange={(nextValue) =>
114
- onValueChange(nextValue === ENUM_SELECT_EMPTY_VALUE ? null : nextValue)
115
- }
116
- value={value ?? ENUM_SELECT_EMPTY_VALUE}
117
- >
118
- <SelectTrigger className={className} id={id} {...aria}>
119
- <SelectValue placeholder={emptyOptionLabel} />
120
- </SelectTrigger>
121
- <SelectContent>
122
- <SelectItem value={ENUM_SELECT_EMPTY_VALUE}>
123
- {emptyOptionLabel}
124
- </SelectItem>
125
- {options.map((option) => (
126
- <SelectItem
127
- disabled={option.disabled}
128
- key={option.value}
129
- value={option.value}
130
- >
131
- {option.label}
132
- </SelectItem>
133
- ))}
134
- </SelectContent>
135
- </Select>
136
- );
137
- }
138
-
139
- export interface ResetEnumSelectProps extends EnumSelectAriaProps {
140
- className?: string;
141
- disabled?: boolean;
142
- id: string;
143
- onValueChange: (value: string) => void;
144
- options: readonly EnumSelectOption[];
145
- placeholder: string;
146
- }
147
-
148
- export function ResetEnumSelect({
149
- className,
150
- disabled,
151
- id,
152
- onValueChange,
153
- options,
154
- placeholder,
155
- ...aria
156
- }: ResetEnumSelectProps) {
157
- const [instanceKey, setInstanceKey] = useState(0);
158
-
159
- return (
160
- <Select
161
- key={instanceKey}
162
- disabled={disabled}
163
- onValueChange={(nextValue) => {
164
- onValueChange(nextValue);
165
- setInstanceKey((current) => current + 1);
166
- }}
167
- value={undefined}
168
- >
169
- <SelectTrigger className={className} id={id} {...aria}>
170
- <SelectValue placeholder={placeholder} />
171
- </SelectTrigger>
172
- <SelectContent>
173
- {options.map((option) => (
174
- <SelectItem
175
- disabled={option.disabled}
176
- key={option.value}
177
- value={option.value}
178
- >
179
- {option.label}
180
- </SelectItem>
181
- ))}
182
- </SelectContent>
183
- </Select>
184
- );
185
- }
@@ -1,25 +0,0 @@
1
- import { forwardRef, type InputHTMLAttributes } from "react";
2
-
3
- import { cn } from "../utilities/cn";
4
-
5
- export type PackageFileInputProps = Omit<
6
- InputHTMLAttributes<HTMLInputElement>,
7
- "type"
8
- >;
9
-
10
- const FILE_INPUT_CLASS =
11
- "block w-full rounded-xl px-3 py-3 text-sm text-on-surface-variant outline-none focus-visible:ring-2 focus-visible:ring-af-focus-ring file:mr-3 file:rounded-lg file:border-0 file:bg-surface-container-high file:px-3 file:py-2 file:text-sm file:font-semibold file:text-on-surface hover:bg-af-overlay aria-invalid:border-af-danger-border aria-invalid:ring-2 aria-invalid:ring-af-danger-border disabled:cursor-not-allowed disabled:bg-surface-container-low disabled:text-on-surface-disabled";
12
-
13
- export const PackageFileInput = forwardRef<
14
- HTMLInputElement,
15
- PackageFileInputProps
16
- >(function PackageFileInput({ className, ...props }, ref) {
17
- return (
18
- <input
19
- className={cn(FILE_INPUT_CLASS, className)}
20
- ref={ref}
21
- type="file"
22
- {...props}
23
- />
24
- );
25
- });
@@ -1,202 +0,0 @@
1
- import {
2
- type ElementType,
3
- forwardRef,
4
- type FieldsetHTMLAttributes,
5
- type HTMLAttributes,
6
- type ReactNode,
7
- } from "react";
8
-
9
- import { cn } from "../utilities/cn";
10
-
11
- export type FormFieldMessageIds = {
12
- descriptionId?: string;
13
- helperId?: string;
14
- warningId?: string;
15
- errorId?: string;
16
- successId?: string;
17
- };
18
-
19
- export function buildFormFieldAriaDescribedBy(
20
- messageIds: FormFieldMessageIds,
21
- ): string | undefined {
22
- const ids = [
23
- messageIds.descriptionId,
24
- messageIds.helperId,
25
- messageIds.warningId,
26
- messageIds.errorId,
27
- messageIds.successId,
28
- ].filter((id): id is string => Boolean(id));
29
-
30
- return ids.length > 0 ? ids.join(" ") : undefined;
31
- }
32
-
33
- export type FormFieldProps = HTMLAttributes<HTMLDivElement>;
34
-
35
- export const FormField = forwardRef<HTMLDivElement, FormFieldProps>(
36
- function FormField({ className, ...props }, ref) {
37
- return <div className={cn("space-y-2", className)} ref={ref} {...props} />;
38
- },
39
- );
40
-
41
- export type FormLabelProps = HTMLAttributes<HTMLElement> & {
42
- as?: ElementType;
43
- children?: ReactNode;
44
- htmlFor?: string;
45
- };
46
-
47
- const FORM_LABEL_CLASS = "block text-sm font-semibold text-on-surface";
48
-
49
- export const FormLabel = forwardRef<HTMLElement, FormLabelProps>(
50
- function FormLabel({ as: Component = "label", className, ...props }, ref) {
51
- return (
52
- <Component
53
- className={cn(FORM_LABEL_CLASS, className)}
54
- ref={ref}
55
- {...props}
56
- />
57
- );
58
- },
59
- );
60
-
61
- export interface FormDescriptionProps extends HTMLAttributes<HTMLElement> {
62
- as?: ElementType;
63
- variant?: "body" | "supporting";
64
- }
65
-
66
- const FORM_BODY_TEXT_CLASS = "m-0 text-body-medium text-on-surface";
67
- const FORM_SUPPORTING_TEXT_CLASS =
68
- "m-0 text-body-small text-on-surface-variant";
69
-
70
- export const FormDescription = forwardRef<HTMLElement, FormDescriptionProps>(
71
- function FormDescription(
72
- { as: Component = "p", className, variant = "supporting", ...props },
73
- ref,
74
- ) {
75
- return (
76
- <Component
77
- className={cn(
78
- variant === "body" ? FORM_BODY_TEXT_CLASS : FORM_SUPPORTING_TEXT_CLASS,
79
- className,
80
- )}
81
- ref={ref}
82
- {...props}
83
- />
84
- );
85
- },
86
- );
87
-
88
- export interface FormHelperTextProps extends HTMLAttributes<HTMLElement> {
89
- as?: ElementType;
90
- }
91
-
92
- export const FormHelperText = forwardRef<HTMLElement, FormHelperTextProps>(
93
- function FormHelperText(
94
- { as: Component = "p", className, ...props },
95
- ref,
96
- ) {
97
- return (
98
- <Component
99
- className={cn(FORM_SUPPORTING_TEXT_CLASS, className)}
100
- ref={ref}
101
- {...props}
102
- />
103
- );
104
- },
105
- );
106
-
107
- export interface FormErrorProps extends HTMLAttributes<HTMLElement> {
108
- as?: ElementType;
109
- role?: "alert" | "status";
110
- }
111
-
112
- export const FormError = forwardRef<HTMLElement, FormErrorProps>(
113
- function FormError(
114
- { as: Component = "p", className, role = "alert", ...props },
115
- ref,
116
- ) {
117
- return (
118
- <Component
119
- className={cn(
120
- "m-0 text-body-small font-medium text-on-error-container",
121
- className,
122
- )}
123
- ref={ref}
124
- role={role}
125
- {...props}
126
- />
127
- );
128
- },
129
- );
130
-
131
- export interface FormWarningProps extends HTMLAttributes<HTMLElement> {
132
- as?: ElementType;
133
- role?: "alert" | "status";
134
- }
135
-
136
- export const FormWarning = forwardRef<HTMLElement, FormWarningProps>(
137
- function FormWarning(
138
- { as: Component = "p", className, role, ...props },
139
- ref,
140
- ) {
141
- return (
142
- <Component
143
- className={cn(
144
- "m-0 text-body-small font-medium text-on-warning-container",
145
- className,
146
- )}
147
- ref={ref}
148
- role={role}
149
- {...props}
150
- />
151
- );
152
- },
153
- );
154
-
155
- export interface FormSuccessProps extends HTMLAttributes<HTMLElement> {
156
- as?: ElementType;
157
- role?: "alert" | "status";
158
- }
159
-
160
- export const FormSuccess = forwardRef<HTMLElement, FormSuccessProps>(
161
- function FormSuccess(
162
- { as: Component = "p", className, role = "status", ...props },
163
- ref,
164
- ) {
165
- return (
166
- <Component
167
- className={cn(
168
- "m-0 text-body-small font-medium text-on-success-container",
169
- className,
170
- )}
171
- ref={ref}
172
- role={role}
173
- {...props}
174
- />
175
- );
176
- },
177
- );
178
-
179
- export type FormFieldGroupProps = FieldsetHTMLAttributes<HTMLFieldSetElement>;
180
-
181
- export const FormFieldGroup = forwardRef<HTMLFieldSetElement, FormFieldGroupProps>(
182
- function FormFieldGroup({ className, ...props }, ref) {
183
- return (
184
- <fieldset
185
- className={cn("m-0 space-y-2 border-0 p-0", className)}
186
- ref={ref}
187
- {...props}
188
- />
189
- );
190
- },
191
- );
192
-
193
- export type FormFieldGroupLabelProps = HTMLAttributes<HTMLLegendElement>;
194
-
195
- export const FormFieldGroupLabel = forwardRef<
196
- HTMLLegendElement,
197
- FormFieldGroupLabelProps
198
- >(function FormFieldGroupLabel({ className, ...props }, ref) {
199
- return (
200
- <legend className={cn(FORM_LABEL_CLASS, "px-0", className)} ref={ref} {...props} />
201
- );
202
- });
@@ -1,25 +0,0 @@
1
- import { forwardRef, type InputHTMLAttributes } from "react";
2
-
3
- import { cn } from "../utilities/cn";
4
-
5
- export type PackageInputProps = InputHTMLAttributes<HTMLInputElement>;
6
-
7
- const INPUT_CLASS =
8
- "flex min-h-11 w-full rounded-xl border border-outline bg-surface-container-high px-3 py-2.5 text-sm text-on-surface outline-none transition-colors placeholder:text-on-surface-disabled focus-visible:border-outline-variant focus-visible:ring-2 focus-visible:ring-af-focus-ring aria-invalid:border-af-danger-border aria-invalid:ring-2 aria-invalid:ring-af-danger-border disabled:cursor-not-allowed disabled:border-outline disabled:bg-surface-container-low disabled:text-on-surface-disabled";
9
-
10
- export function inputVariants({ className }: { className?: string } = {}) {
11
- return cn(INPUT_CLASS, className);
12
- }
13
-
14
- export const PackageInput = forwardRef<HTMLInputElement, PackageInputProps>(
15
- function PackageInput({ className, type = "text", ...props }, ref) {
16
- return (
17
- <input
18
- className={inputVariants({ className })}
19
- ref={ref}
20
- type={type}
21
- {...props}
22
- />
23
- );
24
- },
25
- );
@@ -1,25 +0,0 @@
1
- import { forwardRef, type SelectHTMLAttributes } from "react";
2
-
3
- import { inputVariants } from "./package-input";
4
- import { SelectChevronDownIcon } from "./select-icons";
5
-
6
- export type NativeSelectProps = SelectHTMLAttributes<HTMLSelectElement>;
7
-
8
- export const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
9
- function NativeSelect({ children, className, ...props }, ref) {
10
- return (
11
- <div className="relative">
12
- <select
13
- className={inputVariants({
14
- className: `appearance-none pr-10 ${className ?? ""}`,
15
- })}
16
- ref={ref}
17
- {...props}
18
- >
19
- {children}
20
- </select>
21
- <SelectChevronDownIcon className="pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-af-text-subtle" />
22
- </div>
23
- );
24
- },
25
- );