@dhis2-ui/button 8.15.1 → 8.16.0-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -183,10 +183,8 @@ DropdownButton.propTypes = {
|
|
183
183
|
component: _propTypes2.default.element,
|
184
184
|
dataTest: _propTypes2.default.string,
|
185
185
|
|
186
|
-
/**
|
187
|
-
|
188
|
-
*/
|
189
|
-
destructive: _propTypes2.default.bool,
|
186
|
+
/** Button variant. Mutually exclusive with `primary` and `secondary` props */
|
187
|
+
destructive: _uiConstants.sharedPropTypes.buttonVariantPropType,
|
190
188
|
|
191
189
|
/** Make the button non-interactive */
|
192
190
|
disabled: _propTypes2.default.bool,
|
@@ -202,15 +200,11 @@ DropdownButton.propTypes = {
|
|
202
200
|
/** Controls popper visibility. When implementing this prop the component becomes a controlled component */
|
203
201
|
open: _propTypes2.default.bool,
|
204
202
|
|
205
|
-
/**
|
206
|
-
|
207
|
-
*/
|
208
|
-
primary: _propTypes2.default.bool,
|
203
|
+
/** Button variant. Mutually exclusive with `destructive` and `secondary` props */
|
204
|
+
primary: _uiConstants.sharedPropTypes.buttonVariantPropType,
|
209
205
|
|
210
|
-
/**
|
211
|
-
|
212
|
-
*/
|
213
|
-
secondary: _propTypes2.default.bool,
|
206
|
+
/** Button variant. Mutually exclusive with `primary` and `destructive` props */
|
207
|
+
secondary: _uiConstants.sharedPropTypes.buttonVariantPropType,
|
214
208
|
|
215
209
|
/** Button size. Mutually exclusive with `large` prop */
|
216
210
|
small: _uiConstants.sharedPropTypes.sizePropType,
|
@@ -146,10 +146,8 @@ SplitButton.propTypes = {
|
|
146
146
|
component: _propTypes.default.element,
|
147
147
|
dataTest: _propTypes.default.string,
|
148
148
|
|
149
|
-
/**
|
150
|
-
|
151
|
-
*/
|
152
|
-
destructive: _propTypes.default.bool,
|
149
|
+
/** Applies 'destructive' appearance to indicate purpose. Mutually exclusive with `primary` and `secondary` props */
|
150
|
+
destructive: _uiConstants.sharedPropTypes.buttonVariantPropType,
|
153
151
|
|
154
152
|
/** Disables the button and makes it uninteractive */
|
155
153
|
disabled: _propTypes.default.bool,
|
@@ -164,15 +162,11 @@ SplitButton.propTypes = {
|
|
164
162
|
large: _uiConstants.sharedPropTypes.sizePropType,
|
165
163
|
name: _propTypes.default.string,
|
166
164
|
|
167
|
-
/**
|
168
|
-
|
169
|
-
*/
|
170
|
-
primary: _propTypes.default.bool,
|
165
|
+
/** Applies 'primary' appearance to indicate purpose. Mutually exclusive with `destructive` and `secondary` props */
|
166
|
+
primary: _uiConstants.sharedPropTypes.buttonVariantPropType,
|
171
167
|
|
172
|
-
/**
|
173
|
-
|
174
|
-
*/
|
175
|
-
secondary: _propTypes.default.bool,
|
168
|
+
/** Applies 'secondary' appearance to indicate purpose. Mutually exclusive with `primary` and `destructive` props */
|
169
|
+
secondary: _uiConstants.sharedPropTypes.buttonVariantPropType,
|
176
170
|
|
177
171
|
/** Changes button size. Mutually exclusive with `large` prop */
|
178
172
|
small: _uiConstants.sharedPropTypes.sizePropType,
|
@@ -163,10 +163,8 @@ DropdownButton.propTypes = {
|
|
163
163
|
component: PropTypes.element,
|
164
164
|
dataTest: PropTypes.string,
|
165
165
|
|
166
|
-
/**
|
167
|
-
|
168
|
-
*/
|
169
|
-
destructive: PropTypes.bool,
|
166
|
+
/** Button variant. Mutually exclusive with `primary` and `secondary` props */
|
167
|
+
destructive: sharedPropTypes.buttonVariantPropType,
|
170
168
|
|
171
169
|
/** Make the button non-interactive */
|
172
170
|
disabled: PropTypes.bool,
|
@@ -182,15 +180,11 @@ DropdownButton.propTypes = {
|
|
182
180
|
/** Controls popper visibility. When implementing this prop the component becomes a controlled component */
|
183
181
|
open: PropTypes.bool,
|
184
182
|
|
185
|
-
/**
|
186
|
-
|
187
|
-
*/
|
188
|
-
primary: PropTypes.bool,
|
183
|
+
/** Button variant. Mutually exclusive with `destructive` and `secondary` props */
|
184
|
+
primary: sharedPropTypes.buttonVariantPropType,
|
189
185
|
|
190
|
-
/**
|
191
|
-
|
192
|
-
*/
|
193
|
-
secondary: PropTypes.bool,
|
186
|
+
/** Button variant. Mutually exclusive with `primary` and `destructive` props */
|
187
|
+
secondary: sharedPropTypes.buttonVariantPropType,
|
194
188
|
|
195
189
|
/** Button size. Mutually exclusive with `large` prop */
|
196
190
|
small: sharedPropTypes.sizePropType,
|
@@ -124,10 +124,8 @@ SplitButton.propTypes = {
|
|
124
124
|
component: PropTypes.element,
|
125
125
|
dataTest: PropTypes.string,
|
126
126
|
|
127
|
-
/**
|
128
|
-
|
129
|
-
*/
|
130
|
-
destructive: PropTypes.bool,
|
127
|
+
/** Applies 'destructive' appearance to indicate purpose. Mutually exclusive with `primary` and `secondary` props */
|
128
|
+
destructive: sharedPropTypes.buttonVariantPropType,
|
131
129
|
|
132
130
|
/** Disables the button and makes it uninteractive */
|
133
131
|
disabled: PropTypes.bool,
|
@@ -142,15 +140,11 @@ SplitButton.propTypes = {
|
|
142
140
|
large: sharedPropTypes.sizePropType,
|
143
141
|
name: PropTypes.string,
|
144
142
|
|
145
|
-
/**
|
146
|
-
|
147
|
-
*/
|
148
|
-
primary: PropTypes.bool,
|
143
|
+
/** Applies 'primary' appearance to indicate purpose. Mutually exclusive with `destructive` and `secondary` props */
|
144
|
+
primary: sharedPropTypes.buttonVariantPropType,
|
149
145
|
|
150
|
-
/**
|
151
|
-
|
152
|
-
*/
|
153
|
-
secondary: PropTypes.bool,
|
146
|
+
/** Applies 'secondary' appearance to indicate purpose. Mutually exclusive with `primary` and `destructive` props */
|
147
|
+
secondary: sharedPropTypes.buttonVariantPropType,
|
154
148
|
|
155
149
|
/** Changes button size. Mutually exclusive with `large` prop */
|
156
150
|
small: sharedPropTypes.sizePropType,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dhis2-ui/button",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.16.0-alpha.1",
|
4
4
|
"description": "UI Button",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -13,6 +13,7 @@
|
|
13
13
|
"main": "./build/cjs/index.js",
|
14
14
|
"module": "./build/es/index.js",
|
15
15
|
"exports": {
|
16
|
+
"types": "./types/index.d.ts",
|
16
17
|
"import": "./build/es/index.js",
|
17
18
|
"require": "./build/cjs/index.js"
|
18
19
|
},
|
@@ -32,20 +33,22 @@
|
|
32
33
|
},
|
33
34
|
"dependencies": {
|
34
35
|
"@dhis2/prop-types": "^3.1.2",
|
35
|
-
"@dhis2-ui/layer": "8.
|
36
|
-
"@dhis2-ui/loader": "8.
|
37
|
-
"@dhis2-ui/popper": "8.
|
38
|
-
"@dhis2/ui-constants": "8.
|
39
|
-
"@dhis2/ui-icons": "8.
|
36
|
+
"@dhis2-ui/layer": "8.16.0-alpha.1",
|
37
|
+
"@dhis2-ui/loader": "8.16.0-alpha.1",
|
38
|
+
"@dhis2-ui/popper": "8.16.0-alpha.1",
|
39
|
+
"@dhis2/ui-constants": "8.16.0-alpha.1",
|
40
|
+
"@dhis2/ui-icons": "8.16.0-alpha.1",
|
40
41
|
"classnames": "^2.3.1",
|
41
42
|
"prop-types": "^15.7.2"
|
42
43
|
},
|
43
44
|
"files": [
|
44
|
-
"build"
|
45
|
+
"build",
|
46
|
+
"types"
|
45
47
|
],
|
46
48
|
"devDependencies": {
|
47
49
|
"react": "16.13",
|
48
50
|
"react-dom": "16.13",
|
49
51
|
"styled-jsx": "^4.0.1"
|
50
|
-
}
|
52
|
+
},
|
53
|
+
"types": "types"
|
51
54
|
}
|
package/types/index.d.ts
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
import * as React from 'react'
|
2
|
+
|
3
|
+
export type ButtonType = 'submit' | 'reset' | 'button'
|
4
|
+
|
5
|
+
export interface ButtonEventPayload {
|
6
|
+
value?: string
|
7
|
+
name?: string
|
8
|
+
}
|
9
|
+
|
10
|
+
type ButtonEventHandler<Event extends React.SyntheticEvent> = (
|
11
|
+
arg0: ButtonEventPayload,
|
12
|
+
event: Event
|
13
|
+
) => void
|
14
|
+
|
15
|
+
type ButtonOpenEventHandler<
|
16
|
+
Event extends React.SyntheticEvent = React.MouseEvent<HTMLButtonElement>
|
17
|
+
> = (arg0: ButtonEventPayload & { open: boolean }, event: Event) => void
|
18
|
+
|
19
|
+
export interface ButtonProps {
|
20
|
+
/**
|
21
|
+
* Component to render inside the button
|
22
|
+
*/
|
23
|
+
children?: React.ReactNode
|
24
|
+
/**
|
25
|
+
* A className that will be passed to the `<button>` element
|
26
|
+
*/
|
27
|
+
className?: string
|
28
|
+
/**
|
29
|
+
* A string that will be applied as a `data-test` attribute on the button element
|
30
|
+
* for identification during testing
|
31
|
+
*/
|
32
|
+
dataTest?: string
|
33
|
+
/**
|
34
|
+
* Indicates that the button makes potentially dangerous
|
35
|
+
* deletions or data changes.
|
36
|
+
* Mutually exclusive with `primary` and `secondary` props
|
37
|
+
*/
|
38
|
+
destructive?: boolean
|
39
|
+
/**
|
40
|
+
* Applies a greyed-out appearance and makes the button non-interactive
|
41
|
+
*/
|
42
|
+
disabled?: boolean
|
43
|
+
/**
|
44
|
+
* An icon element to display inside the button
|
45
|
+
*/
|
46
|
+
icon?: React.ReactElement
|
47
|
+
/**
|
48
|
+
* Use this variant to capture the initial focus on the page.
|
49
|
+
*/
|
50
|
+
initialFocus?: boolean
|
51
|
+
/**
|
52
|
+
* Makes the button large. Mutually exclusive with `small`
|
53
|
+
*/
|
54
|
+
large?: boolean
|
55
|
+
/**
|
56
|
+
* Sets the button into a loading state
|
57
|
+
*/
|
58
|
+
loading?: boolean
|
59
|
+
/**
|
60
|
+
* Sets `name` attribute on button element.
|
61
|
+
* Gets passed as part of the first argument to callbacks (see `onClick`).
|
62
|
+
*/
|
63
|
+
name?: string
|
64
|
+
/**
|
65
|
+
* Applies 'primary' button appearance.
|
66
|
+
* Mutually exclusive with `destructive` and `secondary` props
|
67
|
+
*/
|
68
|
+
primary?: boolean
|
69
|
+
/**
|
70
|
+
* Applies 'secondary' button appearance.
|
71
|
+
* Mutually exclusive with `primary` and `destructive` props
|
72
|
+
*/
|
73
|
+
secondary?: boolean
|
74
|
+
/**
|
75
|
+
* Makes the button small. Mutually exclusive with `large` prop
|
76
|
+
*/
|
77
|
+
small?: boolean
|
78
|
+
/**
|
79
|
+
* Tab index for focusing the button with a keyboard
|
80
|
+
*/
|
81
|
+
tabIndex?: string
|
82
|
+
/**
|
83
|
+
* Changes appearance of button to an on/off state
|
84
|
+
*/
|
85
|
+
toggled?: boolean
|
86
|
+
/**
|
87
|
+
* Sets `type` attribute on `<button>` element
|
88
|
+
*/
|
89
|
+
type?: ButtonType
|
90
|
+
/**
|
91
|
+
* Value associated with the button.
|
92
|
+
* Gets passed as part of the first argument to callbacks (see `onClick`).
|
93
|
+
*/
|
94
|
+
value?: string
|
95
|
+
/**
|
96
|
+
* Callback to trigger on de-focus (blur).
|
97
|
+
* Called with same args as `onClick`
|
98
|
+
*/
|
99
|
+
onBlur?: ButtonEventHandler<React.FocusEvent<HTMLButtonElement>>
|
100
|
+
/**
|
101
|
+
* Callback to trigger on click.
|
102
|
+
* Called with args `({ value, name }, event)`
|
103
|
+
*/
|
104
|
+
onClick?: ButtonEventHandler<React.MouseEvent<HTMLButtonElement>>
|
105
|
+
/**
|
106
|
+
* Callback to trigger on focus. Called with same args as `onClick`
|
107
|
+
*/
|
108
|
+
onFocus?: ButtonEventHandler<React.FocusEvent<HTMLButtonElement>>
|
109
|
+
/**
|
110
|
+
* Callback to trigger on key-down. Called with same args as `onClick`
|
111
|
+
*/
|
112
|
+
onKeyDown?: ButtonEventHandler<React.KeyboardEvent<HTMLButtonElement>>
|
113
|
+
}
|
114
|
+
|
115
|
+
export const Button: React.FC<ButtonProps>
|
116
|
+
|
117
|
+
export interface ButtonStripProps {
|
118
|
+
children?: React.ReactNode
|
119
|
+
className?: string
|
120
|
+
dataTest?: string
|
121
|
+
/**
|
122
|
+
* Horizontal alignment for buttons. Mutually exclusive with `middle` prop
|
123
|
+
*/
|
124
|
+
end?: boolean
|
125
|
+
/**
|
126
|
+
* Horizontal alignment. Mutually exclusive with `end` prop
|
127
|
+
*/
|
128
|
+
middle?: boolean
|
129
|
+
}
|
130
|
+
|
131
|
+
export const ButtonStrip: React.FC<ButtonStripProps>
|
132
|
+
|
133
|
+
export type DropdownButtonType = 'submit' | 'reset' | 'button'
|
134
|
+
|
135
|
+
export interface DropdownButtonProps {
|
136
|
+
/**
|
137
|
+
* Children to render inside the buton
|
138
|
+
*/
|
139
|
+
children?: React.ReactNode
|
140
|
+
className?: string
|
141
|
+
/**
|
142
|
+
* Component to show/hide when button is clicked
|
143
|
+
*/
|
144
|
+
component?: React.ReactElement<any>
|
145
|
+
dataTest?: string
|
146
|
+
/**
|
147
|
+
* Button variant. Mutually exclusive with `primary` and `secondary` props
|
148
|
+
*/
|
149
|
+
destructive?: boolean
|
150
|
+
/**
|
151
|
+
* Make the button non-interactive
|
152
|
+
*/
|
153
|
+
disabled?: boolean
|
154
|
+
icon?: React.ReactElement<any>
|
155
|
+
/**
|
156
|
+
* Grants button initial focus on the page
|
157
|
+
*/
|
158
|
+
initialFocus?: boolean
|
159
|
+
/**
|
160
|
+
* Button size. Mutually exclusive with `small` prop
|
161
|
+
*/
|
162
|
+
large?: boolean
|
163
|
+
name?: string
|
164
|
+
/**
|
165
|
+
* Controls popper visibility. When implementing this prop the component becomes a controlled component
|
166
|
+
*/
|
167
|
+
open?: boolean
|
168
|
+
/**
|
169
|
+
* Button variant. Mutually exclusive with `destructive` and `secondary` props
|
170
|
+
*/
|
171
|
+
primary?: boolean
|
172
|
+
/**
|
173
|
+
* Button variant. Mutually exclusive with `primary` and `destructive` props
|
174
|
+
*/
|
175
|
+
secondary?: boolean
|
176
|
+
/**
|
177
|
+
* Button size. Mutually exclusive with `large` prop
|
178
|
+
*/
|
179
|
+
small?: boolean
|
180
|
+
tabIndex?: string
|
181
|
+
/**
|
182
|
+
* Type of button. Can take advantage of different default behavior
|
183
|
+
*/
|
184
|
+
type?: DropdownButtonType
|
185
|
+
value?: string
|
186
|
+
/**
|
187
|
+
* Callback triggered on click.
|
188
|
+
* Called with signature `({ name: string, value: string, open: bool }, event)`
|
189
|
+
* Is required when using the `open` prop to override the internal
|
190
|
+
* state.
|
191
|
+
*/
|
192
|
+
onClick?: ButtonOpenEventHandler
|
193
|
+
}
|
194
|
+
|
195
|
+
export class DropdownButton extends React.Component<DropdownButtonProps, any> {
|
196
|
+
render(): JSX.Element
|
197
|
+
}
|
198
|
+
|
199
|
+
export type SplitButtonType = 'submit' | 'reset' | 'button'
|
200
|
+
|
201
|
+
export interface SplitButtonProps {
|
202
|
+
children?: string
|
203
|
+
className?: string
|
204
|
+
/**
|
205
|
+
* Component to render when the dropdown is opened
|
206
|
+
*/
|
207
|
+
component?: React.ReactElement<any>
|
208
|
+
dataTest?: string
|
209
|
+
/**
|
210
|
+
* Applies 'destructive' appearance to indicate purpose. Mutually exclusive with `primary` and `secondary` props
|
211
|
+
*/
|
212
|
+
destructive?: boolean
|
213
|
+
/**
|
214
|
+
* Disables the button and makes it uninteractive
|
215
|
+
*/
|
216
|
+
disabled?: boolean
|
217
|
+
/**
|
218
|
+
* An icon to add inside the button
|
219
|
+
*/
|
220
|
+
icon?: React.ReactElement<any>
|
221
|
+
/**
|
222
|
+
* Grants the button the initial focus
|
223
|
+
*/
|
224
|
+
initialFocus?: boolean
|
225
|
+
/**
|
226
|
+
* Changes button size. Mutually exclusive with `small` prop
|
227
|
+
*/
|
228
|
+
large?: boolean
|
229
|
+
name?: string
|
230
|
+
/**
|
231
|
+
* Applies 'primary' appearance to indicate purpose. Mutually exclusive with `destructive` and `secondary` props
|
232
|
+
*/
|
233
|
+
primary?: boolean
|
234
|
+
/**
|
235
|
+
* Applies 'secondary' appearance to indicate purpose. Mutually exclusive with `primary` and `destructive` props
|
236
|
+
*/
|
237
|
+
secondary?: boolean
|
238
|
+
/**
|
239
|
+
* Changes button size. Mutually exclusive with `large` prop
|
240
|
+
*/
|
241
|
+
small?: boolean
|
242
|
+
tabIndex?: string
|
243
|
+
/**
|
244
|
+
* Type of button. Applied to html `button` element
|
245
|
+
*/
|
246
|
+
type?: SplitButtonType
|
247
|
+
/**
|
248
|
+
* Value associated with the button. Passed in object to onClick handler
|
249
|
+
*/
|
250
|
+
value?: string
|
251
|
+
onClick?: ButtonOpenEventHandler
|
252
|
+
}
|
253
|
+
|
254
|
+
export class SplitButton extends React.Component<SplitButtonProps, any> {
|
255
|
+
render(): JSX.Element
|
256
|
+
}
|