Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circular dependency and remove absolute imports #135

Merged
merged 3 commits into from
Feb 12, 2021
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- run: echo "always-auth=true" >> ~/.npmrc
- run: yarn
- run: yarn lint
- run: yarn check-circular
# - run: yarn test-once
- run: yarn build
- run: bash ./publish.sh
Expand Down
32 changes: 16 additions & 16 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
module.exports = {
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.tsx'],
addons: [
'@storybook/addon-docs',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-a11y',
'@storybook/addon-storysource',
'storybook-dark-mode/register',
'@storybook/addon-knobs/register', // Keep until we migrate all to addon-controls
'@storybook/addon-controls',
'@storybook/addon-docs',
'@storybook/preset-scss',
],
webpackFinal: async (config) => {
config.module.rules.push(
{
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('ts-loader'),
},
],
},
{
test: /\.md$/,
use: [
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('ts-loader'),
},
],
},
{
test: /\.md$/,
use: [
{
loader: "markdown-loader",
}
]
}
);
loader: 'markdown-loader',
},
],
}
);
config.resolve.extensions.push('.ts', '.tsx');
return config;
},
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"storybook-docs": "start-storybook --docs",
"build-storybook": "build-storybook -c .storybook -o dist/storybook",
"test": "jest --watchAll",
"test-once": "jest"
"test-once": "jest",
"check-circular": "madge --circular --extensions ts,tsx ./"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down Expand Up @@ -91,6 +92,7 @@
"eslint-plugin-react-hooks": "^2.5.1",
"html-react-parser": "^0.14.0",
"jest": "^26.0.1",
"madge": "^4.0.0",
"markdown-loader": "^6.0.0",
"prettier": "^2.2.1",
"react": "^16.13.1",
Expand All @@ -104,4 +106,4 @@
"typescript": "^3.9.3",
"yarn-deduplicate": "^3.1.0"
}
}
}
2 changes: 1 addition & 1 deletion src/components/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type DropdownState<T> = {
displayArrowIndicator?: boolean;
};

class Dropdown<T = LabelValue> extends React.Component<
export class Dropdown<T = LabelValue> extends React.Component<
DropdownProps<T>,
DropdownState<T>
> {
Expand Down
2 changes: 1 addition & 1 deletion src/components/dropdown/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Dropdown from './Dropdown';
export * from './interfaces';
export {Dropdown};
export * from './Dropdown';

export default Dropdown;
2 changes: 1 addition & 1 deletion src/components/input/TextComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styled from 'styled-components';
import * as PropTypes from 'prop-types';
import Icon from '../icon';
import Tooltip from '../tooltip';
import { HasValidationProps } from 'components/validation/interfaces';
import { HasValidationProps } from '../validation/interfaces';

enum Types {
TEXTAREA = 'TextArea',
Expand Down
18 changes: 7 additions & 11 deletions src/components/time-picker/TimePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Dropdown } from '../dropdown';
import { HasValidationProps } from '../validation/interfaces';
import * as PropTypes from 'prop-types';
import { useState, useEffect, useMemo } from 'react';
import * as React from 'react';
import { Dropdown } from '../index';
import { HasValidationProps } from 'components/validation/interfaces';

import { useEffect, useMemo, useState } from 'react';
import { Keys } from '../common/keyUtils';

import { ErrorMessages } from '../validation/interfaces';
import { DisabledTime } from './interfaces';
import {
FIELD,
formatTimeISO,
formatISOTimeToSeconds,
formatISOTimeToSeconds, formatTimeISO,
getFormattedTime,
getISOTimeFromLocalTime,
getOptions,
Expand All @@ -20,12 +19,9 @@ import {
isTimeDisabled,
isTimeSelected,
isTimeValid,
Time,
Time
} from './utils';

import { DisabledTime } from './interfaces';
import { ErrorMessages } from '../validation/interfaces';

enum STEP {
MIN_STEP_VALUE = 600,
MAX_STEP_VALUE = 43200,
Expand Down
1 change: 0 additions & 1 deletion src/components/time-picker/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ import Time from './Time';

export { Time };
export * from './timeUtils';
export * from './matchTimeUtils';
24 changes: 0 additions & 24 deletions src/components/time-picker/utils/matchTimeUtils.tsx

This file was deleted.

24 changes: 22 additions & 2 deletions src/components/time-picker/utils/timeUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Keys } from '../../common/keyUtils';

import { format as formatTime, parse as parseTime, isValid } from 'date-fns';

import { matchExactTime, matchTimeInRange } from './matchTimeUtils';

import Time from './Time';
import { DropdownOption } from '../../dropdown';
import { DisabledTime } from '../interfaces';
Expand Down Expand Up @@ -410,3 +408,25 @@ export const getTimeFromString = (inputTime: string): Time => {
result.groups.ampm
);
};

/**
* Return true if the time is equal to the time in the matcher
* @param time Time {hours, minutes, seconds}
* @param matcher Object {time: 'HH:mm:ss'}
*/
export function matchExactTime(time: Time, matcher): boolean {
if (time === null || !('time' in matcher)) return false;
return formatTimeISO(time) === matcher.time;
}

/**
* Returns true if the range contains the time
* @param time Time {hours, minutes, seconds}
* @param matcher Object {from: 'HH:mm:ss', to: 'HH:mm:ss'}
*/
export function matchTimeInRange(time: Time, matcher): boolean {
if (time === null || !('from' in matcher) || !('to' in matcher)) return false;
return (
matcher.from <= formatTimeISO(time) && formatTimeISO(time) <= matcher.to
);
}
6 changes: 3 additions & 3 deletions stories/TimePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import {TimePicker} from '../src/components';
import './styles/dropdownMenu.stories.css';
import { Button, Validation } from '../src';
import { useState } from 'react';
import { Button, Validation } from '../src';
import { TimePicker } from '../src/components';
import './styles/dropdownMenu.stories.css';

const logChange = (value, errorsMap) => {
if (!value) {
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"strict": true,
"jsx": "react",
"rootDirs": [
"src",
"stories"
],
"baseUrl": "src",
"esModuleInterop": true,
"noImplicitAny": false,
"strictNullChecks": false,
Expand Down
Loading