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
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@
"xliff": "^6.2.2"
},
"scripts": {
"assets:test": "cd packages/assets; yarn test",
"assets:fix": "cd packages/assets; yarn fix",
"assets:build": "cd packages/assets; yarn build",
"components:test": "cd packages/components; yarn test",
"components:fix": "cd packages/components; yarn fix",
"components:extract-translations": "cd packages/components; yarn extract-translations",
"components:build": "cd packages/components; yarn build",
"assets:test": "cd packages/assets; yarn test",
"assets:fix": "cd packages/assets; yarn fix",
"assets:build": "cd packages/assets; yarn build",
"packages:test": "yarn components:test && yarn assets:test",
"packages:fix": "yarn components:fix && yarn assets:fix",
"packages:remove-dist": "rm -rf packages/assets/dist && rm -rf packages/components/dist",
"packages:build": "yarn components:build && yarn assets:build",
"core:test": "cd packages/core; yarn test",
"core:fix": "cd packages/core; yarn fix",
"core:build": "cd packages/core; yarn build",
"packages:test": "yarn components:test && yarn assets:test && yarn core:test",
"packages:fix": "yarn components:fix && yarn assets:fix && yarn core:fix",
"packages:remove-dist": "rm -rf packages/assets/dist && rm -rf packages/components/dist && rm -rf packages/core/dist",
"packages:build": "yarn components:build && yarn assets:build && yarn core:build",
"infra:prettier-test": "yarn prettier \"./{.storybook,src,stories}/**/*.{js,ts,jsx,tsx}\" --check",
"infra:prettier-fix": "yarn infra:prettier-test --write",
"infra:eslint-test": "eslint \"./{.storybook,src,stories}/**/*.{js,ts,jsx,tsx}\"",
Expand Down
1 change: 1 addition & 0 deletions packages/components/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{
"root": ["./"],
"alias": {
"@ibexa/ids-core": ["./packages/core/src"],
"@ids-context": "./packages/components/src/context",
"@ids-internal": "./packages/components/src/internal",
"@ids-types": "./types"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useContext, useEffect, useRef, useState } from 'react';
import Expander from '../Expander';
import { TranslatorContext } from '@ids-context/Translator';

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

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

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

import { createCssClassNames } from '../internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

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

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

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

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

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

import Icon from '../Icon';

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

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

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

import BaseButton from '@ids-internal/partials/BaseButton';
import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

import Icon, { IconSizeType } from '../Icon';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/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-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

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

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

import BaseInput from '@ids-internal/partials/BaseInput';
import ClearBtn from '../../ui/ClearBtn';
import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';
import withStateValue from '@ids-internal/hoc/withStateValue';

import { ComponentEntryDataType } from '@ids-types/general';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

import { BaseButtonProps } from './BaseButton.types';

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

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

import { BaseIconProps } from './BaseIcon.types';

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

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';
import { useGenerateSimpleNumberId } from '@ids-internal/hooks/generators';

import { BaseInputProps } from './BaseInput.types';
Expand Down
8 changes: 2 additions & 6 deletions packages/components/src/internal/shared/validators.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import BaseValidator from '../../validators/BaseValidator';

export interface ValidationResult {
isValid: boolean;
messages: string[];
}
import BaseValidator from '@ibexa/ids-core/validators/BaseValidator';
import type { ValidationResult } from '@ibexa/ids-core/types/validation';

export const validateInput = <T>(value: T, validators: BaseValidator<T>[]): ValidationResult => {
const errors = validators.reduce((errorsAcc: string[], validator) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/ui/ClearBtn/ClearBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useContext } from 'react';
import IconButton from '../../IconButton';
import { TranslatorContext } from '@ids-context/Translator';

import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

import { ClearBtnProps } from './ClearBtn.types';

Expand Down
27 changes: 27 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@ibexa/ids-core",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"cross-env": "^7.0.3"
},
"scripts": {
"prettier:test": "yarn prettier \"./scripts/*.js\" \"./src/**/*.{js,ts}\" --check",
"prettier:fix": "yarn prettier:test --write",
"eslint:test": "yarn eslint \"./scripts/*.js\" \"./src/**/*.{js,ts}\"",
"eslint:fix": "yarn eslint:test --fix",
"ts:test": "yarn tsc --noEmit",
"test": "yarn prettier:test && yarn eslint:test && yarn ts:test",
"fix": "yarn prettier:fix && yarn eslint:fix",
"generate-exports": "node ./scripts/generate_exports.js",
"build:clear": "rm -rf dist/*",
"build:js": "yarn tsc",
"build": "yarn build:clear && yarn build:js && yarn generate-exports"
},
"exports": {
"./helpers/*": "./src/helpers/*",
"./types/*": "./src/types/*",
"./validators/*": "./src/validators/*"
}
}
20 changes: 20 additions & 0 deletions packages/core/scripts/generate_exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');
const path = require('path');

const packageJsonPath = path.resolve(__dirname, '../package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

if (!packageJson.exports) {
console.error('No exports field found in package.json'); // eslint-disable-line no-console
process.exit(1);
}

Object.entries(packageJson.exports).forEach(([key, value]) => {
const distPath = value.replace('./src/', './dist/');

packageJson.exports[key] = distPath;
});

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));

console.log('Updated package.json with exports field.'); // eslint-disable-line no-console
5 changes: 5 additions & 0 deletions packages/core/src/types/translator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type TranslatorFunction = (translationKey: string, parameters?: Record<string, string>) => string;

export interface TranslatorType {
trans: TranslatorFunction;
}
4 changes: 4 additions & 0 deletions packages/core/src/types/validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ValidationResult {
isValid: boolean;
messages: string[];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TranslatorType } from '@ids-context/Translator';
import { TranslatorType } from '../types/translator';

export default abstract class BaseValidator<T> {
protected _translator: TranslatorType;
Expand Down
8 changes: 8 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"include": ["src/*.ts", "src/**/*.ts"],
"compilerOptions": {
"declaration": true,
"outDir": "dist"
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"./node_modules/@types"
],
"paths": {
"@ibexa/ids-core/*": ["./packages/core/src/*"],
"@ids-context/*": ["./packages/components/src/context/*"],
"@ids-internal/*": ["./packages/components/src/internal/*"],
"@ids-types/*": ["./types/*"]
Expand Down