Skip to content

Commit

Permalink
fix: drop module; add typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroslavPetrik committed Dec 2, 2023
1 parent fe39e8e commit c7c1ea4
Show file tree
Hide file tree
Showing 11 changed files with 435 additions and 384 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,38 @@ jobs:
if: ${{!contains(github.event.head_commit.message, '[skip ci]') && !startsWith(github.event.head_commit.message, 'chore:') && !startsWith(github.event.head_commit.message, 'style:') && !startsWith(github.event.head_commit.message, 'docs:') && !contains(github.event.pull_request.title, '[skip ci]') && !startsWith(github.event.pull_request.title, 'chore:') && !startsWith(github.event.pull_request.title, 'style:') && !startsWith(github.event.pull_request.title, 'docs:') && !startsWith(github.event.head_commit.message, 'chore(') && !startsWith(github.event.head_commit.message, 'style(') && !startsWith(github.event.head_commit.message, 'docs(') && !startsWith(github.event.pull_request.title, 'chore(') && !startsWith(github.event.pull_request.title, 'style(') && !startsWith(github.event.pull_request.title, 'docs(') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: 🔃 Checkout
uses: actions/checkout@v4
- run: echo ${{ github.workspace }}

- name: Setup Node.js
- name: 🧫 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/Iron

- name: Cache node_modules
- name: 💾 Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install
- name: 🏗️ Install
uses: borales/actions-yarn@v4
with:
cmd: install

- name: Build
uses: borales/actions-yarn@v4
with:
cmd: build
- name: ✅ Typecheck
run: yarn typecheck

- name: Release
uses: borales/actions-yarn@v4
- name: 🧪 Test
run: yarn test

- name: 🔨 Build
run: yarn build

- name: 🚢 Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
cmd: semantic-release
run: yarn semantic-release
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@form-atoms/flowbite",
"version": "0.0.0-semantic-release",
"type": "module",
"author": "Miroslav Petrik <[email protected]>",
"homepage": "https://github.com/form-atoms/flowbite#readme",
"repository": {
Expand Down Expand Up @@ -31,6 +30,7 @@
],
"scripts": {
"test": "vitest",
"typecheck": "vitest typecheck --passWithNoTests",
"publish": "yarn npm publish --access public",
"build": "tsc --build ./tsconfig.build.json",
"sb": "yarn storybook",
Expand All @@ -43,23 +43,23 @@
},
"devDependencies": {
"@emotion/react": "^11.11.1",
"@form-atoms/field": "^3.8.0",
"@form-atoms/field": "^3.8.4",
"@mdx-js/react": "^2.3.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@storybook/addon-actions": "7.6.0",
"@storybook/addon-docs": "7.6.0",
"@storybook/addon-essentials": "7.6.0",
"@storybook/addon-interactions": "7.6.0",
"@storybook/addon-links": "7.6.0",
"@storybook/builder-vite": "^7.6.0",
"@storybook/addon-actions": "7.6.3",
"@storybook/addon-docs": "7.6.3",
"@storybook/addon-essentials": "7.6.3",
"@storybook/addon-interactions": "7.6.3",
"@storybook/addon-links": "7.6.3",
"@storybook/builder-vite": "^7.6.3",
"@storybook/jest": "0.2.3",
"@storybook/manager-api": "^7.6.0",
"@storybook/react": "7.6.0",
"@storybook/react-vite": "^7.6.0",
"@storybook/manager-api": "^7.6.3",
"@storybook/react": "7.6.3",
"@storybook/react-vite": "^7.6.3",
"@storybook/testing-library": "0.2.2",
"@storybook/theming": "7.6.0",
"@testing-library/jest-dom": "6.1.4",
"@storybook/theming": "7.6.3",
"@testing-library/jest-dom": "6.1.5",
"@testing-library/react": "14.1.2",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.5.1",
Expand All @@ -71,8 +71,8 @@
"@typescript-eslint/parser": "6.13.1",
"@vitejs/plugin-react": "^4.2.0",
"autoprefixer": "10.4.16",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint": "8.55.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "5.0.1",
Expand All @@ -83,14 +83,14 @@
"jotai": "^2.6.0",
"jotai-devtools": "0.7.0",
"jotai-effect": "^0.2.3",
"postcss": "8.4.31",
"postcss": "8.4.32",
"prettier": "^3.1.0",
"prettier-plugin-tailwindcss": "0.5.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.12.0",
"semantic-release": "^22.0.8",
"storybook": "7.6.0",
"storybook": "7.6.3",
"tailwindcss": "^3.3.5",
"typescript": "5.3.2",
"vite-tsconfig-paths": "^4.2.1",
Expand Down Expand Up @@ -129,7 +129,7 @@
]
},
"peerDependencies": {
"@form-atoms/field": "^3.6.0",
"@form-atoms/field": "^3",
"flowbite": "^1.8.1",
"flowbite-react": "^0.7.0"
},
Expand Down
48 changes: 27 additions & 21 deletions src/components/checkbox-group-field/CheckboxGroupField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
} from "@form-atoms/field";
import { Checkbox, HelperText, Label } from "flowbite-react";

import { Option as BaseOption, type OptionRenderProp } from "@/components";

import { Option as BaseOption, type OptionRenderProp } from "../";
import { FlowbiteField } from "../field";

export const CheckboxGroupField = <Option, Field extends ZodArrayField>({
Expand All @@ -22,7 +21,7 @@ export const CheckboxGroupField = <Option, Field extends ZodArrayField>({
...uiProps
}: UseCheckboxGroupProps<Option, Field> &
FieldProps<Field> &
OptionRenderProp) => {
Partial<OptionRenderProp>) => {
const checkboxGroup = useCheckboxGroup({
field,
options,
Expand All @@ -37,24 +36,31 @@ export const CheckboxGroupField = <Option, Field extends ZodArrayField>({
helperText={helperText}
label={label}
>
{({ color, helperText, required: isInputRequired, ...fieldProps }) => {
return (
<>
{checkboxGroup.map((checkboxProps) => (
<Option key={checkboxProps.id}>
<Checkbox
role="checkbox"
{...uiProps}
{...fieldProps}
{...checkboxProps}
/>
<Label htmlFor={checkboxProps.id}>{checkboxProps.label}</Label>
</Option>
))}
{helperText && <HelperText color={color}>{helperText}</HelperText>}
</>
);
}}
{
// eslint-disable-next-line @typescript-eslint/no-unused-vars
({ color, helperText, required: isInputRequired, ...fieldProps }) => {
return (
<>
{checkboxGroup.map((checkboxProps) => (
<Option key={checkboxProps.id}>
<Checkbox
role="checkbox"
{...uiProps}
{...fieldProps}
{...checkboxProps}
/>
<Label htmlFor={checkboxProps.id}>
{checkboxProps.label}
</Label>
</Option>
))}
{helperText && (
<HelperText color={color}>{helperText}</HelperText>
)}
</>
);
}
}
</FlowbiteField>
);
};
3 changes: 1 addition & 2 deletions src/components/field/FlowbiteField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { useAtomValue } from "jotai";
import { ReactNode } from "react";
import { RenderProp } from "react-render-prop-type";

import { RequiredIndicator } from "@/components";

import { RequiredIndicator } from "../";
import { FlowbiteStateColor, useFieldError } from "../../hooks";

type Children = RenderProp<
Expand Down
5 changes: 2 additions & 3 deletions src/components/number-field/NumberField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export const Required: FormStory = {
},
};

const optional = numberField({
optional: true,
});
const optional = numberField().optional();

export const Optional: FormStory = {
...optionalField,
args: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/radio-field/RadioField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Option as BaseOption,
FlowbiteField,
type OptionRenderProp,
} from "@/components";
} from "../";

export const RadioField = <Option, Field extends SelectField>({
field,
Expand Down
3 changes: 1 addition & 2 deletions src/components/radio-option/RadioOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
import { HelperText, Label, Radio } from "flowbite-react";
import { useAtomValue } from "jotai";

import { RequiredIndicator } from "@/components";

import { useFieldError } from "../../hooks";
import { RequiredIndicator } from "../required-indicator";

export const RadioOption = <Field extends CheckboxField>({
field,
Expand Down
2 changes: 1 addition & 1 deletion src/showcase/address-list-field/AddressListField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-icons/hi2";
import { z } from "zod";

import { ListField, TextField } from "@/components";
import { ListField, TextField } from "../../components";

const zipCodeSchema = z.string().regex(/^\d{5}$/);

Expand Down
2 changes: 1 addition & 1 deletion src/showcase/advanced-search/UsageCondition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export const UsageCondition = () => (
getValue={(opt) => opt}
getLabel={(opt) => opt}
Container={Container}
RadioItem={RadioItem}
Option={RadioItem}
/>
);
8 changes: 2 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"types": ["vitest/globals"],
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"types": ["vitest/globals"]
},
"include": ["src", "./.storybook", "./setup.ts"]
"include": ["src", "./setup.ts"]
}
Loading

0 comments on commit c7c1ea4

Please sign in to comment.