@innovaccer/design-system 2.13.0 → 2.13.2
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/CHANGELOG.md +33 -0
- package/core/components/atoms/dropdown/DropdownList.tsx +3 -11
- package/core/components/atoms/dropdown/option/CheckboxOption.tsx +3 -10
- package/core/components/atoms/dropdown/option/index.tsx +3 -3
- package/core/components/atoms/metricInput/__stories__/DefaultMetric.story.jsx +1 -1
- package/core/components/molecules/inputMask/InputMask.tsx +6 -1
- package/core/components/molecules/popover/__stories__/variants/boundaryElement.story.jsx +2 -2
- package/core/components/organisms/datePicker/__tests__/DatePicker.test.tsx +1 -1
- package/core/components/organisms/dateRangePicker/SingleInputTrigger.tsx +22 -1
- package/core/components/organisms/dateRangePicker/Trigger.tsx +19 -2
- package/core/components/organisms/timePicker/TimePicker.tsx +1 -0
- package/core/utils/masks.ts +3 -3
- package/css/dist/index.css +0 -20
- package/css/dist/index.css.map +1 -1
- package/css/src/components/dropdown.css +0 -20
- package/dist/core/components/atoms/dropdown/option/index.d.ts +1 -1
- package/dist/index.esm.js +83 -48
- package/dist/index.js +69 -29
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/docs/package.json +1 -1
- package/docs/src/data/components/index.js +12 -0
- package/docs/src/data/components/mobile.js +12 -0
- package/docs/src/data/nav/components.yaml +0 -1
- package/docs/src/pages/components/chips/images/chips-1.png +0 -0
- package/docs/src/pages/components/chips/usage.mdx +7 -1
- package/docs/src/pages/components/helpText/images/helpText-1.png +0 -0
- package/docs/src/pages/components/helpText/images/helpText-2.png +0 -0
- package/docs/src/pages/components/helpText/images/helpText-3.png +0 -0
- package/docs/src/pages/components/helpText/images/helpText-4.png +0 -0
- package/docs/src/pages/components/helpText/images/helpText-5.png +0 -0
- package/docs/src/pages/components/helpText/usage.mdx +74 -0
- package/docs/src/pages/components/pills/images/pills-1.png +0 -0
- package/docs/src/pages/components/pills/usage.mdx +7 -1
- package/docs/src/pages/components/radio/images/radio-1.png +0 -0
- package/docs/src/pages/components/radio/usage.mdx +7 -1
- package/docs/src/pages/components/switch/images/switch-4.png +0 -0
- package/docs/src/pages/components/switch/images/switch-5.png +0 -0
- package/docs/src/pages/components/switch/images/switch-6.png +0 -0
- package/docs/src/pages/components/switch/usage.mdx +10 -3
- package/docs/src/pages/mobile/components/bottomSheet/images/bottomsheet-8.png +0 -0
- package/docs/src/pages/mobile/components/bottomSheet/usage.mdx +4 -1
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-1.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-10.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-11.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-2.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-3.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-4.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-5.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-6.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-7.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-8.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/images/checkbox-9.png +0 -0
- package/docs/src/pages/mobile/components/checkbox/usage.mdx +122 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
|
|
2
|
+
## 2.13.1 (2022-06-24)
|
|
3
|
+
|
|
4
|
+
### Highlights
|
|
5
|
+
NA
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
NA
|
|
9
|
+
|
|
10
|
+
### Migration guide
|
|
11
|
+
NA
|
|
12
|
+
|
|
13
|
+
### Deprecations
|
|
14
|
+
NA
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
NA
|
|
18
|
+
|
|
19
|
+
### Fixes
|
|
20
|
+
* fix(daterangepicker): fix error state on blur event (fcc00594)
|
|
21
|
+
* fix(daterangepicker): fix dateRangePicker input freeze (c98352c0)
|
|
22
|
+
* fix(popover): fix boundary element story (ca351ed5)
|
|
23
|
+
* fix(metricInput): fix default metric input story (0eb7e111)
|
|
24
|
+
|
|
25
|
+
### Improvements
|
|
26
|
+
NA
|
|
27
|
+
|
|
28
|
+
### Documentation
|
|
29
|
+
* fix(docs): update distribution id for docs-dev (6e21010d)
|
|
30
|
+
* fix(docs): update distribution id for docs-dev (6c23c6ed)
|
|
31
|
+
* feat(docs): add component images (3f9e1fc4)
|
|
32
|
+
* feat(docs): add helptext component (4601c1e0)
|
|
33
|
+
|
|
34
|
+
-------------------
|
|
2
35
|
## 2.13.0 (2022-06-21)
|
|
3
36
|
|
|
4
37
|
### Highlights
|
|
@@ -3,7 +3,7 @@ import { scrollIntoView, _isEqual, _isSelectAllPresent } from './utility';
|
|
|
3
3
|
import { Popover, Checkbox, Button, Text, Input } from '@/index';
|
|
4
4
|
import { PopoverProps } from '@/index.type';
|
|
5
5
|
import DropdownButton, { TriggerProps } from './DropdownButton';
|
|
6
|
-
import Option, {
|
|
6
|
+
import Option, { OptionRendererProps, OptionSchema } from './option';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import Loading from './Loading';
|
|
9
9
|
import { BaseProps, extractBaseProps } from '@/utils/types';
|
|
@@ -322,7 +322,7 @@ const DropdownList = (props: OptionsProps) => {
|
|
|
322
322
|
|
|
323
323
|
const SelectAllClass = classNames(
|
|
324
324
|
{
|
|
325
|
-
['Option-checkbox']:
|
|
325
|
+
['Option-checkbox']: true,
|
|
326
326
|
['Option-checkbox--active']: cursor === 0,
|
|
327
327
|
['OptionWrapper']: true,
|
|
328
328
|
},
|
|
@@ -347,10 +347,6 @@ const DropdownList = (props: OptionsProps) => {
|
|
|
347
347
|
|
|
348
348
|
const optionClickHandler = (item: any) => {
|
|
349
349
|
props.onOptionSelect(item);
|
|
350
|
-
if (withCheckbox) {
|
|
351
|
-
const optionIsSelected = tempSelected.findIndex((option) => option.value === item.value) !== -1;
|
|
352
|
-
props.onSelect(item, !optionIsSelected);
|
|
353
|
-
}
|
|
354
350
|
dropdownTriggerRef.current?.focus();
|
|
355
351
|
};
|
|
356
352
|
|
|
@@ -512,11 +508,7 @@ const DropdownList = (props: OptionsProps) => {
|
|
|
512
508
|
active={active}
|
|
513
509
|
checkboxes={withCheckbox}
|
|
514
510
|
menu={menu}
|
|
515
|
-
onClick={(
|
|
516
|
-
e.preventDefault();
|
|
517
|
-
e.stopPropagation();
|
|
518
|
-
optionClickHandler(item);
|
|
519
|
-
}}
|
|
511
|
+
onClick={() => optionClickHandler(item)}
|
|
520
512
|
onChange={(e) => props.onSelect(item, e.target.checked)}
|
|
521
513
|
optionType={props.optionType}
|
|
522
514
|
/>
|
|
@@ -5,7 +5,7 @@ import { Text, MetaList } from '@/index';
|
|
|
5
5
|
import { MetaListProps } from '@/index.type';
|
|
6
6
|
|
|
7
7
|
const CheckboxOption = (props: OptionTypeProps) => {
|
|
8
|
-
const { className, selected, optionData,
|
|
8
|
+
const { className, selected, optionData, onChangeHandler, onUpdateActiveOption, dataTest } = props;
|
|
9
9
|
const { subInfo, label, disabled } = optionData;
|
|
10
10
|
|
|
11
11
|
const renderSubInfo = (subInfo: string | MetaListProps) => {
|
|
@@ -39,19 +39,12 @@ const CheckboxOption = (props: OptionTypeProps) => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
|
|
43
|
-
<div
|
|
44
|
-
onClick={onClickHandler}
|
|
45
|
-
className={className}
|
|
46
|
-
onMouseEnter={onUpdateActiveOption}
|
|
47
|
-
data-test={dataTest}
|
|
48
|
-
data-disabled={disabled}
|
|
49
|
-
>
|
|
42
|
+
<div className={className} onMouseEnter={onUpdateActiveOption} data-test={dataTest} data-disabled={disabled}>
|
|
50
43
|
<Checkbox
|
|
51
|
-
onChange={onChangeHandler}
|
|
52
44
|
label={label}
|
|
53
45
|
disabled={disabled}
|
|
54
46
|
checked={selected}
|
|
47
|
+
onChange={onChangeHandler}
|
|
55
48
|
tabIndex={-1}
|
|
56
49
|
className={`OptionCheckbox ${subInfo ? 'pb-0' : ''}`}
|
|
57
50
|
data-test={`${dataTest}--Checkbox`}
|
|
@@ -66,7 +66,7 @@ interface OptionProps extends OptionRendererProps {
|
|
|
66
66
|
index: number;
|
|
67
67
|
active?: boolean;
|
|
68
68
|
menu?: boolean;
|
|
69
|
-
onClick?: (
|
|
69
|
+
onClick?: () => void;
|
|
70
70
|
onChange?: (event: ChangeEvent) => void;
|
|
71
71
|
updateActiveOption?: (index: number) => void;
|
|
72
72
|
}
|
|
@@ -94,7 +94,7 @@ const Option = (props: OptionProps) => {
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
const CheckboxClassName = classNames({
|
|
97
|
-
['Option-checkbox']:
|
|
97
|
+
['Option-checkbox']: true,
|
|
98
98
|
['Option-checkbox--active']: active,
|
|
99
99
|
['OptionWrapper']: true,
|
|
100
100
|
});
|
|
@@ -119,7 +119,7 @@ const Option = (props: OptionProps) => {
|
|
|
119
119
|
e.stopPropagation();
|
|
120
120
|
if (disabled) return;
|
|
121
121
|
|
|
122
|
-
if (onClick) onClick(
|
|
122
|
+
if (onClick) onClick();
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
const onChangeHandler = (e: ChangeEvent) => {
|
|
@@ -30,7 +30,7 @@ const customCode = `() => {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<div className="d-flex align-items-center">
|
|
33
|
-
<Label htmlFor="metric-input" className="mr-5">
|
|
33
|
+
<Label htmlFor="metric-input" className="mr-5"> No. of Days </Label>
|
|
34
34
|
<div style={{ width: 'var(--spacing-6)' }}>
|
|
35
35
|
<MetricInput
|
|
36
36
|
id="metric-input"
|
|
@@ -79,6 +79,7 @@ const InputMask = React.forwardRef<HTMLInputElement, InputMaskProps>((props, for
|
|
|
79
79
|
onFocus,
|
|
80
80
|
onClear,
|
|
81
81
|
className,
|
|
82
|
+
id,
|
|
82
83
|
...rest
|
|
83
84
|
} = props;
|
|
84
85
|
|
|
@@ -125,6 +126,10 @@ const InputMask = React.forwardRef<HTMLInputElement, InputMaskProps>((props, for
|
|
|
125
126
|
|
|
126
127
|
React.useImperativeHandle(forwardRef, () => ref.current as HTMLInputElement);
|
|
127
128
|
|
|
129
|
+
React.useEffect(() => {
|
|
130
|
+
setValue(valueProp || '');
|
|
131
|
+
}, [valueProp]);
|
|
132
|
+
|
|
128
133
|
React.useEffect(() => {
|
|
129
134
|
setCursorPosition(newSelectionPos.current);
|
|
130
135
|
}, [value]);
|
|
@@ -213,7 +218,7 @@ const InputMask = React.forwardRef<HTMLInputElement, InputMaskProps>((props, for
|
|
|
213
218
|
enteredVal = inputVal.slice(start, end);
|
|
214
219
|
updatedVal = insertAtIndex(enteredVal, start);
|
|
215
220
|
let oldValue = value;
|
|
216
|
-
if (oldValue.length === 0) {
|
|
221
|
+
if (oldValue.length === 0 && id === 'parent-TimePicker') {
|
|
217
222
|
oldValue = defaultPlaceholderValue;
|
|
218
223
|
}
|
|
219
224
|
insertedStringLength = updatedVal.length;
|
|
@@ -38,8 +38,8 @@ export const boundaryElement = () => {
|
|
|
38
38
|
const ref = React.useRef<HTMLDivElement>(null);
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
|
-
<div ref={ref} style={{ height: 150, border: '1px dashed', padding: 20, overflow: 'auto' }}>
|
|
42
|
-
<Popover {...options} boundaryElement={ref}>
|
|
41
|
+
<div ref={ref.current} style={{ height: 150, border: '1px dashed', padding: 20, overflow: 'auto' }}>
|
|
42
|
+
<Popover {...options} boundaryElement={ref.current}>
|
|
43
43
|
<div style={{ width: 100 }} className="mx-6 my-6">
|
|
44
44
|
<Text>Popup</Text>
|
|
45
45
|
<Button className="mt-4" appearance="primary" onClick={action('button clicked inside popover')}>
|
|
@@ -133,7 +133,7 @@ describe('renders DatePicker component Event Handlers ', () => {
|
|
|
133
133
|
const { getByTestId } = render(<DatePicker onDateChange={FunctionValue} withInput={true} />);
|
|
134
134
|
const input = getByTestId('DesignSystem-Input');
|
|
135
135
|
fireEvent.blur(input);
|
|
136
|
-
expect(input).toHaveValue('');
|
|
136
|
+
expect(input).toHaveValue('__/__/____');
|
|
137
137
|
});
|
|
138
138
|
it('checks onFocus Event', () => {
|
|
139
139
|
const { getByTestId } = render(<DatePicker onDateChange={FunctionValue} withInput={true} />);
|
|
@@ -76,6 +76,20 @@ export const SingleInputTrigger = (props: TriggerProps) => {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
const getErrorState = (currentVal: string, siblingVal: string) => {
|
|
80
|
+
const hasNumber = /\d/;
|
|
81
|
+
|
|
82
|
+
if (currentVal && siblingVal && !currentVal.includes(placeholderChar) && siblingVal.includes(placeholderChar)) {
|
|
83
|
+
return true;
|
|
84
|
+
} else if (currentVal && hasNumber.test(currentVal) && currentVal.includes(placeholderChar)) {
|
|
85
|
+
return true;
|
|
86
|
+
} else if ((currentVal && !hasNumber.test(currentVal)) || !currentVal) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return null;
|
|
91
|
+
};
|
|
92
|
+
|
|
79
93
|
const onBlurHandler = (_e: React.ChangeEvent<HTMLInputElement>, val: string) => {
|
|
80
94
|
setState({
|
|
81
95
|
init: true,
|
|
@@ -85,6 +99,13 @@ export const SingleInputTrigger = (props: TriggerProps) => {
|
|
|
85
99
|
const startVal = date[0];
|
|
86
100
|
const endVal = date[1];
|
|
87
101
|
|
|
102
|
+
const startErr = getErrorState(startVal, endVal);
|
|
103
|
+
const endErr = getErrorState(endVal, startVal);
|
|
104
|
+
|
|
105
|
+
if (startErr !== null && endErr !== null) {
|
|
106
|
+
setState({ startError: startErr, endError: endErr });
|
|
107
|
+
}
|
|
108
|
+
|
|
88
109
|
if (!startVal || startVal.includes(placeholderChar)) setState({ startDate: undefined });
|
|
89
110
|
if (!endVal || endVal.includes(placeholderChar)) setState({ endDate: undefined });
|
|
90
111
|
};
|
|
@@ -123,7 +144,7 @@ export const SingleInputTrigger = (props: TriggerProps) => {
|
|
|
123
144
|
error={showError}
|
|
124
145
|
caption={showError ? errorMessage : ''}
|
|
125
146
|
validators={[inputValidator]}
|
|
126
|
-
clearOnEmptyBlur={
|
|
147
|
+
clearOnEmptyBlur={true}
|
|
127
148
|
/>
|
|
128
149
|
</Column>
|
|
129
150
|
</Row>
|
|
@@ -66,12 +66,29 @@ export const Trigger = (props: TriggerProps) => {
|
|
|
66
66
|
setState({
|
|
67
67
|
init: true,
|
|
68
68
|
});
|
|
69
|
+
const hasNumber = /\d/;
|
|
70
|
+
|
|
69
71
|
if (type === 'start') {
|
|
70
72
|
const { placeholderChar = '_' } = startInputOptions;
|
|
73
|
+
|
|
74
|
+
if (val && hasNumber.test(val) && val.includes(placeholderChar)) {
|
|
75
|
+
setState({ startError: true });
|
|
76
|
+
} else if ((val && !hasNumber.test(val)) || !val) {
|
|
77
|
+
setState({ startError: false });
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
if (!val || val.includes(placeholderChar)) setState({ startDate: undefined });
|
|
72
81
|
}
|
|
82
|
+
|
|
73
83
|
if (type === 'end') {
|
|
74
84
|
const { placeholderChar = '_' } = endInputOptions;
|
|
85
|
+
|
|
86
|
+
if (val && hasNumber.test(val) && val.includes(placeholderChar)) {
|
|
87
|
+
setState({ endError: true });
|
|
88
|
+
} else if ((val && !hasNumber.test(val)) || !val) {
|
|
89
|
+
setState({ endError: false });
|
|
90
|
+
}
|
|
91
|
+
|
|
75
92
|
if (!val || val.includes(placeholderChar)) setState({ endDate: undefined });
|
|
76
93
|
}
|
|
77
94
|
};
|
|
@@ -145,7 +162,7 @@ export const Trigger = (props: TriggerProps) => {
|
|
|
145
162
|
error={showStartError}
|
|
146
163
|
caption={showStartError ? startErrorMessage : ''}
|
|
147
164
|
validators={[inputValidator]}
|
|
148
|
-
clearOnEmptyBlur={
|
|
165
|
+
clearOnEmptyBlur={true}
|
|
149
166
|
/>
|
|
150
167
|
</Column>
|
|
151
168
|
<Column size={'6'} sizeXS={'12'} className="DateRangePicker-input DateRangePicker-input--endDate">
|
|
@@ -177,7 +194,7 @@ export const Trigger = (props: TriggerProps) => {
|
|
|
177
194
|
error={showEndError}
|
|
178
195
|
caption={showEndError ? endErrorMessage : ''}
|
|
179
196
|
validators={[inputValidator]}
|
|
180
|
-
clearOnEmptyBlur={
|
|
197
|
+
clearOnEmptyBlur={true}
|
|
181
198
|
/>
|
|
182
199
|
</Column>
|
|
183
200
|
</Row>
|
package/core/utils/masks.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DatePickerProps, InputMaskProps } from '@/index.type';
|
|
|
3
3
|
|
|
4
4
|
type DateFormat = DatePickerProps['inputFormat'];
|
|
5
5
|
export const date: Record<DateFormat, Mask> = {
|
|
6
|
-
'dd/mm/yyyy': [/[0123]/, /\d/, '/',
|
|
6
|
+
'dd/mm/yyyy': [/[0123]/, /\d/, '/', /[01]/, /\d/, '/', /\d/, /\d/, /\d/, /\d/],
|
|
7
7
|
'mm/dd/yyyy': [/[01]/, /\d/, '/', /[0123]/, /\d/, '/', /\d/, /\d/, /\d/, /\d/],
|
|
8
8
|
'yyyy/mm/dd': [/\d/, /\d/, /\d/, /\d/, '/', /[01]/, /\d/, '/', /[0123]/, /\d/],
|
|
9
9
|
'dd-mm-yyyy': [/[0123]/, /\d/, '-', /[01]/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
|
|
@@ -16,7 +16,7 @@ export const rangeDate: Record<DateFormat, Mask> = {
|
|
|
16
16
|
/[0123]/,
|
|
17
17
|
/\d/,
|
|
18
18
|
'/',
|
|
19
|
-
|
|
19
|
+
/[01]/,
|
|
20
20
|
/\d/,
|
|
21
21
|
'/',
|
|
22
22
|
/\d/,
|
|
@@ -29,7 +29,7 @@ export const rangeDate: Record<DateFormat, Mask> = {
|
|
|
29
29
|
/[0123]/,
|
|
30
30
|
/\d/,
|
|
31
31
|
'/',
|
|
32
|
-
|
|
32
|
+
/[01]/,
|
|
33
33
|
/\d/,
|
|
34
34
|
'/',
|
|
35
35
|
/\d/,
|
package/css/dist/index.css
CHANGED
|
@@ -2155,14 +2155,6 @@ body {
|
|
|
2155
2155
|
padding-right: var(--spacing-l);
|
|
2156
2156
|
}
|
|
2157
2157
|
|
|
2158
|
-
.Option:active {
|
|
2159
|
-
background-color: var(--jal-lighter);
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
.Option > .Checkbox-input {
|
|
2163
|
-
background-color: var(--white);
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
2158
|
.OptionCheckbox {
|
|
2167
2159
|
width: 100%;
|
|
2168
2160
|
padding-left: var(--spacing-l);
|
|
@@ -2170,18 +2162,6 @@ body {
|
|
|
2170
2162
|
padding-bottom: 6px;
|
|
2171
2163
|
}
|
|
2172
2164
|
|
|
2173
|
-
.Option-checkbox > .OptionCheckbox > .Checkbox-outerWrapper {
|
|
2174
|
-
background-color: var(--shadow-0);
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
.Option-checkbox:hover > .OptionCheckbox > .Checkbox-outerWrapper > .Checkbox-input ~ .Checkbox-wrapper {
|
|
2178
|
-
border: var(--spacing-xs) solid var(--stone-dark);
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
.Option-checkbox:active > .OptionCheckbox > .Checkbox-outerWrapper > .Checkbox-input ~ .Checkbox-wrapper {
|
|
2182
|
-
background-color: var(--secondary-light);
|
|
2183
|
-
}
|
|
2184
|
-
|
|
2185
2165
|
.Option--active,
|
|
2186
2166
|
.Option-checkbox--active {
|
|
2187
2167
|
background-color: var(--secondary-lightest);
|