@modul/mbui 0.0.13-beta-pv-53036-69a68bb4 → 0.0.13-beta-pv-53127-63b6a630

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 (129) hide show
  1. package/dist/Base/Input/Base.d.ts +4 -0
  2. package/dist/Base/Input/Base.js +20 -0
  3. package/dist/Base/Input/Base.js.map +1 -0
  4. package/dist/Base/Input/Input.d.ts +4 -0
  5. package/dist/Base/Input/Input.js +18 -0
  6. package/dist/Base/Input/Input.js.map +1 -0
  7. package/dist/Base/Input/index.d.ts +2 -0
  8. package/dist/Base/Input/index.js +7 -0
  9. package/dist/Base/Input/index.js.map +1 -0
  10. package/dist/Base/Input/types.d.ts +9 -0
  11. package/dist/Base/Input/types.js +3 -0
  12. package/dist/Base/Input/types.js.map +1 -0
  13. package/dist/Button/Button.d.ts +1 -1
  14. package/dist/Chip/Chip.d.ts +1 -1
  15. package/dist/Drawer/Drawer.js +1 -1
  16. package/dist/Drawer/Drawer.js.map +1 -1
  17. package/dist/{Alert/Alert.d.ts → Info/Info.d.ts} +4 -4
  18. package/dist/{Alert/Alert.js → Info/Info.js} +7 -7
  19. package/dist/Info/Info.js.map +1 -0
  20. package/dist/Info/index.d.ts +1 -0
  21. package/dist/Info/index.js +6 -0
  22. package/dist/Info/index.js.map +1 -0
  23. package/dist/Input/Input.js +1 -1
  24. package/dist/Input/Input.js.map +1 -1
  25. package/dist/Input/index.d.ts +0 -1
  26. package/dist/Input/index.js +1 -3
  27. package/dist/Input/index.js.map +1 -1
  28. package/dist/Input-OTP/Input.d.ts +4 -4
  29. package/dist/Page/Page.js +1 -1
  30. package/dist/Page/Page.js.map +1 -1
  31. package/dist/Progress/Progress.d.ts +4 -0
  32. package/dist/Progress/Progress.js +12 -0
  33. package/dist/Progress/Progress.js.map +1 -0
  34. package/dist/Progress/index.d.ts +1 -0
  35. package/dist/Progress/index.js +6 -0
  36. package/dist/Progress/index.js.map +1 -0
  37. package/dist/index.d.ts +20 -26
  38. package/dist/index.js +10 -31
  39. package/dist/index.js.map +1 -1
  40. package/package.json +4 -10
  41. package/src/@/config/index.ts +1 -0
  42. package/src/Drawer/Drawer.tsx +2 -2
  43. package/src/DrawerCompanyList/CompanyList.tsx +63 -0
  44. package/src/DrawerCompanyList/index.ts +1 -0
  45. package/src/{Alert/Alert.tsx → Info/Info.tsx} +6 -6
  46. package/src/Info/index.ts +1 -0
  47. package/src/Input/Input.tsx +1 -1
  48. package/src/Input/index.ts +1 -2
  49. package/src/Label/Label.tsx +1 -1
  50. package/src/Page/Page.tsx +1 -1
  51. package/src/Progress/Progress.tsx +23 -0
  52. package/src/Progress/index.ts +1 -0
  53. package/src/assets/css/global.css +10 -22
  54. package/src/index.ts +42 -48
  55. package/dist/Alert/Alert.js.map +0 -1
  56. package/dist/Alert/index.d.ts +0 -1
  57. package/dist/Alert/index.js +0 -6
  58. package/dist/Alert/index.js.map +0 -1
  59. package/dist/Calendar/Calendar.d.ts +0 -8
  60. package/dist/Calendar/Calendar.js +0 -45
  61. package/dist/Calendar/Calendar.js.map +0 -1
  62. package/dist/Calendar/index.d.ts +0 -1
  63. package/dist/Calendar/index.js +0 -6
  64. package/dist/Calendar/index.js.map +0 -1
  65. package/dist/DatePicker/DatePicker.d.ts +0 -9
  66. package/dist/DatePicker/DatePicker.js +0 -23
  67. package/dist/DatePicker/DatePicker.js.map +0 -1
  68. package/dist/DatePicker/index.d.ts +0 -1
  69. package/dist/DatePicker/index.js +0 -6
  70. package/dist/DatePicker/index.js.map +0 -1
  71. package/dist/Form/Form.d.ts +0 -23
  72. package/dist/Form/Form.js +0 -73
  73. package/dist/Form/Form.js.map +0 -1
  74. package/dist/Form/index.d.ts +0 -1
  75. package/dist/Form/index.js +0 -13
  76. package/dist/Form/index.js.map +0 -1
  77. package/dist/Input/InputMask.d.ts +0 -3
  78. package/dist/Input/InputMask.js +0 -12
  79. package/dist/Input/InputMask.js.map +0 -1
  80. package/dist/Label/Label.d.ts +0 -5
  81. package/dist/Label/Label.js +0 -13
  82. package/dist/Label/Label.js.map +0 -1
  83. package/dist/Label/index.d.ts +0 -1
  84. package/dist/Label/index.js +0 -6
  85. package/dist/Label/index.js.map +0 -1
  86. package/dist/Select/Select.d.ts +0 -3
  87. package/dist/Select/Select.js +0 -11
  88. package/dist/Select/Select.js.map +0 -1
  89. package/dist/Select/SelectAccountCard.d.ts +0 -4
  90. package/dist/Select/SelectAccountCard.js +0 -75
  91. package/dist/Select/SelectAccountCard.js.map +0 -1
  92. package/dist/Select/SelectAsync.d.ts +0 -8
  93. package/dist/Select/SelectAsync.js +0 -73
  94. package/dist/Select/SelectAsync.js.map +0 -1
  95. package/dist/Select/SelectBase.d.ts +0 -6
  96. package/dist/Select/SelectBase.js +0 -72
  97. package/dist/Select/SelectBase.js.map +0 -1
  98. package/dist/Select/index.d.ts +0 -4
  99. package/dist/Select/index.js +0 -12
  100. package/dist/Select/index.js.map +0 -1
  101. package/dist/Switch/Switch.d.ts +0 -4
  102. package/dist/Switch/Switch.js +0 -31
  103. package/dist/Switch/Switch.js.map +0 -1
  104. package/dist/Switch/index.d.ts +0 -1
  105. package/dist/Switch/index.js +0 -6
  106. package/dist/Switch/index.js.map +0 -1
  107. package/dist/Textarea/Textarea.d.ts +0 -5
  108. package/dist/Textarea/Textarea.js +0 -12
  109. package/dist/Textarea/Textarea.js.map +0 -1
  110. package/dist/Textarea/index.d.ts +0 -1
  111. package/dist/Textarea/index.js +0 -6
  112. package/dist/Textarea/index.js.map +0 -1
  113. package/src/Alert/index.ts +0 -1
  114. package/src/Calendar/Calendar.tsx +0 -61
  115. package/src/Calendar/index.ts +0 -1
  116. package/src/DatePicker/DatePicker.tsx +0 -38
  117. package/src/DatePicker/index.ts +0 -1
  118. package/src/Form/Form.tsx +0 -152
  119. package/src/Form/index.ts +0 -1
  120. package/src/Input/InputMask.tsx +0 -15
  121. package/src/Select/Select.tsx +0 -8
  122. package/src/Select/SelectAccountCard.tsx +0 -162
  123. package/src/Select/SelectAsync.tsx +0 -183
  124. package/src/Select/SelectBase.tsx +0 -181
  125. package/src/Select/index.ts +0 -4
  126. package/src/Switch/Switch.tsx +0 -47
  127. package/src/Switch/index.ts +0 -1
  128. package/src/Textarea/Textarea.tsx +0 -24
  129. package/src/Textarea/index.ts +0 -1
package/src/Form/Form.tsx DELETED
@@ -1,152 +0,0 @@
1
- import * as React from 'react'
2
- import * as LabelPrimitive from '@radix-ui/react-label'
3
- import { Slot } from '@radix-ui/react-slot'
4
- import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from 'react-hook-form'
5
-
6
- import { cn } from '../@/lib/utils'
7
- import { Label } from '../Label'
8
-
9
- const Form = FormProvider
10
-
11
- type FormFieldContextValue<
12
- TFieldValues extends FieldValues = FieldValues,
13
- TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
14
- > = {
15
- name: TName
16
- }
17
-
18
- const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)
19
-
20
- const FormField = <
21
- TFieldValues extends FieldValues = FieldValues,
22
- TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
23
- >({
24
- ...props
25
- }: ControllerProps<TFieldValues, TName>) => {
26
- return (
27
- <FormFieldContext.Provider value={{ name: props.name }}>
28
- <Controller {...props} />
29
- </FormFieldContext.Provider>
30
- )
31
- }
32
-
33
- const useFormField = () => {
34
- const fieldContext = React.useContext(FormFieldContext)
35
- const itemContext = React.useContext(FormItemContext)
36
- const { getFieldState, formState } = useFormContext()
37
-
38
- const fieldState = getFieldState(fieldContext.name, formState)
39
-
40
- if (!fieldContext) {
41
- throw new Error('useFormField should be used within <FormField>')
42
- }
43
-
44
- const { id } = itemContext
45
-
46
- return {
47
- id,
48
- name: fieldContext.name,
49
- formItemId: `${id}-form-item`,
50
- formDescriptionId: `${id}-form-item-description`,
51
- formMessageId: `${id}-form-item-message`,
52
- ...fieldState,
53
- }
54
- }
55
-
56
- type FormItemContextValue = {
57
- id: string
58
- }
59
-
60
- const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)
61
-
62
- const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
63
- ({ className, ...props }, ref) => {
64
- const id = React.useId()
65
-
66
- return (
67
- <FormItemContext.Provider value={{ id }}>
68
- <div
69
- ref={ref}
70
- className={cn('space-y-2', className)}
71
- {...props}
72
- />
73
- </FormItemContext.Provider>
74
- )
75
- }
76
- )
77
- FormItem.displayName = 'FormItem'
78
-
79
- const FormLabel = React.forwardRef<
80
- React.ElementRef<typeof LabelPrimitive.Root>,
81
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
82
- >(({ className, ...props }, ref) => {
83
- const { error, formItemId } = useFormField()
84
-
85
- return (
86
- <Label
87
- ref={ref}
88
- className={cn(error && 'text-destructive', className)}
89
- htmlFor={formItemId}
90
- {...props}
91
- />
92
- )
93
- })
94
- FormLabel.displayName = 'FormLabel'
95
-
96
- const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
97
- ({ ...props }, ref) => {
98
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
99
-
100
- return (
101
- <Slot
102
- ref={ref}
103
- id={formItemId}
104
- aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
105
- aria-invalid={!!error}
106
- {...props}
107
- />
108
- )
109
- }
110
- )
111
- FormControl.displayName = 'FormControl'
112
-
113
- const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
114
- ({ className, ...props }, ref) => {
115
- const { formDescriptionId } = useFormField()
116
-
117
- return (
118
- <p
119
- ref={ref}
120
- id={formDescriptionId}
121
- className={cn('text-[0.8rem] text-light', className)}
122
- {...props}
123
- />
124
- )
125
- }
126
- )
127
- FormDescription.displayName = 'FormDescription'
128
-
129
- const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
130
- ({ className, children, ...props }, ref) => {
131
- const { error, formMessageId } = useFormField()
132
- const body = error ? String(error?.message) : children
133
-
134
- if (!body) {
135
- return null
136
- }
137
-
138
- return (
139
- <p
140
- ref={ref}
141
- id={formMessageId}
142
- className={cn('text-[0.8rem] font-medium text-destructive', className)}
143
- {...props}
144
- >
145
- {body}
146
- </p>
147
- )
148
- }
149
- )
150
- FormMessage.displayName = 'FormMessage'
151
-
152
- export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField }
package/src/Form/index.ts DELETED
@@ -1 +0,0 @@
1
- export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from './Form'
@@ -1,15 +0,0 @@
1
- import * as React from 'react'
2
- import { IMaskInput } from 'react-imask'
3
-
4
- const inputClasses = 'form-input border-input file:border-0 bg-transparent font-normal file:bg-transparent disabled:opacity-50 border rounded-sm focus-visible:ring-1 focus-visible:ring-ring w-full h-[44px] file:font-medium file:text-sm placeholder:text-muted-foreground leading-[1.17] transition-colors focus-visible:outline-none disabled:cursor-not-allowed'
5
-
6
- const InputMask: React.FC = ({ ...props }) => {
7
- return (
8
- <IMaskInput
9
- className={inputClasses}
10
- {...props}
11
- />
12
- )
13
- }
14
-
15
- export { InputMask }
@@ -1,8 +0,0 @@
1
- import * as React from 'react'
2
- import { SelectBase } from './SelectBase'
3
-
4
- const Select: React.FC = (props) => {
5
- return <SelectBase {...props}/>
6
- }
7
-
8
- export { Select }
@@ -1,162 +0,0 @@
1
- import * as React from 'react'
2
-
3
- import { DropdownSmallOld, CheckSmall } from '../Icon'
4
-
5
- import Select, {
6
- components,
7
- ControlProps,
8
- OptionProps,
9
- DropdownIndicatorProps,
10
- StylesConfig,
11
- SingleValueProps,
12
- MenuProps,
13
- ValueContainerProps,
14
- } from 'react-select'
15
-
16
- import { cn } from '../@/lib/utils'
17
-
18
- const selectTriggerClasses: string =
19
- 'flex items-center bg-gradient-to-r from-[--cl-blue-3] to-primary shadow-[0px_8px_18px_0px_rgba(73,113,208,0.38)] px-[16px] py-[8px] border-none rounded-md min-h-[80px] text-left text-white cursor-pointer'
20
-
21
- const colourStyles: StylesConfig = {
22
- control: () => ({}),
23
- option: () => ({}),
24
- input: () => ({}),
25
- dropdownIndicator: () => ({}),
26
- indicatorsContainer: () => ({}),
27
- menu: () => ({}),
28
- menuList: () => ({}),
29
- singleValue: () => ({}),
30
- valueContainer: () => ({}),
31
- }
32
-
33
- const Control = ({ children, ...props }: ControlProps) => {
34
- const { isFocused } = props
35
- return (
36
- <components.Control
37
- className={cn(
38
- selectTriggerClasses,
39
- { 'outline outline-primary outline-offset-2 outline-2': isFocused }
40
- )}
41
- {...props}
42
- >
43
- {children}
44
- </components.Control>
45
- )
46
- }
47
-
48
- const optionClasses =
49
- 'flex items-center first:rounded-t-md last:rounded-b-md px-[12px] py-[16px] w-full cursor-default select-none outline-none'
50
-
51
- const Option = ({ children, ...props }: OptionProps) => {
52
- const {
53
- isSelected,
54
- isFocused,
55
- isDisabled,
56
- // @ts-ignore
57
- data: { label, account, balance, cur },
58
- } = props
59
- return (
60
- <components.Option
61
- className={cn(optionClasses, { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
62
- {...props}
63
- >
64
- <span className="flex basis-0 grow">
65
- <span>
66
- <span>{label}</span>
67
- <br />
68
- <span className="text-[14px] text-light">{account}</span>
69
- </span>
70
- <span className="ml-auto shrink-0">
71
- {balance}&nbsp;{cur}
72
- </span>
73
- </span>
74
-
75
- <span className="ml-[16px] w-[24px] h-[24px] shrink-0">
76
- {isSelected && (
77
- <CheckSmall
78
- width="24"
79
- height="24"
80
- className="text-primary"
81
- />
82
- )}
83
- </span>
84
- </components.Option>
85
- )
86
- }
87
-
88
- const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
89
- return (
90
- <components.DropdownIndicator
91
- className="shrink-0"
92
- {...props}
93
- >
94
- <DropdownSmallOld
95
- className="text-white"
96
- width="16"
97
- height="16"
98
- />
99
- </components.DropdownIndicator>
100
- )
101
- }
102
-
103
- const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
104
- return (
105
- <components.ValueContainer
106
- className="flex-1 grid"
107
- {...props}
108
- >
109
- {children}
110
- </components.ValueContainer>
111
- )
112
- }
113
-
114
- const SingleValue = ({ children, ...props }: SingleValueProps) => {
115
- // @ts-ignore
116
- const { label, account, balance, cur } = props.data
117
- return (
118
- <components.SingleValue
119
- className="col-start-1 col-end-3 row-start-1 row-end-2"
120
- {...props}
121
- >
122
- <span className="block max-w-full text-[16px] truncate leading-[1.5]">
123
- {label} <span className="opacity-75 text-[14px] leading-[1.42]">{account}</span>
124
- </span>
125
- <span className="block mt-[8px] font-medium text-[24px] leading-[1.333]">
126
- {balance} {cur}
127
- </span>
128
- </components.SingleValue>
129
- )
130
- }
131
-
132
- const Menu = ({ children, ...props }: MenuProps) => {
133
- return (
134
- <components.Menu
135
- className="z-[1] absolute inset-x-0 bg-page shadow-md mt-[8px] rounded-md"
136
- {...props}
137
- >
138
- {children}
139
- </components.Menu>
140
- )
141
- }
142
-
143
- const SelectAccountCard = React.forwardRef<Select>(({ ...props }, ref) => (
144
- <Select
145
- isSearchable={false}
146
- components={{
147
- Control,
148
- Option,
149
- SingleValue,
150
- DropdownIndicator,
151
- IndicatorSeparator: () => null,
152
- Menu,
153
- ValueContainer,
154
- }}
155
- styles={colourStyles}
156
- unstyled={true}
157
- {...props}
158
- />
159
- ))
160
-
161
-
162
- export { SelectAccountCard }
@@ -1,183 +0,0 @@
1
- import * as React from 'react'
2
-
3
- import { DropdownSmallOld, CheckSmall } from '../Icon'
4
-
5
- import {
6
- components,
7
- ControlProps,
8
- OptionProps,
9
- DropdownIndicatorProps,
10
- StylesConfig,
11
- SingleValueProps,
12
- MenuProps,
13
- PlaceholderProps,
14
- ValueContainerProps,
15
- InputProps,
16
- LoadingIndicatorProps,
17
- IndicatorsContainerProps,
18
- } from 'react-select'
19
-
20
- import AsyncSelect from 'react-select/async'
21
-
22
- import { cn } from '../@/lib/utils'
23
-
24
- const selectTriggerClasses: string =
25
- 'flex items-center border-[1px] border-input rounded-sm h-[44px] text-left px-[16px] py-[12px] cursor-pointer'
26
-
27
- const colourStyles: StylesConfig = {
28
- control: () => ({}),
29
- option: () => ({}),
30
- input: () => ({}),
31
- dropdownIndicator: () => ({}),
32
- indicatorsContainer: () => ({}),
33
- menu: () => ({}),
34
- menuList: () => ({}),
35
- singleValue: () => ({}),
36
- valueContainer: () => ({}),
37
- }
38
-
39
- const Input = ({...props }: InputProps) => {
40
- return <components.Input className='col-start-1 col-end-3 row-start-1 row-end-2' {...props} />
41
- }
42
-
43
- const Control = ({ children, ...props }: ControlProps) => {
44
- const { isFocused } = props
45
- return (
46
- <components.Control
47
- className={cn(selectTriggerClasses, { 'outline outline-primary outline-offset-2 outline-2': isFocused })}
48
- {...props}
49
- >
50
- {children}
51
- </components.Control>
52
- )
53
- }
54
-
55
- const optionClasses =
56
- 'flex items-center first:rounded-t-sm last:rounded-b-sm px-[16px] py-[12px] w-full cursor-default select-none outline-none'
57
-
58
- const Option = ({ children, ...props }: OptionProps) => {
59
- const {
60
- isSelected,
61
- isFocused,
62
- isDisabled,
63
- } = props
64
- return (
65
- <components.Option
66
- className={cn(optionClasses, { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
67
- {...props}
68
- >
69
- <span className="flex basis-0 grow">{children}</span>
70
-
71
- <span className="ml-[16px] w-[24px] h-[24px] shrink-0">
72
- {isSelected && (
73
- <CheckSmall
74
- width="24"
75
- height="24"
76
- className="text-primary"
77
- />
78
- )}
79
- </span>
80
- </components.Option>
81
- )
82
- }
83
-
84
- const IndicatorsContainer = ({ children, ...props }: IndicatorsContainerProps) => {
85
- return (
86
- <components.IndicatorsContainer className='flex items-center gap-x-[8px] shrink-0' {...props}>
87
- {children}
88
- </components.IndicatorsContainer>
89
- )
90
- }
91
-
92
- const LoadingIndicator = ({...props }: LoadingIndicatorProps) => {
93
- return (
94
- <components.LoadingIndicator
95
- className='text-light shrink-0'
96
- {...props}
97
- />
98
- )
99
- }
100
-
101
- const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
102
- return (
103
- <components.DropdownIndicator
104
- className="shrink-0"
105
- {...props}
106
- >
107
- <DropdownSmallOld
108
- className="text-light"
109
- width="12"
110
- height="12"
111
- />
112
- </components.DropdownIndicator>
113
- )
114
- }
115
-
116
- const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
117
- return (
118
- <components.ValueContainer
119
- className="flex-1 grid"
120
- {...props}
121
- >
122
- {children}
123
- </components.ValueContainer>
124
- )
125
- }
126
-
127
- const SingleValue = ({ children, ...props }: SingleValueProps) => {
128
- return (
129
- <components.SingleValue
130
- className="col-start-1 col-end-3 row-start-1 row-end-2"
131
- {...props}
132
- >
133
- {children}
134
- </components.SingleValue>
135
- )
136
- }
137
-
138
- const Menu = ({ children, ...props }: MenuProps) => {
139
- return (
140
- <components.Menu
141
- className="z-[1] absolute inset-x-0 bg-page shadow-sm mt-[8px] rounded-sm"
142
- {...props}
143
- >
144
- {children}
145
- </components.Menu>
146
- )
147
- }
148
-
149
- const Placeholder = ({ children, ...props }: PlaceholderProps) => {
150
- return (
151
- <components.Placeholder
152
- className="col-start-1 col-end-3 row-start-1 row-end-2 text-[16px] text-light truncate"
153
- {...props}
154
- >
155
- {children}
156
- </components.Placeholder>
157
- )
158
- }
159
-
160
- const SelectAsync = ({ ...props }) => (
161
- <AsyncSelect
162
- components={{
163
- Control,
164
- Option,
165
- SingleValue,
166
- DropdownIndicator,
167
- IndicatorSeparator: () => null,
168
- Menu,
169
- ValueContainer,
170
- Placeholder,
171
- Input,
172
- LoadingIndicator,
173
- IndicatorsContainer
174
- }}
175
- styles={colourStyles}
176
- unstyled={true}
177
- {...props}
178
- />
179
- )
180
-
181
- SelectAsync.displayName = 'SelectAsync'
182
-
183
- export { SelectAsync }
@@ -1,181 +0,0 @@
1
- import * as React from 'react'
2
-
3
- import { DropdownSmallOld, CheckSmall } from '../Icon'
4
-
5
- import Select, {
6
- components,
7
- ControlProps,
8
- OptionProps,
9
- DropdownIndicatorProps,
10
- StylesConfig,
11
- SingleValueProps,
12
- MenuProps,
13
- PlaceholderProps,
14
- ValueContainerProps,
15
- InputProps,
16
- LoadingIndicatorProps,
17
- IndicatorsContainerProps,
18
- } from 'react-select'
19
-
20
- import { cn } from '../@/lib/utils'
21
-
22
- const selectTriggerClasses: string =
23
- 'flex items-center border-[1px] border-input rounded-sm h-[44px] text-left px-[16px] py-[12px] cursor-pointer'
24
-
25
- const colourStyles: StylesConfig = {
26
- control: () => ({}),
27
- option: () => ({}),
28
- input: () => ({}),
29
- dropdownIndicator: () => ({}),
30
- indicatorsContainer: () => ({}),
31
- menu: () => ({}),
32
- menuList: () => ({}),
33
- singleValue: () => ({}),
34
- valueContainer: () => ({}),
35
- }
36
-
37
- const Input = ({...props }: InputProps) => {
38
- return <components.Input className='col-start-1 col-end-3 row-start-1 row-end-2' {...props} />
39
- }
40
-
41
- const Control = ({ children, ...props }: ControlProps) => {
42
- const { isFocused } = props
43
- return (
44
- <components.Control
45
- className={cn(selectTriggerClasses, { 'outline outline-primary outline-offset-2 outline-2': isFocused })}
46
- {...props}
47
- >
48
- {children}
49
- </components.Control>
50
- )
51
- }
52
-
53
- const optionClasses =
54
- 'flex items-center first:rounded-t-sm last:rounded-b-sm px-[16px] py-[12px] w-full cursor-default select-none outline-none'
55
-
56
- const Option = ({ children, ...props }: OptionProps) => {
57
- const {
58
- isSelected,
59
- isFocused,
60
- isDisabled,
61
- } = props
62
- return (
63
- <components.Option
64
- className={cn(optionClasses, { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
65
- {...props}
66
- >
67
- <span className="flex basis-0 grow">{children}</span>
68
-
69
- <span className="ml-[16px] w-[24px] h-[24px] shrink-0">
70
- {isSelected && (
71
- <CheckSmall
72
- width="24"
73
- height="24"
74
- className="text-primary"
75
- />
76
- )}
77
- </span>
78
- </components.Option>
79
- )
80
- }
81
-
82
- const IndicatorsContainer = ({ children, ...props }: IndicatorsContainerProps) => {
83
- return (
84
- <components.IndicatorsContainer className='flex items-center gap-x-[8px] shrink-0' {...props}>
85
- {children}
86
- </components.IndicatorsContainer>
87
- )
88
- }
89
-
90
- const LoadingIndicator = ({...props }: LoadingIndicatorProps) => {
91
- return (
92
- <components.LoadingIndicator
93
- className='text-light shrink-0'
94
- {...props}
95
- />
96
- )
97
- }
98
-
99
- const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
100
- return (
101
- <components.DropdownIndicator
102
- className="shrink-0"
103
- {...props}
104
- >
105
- <DropdownSmallOld
106
- className="text-light"
107
- width="12"
108
- height="12"
109
- />
110
- </components.DropdownIndicator>
111
- )
112
- }
113
-
114
- const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
115
- return (
116
- <components.ValueContainer
117
- className="flex-1 grid"
118
- {...props}
119
- >
120
- {children}
121
- </components.ValueContainer>
122
- )
123
- }
124
-
125
- const SingleValue = ({ children, ...props }: SingleValueProps) => {
126
- return (
127
- <components.SingleValue
128
- className="col-start-1 col-end-3 row-start-1 row-end-2"
129
- {...props}
130
- >
131
- {children}
132
- </components.SingleValue>
133
- )
134
- }
135
-
136
- const Menu = ({ children, ...props }: MenuProps) => {
137
- return (
138
- <components.Menu
139
- className="z-[1] absolute inset-x-0 bg-page shadow-sm mt-[8px] rounded-sm"
140
- {...props}
141
- >
142
- {children}
143
- </components.Menu>
144
- )
145
- }
146
-
147
- const Placeholder = ({ children, ...props }: PlaceholderProps) => {
148
- return (
149
- <components.Placeholder
150
- className="col-start-1 col-end-3 row-start-1 row-end-2 text-[16px] text-light truncate"
151
- {...props}
152
- >
153
- {children}
154
- </components.Placeholder>
155
- )
156
- }
157
-
158
- const SelectBase = (props) => (
159
- <Select
160
- components={{
161
- Control,
162
- Option,
163
- SingleValue,
164
- DropdownIndicator,
165
- IndicatorSeparator: () => null,
166
- Menu,
167
- ValueContainer,
168
- Placeholder,
169
- Input,
170
- LoadingIndicator,
171
- IndicatorsContainer
172
- }}
173
- styles={colourStyles}
174
- unstyled={true}
175
- {...props}
176
- />
177
- )
178
-
179
- SelectBase.displayName = 'SelectBase'
180
-
181
- export { SelectBase }
@@ -1,4 +0,0 @@
1
- export { SelectAccountCard } from './SelectAccountCard'
2
- export { SelectAsync } from './SelectAsync'
3
- export { SelectBase } from './SelectBase'
4
- export { Select } from './Select'