w-design-system 0.0.26 → 0.0.28

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 (67) hide show
  1. package/dist/components/Button/index.d.ts.map +1 -1
  2. package/dist/components/Button/index.js +33 -19
  3. package/dist/components/Button/index.js.map +1 -1
  4. package/dist/components/DatePicker/index.d.ts +17 -0
  5. package/dist/components/DatePicker/index.d.ts.map +1 -0
  6. package/dist/components/DatePicker/index.js +22 -0
  7. package/dist/components/DatePicker/index.js.map +1 -0
  8. package/dist/components/DatePicker/stories.d.ts +8 -0
  9. package/dist/components/DatePicker/stories.d.ts.map +1 -0
  10. package/dist/components/DatePicker/stories.js +61 -0
  11. package/dist/components/DatePicker/stories.js.map +1 -0
  12. package/dist/components/DateRangePicker/index.d.ts +19 -0
  13. package/dist/components/DateRangePicker/index.d.ts.map +1 -0
  14. package/dist/components/DateRangePicker/index.js +159 -0
  15. package/dist/components/DateRangePicker/index.js.map +1 -0
  16. package/dist/components/DateRangePicker/stories.d.ts +8 -0
  17. package/dist/components/DateRangePicker/stories.d.ts.map +1 -0
  18. package/dist/components/DateRangePicker/stories.js +60 -0
  19. package/dist/components/DateRangePicker/stories.js.map +1 -0
  20. package/dist/components/DateRangePicker/styles.d.ts +18 -0
  21. package/dist/components/DateRangePicker/styles.d.ts.map +1 -0
  22. package/dist/components/DateRangePicker/styles.js +114 -0
  23. package/dist/components/DateRangePicker/styles.js.map +1 -0
  24. package/dist/components/Input/index.d.ts +3 -3
  25. package/dist/components/Input/index.d.ts.map +1 -1
  26. package/dist/components/Input/index.js +3 -3
  27. package/dist/components/Paginate/index.d.ts +2 -2
  28. package/dist/components/Paginate/stories.d.ts +3 -3
  29. package/dist/components/Select/index.d.ts +20 -0
  30. package/dist/components/Select/index.d.ts.map +1 -0
  31. package/dist/components/Select/index.js +68 -0
  32. package/dist/components/Select/index.js.map +1 -0
  33. package/dist/components/Select/stories.d.ts +7 -0
  34. package/dist/components/Select/stories.d.ts.map +1 -0
  35. package/dist/components/Select/stories.js +48 -0
  36. package/dist/components/Select/stories.js.map +1 -0
  37. package/dist/components/Select/styles.d.ts +8 -0
  38. package/dist/components/Select/styles.d.ts.map +1 -0
  39. package/dist/components/Select/styles.js +47 -0
  40. package/dist/components/Select/styles.js.map +1 -0
  41. package/dist/components/Themes/index.d.ts +1 -0
  42. package/dist/components/Themes/index.d.ts.map +1 -1
  43. package/dist/components/Themes/index.js +5 -2
  44. package/dist/components/Themes/index.js.map +1 -1
  45. package/dist/components/Types/index.d.ts +6 -1
  46. package/dist/components/Types/index.d.ts.map +1 -1
  47. package/dist/index.d.ts +3 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +3 -2
  50. package/dist/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/components/Button/index.tsx +34 -19
  53. package/src/components/{DateInput → DatePicker}/index.tsx +5 -5
  54. package/src/components/{DateInput → DatePicker}/stories.tsx +21 -9
  55. package/src/components/{RangeDateInput → DateRangePicker}/index.tsx +79 -117
  56. package/src/components/{RangeDateInput → DateRangePicker}/stories.tsx +12 -13
  57. package/src/components/{DateInput → DateRangePicker}/styles.ts +41 -55
  58. package/src/components/Input/index.tsx +7 -7
  59. package/src/components/Paginate/index.tsx +2 -2
  60. package/src/components/Paginate/stories.tsx +4 -4
  61. package/src/components/Select/index.tsx +123 -0
  62. package/src/components/Select/stories.tsx +51 -0
  63. package/src/components/Select/styles.ts +55 -0
  64. package/src/components/Themes/index.ts +5 -0
  65. package/src/components/Types/index.ts +8 -1
  66. package/src/index.tsx +3 -2
  67. package/src/components/RangeDateInput/styles.ts +0 -145
@@ -0,0 +1,123 @@
1
+ import React, {
2
+ FC,
3
+ HTMLAttributes,
4
+ PropsWithChildren,
5
+ ReactNode,
6
+ useEffect,
7
+ useImperativeHandle,
8
+ useMemo,
9
+ useRef,
10
+ useState,
11
+ } from 'react'
12
+ import { chevronDownSVG } from '../../assets/icon'
13
+ import { IconWrapper } from '../IconWrapper'
14
+ import { Input } from '../Input'
15
+ import { theme } from '../Themes'
16
+ import { OptionButton, Dropdown, DropdownWrapper, SelectWrapper } from './styles'
17
+
18
+ export interface SelectProps extends HTMLAttributes<HTMLDivElement> {
19
+ disabled?: boolean
20
+ label?: string
21
+ leftIcon?: ReactNode
22
+ onOptionChange?: (option: number | null) => void
23
+ options?: { text: string; id: number }[]
24
+ placeholder?: string
25
+ rightIcon?: ReactNode
26
+ selectedOption?: number | null
27
+ value?: string
28
+ }
29
+
30
+ export interface SelectRef {
31
+ setOpen(open: boolean): void
32
+ }
33
+
34
+ const SelectFowardRef: React.ForwardRefRenderFunction<SelectRef, SelectProps> = (
35
+ { children, label, leftIcon, onOptionChange, options, placeholder, rightIcon, selectedOption, value, ...props },
36
+ ref,
37
+ ) => {
38
+ const [open, setOpen] = useState(false)
39
+ const wrapperRef = useRef<HTMLDivElement>(null)
40
+
41
+ useImperativeHandle(ref, () => ({
42
+ setOpen,
43
+ }))
44
+
45
+ useEffect(() => {
46
+ if (!open) return
47
+ const handler = (event: MouseEvent) => {
48
+ let element: HTMLElement | null = event.target as HTMLElement
49
+ while (element && element !== document.body.parentElement) {
50
+ if (element === wrapperRef.current) break
51
+ element = element.parentElement
52
+ }
53
+ if (element === document.body.parentElement) {
54
+ setOpen(false)
55
+ }
56
+ }
57
+ document.addEventListener('click', handler)
58
+
59
+ return () => {
60
+ document.removeEventListener('click', handler)
61
+ }
62
+ }, [open])
63
+
64
+ const onOptionClick = (option: number) => {
65
+ onOptionChange && onOptionChange(option)
66
+ setOpen(false)
67
+ }
68
+
69
+ const valueComputed = useMemo(() => {
70
+ if (value) return value
71
+ if (selectedOption) {
72
+ const option = options?.find(option => option.id === selectedOption)
73
+ return option?.text
74
+ }
75
+ return ''
76
+ }, [value, selectedOption, options])
77
+
78
+ return (
79
+ <SelectWrapper {...props} ref={wrapperRef}>
80
+ <Input
81
+ leftIcon={leftIcon}
82
+ rightIcon={
83
+ <>
84
+ {rightIcon}
85
+ <IconWrapper
86
+ className={`icon ${open ? 'icon-rotate' : ''}`}
87
+ src={chevronDownSVG}
88
+ width="16px"
89
+ color={theme.colors.shade30}
90
+ />
91
+ </>
92
+ }
93
+ placeholder={placeholder}
94
+ label={label}
95
+ value={valueComputed}
96
+ readonly
97
+ onClick={() => setOpen(!open)}
98
+ />
99
+ {open && (
100
+ <DropdownWrapper>
101
+ <Dropdown>
102
+ {(options?.length ?? 0) > 0 && (
103
+ <div>
104
+ {options?.map(option => (
105
+ <OptionButton
106
+ selected={option.id === selectedOption}
107
+ key={option.id}
108
+ onClick={() => onOptionClick(option.id)}
109
+ >
110
+ {option.text}
111
+ </OptionButton>
112
+ ))}
113
+ </div>
114
+ )}
115
+ {children}
116
+ </Dropdown>
117
+ </DropdownWrapper>
118
+ )}
119
+ </SelectWrapper>
120
+ )
121
+ }
122
+
123
+ export const Select = React.forwardRef(SelectFowardRef)
@@ -0,0 +1,51 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import { Select, SelectProps } from './index'
3
+ import React from 'react'
4
+
5
+ const meta: Meta<typeof Select> = {
6
+ title: 'Components/Select',
7
+ component: Select,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ placeholder: { control: 'text' },
11
+ label: { control: 'text' },
12
+ disabled: { control: 'boolean' },
13
+ selectedOption: { control: 'number' },
14
+ onOptionChange: { action: 'selectedOptionChange' },
15
+ },
16
+ } satisfies Meta<typeof Select>
17
+
18
+ export default meta
19
+ type Story = StoryObj<typeof Select>
20
+
21
+ const ComponentWrapper = ({ options, ...args }: SelectProps) => {
22
+ const [selectedOption, setSelectOption] = React.useState<number | null>(null)
23
+
24
+ return (
25
+ <Select
26
+ selectedOption={selectedOption}
27
+ onOptionChange={option => setSelectOption(option)}
28
+ options={
29
+ options ?? [
30
+ {
31
+ text: 'Opção 1',
32
+ id: 1,
33
+ },
34
+ {
35
+ text: 'Opção 2',
36
+ id: 2,
37
+ },
38
+ {
39
+ text: 'Opção 3',
40
+ id: 3,
41
+ },
42
+ ]
43
+ }
44
+ {...args}
45
+ />
46
+ )
47
+ }
48
+
49
+ export const Default: Story = {
50
+ render: args => <ComponentWrapper label="Label" placeholder="Placeholder" />,
51
+ }
@@ -0,0 +1,55 @@
1
+ import styled from 'styled-components'
2
+ import { theme } from '../Themes'
3
+
4
+ export const SelectWrapper = styled.div`
5
+ position: relative;
6
+ .icon {
7
+ transition: transform 0.3s;
8
+ }
9
+ .icon-rotate {
10
+ transform: rotate(180deg) translateY(5px);
11
+ }
12
+ `
13
+
14
+ export const Dropdown = styled.div`
15
+ position: absolute;
16
+ width: 252px;
17
+ padding: 16px;
18
+ z-index: 1;
19
+ border-radius: 4px;
20
+ border: 1px solid ${theme.colors.shade20};
21
+ margin-top: 7px;
22
+ box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
23
+ `
24
+
25
+ export const DropdownWrapper = styled.div`
26
+ position: relative;
27
+ `
28
+
29
+
30
+ export interface OptionButtonProps {
31
+ selected: boolean
32
+ }
33
+
34
+ export const OptionButton = styled.button<OptionButtonProps>`
35
+ background-color: transparent;
36
+ border: none;
37
+ font-size: ${theme.paragraph.medium};
38
+ font-family: 'Nunito Sans', sans-serif;
39
+ color: ${({ selected }) => (selected ? theme.colors.cyan30 : theme.colors.shade40)};
40
+ cursor: pointer;
41
+ padding: 0;
42
+ width: 100%;
43
+ text-align: left;
44
+ height: 46px;
45
+ display: flex;
46
+ align-items: center;
47
+
48
+ &:not(:last-child) {
49
+ border-bottom: 1px solid ${theme.colors.shade10};
50
+ }
51
+
52
+ &:hover {
53
+ color: ${theme.colors.cyan30};
54
+ }
55
+ `
@@ -42,6 +42,10 @@ const mint = {
42
42
  mint10: '#EBF8EF',
43
43
  }
44
44
 
45
+ const special = {
46
+ cyan30opacity16: 'rgba(33, 126, 253, 0.16)',
47
+ }
48
+
45
49
  const white = '#FFFFFF'
46
50
  const black = '#333333'
47
51
  const transparent = 'transparent'
@@ -84,6 +88,7 @@ export const theme = {
84
88
  white,
85
89
  black,
86
90
  transparent,
91
+ ...special,
87
92
  },
88
93
  fonts: ['Nunito Sans', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'],
89
94
  title: {
@@ -1,7 +1,12 @@
1
1
  import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react'
2
-
2
+ import type { DatePickerProps } from '../DatePicker'
3
+ import type { DateRangePickerProps } from '../DateRangePicker'
4
+ import type { SelectProps } from '../Select'
5
+ import type { SelectRef } from '../Select'
6
+ import type { PaginateProps } from '../Paginate'
3
7
  type ColorsVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'gray' | 'warning' | 'yellow'
4
8
  type ColorsVariantBanner = 'notice' | 'success' | 'danger' | 'warning'
9
+
5
10
  export interface ButtonTypes extends ButtonHTMLAttributes<HTMLButtonElement> {
6
11
  variant?: ColorsVariant
7
12
  icon?: string
@@ -47,3 +52,5 @@ export interface TabsTypes extends HTMLAttributes<HTMLDivElement> {
47
52
  defaultActiveTab?: string
48
53
  onTabChange?: (activeTab: string) => void
49
54
  }
55
+
56
+ export { DatePickerProps, DateRangePickerProps, SelectProps, SelectRef, PaginateProps }
package/src/index.tsx CHANGED
@@ -2,17 +2,18 @@ export { Banner } from './components/Banner/index'
2
2
  export { Button } from './components/Button/index'
3
3
  export { ButtonRadiusIcon } from './components/ButtonRadiusIcon/index'
4
4
  export { ButtonRound } from './components/ButtonRound/index'
5
- export { DateInput } from './components/DateInput/index'
5
+ export { DatePicker as DateInput } from './components/DatePicker/index'
6
6
  export { IconWrapper } from './components/IconWrapper/index'
7
7
  export { Input } from './components/Input/index'
8
8
  export { Modal } from './components/Modal/index'
9
9
  export { Paginate } from './components/Paginate/index'
10
10
  export { Paragraph } from './components/Paragraph/index'
11
- export { RangeDateInput } from './components/RangeDateInput/index'
11
+ export { DateRangePicker as RangeDateInput } from './components/DateRangePicker/index'
12
12
  export { Table } from './components/Table/index'
13
13
  export { Tabs } from './components/Tabs/index'
14
14
  export { theme } from './components/Themes/index'
15
15
  export { Title } from './components/Title/index'
16
+ export { Select } from './components/Select/index'
16
17
  export {
17
18
  appsSVG,
18
19
  alertSVG,
@@ -1,145 +0,0 @@
1
- import styled from 'styled-components'
2
- import { theme } from '../Themes'
3
-
4
- export const InputDateWrapper = styled.div`
5
- position: relative;
6
- .icon {
7
- transition: transform 0.3s;
8
- }
9
- .icon-rotate {
10
- transform: rotate(180deg) translateY(5px);
11
- }
12
- `
13
-
14
- export const Dropdown = styled.div`
15
- position: absolute;
16
- width: 252px;
17
- padding: 16px;
18
- z-index: 1;
19
- border-radius: 4px;
20
- border: 1px solid ${theme.colors.shade20};
21
- margin-top: 7px;
22
- box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
23
- `
24
-
25
- export const DropdownWrapper = styled.div`
26
- position: relative;
27
- `
28
-
29
- export const CalendarGrid = styled.div`
30
- display: grid;
31
- font-family: 'Nunito Sans', sans-serif;
32
- grid-template-columns: repeat(7, 36px);
33
- align-items: center;
34
- justify-items: center;
35
- grid-column-gap: 0px;
36
- grid-row-gap: 0px;
37
- height: 100%;
38
- width: 100%;
39
- font-size: ${theme.paragraph.small};
40
- color: ${theme.colors.shade50};
41
- `
42
-
43
- export const CalendarWeekDayLabel = styled.div`
44
- font-size: ${theme.paragraph['xx-small']};
45
- color: ${theme.colors.shade30};
46
- font-weight: 600;
47
- margin-bottom: 4px;
48
- `
49
-
50
- export interface DefaultOptionButtonProps {
51
- selected: boolean
52
- }
53
-
54
- export const DefaultOptionButton = styled.button<DefaultOptionButtonProps>`
55
- background-color: transparent;
56
- border: none;
57
- font-size: ${theme.paragraph.medium};
58
- font-family: 'Nunito Sans', sans-serif;
59
- color: ${({ selected }) => (selected ? theme.colors.cyan30 : theme.colors.shade40)};
60
- cursor: pointer;
61
- padding: 0;
62
- width: 100%;
63
- text-align: left;
64
- height: 46px;
65
- display: flex;
66
- align-items: center;
67
-
68
- &:not(:last-child) {
69
- border-bottom: 1px solid ${theme.colors.shade10};
70
- }
71
-
72
- &:hover {
73
- color: ${theme.colors.cyan30};
74
- }
75
- `
76
-
77
- export const CalendarHeader = styled.div`
78
- display: flex;
79
- justify-content: space-between;
80
- align-items: center;
81
- font-size: ${theme.paragraph.small};
82
- font-family: 'Nunito Sans', sans-serif;
83
- font-weight: 600;
84
-
85
- .icon,
86
- .icon svg,
87
- .icon svg path {
88
- fill: ${theme.colors.shade50} !important;
89
- }
90
-
91
- .icon:hover,
92
- .icon:hover svg,
93
- .icon:hover svg path {
94
- fill: ${theme.colors.cyan30} !important;
95
- }
96
-
97
- .icon-disabled,
98
- .icon-disabled svg,
99
- .icon-disabled svg path {
100
- fill: ${theme.colors.shade20} !important;
101
- }
102
- `
103
- export interface CalendarDayProps {
104
- today: boolean
105
- }
106
-
107
- export const CalendarDay = styled.div<CalendarDayProps>`
108
- position: relative;
109
- cursor: pointer;
110
- color: ${({ today }) => (today ? theme.colors.white : theme.colors.shade50)};
111
- width: 36px;
112
- height: 36px;
113
- `
114
-
115
- export interface CalendarDaySelectedBackgroundProps {
116
- today: boolean
117
- selected: boolean
118
- }
119
- export const CalendarDaySelectedBackground = styled.div<CalendarDaySelectedBackgroundProps>`
120
- position: absolute;
121
- background-color: ${({ selected }) => selected && 'rgba(33, 126, 253, 0.16)'};
122
- width: 100%;
123
- height: 100%;
124
- inset: 0;
125
-
126
- &:hover {
127
- background-color: rgba(33, 126, 253, 0.16);
128
- }
129
-
130
- &::before {
131
- content: '';
132
- border-radius: 50%;
133
- position: absolute;
134
- background-color: ${({ today }) => (today ? theme.colors.cyan40 : 'transparent')};
135
- inset: 0;
136
- }
137
- `
138
- export const CalendarDayValue = styled.div`
139
- position: absolute;
140
- inset: 0;
141
- display: flex;
142
- align-items: center;
143
- justify-content: center;
144
- pointer-events: none;
145
- `