@cryptlex/web-components 5.2.0 → 5.3.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.
Files changed (121) hide show
  1. package/dist/components/data-table/data-table-filter.d.ts +27 -0
  2. package/dist/components/data-table/data-table-filter.js +112 -0
  3. package/dist/components/data-table/data-table.d.ts +73 -0
  4. package/dist/components/data-table/data-table.js +265 -0
  5. package/dist/components/data-table/table-commons.d.ts +56 -0
  6. package/dist/components/data-table/table-commons.js +137 -0
  7. package/dist/components/inputs/checkbox.d.ts +8 -0
  8. package/dist/components/inputs/checkbox.js +25 -0
  9. package/dist/components/inputs/date-picker.d.ts +11 -0
  10. package/dist/components/inputs/date-picker.js +22 -0
  11. package/dist/components/inputs/datefield.d.ts +14 -0
  12. package/dist/components/inputs/datefield.js +25 -0
  13. package/dist/components/inputs/field.d.ts +21 -0
  14. package/dist/components/inputs/field.js +48 -0
  15. package/dist/components/inputs/id-search.d.ts +20 -0
  16. package/dist/components/inputs/id-search.js +40 -0
  17. package/dist/components/inputs/input-otp.d.ts +8 -0
  18. package/dist/components/inputs/input-otp.js +19 -0
  19. package/dist/components/inputs/multi-select.d.ts +17 -0
  20. package/dist/components/inputs/multi-select.js +18 -0
  21. package/dist/components/inputs/numberfield.d.ts +7 -0
  22. package/dist/components/inputs/numberfield.js +25 -0
  23. package/dist/components/inputs/searchfield.d.ts +5 -0
  24. package/dist/components/inputs/searchfield.js +24 -0
  25. package/dist/components/inputs/select-options.d.ts +8 -0
  26. package/dist/components/inputs/select-options.js +286 -0
  27. package/dist/components/inputs/select.d.ts +17 -0
  28. package/dist/components/inputs/select.js +34 -0
  29. package/dist/components/inputs/textfield.d.ts +7 -0
  30. package/dist/components/inputs/textfield.js +28 -0
  31. package/dist/components/key-value-card/key-value-card.d.ts +17 -0
  32. package/dist/components/key-value-card/key-value-card.js +40 -0
  33. package/dist/components/ui/alert.d.ts +8 -0
  34. package/dist/components/ui/alert.js +18 -0
  35. package/dist/components/ui/avatar.d.ts +8 -0
  36. package/dist/components/ui/avatar.js +5 -0
  37. package/dist/components/ui/badge.d.ts +2 -0
  38. package/dist/components/ui/badge.js +5 -0
  39. package/dist/components/ui/breadcrumbs.d.ts +10 -0
  40. package/dist/components/ui/breadcrumbs.js +28 -0
  41. package/dist/components/ui/button.d.ts +11 -0
  42. package/dist/components/ui/button.js +34 -0
  43. package/dist/components/ui/calendar.d.ts +17 -0
  44. package/dist/components/ui/calendar.js +63 -0
  45. package/dist/components/ui/card.d.ts +7 -0
  46. package/dist/components/ui/card.js +20 -0
  47. package/dist/components/ui/dialog.d.ts +19 -0
  48. package/dist/components/ui/dialog.js +42 -0
  49. package/dist/components/ui/disclosure.d.ts +19 -0
  50. package/dist/components/ui/disclosure.js +20 -0
  51. package/dist/components/ui/list-box.d.ts +5 -0
  52. package/dist/components/ui/list-box.js +24 -0
  53. package/dist/components/ui/loader.d.ts +5 -0
  54. package/dist/components/ui/loader.js +6 -0
  55. package/dist/components/ui/menu.d.ts +25 -0
  56. package/dist/components/ui/menu.js +38 -0
  57. package/dist/components/ui/popover.d.ts +4 -0
  58. package/dist/components/ui/popover.js +14 -0
  59. package/dist/components/ui/sidebar.d.ts +53 -0
  60. package/dist/components/ui/sidebar.js +177 -0
  61. package/dist/components/ui/skeleton.d.ts +1 -0
  62. package/dist/components/ui/skeleton.js +5 -0
  63. package/dist/components/ui/sonner.d.ts +4 -0
  64. package/dist/components/ui/sonner.js +14 -0
  65. package/dist/components/ui/table.d.ts +9 -0
  66. package/dist/components/ui/table.js +26 -0
  67. package/dist/components/ui/tabs.d.ts +5 -0
  68. package/dist/components/ui/tabs.js +25 -0
  69. package/dist/components/ui/timeline.d.ts +15 -0
  70. package/dist/components/ui/timeline.js +31 -0
  71. package/dist/components/ui/tooltip.d.ts +4 -0
  72. package/dist/components/ui/tooltip.js +12 -0
  73. package/dist/utils/form-context.d.ts +4 -0
  74. package/{lib/utils/form-context.tsx → dist/utils/form-context.js} +1 -3
  75. package/dist/utils/form-hook.d.ts +25 -0
  76. package/{lib/utils/form-hook.tsx → dist/utils/form-hook.js} +15 -18
  77. package/dist/utils/primitives.d.ts +30 -0
  78. package/{lib/utils/primitives.ts → dist/utils/primitives.js} +8 -37
  79. package/dist/utils/resource-names.d.ts +23 -0
  80. package/{lib/utils/resource-names.tsx → dist/utils/resource-names.js} +42 -75
  81. package/dist/utils/use-mobile.d.ts +1 -0
  82. package/dist/utils/use-mobile.js +15 -0
  83. package/package.json +10 -5
  84. package/lib/components/data-table/data-table-filter.tsx +0 -220
  85. package/lib/components/data-table/data-table.tsx +0 -593
  86. package/lib/components/data-table/table-commons.tsx +0 -233
  87. package/lib/components/inputs/checkbox.tsx +0 -72
  88. package/lib/components/inputs/date-picker.tsx +0 -130
  89. package/lib/components/inputs/datefield.tsx +0 -109
  90. package/lib/components/inputs/field.tsx +0 -106
  91. package/lib/components/inputs/id-search.tsx +0 -83
  92. package/lib/components/inputs/input-otp.tsx +0 -63
  93. package/lib/components/inputs/multi-select.tsx +0 -62
  94. package/lib/components/inputs/numberfield.tsx +0 -110
  95. package/lib/components/inputs/searchfield.tsx +0 -87
  96. package/lib/components/inputs/select-options.tsx +0 -303
  97. package/lib/components/inputs/select.tsx +0 -140
  98. package/lib/components/inputs/textfield.tsx +0 -96
  99. package/lib/components/key-value-card/key-value-card.tsx +0 -115
  100. package/lib/components/ui/alert.tsx +0 -32
  101. package/lib/components/ui/avatar.tsx +0 -22
  102. package/lib/components/ui/badge.tsx +0 -19
  103. package/lib/components/ui/breadcrumbs.tsx +0 -104
  104. package/lib/components/ui/button.tsx +0 -66
  105. package/lib/components/ui/calendar.tsx +0 -220
  106. package/lib/components/ui/card.tsx +0 -58
  107. package/lib/components/ui/dialog.tsx +0 -172
  108. package/lib/components/ui/disclosure.tsx +0 -113
  109. package/lib/components/ui/list-box.tsx +0 -86
  110. package/lib/components/ui/loader.tsx +0 -10
  111. package/lib/components/ui/menu.tsx +0 -168
  112. package/lib/components/ui/popover.tsx +0 -37
  113. package/lib/components/ui/sidebar.tsx +0 -552
  114. package/lib/components/ui/skeleton.tsx +0 -7
  115. package/lib/components/ui/sonner.tsx +0 -26
  116. package/lib/components/ui/table.tsx +0 -79
  117. package/lib/components/ui/tabs.tsx +0 -82
  118. package/lib/components/ui/timeline.tsx +0 -52
  119. package/lib/components/ui/tooltip.tsx +0 -30
  120. package/lib/tokens.scss +0 -89
  121. package/lib/utils/use-mobile.tsx +0 -21
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createColumnHelper } from "@tanstack/react-table";
3
+ import { Checkbox } from "lib/components/inputs/checkbox";
4
+ const cH = createColumnHelper();
5
+ export const TABLE_CHECK_BOX_COLUMN = [
6
+ cH.accessor("checkbox", {
7
+ header: ({ table }) => (_jsx(Checkbox, { isIndeterminate: table.getIsSomeRowsSelected() && !table.getIsAllPageRowsSelected(), isSelected: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected(), onChange: () => table.toggleAllPageRowsSelected(), "aria-label": "Select all" })),
8
+ cell: ({ row }) => (_jsx(Checkbox, { isSelected: row.getIsSelected(), onChange: () => row.toggleSelected(), "aria-label": "Select row" })),
9
+ enableSorting: false,
10
+ enableHiding: false,
11
+ }),
12
+ ];
13
+ export const TABLE_ID_COLUMN = [
14
+ cH.accessor("id", {
15
+ header: () => "ID",
16
+ }),
17
+ ];
18
+ export const TABLE_DEFAULT_DATE_COLUMNS = [
19
+ cH.accessor("createdAt", {
20
+ header: () => "Creation Date",
21
+ cell: ({ row }) => {
22
+ const date = row.getValue("createdAt");
23
+ return formatDate(date);
24
+ },
25
+ enableHiding: false,
26
+ }),
27
+ cH.accessor("updatedAt", {
28
+ header: () => "Last Updated",
29
+ cell: ({ row }) => {
30
+ const date = row.getValue("updatedAt");
31
+ return formatDate(date);
32
+ },
33
+ enableHiding: false,
34
+ }),
35
+ ];
36
+ // TODO, i18n
37
+ export function formatDate(date) {
38
+ if (!date)
39
+ return null;
40
+ const _date = new Date(date);
41
+ return new Intl.DateTimeFormat(undefined, {
42
+ dateStyle: "medium",
43
+ timeStyle: "short",
44
+ }).format(_date);
45
+ }
46
+ /**
47
+ * Format multiple license parameters (expired, suspended, revoked) into a single status
48
+ */
49
+ export function getLicenseStatus(license) {
50
+ const licenseExpired = license.expiresAt && new Date(license.expiresAt) < new Date();
51
+ // Status Column
52
+ switch (true) {
53
+ case license.revoked && license.suspended && licenseExpired:
54
+ return "Revoked, Suspended, Expired";
55
+ case license.revoked && license.suspended:
56
+ return "Revoked, Suspended";
57
+ case license.revoked && licenseExpired:
58
+ return "Revoked, Expired";
59
+ case license.suspended && licenseExpired:
60
+ return "Suspended, Expired";
61
+ case license.suspended:
62
+ return "Suspended";
63
+ case license.revoked:
64
+ return "Revoked";
65
+ case licenseExpired:
66
+ return "Expired";
67
+ default:
68
+ return "Active";
69
+ }
70
+ }
71
+ export function getValidityDisplay(validity) {
72
+ if (validity === 0 || !validity) {
73
+ return "Lifetime";
74
+ }
75
+ else {
76
+ return secondsToDuration(validity);
77
+ }
78
+ }
79
+ export function secondsToDuration(seconds) {
80
+ //@ts-ignore
81
+ const duration = intervalToDuration({
82
+ start: 0,
83
+ end: seconds * 1000,
84
+ });
85
+ const parts = [
86
+ duration.years && `${duration.years}y`,
87
+ duration.months && `${duration.months}m`,
88
+ duration.days && `${duration.days}d`,
89
+ duration.hours && `${duration.hours}h`,
90
+ ];
91
+ // Filter out undefined values and join
92
+ return parts.filter(Boolean).join(" ").trim();
93
+ }
94
+ export function getValueFromData(data, accessor) {
95
+ const accessors = accessor.toString().split(".");
96
+ let value = data;
97
+ for (const acc of accessors) {
98
+ value = value?.[acc];
99
+ }
100
+ return value;
101
+ }
102
+ export const ALL_OS = {
103
+ windows: "Windows",
104
+ macos: "macOS",
105
+ linux: "Linux",
106
+ ios: "iOS",
107
+ android: "Android",
108
+ };
109
+ export function createTableFetchFn(ctxclient, path) {
110
+ return async (pagination, sorting, searching, filters) => {
111
+ const query = {
112
+ ...filters,
113
+ page: pagination.pageIndex + 1,
114
+ limit: pagination.pageSize,
115
+ sort: generateSortParam(sorting[0]),
116
+ search: searching,
117
+ };
118
+ // const pathParams = merge(_baseQueryObject, params);
119
+ return ctxclient.GET(path, { query }).then((value) => {
120
+ const rowCount = Number.parseInt(value.response.headers.get("Pagination-Count") || "0");
121
+ return { total: rowCount, data: value.data };
122
+ });
123
+ };
124
+ }
125
+ function generateSortParam(sort) {
126
+ if (sort) {
127
+ if (sort.desc) {
128
+ return `-${sort.id}`;
129
+ }
130
+ else {
131
+ return `+${sort.id}`;
132
+ }
133
+ }
134
+ else {
135
+ return "-createdAt";
136
+ }
137
+ }
@@ -0,0 +1,8 @@
1
+ import { type CheckboxProps as AriaCheckboxProps } from "react-aria-components";
2
+ import { type FormFieldProps } from "lib/components/inputs/field";
3
+ export declare const CheckboxGroup: (props: import("react-aria-components").CheckboxGroupProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
4
+ type CheckboxProps = AriaCheckboxProps & FormFieldProps;
5
+ export declare function Checkbox({ className, label, description, errorMessage, ...props }: Omit<CheckboxProps, 'children'>): import("react/jsx-runtime").JSX.Element;
6
+ export type TfCheckboxProps = Omit<React.ComponentProps<typeof Checkbox>, "onChange" | "onBlur" | "isChecked">;
7
+ export declare function TfCheckbox({ ...props }: TfCheckboxProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Checkbox as AriaCheckbox, CheckboxGroup as AriaCheckboxGroup, composeRenderProps } from "react-aria-components";
3
+ import { FormField, labelVariants } from "lib/components/inputs/field";
4
+ import { useFieldContext } from "lib/utils/form-context";
5
+ import { cn } from "lib/utils/primitives";
6
+ import { Check, Minus } from "lucide-react";
7
+ export const CheckboxGroup = AriaCheckboxGroup;
8
+ export function Checkbox({ className, label, description, errorMessage, ...props }) {
9
+ return (_jsx("div", { className: "group form-field", children: _jsx(FormField, { label: label, description: description, errorMessage: errorMessage, children: _jsx(AriaCheckbox, { className: composeRenderProps(className, (className) => cn("group/checkbox cursor-pointer focus-ring flex items-center gap-x-2",
10
+ /* Disabled */
11
+ "disabled-muted", labelVariants, className)), ...props, children: composeRenderProps(_jsx(_Fragment, {}), (_, renderProps) => (_jsx(_Fragment, { children: _jsx("div", { className: cn("flex size-input shrink-0 items-center bg-card justify-center border border-input text-current ring-offset-background",
12
+ /* Selected */
13
+ "group-data-[indeterminate]/checkbox:bg-primary group-data-[selected]/checkbox:bg-primary group-data-[indeterminate]/checkbox:text-primary-foreground group-data-[selected]/checkbox:text-primary-foreground",
14
+ /* Disabled */
15
+ "group-data-[disabled]/checkbox:cursor-not-allowed group-data-[disabled]/checkbox:opacity-50",
16
+ /* Invalid */
17
+ "group-data-[invalid]/checkbox:border-destructive group-data-[invalid]/checkbox:group-data-[selected]/checkbox:bg-destructive group-data-[invalid]/checkbox:group-data-[selected]/checkbox:text-destructive-foreground",
18
+ /* Resets */
19
+ "focus:outline-none focus-visible:outline-none"), children: renderProps.isIndeterminate ? (_jsx(Minus, { className: "size-icon" })) : renderProps.isSelected ? (_jsx(Check, { className: "size-icon" })) : null }) }))) }) }) }));
20
+ }
21
+ export function TfCheckbox({ ...props }) {
22
+ const field = useFieldContext();
23
+ return (_jsx(Checkbox, { isSelected: field.state.value, isDisabled: field.form.state.isSubmitting || props.isDisabled, onChange: () => field.handleChange(!field.state.value), onBlur: field.handleBlur, ...props }));
24
+ }
25
+ ;
@@ -0,0 +1,11 @@
1
+ import { DatePickerProps as AriaDatePickerProps, DateRangePickerProps as AriaDateRangePickerProps, DateValue as AriaDateValue } from "react-aria-components";
2
+ import { type ZonedDateTime } from "@internationalized/date";
3
+ import { type FormFieldProps } from "lib/components/inputs/field";
4
+ interface DatePickerProps<T extends AriaDateValue> extends AriaDatePickerProps<T>, FormFieldProps {
5
+ }
6
+ export declare function DatePicker<T extends AriaDateValue>({ label, description, errorMessage, className, ...props }: DatePickerProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export declare function TfDatePicker({ ...props }: Omit<DatePickerProps<ZonedDateTime>, 'value' | 'onChange' | 'onBlur' | 'isInvalid' | 'errorMessage'>): import("react/jsx-runtime").JSX.Element;
8
+ interface DateRangePickerProps<T extends AriaDateValue> extends AriaDateRangePickerProps<T>, FormFieldProps {
9
+ }
10
+ export declare function DateRangePicker<T extends AriaDateValue>({ label, description, errorMessage, className, ...props }: DateRangePickerProps<T>): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CalendarIcon } from "lucide-react";
3
+ import { DatePicker as AriaDatePicker, DateRangePicker as AriaDateRangePicker, Dialog as AriaDialog, composeRenderProps, Popover } from "react-aria-components";
4
+ import { getLocalTimeZone, parseAbsolute } from "@internationalized/date";
5
+ import { DateInput } from "lib/components/inputs/datefield";
6
+ import { FieldGroup, FormField } from "lib/components/inputs/field";
7
+ import { Button } from "lib/components/ui/button";
8
+ import { Calendar, RangeCalendar } from "lib/components/ui/calendar";
9
+ import { useFieldContext } from "lib/utils/form-context";
10
+ import { getFieldErrorMessage } from "lib/utils/form-hook";
11
+ import { cn } from "lib/utils/primitives";
12
+ const DatePickerContent = ({ className, popoverClassName, ...props }) => (_jsx(Popover, { className: composeRenderProps(popoverClassName, (className) => cn("w-auto p-3", className)), children: _jsx(AriaDialog, { className: cn("flex w-full flex-col gap-y-2 outline-none sm:flex-row sm:gap-x-icon sm:gap-y-0", className), ...props }) }));
13
+ export function DatePicker({ label, description, errorMessage, className, ...props }) {
14
+ return (_jsxs(AriaDatePicker, { className: composeRenderProps(className, (className) => cn("group flex flex-col gap-2", className)), ...props, children: [_jsx(FormField, { label: label, description: description, errorMessage: errorMessage, children: _jsxs(FieldGroup, { "aria-label": label, children: [_jsx(DateInput, { className: "flex-1", variant: "ghost" }), _jsx(Button, { variant: "ghost", size: "icon", className: '-me-2 ms-2', children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), _jsx(DatePickerContent, { children: _jsx(Calendar, {}) })] }));
15
+ }
16
+ export function TfDatePicker({ ...props }) {
17
+ const field = useFieldContext();
18
+ return (_jsx(DatePicker, { hideTimeZone: true, value: field.state.value ? parseAbsolute(field.state.value, getLocalTimeZone()) : null, onChange: (v) => v ? field.handleChange(v.toAbsoluteString()) : field.handleChange(null), onBlur: field.handleBlur, isInvalid: !!getFieldErrorMessage(field), errorMessage: getFieldErrorMessage(field), ...props }));
19
+ }
20
+ export function DateRangePicker({ label, description, errorMessage, className, ...props }) {
21
+ return (_jsxs(AriaDateRangePicker, { className: composeRenderProps(className, (className) => cn("group flex flex-col gap-2", className)), ...props, children: [_jsx(FormField, { label: label, errorMessage: errorMessage, description: description, children: _jsxs(FieldGroup, { children: [_jsx(DateInput, { variant: "ghost", slot: "start" }), _jsx("span", { "aria-hidden": true, className: "px-2 text-sm text-muted-foreground", children: "-" }), _jsx(DateInput, { className: "flex-1", variant: "ghost", slot: "end" }), _jsx(Button, { variant: "ghost", size: "icon", className: "mr-1 data-[focus-visible]:ring-offset-0", children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), _jsx(DatePickerContent, { children: _jsx(RangeCalendar, {}) })] }));
22
+ }
@@ -0,0 +1,14 @@
1
+ import { VariantProps } from "class-variance-authority";
2
+ import { DateFieldProps as AriaDateFieldProps, DateInputProps as AriaDateInputProps, DateSegmentProps as AriaDateSegmentProps, DateValue as AriaDateValue, TimeFieldProps as AriaTimeFieldProps, TimeValue as AriaTimeValue } from "react-aria-components";
3
+ import { fieldGroupVariants, type FormFieldProps } from "./field";
4
+ export declare function DateSegment({ className, ...props }: AriaDateSegmentProps): import("react/jsx-runtime").JSX.Element;
5
+ interface DateInputProps extends AriaDateInputProps, VariantProps<typeof fieldGroupVariants> {
6
+ }
7
+ export declare function DateInput({ className, variant, ...props }: Omit<DateInputProps, "children">): import("react/jsx-runtime").JSX.Element;
8
+ interface DateFieldProps<T extends AriaDateValue> extends AriaDateFieldProps<T>, FormFieldProps {
9
+ }
10
+ export declare function DateField<T extends AriaDateValue>({ label, description, className, errorMessage, ...props }: DateFieldProps<T>): import("react/jsx-runtime").JSX.Element;
11
+ interface TimeFieldProps<T extends AriaTimeValue> extends AriaTimeFieldProps<T>, FormFieldProps {
12
+ }
13
+ export declare function TimeField<T extends AriaTimeValue>({ label, description, errorMessage, className, ...props }: TimeFieldProps<T>): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { DateField as AriaDateField, DateInput as AriaDateInput, DateSegment as AriaDateSegment, TimeField as AriaTimeField, composeRenderProps } from "react-aria-components";
4
+ import { cn } from "lib/utils/primitives";
5
+ import { fieldGroupVariants, FormField } from "./field";
6
+ export function DateSegment({ className, ...props }) {
7
+ return (_jsx(AriaDateSegment, { className: composeRenderProps(className, (className) => cn("inline caret-transparent outline-0",
8
+ /* Placeholder */
9
+ "data-[placeholder]:text-muted-foreground",
10
+ /* Disabled */
11
+ "disabled-muted",
12
+ /* Focused */
13
+ "data-[focused]:bg-accent data-[focused]:text-accent-foreground",
14
+ /* Invalid */
15
+ "data-[invalid]:data-[focused]:bg-destructive data-[invalid]:data-[focused]:data-[placeholder]:text-destructive-foreground data-[invalid]:data-[focused]:text-destructive-foreground data-[invalid]:data-[placeholder]:text-destructive data-[invalid]:text-destructive", className)), ...props }));
16
+ }
17
+ export function DateInput({ className, variant, ...props }) {
18
+ return (_jsx(AriaDateInput, { className: composeRenderProps(className, (className) => cn(fieldGroupVariants({ variant }), "text-sm", className)), ...props, children: (segment) => _jsx(DateSegment, { segment: segment }) }));
19
+ }
20
+ export function DateField({ label, description, className, errorMessage, ...props }) {
21
+ return (_jsx(AriaDateField, { className: composeRenderProps(className, (className) => cn("group form-field", className)), ...props, children: _jsx(FormField, { label: label, description: description, errorMessage: errorMessage, children: _jsx(DateInput, {}) }) }));
22
+ }
23
+ export function TimeField({ label, description, errorMessage, className, ...props }) {
24
+ return (_jsx(AriaTimeField, { className: composeRenderProps(className, (className) => cn("group form-field", className)), ...props, children: _jsx(FormField, { label: label, description: description, errorMessage: errorMessage, children: _jsx(DateInput, {}) }) }));
25
+ }
@@ -0,0 +1,21 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import { GroupProps as AriaGroupProps, LabelProps as AriaLabelProps, TextProps as AriaTextProps } from "react-aria-components";
3
+ import type React from "react";
4
+ export declare const labelVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
5
+ export declare function FieldLabel({ className, ...props }: AriaLabelProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function FieldDescription({ className, children, ...props }: AriaTextProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function FieldError({ className, children, ...props }: React.ComponentPropsWithRef<'div'>): import("react/jsx-runtime").JSX.Element;
8
+ export declare const fieldGroupVariants: (props?: ({
9
+ variant?: "default" | "ghost" | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ export interface GroupProps extends AriaGroupProps, VariantProps<typeof fieldGroupVariants> {
12
+ }
13
+ export declare function FieldGroup({ className, variant, ...props }: GroupProps): import("react/jsx-runtime").JSX.Element;
14
+ export type FormFieldProps = {
15
+ label?: string;
16
+ description?: React.ReactNode;
17
+ errorMessage?: string;
18
+ };
19
+ export declare function FormField({ label, description, errorMessage, children }: FormFieldProps & {
20
+ children: React.ReactNode;
21
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { cva } from "class-variance-authority";
4
+ import { Group as AriaGroup, Label as AriaLabel, Text as AriaText, composeRenderProps } from "react-aria-components";
5
+ import { cn } from "lib/utils/primitives";
6
+ import { CircleX, Info } from "lucide-react";
7
+ export const labelVariants = cva([
8
+ "select-none text-sm font-medium leading-none",
9
+ /* Disabled */
10
+ "disabled-muted",
11
+ /* Invalid */
12
+ "group-data-[invalid]:text-destructive",
13
+ ]);
14
+ export function FieldLabel({ className, ...props }) {
15
+ return (_jsx(AriaLabel, { className: cn(labelVariants(), className), ...props }));
16
+ }
17
+ export function FieldDescription({ className, children, ...props }) {
18
+ return (_jsxs(AriaText, { className: cn("text-sm text-muted leading-tight", className), ...props, slot: "description", children: [children, _jsx(Info, { className: "inline size-2 align-text-top ms-0.5" })] }));
19
+ }
20
+ // TODO, if we were to use AriaFieldError, it would use the internal ValidationState Context object, which might be useful for composing inputs but
21
+ // this would have significant overlap with what Tanstack Form is already doing for us. It has pros and cons, needs to be discussed and explored.
22
+ export function FieldError({ className, children, ...props }) {
23
+ return (_jsxs("div", { className: cn("text-sm leading-tight text-destructive duration-150 animate-in transition-transform slide-in-from-top-5 fade-in", className), ...props, children: [children, _jsx(CircleX, { className: "inline size-2 align-text-top ms-0.5" })] }));
24
+ }
25
+ export const fieldGroupVariants = cva("", {
26
+ variants: {
27
+ variant: {
28
+ default: [
29
+ // TODO standardize the padding here
30
+ "relative flex h-input w-full items-center overflow-hidden border border-input bg-card px-2 py-2 text-sm ring-offset-background",
31
+ /* Focus Within */
32
+ "focus-ring",
33
+ /* Disabled */
34
+ "disabled-muted",
35
+ ],
36
+ ghost: "",
37
+ },
38
+ },
39
+ defaultVariants: {
40
+ variant: "default",
41
+ },
42
+ });
43
+ export function FieldGroup({ className, variant, ...props }) {
44
+ return (_jsx(AriaGroup, { className: composeRenderProps(className, (className) => cn(fieldGroupVariants({ variant }), className)), ...props }));
45
+ }
46
+ export function FormField({ label, description, errorMessage, children }) {
47
+ return _jsxs(_Fragment, { children: [label && _jsx(FieldLabel, { children: label }), children, description && (_jsx(FieldDescription, { children: description })), errorMessage && _jsx(FieldError, { children: errorMessage })] });
48
+ }
@@ -0,0 +1,20 @@
1
+ export type SelectState = Set<number | string>;
2
+ type SearchInputProps<T> = {
3
+ value: SelectState;
4
+ onChange: (v: SelectState) => void;
5
+ onBlur?: (v: SelectState) => void;
6
+ multiple: boolean;
7
+ disabled?: boolean;
8
+ idLookup?: (ids: string[]) => Promise<string[] | undefined>;
9
+ searchFn: (q: string) => Promise<T[] | undefined>;
10
+ accessor: 'id' | 'name';
11
+ };
12
+ export declare function IdSearchInput<T extends {
13
+ id: string;
14
+ name: string;
15
+ }>({ value, disabled, searchFn, multiple, onChange, onBlur, accessor, idLookup }: SearchInputProps<T>): import("react/jsx-runtime").JSX.Element;
16
+ export declare function TfIdSearchInput<T extends {
17
+ id: string;
18
+ name: string;
19
+ }>({ disabled, ...props }: Omit<SearchInputProps<T>, 'value' | 'onChange'>): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { SearchField } from "lib/components/inputs/searchfield";
4
+ import { Button } from "lib/components/ui/button";
5
+ import { Loader } from "lib/components/ui/loader";
6
+ import { Menu, MenuItem } from "lib/components/ui/menu";
7
+ import { Popover, PopoverTrigger } from "lib/components/ui/popover";
8
+ import { useFieldContext } from "lib/utils/form-context";
9
+ import { useId, useState } from "react";
10
+ import { Autocomplete } from 'react-aria-components';
11
+ export function IdSearchInput({ value, disabled = false, searchFn, multiple, onChange, onBlur, accessor = 'id', idLookup }) {
12
+ const id = useId();
13
+ const [search, _setSearch] = useState('');
14
+ const { data, isError, isFetching, error } = useQuery({
15
+ queryKey: [id, search],
16
+ queryFn: () => searchFn(search)
17
+ });
18
+ const namesQuery = useQuery({
19
+ queryKey: [id, value],
20
+ queryFn: () => idLookup(Array.from(value.keys()).map(id => id.toString())),
21
+ enabled: idLookup && value.size > 0
22
+ });
23
+ const renderButtonLabel = () => {
24
+ return namesQuery.data?.join(',');
25
+ };
26
+ return _jsx(_Fragment, { children: _jsxs(PopoverTrigger, { onOpenChange: (o) => {
27
+ if (!o) {
28
+ // searchInputRef.current?.focus();
29
+ onBlur?.(value);
30
+ }
31
+ }, children: [_jsx(Button, { className: 'min-w-3xs', isDisabled: disabled, children: renderButtonLabel() }), _jsx(Popover, { className: 'p-2', children: _jsxs(Autocomplete, { inputValue: search, onInputChange: _setSearch, children: [_jsx(SearchField, { className: 'mb-icon', autoFocus: true }), isFetching && _jsx(Loader, { className: "p-input" }), !isFetching && !isError && _jsx(Menu, { selectedKeys: value, selectionMode: multiple ? "multiple" : 'single', onSelectionChange: (s) => {
32
+ if (typeof (s) === 'string')
33
+ return;
34
+ onChange(s);
35
+ }, className: 'text-sm', items: data, renderEmptyState: () => 'No results found.', children: (item) => (_jsx(MenuItem, { id: item[accessor], children: item.name }, item['id'])) }), isError && _jsx("div", { className: "text-destructive p-icon", children: error.message })] }) })] }) });
36
+ }
37
+ export function TfIdSearchInput({ disabled, ...props }) {
38
+ const field = useFieldContext();
39
+ return (_jsx(IdSearchInput, { ...props, disabled: disabled || field.form.state.isSubmitting, value: field.state.value, onBlur: _ => field.handleBlur(), onChange: (e) => field.handleChange(e) }));
40
+ }
@@ -0,0 +1,8 @@
1
+ import { OTPInput } from "input-otp";
2
+ import * as React from "react";
3
+ export declare function InputOTP({ className, containerClassName, ...props }: React.ComponentProps<typeof OTPInput>): import("react/jsx-runtime").JSX.Element;
4
+ export declare function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
5
+ export declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<"div"> & {
6
+ index: number;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ export declare function InputOTPSeparator({ ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { OTPInput, OTPInputContext } from "input-otp";
3
+ import { cn } from "lib/utils/primitives";
4
+ import { Minus } from "lucide-react";
5
+ import * as React from "react";
6
+ export function InputOTP({ className, containerClassName, ...props }) {
7
+ return (_jsx(OTPInput, { containerClassName: cn("flex items-center gap-2 has-disabled:opacity-50", containerClassName), className: cn("disabled:cursor-not-allowed", className), ...props }));
8
+ }
9
+ export function InputOTPGroup({ className, ...props }) {
10
+ return _jsx("div", { className: cn("flex items-center", className), ...props });
11
+ }
12
+ export function InputOTPSlot({ index, className, ...props }) {
13
+ const inputOTPContext = React.use(OTPInputContext);
14
+ const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
15
+ return (_jsxs("div", { className: cn("relative flex h-input w-9 items-center justify-center border-2 border-input body transition-all", isActive ? "z-10 border-2 border-primary" : "", className), ...props, children: [char, hasFakeCaret && (_jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: _jsx("div", { className: "h-icon w-px animate-caret-blink bg-foreground duration-1000" }) }))] }));
16
+ }
17
+ export function InputOTPSeparator({ ...props }) {
18
+ return (_jsx("div", { role: "separator", ...props, children: _jsx(Minus, {}) }));
19
+ }
@@ -0,0 +1,17 @@
1
+ import { type FormFieldProps } from "lib/components/inputs/field";
2
+ import type { SelectOption } from "lib/components/inputs/select-options";
3
+ import { EasyMenu } from "lib/components/ui/menu";
4
+ import React from "react";
5
+ interface MultipleSelectionProps {
6
+ value: Set<string | number>;
7
+ onChange: (v: Set<string | number>) => void;
8
+ buttonLabel?: React.ReactNode;
9
+ items: SelectOption[];
10
+ }
11
+ export interface MultiSelectProps extends MultipleSelectionProps, FormFieldProps, Omit<React.ComponentProps<typeof EasyMenu>, 'label' | 'items'> {
12
+ }
13
+ export declare function MultiSelect({ items, value, onChange: setValue, label, errorMessage, description, ...props }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
14
+ export interface TfMultiSelectProps extends Omit<MultiSelectProps, "value" | "onChange"> {
15
+ }
16
+ export declare function TfMultiSelect({ ...props }: TfMultiSelectProps): import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormField } from "lib/components/inputs/field";
3
+ import { EasyMenu, MenuItem } from "lib/components/ui/menu";
4
+ import { useFieldContext } from "lib/utils/form-context";
5
+ import { getFieldErrorMessage } from "lib/utils/form-hook";
6
+ export function MultiSelect({ items, value, onChange: setValue, label, errorMessage, description, ...props }) {
7
+ return (_jsx("div", { className: "group form-field", children: _jsx(FormField, { label, description, errorMessage, children: _jsx(EasyMenu, { selectionMode: "multiple", selectedKeys: value, onSelectionChange: (v) => {
8
+ if (typeof (v) === 'string')
9
+ return;
10
+ setValue(v);
11
+ }, items: items, label: value.size, ...props, children: (item) => _jsx(MenuItem, { id: item.id, isDisabled: item?.disabled, children: item.label }, item.id) }) }) }));
12
+ }
13
+ ;
14
+ export function TfMultiSelect({ ...props }) {
15
+ const field = useFieldContext();
16
+ return (_jsx(MultiSelect, { value: field.state.value, onChange: field.setValue, onClose: field.handleBlur, errorMessage: getFieldErrorMessage(field), ...props }));
17
+ }
18
+ ;
@@ -0,0 +1,7 @@
1
+ import { NumberFieldProps as AriaNumberFieldProps } from "react-aria-components";
2
+ import type React from "react";
3
+ import { type FormFieldProps } from "./field";
4
+ type NumberFieldProps = AriaNumberFieldProps & FormFieldProps;
5
+ export declare function NumberField({ label, description, errorMessage, className, ...props }: NumberFieldProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function TfNumberField({ isDisabled, ...props }: Omit<React.ComponentProps<typeof NumberField>, 'value' | 'id' | 'onChange' | 'onBlur'>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Input as AriaInput, NumberField as AriaNumberField, composeRenderProps } from "react-aria-components";
3
+ import { Button } from "lib/components/ui/button";
4
+ import { useFieldContext } from "lib/utils/form-context";
5
+ import { getFieldErrorMessage } from "lib/utils/form-hook";
6
+ import { cn } from "lib/utils/primitives";
7
+ import { ChevronDown, ChevronUp } from "lucide-react";
8
+ import { FieldGroup, FormField } from "./field";
9
+ const ANumberField = AriaNumberField;
10
+ function NumberFieldInput({ className, ...props }) {
11
+ return (_jsx(AriaInput, { className: composeRenderProps(className, (className) => cn("w-fit min-w-0 flex-1 border-r border-transparent bg-card pr-2 outline-0 placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden", className)), ...props }));
12
+ }
13
+ function NumberFieldSteppers({ className, ...props }) {
14
+ return (_jsxs("div", { className: cn("absolute right-0 flex h-full flex-col border-l", className), ...props, children: [_jsx(NumberFieldStepper, { slot: "increment", children: _jsx(ChevronUp, { "aria-hidden": true, className: "size-icon" }) }), _jsx("div", { className: "border-b" }), _jsx(NumberFieldStepper, { slot: "decrement", children: _jsx(ChevronDown, { "aria-hidden": true, className: "size-icon" }) })] }));
15
+ }
16
+ function NumberFieldStepper({ className, ...props }) {
17
+ return (_jsx(Button, { className: composeRenderProps(className, (className) => cn("w-auto grow h-3 px-0.5 text-muted-foreground", className)), variant: "ghost", size: "none", ...props }));
18
+ }
19
+ export function NumberField({ label, description, errorMessage, className, ...props }) {
20
+ return (_jsx(ANumberField, { className: composeRenderProps(className, (className) => cn("group form-field", className)), ...props, children: _jsx(FormField, { label: label, description: description, errorMessage: errorMessage, children: _jsxs(FieldGroup, { children: [_jsx(NumberFieldInput, {}), _jsx(NumberFieldSteppers, {})] }) }) }));
21
+ }
22
+ export function TfNumberField({ isDisabled, ...props }) {
23
+ const field = useFieldContext();
24
+ return (_jsx(NumberField, { isInvalid: !!getFieldErrorMessage(field), isDisabled: isDisabled || field.form.state.isSubmitting, value: field.state.value, id: field.name, onChange: field.handleChange, onBlur: field.handleBlur, errorMessage: getFieldErrorMessage(field), ...props }));
25
+ }
@@ -0,0 +1,5 @@
1
+ import { SearchFieldProps as AriaSearchFieldProps } from "react-aria-components";
2
+ import { type FormFieldProps } from "./field";
3
+ export interface SearchFieldProps extends AriaSearchFieldProps, FormFieldProps {
4
+ }
5
+ export declare function SearchField({ label, description, className, errorMessage, ...props }: SearchFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SearchIcon, XIcon } from "lucide-react";
3
+ import { Button as AriaButton, Input as AriaInput, SearchField as AriaSearchField, composeRenderProps } from "react-aria-components";
4
+ import { cn } from "lib/utils/primitives";
5
+ import { FieldGroup, FormField } from "./field";
6
+ function ASearchField({ className, ...props }) {
7
+ return (_jsx(AriaSearchField, { className: composeRenderProps(className, (className) => cn("group", className)), ...props }));
8
+ }
9
+ function ASearchFieldInput({ className, ...props }) {
10
+ return (_jsx(AriaInput, { className: composeRenderProps(className, (className) => cn("min-w-0 ring-0 focus-visible:outline-none flex-1 bg-card px-2 py-1.5 placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden", className)), ...props }));
11
+ }
12
+ function SearchFieldClear({ className, ...props }) {
13
+ return (_jsx(AriaButton, { className: composeRenderProps(className, (className) => cn("mr-1 opacity-70 ring-offset-background transition-opacity",
14
+ /* Hover */
15
+ "data-[hovered]:opacity-100",
16
+ /* Disabled */
17
+ "data-[disabled]:pointer-events-none",
18
+ /* Empty */
19
+ "group-data-[empty]:invisible", className)), ...props }));
20
+ }
21
+ ;
22
+ export function SearchField({ label, description, className, errorMessage, ...props }) {
23
+ return (_jsx(ASearchField, { className: composeRenderProps(className, (className) => cn("group form-field", className)), ...props, children: _jsx(FormField, { label: label, description: description, errorMessage: errorMessage, children: _jsxs(FieldGroup, { children: [_jsx(SearchIcon, { "aria-hidden": true, className: "size-icon text-muted-foreground" }), _jsx(ASearchFieldInput, { placeholder: "" }), _jsx(SearchFieldClear, { children: _jsx(XIcon, { "aria-hidden": true, className: "size-icon" }) })] }) }) }));
24
+ }
@@ -0,0 +1,8 @@
1
+ export type SelectOption = {
2
+ id: string;
3
+ label: React.ReactNode;
4
+ disabled?: boolean;
5
+ };
6
+ export declare const LICENSE_TYPE_OPTIONS: SelectOption[];
7
+ /** Options for MultiSelect component */
8
+ export declare const COUNTRY_OPTIONS: SelectOption[];