@decisiv/ui-components 2.0.1-alpha.8 → 2.0.1-alpha.97
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/lib/atoms/BaseButton/index.d.ts.map +1 -1
- package/lib/atoms/BaseButton/index.js +1 -1
- package/lib/atoms/BooleanInput/index.d.ts.map +1 -1
- package/lib/atoms/BooleanInput/index.js +19 -2
- package/lib/atoms/BooleanInput/index.test.js +17 -6
- package/lib/atoms/BooleanInput/types.d.ts +2 -0
- package/lib/atoms/BooleanInput/types.d.ts.map +1 -1
- package/lib/atoms/BooleanInput/types.js +5 -1
- package/lib/atoms/Calendar/hooks/useCalendar/index.d.ts.map +1 -1
- package/lib/atoms/Calendar/hooks/useCalendar/index.js +2 -1
- package/lib/atoms/Calendar/hooks/useCalendar/index.test.js +5 -6
- package/lib/atoms/Calendar/index.d.ts.map +1 -1
- package/lib/atoms/Calendar/index.js +8 -1
- package/lib/atoms/Calendar/index.test.js +70 -40
- package/lib/atoms/Calendar/types.js +5 -1
- package/lib/atoms/InputField/Containers.d.ts +11 -6
- package/lib/atoms/InputField/Containers.d.ts.map +1 -1
- package/lib/atoms/InputField/Containers.js +6 -6
- package/lib/atoms/InputField/InputLabel.d.ts +1 -0
- package/lib/atoms/InputField/InputLabel.d.ts.map +1 -1
- package/lib/atoms/InputField/InputLabel.js +2 -1
- package/lib/atoms/InputField/index.d.ts +5 -0
- package/lib/atoms/InputField/index.d.ts.map +1 -1
- package/lib/atoms/InputField/index.js +21 -7
- package/lib/atoms/InputField/index.test.js +91 -0
- package/lib/atoms/InputField/schema.d.ts.map +1 -1
- package/lib/atoms/InputField/schema.js +1 -0
- package/lib/atoms/OptionsList/Category.d.ts +1 -1
- package/lib/atoms/OptionsList/Category.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Category.js +4 -2
- package/lib/atoms/OptionsList/Footer.d.ts +8 -0
- package/lib/atoms/OptionsList/Footer.d.ts.map +1 -0
- package/lib/atoms/OptionsList/Footer.js +72 -0
- package/lib/atoms/OptionsList/Option.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Option.js +8 -5
- package/lib/atoms/OptionsList/index.d.ts.map +1 -1
- package/lib/atoms/OptionsList/index.js +43 -16
- package/lib/atoms/OptionsList/index.test.js +107 -11
- package/lib/atoms/OptionsList/schema.d.ts.map +1 -1
- package/lib/atoms/OptionsList/schema.js +4 -0
- package/lib/atoms/OptionsList/types.d.ts +14 -0
- package/lib/atoms/OptionsList/types.d.ts.map +1 -1
- package/lib/atoms/OptionsList/types.js +5 -1
- package/lib/atoms/RequiredIcon.d.ts +9 -0
- package/lib/atoms/RequiredIcon.d.ts.map +1 -0
- package/lib/atoms/{InputField/RequiredIcon.js → RequiredIcon.js} +7 -3
- package/lib/components/Accordion/types.js +5 -1
- package/lib/components/Accordion/useAccordion/types.js +5 -1
- package/lib/components/Avatar/types.js +5 -1
- package/lib/components/Badge/constants.d.ts +2 -0
- package/lib/components/Badge/constants.d.ts.map +1 -0
- package/lib/components/Badge/constants.js +29 -0
- package/lib/components/Badge/index.d.ts.map +1 -1
- package/lib/components/Badge/index.js +12 -23
- package/lib/components/Badge/index.test.js +51 -8
- package/lib/components/Badge/schema.js +1 -1
- package/lib/components/Badge/types.d.ts +1 -1
- package/lib/components/Badge/types.d.ts.map +1 -1
- package/lib/components/Badge/types.js +7 -3
- package/lib/components/Breadcrumbs/types.js +5 -1
- package/lib/components/Button/schema.d.ts +6 -1
- package/lib/components/Button/schema.d.ts.map +1 -1
- package/lib/components/Button/schema.js +9 -4
- package/lib/components/Button/types.js +5 -1
- package/lib/components/Checkbox/index.d.ts.map +1 -1
- package/lib/components/Checkbox/index.js +3 -1
- package/lib/components/Checkbox/schema.d.ts.map +1 -1
- package/lib/components/Checkbox/schema.js +2 -0
- package/lib/components/Combobox/Target.d.ts.map +1 -1
- package/lib/components/Combobox/Target.js +45 -14
- package/lib/components/Combobox/index.d.ts.map +1 -1
- package/lib/components/Combobox/index.js +193 -65
- package/lib/components/Combobox/index.test.js +358 -135
- package/lib/components/Combobox/schema.d.ts.map +1 -1
- package/lib/components/Combobox/schema.js +9 -2
- package/lib/components/Combobox/types.d.ts +12 -3
- package/lib/components/Combobox/types.d.ts.map +1 -1
- package/lib/components/Combobox/types.js +5 -1
- package/lib/components/DropdownList/index.d.ts +4 -0
- package/lib/components/DropdownList/index.d.ts.map +1 -1
- package/lib/components/DropdownList/index.js +76 -11
- package/lib/components/DropdownList/propTypes.d.ts +4 -0
- package/lib/components/DropdownList/propTypes.d.ts.map +1 -0
- package/lib/components/DropdownList/propTypes.js +42 -0
- package/lib/components/DropdownList/schema.d.ts.map +1 -1
- package/lib/components/DropdownList/schema.js +5 -0
- package/lib/components/DropdownList/types.d.ts +4 -1
- package/lib/components/DropdownList/types.d.ts.map +1 -1
- package/lib/components/Filter/IconWrapper/index.d.ts +197 -0
- package/lib/components/Filter/IconWrapper/index.d.ts.map +1 -0
- package/lib/components/Filter/IconWrapper/index.js +35 -0
- package/lib/components/Filter/SimplePrimary/index.d.ts +31 -0
- package/lib/components/Filter/SimplePrimary/index.d.ts.map +1 -0
- package/lib/components/Filter/SimplePrimary/index.js +58 -0
- package/lib/components/Filter/SimplePrimary/index.test.js +34 -0
- package/lib/components/Filter/StyledFilter.d.ts +4 -0
- package/lib/components/Filter/StyledFilter.d.ts.map +1 -0
- package/lib/components/Filter/StyledFilter.js +39 -0
- package/lib/components/Filter/StyledLabel/index.d.ts +8 -0
- package/lib/components/Filter/StyledLabel/index.d.ts.map +1 -0
- package/lib/components/Filter/StyledLabel/index.js +30 -0
- package/lib/components/Filter/index.d.ts +27 -0
- package/lib/components/Filter/index.d.ts.map +1 -0
- package/lib/components/Filter/index.js +95 -0
- package/lib/components/Filter/index.test.js +41 -0
- package/lib/components/Filter/kind.d.ts +6 -0
- package/lib/components/Filter/kind.d.ts.map +1 -0
- package/lib/components/Filter/kind.js +45 -0
- package/lib/components/Filter/schema.d.ts +9 -0
- package/lib/components/Filter/schema.d.ts.map +1 -0
- package/lib/components/Filter/schema.js +32 -0
- package/lib/components/Filter/types.d.ts +17 -0
- package/lib/components/Filter/types.d.ts.map +1 -0
- package/lib/components/Filter/types.js +5 -0
- package/lib/components/JumpTo/JumpToMenu.d.ts +2 -2
- package/lib/components/JumpTo/JumpToMenu.d.ts.map +1 -1
- package/lib/components/JumpTo/JumpToMenu.js +3 -3
- package/lib/components/JumpTo/types.js +5 -1
- package/lib/components/LeftNav/Item/ClickArea.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/ClickArea.js +2 -2
- package/lib/components/LeftNav/Item/ItemWrapper.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/ItemWrapper.js +3 -3
- package/lib/components/LeftNav/Item/MenuItemWrapper.d.ts +7 -0
- package/lib/components/LeftNav/Item/MenuItemWrapper.d.ts.map +1 -0
- package/lib/components/LeftNav/Item/MenuItemWrapper.js +20 -0
- package/lib/components/LeftNav/Item/NavCollapsedXItem/index.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/NavCollapsedXItem/index.js +7 -5
- package/lib/components/LeftNav/Item/NavExpandedItem/index.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/NavExpandedItem/index.js +24 -13
- package/lib/components/LeftNav/Item/types.d.ts +1 -1
- package/lib/components/LeftNav/Item/types.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/types.js +5 -1
- package/lib/components/LeftNav/index.test.js +13 -3
- package/lib/components/LeftNav/schema.d.ts.map +1 -1
- package/lib/components/LeftNav/schema.js +2 -0
- package/lib/components/LeftNav/types.d.ts +1 -0
- package/lib/components/LeftNav/types.d.ts.map +1 -1
- package/lib/components/LeftNav/types.js +5 -1
- package/lib/components/Link/index.d.ts +2 -2
- package/lib/components/Link/index.d.ts.map +1 -1
- package/lib/components/Link/index.js +1 -1
- package/lib/components/Link/index.test.js +8 -0
- package/lib/components/Link/schema.d.ts.map +1 -1
- package/lib/components/Link/schema.js +1 -1
- package/lib/components/Menu/index.d.ts.map +1 -1
- package/lib/components/Menu/index.js +3 -1
- package/lib/components/Menu/types.d.ts +2 -0
- package/lib/components/Menu/types.d.ts.map +1 -1
- package/lib/components/Menu/types.js +5 -1
- package/lib/components/Modal/components.d.ts +2 -2
- package/lib/components/Modal/index.d.ts.map +1 -1
- package/lib/components/Modal/index.js +5 -5
- package/lib/components/Modal/index.test.js +32 -0
- package/lib/components/Modal/schema.d.ts.map +1 -1
- package/lib/components/Modal/schema.js +2 -2
- package/lib/components/Modal/types.d.ts +2 -2
- package/lib/components/Modal/types.d.ts.map +1 -1
- package/lib/components/Modal/types.js +5 -1
- package/lib/components/Notifications/Notification/components.d.ts +3 -3
- package/lib/components/Notifications/Notification/components.d.ts.map +1 -1
- package/lib/components/Notifications/Notification/components.js +12 -6
- package/lib/components/Notifications/Notification/index.d.ts +3 -6
- package/lib/components/Notifications/Notification/index.d.ts.map +1 -1
- package/lib/components/Notifications/Notification/index.js +19 -12
- package/lib/components/Notifications/Notification/index.test.js +38 -19
- package/lib/components/Notifications/NotificationsPanel/index.d.ts +2 -1
- package/lib/components/Notifications/NotificationsPanel/index.d.ts.map +1 -1
- package/lib/components/Notifications/NotificationsPanel/index.js +44 -21
- package/lib/components/Notifications/NotificationsPanel/schema.js +1 -1
- package/lib/components/Notifications/Notifier.test.js +79 -10
- package/lib/components/Notifications/constants.d.ts +2 -0
- package/lib/components/Notifications/constants.d.ts.map +1 -0
- package/lib/components/Notifications/constants.js +16 -0
- package/lib/components/Notifications/schema.d.ts.map +1 -1
- package/lib/components/Notifications/schema.js +2 -1
- package/lib/components/Notifications/useNotifications.d.ts +1 -0
- package/lib/components/Notifications/useNotifications.d.ts.map +1 -1
- package/lib/components/Notifications/useNotifications.js +3 -3
- package/lib/components/Notifications/useNotifications.test.js +7 -4
- package/lib/components/Pagination/Pagination.d.ts +1 -1
- package/lib/components/Pagination/Pagination.d.ts.map +1 -1
- package/lib/components/Pagination/Pagination.js +1 -0
- package/lib/components/Pagination/Pagination.test.js +9 -0
- package/lib/components/Pagination/types.js +5 -1
- package/lib/components/Popover/utils.d.ts +1 -1
- package/lib/components/Select/Target.js +1 -1
- package/lib/components/Select/index.d.ts.map +1 -1
- package/lib/components/Select/index.js +37 -1
- package/lib/components/Select/index.test.js +82 -23
- package/lib/components/Select/schema.d.ts.map +1 -1
- package/lib/components/Select/schema.js +7 -0
- package/lib/components/Select/types.d.ts +4 -1
- package/lib/components/Select/types.d.ts.map +1 -1
- package/lib/components/Select/types.js +5 -1
- package/lib/components/SelectDate/Target.js +1 -1
- package/lib/components/SelectDate/index.d.ts.map +1 -1
- package/lib/components/SelectDate/index.js +28 -1
- package/lib/components/SelectDate/index.test.js +108 -51
- package/lib/components/SelectDate/schema.d.ts.map +1 -1
- package/lib/components/SelectDate/schema.js +2 -0
- package/lib/components/SelectDate/types.d.ts +2 -0
- package/lib/components/SelectDate/types.d.ts.map +1 -1
- package/lib/components/SelectDate/types.js +5 -1
- package/lib/components/SelectDateRange/index.d.ts.map +1 -1
- package/lib/components/SelectDateRange/index.js +28 -1
- package/lib/components/SelectDateRange/index.test.js +115 -58
- package/lib/components/SelectDateRange/schema.d.ts.map +1 -1
- package/lib/components/SelectDateRange/schema.js +2 -0
- package/lib/components/SelectDateRange/types.js +5 -1
- package/lib/components/SelectMenu/index.d.ts +5 -0
- package/lib/components/SelectMenu/index.d.ts.map +1 -1
- package/lib/components/SelectMenu/index.js +27 -3
- package/lib/components/SelectMenu/schema.d.ts.map +1 -1
- package/lib/components/SelectMenu/schema.js +4 -0
- package/lib/components/Table/Body.d.ts.map +1 -1
- package/lib/components/Table/Body.js +182 -38
- package/lib/components/Table/Container.d.ts.map +1 -1
- package/lib/components/Table/Container.js +2 -2
- package/lib/components/Table/DataRow.d.ts.map +1 -1
- package/lib/components/Table/DataRow.js +43 -16
- package/lib/components/Table/DraggableWrapper.d.ts +5 -0
- package/lib/components/Table/DraggableWrapper.d.ts.map +1 -0
- package/lib/components/Table/DraggableWrapper.js +38 -0
- package/lib/components/Table/Grip.d.ts +4 -0
- package/lib/components/Table/Grip.d.ts.map +1 -0
- package/lib/components/Table/Grip.js +30 -0
- package/lib/components/Table/Head.d.ts +1 -1
- package/lib/components/Table/Head.d.ts.map +1 -1
- package/lib/components/Table/Head.js +11 -5
- package/lib/components/Table/HeaderCell/index.d.ts.map +1 -1
- package/lib/components/Table/HeaderCell/index.js +22 -8
- package/lib/components/Table/HeaderCell/types.d.ts +6 -1
- package/lib/components/Table/HeaderCell/types.d.ts.map +1 -1
- package/lib/components/Table/HeaderCell/types.js +5 -1
- package/lib/components/Table/Provider.d.ts +13 -4
- package/lib/components/Table/Provider.d.ts.map +1 -1
- package/lib/components/Table/Provider.js +45 -5
- package/lib/components/Table/index.d.ts.map +1 -1
- package/lib/components/Table/index.js +112 -18
- package/lib/components/Table/index.test.js +330 -84
- package/lib/components/Table/schema.columns.d.ts.map +1 -1
- package/lib/components/Table/schema.columns.js +6 -4
- package/lib/components/Table/schema.d.ts.map +1 -1
- package/lib/components/Table/schema.js +8 -6
- package/lib/components/Table/types.d.ts +34 -4
- package/lib/components/Table/types.d.ts.map +1 -1
- package/lib/components/Table/utils.d.ts +2 -8
- package/lib/components/Table/utils.d.ts.map +1 -1
- package/lib/components/Table/utils.js +21 -20
- package/lib/components/Tabs/types.js +5 -1
- package/lib/components/Tag/types.d.ts +1 -1
- package/lib/components/Tag/types.d.ts.map +1 -1
- package/lib/components/Tag/types.js +5 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextArea/index.js +1 -0
- package/lib/components/TextArea/index.test.js +5 -0
- package/lib/components/TextField/Input.js +1 -1
- package/lib/components/TextField/index.test.js +5 -0
- package/lib/components/Toggle/index.d.ts.map +1 -1
- package/lib/components/Toggle/index.js +4 -0
- package/lib/components/Toggle/index.test.js +39 -10
- package/lib/components/Toggle/types.js +5 -1
- package/lib/components/TopNav/BrandInfo/index.d.ts +2 -1
- package/lib/components/TopNav/BrandInfo/index.d.ts.map +1 -1
- package/lib/components/TopNav/BrandInfo/index.js +9 -1
- package/lib/components/TopNav/BrandInfo/schema.d.ts.map +1 -1
- package/lib/components/TopNav/BrandInfo/schema.js +4 -1
- package/lib/components/TopNav/index.test.js +28 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +9 -0
- package/lib/providers/ConfigProvider/index.d.ts.map +1 -1
- package/lib/providers/ConfigProvider/index.js +5 -1
- package/lib/providers/ConfigProvider/utils/context.d.ts +1 -1
- package/lib/providers/ConfigProvider/utils/context.d.ts.map +1 -1
- package/lib/providers/ConfigProvider/utils/normalizer.d.ts.map +1 -1
- package/lib/providers/ConfigProvider/utils/normalizer.js +1 -1
- package/lib/providers/ConfigProvider/utils/translations.d.ts +1 -1
- package/lib/providers/ConfigProvider/utils/translations.js +1 -1
- package/lib/providers/NotificationsProvider/index.d.ts +6 -5
- package/lib/providers/NotificationsProvider/index.d.ts.map +1 -1
- package/lib/providers/NotificationsProvider/index.js +47 -28
- package/lib/providers/NotificationsProvider/types.d.ts +4 -1
- package/lib/providers/NotificationsProvider/types.d.ts.map +1 -1
- package/lib/utils/joinClassnames.d.ts +3 -0
- package/lib/utils/joinClassnames.d.ts.map +1 -0
- package/lib/utils/joinClassnames.js +26 -0
- package/lib/utils/useFirstMount.d.ts +2 -0
- package/lib/utils/useFirstMount.d.ts.map +1 -0
- package/lib/utils/useFirstMount.js +19 -0
- package/lib/utils/useUpdateEffect.d.ts +4 -0
- package/lib/utils/useUpdateEffect.d.ts.map +1 -0
- package/lib/utils/useUpdateEffect.js +28 -0
- package/package.json +4 -2
- package/lib/atoms/InputField/RequiredIcon.d.ts +0 -4
- package/lib/atoms/InputField/RequiredIcon.d.ts.map +0 -1
|
@@ -41,6 +41,8 @@ var item0Id = '0';
|
|
|
41
41
|
var item0Label = 'Option 0';
|
|
42
42
|
var item2Id = '2';
|
|
43
43
|
var item2Label = 'Option 2';
|
|
44
|
+
var disabledItemLabel = 'Option 4';
|
|
45
|
+
var disabledItemId = '4';
|
|
44
46
|
var items = [{
|
|
45
47
|
id: item0Id,
|
|
46
48
|
label: item0Label,
|
|
@@ -75,8 +77,8 @@ var items = [{
|
|
|
75
77
|
}, {
|
|
76
78
|
label: 'Category 2',
|
|
77
79
|
items: [{
|
|
78
|
-
id:
|
|
79
|
-
label:
|
|
80
|
+
id: disabledItemId,
|
|
81
|
+
label: disabledItemLabel,
|
|
80
82
|
value: '4',
|
|
81
83
|
disabled: true
|
|
82
84
|
}, {
|
|
@@ -189,15 +191,58 @@ describe('OptionsList', function () {
|
|
|
189
191
|
expect(onChange).toHaveBeenCalledWith(selectedItem.id);
|
|
190
192
|
expect(getByLabelText(selectedItem.label)).toBeChecked();
|
|
191
193
|
});
|
|
194
|
+
describe('selecting disabled element with keyboard', function () {
|
|
195
|
+
it('selects an item with Enter or Space key', function () {
|
|
196
|
+
var onChange = jest.fn();
|
|
197
|
+
var onlyDisabledItems = [{
|
|
198
|
+
id: '2',
|
|
199
|
+
label: 'Option 2',
|
|
200
|
+
value: '2',
|
|
201
|
+
disabled: true
|
|
202
|
+
}, {
|
|
203
|
+
id: disabledItemId,
|
|
204
|
+
label: disabledItemLabel,
|
|
205
|
+
value: '4',
|
|
206
|
+
disabled: true
|
|
207
|
+
}];
|
|
208
|
+
|
|
209
|
+
var _render5 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
210
|
+
items: onlyDisabledItems,
|
|
211
|
+
onChange: onChange
|
|
212
|
+
}))),
|
|
213
|
+
getByLabelText = _render5.getByLabelText,
|
|
214
|
+
container = _render5.container;
|
|
215
|
+
|
|
216
|
+
var optionsList = container.querySelector('ul'); // simulate it is focused while tabbing
|
|
217
|
+
|
|
218
|
+
_react2.fireEvent.keyDown(container, {
|
|
219
|
+
key: 'Tab'
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
_react2.fireEvent.focus(optionsList);
|
|
223
|
+
|
|
224
|
+
_react2.fireEvent.keyDown(optionsList, {
|
|
225
|
+
key: 'ArrowDown'
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
_react2.fireEvent.keyDown(optionsList, {
|
|
229
|
+
key: 'Enter'
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
expect(onChange).not.toHaveBeenCalledWith(disabledItemId);
|
|
233
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
234
|
+
expect(getByLabelText(disabledItemLabel)).not.toBeChecked();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
192
237
|
describe('single selection', function () {
|
|
193
238
|
it('calls onChange with id when item is clicked', function () {
|
|
194
239
|
var onChange = jest.fn();
|
|
195
240
|
|
|
196
|
-
var
|
|
241
|
+
var _render6 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
197
242
|
onChange: onChange
|
|
198
243
|
}))),
|
|
199
|
-
getByText =
|
|
200
|
-
getByLabelText =
|
|
244
|
+
getByText = _render6.getByText,
|
|
245
|
+
getByLabelText = _render6.getByLabelText;
|
|
201
246
|
|
|
202
247
|
var item = items[0];
|
|
203
248
|
|
|
@@ -212,15 +257,33 @@ describe('OptionsList', function () {
|
|
|
212
257
|
|
|
213
258
|
expect(getByLabelText(subItem.label)).toBeChecked();
|
|
214
259
|
});
|
|
260
|
+
describe('disabled element', function () {
|
|
261
|
+
it('does not calls onChange when item is clicked', function () {
|
|
262
|
+
var onChange = jest.fn();
|
|
263
|
+
|
|
264
|
+
var _render7 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
265
|
+
onChange: onChange
|
|
266
|
+
}))),
|
|
267
|
+
getByText = _render7.getByText,
|
|
268
|
+
getByLabelText = _render7.getByLabelText;
|
|
269
|
+
|
|
270
|
+
_react2.fireEvent.click(getByText(disabledItemLabel));
|
|
271
|
+
|
|
272
|
+
expect(onChange).not.toHaveBeenLastCalledWith(disabledItemId);
|
|
273
|
+
expect(onChange).not.toHaveBeenCalled(); // the item shouldn't be marked as selected
|
|
274
|
+
|
|
275
|
+
expect(getByLabelText(disabledItemLabel)).not.toBeChecked();
|
|
276
|
+
});
|
|
277
|
+
});
|
|
215
278
|
describe('controlled', function () {
|
|
216
279
|
it('prefers value over internal', function () {
|
|
217
280
|
var selected = items[1];
|
|
218
281
|
|
|
219
|
-
var
|
|
282
|
+
var _render8 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
220
283
|
selected: selected.id
|
|
221
284
|
}))),
|
|
222
|
-
getByText =
|
|
223
|
-
getByLabelText =
|
|
285
|
+
getByText = _render8.getByText,
|
|
286
|
+
getByLabelText = _render8.getByLabelText;
|
|
224
287
|
|
|
225
288
|
var item = items[0];
|
|
226
289
|
|
|
@@ -235,12 +298,12 @@ describe('OptionsList', function () {
|
|
|
235
298
|
it('calls onChange with array of selected ids when item is clicked', function () {
|
|
236
299
|
var onChange = jest.fn();
|
|
237
300
|
|
|
238
|
-
var
|
|
301
|
+
var _render9 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
239
302
|
onChange: onChange,
|
|
240
303
|
multiple: true
|
|
241
304
|
}))),
|
|
242
|
-
getByText =
|
|
243
|
-
getByLabelText =
|
|
305
|
+
getByText = _render9.getByText,
|
|
306
|
+
getByLabelText = _render9.getByLabelText;
|
|
244
307
|
|
|
245
308
|
var item = items[0];
|
|
246
309
|
|
|
@@ -259,5 +322,38 @@ describe('OptionsList', function () {
|
|
|
259
322
|
|
|
260
323
|
expect(onChange).toHaveBeenLastCalledWith([subItem.id]);
|
|
261
324
|
});
|
|
325
|
+
it('adds a footer with buttons when actions are provided', function () {
|
|
326
|
+
var onClick = jest.fn();
|
|
327
|
+
var actions = [{
|
|
328
|
+
id: '1',
|
|
329
|
+
text: 'apply',
|
|
330
|
+
onClick: onClick
|
|
331
|
+
}, {
|
|
332
|
+
id: '2',
|
|
333
|
+
text: 'cancel',
|
|
334
|
+
kind: 'secondary',
|
|
335
|
+
onClick: onClick
|
|
336
|
+
}, {
|
|
337
|
+
id: '3',
|
|
338
|
+
text: 'clear',
|
|
339
|
+
kind: 'secondary',
|
|
340
|
+
variant: 'ghost',
|
|
341
|
+
paddingLeft: 4,
|
|
342
|
+
onClick: onClick
|
|
343
|
+
}];
|
|
344
|
+
|
|
345
|
+
var _render10 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
346
|
+
actions: actions,
|
|
347
|
+
multiple: true
|
|
348
|
+
}))),
|
|
349
|
+
baseElement = _render10.baseElement,
|
|
350
|
+
getByText = _render10.getByText;
|
|
351
|
+
|
|
352
|
+
actions.forEach(function (_ref5) {
|
|
353
|
+
var label = _ref5.text;
|
|
354
|
+
return expect(getByText(label)).toBeTruthy();
|
|
355
|
+
});
|
|
356
|
+
expect(baseElement).toMatchSnapshot();
|
|
357
|
+
});
|
|
262
358
|
});
|
|
263
359
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAA2C,CAAC;AAoExD,eAAe,MAAM,CAAC"}
|
|
@@ -15,6 +15,10 @@ var schema = (0, _reactDesc.describe)({
|
|
|
15
15
|
schema.makePropTypes = function () {
|
|
16
16
|
return {
|
|
17
17
|
defaultSelected: _reactDesc.PropTypes.oneOfType([_reactDesc.PropTypes.string, _reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.string)]).description('These IDs will appear as selected the first time the user opens the dropdown.'),
|
|
18
|
+
actions: _reactDesc.PropTypes.oneOfType([_reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.object), _reactDesc.PropTypes.shape({
|
|
19
|
+
left: _reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.object),
|
|
20
|
+
right: _reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.object)
|
|
21
|
+
})]).description('A collection of objects, each containing a subset of props valid for a Button component. Check the notes below.'),
|
|
18
22
|
items: _reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.shape({
|
|
19
23
|
decoration: _reactDesc.PropTypes.shape({
|
|
20
24
|
type: _reactDesc.PropTypes.oneOf(['Avatar', 'Badge', 'Icon'])
|
|
@@ -4,6 +4,7 @@ import { IconProps } from '@decisiv/iconix';
|
|
|
4
4
|
import { AvatarProps } from '../../components/Avatar';
|
|
5
5
|
import { BadgeProps } from '../../components/Badge';
|
|
6
6
|
import { DimensionsProps } from '../../modifiers/dimensions';
|
|
7
|
+
import { ButtonProps } from '../../components/Button';
|
|
7
8
|
export declare type OptionAvatarProps = Omit<AvatarProps, 'ref' | 'size'>;
|
|
8
9
|
export declare type OptionBadgeProps = Omit<BadgeProps, 'size' | 'variant'>;
|
|
9
10
|
export declare type InputMethod = 'mouse' | 'keyboard' | undefined;
|
|
@@ -22,12 +23,21 @@ interface IconDecoration {
|
|
|
22
23
|
icon: IconComponent;
|
|
23
24
|
disabled?: boolean;
|
|
24
25
|
}
|
|
26
|
+
export interface ActionProps extends ButtonProps {
|
|
27
|
+
id: string;
|
|
28
|
+
}
|
|
29
|
+
interface SideActionProps {
|
|
30
|
+
left?: ActionProps[];
|
|
31
|
+
right?: ActionProps[];
|
|
32
|
+
}
|
|
33
|
+
export declare type FooterActions = SideActionProps | ActionProps[];
|
|
25
34
|
export declare type Decoration = AvatarDecoration | BadgeDecoration | IconDecoration;
|
|
26
35
|
export interface Category {
|
|
27
36
|
borderRadius?: BorderRadiusProperty<string>;
|
|
28
37
|
id?: string;
|
|
29
38
|
items: Option[];
|
|
30
39
|
label: string;
|
|
40
|
+
showCheckbox?: boolean;
|
|
31
41
|
}
|
|
32
42
|
export declare type CategoryProps = Category;
|
|
33
43
|
export declare type IconComponent = (props: IconProps) => JSX.Element;
|
|
@@ -37,6 +47,8 @@ interface BaseOption {
|
|
|
37
47
|
disabled?: boolean;
|
|
38
48
|
id: string;
|
|
39
49
|
label: string;
|
|
50
|
+
showCheckbox?: boolean;
|
|
51
|
+
meta?: object;
|
|
40
52
|
}
|
|
41
53
|
export interface ItemOption extends BaseOption {
|
|
42
54
|
value?: string;
|
|
@@ -49,6 +61,7 @@ export declare type OptionProps = Option;
|
|
|
49
61
|
export declare type Item = Category | Option;
|
|
50
62
|
export interface OptionsListProps extends OptionsListDimensions {
|
|
51
63
|
items: Item[];
|
|
64
|
+
actions?: FooterActions;
|
|
52
65
|
name?: string;
|
|
53
66
|
multiple?: boolean;
|
|
54
67
|
onChange: (ids: Selection) => void;
|
|
@@ -59,6 +72,7 @@ export interface OptionsListProps extends OptionsListDimensions {
|
|
|
59
72
|
defaultActiveId?: string;
|
|
60
73
|
onChangeActiveItem?: (activeId: string) => void;
|
|
61
74
|
onKeyDown?: (event: KeyboardEvent) => void;
|
|
75
|
+
showCheckbox?: boolean;
|
|
62
76
|
tabIndex?: number;
|
|
63
77
|
selectable?: boolean;
|
|
64
78
|
defaultSelected?: Selection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefForwardingComponent, RefAttributes } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
marginLeft?: string;
|
|
4
|
+
marginTop?: string;
|
|
5
|
+
}
|
|
6
|
+
declare type RequiredIconType = RefForwardingComponent<HTMLDivElement, RefAttributes<HTMLDivElement> & Props>;
|
|
7
|
+
declare const RequiredIcon: RequiredIconType;
|
|
8
|
+
export default RequiredIcon;
|
|
9
|
+
//# sourceMappingURL=RequiredIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequiredIcon.d.ts","sourceRoot":"","sources":["../../src/atoms/RequiredIcon.tsx"],"names":[],"mappings":"AACA,OAAc,EACZ,sBAAsB,EAGtB,aAAa,EACd,MAAM,OAAO,CAAC;AAOf,UAAU,KAAK;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,aAAK,gBAAgB,GAAG,sBAAsB,CAC5C,cAAc,EACd,aAAa,CAAC,cAAc,CAAC,GAAG,KAAK,CACtC,CAAC;AAEF,QAAA,MAAM,YAAY,EAAE,gBASnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -21,10 +21,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
|
|
22
22
|
function _extends() { _extends = Object.assign || 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); }
|
|
23
23
|
|
|
24
|
-
var RequiredIconContainer = _styledComponents.default.
|
|
24
|
+
var RequiredIconContainer = _styledComponents.default.div.withConfig({
|
|
25
25
|
displayName: "RequiredIcon__RequiredIconContainer",
|
|
26
|
-
componentId: "
|
|
27
|
-
})(["margin-left:
|
|
26
|
+
componentId: "sc-18pnvm5-0"
|
|
27
|
+
})(["display:inline;margin-left:", ";margin-top:", ";"], function (props) {
|
|
28
|
+
return props.marginLeft || '3px';
|
|
29
|
+
}, function (props) {
|
|
30
|
+
return props.marginTop || '0px';
|
|
31
|
+
});
|
|
28
32
|
|
|
29
33
|
var RequiredIcon = (0, _react.forwardRef)(function (props, ref) {
|
|
30
34
|
return _react.default.createElement(RequiredIconContainer, _extends({}, props, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/constants.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAKzC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sizeStyles = void 0;
|
|
7
|
+
|
|
8
|
+
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
/* eslint-disable import/prefer-default-export */
|
|
13
|
+
var makeSizeStyles = function makeSizeStyles(size) {
|
|
14
|
+
var value = (0, _rem.default)(size);
|
|
15
|
+
return {
|
|
16
|
+
width: value,
|
|
17
|
+
minWidth: value,
|
|
18
|
+
height: value,
|
|
19
|
+
minHeight: value
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var sizeStyles = {
|
|
24
|
+
'small.square': makeSizeStyles(20),
|
|
25
|
+
'medium.round': makeSizeStyles(36),
|
|
26
|
+
'medium.square': makeSizeStyles(30),
|
|
27
|
+
'large.round': makeSizeStyles(60)
|
|
28
|
+
};
|
|
29
|
+
exports.sizeStyles = sizeStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAmB,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAQvE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA2B,MAAM,SAAS,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAsDhC,QAAA,MAAM,YAAY,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAE9D,CAAC;AAQF,eAAe,YAAY,CAAC"}
|
|
@@ -17,8 +17,6 @@ Object.defineProperty(exports, "BadgeProps", {
|
|
|
17
17
|
});
|
|
18
18
|
exports.default = void 0;
|
|
19
19
|
|
|
20
|
-
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
21
|
-
|
|
22
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
23
21
|
|
|
24
22
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
@@ -27,16 +25,18 @@ var _styledComponentsModifiers = require("styled-components-modifiers");
|
|
|
27
25
|
|
|
28
26
|
var _color = _interopRequireDefault(require("../../modifiers/color"));
|
|
29
27
|
|
|
28
|
+
var _constants = require("./constants");
|
|
29
|
+
|
|
30
30
|
var _commonUIColors = require("../../utils/commonUIColors");
|
|
31
31
|
|
|
32
32
|
var _utils = require("../../utils");
|
|
33
33
|
|
|
34
34
|
var _types = require("./types");
|
|
35
35
|
|
|
36
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
37
|
-
|
|
38
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
37
|
|
|
38
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
39
|
+
|
|
40
40
|
function _extends() { _extends = Object.assign || 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); }
|
|
41
41
|
|
|
42
42
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -48,32 +48,21 @@ var colorModifiers = (0, _utils.applyDynamicModifiers)('color', function (_ref)
|
|
|
48
48
|
return (0, _styledComponents.css)(["", ""], color && color in _commonUIColors.commonUIColors && (0, _color.default)(_commonUIColors.commonUIColors[color]));
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
var makeSizeStyles = function makeSizeStyles(size) {
|
|
52
|
-
return {
|
|
53
|
-
width: (0, _rem.default)(size),
|
|
54
|
-
minWidth: (0, _rem.default)(size),
|
|
55
|
-
height: (0, _rem.default)(size),
|
|
56
|
-
minHeight: (0, _rem.default)(size)
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var sizeStyles = {
|
|
61
|
-
'medium.round': makeSizeStyles(36),
|
|
62
|
-
'medium.square': makeSizeStyles(30),
|
|
63
|
-
'large.round': makeSizeStyles(60)
|
|
64
|
-
};
|
|
65
|
-
|
|
66
51
|
var getSizeStyles = function getSizeStyles(key) {
|
|
67
|
-
return (0, _styledComponents.css)(sizeStyles[key] || '');
|
|
52
|
+
return (0, _styledComponents.css)(_constants.sizeStyles[key] || '');
|
|
68
53
|
};
|
|
69
54
|
|
|
70
55
|
var sizeModifiers = (0, _styledComponentsModifiers.applyStyleModifiers)({
|
|
71
|
-
|
|
56
|
+
small: function small(_ref2) {
|
|
72
57
|
var v = _ref2.variant;
|
|
73
|
-
return getSizeStyles("
|
|
58
|
+
return getSizeStyles("small.".concat(v));
|
|
74
59
|
},
|
|
75
|
-
|
|
60
|
+
medium: function medium(_ref3) {
|
|
76
61
|
var v = _ref3.variant;
|
|
62
|
+
return getSizeStyles("medium.".concat(v));
|
|
63
|
+
},
|
|
64
|
+
large: function large(_ref4) {
|
|
65
|
+
var v = _ref4.variant;
|
|
77
66
|
return getSizeStyles("large.".concat(v));
|
|
78
67
|
}
|
|
79
68
|
}, 'size');
|
|
@@ -10,6 +10,8 @@ var _Home = _interopRequireDefault(require("@decisiv/iconix/lib/components/Home"
|
|
|
10
10
|
|
|
11
11
|
var _ = _interopRequireDefault(require("."));
|
|
12
12
|
|
|
13
|
+
var _constants = require("./constants");
|
|
14
|
+
|
|
13
15
|
var _commonUIColors = require("../../utils/commonUIColors");
|
|
14
16
|
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -53,16 +55,25 @@ describe('Badge', function () {
|
|
|
53
55
|
expect(container).toMatchSnapshot();
|
|
54
56
|
});
|
|
55
57
|
});
|
|
58
|
+
it("renders correctly with size=\"small\" and variant=\"square\"", function () {
|
|
59
|
+
var _renderBadge3 = renderBadge({
|
|
60
|
+
size: 'small',
|
|
61
|
+
variant: 'square'
|
|
62
|
+
}),
|
|
63
|
+
container = _renderBadge3.container;
|
|
64
|
+
|
|
65
|
+
expect(container).toMatchSnapshot();
|
|
66
|
+
});
|
|
56
67
|
it('renders correctly in any of the common UI colors', function () {
|
|
57
68
|
Object.entries(_commonUIColors.commonUIColors).forEach(function (_ref) {
|
|
58
69
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
59
70
|
key = _ref2[0],
|
|
60
71
|
value = _ref2[1];
|
|
61
72
|
|
|
62
|
-
var
|
|
73
|
+
var _renderBadge4 = renderBadge({
|
|
63
74
|
color: key
|
|
64
75
|
}),
|
|
65
|
-
container =
|
|
76
|
+
container = _renderBadge4.container;
|
|
66
77
|
|
|
67
78
|
expect(container.firstChild).toHaveStyleRule('background-color', (0, _toColorString.default)(value));
|
|
68
79
|
});
|
|
@@ -75,12 +86,44 @@ describe('Badge', function () {
|
|
|
75
86
|
// @ts-ignore
|
|
76
87
|
console.error.mockRestore();
|
|
77
88
|
});
|
|
78
|
-
it('warns
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
it('warns for invalid size/variant combinations', function () {
|
|
90
|
+
var sizes = ['small', 'medium', 'large'];
|
|
91
|
+
var variants = ['round', 'square'];
|
|
92
|
+
var validCombinations = Object.keys(_constants.sizeStyles);
|
|
93
|
+
|
|
94
|
+
for (var _i2 = 0, _sizes = sizes; _i2 < _sizes.length; _i2++) {
|
|
95
|
+
var size = _sizes[_i2];
|
|
96
|
+
var _iteratorNormalCompletion = true;
|
|
97
|
+
var _didIteratorError = false;
|
|
98
|
+
var _iteratorError = undefined;
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
for (var _iterator = variants[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
102
|
+
var variant = _step.value;
|
|
103
|
+
|
|
104
|
+
if (!validCombinations.includes("".concat(size, ".").concat(variant))) {
|
|
105
|
+
renderBadge({
|
|
106
|
+
size: size,
|
|
107
|
+
variant: variant
|
|
108
|
+
});
|
|
109
|
+
expect(console.error).toHaveBeenCalledWith("Warning: Failed prop type: The Badge component does not support the '".concat(size, "' size and '").concat(variant, "' variant props combination.\n in Badge"));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_didIteratorError = true;
|
|
114
|
+
_iteratorError = err;
|
|
115
|
+
} finally {
|
|
116
|
+
try {
|
|
117
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
118
|
+
_iterator.return();
|
|
119
|
+
}
|
|
120
|
+
} finally {
|
|
121
|
+
if (_didIteratorError) {
|
|
122
|
+
throw _iteratorError;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
84
127
|
});
|
|
85
128
|
});
|
|
86
129
|
});
|
|
@@ -15,7 +15,7 @@ schema.propTypes = {
|
|
|
15
15
|
'aria-label': _reactDesc.PropTypes.string.description('Descriptive text for accessibility purposes').isRequired,
|
|
16
16
|
color: _reactDesc.PropTypes.string.description('(See note) Sets the color for the background and the icon').defaultValue('information'),
|
|
17
17
|
icon: _reactDesc.PropTypes.element.description('Must be an icon component from `@decisiv/iconix`').isRequired,
|
|
18
|
-
size: _reactDesc.PropTypes.oneOf(['medium', 'large']).description('(See note) Sets the size of the badge').defaultValue('medium'),
|
|
18
|
+
size: _reactDesc.PropTypes.oneOf(['small', 'medium', 'large']).description('(See note) Sets the size of the badge').defaultValue('medium'),
|
|
19
19
|
variant: _reactDesc.PropTypes.oneOf(['round', 'square']).description('(See note) Controls primary style variations of the badge').defaultValue('round')
|
|
20
20
|
};
|
|
21
21
|
var _default = schema;
|
|
@@ -8,7 +8,7 @@ export interface BadgeProps {
|
|
|
8
8
|
'aria-label': string;
|
|
9
9
|
color?: CommonUIColorKeys;
|
|
10
10
|
icon: IconComponent;
|
|
11
|
-
size?: 'medium' | 'large';
|
|
11
|
+
size?: 'small' | 'medium' | 'large';
|
|
12
12
|
variant?: 'round' | 'square';
|
|
13
13
|
}
|
|
14
14
|
declare function variantValidator(props: BadgeProps, propName: 'variant', componentName: 'Badge'): Error | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAIpC,aAAK,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAEvD,oBAAY,QAAQ,GAAG,cAAc,CAAC;AAItC,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC9B;AAED,iBAAS,gBAAgB,CACvB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,SAAS,EACnB,aAAa,EAAE,OAAO,GACrB,KAAK,GAAG,IAAI,CAqBd;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
|
|
@@ -9,15 +9,19 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
var _commonUIColors = require("../../utils/commonUIColors");
|
|
11
11
|
|
|
12
|
+
var _constants = require("./constants");
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
16
|
+
var validSizeVariantCombinations = Object.keys(_constants.sizeStyles);
|
|
17
|
+
|
|
14
18
|
function variantValidator(props, propName, componentName) {
|
|
15
19
|
if (process.env.NODE_ENV !== 'production') {
|
|
16
20
|
var size = props.size,
|
|
17
21
|
variant = props[propName];
|
|
18
22
|
|
|
19
|
-
if (size
|
|
20
|
-
return Error("The
|
|
23
|
+
if (!validSizeVariantCombinations.includes("".concat(size, ".").concat(variant))) {
|
|
24
|
+
return Error("The Badge component does not support the '".concat(size, "' size and '").concat(variant, "' variant props combination."));
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
_propTypes.default.checkPropTypes({
|
|
@@ -33,7 +37,7 @@ function variantValidator(props, propName, componentName) {
|
|
|
33
37
|
var propTypes = {
|
|
34
38
|
color: _propTypes.default.oneOf(_commonUIColors.commonUIColorKeys),
|
|
35
39
|
icon: _propTypes.default.elementType.isRequired,
|
|
36
|
-
size: _propTypes.default.oneOf(['medium', 'large']),
|
|
40
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
37
41
|
variant: variantValidator
|
|
38
42
|
};
|
|
39
43
|
exports.propTypes = propTypes;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { Validator } from 'prop-types';
|
|
2
|
+
export declare const makeButtonSchemaPropTypes: (extensions?: {
|
|
3
|
+
[x: string]: Validator<unknown>;
|
|
4
|
+
} | undefined) => {
|
|
5
|
+
[x: string]: Validator<unknown>;
|
|
6
|
+
};
|
|
2
7
|
declare const schema: any;
|
|
3
8
|
export default schema;
|
|
4
9
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Button/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Button/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,yBAAyB;;;;CAiCpC,CAAC;AAEH,QAAA,MAAM,MAAM,KAAsC,CAAC;AAInD,eAAe,MAAM,CAAC"}
|
|
@@ -7,9 +7,14 @@ exports.default = exports.makeButtonSchemaPropTypes = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _reactDesc = require("react-desc");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
|
|
16
|
+
var makeButtonSchemaPropTypes = function makeButtonSchemaPropTypes(extensions) {
|
|
17
|
+
return _objectSpread({
|
|
13
18
|
text: _reactDesc.PropTypes.string.description("The button's text"),
|
|
14
19
|
disabled: _reactDesc.PropTypes.bool.description('Defines if the button will be disabled').defaultValue('false'),
|
|
15
20
|
size: _reactDesc.PropTypes.oneOf(['small', 'medium']).description('Defines the size of the button').defaultValue('medium'),
|
|
@@ -18,7 +23,7 @@ var makeButtonSchemaPropTypes = function makeButtonSchemaPropTypes() {
|
|
|
18
23
|
intent: _reactDesc.PropTypes.oneOf(['success', 'danger']).description('Applies desired hover state of button'),
|
|
19
24
|
kind: _reactDesc.PropTypes.oneOf(['primary', 'secondary']).description('Applies inverted button styles'),
|
|
20
25
|
variant: _reactDesc.PropTypes.oneOf(['normal', 'inverted']).description('Applies secondary button styles')
|
|
21
|
-
};
|
|
26
|
+
}, extensions);
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
exports.makeButtonSchemaPropTypes = makeButtonSchemaPropTypes;
|