@modul/mbui 0.0.12-beta-pv-53064-e5c99806 → 0.0.13-beta-pv-53036-bbe30888

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 (78) hide show
  1. package/dist/{Info/Info.d.ts → Alert/Alert.d.ts} +4 -4
  2. package/dist/{Info/Info.js → Alert/Alert.js} +7 -7
  3. package/dist/Alert/Alert.js.map +1 -0
  4. package/dist/Alert/index.d.ts +1 -0
  5. package/dist/Alert/index.js +6 -0
  6. package/dist/Alert/index.js.map +1 -0
  7. package/dist/Collapsible/AccountCollapsible.js +2 -2
  8. package/dist/Collapsible/AccountCollapsible.js.map +1 -1
  9. package/dist/Icon/icons/AddList.js.map +1 -1
  10. package/dist/Input/Input.js +1 -1
  11. package/dist/Input/Input.js.map +1 -1
  12. package/dist/Label/Label.d.ts +5 -0
  13. package/dist/Label/Label.js +13 -0
  14. package/dist/Label/Label.js.map +1 -0
  15. package/dist/Label/index.d.ts +1 -0
  16. package/dist/Label/index.js +6 -0
  17. package/dist/Label/index.js.map +1 -0
  18. package/dist/Page/Page.js +4 -2
  19. package/dist/Page/Page.js.map +1 -1
  20. package/dist/Select/SelectAccountCard.d.ts +6 -0
  21. package/dist/Select/SelectAccountCard.js +76 -0
  22. package/dist/Select/SelectAccountCard.js.map +1 -0
  23. package/dist/Select/index.d.ts +1 -0
  24. package/dist/Select/index.js +6 -0
  25. package/dist/Select/index.js.map +1 -0
  26. package/dist/Switch/Switch.d.ts +4 -0
  27. package/dist/Switch/Switch.js +12 -0
  28. package/dist/Switch/Switch.js.map +1 -0
  29. package/dist/Switch/index.d.ts +1 -0
  30. package/dist/Switch/index.js +6 -0
  31. package/dist/Switch/index.js.map +1 -0
  32. package/dist/Textarea/Textarea.d.ts +5 -0
  33. package/dist/Textarea/Textarea.js +12 -0
  34. package/dist/Textarea/Textarea.js.map +1 -0
  35. package/dist/Textarea/index.d.ts +1 -0
  36. package/dist/Textarea/index.js +6 -0
  37. package/dist/Textarea/index.js.map +1 -0
  38. package/dist/index.d.ts +22 -19
  39. package/dist/index.js +14 -8
  40. package/dist/index.js.map +1 -1
  41. package/package.json +8 -2
  42. package/src/@/config/index.ts +4 -2
  43. package/src/{Info/Info.tsx → Alert/Alert.tsx} +6 -6
  44. package/src/Alert/index.ts +1 -0
  45. package/src/Collapsible/AccountCollapsible.tsx +2 -2
  46. package/src/Form/Form.tsx +152 -0
  47. package/src/Form/index.ts +1 -0
  48. package/src/Icon/icons/AddList.tsx +1 -0
  49. package/src/Input/Input.tsx +1 -1
  50. package/src/Page/Page.tsx +22 -11
  51. package/src/Select/SelectAccountCard.tsx +163 -0
  52. package/src/Select/index.ts +1 -0
  53. package/src/Switch/Switch.tsx +28 -0
  54. package/src/Switch/index.ts +1 -0
  55. package/src/Textarea/Textarea.tsx +24 -0
  56. package/src/Textarea/index.ts +1 -0
  57. package/src/assets/css/global.css +153 -162
  58. package/src/index.ts +32 -40
  59. package/dist/Base/Input/Base.d.ts +0 -4
  60. package/dist/Base/Input/Base.js +0 -20
  61. package/dist/Base/Input/Base.js.map +0 -1
  62. package/dist/Base/Input/Input.d.ts +0 -4
  63. package/dist/Base/Input/Input.js +0 -18
  64. package/dist/Base/Input/Input.js.map +0 -1
  65. package/dist/Base/Input/index.d.ts +0 -2
  66. package/dist/Base/Input/index.js +0 -7
  67. package/dist/Base/Input/index.js.map +0 -1
  68. package/dist/Base/Input/types.d.ts +0 -9
  69. package/dist/Base/Input/types.js +0 -3
  70. package/dist/Base/Input/types.js.map +0 -1
  71. package/dist/Info/Info.js.map +0 -1
  72. package/dist/Info/index.d.ts +0 -1
  73. package/dist/Info/index.js +0 -6
  74. package/dist/Info/index.js.map +0 -1
  75. package/src/Collapsible/Collapse1 copy.tsx +0 -88
  76. package/src/DrawerCompanyList/CompanyList.tsx +0 -63
  77. package/src/DrawerCompanyList/index.ts +0 -1
  78. package/src/Info/index.ts +0 -1
@@ -0,0 +1,152 @@
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-muted-foreground', 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 }
@@ -0,0 +1 @@
1
+ export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from './Form'
@@ -15,4 +15,5 @@ const SvgAddList = (props: SVGProps<SVGSVGElement>) => (
15
15
  />
16
16
  </SvgIcon>
17
17
  )
18
+
18
19
  export default SvgAddList
@@ -21,7 +21,7 @@ const InputField = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<
21
21
  <input
22
22
  type={type}
23
23
  className={cn(
24
- 'border-input file:border-0 bg-transparent font-normal file:bg-transparent disabled:opacity-50 border rounded-1 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',
24
+ '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',
25
25
  className
26
26
  )}
27
27
  ref={ref}
package/src/Page/Page.tsx CHANGED
@@ -5,27 +5,38 @@ type IProps = {
5
5
  children?: React.ReactNode
6
6
  className?: string
7
7
  }
8
-
9
- const Navbar: FC = ({ children, className }: IProps) => {
10
- return <div className={cn('flex items-center h-[44px] px-[20px]', className)}>{children}</div>
11
- }
12
-
13
- const Content: FC = ({ children, className }: IProps) => {
14
- return <div className={cn('px-[20px]', className)}>{children}</div>
15
- }
16
-
17
8
  interface IPage extends FC<IProps> {
18
9
  displayName: string
19
10
  Navbar: FC<IProps>
20
11
  Content: FC<IProps>
21
12
  }
13
+ const Navbar: FC<IProps> = ({ children, className }) => {
14
+ return <div className={cn('flex items-center h-[44px] px-[20px]', className)}>{children}</div>
15
+ }
16
+
17
+ const Content: FC<IProps> = ({ children, className }) => {
18
+ return <div className={cn('px-[20px] py-[16px] overflow-y-auto', className)}>{children}</div>
19
+ }
22
20
 
23
21
  const Page: IPage = ({ children, className }: IProps) => {
24
- return <div className={cn('sm:container grid grid-cols-[minmax(0,_1fr)] grid-rows-[min-content_1fr_min-content] bg-page h-screen', className)}>{children}</div>
22
+ return (
23
+ <div
24
+ className={cn(
25
+ 'sm:container grid grid-cols-[minmax(0,_1fr)] grid-rows-[min-content_1fr_min-content] bg-page h-screen',
26
+ className
27
+ )}
28
+ >
29
+ {children}
30
+ </div>
31
+ )
25
32
  }
26
33
 
27
34
  Page.displayName = 'Page'
35
+
28
36
  Page.Navbar = Navbar
37
+ Page.Navbar.displayName = 'Page.Navbar'
38
+
29
39
  Page.Content = Content
40
+ Page.Content.displayName = "Page.Content"
30
41
 
31
- export { Page }
42
+ export { Page }
@@ -0,0 +1,163 @@
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'
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 style = { cursor: 'pointer' }
35
+ return (
36
+ <components.Control
37
+ className={selectTriggerClasses}
38
+ {...props}
39
+ >
40
+ {children}
41
+ </components.Control>
42
+ )
43
+ }
44
+
45
+ const optionClasses =
46
+ 'flex items-center first:rounded-t-md last:rounded-b-md px-[12px] py-[16px] w-full cursor-default select-none outline-none'
47
+
48
+ const Option = ({ children, ...props }: OptionProps) => {
49
+ const {
50
+ isSelected,
51
+ isFocused,
52
+ isDisabled,
53
+ // @ts-ignore
54
+ data : { label, account, balance, cur },
55
+ } = props
56
+ const style = { cursor: 'pointer' }
57
+ return (
58
+ <components.Option
59
+ className={cn(
60
+ optionClasses,
61
+ { 'bg-light': isFocused },
62
+ { 'opacity-50 pointer-events-none': isDisabled }
63
+ )}
64
+ {...props}
65
+ >
66
+ <span className="flex basis-0 grow">
67
+ <span>
68
+ <span>{label}</span><br/>
69
+ <span className='text-[14px] text-light'>{account}</span>
70
+ </span>
71
+ <span className='ml-auto shrink-0'>
72
+ {balance}&nbsp;{cur}
73
+ </span>
74
+ </span>
75
+
76
+ <span className='ml-[16px] w-[24px] h-[24px] shrink-0'>
77
+ {isSelected && (
78
+ <CheckSmall
79
+ width="24"
80
+ height="24"
81
+ className="text-primary"
82
+ />
83
+ )}
84
+ </span>
85
+
86
+ </components.Option>
87
+ )
88
+ }
89
+
90
+ const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
91
+ return (
92
+ <components.DropdownIndicator
93
+ className="shrink-0"
94
+ {...props}
95
+ >
96
+ <DropdownSmallOld
97
+ className="text-white"
98
+ width="16"
99
+ height="16"
100
+ />
101
+ </components.DropdownIndicator>
102
+ )
103
+ }
104
+
105
+ const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
106
+ return (
107
+ <components.ValueContainer
108
+ className="flex-1 grid"
109
+ {...props}
110
+ >
111
+ {children}
112
+ </components.ValueContainer>
113
+ )
114
+ }
115
+
116
+ const SingleValue = ({ children, ...props }: SingleValueProps) => {
117
+ // @ts-ignore
118
+ const { label, account, balance, cur } = props.data
119
+ return (
120
+ <components.SingleValue className='col-start-1 col-end-3 row-start-1 row-end-2' {...props}>
121
+ <span className="block max-w-full text-[16px] truncate leading-[1.5]">
122
+ {label} <span className="opacity-75 text-[14px] leading-[1.42]">{account}</span>
123
+ </span>
124
+ <span className="block mt-[8px] font-medium text-[24px] leading-[1.333]">
125
+ {balance} {cur}
126
+ </span>
127
+ </components.SingleValue>
128
+ )
129
+ }
130
+
131
+ const Menu = ({ children, ...props }: MenuProps) => {
132
+ return (
133
+ <components.Menu
134
+ className="bg-page drop-shadow-1 mt-[8px] rounded-md"
135
+ {...props}
136
+ >
137
+ {children}
138
+ </components.Menu>
139
+ )
140
+ }
141
+
142
+ const SelectAccountCard = React.forwardRef<Select, { className: string | undefined }>(({ className, ...props }, ref) => (
143
+ <Select
144
+ className={cn(className)}
145
+ classNamePrefix="super"
146
+ isDisabled={false}
147
+ isSearchable={false}
148
+ components={{
149
+ Control,
150
+ Option,
151
+ SingleValue,
152
+ DropdownIndicator,
153
+ IndicatorSeparator: () => null,
154
+ Menu,
155
+ ValueContainer,
156
+ }}
157
+ styles={colourStyles}
158
+ unstyled={true}
159
+ {...props}
160
+ />
161
+ ))
162
+
163
+ export { SelectAccountCard }
@@ -0,0 +1 @@
1
+ export { SelectAccountCard } from './SelectAccountCard'
@@ -0,0 +1,28 @@
1
+
2
+ import * as React from "react"
3
+ import * as SwitchPrimitives from "@radix-ui/react-switch"
4
+
5
+ import { cn } from "../@/lib/utils"
6
+
7
+ const Switch = React.forwardRef<
8
+ React.ElementRef<typeof SwitchPrimitives.Root>,
9
+ React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
10
+ >(({ className, ...props }, ref) => (
11
+ <SwitchPrimitives.Root
12
+ className={cn(
13
+ "peer inline-flex h-5 w-9 shrink-0 cursor-pointer border-light items-center rounded-full border-2 shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
14
+ className
15
+ )}
16
+ {...props}
17
+ ref={ref}
18
+ >
19
+ <SwitchPrimitives.Thumb
20
+ className={cn(
21
+ "pointer-events-none block h-4 w-4 rounded-full bg-light shadow-md ring-0 transition-transform data-[state=checked]:bg-page data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
22
+ )}
23
+ />
24
+ </SwitchPrimitives.Root>
25
+ ))
26
+ Switch.displayName = SwitchPrimitives.Root.displayName
27
+
28
+ export { Switch }
@@ -0,0 +1 @@
1
+ export { Switch } from './Switch'
@@ -0,0 +1,24 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "../@/lib/utils"
4
+
5
+ export interface TextareaProps
6
+ extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
7
+
8
+ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
9
+ ({ className, ...props }, ref) => {
10
+ return (
11
+ <textarea
12
+ className={cn(
13
+ "flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 placeholder:text-light focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
14
+ className
15
+ )}
16
+ ref={ref}
17
+ {...props}
18
+ />
19
+ )
20
+ }
21
+ )
22
+ Textarea.displayName = "Textarea"
23
+
24
+ export { Textarea }
@@ -0,0 +1 @@
1
+ export { Textarea } from './Textarea'