@dxos/react-ui 0.3.9-main.e6215fc → 0.3.9-main.ef334cd

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.
Files changed (71) hide show
  1. package/dist/lib/browser/index.mjs +268 -384
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts.map +1 -1
  5. package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
  6. package/dist/types/src/components/Input/Input.d.ts +2 -2
  7. package/dist/types/src/components/Input/Input.stories.d.ts +1 -1
  8. package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
  9. package/dist/types/src/components/Lists/List.d.ts.map +1 -0
  10. package/dist/types/src/components/Lists/List.stories.d.ts.map +1 -0
  11. package/dist/types/src/components/Lists/Tree.d.ts.map +1 -0
  12. package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -0
  13. package/dist/types/src/components/Lists/index.d.ts.map +1 -0
  14. package/dist/types/src/components/Main/Main.d.ts +2 -2
  15. package/dist/types/src/components/Status/Status.d.ts +10 -0
  16. package/dist/types/src/components/Status/Status.d.ts.map +1 -0
  17. package/dist/types/src/components/Status/Status.stories.d.ts +12 -0
  18. package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -0
  19. package/dist/types/src/components/Status/index.d.ts +2 -0
  20. package/dist/types/src/components/Status/index.d.ts.map +1 -0
  21. package/dist/types/src/components/index.d.ts +2 -4
  22. package/dist/types/src/components/index.d.ts.map +1 -1
  23. package/package.json +6 -6
  24. package/src/components/AnchoredOverflow/AnchoredOverflow.tsx +12 -2
  25. package/src/components/Breadcrumb/Breadcrumb.tsx +9 -1
  26. package/src/components/Input/Input.stories.tsx +19 -2
  27. package/src/components/Status/Status.stories.tsx +33 -0
  28. package/src/components/Status/Status.tsx +38 -0
  29. package/src/components/{Card → Status}/index.ts +1 -1
  30. package/src/components/index.ts +2 -4
  31. package/dist/types/src/components/Card/Card.d.ts +0 -52
  32. package/dist/types/src/components/Card/Card.d.ts.map +0 -1
  33. package/dist/types/src/components/Card/Card.stories.d.ts +0 -56
  34. package/dist/types/src/components/Card/Card.stories.d.ts.map +0 -1
  35. package/dist/types/src/components/Card/index.d.ts +0 -2
  36. package/dist/types/src/components/Card/index.d.ts.map +0 -1
  37. package/dist/types/src/components/Center/Center.d.ts +0 -4
  38. package/dist/types/src/components/Center/Center.d.ts.map +0 -1
  39. package/dist/types/src/components/Center/Center.stories.d.ts +0 -11
  40. package/dist/types/src/components/Center/Center.stories.d.ts.map +0 -1
  41. package/dist/types/src/components/Center/index.d.ts +0 -2
  42. package/dist/types/src/components/Center/index.d.ts.map +0 -1
  43. package/dist/types/src/components/List/List.d.ts.map +0 -1
  44. package/dist/types/src/components/List/List.stories.d.ts.map +0 -1
  45. package/dist/types/src/components/List/Tree.d.ts.map +0 -1
  46. package/dist/types/src/components/List/Tree.stories.d.ts.map +0 -1
  47. package/dist/types/src/components/List/index.d.ts.map +0 -1
  48. package/dist/types/src/components/ProgressBar/ProgressBar.d.ts +0 -7
  49. package/dist/types/src/components/ProgressBar/ProgressBar.d.ts.map +0 -1
  50. package/dist/types/src/components/ProgressBar/ProgressBar.stories.d.ts +0 -12
  51. package/dist/types/src/components/ProgressBar/ProgressBar.stories.d.ts.map +0 -1
  52. package/dist/types/src/components/ProgressBar/index.d.ts +0 -2
  53. package/dist/types/src/components/ProgressBar/index.d.ts.map +0 -1
  54. package/src/components/Card/Card.stories.tsx +0 -220
  55. package/src/components/Card/Card.tsx +0 -147
  56. package/src/components/Center/Center.stories.tsx +0 -18
  57. package/src/components/Center/Center.tsx +0 -16
  58. package/src/components/Center/index.ts +0 -5
  59. package/src/components/ProgressBar/ProgressBar.stories.tsx +0 -33
  60. package/src/components/ProgressBar/ProgressBar.tsx +0 -29
  61. package/src/components/ProgressBar/index.ts +0 -5
  62. /package/dist/types/src/components/{List → Lists}/List.d.ts +0 -0
  63. /package/dist/types/src/components/{List → Lists}/List.stories.d.ts +0 -0
  64. /package/dist/types/src/components/{List → Lists}/Tree.d.ts +0 -0
  65. /package/dist/types/src/components/{List → Lists}/Tree.stories.d.ts +0 -0
  66. /package/dist/types/src/components/{List → Lists}/index.d.ts +0 -0
  67. /package/src/components/{List → Lists}/List.stories.tsx +0 -0
  68. /package/src/components/{List → Lists}/List.tsx +0 -0
  69. /package/src/components/{List → Lists}/Tree.stories.tsx +0 -0
  70. /package/src/components/{List → Lists}/Tree.tsx +0 -0
  71. /package/src/components/{List → Lists}/index.ts +0 -0
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- import '@dxosTheme';
3
- declare const _default: {
4
- component: (props: import("./Center").CenterProps) => JSX.Element;
5
- actions: {
6
- argTypesRegex: string;
7
- };
8
- };
9
- export default _default;
10
- export declare const Normal: (props: any) => JSX.Element;
11
- //# sourceMappingURL=Center.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Center.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Center/Center.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;;;;;;;AAMpB,wBAGE;AAEF,eAAO,MAAM,MAAM,UAAW,GAAG,gBAEhC,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './Center';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Center/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/List.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,KAAK,wBAAwB,EAAE,KAAK,EAAE,EAAc,KAAK,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAElH,OAAO,EAEL,KAAK,SAAS,IAAI,kBAAkB,EACpC,KAAK,eAAe,EAEpB,KAAK,oBAAoB,IAAI,6BAA6B,EAE1D,KAAK,wBAAwB,IAAI,iCAAiC,EAElE,KAAK,+BAA+B,EAEpC,KAAK,aAAa,IAAI,sBAAsB,EAC5C,KAAK,mBAAmB,EACxB,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,KAAK,SAAS,GAAG,eAAe,CAAC,kBAAkB,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7E,QAAA,MAAM,IAAI,krJAWR,CAAC;AAEH,KAAK,mBAAmB,GAAG,eAAe,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAmCpG,KAAK,oBAAoB,GAAG,eAAe,CAAC,6BAA6B,CAAC,CAAC;AAkB3E,KAAK,wBAAwB,GAAG,eAAe,CAAC,iCAAiC,CAAC,CAAC;AA2BnF,KAAK,iBAAiB,GAAG,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAkBjE,eAAO,MAAM,QAAQ,EAAE;IACrB,IAAI,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;IACnD,MAAM,EAAE,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IACvD,OAAO,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,CAAC;IACzD,WAAW,EAAE,yBAAyB,CAAC,wBAAwB,CAAC,CAAC;IACjE,kBAAkB,EAAE,yBAAyB,CAAC,+BAA+B,CAAC,CAAC;IAC/E,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CAQzF,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;AAE/E,YAAY,EACV,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,GAChC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"List.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/List.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAMpB,OAAO,KAA4C,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAkB,KAAK,SAAS,EAAwB,MAAM,QAAQ,CAAC;;;;AAE9E,wBAEE;AAuBF,eAAO,MAAM,oBAAoB;;;;;CAgChC,CAAC;AA+BF,eAAO,MAAM,kBAAkB;;;;;CA8C9B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;CA+BvB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/Tree.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,wBAAwB,EAAE,KAAK,EAAE,EAAc,KAAK,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAElH,OAAO,EAIL,KAAK,+BAA+B,EACpC,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAGf,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,aAAa,GAAG,SAAS,CAAC;AAE/B,KAAK,aAAa,GAAG,iBAAiB,CAAC;AAwBvC,KAAK,oBAAoB,GAAG,oBAAoB,CAAC;AAIjD,KAAK,wBAAwB,GAAG,wBAAwB,CAAC;AAMzD,KAAK,iBAAiB,GAAG,+BAA+B,CAAC;AAIzD,eAAO,MAAM,IAAI;;;CAAyC,CAAC;AAC3D,eAAO,MAAM,QAAQ,EAAE;IACrB,IAAI,EAAE,yBAAyB,CAAC,aAAa,CAAC,CAAC;IAC/C,OAAO,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,CAAC;IACzD,IAAI,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;IACnD,WAAW,EAAE,yBAAyB,CAAC,wBAAwB,CAAC,CAAC;IACjE,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CAOzF,CAAC;AAEF,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tree.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/Tree.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAMpB,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;;;;AA4CF,wBAEE;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
@@ -1,7 +0,0 @@
1
- export type ProgressBarProps = {
2
- indeterminate?: boolean;
3
- progress?: number;
4
- className?: string;
5
- };
6
- export declare const ProgressBar: (props: ProgressBarProps) => JSX.Element;
7
- //# sourceMappingURL=ProgressBar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["../../../../../src/components/ProgressBar/ProgressBar.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,gBAAgB,gBAgBlD,CAAC"}
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import '@dxosTheme';
3
- declare const _default: {
4
- component: (props: import("./ProgressBar").ProgressBarProps) => JSX.Element;
5
- actions: {
6
- argTypesRegex: string;
7
- };
8
- };
9
- export default _default;
10
- export declare const Normal: (props: any) => JSX.Element;
11
- export declare const Indeterminate: (props: any) => JSX.Element;
12
- //# sourceMappingURL=ProgressBar.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProgressBar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/ProgressBar/ProgressBar.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;;;;;;;AAMpB,wBAGE;AAEF,eAAO,MAAM,MAAM,UAAW,GAAG,gBAShC,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,GAAG,gBAMvC,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './ProgressBar';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ProgressBar/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC"}
@@ -1,220 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxosTheme';
6
-
7
- import { DndContext, type DragEndEvent } from '@dnd-kit/core';
8
- import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
9
- import { CSS } from '@dnd-kit/utilities';
10
- import { faker } from '@faker-js/faker';
11
- import React, { type FC, type PropsWithChildren, useState } from 'react';
12
-
13
- import { chromeSurface, mx } from '@dxos/react-ui-theme';
14
-
15
- import { Card } from './Card';
16
- import { DensityProvider } from '../DensityProvider';
17
- import { DropdownMenu } from '../DropdownMenu';
18
- import { Input } from '../Input';
19
- import { ScrollArea } from '../ScrollArea';
20
-
21
- faker.seed(1);
22
-
23
- // https://unsplash.com
24
- // TODO(burdon): Use https://picsum.photos
25
- const testImages = [
26
- 'https://images.unsplash.com/photo-1616394158624-a2ba9cfe2994',
27
- 'https://images.unsplash.com/photo-1507941097613-9f2157b69235',
28
- 'https://images.unsplash.com/photo-1431274172761-fca41d930114',
29
- 'https://images.unsplash.com/photo-1513635269975-59663e0ac1ad',
30
- 'https://images.unsplash.com/photo-1564221710304-0b37c8b9d729',
31
- 'https://images.unsplash.com/photo-1605425183435-25b7e99104a4',
32
- ];
33
-
34
- type CardData = {
35
- id: string;
36
- title: string;
37
- body: string;
38
- image?: string;
39
- };
40
-
41
- const DraggableCard: FC<{ data: CardData; onDelete: (id: string) => void }> = ({
42
- data: { id, title, body, image },
43
- onDelete,
44
- }) => {
45
- const { attributes, listeners, setNodeRef, transform } = useSortable({ id });
46
- const t = transform ? Object.assign(transform, { scaleY: 1 }) : null;
47
-
48
- return (
49
- <Card.Root ref={setNodeRef} style={{ transform: CSS.Transform.toString(t) }}>
50
- <Card.Header>
51
- <Card.DragHandle {...listeners} {...attributes} />
52
- <Card.Title title={title} />
53
- <DropdownMenu.Root>
54
- <DropdownMenu.Trigger asChild>
55
- <Card.Menu />
56
- </DropdownMenu.Trigger>
57
- <DropdownMenu.Content>
58
- <DropdownMenu.Viewport>
59
- <DropdownMenu.Item onClick={() => onDelete(id)}>Delete</DropdownMenu.Item>
60
- </DropdownMenu.Viewport>
61
- </DropdownMenu.Content>
62
- </DropdownMenu.Root>
63
- </Card.Header>
64
- <Card.Body classNames={'text-sm'} gutter>
65
- <p>{body}</p>
66
- </Card.Body>
67
- {image && <Card.Media src={image} classNames={'h-[160px]'} />}
68
- </Card.Root>
69
- );
70
- };
71
-
72
- const DraggableStory: FC<PropsWithChildren> = ({ children }) => {
73
- const [cards, setCards] = useState<CardData[]>(
74
- Array.from({ length: 7 }).map(() => ({
75
- id: faker.string.uuid(),
76
- title: faker.lorem.sentence(3),
77
- body: faker.lorem.sentences(),
78
- image: faker.datatype.boolean() ? faker.helpers.arrayElement(testImages) : undefined,
79
- })),
80
- );
81
-
82
- const handleDelete = (id: string) => {
83
- setCards((cards) => cards.filter((card) => card.id !== id));
84
- };
85
-
86
- const handleDragEnd = (event: DragEndEvent) => {
87
- const { active, over } = event;
88
- if (active.id !== over?.id) {
89
- setCards((cards) => {
90
- const oldIndex = cards.findIndex((card) => card.id === active.id);
91
- const newIndex = cards.findIndex((card) => card.id === over?.id);
92
- return arrayMove(cards, oldIndex, newIndex);
93
- });
94
- }
95
- };
96
-
97
- return (
98
- <DndContext onDragEnd={handleDragEnd}>
99
- <SortableContext items={cards.map(({ id }) => id)} strategy={verticalListSortingStrategy}>
100
- <div className='flex flex-col overflow-y-scroll'>
101
- <div className='flex flex-col gap-4'>
102
- {cards.map((card) => (
103
- <DraggableCard key={card.id} data={card} onDelete={handleDelete} />
104
- ))}
105
- </div>
106
- </div>
107
- </SortableContext>
108
- </DndContext>
109
- );
110
- };
111
-
112
- const ReadonlyCardStory = () => {
113
- return (
114
- <div className='flex flex-col overflow-y-scroll'>
115
- <div className='flex flex-col gap-4'>
116
- <Card.Root square noPadding>
117
- <Card.Header floating>
118
- <Card.DragHandle position='left' />
119
- <Card.Menu position='right' />
120
- </Card.Header>
121
- <Card.Media src={testImages[1]} />
122
- </Card.Root>
123
-
124
- <Card.Root>
125
- <Card.Header>
126
- <Card.Title title={faker.lorem.sentence(3)} />
127
- </Card.Header>
128
- </Card.Root>
129
-
130
- <Card.Root>
131
- <Card.Body classNames={'text-sm font-thin h-[100px]'}>
132
- <ScrollArea.Root>
133
- <ScrollArea.Viewport>{faker.lorem.sentences(16)}</ScrollArea.Viewport>
134
- <ScrollArea.Scrollbar orientation='vertical'>
135
- <ScrollArea.Thumb />
136
- </ScrollArea.Scrollbar>
137
- </ScrollArea.Root>
138
- </Card.Body>
139
- </Card.Root>
140
-
141
- <Card.Root>
142
- <Card.Header>
143
- <Card.Title center title={faker.lorem.sentence(3)} />
144
- </Card.Header>
145
- <Card.Body classNames={'text-sm font-thin'}>{faker.lorem.sentences(3)}</Card.Body>
146
- </Card.Root>
147
-
148
- <Card.Root>
149
- <Card.Header>
150
- <Card.DragHandle />
151
- <Card.Title title={faker.lorem.sentence(8)} />
152
- {/* TODO(burdon): Menu util. */}
153
- <Card.Menu />
154
- </Card.Header>
155
- <Card.Body gutter classNames={'gap-2 text-sm font-thin'}>
156
- <p>Content with gutter</p>
157
- <p className='line-clamp-3'>{faker.lorem.sentences(3)}</p>
158
- </Card.Body>
159
- </Card.Root>
160
-
161
- <Card.Root>
162
- <Card.Header>
163
- <Card.DragHandle />
164
- <Card.Title title={faker.lorem.sentence(3)} />
165
- <Card.Menu />
166
- </Card.Header>
167
- <Card.Body gutter classNames={'text-sm gap-2 font-thin'}>
168
- <p className='line-clamp-3'>{faker.lorem.sentences(1)}</p>
169
- </Card.Body>
170
- <Card.Media classNames={'h-[200px] grayscale'} src={testImages[0]} />
171
- <Card.Body gutter classNames={'text-sm gap-2 font-thin'}>
172
- <p className='line-clamp-3'>{faker.lorem.sentences(3)}</p>
173
- </Card.Body>
174
- </Card.Root>
175
- </div>
176
- </div>
177
- );
178
- };
179
-
180
- const EditableCardStory = () => {
181
- return (
182
- <div className='flex flex-col h-full justify-center'>
183
- <Card.Root>
184
- <Card.Header>
185
- <Card.DragHandle />
186
- <Input.Root>
187
- <Input.TextInput classNames={'-mx-2 px-2'} variant='subdued' placeholder={'Title'} />
188
- </Input.Root>
189
- <Card.Menu />
190
- </Card.Header>
191
- <Card.Body gutter classNames={'gap-2 text-sm font-thin'}>
192
- {faker.lorem.sentences()}
193
- </Card.Body>
194
- </Card.Root>
195
- </div>
196
- );
197
- };
198
-
199
- export default {
200
- component: Card,
201
- decorators: [
202
- (Story: any) => (
203
- <div className={mx('flex h-screen w-full justify-center overflow-hidden', chromeSurface)}>
204
- <div className='flex flex-col w-[360px] overflow-hidden'>
205
- {/* TODO(burdon): Story for different densities. */}
206
- <DensityProvider density='fine'>
207
- <Story />
208
- </DensityProvider>
209
- </div>
210
- </div>
211
- ),
212
- ],
213
- parameters: {
214
- layout: 'fullscreen',
215
- },
216
- };
217
-
218
- export const Draggable = () => <DraggableStory />;
219
- export const ReadOnly = () => <ReadonlyCardStory />;
220
- export const Editable = () => <EditableCardStory />;
@@ -1,147 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { DotsSixVertical, DotsThreeVertical, type Icon } from '@phosphor-icons/react';
6
- import { type Primitive } from '@radix-ui/react-primitive';
7
- import React, {
8
- type ComponentPropsWithoutRef,
9
- type ComponentPropsWithRef,
10
- type FC,
11
- forwardRef,
12
- type PropsWithChildren,
13
- } from 'react';
14
-
15
- import { useDensityContext, useThemeContext } from '../../hooks';
16
- import { type ThemedClassName } from '../../util';
17
- import { DropdownMenu } from '../DropdownMenu';
18
-
19
- type CardRootProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
20
- grow?: boolean;
21
- square?: boolean;
22
- noPadding?: boolean;
23
- };
24
-
25
- // TODO(burdon): Forward refs for all components?
26
- const CardRoot = forwardRef<HTMLDivElement, CardRootProps>(
27
- ({ grow, square, noPadding, classNames, children, ...props }, forwardedRef) => {
28
- const { tx } = useThemeContext();
29
- return (
30
- <div {...props} ref={forwardedRef} className={tx('card.root', 'card', { grow, square, noPadding }, classNames)}>
31
- {children}
32
- </div>
33
- );
34
- },
35
- );
36
-
37
- type CardHeaderProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { floating?: boolean };
38
-
39
- export const CardHeader: FC<CardHeaderProps> = ({ floating, classNames, children, ...props }) => {
40
- const { tx } = useThemeContext();
41
- return (
42
- <div {...props} className={tx('card.header', 'card', { floating }, classNames)}>
43
- {children}
44
- </div>
45
- );
46
- };
47
-
48
- type CardTitleProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & {
49
- center?: boolean;
50
- title?: string;
51
- };
52
-
53
- export const CardTitle: FC<CardTitleProps> = ({ center, title, classNames, ...props }) => {
54
- const { tx } = useThemeContext();
55
- return (
56
- <div {...props} className={tx('card.title', 'card', { center }, classNames)}>
57
- {title}
58
- </div>
59
- );
60
- };
61
-
62
- // TODO(burdon): Reuse ListItemEndcap?
63
- type CardDragHandleProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { position?: 'left' | 'right' };
64
-
65
- const CardDragHandle: FC<CardDragHandleProps> = ({ position, classNames, ...props }) => {
66
- const { tx } = useThemeContext();
67
- const density = useDensityContext();
68
- return (
69
- <div {...props} className={tx('card.dragHandle', 'card', { density, position }, classNames)}>
70
- <DotsSixVertical className={tx('card.dragHandleIcon', 'card')} />
71
- </div>
72
- );
73
- };
74
-
75
- type CardEndcapProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { Icon: Icon; position?: 'left' | 'right' };
76
-
77
- const CardEndcap: FC<CardEndcapProps> = ({ Icon, position, classNames, ...props }) => {
78
- const { tx } = useThemeContext();
79
- const density = useDensityContext();
80
- return (
81
- <div {...props} className={tx('card.menu', 'card', { density, position }, classNames)}>
82
- <Icon className={tx('card.menuIcon', 'card')} />
83
- </div>
84
- );
85
- };
86
-
87
- type CardMenuProps = PropsWithChildren<
88
- ThemedClassName<ComponentPropsWithoutRef<'div'>> & { position?: 'left' | 'right' }
89
- >;
90
-
91
- // TODO(burdon): Reconcile with Endcap (remove dropdown from here). See ListItem.Endcap (style icon/size?)
92
- const CardMenu = forwardRef<HTMLDivElement, CardMenuProps>(
93
- ({ children, position, classNames, ...props }, forwardRef) => {
94
- const { tx } = useThemeContext();
95
- const density = useDensityContext();
96
- return (
97
- <div {...props} className={tx('card.menu', 'card', { density, position }, classNames)} ref={forwardRef}>
98
- <DropdownMenu.Root>
99
- <DropdownMenu.Trigger asChild>
100
- <DotsThreeVertical className={tx('card.menuIcon', 'card', {})} />
101
- </DropdownMenu.Trigger>
102
- {/* TODO(burdon): Position to the left of the menu button. */}
103
- <DropdownMenu.Content>
104
- <DropdownMenu.Viewport>{children}</DropdownMenu.Viewport>
105
- </DropdownMenu.Content>
106
- </DropdownMenu.Root>
107
- </div>
108
- );
109
- },
110
- );
111
-
112
- type CardBodyProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { gutter?: boolean };
113
-
114
- export const CardBody: FC<CardBodyProps> = ({ gutter, classNames, children, ...props }) => {
115
- const { tx } = useThemeContext();
116
- const density = useDensityContext();
117
- return (
118
- <div {...props} className={tx('card.body', 'card', { density, gutter }, classNames)}>
119
- {children}
120
- </div>
121
- );
122
- };
123
-
124
- type CardMediaProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { src?: string; contain?: boolean };
125
-
126
- // TODO(burdon): Option to set to 50% of height of card.
127
- export const CardMedia: FC<CardMediaProps> = ({ src, contain, classNames, ...props }) => {
128
- const { tx } = useThemeContext();
129
- return (
130
- <div className='flex grow overflow-hidden'>
131
- <img {...props} className={tx('card.media', 'card', { contain }, classNames)} src={src} />
132
- </div>
133
- );
134
- };
135
-
136
- export const Card = {
137
- Root: CardRoot,
138
- Header: CardHeader,
139
- DragHandle: CardDragHandle,
140
- Endcap: CardEndcap,
141
- Menu: CardMenu,
142
- Title: CardTitle,
143
- Body: CardBody,
144
- Media: CardMedia,
145
- };
146
-
147
- export type { CardRootProps };
@@ -1,18 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxosTheme';
6
-
7
- import React from 'react';
8
-
9
- import { Center } from './Center';
10
-
11
- export default {
12
- component: Center,
13
- actions: { argTypesRegex: '^on.*' },
14
- };
15
-
16
- export const Normal = (props: any) => {
17
- return <Center {...props}>✨</Center>;
18
- };
@@ -1,16 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type DetailedHTMLProps, type PropsWithChildren, type HTMLAttributes } from 'react';
6
-
7
- export type CenterProps = PropsWithChildren<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
8
-
9
- export const Center = (props: CenterProps) => {
10
- const { children, className, ...rest } = props;
11
- return (
12
- <div className={'h-full flex items-center justify-center ' + className} {...rest}>
13
- {children}
14
- </div>
15
- );
16
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './Center';
@@ -1,33 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxosTheme';
6
-
7
- import React from 'react';
8
-
9
- import { ProgressBar } from './ProgressBar';
10
-
11
- export default {
12
- component: ProgressBar,
13
- actions: { argTypesRegex: '^on.*' },
14
- };
15
-
16
- export const Normal = (props: any) => {
17
- return (
18
- <div className='flex flex-col gap-5'>
19
- <ProgressBar progress={0} {...props} />
20
- <ProgressBar progress={0.3} {...props} />
21
- <ProgressBar progress={0.7} {...props} />
22
- <ProgressBar progress={1} {...props} />
23
- </div>
24
- );
25
- };
26
-
27
- export const Indeterminate = (props: any) => {
28
- return (
29
- <>
30
- <ProgressBar className='m-4' indeterminate {...props} />
31
- </>
32
- );
33
- };
@@ -1,29 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- export type ProgressBarProps = {
8
- indeterminate?: boolean;
9
- progress?: number;
10
- className?: string;
11
- };
12
-
13
- export const ProgressBar = (props: ProgressBarProps) => {
14
- const { className, indeterminate = false, progress = 0 } = props;
15
- return (
16
- <span
17
- role='none'
18
- className={'w-20 h-1 inline-block relative bg-neutral-400/25 rounded-full' + (className ? ' ' + className : '')}
19
- >
20
- <span
21
- className={
22
- 'absolute left-0 top-0 bottom-0 inline-block bg-neutral-400 rounded-full' +
23
- (indeterminate ? ' animate-progress-indeterminate' : '')
24
- }
25
- {...(indeterminate ? {} : { style: { width: `${(progress * 100).toFixed(0)}%` } })}
26
- />
27
- </span>
28
- );
29
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './ProgressBar';
File without changes
File without changes
File without changes
File without changes
File without changes