@automattic/vip-design-system 2.15.5 → 2.15.7
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/build/system/NewForm/FormAutocomplete.js +14 -1
- package/build/system/NewForm/FormAutocomplete.stories.d.ts +27 -18
- package/build/system/NewForm/FormAutocomplete.stories.jsx +6 -0
- package/build/system/NewForm/FormAutocompleteMultiselect.js +12 -5
- package/build/system/NewForm/FormAutocompleteMultiselect.stories.d.ts +1 -0
- package/build/system/NewForm/FormAutocompleteMultiselect.stories.jsx +9 -0
- package/build/system/NewForm/FormSelect.d.ts +1 -1
- package/build/system/NewForm/FormSelect.js +7 -3
- package/build/system/NewForm/FormSelect.stories.d.ts +26 -9
- package/build/system/NewForm/FormSelect.stories.jsx +8 -0
- package/build/system/Wizard/Wizard.stories.js +13 -2
- package/build/system/Wizard/WizardStep.js +17 -10
- package/package.json +1 -1
- package/src/system/NewForm/FormAutocomplete.js +14 -1
- package/src/system/NewForm/FormAutocomplete.stories.jsx +6 -0
- package/src/system/NewForm/FormAutocompleteMultiselect.js +12 -5
- package/src/system/NewForm/FormAutocompleteMultiselect.stories.jsx +9 -0
- package/src/system/NewForm/FormSelect.stories.jsx +8 -0
- package/src/system/NewForm/FormSelect.tsx +4 -2
- package/src/system/Wizard/Wizard.stories.tsx +9 -2
- package/src/system/Wizard/WizardStep.tsx +16 -11
|
@@ -85,6 +85,12 @@ const inlineStyles = {
|
|
|
85
85
|
borderWidth: 0,
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const allowCustomStyles = {
|
|
89
|
+
'& .autocomplete__option--no-results': {
|
|
90
|
+
cursor: 'pointer',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
88
94
|
const searchIconStyles = {
|
|
89
95
|
'& .autocomplete__input.autocomplete__input': {
|
|
90
96
|
paddingLeft: 6,
|
|
@@ -120,6 +126,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
120
126
|
resetOnBlur = false, // resets the input value to the selection if the input is blurred. Returns null if selection is empty
|
|
121
127
|
source,
|
|
122
128
|
value,
|
|
129
|
+
allowCustom = false,
|
|
123
130
|
...props
|
|
124
131
|
},
|
|
125
132
|
forwardRef
|
|
@@ -199,9 +206,13 @@ const FormAutocomplete = React.forwardRef(
|
|
|
199
206
|
|
|
200
207
|
const handleTypeChange = useCallback(
|
|
201
208
|
query => {
|
|
202
|
-
|
|
209
|
+
const filteredOptions = options.filter(
|
|
203
210
|
option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
|
|
204
211
|
);
|
|
212
|
+
if ( allowCustom && filteredOptions.length === 0 ) {
|
|
213
|
+
return [ { label: query, value: query } ];
|
|
214
|
+
}
|
|
215
|
+
return filteredOptions;
|
|
205
216
|
},
|
|
206
217
|
[ options ]
|
|
207
218
|
);
|
|
@@ -319,6 +330,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
319
330
|
...defaultStyles,
|
|
320
331
|
...( isInline && inlineStyles ),
|
|
321
332
|
...( searchIcon && searchIconStyles ),
|
|
333
|
+
...( allowCustom && allowCustomStyles ),
|
|
322
334
|
...( hasError ? { borderColor: 'input.border.error' } : {} ),
|
|
323
335
|
} }
|
|
324
336
|
>
|
|
@@ -382,6 +394,7 @@ FormAutocomplete.propTypes = {
|
|
|
382
394
|
source: PropTypes.func,
|
|
383
395
|
value: PropTypes.string,
|
|
384
396
|
dropdownArrow: PropTypes.node,
|
|
397
|
+
allowCustom: PropTypes.bool,
|
|
385
398
|
};
|
|
386
399
|
|
|
387
400
|
FormAutocomplete.displayName = 'FormAutocomplete';
|
|
@@ -58,42 +58,51 @@ export function Default({ label, width, ...rest }: {
|
|
|
58
58
|
export namespace Default {
|
|
59
59
|
export { args };
|
|
60
60
|
}
|
|
61
|
-
export function
|
|
61
|
+
export function WithAllowCustom({ label, width, ...rest }: {
|
|
62
62
|
[x: string]: any;
|
|
63
63
|
label?: string | undefined;
|
|
64
64
|
width?: number | undefined;
|
|
65
65
|
}): import("react").JSX.Element;
|
|
66
|
-
export namespace
|
|
66
|
+
export namespace WithAllowCustom {
|
|
67
67
|
let args_1: any;
|
|
68
68
|
export { args_1 as args };
|
|
69
69
|
}
|
|
70
|
-
export function
|
|
70
|
+
export function Inline({ label, width, ...rest }: {
|
|
71
71
|
[x: string]: any;
|
|
72
72
|
label?: string | undefined;
|
|
73
73
|
width?: number | undefined;
|
|
74
74
|
}): import("react").JSX.Element;
|
|
75
|
-
export namespace
|
|
75
|
+
export namespace Inline {
|
|
76
76
|
let args_2: any;
|
|
77
77
|
export { args_2 as args };
|
|
78
78
|
}
|
|
79
|
-
export function
|
|
79
|
+
export function WithDefaultValue({ label, width, ...rest }: {
|
|
80
80
|
[x: string]: any;
|
|
81
81
|
label?: string | undefined;
|
|
82
82
|
width?: number | undefined;
|
|
83
83
|
}): import("react").JSX.Element;
|
|
84
|
-
export namespace
|
|
84
|
+
export namespace WithDefaultValue {
|
|
85
85
|
let args_3: any;
|
|
86
86
|
export { args_3 as args };
|
|
87
87
|
}
|
|
88
|
-
export function
|
|
88
|
+
export function WithSearchIcon({ label, width, ...rest }: {
|
|
89
89
|
[x: string]: any;
|
|
90
90
|
label?: string | undefined;
|
|
91
91
|
width?: number | undefined;
|
|
92
92
|
}): import("react").JSX.Element;
|
|
93
|
-
export namespace
|
|
93
|
+
export namespace WithSearchIcon {
|
|
94
94
|
let args_4: any;
|
|
95
95
|
export { args_4 as args };
|
|
96
96
|
}
|
|
97
|
+
export function WithLoading({ label, width, ...rest }: {
|
|
98
|
+
[x: string]: any;
|
|
99
|
+
label?: string | undefined;
|
|
100
|
+
width?: number | undefined;
|
|
101
|
+
}): import("react").JSX.Element;
|
|
102
|
+
export namespace WithLoading {
|
|
103
|
+
let args_5: any;
|
|
104
|
+
export { args_5 as args };
|
|
105
|
+
}
|
|
97
106
|
export function WithDebounce(): import("react").JSX.Element;
|
|
98
107
|
export function WithSlowSearchAndDebounce({ label, width, ...rest }: {
|
|
99
108
|
[x: string]: any;
|
|
@@ -101,8 +110,8 @@ export function WithSlowSearchAndDebounce({ label, width, ...rest }: {
|
|
|
101
110
|
width?: number | undefined;
|
|
102
111
|
}): import("react").JSX.Element;
|
|
103
112
|
export namespace WithSlowSearchAndDebounce {
|
|
104
|
-
let
|
|
105
|
-
export {
|
|
113
|
+
let args_6: any;
|
|
114
|
+
export { args_6 as args };
|
|
106
115
|
}
|
|
107
116
|
export function WithCustomMessages({ label, width, ...rest }: {
|
|
108
117
|
[x: string]: any;
|
|
@@ -110,8 +119,8 @@ export function WithCustomMessages({ label, width, ...rest }: {
|
|
|
110
119
|
width?: number | undefined;
|
|
111
120
|
}): import("react").JSX.Element;
|
|
112
121
|
export namespace WithCustomMessages {
|
|
113
|
-
let
|
|
114
|
-
export {
|
|
122
|
+
let args_7: any;
|
|
123
|
+
export { args_7 as args };
|
|
115
124
|
}
|
|
116
125
|
export function WithErrors({ label, width, ...rest }: {
|
|
117
126
|
[x: string]: any;
|
|
@@ -119,8 +128,8 @@ export function WithErrors({ label, width, ...rest }: {
|
|
|
119
128
|
width?: number | undefined;
|
|
120
129
|
}): import("react").JSX.Element;
|
|
121
130
|
export namespace WithErrors {
|
|
122
|
-
let
|
|
123
|
-
export {
|
|
131
|
+
let args_8: any;
|
|
132
|
+
export { args_8 as args };
|
|
124
133
|
}
|
|
125
134
|
export function WithArrow({ label, width, ...rest }: {
|
|
126
135
|
[x: string]: any;
|
|
@@ -128,8 +137,8 @@ export function WithArrow({ label, width, ...rest }: {
|
|
|
128
137
|
width?: number | undefined;
|
|
129
138
|
}): import("react").JSX.Element;
|
|
130
139
|
export namespace WithArrow {
|
|
131
|
-
let
|
|
132
|
-
export {
|
|
140
|
+
let args_9: any;
|
|
141
|
+
export { args_9 as args };
|
|
133
142
|
}
|
|
134
143
|
export function WithCustomArrow({ label, width, ...rest }: {
|
|
135
144
|
[x: string]: any;
|
|
@@ -137,8 +146,8 @@ export function WithCustomArrow({ label, width, ...rest }: {
|
|
|
137
146
|
width?: number | undefined;
|
|
138
147
|
}): import("react").JSX.Element;
|
|
139
148
|
export namespace WithCustomArrow {
|
|
140
|
-
let
|
|
141
|
-
export {
|
|
149
|
+
let args_10: any;
|
|
150
|
+
export { args_10 as args };
|
|
142
151
|
export let displayName: string;
|
|
143
152
|
}
|
|
144
153
|
declare namespace args {
|
|
@@ -67,6 +67,12 @@ const DefaultComponent = ( { label = 'Label', width = 250, ...rest } ) => {
|
|
|
67
67
|
export const Default = DefaultComponent.bind( {} );
|
|
68
68
|
Default.args = args;
|
|
69
69
|
|
|
70
|
+
export const WithAllowCustom = DefaultComponent.bind( {} );
|
|
71
|
+
WithAllowCustom.args = {
|
|
72
|
+
...Default.args,
|
|
73
|
+
allowCustom: true,
|
|
74
|
+
};
|
|
75
|
+
|
|
70
76
|
export const Inline = DefaultComponent.bind( {} );
|
|
71
77
|
Inline.args = {
|
|
72
78
|
...Default.args,
|
|
@@ -155,6 +155,7 @@ const FormAutocompleteMultiselect = React.forwardRef(
|
|
|
155
155
|
value,
|
|
156
156
|
listType = 'button',
|
|
157
157
|
initialValue = [],
|
|
158
|
+
allowCustom = false,
|
|
158
159
|
...props
|
|
159
160
|
},
|
|
160
161
|
forwardRef
|
|
@@ -245,11 +246,16 @@ const FormAutocompleteMultiselect = React.forwardRef(
|
|
|
245
246
|
);
|
|
246
247
|
|
|
247
248
|
const handleTypeChange = useCallback(
|
|
248
|
-
query =>
|
|
249
|
-
options.filter(
|
|
249
|
+
query => {
|
|
250
|
+
const filteredOptions = options.filter(
|
|
250
251
|
option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
|
|
251
|
-
)
|
|
252
|
-
|
|
252
|
+
);
|
|
253
|
+
if ( allowCustom && filteredOptions.length === 0 ) {
|
|
254
|
+
return [ { label: query, value: query } ];
|
|
255
|
+
}
|
|
256
|
+
return filteredOptions;
|
|
257
|
+
},
|
|
258
|
+
[ options, allowCustom ]
|
|
253
259
|
);
|
|
254
260
|
|
|
255
261
|
const handleInputChange = useCallback(
|
|
@@ -384,7 +390,7 @@ const FormAutocompleteMultiselect = React.forwardRef(
|
|
|
384
390
|
</Validation>
|
|
385
391
|
) }
|
|
386
392
|
<div sx={ { fontSize: 1 } }>
|
|
387
|
-
{ selectedOptions.length } item{ selectedOptions.length
|
|
393
|
+
{ selectedOptions.length } item{ selectedOptions.length === 1 ? '' : 's' } selected
|
|
388
394
|
</div>
|
|
389
395
|
</Flex>
|
|
390
396
|
<div sx={ { display: 'inline-flex', flexWrap: 'wrap', maxWidth: '100%' } }>
|
|
@@ -428,6 +434,7 @@ FormAutocompleteMultiselect.propTypes = {
|
|
|
428
434
|
value: PropTypes.string,
|
|
429
435
|
dropdownArrow: PropTypes.node,
|
|
430
436
|
initialValue: PropTypes.array,
|
|
437
|
+
allowCustom: PropTypes.bool,
|
|
431
438
|
};
|
|
432
439
|
|
|
433
440
|
FormAutocompleteMultiselect.displayName = 'FormAutocompleteMultiselect';
|
|
@@ -29,6 +29,7 @@ declare namespace _default {
|
|
|
29
29
|
}
|
|
30
30
|
export default _default;
|
|
31
31
|
export function Default(): import("react").JSX.Element;
|
|
32
|
+
export function WithAllowCustom(): import("react").JSX.Element;
|
|
32
33
|
export function WithBadges(): import("react").JSX.Element;
|
|
33
34
|
export function WithInitialValueBadges(): import("react").JSX.Element;
|
|
34
35
|
export function Inline(): import("react").JSX.Element;
|
|
@@ -86,6 +86,15 @@ export const Default = () => {
|
|
|
86
86
|
);
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
export const WithAllowCustom = () => {
|
|
90
|
+
const customArgs = {
|
|
91
|
+
...args,
|
|
92
|
+
allowCustom: true,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return <DefaultComponent { ...customArgs } />;
|
|
96
|
+
};
|
|
97
|
+
|
|
89
98
|
export const WithBadges = () => {
|
|
90
99
|
const customArgs = {
|
|
91
100
|
...args,
|
|
@@ -10,6 +10,7 @@ interface Option {
|
|
|
10
10
|
options?: Option[];
|
|
11
11
|
}
|
|
12
12
|
interface FormSelectProps {
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
isInline?: boolean;
|
|
14
15
|
placeholder?: string;
|
|
15
16
|
forLabel?: string;
|
|
@@ -23,7 +24,6 @@ interface FormSelectProps {
|
|
|
23
24
|
errorMessage?: string;
|
|
24
25
|
wrapperSx?: ThemeUIStyleObject;
|
|
25
26
|
value?: string | number;
|
|
26
|
-
disabled?: boolean;
|
|
27
27
|
className?: string;
|
|
28
28
|
'aria-describedby'?: string;
|
|
29
29
|
'aria-required'?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["isInline", "placeholder", "forLabel", "options", "required", "label", "getOptionLabel", "getOptionValue", "onChange", "hasError", "errorMessage", "wrapperSx"],
|
|
1
|
+
var _excluded = ["disabled", "isInline", "placeholder", "forLabel", "options", "required", "label", "getOptionLabel", "getOptionValue", "onChange", "hasError", "errorMessage", "wrapperSx"],
|
|
2
2
|
_excluded2 = ["options"];
|
|
3
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
4
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -49,7 +49,8 @@ var renderGroup = function renderGroup(groupLabel, groupOptions) {
|
|
|
49
49
|
}, groupLabel);
|
|
50
50
|
};
|
|
51
51
|
var FormSelect = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
|
|
52
|
-
var
|
|
52
|
+
var disabled = _ref2.disabled,
|
|
53
|
+
isInline = _ref2.isInline,
|
|
53
54
|
placeholder = _ref2.placeholder,
|
|
54
55
|
_ref2$forLabel = _ref2.forLabel,
|
|
55
56
|
forLabel = _ref2$forLabel === void 0 ? 'vip-form-select' : _ref2$forLabel,
|
|
@@ -109,8 +110,11 @@ var FormSelect = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
|
|
|
109
110
|
children: [_jsxs("select", _extends({
|
|
110
111
|
onChange: onValueChange,
|
|
111
112
|
ref: forwardRef,
|
|
112
|
-
sx:
|
|
113
|
+
sx: _extends({
|
|
114
|
+
cursor: disabled ? 'not-allowed' : 'pointer'
|
|
115
|
+
}, defaultStyles),
|
|
113
116
|
required: required,
|
|
117
|
+
disabled: disabled,
|
|
114
118
|
"aria-required": required,
|
|
115
119
|
"aria-describedby": hasError ? "describe-" + forLabel + "-validation" : undefined,
|
|
116
120
|
id: forLabel
|
|
@@ -43,23 +43,40 @@ export namespace Default {
|
|
|
43
43
|
export { options };
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
export function
|
|
46
|
+
export function Disabled({ label, width, onChange, ...rest }: {
|
|
47
47
|
[x: string]: any;
|
|
48
48
|
label?: string | undefined;
|
|
49
49
|
width?: number | undefined;
|
|
50
50
|
onChange: any;
|
|
51
51
|
}): import("react").JSX.Element;
|
|
52
|
-
export namespace
|
|
52
|
+
export namespace Disabled {
|
|
53
53
|
export namespace args_1 {
|
|
54
54
|
let placeholder_2: string;
|
|
55
55
|
export { placeholder_2 as placeholder };
|
|
56
56
|
let required_3: boolean;
|
|
57
57
|
export { required_3 as required };
|
|
58
|
+
export let disabled: boolean;
|
|
59
|
+
export { options };
|
|
60
|
+
}
|
|
61
|
+
export { args_1 as args };
|
|
62
|
+
}
|
|
63
|
+
export function WithErrors({ label, width, onChange, ...rest }: {
|
|
64
|
+
[x: string]: any;
|
|
65
|
+
label?: string | undefined;
|
|
66
|
+
width?: number | undefined;
|
|
67
|
+
onChange: any;
|
|
68
|
+
}): import("react").JSX.Element;
|
|
69
|
+
export namespace WithErrors {
|
|
70
|
+
export namespace args_2 {
|
|
71
|
+
let placeholder_3: string;
|
|
72
|
+
export { placeholder_3 as placeholder };
|
|
73
|
+
let required_4: boolean;
|
|
74
|
+
export { required_4 as required };
|
|
58
75
|
export let hasError: boolean;
|
|
59
76
|
export let errorMessage: string;
|
|
60
77
|
export { options };
|
|
61
78
|
}
|
|
62
|
-
export {
|
|
79
|
+
export { args_2 as args };
|
|
63
80
|
}
|
|
64
81
|
export function WithGroup({ label, width, onChange, ...rest }: {
|
|
65
82
|
[x: string]: any;
|
|
@@ -68,7 +85,7 @@ export function WithGroup({ label, width, onChange, ...rest }: {
|
|
|
68
85
|
onChange: any;
|
|
69
86
|
}): import("react").JSX.Element;
|
|
70
87
|
export namespace WithGroup {
|
|
71
|
-
export namespace
|
|
88
|
+
export namespace args_3 {
|
|
72
89
|
let label_1: string;
|
|
73
90
|
export { label_1 as label };
|
|
74
91
|
let options_1: ({
|
|
@@ -83,7 +100,7 @@ export namespace WithGroup {
|
|
|
83
100
|
})[];
|
|
84
101
|
export { options_1 as options };
|
|
85
102
|
}
|
|
86
|
-
export {
|
|
103
|
+
export { args_3 as args };
|
|
87
104
|
}
|
|
88
105
|
export function IsInline({ label, width, onChange, ...rest }: {
|
|
89
106
|
[x: string]: any;
|
|
@@ -92,14 +109,14 @@ export function IsInline({ label, width, onChange, ...rest }: {
|
|
|
92
109
|
onChange: any;
|
|
93
110
|
}): import("react").JSX.Element;
|
|
94
111
|
export namespace IsInline {
|
|
95
|
-
export namespace
|
|
112
|
+
export namespace args_4 {
|
|
96
113
|
let label_2: string;
|
|
97
114
|
export { label_2 as label };
|
|
98
115
|
export let isInline: boolean;
|
|
99
116
|
export let width: string;
|
|
100
117
|
export { groupedOptions as options };
|
|
101
118
|
}
|
|
102
|
-
export {
|
|
119
|
+
export { args_4 as args };
|
|
103
120
|
}
|
|
104
121
|
export function WithOptionLabelAndValue({ label, width, onChange, ...rest }: {
|
|
105
122
|
[x: string]: any;
|
|
@@ -108,7 +125,7 @@ export function WithOptionLabelAndValue({ label, width, onChange, ...rest }: {
|
|
|
108
125
|
onChange: any;
|
|
109
126
|
}): import("react").JSX.Element;
|
|
110
127
|
export namespace WithOptionLabelAndValue {
|
|
111
|
-
export namespace
|
|
128
|
+
export namespace args_5 {
|
|
112
129
|
let label_3: string;
|
|
113
130
|
export { label_3 as label };
|
|
114
131
|
let width_1: string;
|
|
@@ -121,7 +138,7 @@ export namespace WithOptionLabelAndValue {
|
|
|
121
138
|
export function getOptionLabel(option: any): any;
|
|
122
139
|
export function getOptionValue(option: any): any;
|
|
123
140
|
}
|
|
124
|
-
export {
|
|
141
|
+
export { args_5 as args };
|
|
125
142
|
}
|
|
126
143
|
export function WithOnChange(): import("react").JSX.Element;
|
|
127
144
|
declare const options: {
|
|
@@ -76,6 +76,14 @@ Default.args = {
|
|
|
76
76
|
options,
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
export const Disabled = DefaultComponent.bind( {} );
|
|
80
|
+
Disabled.args = {
|
|
81
|
+
placeholder: '- Select -',
|
|
82
|
+
required: true,
|
|
83
|
+
disabled: true,
|
|
84
|
+
options,
|
|
85
|
+
};
|
|
86
|
+
|
|
79
87
|
export const WithErrors = DefaultComponent.bind( {} );
|
|
80
88
|
WithErrors.args = {
|
|
81
89
|
placeholder: '- Select -',
|
|
@@ -172,20 +172,31 @@ export var WithTitleAutoFocus = function WithTitleAutoFocus() {
|
|
|
172
172
|
});
|
|
173
173
|
};
|
|
174
174
|
export var HideStepText = function HideStepText() {
|
|
175
|
+
var _React$useState3 = React.useState(undefined),
|
|
176
|
+
activeStep = _React$useState3[0],
|
|
177
|
+
setActiveStep = _React$useState3[1];
|
|
175
178
|
var steps = [{
|
|
176
179
|
title: 'Included Logs',
|
|
177
180
|
titleVariant: 'h2',
|
|
178
181
|
subTitle: '',
|
|
179
182
|
children: _jsx(Text, {
|
|
183
|
+
sx: {
|
|
184
|
+
mb: 0
|
|
185
|
+
},
|
|
180
186
|
children: "Error Logs"
|
|
181
|
-
})
|
|
187
|
+
}),
|
|
188
|
+
onChange: function onChange() {
|
|
189
|
+
setActiveStep(0);
|
|
190
|
+
},
|
|
191
|
+
actionLabel: 'Edit',
|
|
192
|
+
actionIcon: _jsx(BsPencil, {})
|
|
182
193
|
}];
|
|
183
194
|
return _jsx(React.Fragment, {
|
|
184
195
|
children: _jsx(Box, {
|
|
185
196
|
mt: 4,
|
|
186
197
|
children: _jsx(Wizard, {
|
|
187
198
|
showStepText: false,
|
|
188
|
-
activeStep:
|
|
199
|
+
activeStep: activeStep,
|
|
189
200
|
steps: steps,
|
|
190
201
|
completed: [0],
|
|
191
202
|
className: "vip-wizard-xyz"
|
|
@@ -85,7 +85,8 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
|
|
|
85
85
|
},
|
|
86
86
|
borderColor: 'wizard.step.border.default',
|
|
87
87
|
borderLeftColor: borderLeftColor,
|
|
88
|
-
overflow: 'inherit'
|
|
88
|
+
overflow: 'inherit',
|
|
89
|
+
py: 1
|
|
89
90
|
},
|
|
90
91
|
"data-step": order,
|
|
91
92
|
"data-active": active || undefined,
|
|
@@ -93,13 +94,12 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
|
|
|
93
94
|
ref: forwardRef,
|
|
94
95
|
children: [_jsxs(Flex, {
|
|
95
96
|
sx: {
|
|
96
|
-
alignItems: '
|
|
97
|
-
mb: 2
|
|
97
|
+
alignItems: 'center'
|
|
98
98
|
},
|
|
99
99
|
children: [_jsxs(Heading, {
|
|
100
100
|
variant: titleVariant,
|
|
101
101
|
sx: {
|
|
102
|
-
mb:
|
|
102
|
+
mb: 0,
|
|
103
103
|
color: headingColor,
|
|
104
104
|
fontSize: 2,
|
|
105
105
|
fontWeight: 'heading',
|
|
@@ -111,14 +111,14 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
|
|
|
111
111
|
children: [showStepText && _jsx(Text, {
|
|
112
112
|
sx: {
|
|
113
113
|
fontSize: 1,
|
|
114
|
-
color: 'wizard.step.number.color'
|
|
114
|
+
color: 'wizard.step.number.color',
|
|
115
|
+
pb: 1
|
|
115
116
|
},
|
|
116
117
|
"aria-hidden": "true",
|
|
117
118
|
children: stepText
|
|
118
119
|
}), _jsxs(Flex, {
|
|
119
120
|
as: "span",
|
|
120
121
|
sx: {
|
|
121
|
-
mt: showStepText ? 3 : 2,
|
|
122
122
|
alignItems: 'center'
|
|
123
123
|
},
|
|
124
124
|
"aria-hidden": "true",
|
|
@@ -155,14 +155,21 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
|
|
|
155
155
|
}), !active && (complete || skipped) && (summary || summaryTitle) && _jsx(DescriptionList, {
|
|
156
156
|
as: summaryAs,
|
|
157
157
|
list: summary || [],
|
|
158
|
-
title: summaryTitle
|
|
159
|
-
}), subTitle && active && _jsx(Text, {
|
|
158
|
+
title: summaryTitle,
|
|
160
159
|
sx: {
|
|
161
|
-
mb: 3,
|
|
162
160
|
mt: 2
|
|
161
|
+
}
|
|
162
|
+
}), subTitle && active && _jsx(Text, {
|
|
163
|
+
sx: {
|
|
164
|
+
my: 3
|
|
163
165
|
},
|
|
164
166
|
children: subTitle
|
|
165
|
-
}), active && children
|
|
167
|
+
}), active && Boolean(children) && _jsx(Box, {
|
|
168
|
+
sx: {
|
|
169
|
+
pt: 2
|
|
170
|
+
},
|
|
171
|
+
children: children
|
|
172
|
+
})]
|
|
166
173
|
});
|
|
167
174
|
});
|
|
168
175
|
WizardStep.displayName = 'WizardStep';
|
package/package.json
CHANGED
|
@@ -85,6 +85,12 @@ const inlineStyles = {
|
|
|
85
85
|
borderWidth: 0,
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const allowCustomStyles = {
|
|
89
|
+
'& .autocomplete__option--no-results': {
|
|
90
|
+
cursor: 'pointer',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
88
94
|
const searchIconStyles = {
|
|
89
95
|
'& .autocomplete__input.autocomplete__input': {
|
|
90
96
|
paddingLeft: 6,
|
|
@@ -120,6 +126,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
120
126
|
resetOnBlur = false, // resets the input value to the selection if the input is blurred. Returns null if selection is empty
|
|
121
127
|
source,
|
|
122
128
|
value,
|
|
129
|
+
allowCustom = false,
|
|
123
130
|
...props
|
|
124
131
|
},
|
|
125
132
|
forwardRef
|
|
@@ -199,9 +206,13 @@ const FormAutocomplete = React.forwardRef(
|
|
|
199
206
|
|
|
200
207
|
const handleTypeChange = useCallback(
|
|
201
208
|
query => {
|
|
202
|
-
|
|
209
|
+
const filteredOptions = options.filter(
|
|
203
210
|
option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
|
|
204
211
|
);
|
|
212
|
+
if ( allowCustom && filteredOptions.length === 0 ) {
|
|
213
|
+
return [ { label: query, value: query } ];
|
|
214
|
+
}
|
|
215
|
+
return filteredOptions;
|
|
205
216
|
},
|
|
206
217
|
[ options ]
|
|
207
218
|
);
|
|
@@ -319,6 +330,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
319
330
|
...defaultStyles,
|
|
320
331
|
...( isInline && inlineStyles ),
|
|
321
332
|
...( searchIcon && searchIconStyles ),
|
|
333
|
+
...( allowCustom && allowCustomStyles ),
|
|
322
334
|
...( hasError ? { borderColor: 'input.border.error' } : {} ),
|
|
323
335
|
} }
|
|
324
336
|
>
|
|
@@ -382,6 +394,7 @@ FormAutocomplete.propTypes = {
|
|
|
382
394
|
source: PropTypes.func,
|
|
383
395
|
value: PropTypes.string,
|
|
384
396
|
dropdownArrow: PropTypes.node,
|
|
397
|
+
allowCustom: PropTypes.bool,
|
|
385
398
|
};
|
|
386
399
|
|
|
387
400
|
FormAutocomplete.displayName = 'FormAutocomplete';
|
|
@@ -67,6 +67,12 @@ const DefaultComponent = ( { label = 'Label', width = 250, ...rest } ) => {
|
|
|
67
67
|
export const Default = DefaultComponent.bind( {} );
|
|
68
68
|
Default.args = args;
|
|
69
69
|
|
|
70
|
+
export const WithAllowCustom = DefaultComponent.bind( {} );
|
|
71
|
+
WithAllowCustom.args = {
|
|
72
|
+
...Default.args,
|
|
73
|
+
allowCustom: true,
|
|
74
|
+
};
|
|
75
|
+
|
|
70
76
|
export const Inline = DefaultComponent.bind( {} );
|
|
71
77
|
Inline.args = {
|
|
72
78
|
...Default.args,
|
|
@@ -155,6 +155,7 @@ const FormAutocompleteMultiselect = React.forwardRef(
|
|
|
155
155
|
value,
|
|
156
156
|
listType = 'button',
|
|
157
157
|
initialValue = [],
|
|
158
|
+
allowCustom = false,
|
|
158
159
|
...props
|
|
159
160
|
},
|
|
160
161
|
forwardRef
|
|
@@ -245,11 +246,16 @@ const FormAutocompleteMultiselect = React.forwardRef(
|
|
|
245
246
|
);
|
|
246
247
|
|
|
247
248
|
const handleTypeChange = useCallback(
|
|
248
|
-
query =>
|
|
249
|
-
options.filter(
|
|
249
|
+
query => {
|
|
250
|
+
const filteredOptions = options.filter(
|
|
250
251
|
option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
|
|
251
|
-
)
|
|
252
|
-
|
|
252
|
+
);
|
|
253
|
+
if ( allowCustom && filteredOptions.length === 0 ) {
|
|
254
|
+
return [ { label: query, value: query } ];
|
|
255
|
+
}
|
|
256
|
+
return filteredOptions;
|
|
257
|
+
},
|
|
258
|
+
[ options, allowCustom ]
|
|
253
259
|
);
|
|
254
260
|
|
|
255
261
|
const handleInputChange = useCallback(
|
|
@@ -384,7 +390,7 @@ const FormAutocompleteMultiselect = React.forwardRef(
|
|
|
384
390
|
</Validation>
|
|
385
391
|
) }
|
|
386
392
|
<div sx={ { fontSize: 1 } }>
|
|
387
|
-
{ selectedOptions.length } item{ selectedOptions.length
|
|
393
|
+
{ selectedOptions.length } item{ selectedOptions.length === 1 ? '' : 's' } selected
|
|
388
394
|
</div>
|
|
389
395
|
</Flex>
|
|
390
396
|
<div sx={ { display: 'inline-flex', flexWrap: 'wrap', maxWidth: '100%' } }>
|
|
@@ -428,6 +434,7 @@ FormAutocompleteMultiselect.propTypes = {
|
|
|
428
434
|
value: PropTypes.string,
|
|
429
435
|
dropdownArrow: PropTypes.node,
|
|
430
436
|
initialValue: PropTypes.array,
|
|
437
|
+
allowCustom: PropTypes.bool,
|
|
431
438
|
};
|
|
432
439
|
|
|
433
440
|
FormAutocompleteMultiselect.displayName = 'FormAutocompleteMultiselect';
|
|
@@ -86,6 +86,15 @@ export const Default = () => {
|
|
|
86
86
|
);
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
export const WithAllowCustom = () => {
|
|
90
|
+
const customArgs = {
|
|
91
|
+
...args,
|
|
92
|
+
allowCustom: true,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return <DefaultComponent { ...customArgs } />;
|
|
96
|
+
};
|
|
97
|
+
|
|
89
98
|
export const WithBadges = () => {
|
|
90
99
|
const customArgs = {
|
|
91
100
|
...args,
|
|
@@ -76,6 +76,14 @@ Default.args = {
|
|
|
76
76
|
options,
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
export const Disabled = DefaultComponent.bind( {} );
|
|
80
|
+
Disabled.args = {
|
|
81
|
+
placeholder: '- Select -',
|
|
82
|
+
required: true,
|
|
83
|
+
disabled: true,
|
|
84
|
+
options,
|
|
85
|
+
};
|
|
86
|
+
|
|
79
87
|
export const WithErrors = DefaultComponent.bind( {} );
|
|
80
88
|
WithErrors.args = {
|
|
81
89
|
placeholder: '- Select -',
|
|
@@ -39,6 +39,7 @@ interface Option {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
interface FormSelectProps {
|
|
42
|
+
disabled?: boolean;
|
|
42
43
|
isInline?: boolean;
|
|
43
44
|
placeholder?: string;
|
|
44
45
|
forLabel?: string;
|
|
@@ -52,7 +53,6 @@ interface FormSelectProps {
|
|
|
52
53
|
errorMessage?: string;
|
|
53
54
|
wrapperSx?: ThemeUIStyleObject;
|
|
54
55
|
value?: string | number;
|
|
55
|
-
disabled?: boolean;
|
|
56
56
|
className?: string;
|
|
57
57
|
'aria-describedby'?: string;
|
|
58
58
|
'aria-required'?: boolean;
|
|
@@ -78,6 +78,7 @@ const renderGroup = ( groupLabel: string, groupOptions: Option[] ) => {
|
|
|
78
78
|
const FormSelect = React.forwardRef< HTMLSelectElement, FormSelectProps >(
|
|
79
79
|
(
|
|
80
80
|
{
|
|
81
|
+
disabled,
|
|
81
82
|
isInline,
|
|
82
83
|
placeholder,
|
|
83
84
|
forLabel = 'vip-form-select',
|
|
@@ -149,8 +150,9 @@ const FormSelect = React.forwardRef< HTMLSelectElement, FormSelectProps >(
|
|
|
149
150
|
<select
|
|
150
151
|
onChange={ onValueChange }
|
|
151
152
|
ref={ forwardRef }
|
|
152
|
-
sx={ defaultStyles }
|
|
153
|
+
sx={ { cursor: disabled ? 'not-allowed' : 'pointer', ...defaultStyles } }
|
|
153
154
|
required={ required }
|
|
155
|
+
disabled={ disabled }
|
|
154
156
|
aria-required={ required }
|
|
155
157
|
aria-describedby={ hasError ? `describe-${ forLabel }-validation` : undefined }
|
|
156
158
|
id={ forLabel }
|
|
@@ -152,12 +152,19 @@ export const WithTitleAutoFocus = () => {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
export const HideStepText = () => {
|
|
155
|
+
const [ activeStep, setActiveStep ] = React.useState< number | undefined >( undefined );
|
|
156
|
+
|
|
155
157
|
const steps: WizardStepProps[] = [
|
|
156
158
|
{
|
|
157
159
|
title: 'Included Logs',
|
|
158
160
|
titleVariant: 'h2',
|
|
159
161
|
subTitle: '',
|
|
160
|
-
children: <Text>Error Logs</Text>,
|
|
162
|
+
children: <Text sx={ { mb: 0 } }>Error Logs</Text>,
|
|
163
|
+
onChange: () => {
|
|
164
|
+
setActiveStep( 0 );
|
|
165
|
+
},
|
|
166
|
+
actionLabel: 'Edit',
|
|
167
|
+
actionIcon: <BsPencil />,
|
|
161
168
|
},
|
|
162
169
|
];
|
|
163
170
|
|
|
@@ -166,7 +173,7 @@ export const HideStepText = () => {
|
|
|
166
173
|
<Box mt={ 4 }>
|
|
167
174
|
<Wizard
|
|
168
175
|
showStepText={ false }
|
|
169
|
-
activeStep={
|
|
176
|
+
activeStep={ activeStep }
|
|
170
177
|
steps={ steps }
|
|
171
178
|
completed={ [ 0 ] }
|
|
172
179
|
className="vip-wizard-xyz"
|
|
@@ -112,17 +112,18 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
|
|
|
112
112
|
borderColor: 'wizard.step.border.default',
|
|
113
113
|
borderLeftColor,
|
|
114
114
|
overflow: 'inherit',
|
|
115
|
+
py: 1,
|
|
115
116
|
} }
|
|
116
117
|
data-step={ order }
|
|
117
118
|
data-active={ active || undefined }
|
|
118
119
|
className={ `wizard-step-${ status }` }
|
|
119
120
|
ref={ forwardRef }
|
|
120
121
|
>
|
|
121
|
-
<Flex sx={ { alignItems: '
|
|
122
|
+
<Flex sx={ { alignItems: 'center' } }>
|
|
122
123
|
<Heading
|
|
123
124
|
variant={ titleVariant }
|
|
124
125
|
sx={ {
|
|
125
|
-
mb:
|
|
126
|
+
mb: 0,
|
|
126
127
|
color: headingColor,
|
|
127
128
|
fontSize: 2,
|
|
128
129
|
fontWeight: 'heading',
|
|
@@ -133,16 +134,15 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
|
|
|
133
134
|
aria-current={ active ? 'step' : undefined }
|
|
134
135
|
>
|
|
135
136
|
{ showStepText && (
|
|
136
|
-
<Text
|
|
137
|
+
<Text
|
|
138
|
+
sx={ { fontSize: 1, color: 'wizard.step.number.color', pb: 1 } }
|
|
139
|
+
aria-hidden="true"
|
|
140
|
+
>
|
|
137
141
|
{ stepText }
|
|
138
142
|
</Text>
|
|
139
143
|
) }
|
|
140
144
|
|
|
141
|
-
<Flex
|
|
142
|
-
as="span"
|
|
143
|
-
sx={ { mt: showStepText ? 3 : 2, alignItems: 'center' } }
|
|
144
|
-
aria-hidden="true"
|
|
145
|
-
>
|
|
145
|
+
<Flex as="span" sx={ { alignItems: 'center' } } aria-hidden="true">
|
|
146
146
|
{ complete ? (
|
|
147
147
|
<BsFillCheckCircleFill sx={ statusIconStyles } />
|
|
148
148
|
) : (
|
|
@@ -174,12 +174,17 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
|
|
|
174
174
|
) }
|
|
175
175
|
</Flex>
|
|
176
176
|
{ ! active && ( complete || skipped ) && ( summary || summaryTitle ) && (
|
|
177
|
-
<DescriptionList
|
|
177
|
+
<DescriptionList
|
|
178
|
+
as={ summaryAs }
|
|
179
|
+
list={ summary || [] }
|
|
180
|
+
title={ summaryTitle }
|
|
181
|
+
sx={ { mt: 2 } }
|
|
182
|
+
/>
|
|
178
183
|
) }
|
|
179
184
|
|
|
180
|
-
{ subTitle && active && <Text sx={ {
|
|
185
|
+
{ subTitle && active && <Text sx={ { my: 3 } }>{ subTitle }</Text> }
|
|
181
186
|
|
|
182
|
-
{ active && children }
|
|
187
|
+
{ active && Boolean( children ) && <Box sx={ { pt: 2 } }>{ children }</Box> }
|
|
183
188
|
</Card>
|
|
184
189
|
);
|
|
185
190
|
}
|