@dxos/react-ui-searchlist 0.8.4-main.fd6878d → 0.8.4-main.fffef41
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/lib/browser/index.mjs +258 -139
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +258 -139
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Combobox/Combobox.d.ts +44 -0
- package/dist/types/src/components/Combobox/Combobox.d.ts.map +1 -0
- package/dist/types/src/components/Combobox/Combobox.stories.d.ts +21 -0
- package/dist/types/src/components/Combobox/Combobox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Combobox/index.d.ts +2 -0
- package/dist/types/src/components/Combobox/index.d.ts.map +1 -0
- package/dist/types/src/components/Listbox/Listbox.d.ts +31 -0
- package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -0
- package/dist/types/src/components/Listbox/Listbox.stories.d.ts +21 -0
- package/dist/types/src/components/Listbox/Listbox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Listbox/index.d.ts +2 -0
- package/dist/types/src/components/Listbox/index.d.ts.map +1 -0
- package/dist/types/src/components/{SearchList.d.ts → SearchList/SearchList.d.ts} +7 -27
- package/dist/types/src/components/SearchList/SearchList.d.ts.map +1 -0
- package/dist/types/src/components/SearchList/SearchList.stories.d.ts +25 -0
- package/dist/types/src/components/SearchList/SearchList.stories.d.ts.map +1 -0
- package/dist/types/src/components/SearchList/index.d.ts +2 -0
- package/dist/types/src/components/SearchList/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -14
- package/src/components/Combobox/Combobox.stories.tsx +57 -0
- package/src/components/Combobox/Combobox.tsx +335 -0
- package/src/components/Combobox/index.ts +5 -0
- package/src/components/Listbox/Listbox.stories.tsx +53 -0
- package/src/components/Listbox/Listbox.tsx +209 -0
- package/src/components/Listbox/index.ts +5 -0
- package/src/components/SearchList/SearchList.stories.tsx +64 -0
- package/src/components/SearchList/SearchList.tsx +163 -0
- package/src/components/SearchList/index.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/index.ts +0 -1
- package/src/translations.ts +3 -1
- package/dist/types/src/components/SearchList.d.ts.map +0 -1
- package/dist/types/src/components/SearchList.stories.d.ts +0 -15
- package/dist/types/src/components/SearchList.stories.d.ts.map +0 -1
- package/dist/types/src/composites/PopoverCombobox.d.ts +0 -32
- package/dist/types/src/composites/PopoverCombobox.d.ts.map +0 -1
- package/dist/types/src/composites/PopoverCombobox.stories.d.ts +0 -28
- package/dist/types/src/composites/PopoverCombobox.stories.d.ts.map +0 -1
- package/dist/types/src/composites/index.d.ts +0 -2
- package/dist/types/src/composites/index.d.ts.map +0 -1
- package/src/components/SearchList.stories.tsx +0 -47
- package/src/components/SearchList.tsx +0 -250
- package/src/composites/PopoverCombobox.stories.tsx +0 -44
- package/src/composites/PopoverCombobox.tsx +0 -208
- package/src/composites/index.ts +0 -5
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
import { faker } from '@dxos/random';
|
|
10
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
11
|
-
|
|
12
|
-
import { PopoverCombobox } from './PopoverCombobox';
|
|
13
|
-
|
|
14
|
-
faker.seed(1234);
|
|
15
|
-
|
|
16
|
-
const storybookItems = faker.helpers.uniqueArray(faker.commerce.productName, 16);
|
|
17
|
-
|
|
18
|
-
const DefaultStory = () => {
|
|
19
|
-
return (
|
|
20
|
-
<PopoverCombobox.Root placeholder='Nothing selected'>
|
|
21
|
-
<PopoverCombobox.Trigger />
|
|
22
|
-
<PopoverCombobox.Content filter={(value, search) => (value.includes(search) ? 1 : 0)}>
|
|
23
|
-
<PopoverCombobox.Input placeholder='Search...' />
|
|
24
|
-
<PopoverCombobox.List>
|
|
25
|
-
{storybookItems.map((value) => (
|
|
26
|
-
<PopoverCombobox.Item key={value}>{value}</PopoverCombobox.Item>
|
|
27
|
-
))}
|
|
28
|
-
</PopoverCombobox.List>
|
|
29
|
-
<PopoverCombobox.Arrow />
|
|
30
|
-
</PopoverCombobox.Content>
|
|
31
|
-
</PopoverCombobox.Root>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default {
|
|
36
|
-
title: 'ui/react-ui-searchlist/PopoverCombobox',
|
|
37
|
-
component: PopoverCombobox,
|
|
38
|
-
render: DefaultStory,
|
|
39
|
-
decorators: [withTheme],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Default = {
|
|
43
|
-
args: {},
|
|
44
|
-
};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
6
|
-
import React, { forwardRef } from 'react';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
Popover,
|
|
10
|
-
type PopoverArrowProps,
|
|
11
|
-
type PopoverContentProps,
|
|
12
|
-
type PopoverViewportProps,
|
|
13
|
-
type PopoverVirtualTriggerProps,
|
|
14
|
-
} from '@dxos/react-ui';
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
Combobox,
|
|
18
|
-
type ComboboxRootProps,
|
|
19
|
-
type ComboboxTriggerProps,
|
|
20
|
-
SearchList,
|
|
21
|
-
type SearchListContentProps,
|
|
22
|
-
type SearchListEmptyProps,
|
|
23
|
-
type SearchListInputProps,
|
|
24
|
-
type SearchListItemProps,
|
|
25
|
-
type SearchListRootProps,
|
|
26
|
-
} from '../components';
|
|
27
|
-
|
|
28
|
-
type PopoverComboboxRootProps = ComboboxRootProps & { modal?: boolean };
|
|
29
|
-
|
|
30
|
-
const PopoverComboboxRoot = ({
|
|
31
|
-
modal,
|
|
32
|
-
children,
|
|
33
|
-
open: propsOpen,
|
|
34
|
-
onOpenChange: propsOnOpenChange,
|
|
35
|
-
defaultOpen,
|
|
36
|
-
...props
|
|
37
|
-
}: PopoverComboboxRootProps) => {
|
|
38
|
-
const [open, onOpenChange] = useControllableState({
|
|
39
|
-
prop: propsOpen,
|
|
40
|
-
onChange: propsOnOpenChange,
|
|
41
|
-
defaultProp: defaultOpen,
|
|
42
|
-
});
|
|
43
|
-
return (
|
|
44
|
-
<Combobox.Root open={open} onOpenChange={onOpenChange} {...props}>
|
|
45
|
-
<Popover.Root open={open} onOpenChange={onOpenChange} modal={modal}>
|
|
46
|
-
{children}
|
|
47
|
-
</Popover.Root>
|
|
48
|
-
</Combobox.Root>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
type PopoverComboboxContentProps = SearchListRootProps & PopoverContentProps;
|
|
53
|
-
|
|
54
|
-
const POPOVER_COMBOBOX_CONTENT_NAME = 'PopoverComboboxContent';
|
|
55
|
-
|
|
56
|
-
const PopoverComboboxContent = forwardRef<HTMLDivElement, PopoverComboboxContentProps>(
|
|
57
|
-
(
|
|
58
|
-
{
|
|
59
|
-
side = 'bottom',
|
|
60
|
-
collisionPadding = 48,
|
|
61
|
-
sideOffset,
|
|
62
|
-
align,
|
|
63
|
-
alignOffset,
|
|
64
|
-
avoidCollisions,
|
|
65
|
-
collisionBoundary,
|
|
66
|
-
arrowPadding,
|
|
67
|
-
sticky,
|
|
68
|
-
hideWhenDetached,
|
|
69
|
-
onOpenAutoFocus,
|
|
70
|
-
onCloseAutoFocus,
|
|
71
|
-
onEscapeKeyDown,
|
|
72
|
-
onPointerDownOutside,
|
|
73
|
-
onFocusOutside,
|
|
74
|
-
onInteractOutside,
|
|
75
|
-
forceMount,
|
|
76
|
-
children,
|
|
77
|
-
classNames,
|
|
78
|
-
...props
|
|
79
|
-
},
|
|
80
|
-
forwardedRef,
|
|
81
|
-
) => {
|
|
82
|
-
const { modalId } = Combobox.useComboboxContext(POPOVER_COMBOBOX_CONTENT_NAME);
|
|
83
|
-
return (
|
|
84
|
-
<Popover.Content
|
|
85
|
-
{...{
|
|
86
|
-
side,
|
|
87
|
-
sideOffset,
|
|
88
|
-
align,
|
|
89
|
-
alignOffset,
|
|
90
|
-
avoidCollisions,
|
|
91
|
-
collisionBoundary,
|
|
92
|
-
collisionPadding,
|
|
93
|
-
arrowPadding,
|
|
94
|
-
sticky,
|
|
95
|
-
hideWhenDetached,
|
|
96
|
-
onOpenAutoFocus,
|
|
97
|
-
onCloseAutoFocus,
|
|
98
|
-
onEscapeKeyDown,
|
|
99
|
-
onPointerDownOutside,
|
|
100
|
-
onFocusOutside,
|
|
101
|
-
onInteractOutside,
|
|
102
|
-
forceMount,
|
|
103
|
-
classNames,
|
|
104
|
-
}}
|
|
105
|
-
id={modalId}
|
|
106
|
-
ref={forwardedRef}
|
|
107
|
-
>
|
|
108
|
-
<Popover.Viewport>
|
|
109
|
-
<SearchList.Root {...props} classNames='contents density-fine' role='none'>
|
|
110
|
-
{children}
|
|
111
|
-
</SearchList.Root>
|
|
112
|
-
</Popover.Viewport>
|
|
113
|
-
</Popover.Content>
|
|
114
|
-
);
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
PopoverComboboxContent.displayName = POPOVER_COMBOBOX_CONTENT_NAME;
|
|
119
|
-
|
|
120
|
-
type PopoverComboboxTriggerProps = ComboboxTriggerProps;
|
|
121
|
-
|
|
122
|
-
const PopoverComboboxTrigger = forwardRef<HTMLButtonElement, PopoverComboboxTriggerProps>((props, forwardedRef) => {
|
|
123
|
-
return (
|
|
124
|
-
<Popover.Trigger asChild>
|
|
125
|
-
<Combobox.Trigger {...props} ref={forwardedRef} />
|
|
126
|
-
</Popover.Trigger>
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
type PopoverComboboxVirtualTriggerProps = PopoverVirtualTriggerProps;
|
|
131
|
-
|
|
132
|
-
const PopoverComboboxVirtualTrigger = Popover.VirtualTrigger;
|
|
133
|
-
|
|
134
|
-
type PopoverComboboxInputProps = SearchListInputProps;
|
|
135
|
-
|
|
136
|
-
const PopoverComboboxInput = forwardRef<HTMLInputElement, PopoverComboboxInputProps>(
|
|
137
|
-
({ classNames, ...props }, forwardedRef) => {
|
|
138
|
-
return (
|
|
139
|
-
<SearchList.Input
|
|
140
|
-
{...props}
|
|
141
|
-
classNames={[
|
|
142
|
-
'mli-cardSpacingChrome mbs-cardSpacingChrome is-[calc(100%-2*var(--dx-cardSpacingChrome))]',
|
|
143
|
-
classNames,
|
|
144
|
-
]}
|
|
145
|
-
ref={forwardedRef}
|
|
146
|
-
/>
|
|
147
|
-
);
|
|
148
|
-
},
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
type PopoverComboboxListProps = SearchListContentProps &
|
|
152
|
-
Pick<PopoverViewportProps, 'constrainBlock' | 'constrainInline'>;
|
|
153
|
-
|
|
154
|
-
const PopoverComboboxList = forwardRef<HTMLDivElement, PopoverComboboxListProps>(
|
|
155
|
-
({ constrainInline, constrainBlock, ...props }, forwardedRef) => {
|
|
156
|
-
return (
|
|
157
|
-
<Popover.Viewport {...{ constrainInline, constrainBlock }}>
|
|
158
|
-
<SearchList.Content {...props} ref={forwardedRef} />
|
|
159
|
-
</Popover.Viewport>
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
type PopoverComboboxItemProps = SearchListItemProps;
|
|
165
|
-
|
|
166
|
-
const PopoverComboboxItem = forwardRef<HTMLDivElement, PopoverComboboxItemProps>(
|
|
167
|
-
({ classNames, ...props }, forwardedRef) => {
|
|
168
|
-
return (
|
|
169
|
-
<SearchList.Item
|
|
170
|
-
{...props}
|
|
171
|
-
classNames={['mli-cardSpacingChrome pli-cardSpacingChrome', classNames]}
|
|
172
|
-
ref={forwardedRef}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
},
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
type PopoverComboboxArrowProps = PopoverArrowProps;
|
|
179
|
-
|
|
180
|
-
const PopoverComboboxArrow = Popover.Arrow;
|
|
181
|
-
|
|
182
|
-
type PopoverComboboxEmptyProps = SearchListEmptyProps;
|
|
183
|
-
|
|
184
|
-
const PopoverComboboxEmpty = SearchList.Empty;
|
|
185
|
-
|
|
186
|
-
export const PopoverCombobox = {
|
|
187
|
-
Root: PopoverComboboxRoot,
|
|
188
|
-
Content: PopoverComboboxContent,
|
|
189
|
-
Trigger: PopoverComboboxTrigger,
|
|
190
|
-
VirtualTrigger: PopoverComboboxVirtualTrigger,
|
|
191
|
-
Input: PopoverComboboxInput,
|
|
192
|
-
List: PopoverComboboxList,
|
|
193
|
-
Item: PopoverComboboxItem,
|
|
194
|
-
Arrow: PopoverComboboxArrow,
|
|
195
|
-
Empty: PopoverComboboxEmpty,
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export type {
|
|
199
|
-
PopoverComboboxRootProps,
|
|
200
|
-
PopoverComboboxContentProps,
|
|
201
|
-
PopoverComboboxTriggerProps,
|
|
202
|
-
PopoverComboboxVirtualTriggerProps,
|
|
203
|
-
PopoverComboboxInputProps,
|
|
204
|
-
PopoverComboboxListProps,
|
|
205
|
-
PopoverComboboxItemProps,
|
|
206
|
-
PopoverComboboxArrowProps,
|
|
207
|
-
PopoverComboboxEmptyProps,
|
|
208
|
-
};
|