Skip to content
Merged
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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "@ibexa/design-system",
"version": "1.0.0",
"main": "index.js",
"repository": "[email protected]:GrabowskiM/design-system.git",
"author": "Michał Grabowski <[email protected]>",
"repository": "[email protected]:ibexa/design-system.git",
"license": "MIT",
"private": true,
"type": "module",
Expand Down
17 changes: 7 additions & 10 deletions packages/components/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
[
"module-resolver",
{
"root": ["./"],
"root": ["./src"],
"alias": {
"@ids-core": ["./packages/core/src"],
"@ids-components": "./packages/components/src/components",
"@ids-context": "./packages/components/src/context",
"@ids-hoc": "./packages/components/src/hoc",
"@ids-hooks": "./packages/components/src/hooks",
"@ids-partials": "./packages/components/src/partials",
"@ids-shared": "./packages/components/src/shared",
"@ids-sb-decorators": "./src/storybook/decorators",
"@ids-types": "./types"
"@ids-components": "./src/components",
"@ids-context": "./src/context",
"@ids-hoc": "./src/hoc",
"@ids-hooks": "./src/hooks",
"@ids-partials": "./src/partials",
"@ids-shared": "./src/shared"
}
}
]
Expand Down
3 changes: 1 addition & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
"test": "yarn prettier:test && yarn eslint:test && yarn ts:test",
"fix": "yarn prettier:fix && yarn eslint:fix",
"extract-translations": "node ./scripts/extract_translations.js",
"generate-exports": "node ./scripts/generate_exports.js",
"build:clear": "rm -rf dist/* tsconfig.build.tsbuildinfo",
"build:js": "babel src --out-dir dist --delete-dir-on-start --extensions \".js,.ts,.jsx,.tsx\"",
"build:types": "tsc -b tsconfig.build.json",
"build": "yarn build:clear && yarn build:js && yarn build:types && yarn generate-exports",
"build": "yarn build:clear && yarn build:js && yarn build:types",
"watch:js": "babel src --out-dir dist --delete-dir-on-start --extensions \".js,.ts,.jsx,.tsx\" --watch",
"watch:types": "tsc -b tsconfig.build.json --watch",
"watch": "yarn build:clear && (yarn watch:js & yarn watch:types)"
Expand Down
31 changes: 0 additions & 31 deletions packages/components/scripts/generate_exports.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/components/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useRef, useState } from 'react';

import { Expander, ExpanderType } from '@ids-components/Expander';
import { TranslatorContext } from '@ids-context/Translator';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { AccordionProps } from './Accordion.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useRef, useState } from 'react';

import { BaseChoiceInput } from '@ids-partials/BaseChoiceInput';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateChecked from '@ids-hoc/withStateChecked';
import { createCssClassNames } from '@ids-core';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { AltRadioInputProps } from './AltRadioInput.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React, { useCallback } from 'react';
import { AltRadioInput } from '../AltRadioInput';
import { BaseInputsList } from '@ids-partials/BaseInputsList';
import { HelperTextType } from '@ids-components/HelperText';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import { AltRadiosListFieldDirection, AltRadiosListFieldItem, AltRadiosListFieldProps } from './AltRadiosListField.types';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Autosave/Autosave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from 'react';

import { Icon, IconSize } from '@ids-components/Icon';
import { TranslatorContext } from '@ids-context/Translator';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { AutosaveProps, AutosaveStatus } from './Autosave.types';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { BadgeProps, BadgeSize } from './Badge.types';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { Icon, IconSize } from '@ids-components/Icon';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { ButtonProps, ButtonSize, ButtonType } from './Button.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useCallback } from 'react';

import { BaseChoiceInputField } from '@ids-partials/BaseChoiceInputField';
import { CheckboxInput } from '../CheckboxInput';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateChecked from '@ids-hoc/withStateChecked';
import { createCssClassNames } from '@ids-core';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { CheckboxFieldProps } from './CheckboxField.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import { BaseChoiceInput } from '@ids-partials/BaseChoiceInput';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateChecked from '@ids-hoc/withStateChecked';
import { createCssClassNames } from '@ids-core';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { CheckboxInputProps } from './CheckboxInput.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React, { useCallback } from 'react';
import { BaseInputsList } from '@ids-partials/BaseInputsList';
import { CheckboxField } from '../CheckboxField';
import { HelperTextType } from '@ids-components/HelperText';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import {
CheckboxesListFieldAction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { ChoiceInputLabelProps } from './ChoiceInputLabel.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import { BaseDropdown } from '@ids-partials/BaseDropdown';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import { DropdownMultiInputAction, DropdownMultiInputItem, DropdownMultiInputProps } from './DropdownMultiInput.types';
import { CheckboxInput } from '@ids-components/Checkbox';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import { BaseDropdown, ExtraDropdownItemClickParamsType } from '@ids-partials/BaseDropdown';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import { DropdownSingleInputItem, DropdownSingleInputProps } from './DropdownSingleInput.types';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Expander/Expander.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import { Button, ButtonSize, ButtonType } from '@ids-components/Button';
import { Icon, IconSize } from '@ids-components/Icon';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { ExpanderProps, ExpanderType } from './Expander.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { Icon, IconSize } from '@ids-components/Icon';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { HelperTextProps, HelperTextType } from './HelperText.types';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';

import { AssetsContext, AssetsType } from '@ids-context/Assets';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { IconProps, IconSize } from './Icon.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useInitValidators, useValidateInput } from './InputTextField.utils';
import { BaseField } from '@ids-partials/BaseField';
import { HelperTextType } from '@ids-components/HelperText';
import { InputTextInput } from '../InputTextInput';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import { InputTextFieldProps, InputTextFieldValueType } from './InputTextField.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useContext, useEffect, useMemo, useRef, useState } from 'react';

import BaseValidator from '@ids-core/validators/BaseValidator';
import IsEmptyStringValidator from '@ids-core/validators/IsEmptyStringValidator';
import { BaseValidator, IsEmptyStringValidator, type ValidationResult } from '@ids-core';
import { TranslatorContext } from '@ids-context/Translator';
import { ValidationResult } from '@ids-core/types/validation';
import { validateInput } from '@ids-shared/validators';

import { InputTextFieldValueType } from './InputTextField.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useImperativeHandle, useLayoutEffect, useMemo, useRef, useState

import { BaseInput } from '@ids-partials/BaseInput';
import { ClearBtn } from '../../../ui/ClearBtn';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import { InputTextInputProps, InputTextInputSize } from './InputTextInput.types';
import { ComponentEntryDataType } from '@ids-types/general';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export enum InputTextInputSize {
Small = 'small',
}

export const INPUT_TYPE_VALUES = ['text', 'password', 'email', 'number', 'tel', 'search', 'url'] as const satisfies BaseInputType[];
export const INPUT_TEXT_TYPE_VALUES = ['text', 'password', 'email', 'number', 'tel', 'search', 'url'] as const satisfies BaseInputType[];

export type InputTextInputType = (typeof INPUT_TYPE_VALUES)[number];
export type InputTextInputType = (typeof INPUT_TEXT_TYPE_VALUES)[number];

export interface InputTextInputRef {
focus: () => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Label/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { LabelProps } from './Label.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useCallback } from 'react';

import { BaseChoiceInputField } from '@ids-partials/BaseChoiceInputField';
import { RadioButtonInput } from '../RadioButtonInput';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateChecked from '@ids-hoc/withStateChecked';
import { createCssClassNames } from '@ids-core';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { RadioButtonFieldProps } from './RadioButtonField.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import { BaseChoiceInput } from '@ids-partials/BaseChoiceInput';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateChecked from '@ids-hoc/withStateChecked';
import { createCssClassNames } from '@ids-core';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { RadioButtonInputProps } from './RadioButtonInput.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import { BaseInputsList } from '@ids-partials/BaseInputsList';
import { HelperTextType } from '@ids-components/HelperText';
import { RadioButtonField } from '../RadioButtonField';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import withStateValue from '@ids-hoc/withStateValue';
import { createCssClassNames } from '@ids-core';
import { withStateValue } from '@ids-hoc/withStateValue';

import { RadioButtonsListFieldDirection, RadioButtonsListFieldItem, RadioButtonsListFieldProps } from './RadioButtonsListField.types';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { Icon, IconSize } from '@ids-components/Icon';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';

import { TagGhostType, TagProps, TagSize, TagType } from './Tag.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { BaseField } from '@ids-partials/BaseField';
import { HelperTextType } from '@ids-components/HelperText';
import { ToggleButtonInput } from '../ToggleButtonInput';
import withStateChecked from '@ids-hoc/withStateChecked';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { ToggleButtonFieldProps } from './ToggleButtonField.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React, { useContext, useRef, useState } from 'react';
import { BaseChoiceInput } from '@ids-partials/BaseChoiceInput';
import { ChoiceInputLabel } from '@ids-components/ChoiceInputLabel';
import { TranslatorContext } from '@ids-context/Translator';
import { createCssClassNames } from '@ids-core/helpers/cssClassNames';
import { createCssClassNames } from '@ids-core';
import { useGetOrCreateId } from '@ids-hooks/generators';
import withStateChecked from '@ids-hoc/withStateChecked';
import { withStateChecked } from '@ids-hoc/withStateChecked';

import { ToggleButtonInputProps, ToggleButtonInputSize } from './ToggleButtonInput.types';

Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/components/ToggleButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './ToggleButtonField';
export * from './ToggleButtonInput';
16 changes: 16 additions & 0 deletions packages/components/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export * from './Accordion';
export * from './AltRadio';
export * from './Autosave';
export * from './Badge';
export * from './Button';
export * from './Checkbox';
export * from './ChoiceInputLabel';
export * from './Dropdown';
export * from './Expander';
export * from './HelperText';
export * from './Icon';
export * from './InputText';
export * from './Label';
export * from './RadioButton';
export * from './Tag';
export * from './ToggleButton';
2 changes: 2 additions & 0 deletions packages/components/src/context/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Assets';
export * from './Translator';
2 changes: 2 additions & 0 deletions packages/components/src/hoc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './withStateChecked';
export * from './withStateValue';
6 changes: 3 additions & 3 deletions packages/components/src/hoc/withStateChecked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ interface BaseProps {
checked: boolean;
}

export type WrappedComponentProps<T extends object> = BaseProps & T;
export type WithStateCheckedWrappedComponentProps<T extends object> = BaseProps & T;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default <T extends object>(WrappedComponent: FC<any>) => {
const WrapperComponent = ({ checked, onChange, ...restProps }: WrappedComponentProps<T>) => {
export const withStateChecked = <T extends object>(WrappedComponent: FC<any>) => {
const WrapperComponent = ({ checked, onChange, ...restProps }: WithStateCheckedWrappedComponentProps<T>) => {
const [componentChecked, setComponentChecked] = useState(checked);

const handleChange = (...args: Parameters<OnChangeFn>): ReturnType<OnChangeFn> => {
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/hoc/withStateValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ interface BaseProps<T> {
value: T;
}

export type WrappedComponentProps<Props, ValueType> = BaseProps<ValueType> & Props;
export type WIthStateValueWrappedComponentProps<Props, ValueType> = BaseProps<ValueType> & Props;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default <Props, ValueType>(WrappedComponent: FC<any>) => {
const WrapperComponent = ({ value, onChange, ...restProps }: WrappedComponentProps<Props, ValueType>) => {
export const withStateValue = <Props, ValueType>(WrappedComponent: FC<any>) => {
const WrapperComponent = ({ value, onChange, ...restProps }: WIthStateValueWrappedComponentProps<Props, ValueType>) => {
const [componentValue, setComponentValue] = useState(value);

const handleChange = (...args: Parameters<OnChangeFn<ValueType>>): ReturnType<OnChangeFn<ValueType>> => {
Expand Down
Loading