@dxos/react-ui-list 0.9.0 → 0.9.1-main.c7dcc2e112
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 +993 -521
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +993 -521
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/aspects/index.d.ts +6 -0
- package/dist/types/src/aspects/index.d.ts.map +1 -0
- package/dist/types/src/aspects/useListDisclosure.d.ts +60 -0
- package/dist/types/src/aspects/useListDisclosure.d.ts.map +1 -0
- package/dist/types/src/aspects/useListDisclosure.test.d.ts +2 -0
- package/dist/types/src/aspects/useListDisclosure.test.d.ts.map +1 -0
- package/dist/types/src/aspects/useListGrid.d.ts +30 -0
- package/dist/types/src/aspects/useListGrid.d.ts.map +1 -0
- package/dist/types/src/aspects/useListGrid.test.d.ts +2 -0
- package/dist/types/src/aspects/useListGrid.test.d.ts.map +1 -0
- package/dist/types/src/aspects/useListNavigation.d.ts +68 -0
- package/dist/types/src/aspects/useListNavigation.d.ts.map +1 -0
- package/dist/types/src/aspects/useListNavigation.test.d.ts +2 -0
- package/dist/types/src/aspects/useListNavigation.test.d.ts.map +1 -0
- package/dist/types/src/aspects/useListSelection.d.ts +48 -0
- package/dist/types/src/aspects/useListSelection.d.ts.map +1 -0
- package/dist/types/src/aspects/useListSelection.test.d.ts +2 -0
- package/dist/types/src/aspects/useListSelection.test.d.ts.map +1 -0
- package/dist/types/src/aspects/useReorder.d.ts +103 -0
- package/dist/types/src/aspects/useReorder.d.ts.map +1 -0
- package/dist/types/src/components/Accordion/Accordion.d.ts +1 -1
- package/dist/types/src/components/Accordion/AccordionItem.d.ts +5 -3
- package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
- package/dist/types/src/components/Accordion/AccordionRoot.d.ts +1 -1
- package/dist/types/src/components/Accordion/AccordionRoot.d.ts.map +1 -1
- package/dist/types/src/components/Listbox/Listbox.d.ts +60 -20
- package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -1
- package/dist/types/src/components/Listbox/Listbox.stories.d.ts +27 -3
- package/dist/types/src/components/Listbox/Listbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/OrderedList/OrderedList.d.ts +49 -0
- package/dist/types/src/components/OrderedList/OrderedList.d.ts.map +1 -0
- package/dist/types/src/components/OrderedList/OrderedList.stories.d.ts +11 -0
- package/dist/types/src/components/OrderedList/OrderedList.stories.d.ts.map +1 -0
- package/dist/types/src/components/OrderedList/OrderedList.test.d.ts +2 -0
- package/dist/types/src/components/OrderedList/OrderedList.test.d.ts.map +1 -0
- package/dist/types/src/components/OrderedList/OrderedListItem.d.ts +94 -0
- package/dist/types/src/components/OrderedList/OrderedListItem.d.ts.map +1 -0
- package/dist/types/src/components/OrderedList/OrderedListRoot.d.ts +73 -0
- package/dist/types/src/components/OrderedList/OrderedListRoot.d.ts.map +1 -0
- package/dist/types/src/components/OrderedList/index.d.ts +2 -0
- package/dist/types/src/components/OrderedList/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/vitest-setup.d.ts +2 -0
- package/dist/types/src/vitest-setup.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -15
- package/src/aspects/index.ts +9 -0
- package/src/aspects/useListDisclosure.test.ts +72 -0
- package/src/aspects/useListDisclosure.ts +160 -0
- package/src/aspects/useListGrid.test.ts +41 -0
- package/src/aspects/useListGrid.ts +61 -0
- package/src/aspects/useListNavigation.test.ts +44 -0
- package/src/aspects/useListNavigation.ts +160 -0
- package/src/aspects/useListSelection.test.ts +101 -0
- package/src/aspects/useListSelection.ts +162 -0
- package/src/aspects/useReorder.ts +370 -0
- package/src/components/Accordion/Accordion.stories.tsx +1 -1
- package/src/components/Accordion/AccordionItem.tsx +11 -6
- package/src/components/Accordion/AccordionRoot.tsx +4 -1
- package/src/components/Listbox/Listbox.stories.tsx +171 -21
- package/src/components/Listbox/Listbox.tsx +302 -145
- package/src/components/OrderedList/OrderedList.stories.tsx +379 -0
- package/src/components/OrderedList/OrderedList.test.tsx +59 -0
- package/src/components/OrderedList/OrderedList.tsx +63 -0
- package/src/components/OrderedList/OrderedListItem.tsx +348 -0
- package/src/components/OrderedList/OrderedListRoot.tsx +173 -0
- package/src/components/OrderedList/index.ts +5 -0
- package/src/components/Tree/TreeItem.tsx +2 -0
- package/src/components/Tree/TreeItemHeading.tsx +1 -2
- package/src/components/index.ts +1 -2
- package/src/index.ts +1 -0
- package/src/vitest-setup.ts +11 -0
- package/dist/types/src/components/List/List.d.ts +0 -40
- package/dist/types/src/components/List/List.d.ts.map +0 -1
- package/dist/types/src/components/List/List.stories.d.ts +0 -18
- package/dist/types/src/components/List/List.stories.d.ts.map +0 -1
- package/dist/types/src/components/List/ListItem.d.ts +0 -49
- package/dist/types/src/components/List/ListItem.d.ts.map +0 -1
- package/dist/types/src/components/List/ListRoot.d.ts +0 -29
- package/dist/types/src/components/List/ListRoot.d.ts.map +0 -1
- package/dist/types/src/components/List/index.d.ts +0 -2
- package/dist/types/src/components/List/index.d.ts.map +0 -1
- package/dist/types/src/components/List/testing.d.ts +0 -15
- package/dist/types/src/components/List/testing.d.ts.map +0 -1
- package/dist/types/src/components/RowList/RowList.d.ts +0 -61
- package/dist/types/src/components/RowList/RowList.d.ts.map +0 -1
- package/dist/types/src/components/RowList/RowList.stories.d.ts +0 -35
- package/dist/types/src/components/RowList/RowList.stories.d.ts.map +0 -1
- package/dist/types/src/components/RowList/index.d.ts +0 -3
- package/dist/types/src/components/RowList/index.d.ts.map +0 -1
- package/src/components/List/List.stories.tsx +0 -129
- package/src/components/List/List.tsx +0 -47
- package/src/components/List/ListItem.tsx +0 -287
- package/src/components/List/ListRoot.tsx +0 -106
- package/src/components/List/index.ts +0 -5
- package/src/components/List/testing.ts +0 -31
- package/src/components/RowList/RowList.stories.tsx +0 -163
- package/src/components/RowList/RowList.tsx +0 -350
- package/src/components/RowList/index.ts +0 -6
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
2
|
-
import React, { type ComponentProps, type HTMLAttributes, type PropsWithChildren, type ReactNode, RefObject } from 'react';
|
|
3
|
-
import { type IconButtonProps, type ThemedClassName } from '@dxos/react-ui';
|
|
4
|
-
export type ListItemRecord = any;
|
|
5
|
-
export type ItemDragState = {
|
|
6
|
-
type: 'idle';
|
|
7
|
-
} | {
|
|
8
|
-
type: 'preview';
|
|
9
|
-
container: HTMLElement;
|
|
10
|
-
} | {
|
|
11
|
-
type: 'is-dragging';
|
|
12
|
-
} | {
|
|
13
|
-
type: 'is-dragging-over';
|
|
14
|
-
closestEdge: Edge | null;
|
|
15
|
-
};
|
|
16
|
-
export declare const idle: ItemDragState;
|
|
17
|
-
type ListItemContext<T extends ListItemRecord> = {
|
|
18
|
-
item: T;
|
|
19
|
-
dragHandleRef: RefObject<HTMLButtonElement | null>;
|
|
20
|
-
};
|
|
21
|
-
export declare const ListItemProvider: React.FC<ListItemContext<any> & {
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
}>, useListItemContext: (consumerName: string) => ListItemContext<any>;
|
|
24
|
-
export type ListItemProps<T extends ListItemRecord> = ThemedClassName<PropsWithChildren<{
|
|
25
|
-
item: T;
|
|
26
|
-
asChild?: boolean;
|
|
27
|
-
selected?: boolean;
|
|
28
|
-
} & HTMLAttributes<HTMLDivElement>>>;
|
|
29
|
-
/**
|
|
30
|
-
* Draggable list item.
|
|
31
|
-
*/
|
|
32
|
-
export declare const ListItem: <T extends ListItemRecord>({ children, classNames, item, asChild, selected, ...props }: ListItemProps<T>) => React.JSX.Element;
|
|
33
|
-
export declare const ListItemIconButton: ({ autoHide, iconOnly, variant, classNames, disabled, ...props }: IconButtonProps & {
|
|
34
|
-
autoHide?: boolean;
|
|
35
|
-
}) => React.JSX.Element;
|
|
36
|
-
export declare const ListItemDeleteButton: ({ autoHide, classNames, disabled, icon, label, ...props }: Partial<Pick<IconButtonProps, 'icon'>> & Omit<IconButtonProps, 'icon' | 'label'> & {
|
|
37
|
-
autoHide?: boolean;
|
|
38
|
-
label?: string;
|
|
39
|
-
}) => React.JSX.Element;
|
|
40
|
-
export declare const ListItemDragHandle: ({ disabled }: Pick<IconButtonProps, 'disabled'>) => React.JSX.Element;
|
|
41
|
-
export declare const ListItemDragPreview: <T extends ListItemRecord>({ children, }: {
|
|
42
|
-
children: ({ item }: {
|
|
43
|
-
item: T;
|
|
44
|
-
}) => ReactNode;
|
|
45
|
-
}) => React.ReactPortal | null;
|
|
46
|
-
export declare const ListItemWrapper: ({ classNames, children }: ThemedClassName<PropsWithChildren>) => React.JSX.Element;
|
|
47
|
-
export declare const ListItemTitle: ({ classNames, children, ...props }: ThemedClassName<PropsWithChildren<ComponentProps<'div'>>>) => React.JSX.Element;
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=ListItem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/ListItem.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,IAAI,EAGV,MAAM,uDAAuD,CAAC;AAM/D,OAAO,KAAK,EAAE,EACZ,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,SAAS,EAIV,MAAM,OAAO,CAAC;AAIf,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC;AAEjC,MAAM,MAAM,aAAa,GACrB;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC;CACxB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEN,eAAO,MAAM,IAAI,EAAE,aAAgC,CAAC;AAMpD,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IAC/C,IAAI,EAAE,CAAC,CAAC;IACR,aAAa,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CACpD,CAAC;AASF,eAAO,MAAO,gBAAgB;;IAAE,kBAAkB,gDAGjD,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CACnE,iBAAiB,CACf;IACE,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,cAAc,CAAC,cAAc,CAAC,CACnC,CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,cAAc,+DAO9C,aAAa,CAAC,CAAC,CAAC,sBAkGlB,CAAC;AAMF,eAAO,MAAM,kBAAkB,oEAO5B,eAAe,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,sBAY1C,CAAC;AAGF,eAAO,MAAM,oBAAoB,8DAO9B,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,GACvC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,sBAejF,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBAAkB,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,sBAajF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,cAAc,iBAEzD;IACD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,KAAK,SAAS,CAAC;CAChD,6BAGA,CAAC;AAEF,eAAO,MAAM,eAAe,6BAA8B,eAAe,CAAC,iBAAiB,CAAC,sBAE3F,CAAC;AAEF,eAAO,MAAM,aAAa,uCAIvB,eAAe,CAAC,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,sBAI3D,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type ItemDragState, type ListItemRecord } from './ListItem';
|
|
3
|
-
type ListContext<T extends ListItemRecord> = {
|
|
4
|
-
state: ItemDragState & {
|
|
5
|
-
item?: T;
|
|
6
|
-
};
|
|
7
|
-
setState: (state: ItemDragState & {
|
|
8
|
-
item?: T;
|
|
9
|
-
}) => void;
|
|
10
|
-
readonly?: boolean;
|
|
11
|
-
dragPreview?: boolean;
|
|
12
|
-
isItem?: (item: any) => boolean;
|
|
13
|
-
getId?: (item: T) => string;
|
|
14
|
-
};
|
|
15
|
-
export declare const ListProvider: React.FC<ListContext<any> & {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}>, useListContext: (consumerName: string) => ListContext<any>;
|
|
18
|
-
export type ListRendererProps<T extends ListItemRecord> = {
|
|
19
|
-
state: ListContext<T>['state'];
|
|
20
|
-
items: readonly T[];
|
|
21
|
-
};
|
|
22
|
-
export type ListRootProps<T extends ListItemRecord> = {
|
|
23
|
-
children?: (props: ListRendererProps<T>) => ReactNode;
|
|
24
|
-
items?: readonly T[];
|
|
25
|
-
onMove?: (fromIndex: number, toIndex: number) => void;
|
|
26
|
-
} & Pick<ListContext<T>, 'isItem' | 'getId' | 'readonly' | 'dragPreview'>;
|
|
27
|
-
export declare const ListRoot: <T extends ListItemRecord>({ children, items, isItem, getId, onMove, ...props }: ListRootProps<T>) => React.JSX.Element;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=ListRoot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListRoot.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/ListRoot.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAoC,MAAM,OAAO,CAAC;AAEhF,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAQ,MAAM,YAAY,CAAC;AAE3E,KAAK,WAAW,CAAC,CAAC,SAAS,cAAc,IAAI;IAE3C,KAAK,EAAE,aAAa,GAAG;QAAE,IAAI,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,IAAI,CAAC,EAAE,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CAC7B,CAAC;AAIF,eAAO,MAAO,YAAY;;IAAE,cAAc,4CAA8C,CAAC;AAEzF,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,IAAI;IACxD,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/B,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;CACrB,CAAC;AAIF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,IAAI;IACpD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACtD,KAAK,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC,CAAC;AAE1E,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,cAAc,wDAO9C,aAAa,CAAC,CAAC,CAAC,sBA2DlB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
export declare const TestItemSchema: Schema.Struct<{
|
|
3
|
-
id: import("@dxos/keys").EntityIdClass;
|
|
4
|
-
name: typeof Schema.String;
|
|
5
|
-
}>;
|
|
6
|
-
export type TestItemType = Schema.Schema.Type<typeof TestItemSchema>;
|
|
7
|
-
export declare const TestList: Schema.Struct<{
|
|
8
|
-
items: Schema.mutable<Schema.Array$<Schema.Struct<{
|
|
9
|
-
id: import("@dxos/keys").EntityIdClass;
|
|
10
|
-
name: typeof Schema.String;
|
|
11
|
-
}>>>;
|
|
12
|
-
}>;
|
|
13
|
-
export type TestList = Schema.Schema.Type<typeof TestList>;
|
|
14
|
-
export declare const createList: (n?: number) => TestList;
|
|
15
|
-
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/testing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,cAAc,CAAC,CAAC;AAErE,eAAO,MAAM,QAAQ;;;;;EAEnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE3D,eAAO,MAAM,UAAU,kBAAa,QAQlC,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React, { type FocusEvent, type MouseEvent, type PropsWithChildren } from 'react';
|
|
2
|
-
import { type ScrollAreaRootProps } from '@dxos/react-ui';
|
|
3
|
-
declare const createRowListScope: import("@radix-ui/react-context").CreateScope;
|
|
4
|
-
type RootProps = PropsWithChildren<{
|
|
5
|
-
/** Currently-selected option id (controlled). */
|
|
6
|
-
selectedId?: string;
|
|
7
|
-
/** Initial selected option for uncontrolled mode. */
|
|
8
|
-
defaultSelectedId?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Called when the user picks a different option (click, arrow keys,
|
|
11
|
-
* focus). Receives the option's `id` prop.
|
|
12
|
-
*/
|
|
13
|
-
onSelectChange?: (id: string) => void;
|
|
14
|
-
}>;
|
|
15
|
-
declare function Root({ selectedId, defaultSelectedId, onSelectChange, children }: RootProps): React.JSX.Element;
|
|
16
|
-
declare namespace Root {
|
|
17
|
-
var displayName: string;
|
|
18
|
-
}
|
|
19
|
-
type ViewportProps = Pick<ScrollAreaRootProps, 'thin' | 'padding' | 'centered'>;
|
|
20
|
-
type ContentProps = {
|
|
21
|
-
/**
|
|
22
|
-
* Accessible label for the listbox. Strongly recommended; assistive
|
|
23
|
-
* tech announces this when focus enters the list.
|
|
24
|
-
*/
|
|
25
|
-
'aria-label'?: string;
|
|
26
|
-
};
|
|
27
|
-
type RowProps = PropsWithChildren<{
|
|
28
|
-
/** Stable identifier; matched against the parent's `selectedId`. */
|
|
29
|
-
id: string;
|
|
30
|
-
/** Disable the row — focusable but doesn't update selection, dimmed. */
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
/** Optional click handler in addition to selection. */
|
|
33
|
-
onClick?: (event: MouseEvent<HTMLLIElement>) => void;
|
|
34
|
-
/** Optional focus handler in addition to selection-follows-focus. */
|
|
35
|
-
onFocus?: (event: FocusEvent<HTMLLIElement>) => void;
|
|
36
|
-
}>;
|
|
37
|
-
declare const Row: React.ForwardRefExoticComponent<Omit<RowProps, "className"> & {
|
|
38
|
-
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
39
|
-
} & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLLIElement>>;
|
|
40
|
-
/**
|
|
41
|
-
* Read selection state for a single id, from inside any descendant of
|
|
42
|
-
* `<RowList.Root>`. Returns `true` when the row is currently selected.
|
|
43
|
-
* Lets composing components (e.g. `Listbox.OptionIndicator`) react to
|
|
44
|
-
* selection without re-rendering on unrelated changes.
|
|
45
|
-
*/
|
|
46
|
-
declare const useRowListSelection: (id: string) => boolean;
|
|
47
|
-
declare const RowList: {
|
|
48
|
-
Root: {
|
|
49
|
-
({ selectedId, defaultSelectedId, onSelectChange, children }: RootProps): React.JSX.Element;
|
|
50
|
-
displayName: string;
|
|
51
|
-
};
|
|
52
|
-
Viewport: React.ForwardRefExoticComponent<Omit<ViewportProps, "className"> & {
|
|
53
|
-
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
54
|
-
} & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
|
|
55
|
-
Content: React.ForwardRefExoticComponent<Omit<ContentProps, "className"> & {
|
|
56
|
-
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
57
|
-
} & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLUListElement>>;
|
|
58
|
-
};
|
|
59
|
-
export { RowList, Row, createRowListScope, useRowListSelection };
|
|
60
|
-
export type { RootProps as RowListRootProps, ViewportProps as RowListViewportProps, ContentProps as RowListContentProps, RowProps, };
|
|
61
|
-
//# sourceMappingURL=RowList.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RowList.d.ts","sourceRoot":"","sources":["../../../../../src/components/RowList/RowList.tsx"],"names":[],"mappings":"AA6EA,OAAO,KAAK,EAAE,EAAE,KAAK,UAAU,EAAqB,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAGxH,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAsBtE,QAAA,MAA6B,kBAAkB,+CAAyC,CAAC;AAOzF,KAAK,SAAS,GAAG,iBAAiB,CAAC;IACjC,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC,CAAC;sBAEW,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,SAAS;;;;AAqCpF,KAAK,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC;AAwBhF,KAAK,YAAY,GAAG;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAgEF,KAAK,QAAQ,GAAG,iBAAiB,CAAC;IAChC,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACrD,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACtD,CAAC,CAAC;AAMH,QAAA,MAAM,GAAG;;0HAmDP,CAAC;AAIH;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,OAAQ,MAAM,KAAG,OAGzC,CAAC;AAMF,QAAA,MAAM,OAAO;;sEAxN8D,SAAS;;;;;;;;;CA4NnF,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,CAAC;AACjE,YAAY,EACV,SAAS,IAAI,gBAAgB,EAC7B,aAAa,IAAI,oBAAoB,EACrC,YAAY,IAAI,mBAAmB,EACnC,QAAQ,GACT,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
type TestItem = {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
};
|
|
8
|
-
type StoryArgs = {
|
|
9
|
-
/** Items to render. Defaults to the full 24-item catalog. */
|
|
10
|
-
items?: TestItem[];
|
|
11
|
-
/** Forwards to `RowList.Viewport thin`. */
|
|
12
|
-
thin?: boolean;
|
|
13
|
-
/** Forwards to `RowList.Viewport padding`. */
|
|
14
|
-
padding?: boolean;
|
|
15
|
-
/** Index into `items` that should render disabled. */
|
|
16
|
-
disabledIndex?: number;
|
|
17
|
-
/** Render the description line under each row's name. */
|
|
18
|
-
showDescription?: boolean;
|
|
19
|
-
};
|
|
20
|
-
declare const meta: {
|
|
21
|
-
title: string;
|
|
22
|
-
render: (args: StoryArgs) => React.JSX.Element;
|
|
23
|
-
decorators: import("@storybook/react").Decorator[];
|
|
24
|
-
parameters: {
|
|
25
|
-
layout: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export default meta;
|
|
29
|
-
type Story = StoryObj<StoryArgs>;
|
|
30
|
-
export declare const Default: Story;
|
|
31
|
-
export declare const Thin: Story;
|
|
32
|
-
export declare const WithDisabled: Story;
|
|
33
|
-
export declare const MasterDetail: Story;
|
|
34
|
-
export declare const WithToolbar: Story;
|
|
35
|
-
//# sourceMappingURL=RowList.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RowList.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/RowList/RowList.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAUxC,KAAK,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAelE,KAAK,SAAS,GAAG;IACf,6DAA6D;IAC7D,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAwGF,QAAA,MAAM,IAAI;;;;;QAKN,MAAM;;CAEiB,CAAC;eAEb,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEjC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AACjC,eAAO,MAAM,IAAI,EAAE,KAAuE,CAAC;AAC3F,eAAO,MAAM,YAAY,EAAE,KAAmE,CAAC;AAC/F,eAAO,MAAM,YAAY,EAAE,KAA+C,CAAC;AAC3E,eAAO,MAAM,WAAW,EAAE,KAA8C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/RowList/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Atom, RegistryContext, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
|
-
import * as Schema from 'effect/Schema';
|
|
8
|
-
import React, { useContext, useMemo } from 'react';
|
|
9
|
-
|
|
10
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
-
import { withRegistry } from '@dxos/storybook-utils';
|
|
12
|
-
import { mx } from '@dxos/ui-theme';
|
|
13
|
-
import { arrayMove } from '@dxos/util';
|
|
14
|
-
|
|
15
|
-
import { List, type ListRootProps } from './List';
|
|
16
|
-
import { TestItemSchema, type TestItemType, type TestList, createList } from './testing';
|
|
17
|
-
|
|
18
|
-
// TODO(burdon): var-icon-size.
|
|
19
|
-
const grid = 'grid grid-cols-[32px_1fr_32px] min-h-[2rem] rounded-sm';
|
|
20
|
-
|
|
21
|
-
const DefaultStory = (props: Omit<ListRootProps<TestItemType>, 'items'>) => {
|
|
22
|
-
const registry = useContext(RegistryContext);
|
|
23
|
-
const listAtom = useMemo(() => Atom.make<TestList>(createList(100)).pipe(Atom.keepAlive), []);
|
|
24
|
-
const list = useAtomValue(listAtom);
|
|
25
|
-
const items = list.items;
|
|
26
|
-
|
|
27
|
-
const handleSelect = (item: TestItemType) => {
|
|
28
|
-
console.log('select', item);
|
|
29
|
-
};
|
|
30
|
-
const handleDelete = (item: TestItemType) => {
|
|
31
|
-
const prev = registry.get(listAtom);
|
|
32
|
-
registry.set(listAtom, {
|
|
33
|
-
...prev,
|
|
34
|
-
items: prev.items.filter((i) => i.id !== item.id),
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
const handleMove = (from: number, to: number) => {
|
|
38
|
-
const prev = registry.get(listAtom);
|
|
39
|
-
const newItems = [...prev.items];
|
|
40
|
-
arrayMove(newItems, from, to);
|
|
41
|
-
registry.set(listAtom, { ...prev, items: newItems });
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<List.Root<TestItemType> dragPreview items={items} getId={(item) => item.id} onMove={handleMove} {...props}>
|
|
46
|
-
{({ items }) => (
|
|
47
|
-
<>
|
|
48
|
-
<div className='flex flex-col w-full'>
|
|
49
|
-
<div className={grid}>
|
|
50
|
-
<div />
|
|
51
|
-
<div className='flex items-center text-sm'>Items</div>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
<div role='list' className='h-full w-full overflow-auto'>
|
|
55
|
-
{items?.map((item) => (
|
|
56
|
-
<List.Item<TestItemType> key={item.id} item={item} classNames={mx(grid)}>
|
|
57
|
-
<List.ItemDragHandle />
|
|
58
|
-
<List.ItemTitle onClick={() => handleSelect(item)}>{item.name}</List.ItemTitle>
|
|
59
|
-
<List.ItemDeleteButton onClick={() => handleDelete(item)} />
|
|
60
|
-
</List.Item>
|
|
61
|
-
))}
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
<div className={grid}>
|
|
65
|
-
<div />
|
|
66
|
-
<div className='flex items-center text-sm'>{items?.length} Items</div>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<List.ItemDragPreview<TestItemType>>
|
|
71
|
-
{({ item }) => (
|
|
72
|
-
<List.ItemWrapper classNames={mx(grid, 'bg-modal-surface border border-separator')}>
|
|
73
|
-
<List.ItemDragHandle />
|
|
74
|
-
<div className='flex items-center'>{item.name}</div>
|
|
75
|
-
</List.ItemWrapper>
|
|
76
|
-
)}
|
|
77
|
-
</List.ItemDragPreview>
|
|
78
|
-
</>
|
|
79
|
-
)}
|
|
80
|
-
</List.Root>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const SimpleStory = (props: Omit<ListRootProps<TestItemType>, 'items'>) => {
|
|
85
|
-
const listAtom = useMemo(() => Atom.make<TestList>(createList(100)).pipe(Atom.keepAlive), []);
|
|
86
|
-
const list = useAtomValue(listAtom);
|
|
87
|
-
const items = list.items;
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<List.Root<TestItemType> dragPreview items={items} {...props}>
|
|
91
|
-
{({ items }) => (
|
|
92
|
-
<div role='list' className='h-full w-full overflow-auto'>
|
|
93
|
-
{items?.map((item) => (
|
|
94
|
-
<List.Item<TestItemType> key={item.id} item={item} classNames={mx(grid)}>
|
|
95
|
-
<List.ItemDragHandle />
|
|
96
|
-
<List.ItemTitle>{item.name}</List.ItemTitle>
|
|
97
|
-
<List.ItemDeleteButton />
|
|
98
|
-
</List.Item>
|
|
99
|
-
))}
|
|
100
|
-
</div>
|
|
101
|
-
)}
|
|
102
|
-
</List.Root>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const meta = {
|
|
107
|
-
title: 'ui/react-ui-list/List',
|
|
108
|
-
component: List.Root,
|
|
109
|
-
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
|
|
110
|
-
parameters: {
|
|
111
|
-
layout: 'fullscreen',
|
|
112
|
-
},
|
|
113
|
-
} satisfies Meta<typeof List.Root>;
|
|
114
|
-
|
|
115
|
-
export default meta;
|
|
116
|
-
|
|
117
|
-
export const Default: StoryObj<typeof DefaultStory> = {
|
|
118
|
-
render: DefaultStory,
|
|
119
|
-
args: {
|
|
120
|
-
isItem: Schema.is(TestItemSchema),
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const Simple: StoryObj<typeof SimpleStory> = {
|
|
125
|
-
render: SimpleStory,
|
|
126
|
-
args: {
|
|
127
|
-
isItem: Schema.is(TestItemSchema),
|
|
128
|
-
},
|
|
129
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
ListItem,
|
|
7
|
-
ListItemIconButton,
|
|
8
|
-
ListItemDeleteButton,
|
|
9
|
-
ListItemDragHandle,
|
|
10
|
-
ListItemDragPreview,
|
|
11
|
-
type ListItemProps,
|
|
12
|
-
type ListItemRecord,
|
|
13
|
-
ListItemTitle,
|
|
14
|
-
ListItemWrapper,
|
|
15
|
-
} from './ListItem';
|
|
16
|
-
import { ListRoot, type ListRootProps } from './ListRoot';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Draggable list with per-row drag handles and delete buttons.
|
|
20
|
-
* Ref: https://github.com/atlassian/pragmatic-drag-and-drop
|
|
21
|
-
* Ref: https://github.com/alexreardon/pdnd-react-tailwind/blob/main/src/task.tsx
|
|
22
|
-
*
|
|
23
|
-
* @deprecated New code should use one of:
|
|
24
|
-
*
|
|
25
|
-
* - `RowList` / `CardList` from this same package — for selectable
|
|
26
|
-
* pickers (master/detail). Correct ARIA + dx-* by construction.
|
|
27
|
-
* - `Mosaic.Stack` / `Mosaic.VirtualStack` from `@dxos/react-ui-mosaic`
|
|
28
|
-
* — for virtualized or drag-reorderable card stacks.
|
|
29
|
-
*
|
|
30
|
-
* This component is retained for the existing reorder-with-delete-button
|
|
31
|
-
* use cases (plugin-meeting, plugin-automation, plugin-zen, etc.) until
|
|
32
|
-
* each is migrated; see `AUDIT.md` Phase 6 for the migration plan.
|
|
33
|
-
*/
|
|
34
|
-
export const List = {
|
|
35
|
-
Root: ListRoot,
|
|
36
|
-
Item: ListItem,
|
|
37
|
-
ItemDragPreview: ListItemDragPreview,
|
|
38
|
-
ItemWrapper: ListItemWrapper,
|
|
39
|
-
ItemDragHandle: ListItemDragHandle,
|
|
40
|
-
ItemIconButton: ListItemIconButton,
|
|
41
|
-
ItemDeleteButton: ListItemDeleteButton,
|
|
42
|
-
ItemTitle: ListItemTitle,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
type ListItem = ListItemRecord;
|
|
46
|
-
|
|
47
|
-
export type { ListRootProps, ListItemProps, ListItem, ListItemRecord };
|