Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .babelrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
"project": "./tsconfig.dev.json"
},
"extends": [
"plugin:@typescript-eslint/recommended",
Expand Down
113 changes: 56 additions & 57 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
name: Node.js CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- run: npm run lint
- run: npm run ts
- run: npm run test:unit

e2e-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30


chromatic-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required to retrieve git history
- name: Install dependencies
run: npm ci
- name: Publish to Chromatic
uses: chromaui/action@v1
with:
# Grab this from the Chromatic manage page
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
name: Node.js CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- run: npm run lint
- run: npm run ts
- run: npm run test:unit

e2e-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

chromatic-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required to retrieve git history
- name: Install dependencies
run: npm ci
- name: Publish to Chromatic
uses: chromaui/action@v1
with:
# Grab this from the Chromatic manage page
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
35 changes: 28 additions & 7 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import type { StorybookConfig } from "@storybook/react-webpack5"
import { dirname, join } from "node:path"
import type { StorybookConfig } from "storybook-react-rsbuild"

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")))
}

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions"],
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],

addons: [
"@storybook/addon-links",
{
name: getAbsolutePath("storybook-addon-rslib"),
},
getAbsolutePath("@storybook/addon-docs"),
],

framework: {
name: "@storybook/react-webpack5",
name: getAbsolutePath("storybook-react-rsbuild"),
options: {},
},
docs: {
autodocs: "tag",

typescript: {
reactDocgen: "react-docgen-typescript",
check: true,
},
staticDirs: ["../src/stories/static"],
}

export default config
15 changes: 0 additions & 15 deletions .storybook/preview.ts

This file was deleted.

34 changes: 34 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ChakraProvider, createSystem, defaultConfig } from "@chakra-ui/react"
import { withThemeByClassName } from "@storybook/addon-themes"
import type { Preview } from "@storybook/react"
import { config } from "../src/theme/theme"
import { ThemeProvider } from "next-themes"

const system = createSystem(defaultConfig, config)

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
decorators: [
(Story) => (
<ChakraProvider value={system}>
<ThemeProvider enableSystem attribute="class" disableTransitionOnChange>
<Story />
</ThemeProvider>
</ChakraProvider>
),
withThemeByClassName({
defaultTheme: "light",
themes: { light: "", dark: "dark" },
}),
],
}

export default preview
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ npm i react-spreadsheet-import
Using the component: (it's up to you when the flow is open and what you do on submit with the imported data)

```tsx
import { ReactSpreadsheetImport } from "react-spreadsheet-import";
import { ReactSpreadsheetImport } from "react-spreadsheet-import"

<ReactSpreadsheetImport isOpen={isOpen} onClose={onClose} onSubmit={onSubmit} fields={fields} />
return <ReactSpreadsheetImport isOpen={isOpen} onClose={onClose} onSubmit={onSubmit} fields={fields} />
```

## Required Props
Expand All @@ -55,7 +55,7 @@ import { ReactSpreadsheetImport } from "react-spreadsheet-import";
isOpen: Boolean
// Called when flow is closed without reaching submit.
onClose: () => void
// Called after user completes the flow. Provides data array, where data keys matches your field keys.
// Called after user completes the flow. Provides data array, where data keys matches your field keys.
onSubmit: (data, file) => void | Promise<any>
```

Expand Down Expand Up @@ -128,11 +128,11 @@ Example:

In rare case when you need to skip the beginning of the flow, you can start the flow from any of the steps.

- **initialStepState** - initial state of component that will be rendered on load.
- **initialStepState** - initial state of component that will be rendered on load.

```tsx
initialStepState?: StepState

type StepState =
| {
type: StepType.upload
Expand Down Expand Up @@ -163,19 +163,21 @@ In rare case when you need to skip the beginning of the flow, you can start the
Example:

```tsx
import { ReactSpreadsheetImport, StepType } from "react-spreadsheet-import";

<ReactSpreadsheetImport
initialStepState={{
type: StepType.matchColumns,
data: [
["Josh", "2"],
["Charlie", "3"],
["Lena", "50"],
],
headerValues: ["name", "age"],
}}
/>
import { ReactSpreadsheetImport, StepType } from "react-spreadsheet-import"

return (
<ReactSpreadsheetImport
initialStepState={{
type: StepType.matchColumns,
data: [
["Josh", "2"],
["Charlie", "3"],
["Lena", "50"],
],
headerValues: ["name", "age"],
}}
/>
)
```

### Dates and time
Expand Down
10 changes: 5 additions & 5 deletions e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from '@playwright/test';
import { test } from "@playwright/test"

test('has title', async ({ page }) => {
await page.goto('http://localhost:6006/iframe.html?args=&id=select-header-step--basic&viewMode=story');
test("has title", async ({ page }) => {
await page.goto("http://localhost:6006/iframe.html?args=&id=select-header-step--basic&viewMode=story")

await page.getByRole('row', ).filter({ hasText: 'second' }).click();
});
await page.getByRole("row").filter({ hasText: "second" }).click()
})
Loading