Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9c2c99f
initial - type problems fixed
kuzhelov-ms May 5, 2019
7143e10
simplify generic signature of withAs
kuzhelov-ms May 6, 2019
3abe3c4
improve types
kuzhelov-ms May 6, 2019
a4a8212
further restrict types
kuzhelov-ms May 7, 2019
e65eb69
move docblocks to wrapped type
kuzhelov-ms May 7, 2019
755a524
Merge branch 'master' into feat/strict-component-types-alt
kuzhelov May 7, 2019
5658e34
fix prop types
kuzhelov-ms May 7, 2019
5444dd3
fix cra test project's example
kuzhelov-ms May 7, 2019
0da3769
fix example
kuzhelov-ms May 7, 2019
7a861d3
fix ComponentProps example
kuzhelov-ms May 7, 2019
2823156
rename
kuzhelov-ms May 7, 2019
9fef635
fix types for unit tests
kuzhelov-ms May 7, 2019
00d658b
add types tests
kuzhelov-ms May 7, 2019
9f24072
add escape hatch type
kuzhelov-ms May 7, 2019
d3b9630
address docblock issue for Header
kuzhelov-ms May 8, 2019
67a88fe
more explicit interface to define component type
kuzhelov-ms May 8, 2019
73faa9e
rename refactoring
kuzhelov-ms May 8, 2019
067e213
add types for additional portion of components
kuzhelov-ms May 8, 2019
f9a4f44
another batch of typed components
kuzhelov-ms May 8, 2019
04783b2
loose type checks for 'as component' case
kuzhelov-ms May 8, 2019
182c054
add TS logs
kuzhelov-ms May 8, 2019
11a033f
additional debug
kuzhelov-ms May 8, 2019
e768c3f
upd patch
kuzhelov-ms May 8, 2019
4587636
adjust types
kuzhelov-ms May 8, 2019
40468ff
remove logging
kuzhelov-ms May 8, 2019
f64ade6
return to stable repro
kuzhelov-ms May 9, 2019
8953017
completely loose type checks
kuzhelov-ms May 9, 2019
fbcd62f
restrict types
kuzhelov-ms May 9, 2019
c07919d
further restrict types
kuzhelov-ms May 9, 2019
53e9665
add explicit type
kuzhelov-ms May 9, 2019
c29eb86
disable logging
kuzhelov-ms May 9, 2019
db0d74e
add TODO comments
kuzhelov-ms May 9, 2019
4dbe38f
remove TS logging
kuzhelov-ms May 9, 2019
0d12f07
additional portion of typed components
kuzhelov-ms May 9, 2019
00ac4f4
final portion of type components
kuzhelov-ms May 9, 2019
c79b17d
adjust types
kuzhelov-ms May 9, 2019
5197edd
Merge branch 'master' into feat/strict-component-types-alt
kuzhelov-ms May 9, 2019
b53ac0f
revert prop types changes
kuzhelov-ms May 9, 2019
9a9091c
rename refactoring
kuzhelov-ms May 9, 2019
2940a8c
upd
kuzhelov-ms May 10, 2019
3a6d00f
upd
kuzhelov-ms May 10, 2019
c43efea
update Input types
kuzhelov-ms May 10, 2019
297c48a
simplify scaffolding file of cra test
kuzhelov-ms May 10, 2019
a492f06
update types for Provider and ProviderBox
kuzhelov-ms May 10, 2019
8afe103
revert changes in ComponentProps
kuzhelov-ms May 10, 2019
5d36b5e
remove prop types from logo
kuzhelov-ms May 10, 2019
6290b0e
fix import
kuzhelov-ms May 10, 2019
b80149c
revert ComponentExample changes, add 'variables' to Provider props
kuzhelov-ms May 13, 2019
66a5a9b
pass variables explicitly
kuzhelov-ms May 13, 2019
abd600c
fix ProviderBox types
kuzhelov-ms May 13, 2019
9a5f40b
fix imports
kuzhelov-ms May 13, 2019
1bee2a0
merge master
kuzhelov-ms May 13, 2019
fca4710
update changelog
kuzhelov-ms May 13, 2019
cf7c415
upd
kuzhelov-ms May 13, 2019
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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### BREAKING CHANGES
- Restrict Typescript checks for component props @kuzhelov ([#1290](https://github.com/stardust-ui/react/pull/1290))

<!--------------------------------[ v0.30.0 ]------------------------------- -->
## [v0.30.0](https://github.com/stardust-ui/react/tree/v0.30.0) (2019-05-10)
[Compare changes](https://github.com/stardust-ui/react/compare/v0.29.1...v0.30.0)
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/tasks/test-projects/cra/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class App extends React.Component {
<Icon name="umbrella" circular bordered />
</Animation>
<Attachment header="Document.docx" />
<Avatar src="//placehold.it" />
<Avatar image="//placehold.it" />
<Button content="Click me" />
<Divider />
<Header content="This is " />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ const ComponentControls: React.FC<ComponentControlsProps> = props => {
<Menu
{...rest}
fluid
icon="labeled"
size="tiny"
pills
accessibility={toolbarBehavior}
items={[
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/ComponentDoc/ComponentDoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ComponentDoc extends React.Component<any, any> {
<Flex.Item>
<Header
as="h1"
aria-level="2"
aria-level={2}
content={info.displayName}
variables={{ color: 'black' }}
/>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/ComponentDoc/ComponentDocSee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ComponentDocSee: any = ({ displayName }) => {
<List styles={listStyle}>
{/* Heads up! Still render empty lists to reserve the whitespace */}
<List.Item>
<Header color="grey" content={items.length > 0 ? 'See:' : ' '} size="tiny" />
<Header color="grey" content={items.length > 0 ? 'See:' : ' '} />
</List.Item>
{_.map(items, info => (
<List.Item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE

return (
<Menu
size="small"
primary
underlined
activeIndex={-1}
styles={codeEditorStyle}
Expand All @@ -387,10 +387,7 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
} as React.CSSProperties
}
>
<Menu
size="small"
styles={{ display: 'flex', justifyContent: 'space-between', border: 'none' }}
>
<Menu styles={{ display: 'flex', justifyContent: 'space-between', border: 'none' }}>
{this.renderAPIsMenu()}
{this.renderLanguagesMenu()}
</Menu>
Expand All @@ -408,7 +405,7 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
<SourceRender.Consumer>
{({ error }) =>
error && (
<Segment inverted color="red" size="small">
<Segment inverted color="red">
<pre style={{ whiteSpace: 'pre-wrap' }}>{error.toString()}</pre>
</Segment>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const sidebarStyle = {
type ComponentSidebarProps = {
activePath: string
displayName: string
examplesRef: HTMLElement
onItemClick: (e: React.SyntheticEvent, { examplePath: string }) => void
}

Expand All @@ -38,7 +37,7 @@ class ComponentSidebar extends React.Component<ComponentSidebarProps, any> {
}

render() {
const { activePath, examplesRef, onItemClick } = this.props
const { activePath, onItemClick } = this.props
const { sections } = this.state

const menuItems = _.map(sections, ({ examples, sectionName, index }) => ({
Expand All @@ -56,7 +55,7 @@ class ComponentSidebar extends React.Component<ComponentSidebarProps, any> {

// TODO: use a Sticky component instead of position:fixed, when available
return (
<Segment context={examplesRef} styles={{ padding: 0, position: 'fixed' }}>
<Segment styles={{ padding: 0, position: 'fixed' }}>
<Menu fluid vertical items={menuItems} styles={{ ...sidebarStyle }} />
</Segment>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ export default class ComponentSidebarSection extends React.PureComponent<any, an
{...restProps}
styles={treeStyles}
active={active}
onClick={this.handleTitleClick}
>
<span>{content}</span>
{hasSubtree && <Icon direction={name ? 'arrow-down' : 'arrow-end'} />}
{hasSubtree && <Icon name="arrow-down" />}
</Component>
)

return (
<Tree items={items} onTitleClick={this.handleTitleClick} renderItemTitle={titleRenderer} />
)
return <Tree items={items} renderItemTitle={titleRenderer} />
}
}
2 changes: 1 addition & 1 deletion docs/src/components/DocPage/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface DocPageProps {
const DocPage = ({ title, description, children }: DocPageProps) => (
<DocumentTitle title={`Stardust - ${title}`}>
<div style={{ padding: '2rem', fontSize: '1.15rem', maxWidth: '80ch' }}>
<Header as="h1" aria-level="2" content={title} description={description} textAlign="center" />
<Header as="h1" aria-level={2} content={title} description={description} textAlign="center" />
{children}
</div>
</DocumentTitle>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/DocsBehaviorRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DocsBehaviorRoot extends React.Component<any, any> {
<Segment>
<Header
as="h1"
aria-level="2"
aria-level={2}
content={pageTitle}
description={`Keyboard and Screenreader options for ${match.params.name} component.`}
/>
Expand Down
2 changes: 0 additions & 2 deletions docs/src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ import { Image } from '@stardust-ui/react'

const Logo: any = props => <Image {...props} src="logo.png" />

Logo.propTypes = Image.propTypes

export default Logo
2 changes: 1 addition & 1 deletion docs/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ class Sidebar extends React.Component<any, any> {
<Logo width="32px" styles={logoStyles} />
<Text
role="heading"
aria-level="1"
aria-level={1}
color="white"
content="Stardust UI React &nbsp;"
styles={logoStyles}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { useBooleanKnob } from '@stardust-ui/docs-components'
import { ItemLayout, Image } from '@stardust-ui/react'
import * as React from 'react'

const ItemLayoutExampleSelectionShorthand = () => {
const [selection] = useBooleanKnob({ name: 'selection', initialValue: true })

return (
<ItemLayout
selection={selection}
media={<Image src="public/images/avatar/small/matt.jpg" avatar />}
header="Irving Kuhic"
headerMedia="7:26:56 AM"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PortalExamplePortal extends React.Component {
<Divider />
<div>
<Flex gap="gap.small" vAlign="center">
<Button size="small" onClick={this.clearLog} content="Clear" />
<Button onClick={this.clearLog} content="Clear" />
<span>
Event Log <Label circular>{logCount}</Label>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PortalExamplePortal extends React.Component {
<Divider />
<div>
<Flex gap="gap.small" vAlign="center">
<Button size="small" onClick={this.clearLog} content="Clear" />
<Button onClick={this.clearLog} content="Clear" />
<span>
Event Log <Label circular>{logCount}</Label>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PortalExampleControlled extends React.Component {
<Divider />

<Flex gap="gap.small" vAlign="center">
<Button size="small" onClick={this.clearLog} content="Clear" />
<Button onClick={this.clearLog} content="Clear" />
<span>
Event Log <Label circular>{logCount}</Label>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PortalExampleControlled extends React.Component {
<Divider />

<Flex gap="gap.small" vAlign="center">
<Button size="small" onClick={this.clearLog} content="Clear" />
<Button onClick={this.clearLog} content="Clear" />
<span>
Event Log <Label circular>{logCount}</Label>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class PortalExampleFocusTrapped extends React.Component {
Portal doesn't close on outside click. See passed focus trap props.
</p>
<p tabIndex={0}>To close, simply click the close button</p>
<Button size="small" content="Do nothing" />
<Button size="small" content="Close popup" onClick={this.closePortal} />
<Button content="Do nothing" />
<Button content="Close popup" onClick={this.closePortal} />
</div>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class PortalExamplePortal extends React.Component {
<Header>This portal traps focus on appearance</Header>
<p tabIndex={0}>Portal doesn't close on outside click. See passed focus trap props.</p>
<p tabIndex={0}>To close, simply click the close button</p>
<Button size="small" content="Do nothing" />
<Button size="small" content="Close popup" onClick={this.closePortal} />
<Button content="Do nothing" />
<Button content="Close popup" onClick={this.closePortal} />
</div>
</Portal>
</div>
Expand Down
3 changes: 1 addition & 2 deletions docs/src/prototypes/AsyncShorthand/AsyncShorthand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ class CustomChatMessage extends React.Component {
{ key: 'a', icon: 'thumbs up' },
{ key: 'b', icon: 'user' },
{ key: 'c', icon: 'ellipsis horizontal' },
]}
renderItem={this.renderMenuItem}
].map(item => render => render(item, this.renderMenuItem))}
/>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/prototypes/IconViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class IconViewerExample extends React.Component<any, {}> {
/>

<div style={{ marginTop: '15px' }}>
<Menu tabular styles={{ margin: '15px 0' }}>
<Menu styles={{ margin: '15px 0' }}>
{Object.keys(this.iconFilters).map(filterName => (
<Menu.Item
content={filterName}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/prototypes/chatPane/chatPaneContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ChatPaneContainer extends React.PureComponent<ChatPaneContainerProps> {
{this.getMessagePreviewForScreenReader(props)}
</div>
)}
<ElementType {...props} text={undefined} {...maybeAttributesForDivider} />
<ElementType {...props} {...maybeAttributesForDivider} />
</>
),
}}
Expand All @@ -73,7 +73,7 @@ class ChatPaneContainer extends React.PureComponent<ChatPaneContainerProps> {
)
}

private getElementType = (itemType: ChatItemTypes) => {
private getElementType = (itemType: ChatItemTypes): React.ElementType => {
switch (itemType) {
case ChatItemTypes.message:
return Chat.Message
Expand Down
2 changes: 1 addition & 1 deletion docs/src/prototypes/chatPane/composeMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const getMenuItems = (): MenuItemProps[] => {
'aria-label': `${name} tool`,
}))

items.splice(-1, 0, { key: 'separator', styles: { flex: 1 } })
items.splice(-1, 0, { key: 'separator', styles: { flex: 1 } } as any)

return items
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function createMessageContentWithAttachments(content: string, messageId: string)
/>
)

const stopPropagationOnKeys = (keys: number[]) => (e: Event) => {
const stopPropagationOnKeys = (keys: number[]) => (e: React.KeyboardEvent<any>) => {
if (keys.indexOf(keyboardKey.getCode(e)) > -1) {
e.stopPropagation()
}
Expand Down
6 changes: 3 additions & 3 deletions docs/src/views/PageNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Grid, Segment, Header, Icon } from '@stardust-ui/react'
const PageNotFound = () => (
<Grid>
<div>
<Header as="h1" icon textAlign="center">
<Header as="h1" textAlign="center">
<Icon name="game" />
404
<Header.Description>How about some good old Atari?</Header.Description>
</Header>
</div>

<div>
<Segment basic>
<Segment>
<embed
src="http://www.pizn.com/swf/classic-asteroids.swf"
width="425"
Expand All @@ -28,7 +28,7 @@ const PageNotFound = () => (
</Segment>
</div>
<div>
<Segment basic>
<Segment>
<embed
src="http://www.pizn.com/swf/1-space-invaders.swf"
width="425"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/views/QuickStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default () => (
Stardust components are styled using CSS in JS. This technique requires a style renderer to
render JavaScript objects to CSS.{' '}
<a href="https://reactjs.org/docs/context.html" target="_blank" rel="noopener nofollow">
React Context <Icon name="external" size="small" link fitted />
React Context <Icon name="external" size="small" />
</a>{' '}
is used to provide the style renderer and theme to components.
</p>
Expand Down
6 changes: 3 additions & 3 deletions packages/docs-components/src/knobs/useSelectKnob.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { UseKnobOptions } from './types'
import useKnob from './useKnob'

const useSelectKnob = (options: UseKnobOptions<string>) =>
useKnob<string>({
initialValue: '',
const useSelectKnob = <T extends string>(options: UseKnobOptions<T>) =>
useKnob<T>({
initialValue: '' as T,
type: 'select',
...options,
})
Expand Down
19 changes: 10 additions & 9 deletions packages/react/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import { Accessibility } from '../../lib/accessibility/types'

import {
ComponentEventHandler,
ReactProps,
WithAsProp,
ShorthandValue,
ShorthandRenderFunction,
withSafeTypeForAs,
} from '../../types'

export interface AccordionSlotClassNames {
Expand Down Expand Up @@ -75,13 +76,7 @@ export interface AccordionProps extends UIComponentProps, ChildrenComponentProps
accessibility?: Accessibility
}

/**
* An accordion allows users to toggle the display of sections of content.
* @accessibility
* Implements ARIA Accordion design pattern (keyboard navigation not yet supported).
* Consider using Tree if you intend to wrap Lists in an Accordion.
*/
class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any> {
class Accordion extends AutoControlledComponent<WithAsProp<AccordionProps>, any> {
static displayName = 'Accordion'

static className = 'ui-accordion'
Expand Down Expand Up @@ -202,4 +197,10 @@ class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any>
}
}

export default Accordion
/**
* An accordion allows users to toggle the display of sections of content.
* @accessibility
* Implements ARIA Accordion design pattern (keyboard navigation not yet supported).
* Consider using Tree if you intend to wrap Lists in an Accordion.
*/
export default withSafeTypeForAs<typeof Accordion, AccordionProps>(Accordion)
12 changes: 6 additions & 6 deletions packages/react/src/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
commonPropTypes,
rtlTextContainer,
} from '../../lib'
import { ReactProps, ComponentEventHandler } from '../../types'
import { WithAsProp, ComponentEventHandler, withSafeTypeForAs } from '../../types'

export interface AccordionContentProps
extends UIComponentProps,
Expand All @@ -29,10 +29,7 @@ export interface AccordionContentProps
onClick?: ComponentEventHandler<AccordionContentProps>
}

/**
* A standard AccordionContent.
*/
class AccordionContent extends UIComponent<ReactProps<AccordionContentProps>, any> {
class AccordionContent extends UIComponent<WithAsProp<AccordionContentProps>, any> {
static displayName = 'AccordionContent'

static create: Function
Expand Down Expand Up @@ -65,4 +62,7 @@ AccordionContent.create = createShorthandFactory({
mappedProp: 'content',
})

export default AccordionContent
/**
* A standard AccordionContent.
*/
export default withSafeTypeForAs<typeof AccordionContent, AccordionContentProps>(AccordionContent)
Loading