@clicktap/ui 0.14.13 → 0.14.15
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/components/Link/Link.js +1 -1
- package/components/Link/Link.tsx +18 -13
- package/components/Select/Select.d.ts +7 -1
- package/components/Select/Select.js +1 -1
- package/components/Select/Select.tsx +35 -17
- package/components/Select/Select.types.d.ts +2 -1
- package/components/Select/Select.types.ts +7 -1
- package/package.json +1 -1
package/components/Link/Link.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import{forwardRef as d}from"react";import{Link as l}from"react-aria-components";import{cn as u}from"../../utils/cn.js";const x=d(({children:e,isDisabled:r,className:t,...o},a)=>n(l,{...o,isDisabled:r,className:s=>{const i=typeof t=="function"?t(s):t;return u("flex items-center cursor-pointer","text-slate-500","no-underline","transition-colors duration-300","hover:text-slate-800",['data-[disabled="true"]:cursor-default','data-[disabled="true"]:text-slate-300','data-[disabled="true"]:hover:text-slate-300'],i)},ref:a,children:e}));export{x as Link,x as default};
|
package/components/Link/Link.tsx
CHANGED
|
@@ -11,19 +11,24 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
11
11
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
12
12
|
{...props}
|
|
13
13
|
isDisabled={isDisabled}
|
|
14
|
-
className={
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
className={(renderProps) => {
|
|
15
|
+
const userClasses =
|
|
16
|
+
typeof className === 'function' ? className(renderProps) : className;
|
|
17
|
+
|
|
18
|
+
return cn(
|
|
19
|
+
'flex items-center cursor-pointer',
|
|
20
|
+
'text-slate-500',
|
|
21
|
+
'no-underline',
|
|
22
|
+
'transition-colors duration-300',
|
|
23
|
+
'hover:text-slate-800',
|
|
24
|
+
[
|
|
25
|
+
'data-[disabled="true"]:cursor-default',
|
|
26
|
+
'data-[disabled="true"]:text-slate-300',
|
|
27
|
+
'data-[disabled="true"]:hover:text-slate-300',
|
|
28
|
+
],
|
|
29
|
+
userClasses
|
|
30
|
+
);
|
|
31
|
+
}}
|
|
27
32
|
ref={ref}
|
|
28
33
|
>
|
|
29
34
|
{children}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { ForwardedRef } from 'react';
|
|
1
2
|
import { SelectProps } from './Select.types';
|
|
2
|
-
|
|
3
|
+
interface SelectComponent {
|
|
4
|
+
<T extends object>(props: SelectProps<T> & {
|
|
5
|
+
ref?: ForwardedRef<HTMLInputElement>;
|
|
6
|
+
}): JSX.Element;
|
|
7
|
+
}
|
|
8
|
+
export declare const Select: SelectComponent;
|
|
3
9
|
export default Select;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as v,Fragment as
|
|
1
|
+
import{jsx as e,jsxs as v,Fragment as P}from"react/jsx-runtime";import{Popover as j,ComboBox as m,Label as A,Input as D,Button as E,Text as F,FieldError as M,ListBox as T}from"react-aria-components";import{forwardRef as w,useState as g}from"react";import{motion as R}from"framer-motion";import{cn as o}from"../../utils/cn.js";import{Pulse as U}from"../Loader/Pulse.js";const W=w((d,i)=>e(j,{...d,ref:i})),q=R.create(W);function z({buttonIcon:d,...i}){return d?typeof d=="function"?d(i):d:e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:o("transition-all ease-in-out duration-200",i.isOpen?"rotate-180":"rotate-0"),children:e("path",{d:"M6 9L12 15L18 9",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:o(["stroke-slate-900",i.isDisabled&&"stroke-slate-400",i.isInvalid&&"stroke-red-500"])})})}function G({listBoxComponent:d,children:i,...r}){return e(d||T,{...r,children:i})}function H({label:d,description:i,errorMessage:r,children:u,placeholder:C,key:B,isLoading:a,slots:n,popoverPortalContainer:c,popoverOffset:_,selectedKey:x,className:k,classNames:t,autoComplete:y,...b},L){const[l,f]=g("unmounted"),[h,S]=g(!1);return e(m,{onOpenChange:()=>{f(l==="visible"?"hidden":"visible"),S(!h)},isDisabled:b.isDisabled||a,"data-has-value":!!x,selectedKey:x,...b,className:o("flex flex-col","w-full",k),children:I=>v(P,{children:[e(A,{className:o("flex","text-xs text-slate-500",t==null?void 0:t.label),children:d}),v("div",{className:o("flex","relative","w-full",t==null?void 0:t.comboBoxContainer),children:[e(D,{placeholder:C,className:o("border border-solid border-slate-300","text-sm text-slate-900","py-0 px-2","h-10 w-full","m-0","rounded-md","bg-white","transition-all ease-in-out duration-200","data-[hovered]:border-slate-400","data-[focused]:border-slate-400 data-[focused]:outline data-[focused]:outline-2 data-[focused]:outline-slate-200"," data-[disabled]:bg-slate-100 data-[disabled]:border-slate-300",a?"data-[disabled]:text-slate-900":"data-[disabled]:text-slate-500","data-[invalid]:border-red-500 data-[invalid]:bg-red-100 data-[invalid]:text-red-600","data-[invalid]:data-[hovered]:border-red-600","data-[invalid]:data-[focused]:border-red-600 data-[invalid]:data-[focused]:outline data-[invalid]:data-[focused]:outline-2 data-[invalid]:data-[focused]:outline-red-200","data-[invalid]:placeholder:text-slate-400",t==null?void 0:t.input),ref:L,autoComplete:y}),a?e("div",{className:o("absolute top-2 right-2","block",t==null?void 0:t.loader),children:(n==null?void 0:n.loadingIcon)||e(U,{})}):e(E,{className:o("absolute top-2 right-0","block","border-none","bg-none",t==null?void 0:t.arrowButton),children:e(z,{buttonIcon:n==null?void 0:n.buttonIcon,...I})})]}),i&&e(F,{slot:"description",className:o("flex","text-xs","text-slate-500",t==null?void 0:t.description),children:i}),e(M,{className:o("flex","text-xs","text-red-500",t==null?void 0:t.errorMessage),children:r}),e(q,{isOpen:h,isExiting:l==="hidden",offset:_,UNSTABLE_portalContainer:c,onAnimationComplete:O=>{f(p=>O==="hidden"&&p==="hidden"?"unmounted":p)},variants:{hidden:{opacity:0,y:-10},visible:{opacity:1,y:0}},initial:"hidden",animate:l,className:o("px-0 py-1.5","shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_4px_6px_-4px_rgba(0,0,0,0.1)]","rounded-md","w-[var(--trigger-width)]","bg-white","border border-solid border-slate-300",t==null?void 0:t.listContainer),children:e(G,{listBoxComponent:n==null?void 0:n.listBoxComponent,className:o("max-h-80","overflow-y-scroll",t==null?void 0:t.list),children:u})},B)]})})}const $=w(H);export{$ as Select,$ as default};
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from 'react-aria-components';
|
|
13
13
|
import type { ComboBoxRenderProps, ListBoxProps } from 'react-aria-components';
|
|
14
14
|
import { forwardRef, useState } from 'react';
|
|
15
|
-
import type {
|
|
15
|
+
import type { ForwardedRef, Ref } from 'react';
|
|
16
16
|
import { motion } from 'framer-motion';
|
|
17
17
|
import { cn } from '../../utils/cn';
|
|
18
18
|
import { Pulse } from '../Loader';
|
|
@@ -85,22 +85,28 @@ function ListBoxSlot<T extends object>({
|
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
// Internal component - necessary to preserve generics in children
|
|
89
|
+
// i.e. <Select items={[{id: 'test', value: 'test'}]}.../> won't reference "any"
|
|
90
|
+
function SelectInner<T extends object>(
|
|
91
|
+
{
|
|
92
|
+
label,
|
|
93
|
+
description,
|
|
94
|
+
errorMessage,
|
|
95
|
+
children,
|
|
96
|
+
placeholder,
|
|
97
|
+
key,
|
|
98
|
+
isLoading,
|
|
99
|
+
slots,
|
|
100
|
+
popoverPortalContainer,
|
|
101
|
+
popoverOffset,
|
|
102
|
+
selectedKey,
|
|
103
|
+
className,
|
|
104
|
+
classNames,
|
|
105
|
+
autoComplete,
|
|
106
|
+
...props
|
|
107
|
+
}: SelectProps<T>,
|
|
108
|
+
ref: ForwardedRef<HTMLInputElement>
|
|
109
|
+
) {
|
|
104
110
|
const [animation, setAnimation] =
|
|
105
111
|
useState<ComboBoxPopoverAnimationState>('unmounted');
|
|
106
112
|
const [isComboOpen, setIsComboOpen] = useState<boolean>(false);
|
|
@@ -156,6 +162,8 @@ export function Select<T extends object>({
|
|
|
156
162
|
'data-[invalid]:placeholder:text-slate-400',
|
|
157
163
|
classNames?.input
|
|
158
164
|
)}
|
|
165
|
+
ref={ref}
|
|
166
|
+
autoComplete={autoComplete}
|
|
159
167
|
/>
|
|
160
168
|
{isLoading ? (
|
|
161
169
|
<div
|
|
@@ -250,4 +258,14 @@ export function Select<T extends object>({
|
|
|
250
258
|
);
|
|
251
259
|
}
|
|
252
260
|
|
|
261
|
+
// Type for the exported component that preserves generics
|
|
262
|
+
interface SelectComponent {
|
|
263
|
+
<T extends object>(
|
|
264
|
+
props: SelectProps<T> & { ref?: ForwardedRef<HTMLInputElement> }
|
|
265
|
+
): JSX.Element;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Create the forwarded component with proper typing
|
|
269
|
+
export const Select = forwardRef(SelectInner) as SelectComponent;
|
|
270
|
+
|
|
253
271
|
export default Select;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComboBoxRenderProps, ComboBoxProps as AriaComboBoxProps, ValidationResult, ListBoxProps } from 'react-aria-components';
|
|
2
|
-
import { ComponentType, Key, ReactNode } from 'react';
|
|
2
|
+
import { ComponentType, HTMLInputAutoCompleteAttribute, Key, ReactNode } from 'react';
|
|
3
3
|
import { SlotsToClasses } from '../../types/SlotsToClasses';
|
|
4
4
|
export type ComboBoxPopoverAnimationState = 'unmounted' | 'hidden' | 'visible';
|
|
5
5
|
export type SelectSlots<T extends object> = {
|
|
@@ -19,4 +19,5 @@ export interface SelectProps<T extends object> extends Omit<AriaComboBoxProps<T>
|
|
|
19
19
|
popoverOffset?: number;
|
|
20
20
|
popoverPortalContainer?: Element;
|
|
21
21
|
classNames?: SlotsToClasses<'label' | 'name' | 'comboBoxContainer' | 'input' | 'loader' | 'arrowButton' | 'description' | 'errorMessage' | 'listContainer' | 'list'>;
|
|
22
|
+
autoComplete?: HTMLInputAutoCompleteAttribute;
|
|
22
23
|
}
|
|
@@ -4,7 +4,12 @@ import type {
|
|
|
4
4
|
ValidationResult,
|
|
5
5
|
ListBoxProps,
|
|
6
6
|
} from 'react-aria-components';
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
ComponentType,
|
|
9
|
+
HTMLInputAutoCompleteAttribute,
|
|
10
|
+
Key,
|
|
11
|
+
ReactNode,
|
|
12
|
+
} from 'react';
|
|
8
13
|
import type { SlotsToClasses } from '../../types/SlotsToClasses';
|
|
9
14
|
|
|
10
15
|
export type ComboBoxPopoverAnimationState = 'unmounted' | 'hidden' | 'visible';
|
|
@@ -39,4 +44,5 @@ export interface SelectProps<T extends object>
|
|
|
39
44
|
| 'listContainer'
|
|
40
45
|
| 'list'
|
|
41
46
|
>;
|
|
47
|
+
autoComplete?: HTMLInputAutoCompleteAttribute;
|
|
42
48
|
}
|