@modul/mbui 0.0.20-beta-pv-53154-4403aebc → 0.0.21

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,uCAAmC;AAwDlC,wFAxDQ,iBAAO,OAwDR;AAvDR,iCAA6B;AAwD5B,qFAxDQ,WAAI,OAwDR;AAvDL,qCAAiC;AAwDhC,uFAxDQ,eAAM,OAwDR;AAvDP,uCAAmC;AAwDlC,wFAxDQ,iBAAO,OAwDR;AAvDR,+DAAyB;AAwDxB,eAxDM,cAAI,CAwDN;AAvDL,2CAAsF;AAwDrF,yFAxDQ,oBAAQ,OAwDR;AACR,8FAzDkB,yBAAa,OAyDlB;AACb,6FA1DiC,wBAAY,OA0DjC;AACZ,kGA3D+C,6BAAiB,OA2D/C;AA1DlB,yDAK2B;AA0E1B,iGA9EA,mCAAgB,OA8EA;AAChB,qGA9EA,uCAAoB,OA8EA;AACpB,yGA9EA,2CAAwB,OA8EA;AACxB,qGA9EA,uCAAoB,OA8EA;AA5ErB,0DAA8B;AAmE7B,oBAAI;AAlEL,+CAAmF;AAoDlF,4FApDQ,yBAAW,OAoDR;AACX,mGArDqB,gCAAkB,OAqDrB;AAClB,mGAtDyC,gCAAkB,OAsDzC;AArDnB,+CAMsB;AAgDrB,mGArDA,gCAAkB,OAqDA;AAClB,yGArDA,sCAAwB,OAqDA;AACxB,0GArDA,uCAAyB,OAqDA;AACzB,0GArDA,uCAAyB,OAqDA;AACzB,8GArDA,2CAA6B,OAqDA;AAnD9B,qCAA+D;AAoD9D,uFApDQ,eAAM,OAoDR;AACN,+FArDgB,uBAAc,OAqDhB;AAoDd,6FAzGgC,qBAAY,OAyGhC;AAxGb,mCAA+B;AAuD9B,sFAvDQ,aAAK,OAuDR;AAtDN,yCAAkC;AAuDjC,mFAvDQ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gGAvE2D,sBAAe,OAuE3D;AACf,4FAxE4E,kBAAW,OAwE5E;AAvEZ,yCAAqC;AAwEpC,yFAxEQ,mBAAQ,OAwER;AAvET,6CAAyC;AAwExC,2FAxEQ,uBAAU,OAwER;AAvEX,yCAAqC;AAsDpC,yFAtDQ,mBAAQ,OAsDR;AArDT,+CAUsB;AA8DrB,4FAvEA,yBAAW,OAuEA;AACX,mGAvEA,gCAAkB,OAuEA;AAClB,mGAvEA,gCAAkB,OAuEA;AAClB,kGAvEA,+BAAiB,OAuEA;AACjB,kGAvEA,+BAAiB,OAuEA;AACjB,iGAvEA,8BAAgB,OAuEA;AAChB,uGAvEA,oCAAsB,OAuEA;AACtB,kGAvEA,+BAAiB,OAuEA;AACjB,kGAvEA,+BAAiB,OAuEA;AArElB,iCAAsC;AAsErC,8FAtEQ,oBAAa,OAsER;AArEd,uDAAiI;AAsEhI,qGAtEQ,sCAAoB,OAsER;AACpB,qGAvE8B,sCAAoB,OAuE9B;AACpB,4GAxEoD,6CAA2B,OAwEpD;AAC3B,qGAzEiF,sCAAoB,OAyEjF;AAxErB,+CAA2C;AA2E1C,4FA3EQ,yBAAW,OA2ER;AA1EZ,mCAA8C;AAwE7C,sFAxEQ,aAAK,OAwER;AACL,8FAzEe,qBAAa,OAyEf;AAxEd,uCAA0C;AA2EzC,wFA3EQ,iBAAO,OA2ER;AACP,sFA5EiB,eAAK,OA4EjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modul/mbui",
3
- "version": "0.0.20-beta-pv-53154-4403aebc",
3
+ "version": "0.0.21",
4
4
  "packageManager": "yarn@3.5.1",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -3,15 +3,15 @@ import type { SVGProps } from 'react'
3
3
  import { SvgIcon } from '../SvgIcon'
4
4
  const SvgShare = (props: SVGProps<SVGSVGElement>) => (
5
5
  <SvgIcon
6
- width={20}
7
- height={20}
6
+ width={24}
7
+ height={24}
8
8
  fill="none"
9
- viewBox="0 0 20 20"
9
+ viewBox="0 0 24 24"
10
10
  {...props}
11
11
  >
12
12
  <path
13
13
  fill="currentColor"
14
- d="M16 18H4c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h6c.55 0 1 .45 1 1s-.45 1-1 1H4v12h12v-4c0-.55.45-1 1-1s1 .45 1 1v4c0 1.1-.9 2-2 2m1.71-12.71-3-3c-.39-.39-1.03-.39-1.42 0s-.39 1.03 0 1.42l1.3 1.3C10.37 5.23 7 8.73 7 13c0 .55.45 1 1 1s1-.45 1-1c0-3.16 2.45-5.76 5.56-5.98l-1.27 1.27c-.39.39-.39 1.03 0 1.42.41.39 1.02.38 1.42 0l3-3c.39-.39.39-1.03 0-1.42"
14
+ d="M19 23H5c-1.1 0-2-.9-2-2V10c0-1.1.9-2 2-2h3c.55 0 1 .45 1 1s-.45 1-1 1H5v11h14V10h-3c-.55 0-1-.45-1-1s.45-1 1-1h3c1.1 0 2 .9 2 2v11c0 1.1-.9 2-2 2ZM15.71 4.29l-3-3a.9959.9959 0 0 0-1.41 0l-3 3c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L11 4.41V15c0 .55.45 1 1 1s1-.45 1-1V4.41l1.29 1.29c.39.39 1.02.39 1.41 0 .4-.38.4-1.02.01-1.41Z"
15
15
  />
16
16
  </SvgIcon>
17
17
  )
@@ -0,0 +1,101 @@
1
+ import * as React from 'react'
2
+ import { CheckSmall } from '../../src/Icon'
3
+ import Select, { components, OptionProps, SingleValueProps, GroupBase, Props } from 'react-select'
4
+ import { cn } from '../@/lib/utils'
5
+ import {
6
+ colourStyles,
7
+ Control,
8
+ DropdownIndicator,
9
+ IndicatorsContainer,
10
+ Input,
11
+ LoadingIndicator,
12
+ Menu,
13
+ optionClasses,
14
+ Placeholder,
15
+ ValueContainer,
16
+ } from './components'
17
+
18
+ const Option = ({ children, ...props }: OptionProps) => {
19
+ const {
20
+ isSelected,
21
+ isFocused,
22
+ isDisabled,
23
+ // @ts-ignore
24
+ data: { label, account, balance, cur },
25
+ } = props
26
+ return (
27
+ <components.Option
28
+ className={cn(optionClasses, 'items-start', { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
29
+ {...props}
30
+ >
31
+ <span className="flex basis-0 grow">
32
+ <span>
33
+ <span className="text-[16px`] leading-[1.375]">{label}</span>
34
+ <br />
35
+ <span className="text-[12px] text-light">{account}</span>
36
+ </span>
37
+ <span className="ml-auto shrink-0">{cur}</span>
38
+ </span>
39
+
40
+ <span className="ml-[16px] shrink-0 size-[24px]">
41
+ {isSelected && (
42
+ <CheckSmall
43
+ width="24"
44
+ height="24"
45
+ className="text-primary"
46
+ />
47
+ )}
48
+ </span>
49
+ </components.Option>
50
+ )
51
+ }
52
+
53
+ const SingleValue = ({ children, ...props }: SingleValueProps) => {
54
+ const {
55
+ // @ts-ignore
56
+ data: { account, cur },
57
+ } = props
58
+ return (
59
+ <components.SingleValue
60
+ className="col-start-1 col-end-3 row-start-1 row-end-2"
61
+ {...props}
62
+ >
63
+ {account} ({cur})
64
+ </components.SingleValue>
65
+ )
66
+ }
67
+
68
+ type SelectAccountProps<
69
+ Option,
70
+ IsMulti extends boolean = false,
71
+ Group extends GroupBase<Option> = GroupBase<Option>
72
+ > = Props<Option, IsMulti, Group>
73
+
74
+ function SelectAccount<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
75
+ props: SelectAccountProps<Option, IsMulti, Group>
76
+ ) {
77
+ return (
78
+ <Select
79
+ components={{
80
+ Control,
81
+ Option,
82
+ SingleValue,
83
+ DropdownIndicator,
84
+ IndicatorSeparator: () => null,
85
+ Menu,
86
+ ValueContainer,
87
+ Placeholder,
88
+ Input,
89
+ LoadingIndicator,
90
+ IndicatorsContainer,
91
+ }}
92
+ styles={colourStyles}
93
+ unstyled={true}
94
+ {...props}
95
+ />
96
+ )
97
+ }
98
+
99
+ SelectAccount.displayName = 'SelectAccount'
100
+
101
+ export { SelectAccount }
@@ -5,14 +5,12 @@ import Select, {
5
5
  ControlProps,
6
6
  OptionProps,
7
7
  DropdownIndicatorProps,
8
- StylesConfig,
9
8
  SingleValueProps,
10
- MenuProps,
11
- ValueContainerProps,
12
9
  Props,
13
10
  GroupBase,
14
11
  } from 'react-select'
15
12
  import { cn } from '../@/lib/utils'
13
+ import { colourStyles, Menu, optionClasses, ValueContainer } from './components'
16
14
 
17
15
  const selectTriggerClasses: string = `
18
16
  flex
@@ -30,19 +28,6 @@ const selectTriggerClasses: string = `
30
28
  shadow-[0px_8px_18px_0px_rgba(73,113,208,0.38)]
31
29
  cursor-pointer
32
30
  `
33
-
34
- const colourStyles: StylesConfig = {
35
- control: () => ({}),
36
- option: () => ({}),
37
- input: () => ({}),
38
- dropdownIndicator: () => ({}),
39
- indicatorsContainer: () => ({}),
40
- menu: () => ({}),
41
- menuList: () => ({}),
42
- singleValue: () => ({}),
43
- valueContainer: () => ({}),
44
- }
45
-
46
31
  const Control = ({ children, ...props }: ControlProps) => {
47
32
  const { isFocused } = props
48
33
  return (
@@ -58,19 +43,6 @@ const Control = ({ children, ...props }: ControlProps) => {
58
43
  )
59
44
  }
60
45
 
61
- const optionClasses = `
62
- flex
63
- items-center
64
- py-[16px]
65
- px-[12px]
66
- w-full
67
- first:rounded-t-md
68
- last:rounded-b-md
69
- cursor-default
70
- select-none
71
- outline-none
72
- `
73
-
74
46
  const Option = ({ children, ...props }: OptionProps) => {
75
47
  const {
76
48
  isSelected,
@@ -123,17 +95,6 @@ const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
123
95
  )
124
96
  }
125
97
 
126
- const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
127
- return (
128
- <components.ValueContainer
129
- className="flex-1 grid"
130
- {...props}
131
- >
132
- {children}
133
- </components.ValueContainer>
134
- )
135
- }
136
-
137
98
  const SingleValue = ({ children, ...props }: SingleValueProps) => {
138
99
  // @ts-ignore
139
100
  const { label, account, balance, cur } = props.data
@@ -152,17 +113,6 @@ const SingleValue = ({ children, ...props }: SingleValueProps) => {
152
113
  )
153
114
  }
154
115
 
155
- const Menu = ({ children, ...props }: MenuProps) => {
156
- return (
157
- <components.Menu
158
- className="z-[1] absolute inset-x-0 bg-page shadow-md mt-[8px] rounded-md"
159
- {...props}
160
- >
161
- {children}
162
- </components.Menu>
163
- )
164
- }
165
-
166
116
  type SelectAccountCardProps<
167
117
  Option,
168
118
  IsMulti extends boolean = false,
@@ -1,167 +1,6 @@
1
1
  import * as React from 'react'
2
- import { DropdownSmallOld, CheckSmall } from '../../src/Icon'
3
- import {
4
- components,
5
- ControlProps,
6
- OptionProps,
7
- DropdownIndicatorProps,
8
- StylesConfig,
9
- SingleValueProps,
10
- MenuProps,
11
- PlaceholderProps,
12
- ValueContainerProps,
13
- InputProps,
14
- LoadingIndicatorProps,
15
- IndicatorsContainerProps,
16
- } from 'react-select'
17
2
  import AsyncSelect from 'react-select/async'
18
- import { cn } from '../@/lib/utils'
19
-
20
- const selectTriggerClasses: string = `
21
- flex
22
- items-center
23
- py-[12px]
24
- px-[16px]
25
- h-[44px]
26
- border-[1px]
27
- border-input
28
- rounded-sm
29
- text-left
30
- cursor-pointer
31
- `
32
-
33
- const colourStyles: StylesConfig = {
34
- control: () => ({}),
35
- option: () => ({}),
36
- input: () => ({}),
37
- dropdownIndicator: () => ({}),
38
- indicatorsContainer: () => ({}),
39
- menu: () => ({}),
40
- menuList: () => ({}),
41
- singleValue: () => ({}),
42
- valueContainer: () => ({}),
43
- }
44
-
45
- const Input = ({...props }: InputProps) => {
46
- return <components.Input className='col-start-1 col-end-3 row-start-1 row-end-2' {...props} />
47
- }
48
-
49
- const Control = ({ children, ...props }: ControlProps) => {
50
- const { isFocused } = props
51
- return (
52
- <components.Control
53
- className={cn(selectTriggerClasses, { 'outline outline-primary outline-offset-2 outline-2': isFocused })}
54
- {...props}
55
- >
56
- {children}
57
- </components.Control>
58
- )
59
- }
60
-
61
- const optionClasses =
62
- 'flex items-center first:rounded-t-sm last:rounded-b-sm px-[16px] py-[12px] w-full cursor-default select-none outline-none'
63
-
64
- const Option = ({ children, ...props }: OptionProps) => {
65
- const {
66
- isSelected,
67
- isFocused,
68
- isDisabled,
69
- } = props
70
- return (
71
- <components.Option
72
- className={cn(optionClasses, { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
73
- {...props}
74
- >
75
- <span className="flex basis-0 grow">{children}</span>
76
-
77
- <span className="ml-[16px] shrink-0 size-[24px]">
78
- {isSelected && (
79
- <CheckSmall
80
- width="24"
81
- height="24"
82
- className="text-primary"
83
- />
84
- )}
85
- </span>
86
- </components.Option>
87
- )
88
- }
89
-
90
- const IndicatorsContainer = ({ children, ...props }: IndicatorsContainerProps) => {
91
- return (
92
- <components.IndicatorsContainer className='flex items-center gap-x-[8px] shrink-0' {...props}>
93
- {children}
94
- </components.IndicatorsContainer>
95
- )
96
- }
97
-
98
- const LoadingIndicator = ({...props }: LoadingIndicatorProps) => {
99
- return (
100
- <components.LoadingIndicator
101
- className='text-light shrink-0'
102
- {...props}
103
- />
104
- )
105
- }
106
-
107
- const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
108
- return (
109
- <components.DropdownIndicator
110
- className="shrink-0"
111
- {...props}
112
- >
113
- <DropdownSmallOld
114
- className="text-light"
115
- width="12"
116
- height="12"
117
- />
118
- </components.DropdownIndicator>
119
- )
120
- }
121
-
122
- const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
123
- return (
124
- <components.ValueContainer
125
- className="flex-1 grid"
126
- {...props}
127
- >
128
- {children}
129
- </components.ValueContainer>
130
- )
131
- }
132
-
133
- const SingleValue = ({ children, ...props }: SingleValueProps) => {
134
- return (
135
- <components.SingleValue
136
- className="col-start-1 col-end-3 row-start-1 row-end-2"
137
- {...props}
138
- >
139
- {children}
140
- </components.SingleValue>
141
- )
142
- }
143
-
144
- const Menu = ({ children, ...props }: MenuProps) => {
145
- return (
146
- <components.Menu
147
- className="z-[1] absolute inset-x-0 bg-page shadow-sm mt-[8px] rounded-sm"
148
- {...props}
149
- >
150
- {children}
151
- </components.Menu>
152
- )
153
- }
154
-
155
- const Placeholder = ({ children, ...props }: PlaceholderProps) => {
156
- return (
157
- <components.Placeholder
158
- className="col-start-1 col-end-3 row-start-1 row-end-2 text-[16px] text-light truncate"
159
- {...props}
160
- >
161
- {children}
162
- </components.Placeholder>
163
- )
164
- }
3
+ import { colourStyles, Control, DropdownIndicator, IndicatorsContainer, Input, LoadingIndicator, Menu, Option, Placeholder, SingleValue, ValueContainer } from './components'
165
4
 
166
5
  const SelectAsync = ({ ...props }) => (
167
6
  <AsyncSelect
@@ -1,169 +1,22 @@
1
1
  import * as React from 'react'
2
2
 
3
- import { DropdownSmallOld, CheckSmall } from '../../src/Icon'
4
-
5
3
  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, GroupBase, Props,
4
+ GroupBase,
5
+ Props,
18
6
  } from 'react-select'
19
-
20
- import { cn } from '../@/lib/utils'
21
-
22
- const selectTriggerClasses: string = `
23
- flex
24
- items-center
25
- py-[12px]
26
- px-[16px]
27
- h-[44px]
28
- text-left
29
- border-[1px]
30
- border-input
31
- rounded-sm
32
- cursor-pointer
33
- `
34
-
35
- const colourStyles: StylesConfig = {
36
- control: () => ({}),
37
- option: () => ({}),
38
- input: () => ({}),
39
- dropdownIndicator: () => ({}),
40
- indicatorsContainer: () => ({}),
41
- menu: () => ({}),
42
- menuList: () => ({}),
43
- singleValue: () => ({}),
44
- valueContainer: () => ({}),
45
- }
46
-
47
- const Input = ({...props }: InputProps) => {
48
- return <components.Input className='col-start-1 col-end-3 row-start-1 row-end-2' {...props} />
49
- }
50
-
51
- const Control = ({ children, ...props }: ControlProps) => {
52
- const { isFocused } = props
53
- return (
54
- <components.Control
55
- className={cn(selectTriggerClasses, { 'outline outline-primary outline-offset-2 outline-2': isFocused })}
56
- {...props}
57
- >
58
- {children}
59
- </components.Control>
60
- )
61
- }
62
-
63
- const optionClasses =
64
- 'flex items-center first:rounded-t-sm last:rounded-b-sm px-[16px] py-[12px] w-full cursor-default select-none outline-none'
65
-
66
- const Option = ({ children, ...props }: OptionProps) => {
67
- const {
68
- isSelected,
69
- isFocused,
70
- isDisabled,
71
- } = props
72
- return (
73
- <components.Option
74
- className={cn(optionClasses, { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
75
- {...props}
76
- >
77
- <span className="flex basis-0 grow">{children}</span>
78
-
79
- <span className="ml-[16px] shrink-0 size-[24px]">
80
- {isSelected && (
81
- <CheckSmall
82
- width="24"
83
- height="24"
84
- className="text-primary"
85
- />
86
- )}
87
- </span>
88
- </components.Option>
89
- )
90
- }
91
-
92
- const IndicatorsContainer = ({ children, ...props }: IndicatorsContainerProps) => {
93
- return (
94
- <components.IndicatorsContainer className='flex items-center gap-x-[8px] shrink-0' {...props}>
95
- {children}
96
- </components.IndicatorsContainer>
97
- )
98
- }
99
-
100
- const LoadingIndicator = ({...props }: LoadingIndicatorProps) => {
101
- return (
102
- <components.LoadingIndicator
103
- className='text-light shrink-0'
104
- {...props}
105
- />
106
- )
107
- }
108
-
109
- const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
110
- return (
111
- <components.DropdownIndicator
112
- className="shrink-0"
113
- {...props}
114
- >
115
- <DropdownSmallOld
116
- className="text-light"
117
- width="12"
118
- height="12"
119
- />
120
- </components.DropdownIndicator>
121
- )
122
- }
123
-
124
- const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
125
- return (
126
- <components.ValueContainer
127
- className="flex-1 grid"
128
- {...props}
129
- >
130
- {children}
131
- </components.ValueContainer>
132
- )
133
- }
134
-
135
- const SingleValue = ({ children, ...props }: SingleValueProps) => {
136
- return (
137
- <components.SingleValue
138
- className="col-start-1 col-end-3 row-start-1 row-end-2"
139
- {...props}
140
- >
141
- {children}
142
- </components.SingleValue>
143
- )
144
- }
145
-
146
- const Menu = ({ children, ...props }: MenuProps) => {
147
- return (
148
- <components.Menu
149
- className="z-[1] absolute inset-x-0 bg-page shadow-sm mt-[8px] rounded-sm"
150
- {...props}
151
- >
152
- {children}
153
- </components.Menu>
154
- )
155
- }
156
-
157
- const Placeholder = ({ children, ...props }: PlaceholderProps) => {
158
- return (
159
- <components.Placeholder
160
- className="col-start-1 col-end-3 row-start-1 row-end-2 text-[16px] text-light truncate"
161
- {...props}
162
- >
163
- {children}
164
- </components.Placeholder>
165
- )
166
- }
7
+ import {
8
+ colourStyles,
9
+ Control,
10
+ DropdownIndicator,
11
+ IndicatorsContainer,
12
+ Input,
13
+ LoadingIndicator,
14
+ Menu,
15
+ Placeholder,
16
+ SingleValue,
17
+ ValueContainer,
18
+ Option,
19
+ } from './components'
167
20
 
168
21
  type SelectBaseProps<
169
22
  Option,
@@ -171,11 +24,9 @@ type SelectBaseProps<
171
24
  Group extends GroupBase<Option> = GroupBase<Option>
172
25
  > = Props<Option, IsMulti, Group>
173
26
 
174
- function SelectBase<
175
- Option,
176
- IsMulti extends boolean = false,
177
- Group extends GroupBase<Option> = GroupBase<Option>
178
- >(props: SelectBaseProps<Option, IsMulti, Group>) {
27
+ function SelectBase<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
28
+ props: SelectBaseProps<Option, IsMulti, Group>
29
+ ) {
179
30
  return (
180
31
  <Select
181
32
  components={{
@@ -189,7 +40,7 @@ function SelectBase<
189
40
  Placeholder,
190
41
  Input,
191
42
  LoadingIndicator,
192
- IndicatorsContainer
43
+ IndicatorsContainer,
193
44
  }}
194
45
  styles={colourStyles}
195
46
  unstyled={true}