@usefragments/ui 1.1.1 → 1.2.0

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 (141) hide show
  1. package/dist/assets/ui.css +327 -274
  2. package/dist/components/Checkbox/Checkbox.module.scss.cjs +11 -11
  3. package/dist/components/Checkbox/Checkbox.module.scss.js +11 -11
  4. package/dist/components/Chip/Chip.module.scss.cjs +15 -15
  5. package/dist/components/Chip/Chip.module.scss.js +15 -15
  6. package/dist/components/Combobox/index.cjs +106 -9
  7. package/dist/components/Combobox/index.d.ts.map +1 -1
  8. package/dist/components/Combobox/index.js +106 -9
  9. package/dist/components/DataTable/DataTable.module.scss.cjs +37 -34
  10. package/dist/components/DataTable/DataTable.module.scss.js +37 -34
  11. package/dist/components/Main/Main.module.scss.cjs +26 -0
  12. package/dist/components/Main/Main.module.scss.js +26 -0
  13. package/dist/components/Main/index.cjs +128 -0
  14. package/dist/components/Main/index.d.ts +22 -0
  15. package/dist/components/Main/index.d.ts.map +1 -0
  16. package/dist/components/Main/index.js +111 -0
  17. package/dist/components/Table/Table.module.scss.cjs +19 -19
  18. package/dist/components/Table/Table.module.scss.js +19 -19
  19. package/dist/components/TableOfContents/TableOfContents.module.scss.cjs +15 -15
  20. package/dist/components/TableOfContents/TableOfContents.module.scss.js +15 -15
  21. package/dist/components/TableOfContents/index.cjs +22 -42
  22. package/dist/components/TableOfContents/index.d.ts +3 -3
  23. package/dist/components/TableOfContents/index.d.ts.map +1 -1
  24. package/dist/components/TableOfContents/index.js +22 -42
  25. package/dist/index.cjs +87 -85
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -0
  29. package/fragments.json +1 -1
  30. package/package.json +7 -2
  31. package/src/components/Checkbox/Checkbox.contract.json +5 -24
  32. package/src/components/Checkbox/Checkbox.module.scss +4 -2
  33. package/src/components/Chip/Chip.contract.json +11 -28
  34. package/src/components/Chip/Chip.module.scss +21 -45
  35. package/src/components/Combobox/Combobox.contract.json +6 -24
  36. package/src/components/Combobox/index.tsx +132 -6
  37. package/src/components/DataTable/DataTable.module.scss +31 -8
  38. package/src/components/Main/Main.contract.json +79 -0
  39. package/src/components/Main/Main.module.scss +31 -0
  40. package/src/components/Main/index.tsx +124 -0
  41. package/src/components/Table/Table.module.scss +22 -5
  42. package/src/components/TableOfContents/TableOfContents.contract.json +6 -16
  43. package/src/components/TableOfContents/TableOfContents.module.scss +10 -13
  44. package/src/components/TableOfContents/index.tsx +27 -38
  45. package/src/index.ts +3 -0
  46. package/src/tokens/_component-properties.scss +1 -0
  47. package/dist/components/Cloud/DashboardLayoutPrototypes.shared.d.ts +0 -33
  48. package/dist/components/Cloud/DashboardLayoutPrototypes.shared.d.ts.map +0 -1
  49. package/dist/components/Cloud/DashboardLayoutPrototypes.shell.d.ts +0 -11
  50. package/dist/components/Cloud/DashboardLayoutPrototypes.shell.d.ts.map +0 -1
  51. package/dist/components/Cloud/PullRequestsPrototypes.content.d.ts +0 -5
  52. package/dist/components/Cloud/PullRequestsPrototypes.content.d.ts.map +0 -1
  53. package/dist/components/Cloud/PullRequestsPrototypes.detail-panels.d.ts +0 -4
  54. package/dist/components/Cloud/PullRequestsPrototypes.detail-panels.d.ts.map +0 -1
  55. package/dist/components/Cloud/PullRequestsPrototypes.detail.d.ts +0 -3
  56. package/dist/components/Cloud/PullRequestsPrototypes.detail.d.ts.map +0 -1
  57. package/dist/components/Cloud/PullRequestsPrototypes.id-data.d.ts +0 -86
  58. package/dist/components/Cloud/PullRequestsPrototypes.id-data.d.ts.map +0 -1
  59. package/dist/components/Cloud/PullRequestsPrototypes.id-page.d.ts +0 -2
  60. package/dist/components/Cloud/PullRequestsPrototypes.id-page.d.ts.map +0 -1
  61. package/src/components/Accordion/Accordion.stories.tsx +0 -106
  62. package/src/components/Alert/Alert.stories.tsx +0 -119
  63. package/src/components/AppShell/AppShell.stories.tsx +0 -156
  64. package/src/components/Avatar/Avatar.stories.tsx +0 -74
  65. package/src/components/Badge/Badge.stories.tsx +0 -92
  66. package/src/components/BentoGrid/BentoGrid.stories.tsx +0 -98
  67. package/src/components/Box/Box.stories.tsx +0 -150
  68. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +0 -87
  69. package/src/components/Button/Button.stories.tsx +0 -103
  70. package/src/components/ButtonGroup/ButtonGroup.stories.tsx +0 -97
  71. package/src/components/Card/Card.stories.tsx +0 -144
  72. package/src/components/Chart/Chart.stories.tsx +0 -119
  73. package/src/components/Checkbox/Checkbox.stories.tsx +0 -68
  74. package/src/components/Chip/Chip.stories.tsx +0 -70
  75. package/src/components/Cloud/CloudGovernanceShell.module.scss +0 -88
  76. package/src/components/Cloud/CloudGovernanceShell.stories.tsx +0 -446
  77. package/src/components/Cloud/ControlSizing.module.scss +0 -49
  78. package/src/components/Cloud/ControlSizing.stories.tsx +0 -238
  79. package/src/components/Cloud/DashboardLayoutPrototypes.module.scss +0 -462
  80. package/src/components/Cloud/DashboardLayoutPrototypes.shared.tsx +0 -375
  81. package/src/components/Cloud/DashboardLayoutPrototypes.shell.tsx +0 -147
  82. package/src/components/Cloud/DashboardLayoutPrototypes.stories.tsx +0 -328
  83. package/src/components/Cloud/PullRequestsPrototypes.content.tsx +0 -283
  84. package/src/components/Cloud/PullRequestsPrototypes.detail-panels.tsx +0 -381
  85. package/src/components/Cloud/PullRequestsPrototypes.detail.tsx +0 -204
  86. package/src/components/Cloud/PullRequestsPrototypes.id-data.ts +0 -395
  87. package/src/components/Cloud/PullRequestsPrototypes.id-page.tsx +0 -349
  88. package/src/components/Cloud/PullRequestsPrototypes.stories.tsx +0 -81
  89. package/src/components/CodeBlock/CodeBlock.stories.tsx +0 -147
  90. package/src/components/Collapsible/Collapsible.stories.tsx +0 -94
  91. package/src/components/ColorPicker/ColorPicker.stories.tsx +0 -74
  92. package/src/components/Combobox/Combobox.stories.tsx +0 -133
  93. package/src/components/Command/Command.stories.tsx +0 -102
  94. package/src/components/ConversationList/ConversationList.stories.tsx +0 -93
  95. package/src/components/DataTable/DataTable.stories.tsx +0 -129
  96. package/src/components/DatePicker/DatePicker.stories.tsx +0 -129
  97. package/src/components/Dialog/Dialog.stories.tsx +0 -154
  98. package/src/components/Drawer/Drawer.stories.tsx +0 -144
  99. package/src/components/Editor/Editor.stories.tsx +0 -99
  100. package/src/components/EmptyState/EmptyState.stories.tsx +0 -97
  101. package/src/components/Field/Field.stories.tsx +0 -109
  102. package/src/components/Fieldset/Fieldset.stories.tsx +0 -116
  103. package/src/components/Form/Form.stories.tsx +0 -142
  104. package/src/components/Grid/Grid.stories.tsx +0 -125
  105. package/src/components/Header/Header.stories.tsx +0 -133
  106. package/src/components/Icon/Icon.stories.tsx +0 -80
  107. package/src/components/IconButton/IconButton.stories.tsx +0 -78
  108. package/src/components/Image/Image.stories.tsx +0 -109
  109. package/src/components/Input/Input.stories.tsx +0 -104
  110. package/src/components/Link/Link.stories.tsx +0 -67
  111. package/src/components/List/List.stories.tsx +0 -95
  112. package/src/components/Listbox/Listbox.stories.tsx +0 -81
  113. package/src/components/Loading/Loading.stories.tsx +0 -69
  114. package/src/components/Markdown/Markdown.stories.tsx +0 -75
  115. package/src/components/Menu/Menu.stories.tsx +0 -113
  116. package/src/components/Message/Message.stories.tsx +0 -85
  117. package/src/components/NavigationMenu/NavigationMenu.stories.tsx +0 -161
  118. package/src/components/Pagination/Pagination.stories.tsx +0 -81
  119. package/src/components/Popover/Popover.stories.tsx +0 -152
  120. package/src/components/Progress/Progress.stories.tsx +0 -64
  121. package/src/components/Prompt/Prompt.stories.tsx +0 -93
  122. package/src/components/RadioGroup/RadioGroup.stories.tsx +0 -107
  123. package/src/components/ScrollArea/ScrollArea.stories.tsx +0 -97
  124. package/src/components/Select/Select.stories.tsx +0 -127
  125. package/src/components/Separator/Separator.stories.tsx +0 -84
  126. package/src/components/Sidebar/Sidebar.stories.tsx +0 -122
  127. package/src/components/Skeleton/Skeleton.stories.tsx +0 -80
  128. package/src/components/Slider/Slider.stories.tsx +0 -73
  129. package/src/components/Stack/Stack.stories.tsx +0 -73
  130. package/src/components/Switch/Switch.stories.tsx +0 -59
  131. package/src/components/Table/Table.stories.tsx +0 -219
  132. package/src/components/TableOfContents/TableOfContents.stories.tsx +0 -120
  133. package/src/components/Tabs/Tabs.stories.tsx +0 -136
  134. package/src/components/Text/Text.stories.tsx +0 -133
  135. package/src/components/Textarea/Textarea.stories.tsx +0 -107
  136. package/src/components/Theme/Theme.stories.tsx +0 -95
  137. package/src/components/ThinkingIndicator/ThinkingIndicator.stories.tsx +0 -85
  138. package/src/components/Toast/Toast.stories.tsx +0 -91
  139. package/src/components/ToggleGroup/ToggleGroup.stories.tsx +0 -114
  140. package/src/components/Tooltip/Tooltip.stories.tsx +0 -95
  141. package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +0 -78
@@ -1,74 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { ColorPicker } from '.';
3
-
4
- /**
5
- * Color selection control with a swatch, hex input, and visual picker.
6
- * Accepts controlled `value` or uncontrolled `defaultValue` hex strings,
7
- * sizes sm/md/lg, an optional hex input, and an error state.
8
- */
9
- const meta = {
10
- title: 'Forms/ColorPicker',
11
- component: ColorPicker,
12
- tags: ['autodocs'],
13
- parameters: {
14
- docs: {
15
- description: {
16
- component: 'Color selection control with hex input and visual picker.',
17
- },
18
- },
19
- },
20
- argTypes: {
21
- size: {
22
- control: 'select',
23
- options: ['sm', 'md', 'lg'],
24
- description: 'Size variant',
25
- },
26
- showInput: { control: 'boolean', description: 'Show the hex input field' },
27
- error: { control: 'boolean', description: 'Show error styling' },
28
- disabled: { control: 'boolean' },
29
- },
30
- args: {
31
- label: 'Brand Color',
32
- defaultValue: '#3b82f6',
33
- size: 'md',
34
- showInput: true,
35
- },
36
- } satisfies Meta<typeof ColorPicker>;
37
-
38
- export default meta;
39
-
40
- type Story = StoryObj<typeof meta>;
41
-
42
- export const Default: Story = {
43
- args: { label: 'Brand Color', defaultValue: '#3b82f6' },
44
- };
45
-
46
- export const WithHelperText: Story = {
47
- args: {
48
- label: 'Primary Color',
49
- defaultValue: '#10b981',
50
- helperText: 'This color will be used for buttons and links',
51
- },
52
- };
53
-
54
- export const SwatchOnly: Story = {
55
- args: { defaultValue: '#ef4444', size: 'sm', showInput: false },
56
- };
57
-
58
- export const ErrorState: Story = {
59
- args: {
60
- label: 'Brand Color',
61
- defaultValue: '#000000',
62
- error: true,
63
- helperText: 'Please select a valid brand color',
64
- },
65
- };
66
-
67
- export const Disabled: Story = {
68
- args: {
69
- label: 'Locked Color',
70
- defaultValue: '#64748b',
71
- helperText: 'This color cannot be changed',
72
- disabled: true,
73
- },
74
- };
@@ -1,133 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { Combobox } from '.';
3
-
4
- /**
5
- * Searchable select that filters a dropdown of options as you type.
6
- * Compose Combobox.Input and Combobox.Content with Combobox.Item children.
7
- * Supports single and multiple selection, groups, and an empty state.
8
- */
9
- const meta = {
10
- title: 'Forms/Combobox',
11
- component: Combobox,
12
- tags: ['autodocs'],
13
- parameters: {
14
- docs: {
15
- description: {
16
- component: 'Searchable select that filters options as you type.',
17
- },
18
- },
19
- },
20
- argTypes: {
21
- size: {
22
- control: 'select',
23
- options: ['sm', 'md', 'lg'],
24
- description: 'Size variant',
25
- },
26
- multiple: { control: 'boolean', description: 'Allow multiple selections' },
27
- autoHighlight: {
28
- control: 'boolean',
29
- description: 'Auto-highlight first match while filtering',
30
- },
31
- disabled: { control: 'boolean' },
32
- },
33
- args: {
34
- size: 'md',
35
- placeholder: 'Select a fruit',
36
- children: (
37
- <>
38
- <Combobox.Input />
39
- <Combobox.Content>
40
- <Combobox.Empty>No matches</Combobox.Empty>
41
- <Combobox.Item value="apple">Apple</Combobox.Item>
42
- </Combobox.Content>
43
- </>
44
- ),
45
- },
46
- } satisfies Meta<typeof Combobox>;
47
-
48
- export default meta;
49
-
50
- type Story = StoryObj<typeof meta>;
51
-
52
- export const Default: Story = {
53
- render: (args) => (
54
- <Combobox {...args}>
55
- <Combobox.Input />
56
- <Combobox.Content>
57
- <Combobox.Empty>No matches</Combobox.Empty>
58
- <Combobox.Item value="apple">Apple</Combobox.Item>
59
- <Combobox.Item value="banana">Banana</Combobox.Item>
60
- <Combobox.Item value="orange">Orange</Combobox.Item>
61
- <Combobox.Item value="grape">Grape</Combobox.Item>
62
- </Combobox.Content>
63
- </Combobox>
64
- ),
65
- };
66
-
67
- export const Multiple: Story = {
68
- args: { multiple: true, placeholder: 'Select fruits...' },
69
- render: (args) => (
70
- <Combobox {...args}>
71
- <Combobox.Input />
72
- <Combobox.Content>
73
- <Combobox.Item value="apple">Apple</Combobox.Item>
74
- <Combobox.Item value="banana">Banana</Combobox.Item>
75
- <Combobox.Item value="orange">Orange</Combobox.Item>
76
- <Combobox.Item value="mango">Mango</Combobox.Item>
77
- </Combobox.Content>
78
- </Combobox>
79
- ),
80
- };
81
-
82
- export const WithLabel: Story = {
83
- args: {
84
- label: 'Assignee',
85
- placeholder: 'Search assignees...',
86
- helperText: 'Type to filter the list of available assignees.',
87
- },
88
- render: (args) => (
89
- <Combobox {...args}>
90
- <Combobox.Input />
91
- <Combobox.Content>
92
- <Combobox.Empty>No matches</Combobox.Empty>
93
- <Combobox.Item value="alice">Alice Johnson</Combobox.Item>
94
- <Combobox.Item value="bob">Bob Chen</Combobox.Item>
95
- <Combobox.Item value="carol">Carol Smith</Combobox.Item>
96
- </Combobox.Content>
97
- </Combobox>
98
- ),
99
- };
100
-
101
- export const WithGroups: Story = {
102
- args: { placeholder: 'Search countries...' },
103
- render: (args) => (
104
- <Combobox {...args}>
105
- <Combobox.Input />
106
- <Combobox.Content>
107
- <Combobox.Group>
108
- <Combobox.GroupLabel>North America</Combobox.GroupLabel>
109
- <Combobox.Item value="us">United States</Combobox.Item>
110
- <Combobox.Item value="ca">Canada</Combobox.Item>
111
- </Combobox.Group>
112
- <Combobox.Group>
113
- <Combobox.GroupLabel>Europe</Combobox.GroupLabel>
114
- <Combobox.Item value="uk">United Kingdom</Combobox.Item>
115
- <Combobox.Item value="de">Germany</Combobox.Item>
116
- </Combobox.Group>
117
- </Combobox.Content>
118
- </Combobox>
119
- ),
120
- };
121
-
122
- export const ErrorState: Story = {
123
- args: { label: 'Reviewer', placeholder: 'Search reviewers...' },
124
- render: (args) => (
125
- <Combobox {...args} error="Please select a reviewer">
126
- <Combobox.Input />
127
- <Combobox.Content>
128
- <Combobox.Item value="alice">Alice</Combobox.Item>
129
- <Combobox.Item value="bob">Bob</Combobox.Item>
130
- </Combobox.Content>
131
- </Combobox>
132
- ),
133
- };
@@ -1,102 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { Command } from '.';
3
-
4
- /**
5
- * Searchable command palette combining an input with a filterable,
6
- * keyboard-navigable list of actions. Compose Command.Input and Command.List
7
- * with Command.Item children; group with Command.Group and Command.Separator.
8
- */
9
- const meta = {
10
- title: 'Navigation/Command',
11
- component: Command,
12
- tags: ['autodocs'],
13
- parameters: {
14
- docs: {
15
- description: {
16
- component: 'Searchable command palette for quick actions.',
17
- },
18
- },
19
- },
20
- argTypes: {
21
- loop: { control: 'boolean', description: 'Loop keyboard navigation' },
22
- },
23
- args: {
24
- loop: true,
25
- children: (
26
- <>
27
- <Command.Input placeholder="Type a command..." />
28
- <Command.List>
29
- <Command.Item onItemSelect={() => {}}>Open File</Command.Item>
30
- <Command.Empty>No results found.</Command.Empty>
31
- </Command.List>
32
- </>
33
- ),
34
- },
35
- } satisfies Meta<typeof Command>;
36
-
37
- export default meta;
38
-
39
- type Story = StoryObj<typeof meta>;
40
-
41
- export const Default: Story = {
42
- render: (args) => (
43
- <div style={{ maxWidth: '400px', width: '100%' }}>
44
- <Command {...args}>
45
- <Command.Input placeholder="Type a command..." />
46
- <Command.List>
47
- <Command.Item onItemSelect={() => {}}>Open File</Command.Item>
48
- <Command.Item onItemSelect={() => {}}>Save Document</Command.Item>
49
- <Command.Item onItemSelect={() => {}}>Print</Command.Item>
50
- <Command.Empty>No results found.</Command.Empty>
51
- </Command.List>
52
- </Command>
53
- </div>
54
- ),
55
- };
56
-
57
- export const WithGroups: Story = {
58
- render: (args) => (
59
- <div style={{ maxWidth: '400px', width: '100%' }}>
60
- <Command {...args}>
61
- <Command.Input placeholder="Search..." />
62
- <Command.List>
63
- <Command.Group heading="Suggestions">
64
- <Command.Item onItemSelect={() => {}}>Calendar</Command.Item>
65
- <Command.Item onItemSelect={() => {}}>Calculator</Command.Item>
66
- </Command.Group>
67
- <Command.Separator />
68
- <Command.Group heading="Settings">
69
- <Command.Item onItemSelect={() => {}}>Profile</Command.Item>
70
- <Command.Item onItemSelect={() => {}}>Billing</Command.Item>
71
- <Command.Item disabled onItemSelect={() => {}}>
72
- Team (coming soon)
73
- </Command.Item>
74
- </Command.Group>
75
- <Command.Empty>No results found.</Command.Empty>
76
- </Command.List>
77
- </Command>
78
- </div>
79
- ),
80
- };
81
-
82
- export const WithKeywords: Story = {
83
- render: (args) => (
84
- <div style={{ maxWidth: '400px', width: '100%' }}>
85
- <Command {...args}>
86
- <Command.Input placeholder="What do you need?" />
87
- <Command.List>
88
- <Command.Item keywords={['create', 'add']} onItemSelect={() => {}}>
89
- New Document
90
- </Command.Item>
91
- <Command.Item keywords={['browse']} onItemSelect={() => {}}>
92
- Open Folder
93
- </Command.Item>
94
- <Command.Item keywords={['find']} onItemSelect={() => {}}>
95
- Search
96
- </Command.Item>
97
- <Command.Empty>No results found.</Command.Empty>
98
- </Command.List>
99
- </Command>
100
- </div>
101
- ),
102
- };
@@ -1,93 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { ConversationList } from '.';
3
-
4
- /**
5
- * Scrollable message container with auto-scroll and history loading.
6
- * Holds message children, with autoScroll behavior (true/false/"smart"),
7
- * an optional empty state, and ConversationList.DateSeparator /
8
- * ConversationList.TypingIndicator subcomponents.
9
- */
10
- const meta = {
11
- title: 'Ai/ConversationList',
12
- component: ConversationList,
13
- tags: ['autodocs'],
14
- parameters: {
15
- docs: {
16
- description: {
17
- component:
18
- 'Scrollable message container with auto-scroll and history loading.',
19
- },
20
- },
21
- },
22
- argTypes: {
23
- loadingHistory: {
24
- control: 'boolean',
25
- description: 'Show loading spinner at top while loading history',
26
- },
27
- },
28
- args: {
29
- autoScroll: 'smart',
30
- loadingHistory: false,
31
- children: (
32
- <>
33
- <div>Hello!</div>
34
- <div>Hi there! How can I help you today?</div>
35
- </>
36
- ),
37
- },
38
- } satisfies Meta<typeof ConversationList>;
39
-
40
- export default meta;
41
-
42
- type Story = StoryObj<typeof meta>;
43
-
44
- export const Basic: Story = {
45
- render: (args) => (
46
- <ConversationList {...args} style={{ height: 280 }}>
47
- <div>Hello!</div>
48
- <div>Hi there! How can I help you today?</div>
49
- <div>Can you explain React hooks?</div>
50
- </ConversationList>
51
- ),
52
- };
53
-
54
- export const WithDateSeparators: Story = {
55
- render: (args) => (
56
- <ConversationList {...args} style={{ height: 280 }}>
57
- <ConversationList.DateSeparator date={new Date(Date.now() - 86400000)} />
58
- <div>A message from yesterday</div>
59
- <ConversationList.DateSeparator date={new Date()} />
60
- <div>And a message from today!</div>
61
- </ConversationList>
62
- ),
63
- };
64
-
65
- export const WithTypingIndicator: Story = {
66
- render: (args) => (
67
- <ConversationList {...args} style={{ height: 280 }}>
68
- <div>What is TypeScript?</div>
69
- <ConversationList.TypingIndicator name="Assistant" />
70
- </ConversationList>
71
- ),
72
- };
73
-
74
- export const LoadingHistory: Story = {
75
- args: { loadingHistory: true },
76
- render: (args) => (
77
- <ConversationList {...args} style={{ height: 280 }}>
78
- <div>This is the latest message</div>
79
- </ConversationList>
80
- ),
81
- };
82
-
83
- export const Empty: Story = {
84
- render: (args) => (
85
- <ConversationList
86
- {...args}
87
- style={{ height: 280 }}
88
- emptyState={<div>Start the conversation</div>}
89
- >
90
- {null}
91
- </ConversationList>
92
- ),
93
- };
@@ -1,129 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { DataTable } from '.';
3
- import type { ColumnDef, DataTableProps } from '.';
4
-
5
- /**
6
- * Data table with sorting, selection, and column management, powered by
7
- * TanStack Table. Requires `columns` and `data`; supports sortable headers,
8
- * checkbox selection, clickable rows, striped/bordered styling, and sizes.
9
- */
10
-
11
- type User = {
12
- id: string;
13
- name: string;
14
- email: string;
15
- role: string;
16
- status: string;
17
- };
18
-
19
- const columns: ColumnDef<User>[] = [
20
- { accessorKey: 'name', header: 'Name' },
21
- { accessorKey: 'email', header: 'Email' },
22
- { accessorKey: 'role', header: 'Role' },
23
- { accessorKey: 'status', header: 'Status' },
24
- ];
25
-
26
- const data: User[] = [
27
- {
28
- id: '1',
29
- name: 'Alice Johnson',
30
- email: 'alice@example.com',
31
- role: 'Admin',
32
- status: 'active',
33
- },
34
- {
35
- id: '2',
36
- name: 'Bob Chen',
37
- email: 'bob@example.com',
38
- role: 'Member',
39
- status: 'pending',
40
- },
41
- {
42
- id: '3',
43
- name: 'Carol Smith',
44
- email: 'carol@example.com',
45
- role: 'Member',
46
- status: 'active',
47
- },
48
- ];
49
-
50
- const meta = {
51
- title: 'Display/DataTable',
52
- component: DataTable,
53
- tags: ['autodocs'],
54
- parameters: {
55
- docs: {
56
- description: {
57
- component: 'Data table with sorting, selection, and column management.',
58
- },
59
- },
60
- },
61
- argTypes: {
62
- size: {
63
- control: 'select',
64
- options: ['sm', 'md'],
65
- description: 'Table density',
66
- },
67
- sortable: { control: 'boolean', description: 'Enable column sorting' },
68
- selectable: { control: 'boolean', description: 'Enable row selection' },
69
- showCheckbox: {
70
- control: 'boolean',
71
- description: 'Show checkbox column (requires selectable)',
72
- },
73
- striped: { control: 'boolean', description: 'Alternating row backgrounds' },
74
- bordered: { control: 'boolean', description: 'Bordered container' },
75
- captionHidden: { control: 'boolean' },
76
- },
77
- args: { columns, data, size: 'md' },
78
- } satisfies Meta<DataTableProps<User>>;
79
-
80
- export default meta;
81
-
82
- type Story = StoryObj<DataTableProps<User>>;
83
-
84
- export const Default: Story = {
85
- args: { columns, data },
86
- };
87
-
88
- export const Sortable: Story = {
89
- args: {
90
- columns,
91
- data,
92
- sortable: true,
93
- bordered: true,
94
- caption: 'Team members',
95
- captionHidden: true,
96
- },
97
- };
98
-
99
- export const CheckboxSelection: Story = {
100
- args: {
101
- columns,
102
- data,
103
- selectable: true,
104
- showCheckbox: true,
105
- bordered: true,
106
- getRowId: (row: User) => row.id,
107
- },
108
- };
109
-
110
- export const Striped: Story = {
111
- args: { columns, data, striped: true, size: 'sm' },
112
- };
113
-
114
- export const ClickableRows: Story = {
115
- args: {
116
- columns,
117
- data,
118
- onRowClick: (row: User) => alert(row.name),
119
- size: 'sm',
120
- },
121
- };
122
-
123
- export const Empty: Story = {
124
- args: {
125
- columns,
126
- data: [],
127
- emptyMessage: 'No users match your search criteria',
128
- },
129
- };
@@ -1,129 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { DatePicker } from ".";
3
-
4
- /**
5
- * Date picker with a calendar dropdown for single dates or date ranges,
6
- * built on react-day-picker. Compose DatePicker.Trigger, DatePicker.Content,
7
- * and DatePicker.Calendar. Supports modes single/range and disabled dates.
8
- */
9
- const meta = {
10
- title: "Forms/DatePicker",
11
- component: DatePicker,
12
- tags: ["autodocs"],
13
- parameters: {
14
- docs: {
15
- description: {
16
- component: "Date picker with calendar dropdown for dates or ranges.",
17
- },
18
- },
19
- },
20
- argTypes: {
21
- mode: {
22
- control: "select",
23
- options: ["single", "range"],
24
- description: "Selection mode",
25
- },
26
- size: {
27
- control: "select",
28
- options: ["sm", "md", "lg"],
29
- description: "Trigger size variant",
30
- },
31
- disabled: { control: "boolean" },
32
- fixedWeeks: { control: "boolean", description: "Always show 6 rows" },
33
- },
34
- args: {
35
- mode: "single",
36
- size: "md",
37
- placeholder: "Pick a date",
38
- children: (
39
- <>
40
- <DatePicker.Trigger />
41
- <DatePicker.Content>
42
- <DatePicker.Calendar />
43
- </DatePicker.Content>
44
- </>
45
- ),
46
- },
47
- } satisfies Meta<typeof DatePicker>;
48
-
49
- export default meta;
50
-
51
- type Story = StoryObj<typeof meta>;
52
-
53
- export const Default: Story = {
54
- render: (args) => (
55
- <DatePicker {...args}>
56
- <DatePicker.Trigger />
57
- <DatePicker.Content>
58
- <DatePicker.Calendar />
59
- </DatePicker.Content>
60
- </DatePicker>
61
- ),
62
- };
63
-
64
- export const Range: Story = {
65
- args: { mode: "range", placeholder: "Select date range", numberOfMonths: 2 },
66
- render: (args) => (
67
- <DatePicker {...args}>
68
- <DatePicker.Trigger />
69
- <DatePicker.Content>
70
- <DatePicker.Calendar />
71
- </DatePicker.Content>
72
- </DatePicker>
73
- ),
74
- };
75
-
76
- export const DisabledDates: Story = {
77
- args: {
78
- placeholder: "Select a future date",
79
- disabledDates: (date: Date) => date < new Date(),
80
- },
81
- render: (args) => (
82
- <DatePicker {...args}>
83
- <DatePicker.Trigger />
84
- <DatePicker.Content>
85
- <DatePicker.Calendar />
86
- </DatePicker.Content>
87
- </DatePicker>
88
- ),
89
- };
90
-
91
- export const WithLabel: Story = {
92
- args: {
93
- label: "Start Date",
94
- placeholder: "Pick a date",
95
- helperText: "Choose when the project begins.",
96
- },
97
- render: (args) => (
98
- <DatePicker {...args}>
99
- <DatePicker.Trigger />
100
- <DatePicker.Content>
101
- <DatePicker.Calendar />
102
- </DatePicker.Content>
103
- </DatePicker>
104
- ),
105
- };
106
-
107
- export const ErrorState: Story = {
108
- args: { label: "Start Date", placeholder: "Pick a date" },
109
- render: (args) => (
110
- <DatePicker {...args} error="Please select a start date">
111
- <DatePicker.Trigger />
112
- <DatePicker.Content>
113
- <DatePicker.Calendar />
114
- </DatePicker.Content>
115
- </DatePicker>
116
- ),
117
- };
118
-
119
- export const Disabled: Story = {
120
- args: { placeholder: "Pick a date", disabled: true },
121
- render: (args) => (
122
- <DatePicker {...args}>
123
- <DatePicker.Trigger />
124
- <DatePicker.Content>
125
- <DatePicker.Calendar />
126
- </DatePicker.Content>
127
- </DatePicker>
128
- ),
129
- };