@a-type/ui 4.0.9 → 4.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/autocomplete/Autocomplete.d.ts +114 -0
- package/dist/cjs/components/autocomplete/Autocomplete.js +119 -0
- package/dist/cjs/components/autocomplete/Autocomplete.js.map +1 -0
- package/dist/cjs/components/autocomplete/Autocomplete.stories.d.ts +52 -0
- package/dist/cjs/components/autocomplete/Autocomplete.stories.js +94 -0
- package/dist/cjs/components/autocomplete/Autocomplete.stories.js.map +1 -0
- package/dist/cjs/components/chip/Chip.d.ts +3 -4
- package/dist/cjs/components/chip/Chip.js +1 -1
- package/dist/cjs/components/chip/Chip.js.map +1 -1
- package/dist/cjs/components/chip/Chip.stories.js +1 -1
- package/dist/cjs/components/chip/Chip.stories.js.map +1 -1
- package/dist/cjs/components/dialog/Dialog.js +7 -7
- package/dist/cjs/components/dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/dropdownMenu/DropdownMenu.js +11 -44
- package/dist/cjs/components/dropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/cjs/components/forms/TextField.js +1 -1
- package/dist/cjs/components/forms/TextField.js.map +1 -1
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/input/Input.d.ts +12 -5
- package/dist/cjs/components/input/Input.js +26 -12
- package/dist/cjs/components/input/Input.js.map +1 -1
- package/dist/cjs/components/input/Input.stories.d.ts +5 -1
- package/dist/cjs/components/input/Input.stories.js +6 -2
- package/dist/cjs/components/input/Input.stories.js.map +1 -1
- package/dist/cjs/components/layouts/PageNowPlaying.d.ts +1 -2
- package/dist/cjs/components/layouts/PageNowPlaying.js +2 -4
- package/dist/cjs/components/layouts/PageNowPlaying.js.map +1 -1
- package/dist/cjs/components/popover/Popover.js +6 -5
- package/dist/cjs/components/popover/Popover.js.map +1 -1
- package/dist/cjs/components/primitives/menus.d.ts +5 -0
- package/dist/cjs/components/primitives/menus.js +14 -0
- package/dist/cjs/components/primitives/menus.js.map +1 -0
- package/dist/cjs/components/quickAction/QuickAction.d.ts +17 -0
- package/dist/cjs/components/quickAction/QuickAction.js +63 -0
- package/dist/cjs/components/quickAction/QuickAction.js.map +1 -0
- package/dist/cjs/components/quickAction/QuickAction.stories.d.ts +22 -0
- package/dist/cjs/components/quickAction/QuickAction.stories.js +61 -0
- package/dist/cjs/components/quickAction/QuickAction.stories.js.map +1 -0
- package/dist/cjs/components/textArea/TextArea.d.ts +2 -2
- package/dist/cjs/components/textArea/TextArea.js +6 -17
- package/dist/cjs/components/textArea/TextArea.js.map +1 -1
- package/dist/cjs/components/textArea/TextArea.stories.d.ts +1 -1
- package/dist/cjs/systems/inputs.d.ts +3 -0
- package/dist/cjs/systems/inputs.js +14 -0
- package/dist/cjs/systems/inputs.js.map +1 -0
- package/dist/cjs/uno/preflights/layers.js +1 -1
- package/dist/cjs/uno/preflights/layers.js.map +1 -1
- package/dist/css/main.css +7 -6
- package/dist/esm/components/autocomplete/Autocomplete.d.ts +114 -0
- package/dist/esm/components/autocomplete/Autocomplete.js +113 -0
- package/dist/esm/components/autocomplete/Autocomplete.js.map +1 -0
- package/dist/esm/components/autocomplete/Autocomplete.stories.d.ts +52 -0
- package/dist/esm/components/autocomplete/Autocomplete.stories.js +91 -0
- package/dist/esm/components/autocomplete/Autocomplete.stories.js.map +1 -0
- package/dist/esm/components/chip/Chip.d.ts +3 -4
- package/dist/esm/components/chip/Chip.js +1 -1
- package/dist/esm/components/chip/Chip.js.map +1 -1
- package/dist/esm/components/chip/Chip.stories.js +1 -1
- package/dist/esm/components/chip/Chip.stories.js.map +1 -1
- package/dist/esm/components/dialog/Dialog.js +7 -7
- package/dist/esm/components/dialog/Dialog.js.map +1 -1
- package/dist/esm/components/dropdownMenu/DropdownMenu.js +8 -8
- package/dist/esm/components/dropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/esm/components/forms/TextField.js +1 -1
- package/dist/esm/components/forms/TextField.js.map +1 -1
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/input/Input.d.ts +12 -5
- package/dist/esm/components/input/Input.js +29 -14
- package/dist/esm/components/input/Input.js.map +1 -1
- package/dist/esm/components/input/Input.stories.d.ts +5 -1
- package/dist/esm/components/input/Input.stories.js +5 -1
- package/dist/esm/components/input/Input.stories.js.map +1 -1
- package/dist/esm/components/layouts/PageNowPlaying.d.ts +1 -2
- package/dist/esm/components/layouts/PageNowPlaying.js +2 -4
- package/dist/esm/components/layouts/PageNowPlaying.js.map +1 -1
- package/dist/esm/components/popover/Popover.js +6 -5
- package/dist/esm/components/popover/Popover.js.map +1 -1
- package/dist/esm/components/primitives/menus.d.ts +5 -0
- package/dist/esm/components/primitives/menus.js +8 -0
- package/dist/esm/components/primitives/menus.js.map +1 -0
- package/dist/esm/components/quickAction/QuickAction.d.ts +17 -0
- package/dist/esm/components/quickAction/QuickAction.js +56 -0
- package/dist/esm/components/quickAction/QuickAction.js.map +1 -0
- package/dist/esm/components/quickAction/QuickAction.stories.d.ts +22 -0
- package/dist/esm/components/quickAction/QuickAction.stories.js +55 -0
- package/dist/esm/components/quickAction/QuickAction.stories.js.map +1 -0
- package/dist/esm/components/textArea/TextArea.d.ts +2 -2
- package/dist/esm/components/textArea/TextArea.js +6 -17
- package/dist/esm/components/textArea/TextArea.js.map +1 -1
- package/dist/esm/components/textArea/TextArea.stories.d.ts +1 -1
- package/dist/esm/systems/inputs.d.ts +3 -0
- package/dist/esm/systems/inputs.js +11 -0
- package/dist/esm/systems/inputs.js.map +1 -0
- package/dist/esm/uno/preflights/layers.js +1 -1
- package/dist/esm/uno/preflights/layers.js.map +1 -1
- package/package.json +2 -2
- package/src/components/autocomplete/Autocomplete.stories.tsx +221 -0
- package/src/components/autocomplete/Autocomplete.tsx +343 -0
- package/src/components/chip/Chip.stories.tsx +1 -4
- package/src/components/chip/Chip.tsx +5 -7
- package/src/components/dialog/Dialog.tsx +535 -535
- package/src/components/dropdownMenu/DropdownMenu.tsx +173 -190
- package/src/components/forms/TextField.tsx +140 -140
- package/src/components/index.ts +2 -0
- package/src/components/input/Input.stories.tsx +14 -1
- package/src/components/input/Input.tsx +109 -74
- package/src/components/layouts/PageNowPlaying.tsx +1 -5
- package/src/components/popover/Popover.tsx +123 -132
- package/src/components/primitives/menus.tsx +44 -0
- package/src/components/quickAction/QuickAction.stories.tsx +106 -0
- package/src/components/quickAction/QuickAction.tsx +107 -0
- package/src/components/textArea/TextArea.tsx +80 -105
- package/src/systems/inputs.ts +11 -0
- package/src/uno/preflights/layers.ts +1 -1
|
@@ -1,190 +1,173 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {
|
|
3
|
-
Menu as BaseMenu,
|
|
4
|
-
MenuArrowProps,
|
|
5
|
-
MenuItemProps,
|
|
6
|
-
MenuPopupProps,
|
|
7
|
-
MenuPositionerProps,
|
|
8
|
-
MenuTriggerProps,
|
|
9
|
-
} from '@base-ui/react/menu';
|
|
10
|
-
import
|
|
11
|
-
import { Ref } from 'react';
|
|
12
|
-
import { withClassName } from '../../hooks/withClassName.js';
|
|
13
|
-
import { GroupScaleReset } from '../../systems/GroupScale.js';
|
|
14
|
-
import { PaletteName } from '../../uno/index.js';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'layer-components:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'layer-components:(
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
export const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
export const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
export const DropdownMenuItemRightSlot = withClassName('div', 'ml-auto pl-md');
|
|
175
|
-
|
|
176
|
-
export const DropdownMenu = Object.assign(DropdownMenuRoot, {
|
|
177
|
-
Content: DropdownMenuContent,
|
|
178
|
-
Trigger: DropdownMenuTrigger,
|
|
179
|
-
Item: StyledItem,
|
|
180
|
-
CheckboxItem: StyledCheckboxItem,
|
|
181
|
-
RadioGroup: BaseMenu.RadioGroup,
|
|
182
|
-
RadioItem: StyledRadioItem,
|
|
183
|
-
ItemIndicator: StyledItemIndicator,
|
|
184
|
-
Label: StyledLabel,
|
|
185
|
-
Separator: StyledSeparator,
|
|
186
|
-
Arrow: StyledArrow,
|
|
187
|
-
ItemRightSlot: DropdownMenuItemRightSlot,
|
|
188
|
-
TriggerIcon: DropdownMenuTriggerIcon,
|
|
189
|
-
createHandle: BaseMenu.createHandle,
|
|
190
|
-
});
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
Menu as BaseMenu,
|
|
4
|
+
MenuArrowProps,
|
|
5
|
+
MenuItemProps,
|
|
6
|
+
MenuPopupProps,
|
|
7
|
+
MenuPositionerProps,
|
|
8
|
+
MenuTriggerProps,
|
|
9
|
+
} from '@base-ui/react/menu';
|
|
10
|
+
import { clsx } from 'clsx';
|
|
11
|
+
import { Ref } from 'react';
|
|
12
|
+
import { withClassName } from '../../hooks/withClassName.js';
|
|
13
|
+
import { GroupScaleReset } from '../../systems/GroupScale.js';
|
|
14
|
+
import { PaletteName } from '../../uno/index.js';
|
|
15
|
+
import {
|
|
16
|
+
itemClassName,
|
|
17
|
+
itemListClassName,
|
|
18
|
+
popupClassName,
|
|
19
|
+
} from '../primitives/menus.js';
|
|
20
|
+
import { ArrowSvg } from '../utility/ArrowSvg.js';
|
|
21
|
+
import { SlotDiv } from '../utility/SlotDiv.js';
|
|
22
|
+
import { DropdownTriggerProvider } from './DropdownTriggerContext.js';
|
|
23
|
+
|
|
24
|
+
const StyledContent = withClassName(
|
|
25
|
+
function DropdownMenuContent(props: MenuPopupProps) {
|
|
26
|
+
return (
|
|
27
|
+
<GroupScaleReset>
|
|
28
|
+
<BaseMenu.Popup {...props} />
|
|
29
|
+
</GroupScaleReset>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
popupClassName,
|
|
33
|
+
'layer-components:(min-w-220px)',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const StyledItemBase = withClassName(BaseMenu.Item, itemClassName);
|
|
37
|
+
export interface DropdownMenuItemProps extends MenuItemProps {
|
|
38
|
+
color?: PaletteName;
|
|
39
|
+
ref?: Ref<HTMLDivElement>;
|
|
40
|
+
}
|
|
41
|
+
const StyledItem = ({
|
|
42
|
+
ref: forwardedRef,
|
|
43
|
+
className,
|
|
44
|
+
color = 'gray',
|
|
45
|
+
...props
|
|
46
|
+
}: DropdownMenuItemProps) => {
|
|
47
|
+
return (
|
|
48
|
+
<StyledItemBase
|
|
49
|
+
{...props}
|
|
50
|
+
className={clsx(color && `palette-${color}`, className)}
|
|
51
|
+
ref={forwardedRef}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
const StyledCheckboxItem = withClassName(BaseMenu.CheckboxItem, itemClassName);
|
|
56
|
+
const StyledRadioItem = withClassName(BaseMenu.RadioItem, itemClassName);
|
|
57
|
+
|
|
58
|
+
const StyledLabel = withClassName(
|
|
59
|
+
'span',
|
|
60
|
+
'layer-components:(py-1 pl-3 text-sm font-bold leading-6)',
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const StyledSeparator = withClassName(
|
|
64
|
+
BaseMenu.Separator,
|
|
65
|
+
'layer-components:(m-5px h-1px bg-gray)',
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const StyledItemIndicator = withClassName(
|
|
69
|
+
BaseMenu.CheckboxItemIndicator,
|
|
70
|
+
'layer-components:(absolute left-0 w-25px inline-flex items-center justify-center)',
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const StyledArrow = withClassName(
|
|
74
|
+
(props: MenuArrowProps) => (
|
|
75
|
+
<BaseMenu.Arrow {...props}>
|
|
76
|
+
<ArrowSvg />
|
|
77
|
+
</BaseMenu.Arrow>
|
|
78
|
+
),
|
|
79
|
+
'layer-components:(arrow)',
|
|
80
|
+
'layer-components:data-[closed]:(scale-0 opacity-0)',
|
|
81
|
+
'layer-components:data-[open]:(scale-100 opacity-100)',
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const StyledTrigger = withClassName(BaseMenu.Trigger, 'select-none');
|
|
85
|
+
|
|
86
|
+
const StyledPortal = BaseMenu.Portal;
|
|
87
|
+
|
|
88
|
+
// Exports
|
|
89
|
+
export const DropdownMenuRoot = BaseMenu.Root;
|
|
90
|
+
export const DropdownMenuItem = StyledItem;
|
|
91
|
+
export const DropdownMenuCheckboxItem = StyledCheckboxItem;
|
|
92
|
+
export const DropdownMenuRadioGroup = BaseMenu.RadioGroup;
|
|
93
|
+
export const DropdownMenuRadioItem = StyledRadioItem;
|
|
94
|
+
export const DropdownMenuItemIndicator = StyledItemIndicator;
|
|
95
|
+
export const DropdownMenuLabel = StyledLabel;
|
|
96
|
+
export const DropdownMenuSeparator = StyledSeparator;
|
|
97
|
+
export const DropdownMenuArrow = StyledArrow;
|
|
98
|
+
|
|
99
|
+
export function DropdownMenuTrigger({ ...props }: MenuTriggerProps) {
|
|
100
|
+
return (
|
|
101
|
+
<DropdownTriggerProvider>
|
|
102
|
+
<StyledTrigger {...props} />
|
|
103
|
+
</DropdownTriggerProvider>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
export const DropdownMenuTriggerIcon = withClassName(
|
|
107
|
+
SlotDiv,
|
|
108
|
+
'layer-components:transition-transform layer-components:[[data-popup-open]>&]:rotate-180',
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
export const DropdownMenuContent = ({
|
|
112
|
+
children,
|
|
113
|
+
forceMount,
|
|
114
|
+
keepMounted,
|
|
115
|
+
side,
|
|
116
|
+
sideOffset = 8,
|
|
117
|
+
align,
|
|
118
|
+
alignOffset,
|
|
119
|
+
anchor,
|
|
120
|
+
arrowPadding = 2,
|
|
121
|
+
collisionAvoidance,
|
|
122
|
+
collisionBoundary,
|
|
123
|
+
collisionPadding,
|
|
124
|
+
sticky,
|
|
125
|
+
positionMethod,
|
|
126
|
+
...props
|
|
127
|
+
}: MenuPopupProps &
|
|
128
|
+
MenuPositionerProps & {
|
|
129
|
+
/** @deprecated - use keepMounted */
|
|
130
|
+
forceMount?: boolean;
|
|
131
|
+
keepMounted?: boolean;
|
|
132
|
+
}) => {
|
|
133
|
+
return (
|
|
134
|
+
<StyledPortal keepMounted={keepMounted ?? forceMount}>
|
|
135
|
+
<BaseMenu.Positioner
|
|
136
|
+
sideOffset={sideOffset}
|
|
137
|
+
side={side}
|
|
138
|
+
align={align}
|
|
139
|
+
alignOffset={alignOffset}
|
|
140
|
+
anchor={anchor}
|
|
141
|
+
arrowPadding={arrowPadding}
|
|
142
|
+
collisionAvoidance={collisionAvoidance}
|
|
143
|
+
collisionBoundary={collisionBoundary}
|
|
144
|
+
collisionPadding={collisionPadding}
|
|
145
|
+
sticky={sticky}
|
|
146
|
+
positionMethod={positionMethod}
|
|
147
|
+
>
|
|
148
|
+
<StyledContent {...props}>
|
|
149
|
+
<div className={itemListClassName}>{children}</div>
|
|
150
|
+
<StyledArrow />
|
|
151
|
+
</StyledContent>
|
|
152
|
+
</BaseMenu.Positioner>
|
|
153
|
+
</StyledPortal>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const DropdownMenuItemRightSlot = withClassName('div', 'ml-auto pl-md');
|
|
158
|
+
|
|
159
|
+
export const DropdownMenu = Object.assign(DropdownMenuRoot, {
|
|
160
|
+
Content: DropdownMenuContent,
|
|
161
|
+
Trigger: DropdownMenuTrigger,
|
|
162
|
+
Item: StyledItem,
|
|
163
|
+
CheckboxItem: StyledCheckboxItem,
|
|
164
|
+
RadioGroup: BaseMenu.RadioGroup,
|
|
165
|
+
RadioItem: StyledRadioItem,
|
|
166
|
+
ItemIndicator: StyledItemIndicator,
|
|
167
|
+
Label: StyledLabel,
|
|
168
|
+
Separator: StyledSeparator,
|
|
169
|
+
Arrow: StyledArrow,
|
|
170
|
+
ItemRightSlot: DropdownMenuItemRightSlot,
|
|
171
|
+
TriggerIcon: DropdownMenuTriggerIcon,
|
|
172
|
+
createHandle: BaseMenu.createHandle,
|
|
173
|
+
});
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useField, useFormikContext } from 'formik';
|
|
4
|
-
import {
|
|
5
|
-
ComponentProps,
|
|
6
|
-
InputHTMLAttributes,
|
|
7
|
-
KeyboardEvent,
|
|
8
|
-
Ref,
|
|
9
|
-
useCallback,
|
|
10
|
-
useEffect,
|
|
11
|
-
useRef,
|
|
12
|
-
} from 'react';
|
|
13
|
-
import { withClassName } from '../../hooks.js';
|
|
14
|
-
import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
|
|
15
|
-
import useMergedRef from '../../hooks/useMergedRef.js';
|
|
16
|
-
import { Input } from '../input/Input.js';
|
|
17
|
-
import { TextArea, TextAreaProps } from '../textArea/TextArea.js';
|
|
18
|
-
import { FieldLabel } from './FieldLabel.js';
|
|
19
|
-
|
|
20
|
-
export type TextFieldProps = {
|
|
21
|
-
name: string;
|
|
22
|
-
label?: string;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
type?: InputHTMLAttributes<HTMLInputElement>['type'];
|
|
25
|
-
className?: string;
|
|
26
|
-
placeholder?: string;
|
|
27
|
-
autoComplete?: InputHTMLAttributes<HTMLInputElement>['autoComplete'];
|
|
28
|
-
autoFocus?: InputHTMLAttributes<HTMLInputElement>['autoFocus'];
|
|
29
|
-
autoFocusDelay?: number;
|
|
30
|
-
inputRef?: Ref<HTMLInputElement>;
|
|
31
|
-
inputClassName?: string;
|
|
32
|
-
} & ComponentProps<typeof Input>;
|
|
33
|
-
|
|
34
|
-
const emptyRef = (() => {}) as any;
|
|
35
|
-
|
|
36
|
-
export const TextField = function TextField({
|
|
37
|
-
ref,
|
|
38
|
-
name,
|
|
39
|
-
label,
|
|
40
|
-
className,
|
|
41
|
-
autoFocusDelay,
|
|
42
|
-
autoFocus,
|
|
43
|
-
inputRef,
|
|
44
|
-
onChange,
|
|
45
|
-
onFocus,
|
|
46
|
-
onBlur,
|
|
47
|
-
id: providedId,
|
|
48
|
-
inputClassName,
|
|
49
|
-
...rest
|
|
50
|
-
}: TextFieldProps & {
|
|
51
|
-
ref?: React.Ref<HTMLDivElement>;
|
|
52
|
-
}) {
|
|
53
|
-
const [props] = useField({
|
|
54
|
-
name,
|
|
55
|
-
onChange,
|
|
56
|
-
onFocus,
|
|
57
|
-
onBlur,
|
|
58
|
-
});
|
|
59
|
-
const innerInputRef = useRef<HTMLInputElement>(null);
|
|
60
|
-
const id = useIdOrGenerated(providedId);
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (autoFocusDelay) {
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
if (innerInputRef.current) innerInputRef.current.focus();
|
|
66
|
-
}, autoFocusDelay);
|
|
67
|
-
}
|
|
68
|
-
}, [autoFocusDelay]);
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<FieldRoot className={className} ref={ref}>
|
|
72
|
-
{label && <FieldLabel htmlFor={id}>{label}</FieldLabel>}
|
|
73
|
-
<Input
|
|
74
|
-
{...props}
|
|
75
|
-
{...rest}
|
|
76
|
-
id={id}
|
|
77
|
-
autoFocus={autoFocus}
|
|
78
|
-
className={inputClassName}
|
|
79
|
-
ref={useMergedRef(innerInputRef, inputRef || emptyRef)}
|
|
80
|
-
/>
|
|
81
|
-
</FieldRoot>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export type TextAreaFieldProps = {
|
|
86
|
-
name: string;
|
|
87
|
-
label?: string;
|
|
88
|
-
required?: boolean;
|
|
89
|
-
rows?: number;
|
|
90
|
-
disabled?: boolean;
|
|
91
|
-
className?: string;
|
|
92
|
-
inputRef?: Ref<HTMLTextAreaElement>;
|
|
93
|
-
submitOnEnter?: boolean;
|
|
94
|
-
textAreaClassName?: string;
|
|
95
|
-
} & TextAreaProps;
|
|
96
|
-
|
|
97
|
-
export function TextAreaField({
|
|
98
|
-
name,
|
|
99
|
-
label,
|
|
100
|
-
className,
|
|
101
|
-
inputRef,
|
|
102
|
-
onKeyDown,
|
|
103
|
-
submitOnEnter,
|
|
104
|
-
id: providedId,
|
|
105
|
-
textAreaClassName,
|
|
106
|
-
...rest
|
|
107
|
-
}: TextAreaFieldProps) {
|
|
108
|
-
const [props] = useField(name);
|
|
109
|
-
const { submitForm } = useFormikContext();
|
|
110
|
-
const onKeyDownInner = useCallback(
|
|
111
|
-
(e: KeyboardEvent<HTMLInputElement>) => {
|
|
112
|
-
if (submitOnEnter && e.key === 'Enter' && !e.shiftKey) {
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
submitForm();
|
|
115
|
-
}
|
|
116
|
-
onKeyDown?.(e as any);
|
|
117
|
-
},
|
|
118
|
-
[submitOnEnter, onKeyDown, submitForm],
|
|
119
|
-
);
|
|
120
|
-
const id = useIdOrGenerated(providedId);
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<FieldRoot className={className}>
|
|
124
|
-
{label && <FieldLabel htmlFor={id}>{label}</FieldLabel>}
|
|
125
|
-
<TextArea
|
|
126
|
-
ref={inputRef}
|
|
127
|
-
{...props}
|
|
128
|
-
{...rest}
|
|
129
|
-
className={textAreaClassName}
|
|
130
|
-
id={id}
|
|
131
|
-
onKeyDown={onKeyDownInner}
|
|
132
|
-
/>
|
|
133
|
-
</FieldRoot>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export const FieldRoot = withClassName(
|
|
138
|
-
'div',
|
|
139
|
-
'flex flex-col items-stretch gap-xs
|
|
140
|
-
);
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useField, useFormikContext } from 'formik';
|
|
4
|
+
import {
|
|
5
|
+
ComponentProps,
|
|
6
|
+
InputHTMLAttributes,
|
|
7
|
+
KeyboardEvent,
|
|
8
|
+
Ref,
|
|
9
|
+
useCallback,
|
|
10
|
+
useEffect,
|
|
11
|
+
useRef,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import { withClassName } from '../../hooks.js';
|
|
14
|
+
import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
|
|
15
|
+
import useMergedRef from '../../hooks/useMergedRef.js';
|
|
16
|
+
import { Input } from '../input/Input.js';
|
|
17
|
+
import { TextArea, TextAreaProps } from '../textArea/TextArea.js';
|
|
18
|
+
import { FieldLabel } from './FieldLabel.js';
|
|
19
|
+
|
|
20
|
+
export type TextFieldProps = {
|
|
21
|
+
name: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
type?: InputHTMLAttributes<HTMLInputElement>['type'];
|
|
25
|
+
className?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
autoComplete?: InputHTMLAttributes<HTMLInputElement>['autoComplete'];
|
|
28
|
+
autoFocus?: InputHTMLAttributes<HTMLInputElement>['autoFocus'];
|
|
29
|
+
autoFocusDelay?: number;
|
|
30
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
31
|
+
inputClassName?: string;
|
|
32
|
+
} & ComponentProps<typeof Input>;
|
|
33
|
+
|
|
34
|
+
const emptyRef = (() => {}) as any;
|
|
35
|
+
|
|
36
|
+
export const TextField = function TextField({
|
|
37
|
+
ref,
|
|
38
|
+
name,
|
|
39
|
+
label,
|
|
40
|
+
className,
|
|
41
|
+
autoFocusDelay,
|
|
42
|
+
autoFocus,
|
|
43
|
+
inputRef,
|
|
44
|
+
onChange,
|
|
45
|
+
onFocus,
|
|
46
|
+
onBlur,
|
|
47
|
+
id: providedId,
|
|
48
|
+
inputClassName,
|
|
49
|
+
...rest
|
|
50
|
+
}: TextFieldProps & {
|
|
51
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
52
|
+
}) {
|
|
53
|
+
const [props] = useField({
|
|
54
|
+
name,
|
|
55
|
+
onChange,
|
|
56
|
+
onFocus,
|
|
57
|
+
onBlur,
|
|
58
|
+
});
|
|
59
|
+
const innerInputRef = useRef<HTMLInputElement>(null);
|
|
60
|
+
const id = useIdOrGenerated(providedId);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (autoFocusDelay) {
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
if (innerInputRef.current) innerInputRef.current.focus();
|
|
66
|
+
}, autoFocusDelay);
|
|
67
|
+
}
|
|
68
|
+
}, [autoFocusDelay]);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<FieldRoot className={className} ref={ref}>
|
|
72
|
+
{label && <FieldLabel htmlFor={id}>{label}</FieldLabel>}
|
|
73
|
+
<Input
|
|
74
|
+
{...props}
|
|
75
|
+
{...rest}
|
|
76
|
+
id={id}
|
|
77
|
+
autoFocus={autoFocus}
|
|
78
|
+
className={inputClassName}
|
|
79
|
+
ref={useMergedRef(innerInputRef, inputRef || emptyRef)}
|
|
80
|
+
/>
|
|
81
|
+
</FieldRoot>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type TextAreaFieldProps = {
|
|
86
|
+
name: string;
|
|
87
|
+
label?: string;
|
|
88
|
+
required?: boolean;
|
|
89
|
+
rows?: number;
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
className?: string;
|
|
92
|
+
inputRef?: Ref<HTMLTextAreaElement>;
|
|
93
|
+
submitOnEnter?: boolean;
|
|
94
|
+
textAreaClassName?: string;
|
|
95
|
+
} & TextAreaProps;
|
|
96
|
+
|
|
97
|
+
export function TextAreaField({
|
|
98
|
+
name,
|
|
99
|
+
label,
|
|
100
|
+
className,
|
|
101
|
+
inputRef,
|
|
102
|
+
onKeyDown,
|
|
103
|
+
submitOnEnter,
|
|
104
|
+
id: providedId,
|
|
105
|
+
textAreaClassName,
|
|
106
|
+
...rest
|
|
107
|
+
}: TextAreaFieldProps) {
|
|
108
|
+
const [props] = useField(name);
|
|
109
|
+
const { submitForm } = useFormikContext();
|
|
110
|
+
const onKeyDownInner = useCallback(
|
|
111
|
+
(e: KeyboardEvent<HTMLInputElement>) => {
|
|
112
|
+
if (submitOnEnter && e.key === 'Enter' && !e.shiftKey) {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
submitForm();
|
|
115
|
+
}
|
|
116
|
+
onKeyDown?.(e as any);
|
|
117
|
+
},
|
|
118
|
+
[submitOnEnter, onKeyDown, submitForm],
|
|
119
|
+
);
|
|
120
|
+
const id = useIdOrGenerated(providedId);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<FieldRoot className={className}>
|
|
124
|
+
{label && <FieldLabel htmlFor={id}>{label}</FieldLabel>}
|
|
125
|
+
<TextArea
|
|
126
|
+
ref={inputRef as any}
|
|
127
|
+
{...props}
|
|
128
|
+
{...rest}
|
|
129
|
+
className={textAreaClassName}
|
|
130
|
+
id={id}
|
|
131
|
+
onKeyDown={onKeyDownInner}
|
|
132
|
+
/>
|
|
133
|
+
</FieldRoot>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const FieldRoot = withClassName(
|
|
138
|
+
'div',
|
|
139
|
+
'flex flex-col items-stretch self-stretch gap-xs',
|
|
140
|
+
);
|
package/src/components/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from '@base-ui/react/use-render';
|
|
2
2
|
export * from './actions/index.js';
|
|
3
|
+
export * from './autocomplete/Autocomplete.js';
|
|
3
4
|
export * from './avatar/index.js';
|
|
4
5
|
export * from './box/Box.js';
|
|
5
6
|
export * from './button/index.js';
|
|
@@ -38,6 +39,7 @@ export * from './popover/index.js';
|
|
|
38
39
|
export * from './progress/Progress.js';
|
|
39
40
|
export * from './provider/Provider.js';
|
|
40
41
|
export * from './pwaInstall/index.js';
|
|
42
|
+
export * from './quickAction/QuickAction.js';
|
|
41
43
|
export * from './relativeTime/index.js';
|
|
42
44
|
export * from './richEditor/index.js';
|
|
43
45
|
export * from './scrollArea/ScrollArea.js';
|