@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.
- package/dist/components/data-table/data-table-filter.d.ts +27 -0
- package/dist/components/data-table/data-table-filter.js +112 -0
- package/dist/components/data-table/data-table.d.ts +73 -0
- package/dist/components/data-table/data-table.js +265 -0
- package/dist/components/data-table/table-commons.d.ts +56 -0
- package/dist/components/data-table/table-commons.js +137 -0
- package/dist/components/inputs/checkbox.d.ts +8 -0
- package/dist/components/inputs/checkbox.js +25 -0
- package/dist/components/inputs/date-picker.d.ts +11 -0
- package/dist/components/inputs/date-picker.js +22 -0
- package/dist/components/inputs/datefield.d.ts +14 -0
- package/dist/components/inputs/datefield.js +25 -0
- package/dist/components/inputs/field.d.ts +21 -0
- package/dist/components/inputs/field.js +48 -0
- package/dist/components/inputs/id-search.d.ts +20 -0
- package/dist/components/inputs/id-search.js +40 -0
- package/dist/components/inputs/input-otp.d.ts +8 -0
- package/dist/components/inputs/input-otp.js +19 -0
- package/dist/components/inputs/multi-select.d.ts +17 -0
- package/dist/components/inputs/multi-select.js +18 -0
- package/dist/components/inputs/numberfield.d.ts +7 -0
- package/dist/components/inputs/numberfield.js +25 -0
- package/dist/components/inputs/searchfield.d.ts +5 -0
- package/dist/components/inputs/searchfield.js +24 -0
- package/dist/components/inputs/select-options.d.ts +8 -0
- package/dist/components/inputs/select-options.js +286 -0
- package/dist/components/inputs/select.d.ts +17 -0
- package/dist/components/inputs/select.js +34 -0
- package/dist/components/inputs/textfield.d.ts +7 -0
- package/dist/components/inputs/textfield.js +28 -0
- package/dist/components/key-value-card/key-value-card.d.ts +17 -0
- package/dist/components/key-value-card/key-value-card.js +40 -0
- package/dist/components/ui/alert.d.ts +8 -0
- package/dist/components/ui/alert.js +18 -0
- package/dist/components/ui/avatar.d.ts +8 -0
- package/dist/components/ui/avatar.js +5 -0
- package/dist/components/ui/badge.d.ts +2 -0
- package/dist/components/ui/badge.js +5 -0
- package/dist/components/ui/breadcrumbs.d.ts +10 -0
- package/dist/components/ui/breadcrumbs.js +28 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.js +34 -0
- package/dist/components/ui/calendar.d.ts +17 -0
- package/dist/components/ui/calendar.js +63 -0
- package/dist/components/ui/card.d.ts +7 -0
- package/dist/components/ui/card.js +20 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.js +42 -0
- package/dist/components/ui/disclosure.d.ts +19 -0
- package/dist/components/ui/disclosure.js +20 -0
- package/dist/components/ui/list-box.d.ts +5 -0
- package/dist/components/ui/list-box.js +24 -0
- package/dist/components/ui/loader.d.ts +5 -0
- package/dist/components/ui/loader.js +6 -0
- package/dist/components/ui/menu.d.ts +25 -0
- package/dist/components/ui/menu.js +38 -0
- package/dist/components/ui/popover.d.ts +4 -0
- package/dist/components/ui/popover.js +14 -0
- package/dist/components/ui/sidebar.d.ts +53 -0
- package/dist/components/ui/sidebar.js +177 -0
- package/dist/components/ui/skeleton.d.ts +1 -0
- package/dist/components/ui/skeleton.js +5 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.js +14 -0
- package/dist/components/ui/table.d.ts +9 -0
- package/dist/components/ui/table.js +26 -0
- package/dist/components/ui/tabs.d.ts +5 -0
- package/dist/components/ui/tabs.js +25 -0
- package/dist/components/ui/timeline.d.ts +15 -0
- package/dist/components/ui/timeline.js +31 -0
- package/dist/components/ui/tooltip.d.ts +4 -0
- package/dist/components/ui/tooltip.js +12 -0
- package/dist/utils/form-context.d.ts +4 -0
- package/{lib/utils/form-context.tsx → dist/utils/form-context.js} +1 -3
- package/dist/utils/form-hook.d.ts +25 -0
- package/{lib/utils/form-hook.tsx → dist/utils/form-hook.js} +15 -18
- package/dist/utils/primitives.d.ts +30 -0
- package/{lib/utils/primitives.ts → dist/utils/primitives.js} +8 -37
- package/dist/utils/resource-names.d.ts +23 -0
- package/{lib/utils/resource-names.tsx → dist/utils/resource-names.js} +42 -75
- package/dist/utils/use-mobile.d.ts +1 -0
- package/dist/utils/use-mobile.js +15 -0
- package/package.json +10 -5
- package/lib/components/data-table/data-table-filter.tsx +0 -220
- package/lib/components/data-table/data-table.tsx +0 -593
- package/lib/components/data-table/table-commons.tsx +0 -233
- package/lib/components/inputs/checkbox.tsx +0 -72
- package/lib/components/inputs/date-picker.tsx +0 -130
- package/lib/components/inputs/datefield.tsx +0 -109
- package/lib/components/inputs/field.tsx +0 -106
- package/lib/components/inputs/id-search.tsx +0 -83
- package/lib/components/inputs/input-otp.tsx +0 -63
- package/lib/components/inputs/multi-select.tsx +0 -62
- package/lib/components/inputs/numberfield.tsx +0 -110
- package/lib/components/inputs/searchfield.tsx +0 -87
- package/lib/components/inputs/select-options.tsx +0 -303
- package/lib/components/inputs/select.tsx +0 -140
- package/lib/components/inputs/textfield.tsx +0 -96
- package/lib/components/key-value-card/key-value-card.tsx +0 -115
- package/lib/components/ui/alert.tsx +0 -32
- package/lib/components/ui/avatar.tsx +0 -22
- package/lib/components/ui/badge.tsx +0 -19
- package/lib/components/ui/breadcrumbs.tsx +0 -104
- package/lib/components/ui/button.tsx +0 -66
- package/lib/components/ui/calendar.tsx +0 -220
- package/lib/components/ui/card.tsx +0 -58
- package/lib/components/ui/dialog.tsx +0 -172
- package/lib/components/ui/disclosure.tsx +0 -113
- package/lib/components/ui/list-box.tsx +0 -86
- package/lib/components/ui/loader.tsx +0 -10
- package/lib/components/ui/menu.tsx +0 -168
- package/lib/components/ui/popover.tsx +0 -37
- package/lib/components/ui/sidebar.tsx +0 -552
- package/lib/components/ui/skeleton.tsx +0 -7
- package/lib/components/ui/sonner.tsx +0 -26
- package/lib/components/ui/table.tsx +0 -79
- package/lib/components/ui/tabs.tsx +0 -82
- package/lib/components/ui/timeline.tsx +0 -52
- package/lib/components/ui/tooltip.tsx +0 -30
- package/lib/tokens.scss +0 -89
- package/lib/utils/use-mobile.tsx +0 -21
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { SearchField } from "lib/components/inputs/searchfield";
|
|
3
|
-
import { Button } from "lib/components/ui/button";
|
|
4
|
-
import { Loader } from "lib/components/ui/loader";
|
|
5
|
-
import { Menu, MenuItem } from "lib/components/ui/menu";
|
|
6
|
-
import { Popover, PopoverTrigger } from "lib/components/ui/popover";
|
|
7
|
-
import { useFieldContext } from "lib/utils/form-context";
|
|
8
|
-
import { useId, useState } from "react";
|
|
9
|
-
import { Autocomplete } from 'react-aria-components';
|
|
10
|
-
|
|
11
|
-
export type SelectState = Set<number | string>;
|
|
12
|
-
|
|
13
|
-
type SearchInputProps<T> = {
|
|
14
|
-
value: SelectState;
|
|
15
|
-
onChange: (v: SelectState) => void
|
|
16
|
-
onBlur?: (v: SelectState) => void
|
|
17
|
-
multiple: boolean
|
|
18
|
-
disabled?: boolean
|
|
19
|
-
idLookup?: (ids: string[]) => Promise<string[] | undefined>
|
|
20
|
-
searchFn: (q: string) => Promise<T[] | undefined>
|
|
21
|
-
accessor: 'id' | 'name';
|
|
22
|
-
}
|
|
23
|
-
export function IdSearchInput<T extends { id: string; name: string }>({ value, disabled = false, searchFn, multiple, onChange, onBlur, accessor = 'id', idLookup }: SearchInputProps<T>) {
|
|
24
|
-
const id = useId();
|
|
25
|
-
const [search, _setSearch] = useState('');
|
|
26
|
-
const { data, isError, isFetching, error } = useQuery({
|
|
27
|
-
queryKey: [id, search],
|
|
28
|
-
queryFn: () => searchFn(search)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const namesQuery = useQuery({
|
|
32
|
-
queryKey: [id, value],
|
|
33
|
-
queryFn: () => idLookup!(Array.from(value.keys()).map(id => id.toString())),
|
|
34
|
-
enabled: idLookup && value.size > 0
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const renderButtonLabel = () => {
|
|
38
|
-
return namesQuery.data?.join(',');
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return <>
|
|
42
|
-
<PopoverTrigger onOpenChange={(o) => {
|
|
43
|
-
if (!o) {
|
|
44
|
-
// searchInputRef.current?.focus();
|
|
45
|
-
onBlur?.(value);
|
|
46
|
-
}
|
|
47
|
-
}}>
|
|
48
|
-
<Button className={'min-w-3xs'} isDisabled={disabled}>{renderButtonLabel()}</Button>
|
|
49
|
-
<Popover className={'p-2'}>
|
|
50
|
-
<Autocomplete
|
|
51
|
-
inputValue={search}
|
|
52
|
-
onInputChange={_setSearch}
|
|
53
|
-
>
|
|
54
|
-
<SearchField className={'mb-icon'} autoFocus />
|
|
55
|
-
{isFetching && <Loader className="p-input" />}
|
|
56
|
-
{!isFetching && !isError && <Menu selectedKeys={value} selectionMode={multiple ? "multiple" : 'single'} onSelectionChange={(s) => {
|
|
57
|
-
if (typeof (s) === 'string') return;
|
|
58
|
-
onChange(s)
|
|
59
|
-
}} className={'text-sm'} items={data} renderEmptyState={() => 'No results found.'}>
|
|
60
|
-
{(item) => (<MenuItem key={item['id']} id={item[accessor]}>{item.name}</MenuItem>)}
|
|
61
|
-
</Menu>}
|
|
62
|
-
{
|
|
63
|
-
isError && <div className="text-destructive p-icon">{error.message}</div>
|
|
64
|
-
}
|
|
65
|
-
</Autocomplete>
|
|
66
|
-
</Popover>
|
|
67
|
-
</PopoverTrigger >
|
|
68
|
-
</>
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function TfIdSearchInput<T extends { id: string; name: string }>({ disabled, ...props }: Omit<SearchInputProps<T>, 'value' | 'onChange'>) {
|
|
73
|
-
const field = useFieldContext<SelectState>();
|
|
74
|
-
return (
|
|
75
|
-
<IdSearchInput
|
|
76
|
-
{...props}
|
|
77
|
-
disabled={disabled || field.form.state.isSubmitting}
|
|
78
|
-
value={field.state.value}
|
|
79
|
-
onBlur={_ => field.handleBlur()}
|
|
80
|
-
onChange={(e) => field.handleChange(e)}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { OTPInput, OTPInputContext } from "input-otp";
|
|
2
|
-
import { cn } from "lib/utils/primitives";
|
|
3
|
-
import { Minus } from "lucide-react";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
export function InputOTP({
|
|
7
|
-
className,
|
|
8
|
-
containerClassName,
|
|
9
|
-
...props
|
|
10
|
-
}: React.ComponentProps<typeof OTPInput>) {
|
|
11
|
-
return (
|
|
12
|
-
<OTPInput
|
|
13
|
-
containerClassName={cn(
|
|
14
|
-
"flex items-center gap-2 has-disabled:opacity-50",
|
|
15
|
-
containerClassName,
|
|
16
|
-
)}
|
|
17
|
-
className={cn("disabled:cursor-not-allowed", className)}
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function InputOTPGroup({
|
|
24
|
-
className,
|
|
25
|
-
...props
|
|
26
|
-
}: React.ComponentProps<"div">) {
|
|
27
|
-
return <div className={cn("flex items-center", className)} {...props} />;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function InputOTPSlot({
|
|
31
|
-
index,
|
|
32
|
-
className,
|
|
33
|
-
...props
|
|
34
|
-
}: React.ComponentProps<"div"> & { index: number }) {
|
|
35
|
-
const inputOTPContext = React.use(OTPInputContext);
|
|
36
|
-
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div
|
|
40
|
-
className={cn(
|
|
41
|
-
"relative flex h-input w-9 items-center justify-center border-2 border-input body transition-all",
|
|
42
|
-
isActive ? "z-10 border-2 border-primary" : "",
|
|
43
|
-
className,
|
|
44
|
-
)}
|
|
45
|
-
{...props}
|
|
46
|
-
>
|
|
47
|
-
{char}
|
|
48
|
-
{hasFakeCaret && (
|
|
49
|
-
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
50
|
-
<div className="h-icon w-px animate-caret-blink bg-foreground duration-1000" />
|
|
51
|
-
</div>
|
|
52
|
-
)}
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function InputOTPSeparator({ ...props }: React.ComponentProps<"div">) {
|
|
58
|
-
return (
|
|
59
|
-
<div role="separator" {...props}>
|
|
60
|
-
<Minus />
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { FormField, type FormFieldProps } from "lib/components/inputs/field";
|
|
2
|
-
import type { SelectOption } from "lib/components/inputs/select-options";
|
|
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
|
-
import React from "react";
|
|
7
|
-
|
|
8
|
-
interface MultipleSelectionProps {
|
|
9
|
-
value: Set<string | number>;
|
|
10
|
-
onChange: (v: Set<string | number>) => void;
|
|
11
|
-
buttonLabel?: React.ReactNode;
|
|
12
|
-
items: SelectOption[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface MultiSelectProps extends MultipleSelectionProps, FormFieldProps, Omit<React.ComponentProps<typeof EasyMenu>, 'label' | 'items'> { }
|
|
16
|
-
|
|
17
|
-
export function MultiSelect({
|
|
18
|
-
items,
|
|
19
|
-
value,
|
|
20
|
-
onChange: setValue,
|
|
21
|
-
label,
|
|
22
|
-
errorMessage,
|
|
23
|
-
description,
|
|
24
|
-
...props
|
|
25
|
-
}: MultiSelectProps) {
|
|
26
|
-
return (
|
|
27
|
-
<div className="group form-field">
|
|
28
|
-
<FormField {...{ label, description, errorMessage }}>
|
|
29
|
-
<EasyMenu
|
|
30
|
-
selectionMode="multiple"
|
|
31
|
-
selectedKeys={value}
|
|
32
|
-
onSelectionChange={(v) => {
|
|
33
|
-
if (typeof (v) === 'string') return
|
|
34
|
-
setValue(v)
|
|
35
|
-
}}
|
|
36
|
-
items={items}
|
|
37
|
-
label={value.size}
|
|
38
|
-
{...props}>
|
|
39
|
-
{(item) => <MenuItem id={item.id} key={item.id} isDisabled={item?.disabled}>{item.label}</MenuItem>}
|
|
40
|
-
</EasyMenu>
|
|
41
|
-
</FormField>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// TODO implement isDisabled
|
|
48
|
-
export interface TfMultiSelectProps
|
|
49
|
-
extends Omit<MultiSelectProps, "value" | "onChange"> { }
|
|
50
|
-
export function TfMultiSelect({ ...props }: TfMultiSelectProps) {
|
|
51
|
-
const field = useFieldContext<Set<number | string>>();
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<MultiSelect
|
|
55
|
-
value={field.state.value}
|
|
56
|
-
onChange={field.setValue}
|
|
57
|
-
onClose={field.handleBlur}
|
|
58
|
-
errorMessage={getFieldErrorMessage(field)}
|
|
59
|
-
{...props}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ButtonProps as AriaButtonProps,
|
|
3
|
-
Input as AriaInput,
|
|
4
|
-
InputProps as AriaInputProps,
|
|
5
|
-
NumberField as AriaNumberField,
|
|
6
|
-
NumberFieldProps as AriaNumberFieldProps,
|
|
7
|
-
composeRenderProps
|
|
8
|
-
} from "react-aria-components"
|
|
9
|
-
|
|
10
|
-
import { Button } from "lib/components/ui/button"
|
|
11
|
-
import { useFieldContext } from "lib/utils/form-context"
|
|
12
|
-
import { getFieldErrorMessage } from "lib/utils/form-hook"
|
|
13
|
-
import { cn } from "lib/utils/primitives"
|
|
14
|
-
import { ChevronDown, ChevronUp } from "lucide-react"
|
|
15
|
-
import type React from "react"
|
|
16
|
-
import { FieldGroup, FormField, type FormFieldProps } from "./field"
|
|
17
|
-
|
|
18
|
-
const ANumberField = AriaNumberField
|
|
19
|
-
|
|
20
|
-
function NumberFieldInput({ className, ...props }: AriaInputProps) {
|
|
21
|
-
return (
|
|
22
|
-
<AriaInput
|
|
23
|
-
className={composeRenderProps(className, (className) =>
|
|
24
|
-
cn(
|
|
25
|
-
"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",
|
|
26
|
-
className
|
|
27
|
-
)
|
|
28
|
-
)}
|
|
29
|
-
{...props}
|
|
30
|
-
/>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function NumberFieldSteppers({
|
|
35
|
-
className,
|
|
36
|
-
...props
|
|
37
|
-
}: React.ComponentProps<"div">) {
|
|
38
|
-
return (
|
|
39
|
-
<div
|
|
40
|
-
className={cn(
|
|
41
|
-
"absolute right-0 flex h-full flex-col border-l",
|
|
42
|
-
className
|
|
43
|
-
)}
|
|
44
|
-
{...props}
|
|
45
|
-
>
|
|
46
|
-
<NumberFieldStepper slot="increment">
|
|
47
|
-
<ChevronUp aria-hidden className="size-icon" />
|
|
48
|
-
</NumberFieldStepper>
|
|
49
|
-
<div className="border-b" />
|
|
50
|
-
<NumberFieldStepper slot="decrement">
|
|
51
|
-
<ChevronDown aria-hidden className="size-icon" />
|
|
52
|
-
</NumberFieldStepper>
|
|
53
|
-
</div>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function NumberFieldStepper({ className, ...props }: AriaButtonProps) {
|
|
58
|
-
return (
|
|
59
|
-
<Button
|
|
60
|
-
className={composeRenderProps(className, (className) =>
|
|
61
|
-
cn("w-auto grow h-3 px-0.5 text-muted-foreground", className)
|
|
62
|
-
)}
|
|
63
|
-
variant={"ghost"}
|
|
64
|
-
size={"none"}
|
|
65
|
-
{...props}
|
|
66
|
-
/>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type NumberFieldProps = AriaNumberFieldProps & FormFieldProps
|
|
71
|
-
export function NumberField({
|
|
72
|
-
label,
|
|
73
|
-
description,
|
|
74
|
-
errorMessage,
|
|
75
|
-
className,
|
|
76
|
-
...props
|
|
77
|
-
}: NumberFieldProps) {
|
|
78
|
-
return (
|
|
79
|
-
<ANumberField
|
|
80
|
-
className={composeRenderProps(className, (className) =>
|
|
81
|
-
cn("group form-field", className)
|
|
82
|
-
)}
|
|
83
|
-
{...props}
|
|
84
|
-
>
|
|
85
|
-
<FormField label={label} description={description} errorMessage={errorMessage}>
|
|
86
|
-
<FieldGroup>
|
|
87
|
-
<NumberFieldInput />
|
|
88
|
-
<NumberFieldSteppers />
|
|
89
|
-
</FieldGroup>
|
|
90
|
-
</FormField>
|
|
91
|
-
</ANumberField>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function TfNumberField({ isDisabled, ...props }: Omit<React.ComponentProps<typeof NumberField>, 'value' | 'id' | 'onChange' | 'onBlur'>) {
|
|
96
|
-
const field = useFieldContext<number>();
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<NumberField
|
|
100
|
-
isInvalid={!!getFieldErrorMessage(field)}
|
|
101
|
-
isDisabled={isDisabled || field.form.state.isSubmitting}
|
|
102
|
-
value={field.state.value}
|
|
103
|
-
id={field.name}
|
|
104
|
-
onChange={field.handleChange}
|
|
105
|
-
onBlur={field.handleBlur}
|
|
106
|
-
errorMessage={getFieldErrorMessage(field)}
|
|
107
|
-
{...props}
|
|
108
|
-
/>)
|
|
109
|
-
}
|
|
110
|
-
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { SearchIcon, XIcon } from "lucide-react"
|
|
2
|
-
import {
|
|
3
|
-
Button as AriaButton,
|
|
4
|
-
ButtonProps as AriaButtonProps,
|
|
5
|
-
Input as AriaInput,
|
|
6
|
-
InputProps as AriaInputProps,
|
|
7
|
-
SearchField as AriaSearchField,
|
|
8
|
-
SearchFieldProps as AriaSearchFieldProps,
|
|
9
|
-
composeRenderProps
|
|
10
|
-
} from "react-aria-components"
|
|
11
|
-
|
|
12
|
-
import { cn } from "lib/utils/primitives"
|
|
13
|
-
|
|
14
|
-
import { FieldGroup, FormField, type FormFieldProps } from "./field"
|
|
15
|
-
|
|
16
|
-
function ASearchField({ className, ...props }: AriaSearchFieldProps) {
|
|
17
|
-
return (
|
|
18
|
-
<AriaSearchField
|
|
19
|
-
className={composeRenderProps(className, (className) =>
|
|
20
|
-
cn("group", className)
|
|
21
|
-
)}
|
|
22
|
-
{...props}
|
|
23
|
-
/>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function ASearchFieldInput({ className, ...props }: AriaInputProps) {
|
|
28
|
-
return (
|
|
29
|
-
<AriaInput
|
|
30
|
-
className={composeRenderProps(className, (className) =>
|
|
31
|
-
cn(
|
|
32
|
-
"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",
|
|
33
|
-
className
|
|
34
|
-
)
|
|
35
|
-
)}
|
|
36
|
-
{...props}
|
|
37
|
-
/>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function SearchFieldClear({ className, ...props }: AriaButtonProps) {
|
|
42
|
-
return (
|
|
43
|
-
<AriaButton
|
|
44
|
-
className={composeRenderProps(className, (className) =>
|
|
45
|
-
cn(
|
|
46
|
-
"mr-1 opacity-70 ring-offset-background transition-opacity",
|
|
47
|
-
/* Hover */
|
|
48
|
-
"data-[hovered]:opacity-100",
|
|
49
|
-
/* Disabled */
|
|
50
|
-
"data-[disabled]:pointer-events-none",
|
|
51
|
-
/* Empty */
|
|
52
|
-
"group-data-[empty]:invisible",
|
|
53
|
-
className
|
|
54
|
-
)
|
|
55
|
-
)}
|
|
56
|
-
{...props}
|
|
57
|
-
/>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface SearchFieldProps extends AriaSearchFieldProps, FormFieldProps { };
|
|
62
|
-
export function SearchField({
|
|
63
|
-
label,
|
|
64
|
-
description,
|
|
65
|
-
className,
|
|
66
|
-
errorMessage,
|
|
67
|
-
...props
|
|
68
|
-
}: SearchFieldProps) {
|
|
69
|
-
return (
|
|
70
|
-
<ASearchField
|
|
71
|
-
className={composeRenderProps(className, (className) =>
|
|
72
|
-
cn("group form-field", className)
|
|
73
|
-
)}
|
|
74
|
-
{...props}
|
|
75
|
-
>
|
|
76
|
-
<FormField label={label} description={description} errorMessage={errorMessage}>
|
|
77
|
-
<FieldGroup>
|
|
78
|
-
<SearchIcon aria-hidden className="size-icon text-muted-foreground" />
|
|
79
|
-
<ASearchFieldInput placeholder="" />
|
|
80
|
-
<SearchFieldClear>
|
|
81
|
-
<XIcon aria-hidden className="size-icon" />
|
|
82
|
-
</SearchFieldClear>
|
|
83
|
-
</FieldGroup>
|
|
84
|
-
</FormField>
|
|
85
|
-
</ASearchField>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
export type SelectOption = {
|
|
2
|
-
id: string
|
|
3
|
-
label: React.ReactNode,
|
|
4
|
-
disabled?: boolean
|
|
5
|
-
}
|
|
6
|
-
export const LICENSE_TYPE_OPTIONS: SelectOption[] = [
|
|
7
|
-
{
|
|
8
|
-
label: <>Node-locked</>,
|
|
9
|
-
id: "node-locked",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
label: <>Hosted floating</>,
|
|
13
|
-
id: "hosted-floating",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
label: <>LexFloatServer</>,
|
|
17
|
-
id: "on-premise-floating",
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Creates Unicode flag from a two-letter ISO country code.
|
|
24
|
-
* https://stackoverflow.com/questions/24050671/how-to-put-japan-flag-character-in-a-string
|
|
25
|
-
* @param {string} country — A two-letter ISO country code (case-insensitive).
|
|
26
|
-
* @return {string}
|
|
27
|
-
*/
|
|
28
|
-
function getCountryFlag(country: string) {
|
|
29
|
-
function getRegionalIndicatorSymbol(letter: string) {
|
|
30
|
-
return String.fromCodePoint(
|
|
31
|
-
0x1f1e6 - 65 + letter.toUpperCase().charCodeAt(0),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
getRegionalIndicatorSymbol(country[0]) +
|
|
37
|
-
getRegionalIndicatorSymbol(country[1])
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const ALL_COUNTRIES: { [key: string]: string } = {
|
|
42
|
-
AF: "Afghanistan",
|
|
43
|
-
AX: "Åland Islands",
|
|
44
|
-
AL: "Albania",
|
|
45
|
-
DZ: "Algeria",
|
|
46
|
-
AS: "American Samoa",
|
|
47
|
-
AD: "Andorra",
|
|
48
|
-
AO: "Angola",
|
|
49
|
-
AI: "Anguilla",
|
|
50
|
-
AQ: "Antarctica",
|
|
51
|
-
AG: "Antigua and Barbuda",
|
|
52
|
-
AR: "Argentina",
|
|
53
|
-
AM: "Armenia",
|
|
54
|
-
AW: "Aruba",
|
|
55
|
-
AU: "Australia",
|
|
56
|
-
AT: "Austria",
|
|
57
|
-
AZ: "Azerbaijan",
|
|
58
|
-
BS: "Bahamas",
|
|
59
|
-
BH: "Bahrain",
|
|
60
|
-
BD: "Bangladesh",
|
|
61
|
-
BB: "Barbados",
|
|
62
|
-
BY: "Belarus",
|
|
63
|
-
BE: "Belgium",
|
|
64
|
-
BZ: "Belize",
|
|
65
|
-
BJ: "Benin",
|
|
66
|
-
BM: "Bermuda",
|
|
67
|
-
BT: "Bhutan",
|
|
68
|
-
BO: "Bolivia (Plurinational State of)",
|
|
69
|
-
BQ: "Bonaire, Sint Eustatius and Saba",
|
|
70
|
-
BA: "Bosnia and Herzegovina",
|
|
71
|
-
BW: "Botswana",
|
|
72
|
-
BV: "Bouvet Island",
|
|
73
|
-
BR: "Brazil",
|
|
74
|
-
IO: "British Indian Ocean Territory",
|
|
75
|
-
BN: "Brunei Darussalam",
|
|
76
|
-
BG: "Bulgaria",
|
|
77
|
-
BF: "Burkina Faso",
|
|
78
|
-
BI: "Burundi",
|
|
79
|
-
CV: "Caboe Verde",
|
|
80
|
-
KH: "Cambodia",
|
|
81
|
-
CM: "Cameroon",
|
|
82
|
-
CA: "Canada",
|
|
83
|
-
KY: "Cayman Islands",
|
|
84
|
-
CF: "Central African Republic",
|
|
85
|
-
TD: "Chad",
|
|
86
|
-
CL: "Chile",
|
|
87
|
-
CN: "China",
|
|
88
|
-
CX: "Christmas Island",
|
|
89
|
-
CC: "Cocos (Keeling) Islands",
|
|
90
|
-
CO: "Colombia",
|
|
91
|
-
KM: "Comoros",
|
|
92
|
-
CG: "Congo",
|
|
93
|
-
CD: "Congo, Democratic Republic of the",
|
|
94
|
-
CK: "Cook Islands",
|
|
95
|
-
CR: "Costa Rica",
|
|
96
|
-
CI: "Côte d'voire",
|
|
97
|
-
HR: "Croatia",
|
|
98
|
-
CU: "Cuba",
|
|
99
|
-
CW: "Curaçao",
|
|
100
|
-
CY: "Cyprus",
|
|
101
|
-
CZ: "Czechia",
|
|
102
|
-
DK: "Denmark",
|
|
103
|
-
DJ: "Djibouti",
|
|
104
|
-
DM: "Dominica",
|
|
105
|
-
DO: "Dominican Republic",
|
|
106
|
-
EC: "Ecuador",
|
|
107
|
-
EG: "Egypt",
|
|
108
|
-
SV: "El Salvador",
|
|
109
|
-
GQ: "Equatorial Guinea",
|
|
110
|
-
ER: "Eritrea",
|
|
111
|
-
EE: "Estonia",
|
|
112
|
-
SZ: "Eswatini",
|
|
113
|
-
ET: "Ethiopia",
|
|
114
|
-
FK: "Falkland Islands (Malvinas)",
|
|
115
|
-
FO: "Faroe Islands",
|
|
116
|
-
FJ: "Fiji",
|
|
117
|
-
FI: "Finland",
|
|
118
|
-
FR: "France",
|
|
119
|
-
GF: "French Guiana",
|
|
120
|
-
PF: "French Polynesia",
|
|
121
|
-
TF: "French Southern Territories",
|
|
122
|
-
GA: "Gabon",
|
|
123
|
-
GM: "Gambia",
|
|
124
|
-
GE: "Georgia",
|
|
125
|
-
DE: "Germany",
|
|
126
|
-
GH: "Ghana",
|
|
127
|
-
GI: "Gibraltar",
|
|
128
|
-
GR: "Greece",
|
|
129
|
-
GL: "Greenland",
|
|
130
|
-
GD: "Grenada",
|
|
131
|
-
GP: "Guadeloupe",
|
|
132
|
-
GU: "Guam",
|
|
133
|
-
GT: "Guatemala",
|
|
134
|
-
GG: "Guernsey",
|
|
135
|
-
GN: "Guinea",
|
|
136
|
-
GW: "Guinea-Bissau",
|
|
137
|
-
GY: "Guyana",
|
|
138
|
-
HT: "Haiti",
|
|
139
|
-
HM: "Heard Island and Mcdonald Islands",
|
|
140
|
-
VA: "Holy See",
|
|
141
|
-
HN: "Honduras",
|
|
142
|
-
HK: "Hong Kong",
|
|
143
|
-
HU: "Hungary",
|
|
144
|
-
IS: "Iceland",
|
|
145
|
-
IN: "India",
|
|
146
|
-
ID: "Indonesia",
|
|
147
|
-
IR: "Iran (Islamic Republic of)",
|
|
148
|
-
IQ: "Iraq",
|
|
149
|
-
IE: "Ireland",
|
|
150
|
-
IM: "Isle of Man",
|
|
151
|
-
IL: "Israel",
|
|
152
|
-
IT: "Italy",
|
|
153
|
-
JM: "Jamaica",
|
|
154
|
-
JP: "Japan",
|
|
155
|
-
JE: "Jersey",
|
|
156
|
-
JO: "Jordan",
|
|
157
|
-
KZ: "Kazakhstan",
|
|
158
|
-
KE: "Kenya",
|
|
159
|
-
KI: "Kiribati",
|
|
160
|
-
KP: "Korea (Democratic People's Republic of)",
|
|
161
|
-
KR: "Korea (Republic of)",
|
|
162
|
-
KW: "Kuwait",
|
|
163
|
-
KG: "Kyrgyzstan",
|
|
164
|
-
LA: "Lao People's Democratic Republic",
|
|
165
|
-
LV: "Latvia",
|
|
166
|
-
LB: "Lebanon",
|
|
167
|
-
LS: "Lesotho",
|
|
168
|
-
LR: "Liberia",
|
|
169
|
-
LY: "Libya",
|
|
170
|
-
LI: "Liechtenstein",
|
|
171
|
-
LT: "Lithuania",
|
|
172
|
-
LU: "Luxembourg",
|
|
173
|
-
MO: "Macao",
|
|
174
|
-
MG: "Madagascar",
|
|
175
|
-
MW: "Malawi",
|
|
176
|
-
MY: "Malaysia",
|
|
177
|
-
MV: "Maldives",
|
|
178
|
-
ML: "Mali",
|
|
179
|
-
MT: "Malta",
|
|
180
|
-
MH: "Marshall Islands",
|
|
181
|
-
MQ: "Martinique",
|
|
182
|
-
MR: "Mauritania",
|
|
183
|
-
MU: "Mauritius",
|
|
184
|
-
YT: "Mayotte",
|
|
185
|
-
MX: "Mexico",
|
|
186
|
-
FM: "Micronesia (Federated States of)",
|
|
187
|
-
MD: "Moldova, Republic of",
|
|
188
|
-
MC: "Monaco",
|
|
189
|
-
MN: "Mongolia",
|
|
190
|
-
ME: "Montenegro",
|
|
191
|
-
MS: "Montserrat",
|
|
192
|
-
MA: "Morocco",
|
|
193
|
-
MZ: "Mozambique",
|
|
194
|
-
MM: "Myanmar",
|
|
195
|
-
NA: "Namibia",
|
|
196
|
-
NR: "Nauru",
|
|
197
|
-
NP: "Nepal",
|
|
198
|
-
NL: "Netherlands, Kingdom of the",
|
|
199
|
-
NC: "New Caledonia",
|
|
200
|
-
NZ: "New Zealand",
|
|
201
|
-
NI: "Nicaragua",
|
|
202
|
-
NE: "Niger",
|
|
203
|
-
NG: "Nigeria",
|
|
204
|
-
NU: "Niue",
|
|
205
|
-
NF: "Norfolk Island",
|
|
206
|
-
MK: "North Macedonia",
|
|
207
|
-
MP: "Northern Mariana Islands",
|
|
208
|
-
NO: "Norway",
|
|
209
|
-
OM: "Oman",
|
|
210
|
-
PK: "Pakistan",
|
|
211
|
-
PW: "Palau",
|
|
212
|
-
PS: "Palestine, State of",
|
|
213
|
-
PA: "Panama",
|
|
214
|
-
PG: "Papua New Guinea",
|
|
215
|
-
PY: "Paraguay",
|
|
216
|
-
PE: "Peru",
|
|
217
|
-
PH: "Philippines",
|
|
218
|
-
PN: "Pitcairn",
|
|
219
|
-
PL: "Poland",
|
|
220
|
-
PT: "Portugal",
|
|
221
|
-
PR: "Puerto Rico",
|
|
222
|
-
QA: "Qatar",
|
|
223
|
-
RE: "Réunion",
|
|
224
|
-
RO: "Romania",
|
|
225
|
-
RU: "Russian Federation",
|
|
226
|
-
RW: "Rwanda",
|
|
227
|
-
BL: "Saint Barthélemy",
|
|
228
|
-
SH: "Saint Helena, Ascension Island, Tristan da Cunha",
|
|
229
|
-
KN: "Saint Kitts and Nevis",
|
|
230
|
-
LC: "Saint Lucia",
|
|
231
|
-
MF: "Saint Martin (French part)",
|
|
232
|
-
PM: "Saint Pierre and Miquelon",
|
|
233
|
-
VC: "Saint Vincent and the Grenadines",
|
|
234
|
-
WS: "Samoa",
|
|
235
|
-
SM: "San Marino",
|
|
236
|
-
ST: "Sao Tome and Principe",
|
|
237
|
-
SA: "Saudi Arabia",
|
|
238
|
-
SN: "Senegal",
|
|
239
|
-
RS: "Serbia",
|
|
240
|
-
SC: "Seychelles",
|
|
241
|
-
SL: "Sierra Leone",
|
|
242
|
-
SG: "Singapore",
|
|
243
|
-
SX: "Sint Maarten (Dutch part)",
|
|
244
|
-
SK: "Slovakia",
|
|
245
|
-
SI: "Slovenia",
|
|
246
|
-
SB: "Solomon Islands",
|
|
247
|
-
SO: "Somalia",
|
|
248
|
-
ZA: "South Africa",
|
|
249
|
-
GS: "South Georgia and the South Sandwich Islands",
|
|
250
|
-
SS: "South Sudan",
|
|
251
|
-
ES: "Spain",
|
|
252
|
-
LK: "Sri Lanka",
|
|
253
|
-
SD: "Sudan",
|
|
254
|
-
SR: "Suriname",
|
|
255
|
-
SJ: "Svalbard and Jan Mayen",
|
|
256
|
-
SE: "Sweden",
|
|
257
|
-
CH: "Switzerland",
|
|
258
|
-
SY: "Syrian Arab Republic",
|
|
259
|
-
TW: "Taiwan, Province of China",
|
|
260
|
-
TJ: "Tajikistan",
|
|
261
|
-
TZ: "Tanzania, United Republic of",
|
|
262
|
-
TH: "Thailand",
|
|
263
|
-
TL: "Timor-Leste",
|
|
264
|
-
TG: "Togo",
|
|
265
|
-
TK: "Tokelau",
|
|
266
|
-
TO: "Tonga",
|
|
267
|
-
TT: "Trinidad and Tobago",
|
|
268
|
-
TN: "Tunisia",
|
|
269
|
-
TR: "Türkiye",
|
|
270
|
-
TM: "Turkmenistan",
|
|
271
|
-
TC: "Turks and Caicos Islands",
|
|
272
|
-
TV: "Tuvalu",
|
|
273
|
-
UG: "Uganda",
|
|
274
|
-
UA: "Ukraine",
|
|
275
|
-
AE: "United Arab Emirates",
|
|
276
|
-
GB: "United Kingdom of Great Britain and Northern Ireland",
|
|
277
|
-
UM: "United States Minor Outlying Islands",
|
|
278
|
-
US: "United States of America",
|
|
279
|
-
UY: "Uruguay",
|
|
280
|
-
UZ: "Uzbekistan",
|
|
281
|
-
VU: "Vanuatu",
|
|
282
|
-
VE: "Venezuela (Bolivarian Republic of)",
|
|
283
|
-
VN: "Viet Nam",
|
|
284
|
-
VG: "Virgin Islands (British)",
|
|
285
|
-
VI: "Virgin Islands (U.S)",
|
|
286
|
-
WF: "Wallis and Futuna",
|
|
287
|
-
EH: "Western Sahara",
|
|
288
|
-
YE: "Yemen",
|
|
289
|
-
ZM: "Zambia",
|
|
290
|
-
ZW: "Zimbabwe",
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
/** Options for MultiSelect component */
|
|
294
|
-
export const COUNTRY_OPTIONS: SelectOption[] = Object.entries(ALL_COUNTRIES).map((v) => {
|
|
295
|
-
return {
|
|
296
|
-
label: (
|
|
297
|
-
<>
|
|
298
|
-
{getCountryFlag(v[0])} {v[1]}
|
|
299
|
-
</>
|
|
300
|
-
),
|
|
301
|
-
id: v[0],
|
|
302
|
-
};
|
|
303
|
-
});
|