@edvisor/product-language 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -0
- package/index.js +6078 -0
- package/lib/components/alert-banner/alert-banner.d.ts +11 -0
- package/lib/components/alert-banner/alert-level-flags.d.ts +13 -0
- package/lib/components/alert-banner/index.d.ts +1 -0
- package/lib/components/badge/badge-type-flags.d.ts +18 -0
- package/lib/components/badge/badge.d.ts +5 -0
- package/lib/components/badge/index.d.ts +1 -0
- package/{src/lib/components/card/atoms/card-frame.tsx → lib/components/card/atoms/card-frame.d.ts} +7 -17
- package/lib/components/card/atoms/index.d.ts +1 -0
- package/lib/components/card/card.d.ts +14 -0
- package/lib/components/card/components/card-alert-banner-slot.d.ts +5 -0
- package/lib/components/card/components/card-controls-slot.d.ts +4 -0
- package/lib/components/card/components/card-section-slot.d.ts +11 -0
- package/lib/components/card/components/index.d.ts +3 -0
- package/lib/components/card/index.d.ts +2 -0
- package/lib/components/card/molecules/index.d.ts +1 -0
- package/lib/components/card/molecules/left-right-card.d.ts +16 -0
- package/lib/components/checkbox/checkbox.d.ts +11 -0
- package/lib/components/checkbox/components/components.d.ts +12 -0
- package/lib/components/checkbox/index.d.ts +1 -0
- package/lib/components/divider/divider-type-flags.d.ts +9 -0
- package/lib/components/divider/divider.d.ts +7 -0
- package/lib/components/divider/index.d.ts +1 -0
- package/lib/components/index.d.ts +12 -0
- package/lib/components/input-field/components/index.d.ts +2 -0
- package/lib/components/input-field/components/labeled-input.d.ts +11 -0
- package/lib/components/input-field/components/stepper.d.ts +7 -0
- package/lib/components/input-field/index.d.ts +3 -0
- package/lib/components/input-field/input-field.d.ts +25 -0
- package/lib/components/input-field/input-number.d.ts +18 -0
- package/lib/components/input-field/input-text.d.ts +14 -0
- package/lib/components/layout/flex.d.ts +16 -0
- package/lib/components/layout/grid-layout.d.ts +11 -0
- package/lib/components/layout/index.d.ts +3 -0
- package/lib/components/layout/left-right-layout.d.ts +70 -0
- package/lib/components/link/index.d.ts +1 -0
- package/lib/components/link/link.d.ts +14 -0
- package/lib/components/molecules/avatar/avatar-size-flags.d.ts +12 -0
- package/lib/components/molecules/avatar/avatar.d.ts +12 -0
- package/lib/components/molecules/avatar/index.d.ts +1 -0
- package/lib/components/molecules/button/button-flags.d.ts +39 -0
- package/lib/components/molecules/button/button.d.ts +24 -0
- package/lib/components/molecules/button/index.d.ts +1 -0
- package/lib/components/molecules/index.d.ts +3 -0
- package/lib/components/molecules/input-checkbox/index.d.ts +1 -0
- package/lib/components/molecules/input-checkbox/input-checkbox.d.ts +8 -0
- package/lib/components/organisms/index.d.ts +1 -0
- package/lib/components/organisms/multi-choice-list/index.d.ts +1 -0
- package/lib/components/organisms/multi-choice-list/multi-choice-list.d.ts +11 -0
- package/lib/components/spinner/index.d.ts +1 -0
- package/lib/components/spinner/spinner-size-flags.d.ts +10 -0
- package/lib/components/spinner/spinner.d.ts +9 -0
- package/lib/components/thumbnail/index.d.ts +1 -0
- package/lib/components/thumbnail/thumbnail-size-flags.d.ts +10 -0
- package/lib/components/thumbnail/thumbnail.d.ts +9 -0
- package/lib/components/typography/index.d.ts +1 -0
- package/lib/components/typography/typography.d.ts +23 -0
- package/lib/foundations/color-system/base-palette/base-palette.d.ts +77 -0
- package/lib/foundations/color-system/base-palette/index.d.ts +1 -0
- package/lib/foundations/color-system/color-guidelines/color-guidelines.d.ts +131 -0
- package/lib/foundations/color-system/color-guidelines/index.d.ts +1 -0
- package/lib/foundations/color-system/components/color-sample.d.ts +17 -0
- package/lib/foundations/color-system/components/index.d.ts +1 -0
- package/lib/foundations/color-system/index.d.ts +1 -0
- package/lib/foundations/index.d.ts +4 -0
- package/lib/foundations/shadows/components.d.ts +8 -0
- package/lib/foundations/shadows/index.d.ts +1 -0
- package/lib/foundations/shadows/shadows.d.ts +8 -0
- package/lib/foundations/spacing/index.d.ts +1 -0
- package/lib/foundations/spacing/spacing-guidelines.d.ts +22 -0
- package/lib/foundations/spacing/spacing.d.ts +18 -0
- package/lib/foundations/typography/constants.d.ts +22 -0
- package/lib/foundations/typography/index.d.ts +1 -0
- package/lib/foundations/typography/text-aspect-flags.d.ts +14 -0
- package/lib/foundations/typography/typography.d.ts +19 -0
- package/lib/helpers/generic-types.d.ts +21 -0
- package/lib/helpers/index.d.ts +6 -0
- package/lib/helpers/nothing.d.ts +8 -0
- package/{src/lib/helpers/numbers.ts → lib/helpers/numbers.d.ts} +41 -53
- package/lib/helpers/safe-navigation.d.ts +14 -0
- package/lib/helpers/slots.d.ts +8 -0
- package/lib/helpers/strings.d.ts +1 -0
- package/package.json +12 -22
- package/release-it.json +18 -0
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -139
- package/.storybook/main.js +0 -57
- package/.storybook/manager.js +0 -7
- package/.storybook/preview-head.html +0 -1
- package/.storybook/preview.js +0 -15
- package/.storybook/tsconfig.json +0 -30
- package/jest.config.ts +0 -15
- package/jest.setup.ts +0 -2
- package/project.json +0 -75
- package/src/assets/svg/example_icon.svg +0 -3
- package/src/assets/svg/example_icon_white.svg +0 -3
- package/src/assets/svg/spinner.svg +0 -3
- package/src/assets/svg/spinner_white.svg +0 -3
- package/src/helpers/index.ts +0 -3
- package/src/helpers/talesOf.tsx +0 -42
- package/src/index.ts +0 -2
- package/src/lib/components/README.md +0 -49
- package/src/lib/components/alert-banner/alert-banner.tsx +0 -34
- package/src/lib/components/alert-banner/alert-level-flags.ts +0 -77
- package/src/lib/components/alert-banner/index.ts +0 -1
- package/src/lib/components/badge/badge-type-flags.ts +0 -72
- package/src/lib/components/badge/badge.stories.tsx +0 -16
- package/src/lib/components/badge/badge.test.tsx +0 -29
- package/src/lib/components/badge/badge.tsx +0 -31
- package/src/lib/components/badge/index.ts +0 -1
- package/src/lib/components/card/atoms/index.ts +0 -1
- package/src/lib/components/card/card.test.tsx +0 -163
- package/src/lib/components/card/card.tsx +0 -78
- package/src/lib/components/card/components/card-alert-banner-slot.tsx +0 -16
- package/src/lib/components/card/components/card-controls-slot.tsx +0 -19
- package/src/lib/components/card/components/card-section-slot.tsx +0 -51
- package/src/lib/components/card/components/index.ts +0 -3
- package/src/lib/components/card/index.ts +0 -2
- package/src/lib/components/card/molecules/index.ts +0 -1
- package/src/lib/components/card/molecules/left-right-card.test.tsx +0 -89
- package/src/lib/components/card/molecules/left-right-card.tsx +0 -63
- package/src/lib/components/card/storybook/card.stories.mdx +0 -100
- package/src/lib/components/card/storybook/components.tsx +0 -240
- package/src/lib/components/checkbox/checkbox.test.tsx +0 -39
- package/src/lib/components/checkbox/checkbox.tsx +0 -124
- package/src/lib/components/checkbox/components/components.tsx +0 -59
- package/src/lib/components/checkbox/index.tsx +0 -1
- package/src/lib/components/checkbox/stories/checkbox.stories.mdx +0 -54
- package/src/lib/components/checkbox/stories/components.tsx +0 -36
- package/src/lib/components/checkbox/stories/index.tsx +0 -1
- package/src/lib/components/divider/divider-type-flags.tsx +0 -37
- package/src/lib/components/divider/divider.test.tsx +0 -34
- package/src/lib/components/divider/divider.tsx +0 -37
- package/src/lib/components/divider/index.tsx +0 -1
- package/src/lib/components/divider/stories/components.tsx +0 -13
- package/src/lib/components/divider/stories/divider.stories.mdx +0 -50
- package/src/lib/components/index.ts +0 -14
- package/src/lib/components/input-field/components/index.ts +0 -2
- package/src/lib/components/input-field/components/labeled-input.tsx +0 -61
- package/src/lib/components/input-field/components/stepper.tsx +0 -59
- package/src/lib/components/input-field/index.ts +0 -6
- package/src/lib/components/input-field/input-field.test.tsx +0 -108
- package/src/lib/components/input-field/input-field.tsx +0 -126
- package/src/lib/components/input-field/input-number.tsx +0 -41
- package/src/lib/components/input-field/input-text.tsx +0 -30
- package/src/lib/components/input-field/storybook/components.tsx +0 -334
- package/src/lib/components/input-field/storybook/input-field.stories.mdx +0 -113
- package/src/lib/components/layout/flex.tsx +0 -22
- package/src/lib/components/layout/grid-layout.tsx +0 -40
- package/src/lib/components/layout/index.ts +0 -3
- package/src/lib/components/layout/left-right-layout.tsx +0 -67
- package/src/lib/components/link/index.ts +0 -1
- package/src/lib/components/link/link.test.tsx +0 -29
- package/src/lib/components/link/link.tsx +0 -56
- package/src/lib/components/link/storybook/link.stories.mdx +0 -51
- package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +0 -55
- package/src/lib/components/molecules/avatar/avatar.test.tsx +0 -114
- package/src/lib/components/molecules/avatar/avatar.tsx +0 -80
- package/src/lib/components/molecules/avatar/index.tsx +0 -1
- package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +0 -55
- package/src/lib/components/molecules/avatar/stories/components.tsx +0 -36
- package/src/lib/components/molecules/button/button-flags.tsx +0 -235
- package/src/lib/components/molecules/button/button.test.tsx +0 -77
- package/src/lib/components/molecules/button/button.tsx +0 -231
- package/src/lib/components/molecules/button/index.tsx +0 -1
- package/src/lib/components/molecules/button/stories/button.stories.mdx +0 -104
- package/src/lib/components/molecules/button/stories/components.tsx +0 -86
- package/src/lib/components/molecules/index.ts +0 -3
- package/src/lib/components/molecules/input-checkbox/index.tsx +0 -1
- package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +0 -34
- package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +0 -50
- package/src/lib/components/molecules/input-checkbox/stories/components.tsx +0 -36
- package/src/lib/components/molecules/input-checkbox/stories/index.tsx +0 -1
- package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +0 -51
- package/src/lib/components/organisms/index.ts +0 -1
- package/src/lib/components/organisms/multi-choice-list/index.tsx +0 -1
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +0 -33
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +0 -53
- package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +0 -126
- package/src/lib/components/organisms/multi-choice-list/stories/index.tsx +0 -1
- package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +0 -99
- package/src/lib/components/spinner/index.tsx +0 -1
- package/src/lib/components/spinner/spinner-size-flags.tsx +0 -39
- package/src/lib/components/spinner/spinner.test.tsx +0 -31
- package/src/lib/components/spinner/spinner.tsx +0 -67
- package/src/lib/components/spinner/stories/components.tsx +0 -8
- package/src/lib/components/spinner/stories/spinner.stories.mdx +0 -42
- package/src/lib/components/thumbnail/index.tsx +0 -1
- package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +0 -34
- package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +0 -41
- package/src/lib/components/thumbnail/thumbnail.test.tsx +0 -51
- package/src/lib/components/thumbnail/thumbnail.tsx +0 -40
- package/src/lib/components/typography/index.ts +0 -1
- package/src/lib/components/typography/storybook/components.tsx +0 -256
- package/src/lib/components/typography/storybook/typography.stories.mdx +0 -88
- package/src/lib/components/typography/typography.test.tsx +0 -93
- package/src/lib/components/typography/typography.tsx +0 -57
- package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +0 -123
- package/src/lib/foundations/color-system/base-palette/base-palette.ts +0 -94
- package/src/lib/foundations/color-system/base-palette/index.ts +0 -1
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +0 -85
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +0 -231
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +0 -159
- package/src/lib/foundations/color-system/color-guidelines/index.ts +0 -1
- package/src/lib/foundations/color-system/components/color-sample.tsx +0 -99
- package/src/lib/foundations/color-system/components/index.ts +0 -1
- package/src/lib/foundations/color-system/index.ts +0 -1
- package/src/lib/foundations/index.ts +0 -4
- package/src/lib/foundations/shadows/components.tsx +0 -59
- package/src/lib/foundations/shadows/index.ts +0 -1
- package/src/lib/foundations/shadows/shadows.stories.mdx +0 -71
- package/src/lib/foundations/shadows/shadows.tsx +0 -47
- package/src/lib/foundations/spacing/index.ts +0 -1
- package/src/lib/foundations/spacing/spacing-guidelines.ts +0 -24
- package/src/lib/foundations/spacing/spacing.stories.mdx +0 -51
- package/src/lib/foundations/spacing/spacing.ts +0 -18
- package/src/lib/foundations/typography/constants.ts +0 -25
- package/src/lib/foundations/typography/index.tsx +0 -1
- package/src/lib/foundations/typography/text-aspect-flags.ts +0 -54
- package/src/lib/foundations/typography/typography.tsx +0 -97
- package/src/lib/helpers/generic-types.ts +0 -44
- package/src/lib/helpers/index.ts +0 -6
- package/src/lib/helpers/nothing.tsx +0 -18
- package/src/lib/helpers/safe-navigation.ts +0 -34
- package/src/lib/helpers/slots.tsx +0 -76
- package/src/lib/helpers/strings.test.ts +0 -47
- package/src/lib/helpers/strings.ts +0 -16
- package/tsconfig.json +0 -35
- package/tsconfig.lib.json +0 -28
- package/tsconfig.spec.json +0 -21
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
|
|
2
|
-
import { Divider } from '../index'
|
|
3
|
-
import { WrapperStories, AvatarsWithText, AvatarsWithImage, WrapperStoriesWithLabel } from './components'
|
|
4
|
-
|
|
5
|
-
<Meta
|
|
6
|
-
title="Components/Divider"
|
|
7
|
-
component={Divider}
|
|
8
|
-
/>
|
|
9
|
-
|
|
10
|
-
# Divider
|
|
11
|
-
|
|
12
|
-
For more details, check out the component page on [Figma](https://www.figma.com/file/ue1CurHfZ426o2T2l8Dk64/Edvisor-Product-Language?node-id=1194%3A1611)
|
|
13
|
-
|
|
14
|
-
## How to use
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
// Import the component
|
|
18
|
-
import { Divider } from './index'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Render the component sending the parameters
|
|
22
|
-
<Divider default/>
|
|
23
|
-
|
|
24
|
-
//or
|
|
25
|
-
|
|
26
|
-
<Divider subdued/>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Examples
|
|
30
|
-
|
|
31
|
-
Default Divider
|
|
32
|
-
|
|
33
|
-
<Canvas>
|
|
34
|
-
<Story name="default">
|
|
35
|
-
<WrapperStories>
|
|
36
|
-
<Divider default/>
|
|
37
|
-
</WrapperStories>
|
|
38
|
-
</Story>
|
|
39
|
-
</Canvas>
|
|
40
|
-
|
|
41
|
-
Subdued Divider
|
|
42
|
-
|
|
43
|
-
<Canvas>
|
|
44
|
-
<Story name="subdued">
|
|
45
|
-
<WrapperStories>
|
|
46
|
-
<Divider subdued/>
|
|
47
|
-
</WrapperStories>
|
|
48
|
-
</Story>
|
|
49
|
-
</Canvas>
|
|
50
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './alert-banner'
|
|
2
|
-
export * from './badge'
|
|
3
|
-
export * from './card'
|
|
4
|
-
export * from './checkbox'
|
|
5
|
-
export * from './divider'
|
|
6
|
-
export * from './input-field'
|
|
7
|
-
export * from './layout'
|
|
8
|
-
export * from './link'
|
|
9
|
-
export * from './thumbnail'
|
|
10
|
-
export * from './typography'
|
|
11
|
-
|
|
12
|
-
//Adding everything in molecules
|
|
13
|
-
export * from './molecules'
|
|
14
|
-
export * from './organisms'
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
|
|
3
|
-
import { Icons, Margin } from '@foundations'
|
|
4
|
-
import { PropsWithChildren, FC, maybeRender, safeArray } from '@helpers'
|
|
5
|
-
import { Flex } from 'components/layout'
|
|
6
|
-
import { Body, Label1 } from 'components/typography'
|
|
7
|
-
|
|
8
|
-
export const Icon = styled.div`
|
|
9
|
-
height: 16px;
|
|
10
|
-
width: 16px;
|
|
11
|
-
border: 2px solid ${Icons.Default};
|
|
12
|
-
border-radius: 50%;
|
|
13
|
-
margin-right: ${Margin.s};
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
const ErrorIcon = styled(Icon)`
|
|
17
|
-
border: 2px solid ${Icons.Critical};
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
const HTMLLabel = styled.label`
|
|
21
|
-
all: unset;
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
const LabelText = styled(Label1)`
|
|
25
|
-
margin-bottom: ${Margin.xxs};
|
|
26
|
-
`
|
|
27
|
-
|
|
28
|
-
const HelpText = styled(Body)`
|
|
29
|
-
margin-bottom: ${Margin.xxs};
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
const ErrorMessage = styled(Flex)`
|
|
33
|
-
margin-bottom: ${Margin.xxs};
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
interface ILabeledInputProps extends PropsWithChildren {
|
|
37
|
-
label?: string
|
|
38
|
-
helpText?: string
|
|
39
|
-
errors?: { message: string }[]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const LabeledInput: FC<ILabeledInputProps> = (props) => {
|
|
43
|
-
return (
|
|
44
|
-
<HTMLLabel>
|
|
45
|
-
<label>
|
|
46
|
-
{maybeRender(props.label, <LabelText>{props.label}</LabelText>)}
|
|
47
|
-
{props.children}
|
|
48
|
-
</label>
|
|
49
|
-
{safeArray(props.errors).map((e) => (
|
|
50
|
-
<ErrorMessage center key={e.message}>
|
|
51
|
-
<ErrorIcon />
|
|
52
|
-
<Body>{e.message}</Body>
|
|
53
|
-
</ErrorMessage>
|
|
54
|
-
))}
|
|
55
|
-
{maybeRender(
|
|
56
|
-
props.helpText,
|
|
57
|
-
<HelpText subdued>{props.helpText}</HelpText>
|
|
58
|
-
)}
|
|
59
|
-
</HTMLLabel>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Margin, Padding, Surface } from '@foundations'
|
|
2
|
-
import { FC } from '@helpers'
|
|
3
|
-
import { Center } from 'components/layout'
|
|
4
|
-
import styled from 'styled-components'
|
|
5
|
-
|
|
6
|
-
const Controls = styled.div`
|
|
7
|
-
height: 34px;
|
|
8
|
-
width: 26px;
|
|
9
|
-
padding: ${Padding.xxxs} ${Padding.xxxs};
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
const Up = styled(Center)`
|
|
14
|
-
background: ${Surface.Neutral.Default};
|
|
15
|
-
width: 22px;
|
|
16
|
-
height: 14px;
|
|
17
|
-
border-radius: 3px 3px 0px 0px;
|
|
18
|
-
margin-bottom: ${Margin.xxxs};
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
const TriangleUp = styled.div`
|
|
25
|
-
width: 0px;
|
|
26
|
-
height: 0px;
|
|
27
|
-
border-left: 5px solid transparent;
|
|
28
|
-
border-right: 5px solid transparent;
|
|
29
|
-
border-bottom: 5px solid black;
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
const TriangleDown = styled.div`
|
|
33
|
-
width: 0px;
|
|
34
|
-
height: 0px;
|
|
35
|
-
border-left: 5px solid transparent;
|
|
36
|
-
border-right: 5px solid transparent;
|
|
37
|
-
border-top: 5px solid black;
|
|
38
|
-
`
|
|
39
|
-
|
|
40
|
-
const Down = styled(Center)`
|
|
41
|
-
background: ${Surface.Neutral.Default};
|
|
42
|
-
width: 22px;
|
|
43
|
-
height: 14px;
|
|
44
|
-
border-radius: 0px 0px 3px 3px;
|
|
45
|
-
`
|
|
46
|
-
|
|
47
|
-
interface IStepperProps {
|
|
48
|
-
onUpClick?: () => void
|
|
49
|
-
onDownClick?: () => void
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const Stepper: FC<IStepperProps> = (props: IStepperProps) => {
|
|
53
|
-
return (
|
|
54
|
-
<Controls>
|
|
55
|
-
<Up onClick={props.onUpClick}><TriangleUp /></Up>
|
|
56
|
-
<Down onClick={props.onDownClick}><TriangleDown /></Down>
|
|
57
|
-
</Controls>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {fireEvent, render, screen } from '@testing-library/react'
|
|
2
|
-
import { InputField } from './index'
|
|
3
|
-
|
|
4
|
-
describe('InputField', () => {
|
|
5
|
-
describe('the inner input element', () => {
|
|
6
|
-
it('should receive nice html props', async () => {
|
|
7
|
-
render(
|
|
8
|
-
<InputField
|
|
9
|
-
value="value"
|
|
10
|
-
onChange={() => undefined}
|
|
11
|
-
type="text"
|
|
12
|
-
label="Label"
|
|
13
|
-
placeholder="placeholder"
|
|
14
|
-
/>
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
expect(screen.getByRole('textbox')).toBeInTheDocument()
|
|
18
|
-
expect(screen.getByPlaceholderText('placeholder')).toBeInTheDocument()
|
|
19
|
-
expect(screen.getByDisplayValue('value')).toBeInTheDocument()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should call the onChange callback on change events', async () => {
|
|
23
|
-
const handleChange = jest.fn()
|
|
24
|
-
|
|
25
|
-
render(<InputField value="value" onChange={handleChange} />)
|
|
26
|
-
|
|
27
|
-
fireEvent.change(screen.getByRole('textbox'), {
|
|
28
|
-
target: { value: 'JavaScript' },
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
expect(handleChange).toHaveBeenCalledTimes(1)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('Label', () => {
|
|
36
|
-
it('should render when given', async () => {
|
|
37
|
-
render(<InputField label="Label" />)
|
|
38
|
-
|
|
39
|
-
expect(screen.getByLabelText('Label')).toBeInTheDocument()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('should not render when not given', async () => {
|
|
43
|
-
render(<InputField />)
|
|
44
|
-
|
|
45
|
-
expect(screen.queryByLabelText('Label')).not.toBeInTheDocument()
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('Prefix', () => {
|
|
50
|
-
it('should render when given', async () => {
|
|
51
|
-
render(<InputField prefix="$" />)
|
|
52
|
-
|
|
53
|
-
expect(screen.getByText('$')).toBeInTheDocument()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('should not render when not given', async () => {
|
|
57
|
-
render(<InputField />)
|
|
58
|
-
|
|
59
|
-
expect(screen.queryByText('$')).not.toBeInTheDocument()
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
describe('Suffix', () => {
|
|
64
|
-
it('should render when given', async () => {
|
|
65
|
-
render(<InputField suffix="%" />)
|
|
66
|
-
|
|
67
|
-
expect(screen.getByText('%')).toBeInTheDocument()
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('should not render when not given', async () => {
|
|
71
|
-
render(<InputField />)
|
|
72
|
-
|
|
73
|
-
expect(screen.queryByText('&')).not.toBeInTheDocument()
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
describe('Slots', () => {
|
|
78
|
-
it('should render the Icon slot', async () => {
|
|
79
|
-
render(
|
|
80
|
-
<InputField>
|
|
81
|
-
<InputField.Icon>Icon</InputField.Icon>
|
|
82
|
-
</InputField>
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
expect(screen.getByText('Icon')).toBeInTheDocument()
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('should render the Controls slot', async () => {
|
|
89
|
-
render(
|
|
90
|
-
<InputField>
|
|
91
|
-
<InputField.Controls>Controls</InputField.Controls>
|
|
92
|
-
</InputField>
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
expect(screen.getByText('Controls')).toBeInTheDocument()
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('should not render other kinds of children', () => {
|
|
99
|
-
render(
|
|
100
|
-
<InputField>
|
|
101
|
-
<div>Other Children</div>
|
|
102
|
-
</InputField>
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
expect(screen.queryByText('Other Children')).not.toBeInTheDocument()
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
})
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
import { InputHTMLAttributes } from 'react'
|
|
3
|
-
|
|
4
|
-
import { Borders, Focused, Margin, Padding, Surface, Typography, _Typography } from '@foundations'
|
|
5
|
-
import { getSlot, Slot, is, forwardRef, If } from '@helpers'
|
|
6
|
-
import { Flex, SpaceBetween } from '../layout'
|
|
7
|
-
|
|
8
|
-
import { LabeledInput } from './components'
|
|
9
|
-
import { Label1, Label2 } from 'components/typography'
|
|
10
|
-
|
|
11
|
-
const FancyBorder = styled(SpaceBetween)<{ invalid?: boolean }>`
|
|
12
|
-
background: ${({ invalid }) => is(invalid) ? Surface.Critical.Subdued : Surface.Default.Default };
|
|
13
|
-
border: 1px solid ${({ invalid }) => is(invalid) ? Borders.Critical.Default : Borders.Default.Default };
|
|
14
|
-
border-radius: 6px;
|
|
15
|
-
box-sizing: border-box;
|
|
16
|
-
margin-bottom: ${Margin.xxs};
|
|
17
|
-
padding-left: ${Padding.s};
|
|
18
|
-
|
|
19
|
-
user-select: none;
|
|
20
|
-
|
|
21
|
-
:focus, :focus-within, :active {
|
|
22
|
-
border: ${({ invalid }) => is(invalid)
|
|
23
|
-
? `1px solid ${Borders.Critical.Default}`
|
|
24
|
-
: `2px solid ${Focused.Default}`
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
const InputLayout = styled(Flex)`
|
|
30
|
-
width: 100%;
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
export const HTMLInput = styled.input`
|
|
34
|
-
all: unset;
|
|
35
|
-
|
|
36
|
-
padding: ${Padding.none} ${Padding.none} ${Padding.xs} ${Padding.none};
|
|
37
|
-
|
|
38
|
-
width: 100%;
|
|
39
|
-
|
|
40
|
-
::-webkit-inner-spin-button {
|
|
41
|
-
-webkit-appearance: none;
|
|
42
|
-
margin: ${Margin.none};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
${Typography.Body}
|
|
46
|
-
|
|
47
|
-
::placeholder {
|
|
48
|
-
${_Typography.LightText}
|
|
49
|
-
}
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
const PrefixFrame = styled(Label1)`
|
|
53
|
-
margin-right: ${Margin.xs};
|
|
54
|
-
`
|
|
55
|
-
|
|
56
|
-
const SuffixFrame = styled(Label1)`
|
|
57
|
-
margin-right: ${Margin.xs};
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
class IconSlot extends Slot {}
|
|
61
|
-
class ControlsSlot extends Slot {}
|
|
62
|
-
|
|
63
|
-
export type InputFieldSlots = {
|
|
64
|
-
Icon: typeof IconSlot,
|
|
65
|
-
Controls: typeof ControlsSlot,
|
|
66
|
-
Label: typeof LabeledInput,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface IInputFieldProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
70
|
-
invalid?: boolean
|
|
71
|
-
prefix?: string
|
|
72
|
-
suffix?: string
|
|
73
|
-
label?: string
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const InputFrame = styled.label`
|
|
77
|
-
width: 100%;
|
|
78
|
-
padding: ${Padding.xs} ${Padding.none} ${Padding.none} ${Padding.none};
|
|
79
|
-
flex-direction: column;
|
|
80
|
-
display: flex;
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
const ControlsFrame = Flex
|
|
84
|
-
|
|
85
|
-
const Label = styled(Label2)`
|
|
86
|
-
margin-bottom: ${Margin.xxs};
|
|
87
|
-
`
|
|
88
|
-
|
|
89
|
-
export const InputField = forwardRef<
|
|
90
|
-
HTMLInputElement,
|
|
91
|
-
IInputFieldProps,
|
|
92
|
-
InputFieldSlots
|
|
93
|
-
>((props: IInputFieldProps, ref) => {
|
|
94
|
-
const { children, prefix, suffix, label, className, ...inputProps } = props
|
|
95
|
-
const icon = getSlot(IconSlot, children)
|
|
96
|
-
const controls = getSlot(ControlsSlot, children)
|
|
97
|
-
const required = is(props.required) ? '*' : ''
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<FancyBorder invalid={props.invalid} className={className}>
|
|
101
|
-
<InputFrame>
|
|
102
|
-
<If is={label}>
|
|
103
|
-
<Label subdued>
|
|
104
|
-
{label}
|
|
105
|
-
{required}
|
|
106
|
-
</Label>
|
|
107
|
-
</If>
|
|
108
|
-
<InputLayout>
|
|
109
|
-
{icon}
|
|
110
|
-
<If is={prefix}>
|
|
111
|
-
<PrefixFrame subdued>{prefix}</PrefixFrame>
|
|
112
|
-
</If>
|
|
113
|
-
<HTMLInput ref={ref} {...inputProps} />
|
|
114
|
-
<If is={suffix}>
|
|
115
|
-
<SuffixFrame subdued>{suffix}</SuffixFrame>
|
|
116
|
-
</If>
|
|
117
|
-
</InputLayout>
|
|
118
|
-
</InputFrame>
|
|
119
|
-
<ControlsFrame center>{controls}</ControlsFrame>
|
|
120
|
-
</FancyBorder>
|
|
121
|
-
)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
InputField.Icon = IconSlot
|
|
125
|
-
InputField.Controls = ControlsSlot
|
|
126
|
-
InputField.Label = LabeledInput
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { FC, isNil } from '@helpers'
|
|
2
|
-
import { InputField, InputFieldSlots } from './input-field'
|
|
3
|
-
import { Stepper } from './components'
|
|
4
|
-
|
|
5
|
-
interface IInputNumberProps {
|
|
6
|
-
value?: number
|
|
7
|
-
onChange: (change?: number) => void
|
|
8
|
-
|
|
9
|
-
label?: string
|
|
10
|
-
placeholder?: string
|
|
11
|
-
invalid?: boolean
|
|
12
|
-
prefix?: string
|
|
13
|
-
suffix?: string
|
|
14
|
-
required?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type IInputNumberSlots = InputFieldSlots & {
|
|
18
|
-
Stepper: typeof Stepper
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const InputNumber: FC<IInputNumberProps, IInputNumberSlots> = (props) => {
|
|
22
|
-
const { onChange, value, ...inputFieldProps } = props
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<InputField
|
|
26
|
-
type='number'
|
|
27
|
-
value={isNil(value) || isNaN(value) ? '' : value}
|
|
28
|
-
onChange={(e) => {
|
|
29
|
-
const next = e.target.value === '' ? undefined : parseFloat(e.target.value)
|
|
30
|
-
|
|
31
|
-
onChange(next)
|
|
32
|
-
}}
|
|
33
|
-
{...inputFieldProps}
|
|
34
|
-
/>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
InputNumber.Icon = InputField.Icon
|
|
39
|
-
InputNumber.Controls = InputField.Controls
|
|
40
|
-
InputNumber.Label = InputField.Label
|
|
41
|
-
InputNumber.Stepper = Stepper
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FC } from '@helpers'
|
|
2
|
-
import { InputField, InputFieldSlots } from './input-field'
|
|
3
|
-
|
|
4
|
-
interface IInputTextProps {
|
|
5
|
-
value: string
|
|
6
|
-
onChange: (change: string) => void
|
|
7
|
-
|
|
8
|
-
label?: string
|
|
9
|
-
invalid?: boolean
|
|
10
|
-
placeholder?: string
|
|
11
|
-
prefix?: string
|
|
12
|
-
suffix?: string
|
|
13
|
-
required?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const InputText: FC<IInputTextProps, InputFieldSlots> = (props) => {
|
|
17
|
-
const { onChange, ...inputFieldProps } = props
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<InputField
|
|
21
|
-
type='text'
|
|
22
|
-
onChange={(e) => onChange(e.target.value)}
|
|
23
|
-
{...inputFieldProps}
|
|
24
|
-
/>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
InputText.Icon = InputField.Icon
|
|
29
|
-
InputText.Controls = InputField.Controls
|
|
30
|
-
InputText.Label = InputField.Label
|