@liguelead/design-system 0.0.8 → 0.0.10

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.
Files changed (58) hide show
  1. package/components/Button/Button.appearance.ts +62 -62
  2. package/components/Button/Button.sizes.ts +41 -41
  3. package/components/Button/Button.styles.ts +50 -50
  4. package/components/Button/Button.tsx +76 -76
  5. package/components/Button/Button.types.ts +23 -23
  6. package/components/Button/index.ts +1 -1
  7. package/components/Checkbox/Checkbox.styles.ts +66 -66
  8. package/components/Checkbox/Checkbox.tsx +40 -40
  9. package/components/Checkbox/Checkbox.types.ts +11 -11
  10. package/components/Checkbox/index.tsx +2 -2
  11. package/components/DatePicker/DatePicker.styles.ts +66 -66
  12. package/components/DatePicker/DatePicker.tsx +135 -135
  13. package/components/DatePicker/DatePicker.types.ts +29 -29
  14. package/components/DatePicker/index.ts +1 -1
  15. package/components/IconButton/IconButton.sizes.ts +41 -41
  16. package/components/IconButton/IconButton.tsx +70 -70
  17. package/components/IconButton/index.ts +1 -1
  18. package/components/PageWrapper/PageWrapper.tsx +31 -31
  19. package/components/PageWrapper/index.ts +1 -1
  20. package/components/SegmentedButton/SegmentedButton.styles.ts +29 -29
  21. package/components/SegmentedButton/SegmentedButton.tsx +49 -49
  22. package/components/SegmentedButton/SegmentedButton.types.ts +20 -20
  23. package/components/SegmentedButton/index.ts +1 -1
  24. package/components/Select/Select.sizes.ts +56 -56
  25. package/components/Select/Select.states.tsx +69 -69
  26. package/components/Select/Select.styles.ts +148 -148
  27. package/components/Select/Select.tsx +145 -144
  28. package/components/Select/Select.types.ts +36 -36
  29. package/components/Select/index.ts +1 -1
  30. package/components/Text/Text.styles.ts +43 -43
  31. package/components/Text/Text.tsx +27 -27
  32. package/components/Text/Text.types.ts +42 -42
  33. package/components/Text/index.ts +1 -1
  34. package/components/TextField/TextField.sizes.ts +58 -58
  35. package/components/TextField/TextField.states.tsx +53 -76
  36. package/components/TextField/TextField.styles.ts +81 -98
  37. package/components/TextField/TextField.tsx +105 -108
  38. package/components/TextField/TextField.types.ts +22 -21
  39. package/components/TextField/index.ts +2 -2
  40. package/components/TextField/utils/getState.ts +7 -0
  41. package/components/ThemeProvider/ThemeProvider.tsx +21 -21
  42. package/components/ThemeProvider/index.ts +1 -1
  43. package/components/ThemeProvider/style.ts +969 -969
  44. package/components/Wizard/StepContent.tsx +28 -28
  45. package/components/Wizard/StepMenuItem.tsx +33 -33
  46. package/components/Wizard/Wizard.context.tsx +76 -76
  47. package/components/Wizard/Wizard.styles.ts +126 -126
  48. package/components/Wizard/Wizard.tsx +55 -55
  49. package/components/Wizard/index.ts +1 -1
  50. package/components/index.ts +11 -11
  51. package/package.json +41 -39
  52. package/scripts/createTypes.js +70 -70
  53. package/utils/colorDarken.ts +10 -10
  54. package/utils/colorLighten.ts +10 -10
  55. package/utils/darkenOrLighen.ts +19 -19
  56. package/utils/getTextColor.ts +12 -12
  57. package/utils/index.ts +5 -5
  58. package/utils/parseColor.ts +7 -7
@@ -1,144 +1,145 @@
1
- import { forwardRef, useState } from 'react'
2
- import * as RadixSelect from '@radix-ui/react-select'
3
- import { CaretDown, Plus } from '@phosphor-icons/react'
4
- import {
5
- FloatingLabel,
6
- HelperText,
7
- IconWrapper,
8
- InputWrapper,
9
- StyledContent,
10
- StyledInput,
11
- StyledItem,
12
- Wrapper
13
- } from './Select.styles'
14
- import { SelectStates } from './Select.states'
15
- import { textFieldSizes } from './Select.sizes'
16
- import TextField, { getState } from '../TextField/TextField'
17
- import { SelectProps, StateInterface } from './Select.types'
18
-
19
- const Select = forwardRef<HTMLInputElement, SelectProps>(
20
- (
21
- {
22
- label,
23
- defaultValue,
24
- error,
25
- helperText,
26
- leftIcon,
27
- size = 'md',
28
- options,
29
- className,
30
- disabled = false,
31
- handleLeftIcon,
32
- register
33
- },
34
- ref
35
- ) => {
36
- const [selectValue, setSelectValue] = useState(
37
- defaultValue ?? options[0]?.value
38
- )
39
- const [open, setOpen] = useState(false)
40
-
41
- const handleOnChange = (value: string) => {
42
- if (value) {
43
- setSelectValue(value)
44
- register?.onChange({
45
- target: {
46
- name: register.name,
47
- value
48
- }
49
- })
50
- }
51
- }
52
-
53
- const state = getState(disabled, !!error)
54
- const textFieldState: StateInterface = SelectStates(state)
55
- const textFieldSize = textFieldSizes(size, !!leftIcon, false)
56
- const selectedLabel =
57
- options.find(option => option.value === selectValue)?.label ?? ''
58
-
59
- return (
60
- <Wrapper
61
- className={className}
62
- size={textFieldSize}
63
- $themefication={textFieldState}>
64
- <input
65
- type="hidden"
66
- value={selectValue}
67
- ref={instance => {
68
- if (typeof ref === 'function') {
69
- ref(instance)
70
- } else if (ref) {
71
- ref.current = instance
72
- }
73
- register?.ref(instance)
74
- }}
75
- onChange={register?.onChange}
76
- onBlur={register?.onBlur}
77
- />
78
- {!disabled ? (
79
- <RadixSelect.Root
80
- value={selectValue}
81
- onOpenChange={open => setOpen(open)}
82
- defaultValue={defaultValue}
83
- onValueChange={(value: string) =>
84
- handleOnChange(value)
85
- }>
86
- <RadixSelect.Trigger asChild>
87
- <InputWrapper>
88
- {leftIcon && (
89
- <IconWrapper onClick={handleLeftIcon}>
90
- {leftIcon}
91
- </IconWrapper>
92
- )}
93
- <IconWrapper $right $error={!!error}>
94
- <CaretDown weight="fill" size={14} />
95
- </IconWrapper>
96
- <StyledInput
97
- readOnly
98
- style={{ cursor: 'pointer !important' }}
99
- value={selectedLabel}
100
- placeholder=" "
101
- className={open ? 'is-open' : ''}
102
- />
103
- <FloatingLabel
104
- className={open ? 'is-open' : ''}>
105
- {label}
106
- </FloatingLabel>
107
- </InputWrapper>
108
- </RadixSelect.Trigger>
109
- <StyledContent
110
- asChild
111
- sideOffset={0}
112
- position="popper"
113
- align="start"
114
- className="RadixSelectContent">
115
- <RadixSelect.Viewport className="RadixSelectViewport">
116
- {options.map(option => (
117
- <StyledItem
118
- key={option.value}
119
- value={option.value}>
120
- <Plus width={20} />
121
- {option.label}
122
- </StyledItem>
123
- ))}
124
- </RadixSelect.Viewport>
125
- </StyledContent>
126
- </RadixSelect.Root>
127
- ) : (
128
- <TextField
129
- leftIcon={leftIcon}
130
- rightIcon={<CaretDown weight="fill" size={14} />}
131
- label={label}
132
- size={size}
133
- disabled
134
- />
135
- )}
136
- {(helperText || error) && (
137
- <HelperText>{error?.message || helperText}</HelperText>
138
- )}
139
- </Wrapper>
140
- )
141
- }
142
- )
143
-
144
- export default Select
1
+ import { forwardRef, useState } from 'react'
2
+ import * as RadixSelect from '@radix-ui/react-select'
3
+ import { CaretDown, Plus } from '@phosphor-icons/react'
4
+ import {
5
+ FloatingLabel,
6
+ HelperText,
7
+ IconWrapper,
8
+ InputWrapper,
9
+ StyledContent,
10
+ StyledInput,
11
+ StyledItem,
12
+ Wrapper
13
+ } from './Select.styles'
14
+ import { SelectStates } from './Select.states'
15
+ import { textFieldSizes } from './Select.sizes'
16
+ import TextField from '../TextField/TextField'
17
+ import { SelectProps, StateInterface } from './Select.types'
18
+ import getState from '../TextField/utils/getState'
19
+
20
+ const Select = forwardRef<HTMLInputElement, SelectProps>(
21
+ (
22
+ {
23
+ label,
24
+ defaultValue,
25
+ error,
26
+ helperText,
27
+ leftIcon,
28
+ size = 'md',
29
+ options,
30
+ className,
31
+ disabled = false,
32
+ handleLeftIcon,
33
+ register
34
+ },
35
+ ref
36
+ ) => {
37
+ const [selectValue, setSelectValue] = useState(
38
+ defaultValue ?? options[0]?.value
39
+ )
40
+ const [open, setOpen] = useState(false)
41
+
42
+ const handleOnChange = (value: string) => {
43
+ if (value) {
44
+ setSelectValue(value)
45
+ register?.onChange({
46
+ target: {
47
+ name: register.name,
48
+ value
49
+ }
50
+ })
51
+ }
52
+ }
53
+
54
+ const state = getState(disabled, !!error)
55
+ const textFieldState: StateInterface = SelectStates(state)
56
+ const textFieldSize = textFieldSizes(size, !!leftIcon, false)
57
+ const selectedLabel =
58
+ options.find(option => option.value === selectValue)?.label ?? ''
59
+
60
+ return (
61
+ <Wrapper
62
+ className={className}
63
+ size={textFieldSize}
64
+ $themefication={textFieldState}>
65
+ <input
66
+ type="hidden"
67
+ value={selectValue}
68
+ ref={instance => {
69
+ if (typeof ref === 'function') {
70
+ ref(instance)
71
+ } else if (ref) {
72
+ ref.current = instance
73
+ }
74
+ register?.ref(instance)
75
+ }}
76
+ onChange={register?.onChange}
77
+ onBlur={register?.onBlur}
78
+ />
79
+ {!disabled ? (
80
+ <RadixSelect.Root
81
+ value={selectValue}
82
+ onOpenChange={open => setOpen(open)}
83
+ defaultValue={defaultValue}
84
+ onValueChange={(value: string) =>
85
+ handleOnChange(value)
86
+ }>
87
+ <RadixSelect.Trigger asChild>
88
+ <InputWrapper>
89
+ {leftIcon && (
90
+ <IconWrapper onClick={handleLeftIcon}>
91
+ {leftIcon}
92
+ </IconWrapper>
93
+ )}
94
+ <IconWrapper $right $error={!!error}>
95
+ <CaretDown weight="fill" size={14} />
96
+ </IconWrapper>
97
+ <StyledInput
98
+ readOnly
99
+ style={{ cursor: 'pointer !important' }}
100
+ value={selectedLabel}
101
+ placeholder=" "
102
+ className={open ? 'is-open' : ''}
103
+ />
104
+ <FloatingLabel
105
+ className={open ? 'is-open' : ''}>
106
+ {label}
107
+ </FloatingLabel>
108
+ </InputWrapper>
109
+ </RadixSelect.Trigger>
110
+ <StyledContent
111
+ asChild
112
+ sideOffset={0}
113
+ position="popper"
114
+ align="start"
115
+ className="RadixSelectContent">
116
+ <RadixSelect.Viewport className="RadixSelectViewport">
117
+ {options.map(option => (
118
+ <StyledItem
119
+ key={option.value}
120
+ value={option.value}>
121
+ <Plus width={20} />
122
+ {option.label}
123
+ </StyledItem>
124
+ ))}
125
+ </RadixSelect.Viewport>
126
+ </StyledContent>
127
+ </RadixSelect.Root>
128
+ ) : (
129
+ <TextField
130
+ leftIcon={leftIcon}
131
+ rightIcon={<CaretDown weight="fill" size={14} />}
132
+ label={label}
133
+ size={size}
134
+ disabled
135
+ />
136
+ )}
137
+ {(helperText || error) && (
138
+ <HelperText>{error?.message || helperText}</HelperText>
139
+ )}
140
+ </Wrapper>
141
+ )
142
+ }
143
+ )
144
+
145
+ export default Select
@@ -1,36 +1,36 @@
1
- import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
2
- export interface SelectProps<TFieldValues extends FieldValues = FieldValues> {
3
- className?: string
4
- disabled?: boolean
5
- error?: TFieldValues
6
- label: string
7
- options: Array<{ label: string; value: string }>
8
- value?: string
9
- defaultValue?: string
10
- handleLeftIcon?: () => void
11
- helperText?: string
12
- leftIcon?: React.ReactNode
13
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
14
- size?: 'sm' | 'md' | 'lg'
15
- register?: UseFormRegisterReturn<string>
16
- }
17
-
18
- export interface StateInterface {
19
- input: string
20
- label: string
21
- helperText: string
22
- animation?: string
23
- }
24
-
25
- export interface TextFieldStates {
26
- error: StateInterface
27
- default: StateInterface
28
- disabled: StateInterface
29
- }
30
-
31
- export type TextFieldSize = 'sm' | 'md' | 'lg'
32
-
33
- export type TextFieldSizeType = {
34
- input: string
35
- label: string
36
- }
1
+ import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
2
+ export interface SelectProps<TFieldValues extends FieldValues = FieldValues> {
3
+ className?: string
4
+ disabled?: boolean
5
+ error?: TFieldValues
6
+ label: string
7
+ options: Array<{ label: string; value: string }>
8
+ value?: string
9
+ defaultValue?: string
10
+ handleLeftIcon?: () => void
11
+ helperText?: string
12
+ leftIcon?: React.ReactNode
13
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
14
+ size?: 'sm' | 'md' | 'lg'
15
+ register?: UseFormRegisterReturn<string>
16
+ }
17
+
18
+ export interface StateInterface {
19
+ input: string
20
+ label: string
21
+ helperText: string
22
+ animation?: string
23
+ }
24
+
25
+ export interface TextFieldStates {
26
+ error: StateInterface
27
+ default: StateInterface
28
+ disabled: StateInterface
29
+ }
30
+
31
+ export type TextFieldSize = 'sm' | 'md' | 'lg'
32
+
33
+ export type TextFieldSizeType = {
34
+ input: string
35
+ label: string
36
+ }
@@ -1 +1 @@
1
- export { default } from './Select'
1
+ export { default } from './Select'
@@ -1,43 +1,43 @@
1
- import { parseColor } from '../../utils'
2
- import styled, { css } from 'styled-components'
3
- import {
4
- fontSize,
5
- fontWeight,
6
- lineHeight,
7
- fontFamily
8
- } from '@liguelead/foundation'
9
- import { TextProps } from './Text.types'
10
-
11
- type BodyProps = Omit<TextProps, 'tag'>
12
-
13
- const Body = styled.p.withConfig({
14
- shouldForwardProp: prop =>
15
- !['color', 'margin', 'isTitle', 'size', 'align', 'weight'].includes(
16
- prop
17
- )
18
- })<BodyProps>`
19
- position: relative;
20
-
21
- ${({
22
- align = 'left',
23
- color = 'neutral800',
24
- isTitle,
25
- theme,
26
- size = 'body01'
27
- }) => css`
28
- text-align: ${align};
29
- color: ${parseColor(theme.colors[color] || theme.colors.neutral800)};
30
- font-family: '${isTitle
31
- ? fontFamily[theme.fonts.headings]
32
- : fontFamily[theme.fonts.default]}',
33
- sans-serif;
34
- font-weight: ${fontWeight[theme.typography[size]?.fontWeight] ||
35
- 'normal'};
36
- font-size: ${fontSize[theme.typography[size]?.fontSize] ||
37
- fontSize.fontSize16}px;
38
- line-height: ${lineHeight[theme.typography[size]?.lineHeight] ||
39
- lineHeight.lineHeight24}px;
40
- `}
41
- `
42
-
43
- export { Body }
1
+ import { parseColor } from '../../utils'
2
+ import styled, { css } from 'styled-components'
3
+ import {
4
+ fontSize,
5
+ fontWeight,
6
+ lineHeight,
7
+ fontFamily
8
+ } from '@liguelead/foundation'
9
+ import { TextProps } from './Text.types'
10
+
11
+ type BodyProps = Omit<TextProps, 'tag'>
12
+
13
+ const Body = styled.p.withConfig({
14
+ shouldForwardProp: prop =>
15
+ !['color', 'margin', 'isTitle', 'size', 'align', 'weight'].includes(
16
+ prop
17
+ )
18
+ })<BodyProps>`
19
+ position: relative;
20
+
21
+ ${({
22
+ align = 'left',
23
+ color = 'neutral800',
24
+ isTitle,
25
+ theme,
26
+ size = 'body01'
27
+ }) => css`
28
+ text-align: ${align};
29
+ color: ${parseColor(theme.colors[color] || theme.colors.neutral800)};
30
+ font-family: '${isTitle
31
+ ? fontFamily[theme.fonts.headings]
32
+ : fontFamily[theme.fonts.default]}',
33
+ sans-serif;
34
+ font-weight: ${fontWeight[theme.typography[size]?.fontWeight] ||
35
+ 'normal'};
36
+ font-size: ${fontSize[theme.typography[size]?.fontSize] ||
37
+ fontSize.fontSize16}px;
38
+ line-height: ${lineHeight[theme.typography[size]?.lineHeight] ||
39
+ lineHeight.lineHeight24}px;
40
+ `}
41
+ `
42
+
43
+ export { Body }
@@ -1,27 +1,27 @@
1
- import React from 'react'
2
- import { Body } from './Text.styles'
3
- import { TextProps } from './Text.types'
4
-
5
- const Text: React.FC<TextProps> = ({
6
- align,
7
- children,
8
- color = 'neutral1000',
9
- isTitle = false,
10
- tag = 'p',
11
- size,
12
- ...rest
13
- }) => {
14
- return (
15
- <Body
16
- as={isTitle ? 'h2' : tag}
17
- align={align}
18
- color={color}
19
- size={size}
20
- isTitle={isTitle}
21
- {...rest}>
22
- {children}
23
- </Body>
24
- )
25
- }
26
-
27
- export default Text
1
+ import React from 'react'
2
+ import { Body } from './Text.styles'
3
+ import { TextProps } from './Text.types'
4
+
5
+ const Text: React.FC<TextProps> = ({
6
+ align,
7
+ children,
8
+ color = 'neutral1000',
9
+ isTitle = false,
10
+ tag = 'p',
11
+ size,
12
+ ...rest
13
+ }) => {
14
+ return (
15
+ <Body
16
+ as={isTitle ? 'h2' : tag}
17
+ align={align}
18
+ color={color}
19
+ size={size}
20
+ isTitle={isTitle}
21
+ {...rest}>
22
+ {children}
23
+ </Body>
24
+ )
25
+ }
26
+
27
+ export default Text
@@ -1,42 +1,42 @@
1
- import { colorType } from 'types'
2
- import { ReactNode } from 'react'
3
-
4
- type AlignType = 'left' | 'center' | 'right' | 'justify'
5
-
6
- type SizeType =
7
- | 'span01'
8
- | 'body01'
9
- | 'body02'
10
- | 'heading01'
11
- | 'heading02'
12
- | 'heading03'
13
- | 'heading04'
14
-
15
- type TagType =
16
- | 'h1'
17
- | 'h2'
18
- | 'h3'
19
- | 'h4'
20
- | 'h5'
21
- | 'h6'
22
- | 'p'
23
- | 'span'
24
- | 'label'
25
- | 'small'
26
- | 'b'
27
- | 'i'
28
- | 'em'
29
- | 'td'
30
- | 'div'
31
- | 'a'
32
-
33
- export interface TextProps {
34
- align?: AlignType
35
- children?: ReactNode
36
- color?: colorType
37
- isTitle?: boolean
38
- tag?: TagType
39
- size?: SizeType
40
- weight?: string
41
- className?: string
42
- }
1
+ import { colorType } from 'types'
2
+ import { ReactNode } from 'react'
3
+
4
+ type AlignType = 'left' | 'center' | 'right' | 'justify'
5
+
6
+ type SizeType =
7
+ | 'span01'
8
+ | 'body01'
9
+ | 'body02'
10
+ | 'heading01'
11
+ | 'heading02'
12
+ | 'heading03'
13
+ | 'heading04'
14
+
15
+ type TagType =
16
+ | 'h1'
17
+ | 'h2'
18
+ | 'h3'
19
+ | 'h4'
20
+ | 'h5'
21
+ | 'h6'
22
+ | 'p'
23
+ | 'span'
24
+ | 'label'
25
+ | 'small'
26
+ | 'b'
27
+ | 'i'
28
+ | 'em'
29
+ | 'td'
30
+ | 'div'
31
+ | 'a'
32
+
33
+ export interface TextProps {
34
+ align?: AlignType
35
+ children?: ReactNode
36
+ color?: colorType
37
+ isTitle?: boolean
38
+ tag?: TagType
39
+ size?: SizeType
40
+ weight?: string
41
+ className?: string
42
+ }
@@ -1 +1 @@
1
- export { default } from './Text'
1
+ export { default } from './Text'