Skip to content

Commit

Permalink
version 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
morrys committed Mar 18, 2024
1 parent 81400ae commit 5cf4760
Show file tree
Hide file tree
Showing 90 changed files with 2,454 additions and 10,269 deletions.
26 changes: 17 additions & 9 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import i18n from './i18n';
import themeLight from './astrea-theme-light';
import themeDark from './astrea-theme-dark';
import { theme as nsTheme } from '../src/themes/NetServiceTheme';
import { theme as blueChia } from '../src/themes/BlueChia';
import { BlueChiaTheme as blueChia } from '../src/themes/BlueChiaTheme';
import { GoldMinaTheme as goldMina } from '../src/themes/GoldMinaTheme';
import { AstreaTheme as astrea } from '../src/themes/AstreaTheme';
import './styles.scss';

const isDark = typeof window !== `undefined` ? window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches : null;
Expand All @@ -21,8 +23,10 @@ export const globalTypes = {
icon: 'paintbrush',
dynamicTitle: true,
items: [
{ value: 'nsTheme', left: '🌊', title: 'Green NS' },
{ value: 'blueChia', left: '🍃', title: 'Blue Chia' }
{ value: 'nsTheme', left: '🍃', title: 'Green NS' },
{ value: 'blueChia', left: '🌊', title: 'Blue Chia' },
{ value: 'goldMina', left: '🌟', title: 'Gold Mina' },
{ value: 'astrea', left: '🌚', title: 'Astrea' }
],
},
},
Expand All @@ -45,6 +49,8 @@ export const globalTypes = {
const THEMES = {
nsTheme,
blueChia,
goldMina,
astrea
};

// Wrap stories in the I18nextProvider component
Expand Down Expand Up @@ -100,11 +106,9 @@ const preview: Preview = {
'Welcome',
'Styles',
'Components',
'Navigation',
'Form',
'Wrappers',
'Docs',
'Example',
'Patterns',
'Layouts',
'Tools',
],
locales: 'en-US',
},
Expand All @@ -121,7 +125,11 @@ const preview: Preview = {
lightClass: 'light-theme',
stylePreview: true
},
showCode: true,
docs: {
canvas: {
sourceState: 'shown'
}
}
},
globals: {
locale: 'en',
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
Install @netservice/astrea-react-ds using yarn, npm or pnpm:

```
yarn add @netservice/astrea-react-ds
pnpm add @netservice/astrea-react-ds
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netservice/astrea-react-ds",
"version": "1.8.1",
"version": "1.9.0",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/components/Dropdown/NsDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@mui/material';
import HomeIcon from '@mui/icons-material/Home';
import LogoutIcon from '@mui/icons-material/Logout';
import { DynamicLinkProps, IDropDown } from 'src/util/types';
import { DynamicLinkProps, IDropDown } from '../../../util/types';

/**
* DynamicLink/ Dropdown Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useTranslation } from 'react-i18next';
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
import FileUploadIcon from '@mui/icons-material/FileUpload';
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
import { ValidatedSelect } from './form/fields/ValidatedSelect';
import { NsSelect } from './form/fields/NsSelect';
import { required } from './form/validators';

export interface DragDropProps {
export interface NsDragAndDropProps {
value?: File[];
onChange?: (e: any[]) => void;
loadText?: string;
Expand All @@ -28,7 +28,7 @@ export interface DragDropProps {
defaultValue?: any;
}

export function DragDrop({
export function NsDragAndDrop({
value,
onChange,
loadText,
Expand All @@ -37,7 +37,7 @@ export function DragDrop({
validationFile,
displayForm,
onFileLoaded,
}: DragDropProps) {
}: NsDragAndDropProps) {
const theme = useTheme();
const [images, setImages] = React.useState<File[]>(value ?? []);
const [showCarica, setShowCarica] = React.useState<boolean | undefined>(
Expand Down Expand Up @@ -254,7 +254,7 @@ export function DragDrop({
</Box>
<Box sx={{ display: 'flex' }} mt={2}>
{attachmentTypes ? (
<ValidatedSelect
<NsSelect
validate={required}
defaultValue={attachmentTypes[0].codice}
errorMessage={
Expand All @@ -271,7 +271,7 @@ export function DragDrop({
{att.descrizione}
</MenuItem>
))}
</ValidatedSelect>
</NsSelect>
) : (
<></>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useFormState } from 'relay-forms';
import React from 'react';
import { Alert, Box, Stack } from '@mui/material';

export const Errors: React.FC<any> = () => {
export const NsErrors: React.FC<any> = () => {
const { errors, isSubmitting, isValidating } = useFormState();
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ import { Button, Input } from '@mui/material';
import { Box } from '@mui/system';
import { useTranslation } from 'react-i18next';

/**
* File Upload Component
* @author vadim.chilinciuc
*
*/

export interface FileUploadProps {
export interface NsInputFileProps {
value?: File;
onChange?: (e: any) => void;
}

export function FileUpload({ onChange, value }: FileUploadProps) {
export function NsInputFile({ onChange, value }: NsInputFileProps) {
const inputRef = useRef<HTMLInputElement | null>(null);
const [selectedFile, setSelectedFile] = useState<any>(value);
const {t} = useTranslation();
const { t } = useTranslation();
const inputId = useId();

// Function to handle file selection
Expand Down Expand Up @@ -58,9 +52,18 @@ export function FileUpload({ onChange, value }: FileUploadProps) {
ref={inputRef}
/>
<label htmlFor={inputId}>
<Button variant="contained" color="secondary" size="small" component="span">{t('form.fileUpload.selectFile')}</Button>
<Button
variant="contained"
color="secondary"
size="small"
component="span"
>
{t('form.fileUpload.selectFile')}
</Button>
</label>
<Box pl={2} component="span">{value?.name ? value.name : t('form.fileUpload.noFileSelected')} </Box>
<Box pl={2} component="span">
{value?.name ? value.name : t('form.fileUpload.noFileSelected')}{' '}
</Box>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import React from 'react';
import { Box, FormLabel, Typography } from '@mui/material';
import { Box, Typography } from '@mui/material';
import uniqueId from '../../util/uniqueId';

export interface LabelProps {
export interface NsLabelProps {
nameHtml?: string;
label?: React.ReactNode;
}

export const LabelInput: React.FC<React.PropsWithChildren<LabelProps>> = ({
export const NsLabelInput: React.FC<React.PropsWithChildren<NsLabelProps>> = ({
nameHtml,
label,
children,
}) => {
const id = React.useMemo(() => nameHtml || uniqueId('u_label-'), [nameHtml]);
const isRequired = React.Children.toArray(children).some((child) =>
React.isValidElement(child) && child.props.required
const isRequired = React.Children.toArray(children).some(
(child) => React.isValidElement(child) && child.props.required
);

return (
<Box pr={1}>
<Typography component="span" marginBottom={1} style={{ display: 'inline', fontSize: '1.2rem' }}>
<Typography
component="span"
marginBottom={1}
style={{ display: 'inline', fontSize: '1.2rem' }}
>
{isRequired && <span style={{ color: 'red' }}>*</span>}
{label}
</Typography>
Expand Down
Loading

0 comments on commit 5cf4760

Please sign in to comment.