@rttui/skin-anocca 1.0.16 → 1.0.17

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 (47) hide show
  1. package/dist/cjs/HeaderPinButtons.cjs +109 -0
  2. package/dist/cjs/HeaderPinButtons.cjs.map +10 -0
  3. package/dist/cjs/RowPinButtons.cjs +75 -0
  4. package/dist/cjs/RowPinButtons.cjs.map +10 -0
  5. package/dist/cjs/index.cjs +383 -0
  6. package/dist/cjs/index.cjs.map +10 -0
  7. package/dist/cjs/package.json +5 -0
  8. package/dist/cjs/stories/ReactTanstackTableUiStory.stories.cjs +234 -0
  9. package/dist/cjs/stories/ReactTanstackTableUiStory.stories.cjs.map +10 -0
  10. package/dist/cjs/stories/ReactTanstackTableUiStoryComponent.cjs +147 -0
  11. package/dist/cjs/stories/ReactTanstackTableUiStoryComponent.cjs.map +10 -0
  12. package/dist/cjs/stories/createSourceCode.cjs +92 -0
  13. package/dist/cjs/stories/createSourceCode.cjs.map +10 -0
  14. package/dist/mjs/HeaderPinButtons.mjs +79 -0
  15. package/dist/mjs/HeaderPinButtons.mjs.map +10 -0
  16. package/dist/mjs/RowPinButtons.mjs +45 -0
  17. package/dist/mjs/RowPinButtons.mjs.map +10 -0
  18. package/dist/mjs/index.mjs +352 -0
  19. package/dist/mjs/index.mjs.map +10 -0
  20. package/dist/mjs/package.json +5 -0
  21. package/dist/mjs/stories/ReactTanstackTableUiStory.stories.mjs +204 -0
  22. package/dist/mjs/stories/ReactTanstackTableUiStory.stories.mjs.map +10 -0
  23. package/dist/mjs/stories/ReactTanstackTableUiStoryComponent.mjs +110 -0
  24. package/dist/mjs/stories/ReactTanstackTableUiStoryComponent.mjs.map +10 -0
  25. package/{src/stories/createSourceCode.ts → dist/mjs/stories/createSourceCode.mjs} +13 -4
  26. package/dist/mjs/stories/createSourceCode.mjs.map +10 -0
  27. package/dist/types/HeaderPinButtons.d.ts +1 -0
  28. package/dist/types/RowPinButtons.d.ts +4 -0
  29. package/dist/types/index.d.ts +3 -0
  30. package/dist/types/stories/ReactTanstackTableUiStory.stories.d.ts +72 -0
  31. package/dist/types/stories/ReactTanstackTableUiStoryComponent.d.ts +15 -0
  32. package/dist/types/stories/createSourceCode.d.ts +5 -0
  33. package/package.json +5 -2
  34. package/.storybook/main.ts +0 -18
  35. package/.storybook/preview.ts +0 -14
  36. package/CHANGELOG.md +0 -126
  37. package/index.html +0 -13
  38. package/src/HeaderPinButtons.tsx +0 -81
  39. package/src/RowPinButtons.tsx +0 -40
  40. package/src/index.tsx +0 -460
  41. package/src/stories/ReactTanstackTableUiStory.mdx +0 -147
  42. package/src/stories/ReactTanstackTableUiStory.stories.tsx +0 -207
  43. package/src/stories/ReactTanstackTableUiStoryComponent.tsx +0 -113
  44. package/src/stories/ScrollbarWidthSpecified.mdx +0 -42
  45. package/tsconfig.json +0 -34
  46. package/tsconfig.types.json +0 -9
  47. package/vite.config.ts +0 -23
@@ -1,207 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
-
3
- import { getCoreRowModel } from "@tanstack/react-table";
4
- import { AnoccaSkin } from "..";
5
- import { ReactTanstackTableUi } from "./ReactTanstackTableUiStoryComponent";
6
- import { createSourceCode } from "./createSourceCode";
7
-
8
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
9
- const meta = {
10
- title: "ReactTanstackTableUi",
11
- component: ReactTanstackTableUi,
12
- parameters: {
13
- // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
14
- layout: "centered",
15
- },
16
- // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
- argTypes: {
18
- data: { control: "select" },
19
- columns: { control: "select" },
20
- pinColsRelativeTo: { control: "select", options: ["cols", "table"] },
21
- skin: {
22
- control: "object",
23
- table: { disable: true },
24
- },
25
- },
26
- // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
27
- args: {
28
- width: 600,
29
- height: 400,
30
- skin: AnoccaSkin,
31
- autoCrushColumns: false,
32
- data: "big",
33
- columns: "few",
34
- getCoreRowModel: getCoreRowModel(),
35
- pinColsRelativeTo: "cols",
36
- fillAvailableSpaceAfterCrush: false,
37
- scrollbarWidth: 16,
38
- getRowId: (row) => row.id,
39
- },
40
- } satisfies Meta<typeof ReactTanstackTableUi>;
41
-
42
- export default meta;
43
- type Story = StoryObj<typeof meta>;
44
-
45
- export const Basic: Story = {
46
- args: {
47
- enableColumnPinning: true,
48
- autoCrushColumns: false,
49
- fillAvailableSpaceAfterCrush: false,
50
- pinColsRelativeTo: "cols",
51
- },
52
- parameters: {
53
- docs: {
54
- source: { language: "tsx", code: createSourceCode() },
55
- },
56
- },
57
- };
58
-
59
- export const AutoCrushColumns: Story = {
60
- args: {
61
- autoCrushColumns: true,
62
- },
63
- parameters: {
64
- docs: {
65
- source: {
66
- language: "tsx",
67
- code: createSourceCode({ props: " autoCrushColumns" }),
68
- },
69
- },
70
- },
71
- };
72
-
73
- export const AutoCrushColumnsExceptName: Story = {
74
- args: {
75
- autoCrushColumns: true,
76
- enableColumnPinning: true,
77
- meta: {
78
- name: {
79
- autoCrush: false,
80
- },
81
- },
82
- },
83
- parameters: {
84
- docs: {
85
- source: {
86
- language: "tsx",
87
- code: createSourceCode({
88
- props: " autoCrushColumns",
89
- nameMeta: " autoCrush: false,",
90
- }),
91
- },
92
- },
93
- },
94
- };
95
-
96
- export const PinRelativeToCols: Story = {
97
- args: {
98
- autoCrushColumns: true,
99
- pinColsRelativeTo: "cols",
100
- enableColumnPinning: true,
101
- initialState: {
102
- columnPinning: {
103
- right: ["city"],
104
- },
105
- },
106
- },
107
- };
108
-
109
- export const PinRelativeToTable: Story = {
110
- args: {
111
- autoCrushColumns: true,
112
- pinColsRelativeTo: "table",
113
- enableColumnPinning: true,
114
- initialState: {
115
- columnPinning: {
116
- right: ["city"],
117
- },
118
- },
119
- },
120
- };
121
-
122
- export const FillAvailableSpaceAfterCrush: Story = {
123
- args: {
124
- autoCrushColumns: true,
125
- fillAvailableSpaceAfterCrush: true,
126
- },
127
- };
128
-
129
- export const FillAvailableSpaceAfterCrushExceptName: Story = {
130
- args: {
131
- autoCrushColumns: true,
132
- fillAvailableSpaceAfterCrush: true,
133
- meta: {
134
- name: {
135
- fillAvailableSpaceAfterCrush: false,
136
- },
137
- },
138
- },
139
- parameters: {
140
- docs: {
141
- source: {
142
- language: "tsx",
143
- code: createSourceCode({
144
- props: " autoCrushColumns\n fillAvailableSpaceAfterCrush",
145
- nameMeta: " fillAvailableSpaceAfterCrush: false,",
146
- }),
147
- },
148
- },
149
- },
150
- };
151
-
152
- export const FillAvailableSpaceAfterCrushWithoutSpecifiedScrollbarWidth: Story =
153
- {
154
- args: {
155
- autoCrushColumns: true,
156
- fillAvailableSpaceAfterCrush: true,
157
- scrollbarWidth: 0,
158
- },
159
- };
160
-
161
- export const CanPinRowsRelativeToRows: Story = {
162
- args: {
163
- enableRowPinning: true,
164
- enableColumnPinning: true,
165
- data: "small",
166
- pinRowsRelativeTo: "rows",
167
- initialState: {
168
- rowPinning: {
169
- bottom: ["3"],
170
- },
171
- },
172
- },
173
- };
174
-
175
- export const CanPinRowsRelativeToTable: Story = {
176
- args: {
177
- enableRowPinning: true,
178
- enableColumnPinning: true,
179
- data: "small",
180
- pinRowsRelativeTo: "table",
181
- initialState: {
182
- rowPinning: {
183
- bottom: ["3"],
184
- },
185
- },
186
- },
187
- };
188
-
189
- export const SizeByLargestHeader: Story = {
190
- args: {
191
- autoCrushColumns: true,
192
- crushMinSizeBy: "cell",
193
- },
194
- };
195
-
196
- export const SizeByLargestHeaderWithMeta: Story = {
197
- args: {
198
- autoCrushColumns: true,
199
- crushMinSizeBy: "header",
200
- enableColumnPinning: true,
201
- meta: {
202
- age: {
203
- crushMinSizeBy: 'cell',
204
- },
205
- },
206
- },
207
- };
@@ -1,113 +0,0 @@
1
- import { Box, ScopedCssBaseline, ThemeProvider, Typography } from "@mui/material";
2
- import { useTheme } from "@mui/material/styles";
3
- import {
4
- decorateColumnHelper,
5
- ReactTanstackTableUi as TableComponent,
6
- } from "@rttui/core";
7
- import {
8
- ColumnDef,
9
- ColumnMeta,
10
- createColumnHelper,
11
- Table,
12
- TableOptions,
13
- useReactTable,
14
- } from "@tanstack/react-table";
15
- import { HeaderPinButtons } from "../HeaderPinButtons";
16
- import React from "react";
17
- import { RowPinButtons } from "../RowPinButtons";
18
- type Person = {
19
- id: string;
20
- name: string;
21
- age: number;
22
- city: string;
23
- } & Record<`col${number}`, string>;
24
-
25
- const smallData: Person[] = [
26
- { id: "1", name: "John", age: 20, city: "New York" },
27
- { id: "2", name: "Jane", age: 21, city: "Los Angeles" },
28
- { id: "3", name: "Jim", age: 22, city: "Chicago" },
29
- ];
30
-
31
- const bigData: Person[] = Array.from({ length: 1000 }, (_, i) => ({
32
- id: i.toString(),
33
- name: `Person ${i}`,
34
- age: 20 + i,
35
- city: `City ${i}`,
36
- ...Object.fromEntries(
37
- Array.from({ length: 100 }, (_, j) => [`col${j}`, `Value ${i}-${j}`]),
38
- ),
39
- }));
40
-
41
- export const ReactTanstackTableUi = (
42
- props: {
43
- data: "big" | "small";
44
- columns: "many" | "few";
45
- meta?: Record<string, ColumnMeta<Person, string>>;
46
- } & Omit<TableOptions<Person>, "data" | "columns"> &
47
- Omit<React.ComponentProps<typeof TableComponent>, "table">,
48
- ) => {
49
- const theme = useTheme();
50
- const data: Person[] = props.data === "big" ? bigData : smallData;
51
-
52
- const columns: ColumnDef<Person>[] = React.useMemo(() => {
53
- const columnHelper = decorateColumnHelper(createColumnHelper<Person>(), {
54
- header: (original) => (
55
- <Box sx={{ display: "flex", gap: 2 }}>
56
- {original}
57
- {props.enableColumnPinning && <HeaderPinButtons />}
58
- </Box>
59
- ),
60
- });
61
-
62
- const fewColumns = [
63
- columnHelper.accessor("name", {
64
- header: "Name",
65
- cell: (info) => (
66
- <Box sx={{ display: "flex", gap: 2, flex: 1 }}>
67
- <Typography variant="body2">{info.getValue()}</Typography>
68
- {props.enableRowPinning && <Box sx={{ flexGrow: 1 }} />}
69
- {props.enableRowPinning && <RowPinButtons row={info.row} />}
70
- </Box>
71
- ),
72
- meta: props.meta?.["name"],
73
- }),
74
- columnHelper.accessor("age", {
75
- header: "Age",
76
- meta: props.meta?.["age"],
77
- cell: (info) => <Typography variant="body2">{info.getValue()}</Typography>,
78
- size: 50,
79
- }),
80
- columnHelper.accessor("city", {
81
- header: "City",
82
- meta: props.meta?.["city"],
83
- cell: (info) => <Typography variant="body2">{info.getValue()}</Typography>,
84
- }),
85
- ];
86
-
87
- const manyColumns = [
88
- ...fewColumns,
89
- ...Array.from({ length: 100 }, (_, i) =>
90
- columnHelper.accessor(`col${i}`, {
91
- header: `Column ${i}`,
92
- cell: (info) => <Typography variant="body2">{info.getValue()}</Typography>,
93
- }),
94
- ),
95
- ];
96
-
97
- return props.columns === "few" ? fewColumns : manyColumns;
98
- }, [props.columns, props.enableColumnPinning, props.enableRowPinning, props.meta]);
99
-
100
- const table = useReactTable({
101
- ...props,
102
- data,
103
- columns,
104
- });
105
-
106
- return (
107
- <ScopedCssBaseline>
108
- <ThemeProvider theme={theme}>
109
- <TableComponent {...props} table={table as Table<unknown>} />
110
- </ThemeProvider>
111
- </ScopedCssBaseline>
112
- );
113
- };
@@ -1,42 +0,0 @@
1
- import { Canvas, Meta, Story, Source, Controls } from '@storybook/blocks';
2
- import { Box } from '@mui/material';
3
-
4
- import * as ColumnPinningStories from './ReactTanstackTableUiStory.stories';
5
-
6
- <Meta of={ColumnPinningStories} />
7
-
8
- # ⚠️ No scrollbar width specified
9
- We get a horizontal scrollbar because we don't specify the width of the vertical scrollbar.
10
- ```tsx
11
- <ReactTanstackTableUi
12
- autoCrushColumns
13
- fillAvailableSpaceAfterCrush
14
- />
15
- ```
16
- <Box sx={{
17
- '*::-webkit-scrollbar': { width: '16px' },
18
- '*::-webkit-scrollbar-track': { backgroundColor: 'yellow' },
19
- '*::-webkit-scrollbar-thumb': { backgroundColor: 'blue' },
20
- }}
21
- >
22
- <Story of={ColumnPinningStories.FillAvailableSpaceAfterCrushWithoutSpecifiedScrollbarWidth} />
23
- </Box>
24
- <br /><br />
25
- # ✅ Scrollbar width specified
26
- We specify the width of the vertical scrollbar and we correctly only see a vertical scrollbar.
27
- ```tsx
28
- <ReactTanstackTableUi
29
- autoCrushColumns
30
- fillAvailableSpaceAfterCrush
31
- scrollbarWidth={16}
32
- />
33
- ```
34
- <Box sx={{
35
- '*::-webkit-scrollbar': { width: '16px' },
36
- '*::-webkit-scrollbar-track': { backgroundColor: 'yellow' },
37
- '*::-webkit-scrollbar-thumb': { backgroundColor: 'blue' },
38
- }}
39
- >
40
- <Story of={ColumnPinningStories.FillAvailableSpaceAfterCrushExceptName} />
41
- </Box>
42
-
package/tsconfig.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "allowJs": true,
4
- "allowSyntheticDefaultImports": true,
5
- "baseUrl": "src",
6
- "target": "ESNext",
7
- "declaration": true,
8
- "esModuleInterop": true,
9
- "inlineSourceMap": false,
10
- "lib": [
11
- "esnext",
12
- "dom"
13
- ],
14
- "listEmittedFiles": false,
15
- "jsx": "react-jsx",
16
- "listFiles": false,
17
- "moduleResolution": "node",
18
- "noFallthroughCasesInSwitch": true,
19
- "pretty": true,
20
- "resolveJsonModule": true,
21
- "rootDir": "src",
22
- "skipLibCheck": true,
23
- "strict": true,
24
- "traceResolution": false
25
- },
26
- "compileOnSave": false,
27
- "exclude": [
28
- "node_modules",
29
- "dist"
30
- ],
31
- "include": [
32
- "src"
33
- ]
34
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "outDir": "dist/types",
6
- "emitDeclarationOnly": true,
7
- "declarationDir": "dist/types"
8
- }
9
- }
package/vite.config.ts DELETED
@@ -1,23 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import react from "@vitejs/plugin-react";
3
- import path from "path";
4
- import fs from "fs";
5
- let base: undefined | string;
6
-
7
- try {
8
- const packageJson = fs.readFileSync(
9
- path.join(__dirname, "package.json"),
10
- "utf-8",
11
- );
12
- const viteBase = JSON.parse(packageJson).viteBase;
13
- if (viteBase) {
14
- base = viteBase;
15
- }
16
- } catch (e) {
17
- // ignore
18
- }
19
-
20
- // https://vite.dev/config/
21
- export default defineConfig({
22
- plugins: [react()],
23
- });