Skip to content

Commit

Permalink
Merge pull request #256 from db-ui/refactor-xo-feedback
Browse files Browse the repository at this point in the history
refactor(xo): optimizations
  • Loading branch information
mfranzke authored Jan 25, 2023
2 parents 0ed9e6d + 505b0d7 commit 3d16970
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 46 deletions.
4 changes: 2 additions & 2 deletions packages/components/plugins/power-apps/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ChildProcess = require('child_process');
const Buff = require('buffer');
const ChildProcess = require('node:child_process');
const Buff = require('node:buffer');

module.exports = () => ({
json: {
Expand Down
10 changes: 5 additions & 5 deletions packages/components/scripts/post-build/copy-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const Fse = require('fs-extra');
const Frameworks = require('./framworks');

module.exports = () => {
[
for (const file of [
'package.json',
'angular.json',
'tsconfig.json',
'ng-package.json',
'vite.config.ts'
].forEach((file) => {
Frameworks.forEach((framework) => {
]) {
for (const framework of Frameworks) {
const resolvedFramework =
framework === 'vue' ? `vue/vue3` : framework;
if (
Expand All @@ -20,6 +20,6 @@ module.exports = () => {
`../../output/${resolvedFramework}/${file}`
);
}
});
});
}
}
};
6 changes: 3 additions & 3 deletions packages/components/scripts/post-build/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = () => {
try {
const cleanName = component.name
.split('-')
.map((part) => `${part[0].toUpperCase()}${part.substring(1)}`)
.map((part) => `${part[0].toUpperCase()}${part.slice(1)}`)
.join('');
const stateName = `DB${cleanName}State`;

Expand All @@ -32,14 +32,14 @@ module.exports = () => {
];
}

replacements.forEach((replacement) => {
for (const replacement of replacements) {
const option = {
files: tsxFile,
from: replacement.from,
to: replacement.to
};
Replace.replaceInFileSync(option);
});
}
} catch (error) {
console.error('Error occurred:', error);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/scripts/post-build/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ module.exports = () => {
];
}

replacements.forEach((replacement) => {
for (const replacement of replacements) {
const option = {
files: vueFile,
from: replacement.from,
to: replacement.to
};
Replace.replaceInFileSync(option);
});
}
} catch (error) {
console.error('Error occurred:', error);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/button/button.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { onMount, Show, useMetadata, useStore } from '@builder.io/mitosis';
import type { DBButtonProps, DBButtonState } from './model';
import { DBIcon } from '../icon';
import type { DBButtonProps, DBButtonState } from './model';

useMetadata({
isAttachedToShadowDom: true,
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/components/button/model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
ClickEventProps,
ClickEventState,
GlobalProps,
GlobalState
type ClickEventProps,
type ClickEventState,
type GlobalProps,
type GlobalState
} from '../../shared/model';

export type DBButtonDefaultProps = {
Expand Down
10 changes: 5 additions & 5 deletions packages/components/src/components/card/model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ClickEventProps,
ClickEventState,
GlobalProps,
GlobalState,
ImageProps
type ClickEventProps,
type ClickEventState,
type GlobalProps,
type GlobalState,
type ImageProps
} from '../../shared/model';

export type DBCardDefaultProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { onMount, Show, useMetadata, useStore } from '@builder.io/mitosis';
import { DBDividerState, DBDividerProps } from './model';
import { type DBDividerState, type DBDividerProps } from './model';

useMetadata({
isAttachedToShadowDom: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/components/divider/model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { GlobalProps, GlobalState } from '../../shared/model';
import { type GlobalProps, type GlobalState } from '../../shared/model';

export interface DBDividerDefaultProps {
export type DBDividerDefaultProps = {
margin?: 'none' | '_';
variant?: 'horizontal' | 'vertical';
}
};

export type DBDividerProps = DBDividerDefaultProps & GlobalProps;

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/icon/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GlobalProps, GlobalState } from '../../shared/model';
import { type GlobalProps, type GlobalState } from '../../shared/model';

export type DBIconDefaultProps = {
icon?: string;
Expand Down
11 changes: 5 additions & 6 deletions packages/components/src/components/input/input.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
useRef,
useStore
} from '@builder.io/mitosis';
import { DBInputState, DBInputProps, iconVariants } from './model';
import { DBIcon } from '../icon';
import { DEFAULT_ID, uuid } from '../../utils';
import { type DBInputState, type DBInputProps, iconVariants } from './model';

useMetadata({
isAttachedToShadowDom: false,
Expand All @@ -29,6 +29,7 @@ export default function DBInput(props: DBInputProps) {
if (props.onChange) {
props.onChange(event);
}

if (props.change) {
props.change(event);
}
Expand All @@ -47,6 +48,7 @@ export default function DBInput(props: DBInputProps) {
if (props.onBlur) {
props.onBlur(event);
}

if (props.blur) {
props.blur(event);
}
Expand All @@ -55,18 +57,15 @@ export default function DBInput(props: DBInputProps) {
if (props.onFocus) {
props.onFocus(event);
}

if (props.focus) {
props.focus(event);
}
}
});

onMount(() => {
if (props.id) {
state.mId = props.id;
} else {
state.mId = 'input-' + uuid();
}
state.mId = props.id ? props.id : 'input-' + uuid();

if (props.value) {
state._value = props.value;
Expand Down
18 changes: 8 additions & 10 deletions packages/components/src/components/input/model.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {
FocusEventProps,
FocusEventState,
GlobalTextProps,
ValidEventProps
} from '../../shared/model';
import {
ChangeEventState,
ChangeEventProps,
GlobalProps,
GlobalState
type FocusEventProps,
type FocusEventState,
type GlobalTextProps,
type ValidEventProps,
type ChangeEventState,
type ChangeEventProps,
type GlobalProps,
type GlobalState
} from '../../shared/model';

export type DBInputDefaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/tab-bar/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DBTabProps } from '../tab/model';
import { GlobalProps, GlobalState } from '../../shared/model';
import { type GlobalProps, type GlobalState } from '../../shared/model';

export type DBTabBarDefaultProps = {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { For, onMount, Show, useMetadata, useStore } from '@builder.io/mitosis';
import type { DBTabBarState, DBTabBarProps } from './model';
import { DBTab } from '../tab';
import type { DBTabProps } from '../tab/model';
import type { DBTabBarState, DBTabBarProps } from './model';

useMetadata({
isAttachedToShadowDom: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/tab/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GlobalProps, GlobalState } from '../../shared/model';
import { type GlobalProps, type GlobalState } from '../../shared/model';

export type DBTabDefaultProps = {
/**
Expand Down

0 comments on commit 3d16970

Please sign in to comment.