Skip to content

Commit

Permalink
Merge pull request #190 from Enterwell/stage
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
AleksandarDev authored Nov 27, 2023
2 parents 7c53a7b + f2f7c93 commit a9b0cc5
Show file tree
Hide file tree
Showing 20 changed files with 702 additions and 516 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/npm-publish-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ jobs:
publish:
name: Publish ${{ inputs.name }}
runs-on: ubuntu-latest
concurrency: ci-${{ github.ref }}
concurrency: ci-${{ github.ref }}-${{ inputs.name }}
steps:
# Ensuring that only one PR-environment-creation per branch will run at a time
- name: Mutex setup
uses: ben-z/[email protected]
with:
branch: "mutex/${{ github.event.workflow_run.head_branch }}-publish"
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/[email protected]
Expand All @@ -30,15 +35,14 @@ jobs:
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git pull
- name: Changelog
id: version-bump
uses: Enterwell/ChangelogManager-GitHub-Action@v3
with:
changelog-location: ./packages/${{ inputs.name }}
should-bump-version: true
changes-location: ./packages/${{ inputs.name }}/changes
path-to-project-file: ./packages/${{ inputs.name }}/package.json
path-to-project-file: ./packages/${{ inputs.name }}/package.json\
- name: Commit changelog changes
uses: EndBug/[email protected]
with:
Expand Down
40 changes: 40 additions & 0 deletions apps/docs/components/ExampleSelectManageable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Select, type SelectItem } from '@enterwell/react-ui';
import { Add, Edit } from '@mui/icons-material';
import { Button, IconButton, Typography } from '@mui/material';
import { Stack, Box } from '@mui/system';
import { useState } from 'react';

export function ExampleSelectManageable() {
const [value, setValue] = useState<SelectItem[]>([]);

return (
<Box sx={{ width: 400 }}>
{/* // @highlight-start */}
<Select
value={value}
onChange={(_, value) => setValue(value)}
options={[
{ value: '1', label: 'One' },
{ value: '2', label: 'Two' },
{ value: '3', label: 'Three' },
{ value: '4', label: 'Four' },
]}
displayOption={(option) => (
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{width: '100%'}} spacing={1}>
<Typography>{option.label}</Typography>
<IconButton size="small">
<Edit fontSize='small' />
</IconButton>
</Stack>
)}
listEndDecorator={(
<Button startIcon={<Add />} fullWidth>
Add
</Button>
)}
fullWidth
/>
{/* // @highlight-end */}
</Box>
)
}
22 changes: 11 additions & 11 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@
"@enterwell/react-ui": "workspace:*",
"@mdx-js/mdx": "3.0.0",
"@mdx-js/react": "3.0.0",
"@mui/icons-material": "5.14.16",
"@mui/lab": "5.0.0-alpha.152",
"@mui/material": "5.14.17",
"@mui/system": "5.14.17",
"@mui/x-data-grid": "6.17.0",
"@mui/x-data-grid-pro": "6.17.0",
"@mui/icons-material": "5.14.18",
"@mui/lab": "5.0.0-alpha.153",
"@mui/material": "5.14.18",
"@mui/system": "5.14.18",
"@mui/x-data-grid": "6.18.2",
"@mui/x-data-grid-pro": "6.18.2",
"@mui/x-date-pickers": "5.0.20",
"@mui/x-date-pickers-pro": "5.0.20",
"classix": "2.1.35",
"comment-parser": "1.4.1",
"next": "14.0.1",
"next": "14.0.3",
"nextra": "2.13.2",
"nextra-theme-docs": "2.13.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss-animate": "1.0.7"
},
"devDependencies": {
"@types/node": "18.18.8",
"@types/react": "18.2.36",
"@types/react-dom": "18.2.14",
"@types/node": "18.18.13",
"@types/react": "18.2.38",
"@types/react-dom": "18.2.17",
"autoprefixer": "10.4.16",
"postcss": "8.4.31",
"tailwindcss": "3.3.5",
"typescript": "5.2.2",
"typescript": "5.3.2",
"unist-builder": "4.0.0",
"unist-util-visit": "5.0.0"
}
Expand Down
5 changes: 5 additions & 0 deletions apps/docs/pages/react-ui/components/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Select } from '@enterwell/react-ui';
import { ComponentWithSource } from '../../../components/docs/ComponentWithSource.tsx';
import { ExampleSelect } from '../../../components/ExampleSelect.tsx';
import { ExampleSelectWithPagination } from '../../../components/ExampleSelectWithPagination.tsx';
import { ExampleSelectManageable } from '../../../components/ExampleSelectManageable.tsx';
import { ComponentDescription, ComponentParameters, ComponentSource } from '../../../components/docs/ComponentDocs';

# Select
Expand All @@ -28,6 +29,10 @@ import { ComponentDescription, ComponentParameters, ComponentSource } from '../.

<ComponentWithSource component={ ExampleSelectWithPagination } centered />

### As manageable

<ComponentWithSource component={ ExampleSelectManageable } centered />

## Inspect

<details>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"lint": "turbo run lint"
},
"devDependencies": {
"eslint": "8.53.0",
"eslint": "8.54.0",
"tsconfig": "workspace:*",
"turbo": "1.10.16",
"@turbo/gen": "1.10.16"
},
"packageManager": "pnpm@8.10.2",
"packageManager": "pnpm@8.11.0",
"name": "ui"
}
2 changes: 1 addition & 1 deletion packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"private": true,
"devDependencies": {
"@vercel/style-guide": "5.0.1",
"@vercel/style-guide": "5.1.0",
"eslint-config-turbo": "1.10.16"
}
}
Empty file.
20 changes: 10 additions & 10 deletions packages/react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
},
"license": "MIT",
"scripts": {
"dev:js": "tsup index.ts --watch --format esm --dts --outDir dist",
"dev:js": "tsup index.ts --format esm --dts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"before-build:clean": "rimraf dist",
"build:js": "tsup index.ts --format esm --dts --outDir dist",
"build:js": "tsup index.ts --format esm --dts",
"after-build:api": "api-extractor run && node ./scripts/transform-api-docs.js",
"build": "pnpm run \"/^before-build:.*/\" && pnpm run \"/^build:.*/\" && pnpm run \"/^after-build:.*/\"",
"lint": "eslint ."
},
"devDependencies": {
"@microsoft/api-extractor": "7.38.2",
"@types/node": "18.18.8",
"@types/react": "18.2.36",
"@types/react-dom": "18.2.14",
"@microsoft/api-extractor": "7.38.3",
"@types/node": "18.18.13",
"@types/react": "18.2.38",
"@types/react-dom": "18.2.17",
"eslint-config-custom": "workspace:*",
"react": "18.2.0",
"rimraf": "5.0.5",
"tsconfig": "workspace:*",
"tsup": "7.2.0",
"typescript": "5.2.2"
"tsup": "8.0.1",
"typescript": "5.3.2"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18",
"react-dom": "^18"
}
}
Empty file.
32 changes: 16 additions & 16 deletions packages/react-mui-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@
},
"license": "MIT",
"scripts": {
"dev:js": "tsup index.ts --watch --format esm --dts --outDir dist",
"dev:js": "tsup index.ts --format esm --dts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"before-build:clean": "rimraf dist",
"build:js": "tsup index.ts --format esm --dts --outDir dist",
"build:js": "tsup index.ts --format esm --dts",
"after-build:api": "api-extractor run && node ./scripts/transform-api-docs.js",
"build": "pnpm run \"/^before-build:.*/\" && pnpm run \"/^build:.*/\" && pnpm run \"/^after-build:.*/\"",
"lint": "eslint ."
},
"devDependencies": {
"@enterwell/react-hooks": "workspace:*",
"@enterwell/react-ui": "workspace:*",
"@microsoft/api-extractor": "7.38.2",
"@mui/material": "5.14.17",
"@mui/x-data-grid": "6.17.0",
"@mui/x-data-grid-pro": "6.17.0",
"@types/node": "18.18.8",
"@types/react": "18.2.36",
"@types/react-dom": "18.2.14",
"@microsoft/api-extractor": "7.38.3",
"@mui/material": "5.14.18",
"@mui/x-data-grid": "6.18.2",
"@mui/x-data-grid-pro": "6.18.2",
"@types/node": "18.18.13",
"@types/react": "18.2.38",
"@types/react-dom": "18.2.17",
"date-fns": "2.30.0",
"eslint-config-custom": "workspace:*",
"react": "18.2.0",
"rimraf": "5.0.5",
"tsconfig": "workspace:*",
"tsup": "7.2.0",
"typescript": "5.2.2"
"tsup": "8.0.1",
"typescript": "5.3.2"
},
"peerDependencies": {
"@enterwell/react-ui": "workspace:*",
"@mui/material": "5.14.17",
"@mui/x-data-grid": "6.17.0",
"@mui/x-data-grid-pro": "6.17.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@mui/material": "^5",
"@mui/x-data-grid": "^6",
"@mui/x-data-grid-pro": "^6",
"react": "^18",
"react-dom": "^18"
}
}
13 changes: 6 additions & 7 deletions packages/react-ui/ConfirmDialog/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
Button,
Typography,
type DialogProps,
type ButtonProps,
} from '@mui/material';
import { Stack } from '@mui/system';
import { ComponentProps } from 'react';

/**
* The confirm dialog props type.
Expand All @@ -17,7 +17,7 @@ export type ConfirmDialogProps = Omit<DialogProps, "open" | "onClose" | "color">
isOpen: boolean;
header: string;
message?: string;
color?: ComponentProps<typeof Button>['color'];
color?: ButtonProps["color"];
confirmButtonText?: string;
cancelButtonText?: string;
onConfirm: () => void;
Expand All @@ -36,7 +36,6 @@ export function ConfirmDialog({
header,
message,
maxWidth = "xs",
fullWidth = true,
color = "primary",
confirmButtonText = "Potvrdi",
cancelButtonText = "Odustani",
Expand All @@ -45,11 +44,11 @@ export function ConfirmDialog({
...rest
}: ConfirmDialogProps) {
return (
<Dialog open={isOpen} onClose={onCancel} {...rest}>
<Dialog open={isOpen} onClose={onCancel} maxWidth={maxWidth} {...rest}>
<DialogContent>
<Stack spacing={2}>
<Typography variant="h5" textAlign="center" paddingTop={4} paddingX={3}>{header}</Typography>
{message && <Typography variant="body1" color="textSecondary" textAlign="center" paddingX={3}>{message}</Typography>}
<Stack spacing={2} paddingX={3}>
<Typography variant="h2" textAlign="center" paddingTop={4}>{header}</Typography>
{message && <Typography color="textSecondary" textAlign="center">{message}</Typography>}
</Stack>
</DialogContent>
<DialogActions sx={{ p: 3 }}>
Expand Down
23 changes: 20 additions & 3 deletions packages/react-ui/Select/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect, KeyboardEvent, SyntheticEvent, FocusEvent, ReactNode } from 'react';
import { Autocomplete, TextField, CircularProgress, ChipTypeMap } from '@mui/material';
import { Autocomplete, TextField, CircularProgress, ChipTypeMap, Popper, Paper } from '@mui/material';
import { type AutocompleteProps, createFilterOptions } from '@mui/material/Autocomplete';
import { useDebounce } from '@enterwell/react-hooks';

Expand Down Expand Up @@ -48,7 +48,7 @@ export type SelectProps<
placeholder?: string;
loading?: boolean;
label?: ReactNode;
displayOption?: (option: T) => string;
displayOption?: (option: T) => string | ReactNode;
pageSize?: number;
onPage?: (text: string | null, page: number, pageSize: number) => void;

Expand All @@ -64,6 +64,8 @@ export type SelectProps<
disableFilterOptions?: boolean;
stopPropagationOnKeyCodeSpace?: boolean;
onBlur?: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
listStartDecorator?: ReactNode;
listEndDecorator?: ReactNode;
};

/**
Expand Down Expand Up @@ -95,6 +97,8 @@ export function Select<
disableFilterOptions,
stopPropagationOnKeyCodeSpace,
onBlur,
listStartDecorator,
listEndDecorator,
...rest
}: SelectProps<T, ChipComponent>) {

Expand All @@ -116,7 +120,7 @@ export function Select<
if (!pageSize) {
throw Error("Page size is required when using pagination.");
}

onPage(debouncedText, 0, pageSize);
}
}, [debouncedText]);
Expand Down Expand Up @@ -234,6 +238,19 @@ export function Select<
{displayOption ? displayOption(option) : option.label}
</li>
)}
PopperComponent={({ children, ...rest }) => (
<Popper {...rest} sx={{
'& .MuiAutocomplete-paper': {
boxShadow: 'none'
}
}}>
<Paper>
{listStartDecorator}
{typeof children === 'function' ? children({ placement: rest.placement ?? 'auto' }) : children}
{listEndDecorator}
</Paper>
</Popper>
)}
filterOptions={customFilterOptions}
renderInput={(params) => (
<TextField
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit a9b0cc5

Please sign in to comment.