@dxc-technology/halstack-react 0.0.0-ff6151e → 0.0.0-ff99b25
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/BackgroundColorContext.js +50 -0
- package/ThemeContext.js +246 -0
- package/V3Select/V3Select.js +455 -0
- package/V3Select/index.d.ts +27 -0
- package/V3Textarea/V3Textarea.js +260 -0
- package/V3Textarea/index.d.ts +27 -0
- package/accordion/Accordion.d.ts +4 -0
- package/accordion/Accordion.js +258 -0
- package/accordion/types.d.ts +68 -0
- package/accordion/types.js +5 -0
- package/accordion-group/AccordionGroup.d.ts +7 -0
- package/accordion-group/AccordionGroup.js +170 -0
- package/accordion-group/types.d.ts +72 -0
- package/accordion-group/types.js +5 -0
- package/alert/Alert.d.ts +4 -0
- package/alert/Alert.js +290 -0
- package/alert/types.d.ts +49 -0
- package/alert/types.js +5 -0
- package/badge/Badge.js +59 -0
- package/{dist/box → box}/Box.js +38 -34
- package/box/Box.stories.jsx +132 -0
- package/box/index.d.ts +25 -0
- package/button/Button.d.ts +4 -0
- package/button/Button.js +182 -0
- package/button/Button.stories.tsx +293 -0
- package/button/types.d.ts +57 -0
- package/button/types.js +5 -0
- package/card/Card.d.ts +4 -0
- package/card/Card.js +165 -0
- package/card/types.d.ts +69 -0
- package/card/types.js +5 -0
- package/checkbox/Checkbox.d.ts +4 -0
- package/checkbox/Checkbox.js +253 -0
- package/checkbox/types.d.ts +60 -0
- package/checkbox/types.js +5 -0
- package/chip/Chip.js +221 -0
- package/chip/index.d.ts +22 -0
- package/{dist/common → common}/OpenSans.css +0 -0
- package/{dist/common → common}/RequiredComponent.js +3 -11
- package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/common/utils.js +22 -0
- package/common/variables.js +1569 -0
- package/{dist/date → date}/Date.js +81 -65
- package/date/index.d.ts +27 -0
- package/date-input/DateInput.d.ts +4 -0
- package/date-input/DateInput.js +361 -0
- package/date-input/types.d.ts +100 -0
- package/date-input/types.js +5 -0
- package/dialog/Dialog.d.ts +4 -0
- package/dialog/Dialog.js +165 -0
- package/dialog/types.d.ts +43 -0
- package/dialog/types.js +5 -0
- package/dropdown/Dropdown.d.ts +4 -0
- package/dropdown/Dropdown.js +417 -0
- package/dropdown/types.d.ts +89 -0
- package/dropdown/types.js +5 -0
- package/file-input/FileInput.js +532 -0
- package/file-input/FileItem.js +193 -0
- package/file-input/index.d.ts +81 -0
- package/footer/Footer.d.ts +4 -0
- package/footer/Footer.js +266 -0
- package/footer/Footer.stories.jsx +151 -0
- package/footer/Icons.js +77 -0
- package/footer/types.d.ts +61 -0
- package/footer/types.js +5 -0
- package/header/Header.js +326 -0
- package/header/Icons.js +59 -0
- package/header/index.d.ts +25 -0
- package/heading/Heading.js +176 -0
- package/heading/index.d.ts +17 -0
- package/input-text/Icons.js +22 -0
- package/input-text/InputText.js +611 -0
- package/input-text/index.d.ts +36 -0
- package/{dist/layout → layout}/ApplicationLayout.js +42 -142
- package/layout/Icons.js +55 -0
- package/link/Link.js +183 -0
- package/link/index.d.ts +23 -0
- package/main.d.ts +44 -0
- package/{dist/main.js → main.js} +125 -65
- package/number-input/NumberInput.js +128 -0
- package/number-input/NumberInput.stories.jsx +115 -0
- package/number-input/NumberInputContext.js +16 -0
- package/number-input/index.d.ts +113 -0
- package/package.json +34 -22
- package/paginator/Icons.js +66 -0
- package/paginator/Paginator.d.ts +4 -0
- package/paginator/Paginator.js +198 -0
- package/paginator/types.d.ts +38 -0
- package/paginator/types.js +5 -0
- package/password-input/PasswordInput.js +199 -0
- package/password-input/PasswordInput.stories.jsx +131 -0
- package/password-input/index.d.ts +94 -0
- package/progress-bar/ProgressBar.d.ts +4 -0
- package/progress-bar/ProgressBar.js +170 -0
- package/progress-bar/types.d.ts +37 -0
- package/progress-bar/types.js +5 -0
- package/radio/Radio.d.ts +4 -0
- package/radio/Radio.js +174 -0
- package/radio/types.d.ts +54 -0
- package/radio/types.js +5 -0
- package/{dist/resultsetTable → resultsetTable}/ResultsetTable.js +95 -162
- package/resultsetTable/index.d.ts +19 -0
- package/select/Select.js +865 -0
- package/select/index.d.ts +131 -0
- package/sidenav/Sidenav.js +145 -0
- package/sidenav/index.d.ts +13 -0
- package/slider/Slider.d.ts +4 -0
- package/slider/Slider.js +306 -0
- package/slider/types.d.ts +83 -0
- package/slider/types.js +5 -0
- package/spinner/Spinner.js +267 -0
- package/spinner/index.d.ts +17 -0
- package/switch/Switch.d.ts +4 -0
- package/switch/Switch.js +179 -0
- package/switch/types.d.ts +58 -0
- package/switch/types.js +5 -0
- package/table/Table.js +118 -0
- package/table/index.d.ts +13 -0
- package/tabs/Tabs.d.ts +4 -0
- package/tabs/Tabs.js +211 -0
- package/tabs/types.d.ts +71 -0
- package/tabs/types.js +5 -0
- package/tag/Tag.js +208 -0
- package/tag/index.d.ts +24 -0
- package/text-input/TextInput.js +825 -0
- package/text-input/index.d.ts +135 -0
- package/textarea/Textarea.js +317 -0
- package/textarea/Textarea.stories.jsx +135 -0
- package/textarea/index.d.ts +117 -0
- package/{dist/toggle → toggle}/Toggle.js +30 -67
- package/toggle/index.d.ts +21 -0
- package/toggle-group/ToggleGroup.js +243 -0
- package/toggle-group/index.d.ts +21 -0
- package/{dist/upload → upload}/Upload.js +23 -22
- package/upload/buttons-upload/ButtonsUpload.js +111 -0
- package/upload/buttons-upload/Icons.js +40 -0
- package/upload/dragAndDropArea/DragAndDropArea.js +225 -0
- package/upload/dragAndDropArea/Icons.js +39 -0
- package/upload/file-upload/FileToUpload.js +115 -0
- package/upload/file-upload/Icons.js +66 -0
- package/upload/files-upload/FilesToUpload.js +109 -0
- package/upload/index.d.ts +15 -0
- package/upload/transaction/Icons.js +160 -0
- package/upload/transaction/Transaction.js +104 -0
- package/upload/transactions/Transactions.js +94 -0
- package/{dist/useTheme.js → useTheme.js} +0 -0
- package/wizard/Icons.js +65 -0
- package/wizard/Wizard.js +271 -0
- package/wizard/index.d.ts +18 -0
- package/README.md +0 -66
- package/babel.config.js +0 -4
- package/dist/ThemeContext.js +0 -54
- package/dist/accordion/Accordion.js +0 -273
- package/dist/accordion/Accordion.stories.js +0 -207
- package/dist/accordion/readme.md +0 -96
- package/dist/accordion-group/AccordionGroup.js +0 -159
- package/dist/accordion-group/AccordionGroup.stories.js +0 -207
- package/dist/accordion-group/readme.md +0 -70
- package/dist/alert/Alert.js +0 -304
- package/dist/alert/Alert.stories.js +0 -158
- package/dist/alert/close.svg +0 -4
- package/dist/alert/error.svg +0 -4
- package/dist/alert/info.svg +0 -4
- package/dist/alert/readme.md +0 -43
- package/dist/alert/success.svg +0 -4
- package/dist/alert/warning.svg +0 -4
- package/dist/badge/Badge.js +0 -58
- package/dist/button/Button.js +0 -202
- package/dist/button/Button.stories.js +0 -224
- package/dist/button/readme.md +0 -93
- package/dist/card/Card.js +0 -217
- package/dist/checkbox/Checkbox.js +0 -240
- package/dist/checkbox/Checkbox.stories.js +0 -144
- package/dist/checkbox/readme.md +0 -116
- package/dist/chip/Chip.js +0 -208
- package/dist/common/services/example-service.js +0 -10
- package/dist/common/services/example-service.test.js +0 -12
- package/dist/common/utils.js +0 -42
- package/dist/common/variables.js +0 -436
- package/dist/date/Date.stories.js +0 -205
- package/dist/date/calendar.svg +0 -1
- package/dist/date/calendar_dark.svg +0 -1
- package/dist/date/readme.md +0 -73
- package/dist/dialog/Dialog.js +0 -197
- package/dist/dialog/Dialog.stories.js +0 -217
- package/dist/dialog/readme.md +0 -32
- package/dist/dropdown/Dropdown.js +0 -449
- package/dist/dropdown/Dropdown.stories.js +0 -249
- package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
- package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
- package/dist/dropdown/readme.md +0 -69
- package/dist/footer/Footer.js +0 -371
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo_wht.png +0 -0
- package/dist/footer/readme.md +0 -41
- package/dist/header/Header.js +0 -373
- package/dist/header/Header.stories.js +0 -176
- package/dist/header/close_icon.svg +0 -1
- package/dist/header/dxc_logo_black.png +0 -0
- package/dist/header/dxc_logo_blk_rgb.svg +0 -6
- package/dist/header/dxc_logo_white.png +0 -0
- package/dist/header/hamb_menu_black.svg +0 -1
- package/dist/header/hamb_menu_white.svg +0 -1
- package/dist/header/readme.md +0 -33
- package/dist/heading/Heading.js +0 -153
- package/dist/input-text/InputText.js +0 -570
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/input-text/error.svg +0 -1
- package/dist/input-text/readme.md +0 -91
- package/dist/layout/facebook.svg +0 -45
- package/dist/layout/linkedin.svg +0 -50
- package/dist/layout/twitter.svg +0 -53
- package/dist/link/Link.js +0 -192
- package/dist/link/readme.md +0 -51
- package/dist/paginator/Paginator.js +0 -232
- package/dist/paginator/images/next.svg +0 -3
- package/dist/paginator/images/nextPage.svg +0 -3
- package/dist/paginator/images/previous.svg +0 -3
- package/dist/paginator/images/previousPage.svg +0 -3
- package/dist/paginator/readme.md +0 -50
- package/dist/progress-bar/ProgressBar.js +0 -185
- package/dist/progress-bar/ProgressBar.stories.js +0 -280
- package/dist/progress-bar/readme.md +0 -63
- package/dist/radio/Radio.js +0 -195
- package/dist/radio/Radio.stories.js +0 -166
- package/dist/radio/readme.md +0 -70
- package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
- package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
- package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
- package/dist/select/Select.js +0 -473
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/sidenav/Sidenav.js +0 -128
- package/dist/slider/Slider.js +0 -266
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/slider/readme.md +0 -64
- package/dist/spinner/Spinner.js +0 -193
- package/dist/spinner/Spinner.stories.js +0 -183
- package/dist/spinner/readme.md +0 -65
- package/dist/switch/Switch.js +0 -199
- package/dist/switch/Switch.stories.js +0 -134
- package/dist/switch/readme.md +0 -133
- package/dist/table/Table.js +0 -105
- package/dist/tabs/Tabs.js +0 -292
- package/dist/tabs/Tabs.stories.js +0 -130
- package/dist/tabs/readme.md +0 -78
- package/dist/tabs-for-sections/TabsForSections.js +0 -92
- package/dist/tabs-for-sections/readme.md +0 -78
- package/dist/tag/Tag.js +0 -249
- package/dist/textarea/Textarea.js +0 -227
- package/dist/toggle/Toggle.stories.js +0 -297
- package/dist/toggle/readme.md +0 -80
- package/dist/toggle-group/ToggleGroup.js +0 -226
- package/dist/toggle-group/readme.md +0 -82
- package/dist/upload/Upload.stories.js +0 -72
- package/dist/upload/buttons-upload/ButtonsUpload.js +0 -122
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -279
- package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
- package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
- package/dist/upload/file-upload/FileToUpload.js +0 -158
- package/dist/upload/file-upload/audio-icon.svg +0 -4
- package/dist/upload/file-upload/close.svg +0 -4
- package/dist/upload/file-upload/file-icon.svg +0 -4
- package/dist/upload/file-upload/video-icon.svg +0 -4
- package/dist/upload/files-upload/FilesToUpload.js +0 -123
- package/dist/upload/readme.md +0 -37
- package/dist/upload/transaction/Transaction.js +0 -155
- package/dist/upload/transaction/audio-icon-err.svg +0 -4
- package/dist/upload/transaction/audio-icon.svg +0 -4
- package/dist/upload/transaction/error-icon.svg +0 -4
- package/dist/upload/transaction/file-icon-err.svg +0 -4
- package/dist/upload/transaction/file-icon.svg +0 -4
- package/dist/upload/transaction/image-icon-err.svg +0 -4
- package/dist/upload/transaction/image-icon.svg +0 -4
- package/dist/upload/transaction/success-icon.svg +0 -4
- package/dist/upload/transaction/video-icon-err.svg +0 -4
- package/dist/upload/transaction/video-icon.svg +0 -4
- package/dist/upload/transactions/Transactions.js +0 -120
- package/dist/wizard/Wizard.js +0 -331
- package/dist/wizard/invalid_icon.svg +0 -6
- package/dist/wizard/valid_icon.svg +0 -6
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/Accordion.test.js +0 -33
- package/test/AccordionGroup.test.js +0 -109
- package/test/Alert.test.js +0 -53
- package/test/Box.test.js +0 -10
- package/test/Button.test.js +0 -18
- package/test/Card.test.js +0 -30
- package/test/Checkbox.test.js +0 -45
- package/test/Chip.test.js +0 -25
- package/test/Date.test.js +0 -393
- package/test/Dialog.test.js +0 -23
- package/test/Dropdown.test.js +0 -130
- package/test/Footer.test.js +0 -99
- package/test/Header.test.js +0 -39
- package/test/Heading.test.js +0 -35
- package/test/InputText.test.js +0 -240
- package/test/Link.test.js +0 -42
- package/test/Paginator.test.js +0 -194
- package/test/ProgressBar.test.js +0 -35
- package/test/Radio.test.js +0 -37
- package/test/ResultsetTable.test.js +0 -304
- package/test/Select.test.js +0 -192
- package/test/Sidenav.test.js +0 -45
- package/test/Slider.test.js +0 -82
- package/test/Spinner.test.js +0 -27
- package/test/Switch.test.js +0 -45
- package/test/Table.test.js +0 -36
- package/test/Tabs.test.js +0 -109
- package/test/TabsForSections.test.js +0 -34
- package/test/Tag.test.js +0 -32
- package/test/TextArea.test.js +0 -52
- package/test/ToggleGroup.test.js +0 -81
- package/test/Upload.test.js +0 -60
- package/test/Wizard.test.js +0 -130
- package/test/mocks/pngMock.js +0 -1
- package/test/mocks/svgMock.js +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
type Size = "small" | "medium" | "large" | "fillParent";
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Margin = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Text to be placed above the textarea.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Name attribute of the textarea element.
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Value of the textarea. If undefined, the component will be uncontrolled and the value will be managed internally.
|
|
21
|
+
*/
|
|
22
|
+
value?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Helper text to be placed above the textarea.
|
|
25
|
+
*/
|
|
26
|
+
helperText?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Text to be put as placeholder of the textarea.
|
|
29
|
+
*/
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the component will be disabled.
|
|
33
|
+
*/
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If true, the textarea will be optional, showing '(Optional)'
|
|
37
|
+
* next to the label. Otherwise, the field will be considered required
|
|
38
|
+
* and an error will be passed as a parameter to the OnBlur and onChange functions
|
|
39
|
+
* when it has not been filled.
|
|
40
|
+
*/
|
|
41
|
+
optional?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Defines the textarea's ability to resize vertically. It can be:
|
|
44
|
+
* - 'auto': The textarea grows or shrinks automatically in order to fit the content.
|
|
45
|
+
* - 'manual': The height of the textarea is enabled to be manually modified.
|
|
46
|
+
* - 'none': The textarea has a fixed height and can't be modified.
|
|
47
|
+
*/
|
|
48
|
+
verticalGrow?: "auto" | "manual" | "none";
|
|
49
|
+
/**
|
|
50
|
+
* Number of rows of the textarea.
|
|
51
|
+
*/
|
|
52
|
+
rows?: number;
|
|
53
|
+
/**
|
|
54
|
+
* This function will be called when the user types within the textarea.
|
|
55
|
+
* An object including the current value and the error (if the value
|
|
56
|
+
* entered is not valid) will be passed to this function.
|
|
57
|
+
* If there is no error, error will be null.
|
|
58
|
+
*/
|
|
59
|
+
onChange?: (val: { value: string; error: string }) => void;
|
|
60
|
+
/**
|
|
61
|
+
* This function will be called when the textarea loses the focus. An
|
|
62
|
+
* object including the textarea value and the error (if the value entered
|
|
63
|
+
* is not valid) will be passed to this function. If there is no error,
|
|
64
|
+
* error will be null.
|
|
65
|
+
*/
|
|
66
|
+
onBlur?: (val: { value: string; error: string }) => void;
|
|
67
|
+
/**
|
|
68
|
+
* If it is defined, the component will change its appearance, showing
|
|
69
|
+
* the error below the textarea. If it is not defined, the error
|
|
70
|
+
* messages will be managed internally, but never displayed on its own.
|
|
71
|
+
*/
|
|
72
|
+
error?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Regular expression that defines the valid format allowed by the
|
|
75
|
+
* textarea. This will be checked both when the textarea loses the focus
|
|
76
|
+
* and while typing within it. If the string entered does not match the
|
|
77
|
+
* pattern, the onBlur and onChange functions will be called with the
|
|
78
|
+
* current value and an internal error informing that this value does not
|
|
79
|
+
* match the pattern. If the pattern is met, the error parameter of both
|
|
80
|
+
* events will be null.
|
|
81
|
+
*/
|
|
82
|
+
pattern?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Specifies the minimun and maximum length allowed by the textarea.
|
|
85
|
+
* This will be checked both when the textarea loses the
|
|
86
|
+
* focus and while typing within it. If the string entered does not
|
|
87
|
+
* comply the length, the onBlur and onChange functions will be called
|
|
88
|
+
* with the current value and an internal error informing that the value
|
|
89
|
+
* length does not comply the specified range. If a valid length is
|
|
90
|
+
* reached, the error parameter of both events will be null.
|
|
91
|
+
*/
|
|
92
|
+
length?: { min: number; max: number };
|
|
93
|
+
/**
|
|
94
|
+
* HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the textarea value.
|
|
95
|
+
* Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
|
|
96
|
+
*/
|
|
97
|
+
autocomplete?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
100
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
101
|
+
*/
|
|
102
|
+
margin?: Space | Margin;
|
|
103
|
+
/**
|
|
104
|
+
* Size of the component ('small' | 'medium' | 'large' | 'fillParent').
|
|
105
|
+
*/
|
|
106
|
+
size?: Size;
|
|
107
|
+
/**
|
|
108
|
+
* Value of the tabindex attribute.
|
|
109
|
+
*/
|
|
110
|
+
tabIndex?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Reference to the component.
|
|
113
|
+
*/
|
|
114
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default function DxcTextarea(props: Props): JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
@@ -15,7 +15,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
15
15
|
|
|
16
16
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
17
|
|
|
18
|
-
var _react =
|
|
18
|
+
var _react = _interopRequireDefault(require("react"));
|
|
19
19
|
|
|
20
20
|
var _lab = require("@material-ui/lab");
|
|
21
21
|
|
|
@@ -23,53 +23,15 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
23
23
|
|
|
24
24
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
25
25
|
|
|
26
|
-
require("../common/OpenSans.css");
|
|
27
|
-
|
|
28
|
-
var _variables = require("../common/variables.js");
|
|
29
|
-
|
|
30
26
|
var _utils = require("../common/utils.js");
|
|
31
27
|
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
function _templateObject4() {
|
|
35
|
-
var data = (0, _taggedTemplateLiteral2["default"])([""]);
|
|
28
|
+
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return data;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _templateObject3() {
|
|
45
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n width: 20px;\n height: 20px;\n line-height: 1;\n margin-right: ", ";\n margin-left: ", ";\n"]);
|
|
46
|
-
|
|
47
|
-
_templateObject3 = function _templateObject3() {
|
|
48
|
-
return data;
|
|
49
|
-
};
|
|
30
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
}
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
53
33
|
|
|
54
|
-
function
|
|
55
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n line-height: 1;\n display: flex;\n align-items: center;\n flex-direction: ", ";\n"]);
|
|
56
|
-
|
|
57
|
-
_templateObject2 = function _templateObject2() {
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return data;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function _templateObject() {
|
|
65
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n & {\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n opacity: ", ";\n cursor: ", ";\n display: inline-block;\n width: ", ";\n }\n\n .MuiToggleButton-label {\n font-size: 14px;\n font-family: \"Open Sans\", sans-serif;\n color: ", ";\n }\n .MuiButtonBase-root {\n width: ", ";\n min-height: ", ";\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root {\n min-width: 42px;\n height: 43px;\n border: ", ";\n\n border-radius: 4px !important;\n }\n\n .MuiToggleButton-root.Mui-selected {\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root:last-child,\n .MuiToggleButton-root:first-child,\n .MuiToggleButton-root:not(:first-child) {\n padding: ", ";\n }\n\n .MuiTouchRipple-child {\n background-color: ", ";\n }\n"]);
|
|
66
|
-
|
|
67
|
-
_templateObject = function _templateObject() {
|
|
68
|
-
return data;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return data;
|
|
72
|
-
}
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
73
35
|
|
|
74
36
|
var DxcToggle = function DxcToggle(_ref) {
|
|
75
37
|
var _ref$label = _ref.label,
|
|
@@ -92,8 +54,7 @@ var DxcToggle = function DxcToggle(_ref) {
|
|
|
92
54
|
margin = _ref.margin,
|
|
93
55
|
_ref$size = _ref.size,
|
|
94
56
|
size = _ref$size === void 0 ? "fitContent" : _ref$size;
|
|
95
|
-
|
|
96
|
-
var colorsTheme = (0, _react.useContext)(_ThemeContext["default"]) || _variables.globalTokens;
|
|
57
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
97
58
|
|
|
98
59
|
var handlerToggleClick = function handlerToggleClick() {
|
|
99
60
|
if (!disabled && typeof onClick === "function") {
|
|
@@ -101,9 +62,9 @@ var DxcToggle = function DxcToggle(_ref) {
|
|
|
101
62
|
}
|
|
102
63
|
};
|
|
103
64
|
|
|
104
|
-
return _react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
65
|
+
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
105
66
|
theme: colorsTheme
|
|
106
|
-
}, _react["default"].createElement(DxcToggleContainer, {
|
|
67
|
+
}, /*#__PURE__*/_react["default"].createElement(DxcToggleContainer, {
|
|
107
68
|
margin: margin,
|
|
108
69
|
brightness: theme,
|
|
109
70
|
disabled: disabled,
|
|
@@ -115,21 +76,21 @@ var DxcToggle = function DxcToggle(_ref) {
|
|
|
115
76
|
value: true,
|
|
116
77
|
size: size,
|
|
117
78
|
onClick: handlerToggleClick
|
|
118
|
-
}, _react["default"].createElement(_lab.ToggleButton, {
|
|
79
|
+
}, /*#__PURE__*/_react["default"].createElement(_lab.ToggleButton, {
|
|
119
80
|
disabled: disabled,
|
|
120
81
|
disableRipple: disableRipple,
|
|
121
82
|
selected: selected,
|
|
122
83
|
label: label,
|
|
123
84
|
value: true
|
|
124
|
-
}, _react["default"].createElement(ContentContainer, {
|
|
85
|
+
}, /*#__PURE__*/_react["default"].createElement(ContentContainer, {
|
|
125
86
|
iconPosition: iconPosition,
|
|
126
87
|
label: label,
|
|
127
88
|
iconSrc: iconSrc
|
|
128
|
-
}, iconSrc !== "" && _react["default"].createElement(IconContainer, {
|
|
89
|
+
}, iconSrc !== "" && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
129
90
|
iconPosition: iconPosition,
|
|
130
91
|
label: label,
|
|
131
92
|
src: iconSrc
|
|
132
|
-
}), label !== "" && _react["default"].createElement(LabelContainer, null, label)))));
|
|
93
|
+
}), label !== "" && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label)))));
|
|
133
94
|
};
|
|
134
95
|
|
|
135
96
|
var sizes = {
|
|
@@ -148,22 +109,24 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
148
109
|
return sizes[size];
|
|
149
110
|
};
|
|
150
111
|
|
|
151
|
-
var DxcToggleContainer = _styledComponents["default"].div(_templateObject(), function (props) {
|
|
152
|
-
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ?
|
|
112
|
+
var DxcToggleContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n & {\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n opacity: ", ";\n cursor: ", ";\n display: inline-block;\n width: ", ";\n }\n\n .MuiToggleButton-label {\n font-size: 14px;\n font-family: ", ";\n color: ", ";\n }\n .MuiButtonBase-root {\n width: ", ";\n min-height: ", ";\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root {\n min-width: 42px;\n height: 43px;\n border: ", ";\n\n border-radius: 4px !important;\n }\n\n .MuiToggleButton-root.Mui-selected {\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root:last-child,\n .MuiToggleButton-root:first-child,\n .MuiToggleButton-root:not(:first-child) {\n padding: ", ";\n }\n\n .MuiTouchRipple-child {\n background-color: ", ";\n }\n"])), function (props) {
|
|
113
|
+
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? spaces[props.margin] : "0px";
|
|
153
114
|
}, function (props) {
|
|
154
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ?
|
|
115
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? spaces[props.margin.top] : "";
|
|
155
116
|
}, function (props) {
|
|
156
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ?
|
|
117
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? spaces[props.margin.right] : "";
|
|
157
118
|
}, function (props) {
|
|
158
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ?
|
|
119
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? spaces[props.margin.bottom] : "";
|
|
159
120
|
}, function (props) {
|
|
160
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ?
|
|
121
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? spaces[props.margin.left] : "";
|
|
161
122
|
}, function (props) {
|
|
162
123
|
return props.disabled ? "0.5" : "1";
|
|
163
124
|
}, function (props) {
|
|
164
125
|
return props.disabled ? "not-allowed" : "pointer";
|
|
165
126
|
}, function (props) {
|
|
166
127
|
return calculateWidth(props.margin, props.size);
|
|
128
|
+
}, function (props) {
|
|
129
|
+
return props.theme.fontFamily;
|
|
167
130
|
}, function (props) {
|
|
168
131
|
return props.brightness === "dark" && props.mode === "outlined" ? props.theme.white : props.theme.black;
|
|
169
132
|
}, function (props) {
|
|
@@ -190,17 +153,17 @@ var DxcToggleContainer = _styledComponents["default"].div(_templateObject(), fun
|
|
|
190
153
|
return props.mode === "basic" ? props.selected === false ? props.theme.yellow : props.theme.darkWhite : props.selected === false ? props.theme.lightGrey : props.theme.white;
|
|
191
154
|
});
|
|
192
155
|
|
|
193
|
-
var ContentContainer = _styledComponents["default"].span(_templateObject2(), function (props) {
|
|
156
|
+
var ContentContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: 1;\n display: flex;\n align-items: center;\n flex-direction: ", ";\n"])), function (props) {
|
|
194
157
|
return props.iconPosition === "after" ? "row-reverse" : "row";
|
|
195
158
|
});
|
|
196
159
|
|
|
197
|
-
var IconContainer = _styledComponents["default"].img(_templateObject3(), function (props) {
|
|
160
|
+
var IconContainer = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 20px;\n height: 20px;\n line-height: 1;\n margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
198
161
|
return props.label !== "" && props.iconPosition === "before" ? "10px" : "";
|
|
199
162
|
}, function (props) {
|
|
200
163
|
return props.label !== "" && props.iconPosition === "after" ? "10px" : "";
|
|
201
164
|
});
|
|
202
165
|
|
|
203
|
-
var LabelContainer = _styledComponents["default"].span(_templateObject4());
|
|
166
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
204
167
|
|
|
205
168
|
DxcToggle.propTypes = {
|
|
206
169
|
size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
|
|
@@ -213,11 +176,11 @@ DxcToggle.propTypes = {
|
|
|
213
176
|
disableRipple: _propTypes["default"].bool,
|
|
214
177
|
onClick: _propTypes["default"].func,
|
|
215
178
|
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
216
|
-
top: _propTypes["default"].oneOf(Object.keys(
|
|
217
|
-
bottom: _propTypes["default"].oneOf(Object.keys(
|
|
218
|
-
left: _propTypes["default"].oneOf(Object.keys(
|
|
219
|
-
right: _propTypes["default"].oneOf(Object.keys(
|
|
220
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(
|
|
179
|
+
top: _propTypes["default"].oneOf(Object.keys(spaces)),
|
|
180
|
+
bottom: _propTypes["default"].oneOf(Object.keys(spaces)),
|
|
181
|
+
left: _propTypes["default"].oneOf(Object.keys(spaces)),
|
|
182
|
+
right: _propTypes["default"].oneOf(Object.keys(spaces))
|
|
183
|
+
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(spaces)))])
|
|
221
184
|
};
|
|
222
185
|
var _default = DxcToggle;
|
|
223
186
|
exports["default"] = _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
2
|
+
type Margin = {
|
|
3
|
+
top?: Space;
|
|
4
|
+
bottom?: Space;
|
|
5
|
+
left?: Space;
|
|
6
|
+
right?: Space;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
label?: string;
|
|
11
|
+
helperText?: string;
|
|
12
|
+
value?: any;
|
|
13
|
+
onChange?: void;
|
|
14
|
+
disabled?: boolean,
|
|
15
|
+
options?: any;
|
|
16
|
+
multiple?: boolean;
|
|
17
|
+
margin?: Space | Margin;
|
|
18
|
+
tabIndex?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default function DxcToggle(props: Props): JSX.Element;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
+
|
|
16
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
+
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
|
|
22
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
|
+
|
|
24
|
+
var _uuid = require("uuid");
|
|
25
|
+
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
28
|
+
var _variables = require("../common/variables.js");
|
|
29
|
+
|
|
30
|
+
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
31
|
+
|
|
32
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
+
|
|
38
|
+
var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
39
|
+
var label = _ref.label,
|
|
40
|
+
helperText = _ref.helperText,
|
|
41
|
+
value = _ref.value,
|
|
42
|
+
onChange = _ref.onChange,
|
|
43
|
+
_ref$disabled = _ref.disabled,
|
|
44
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
45
|
+
_ref$options = _ref.options,
|
|
46
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
47
|
+
margin = _ref.margin,
|
|
48
|
+
_ref$multiple = _ref.multiple,
|
|
49
|
+
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
50
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
51
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
52
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
53
|
+
|
|
54
|
+
var _useState = (0, _react.useState)(multiple ? [] : null),
|
|
55
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
56
|
+
selectedValue = _useState2[0],
|
|
57
|
+
setSelectedValue = _useState2[1];
|
|
58
|
+
|
|
59
|
+
var _useState3 = (0, _react.useState)("toggle-group-".concat((0, _uuid.v4)())),
|
|
60
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
61
|
+
toggleGroupId = _useState4[0];
|
|
62
|
+
|
|
63
|
+
var handleToggleChange = function handleToggleChange(selectedOption) {
|
|
64
|
+
var newSelectedOptions;
|
|
65
|
+
|
|
66
|
+
if (value == null) {
|
|
67
|
+
if (multiple) {
|
|
68
|
+
newSelectedOptions = selectedValue.map(function (value) {
|
|
69
|
+
return value;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (newSelectedOptions.includes(selectedOption)) {
|
|
73
|
+
var index = newSelectedOptions.indexOf(selectedOption);
|
|
74
|
+
newSelectedOptions.splice(index, 1);
|
|
75
|
+
} else {
|
|
76
|
+
newSelectedOptions.push(selectedOption);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setSelectedValue(newSelectedOptions);
|
|
80
|
+
} else setSelectedValue(selectedOption === selectedValue ? null : selectedOption);
|
|
81
|
+
} else if (multiple) {
|
|
82
|
+
newSelectedOptions = value.map(function (v) {
|
|
83
|
+
return v;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (newSelectedOptions.includes(selectedOption)) {
|
|
87
|
+
var _index = newSelectedOptions.indexOf(selectedOption);
|
|
88
|
+
|
|
89
|
+
newSelectedOptions.splice(_index, 1);
|
|
90
|
+
} else newSelectedOptions.push(selectedOption);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
typeof onChange === "function" && onChange(multiple ? newSelectedOptions : selectedOption);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var handleKeyPress = function handleKeyPress(event, optionValue) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
if (!disabled && (event.nativeEvent.code === "Enter" || event.nativeEvent.code === "Space")) handleToggleChange(optionValue);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
102
|
+
theme: colorsTheme.toggleGroup
|
|
103
|
+
}, /*#__PURE__*/_react["default"].createElement(ToggleGroup, {
|
|
104
|
+
margin: margin,
|
|
105
|
+
disabled: disabled
|
|
106
|
+
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
107
|
+
htmlFor: toggleGroupId,
|
|
108
|
+
disabled: disabled
|
|
109
|
+
}, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
110
|
+
disabled: disabled
|
|
111
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(OptionsContainer, {
|
|
112
|
+
id: toggleGroupId,
|
|
113
|
+
role: multiple ? "group" : "radiogroup"
|
|
114
|
+
}, options.map(function (option, i) {
|
|
115
|
+
return /*#__PURE__*/_react["default"].createElement(ToggleContainer, {
|
|
116
|
+
selected: multiple ? value ? value.includes(option.value) : selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
|
|
117
|
+
role: multiple ? "switch" : "radio",
|
|
118
|
+
"aria-checked": multiple ? value ? value.includes(option.value) : selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
|
|
119
|
+
tabIndex: !disabled ? tabIndex : -1,
|
|
120
|
+
onClick: function onClick() {
|
|
121
|
+
return !disabled && handleToggleChange(option.value);
|
|
122
|
+
},
|
|
123
|
+
isFirst: i === 0,
|
|
124
|
+
isLast: i === options.length - 1,
|
|
125
|
+
isIcon: option.iconSrc || option.icon,
|
|
126
|
+
optionLabel: option.label,
|
|
127
|
+
disabled: disabled,
|
|
128
|
+
onKeyPress: function onKeyPress(event) {
|
|
129
|
+
handleKeyPress(event, option.value);
|
|
130
|
+
},
|
|
131
|
+
key: "toggle-".concat(i, "-").concat(option.label)
|
|
132
|
+
}, /*#__PURE__*/_react["default"].createElement(OptionContent, null, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
133
|
+
optionLabel: option.label
|
|
134
|
+
}, (0, _typeof2["default"])(option.icon) === "object" ? option.icon : /*#__PURE__*/_react["default"].createElement(option.icon)), option.iconSrc && /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
135
|
+
src: option.iconSrc,
|
|
136
|
+
optionLabel: option.label
|
|
137
|
+
}), option.label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, option.label)));
|
|
138
|
+
}))));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var Label = _styledComponents["default"].label(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
142
|
+
return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
|
|
143
|
+
}, function (props) {
|
|
144
|
+
return props.theme.labelFontFamily;
|
|
145
|
+
}, function (props) {
|
|
146
|
+
return props.theme.labelFontSize;
|
|
147
|
+
}, function (props) {
|
|
148
|
+
return props.theme.labelFontStyle;
|
|
149
|
+
}, function (props) {
|
|
150
|
+
return props.theme.labelFontWeight;
|
|
151
|
+
}, function (props) {
|
|
152
|
+
return props.theme.labelLineHeight;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
var HelperText = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
156
|
+
return props.disabled ? props.theme.disabledHelperTextFontcolor : props.theme.helperTextFontColor;
|
|
157
|
+
}, function (props) {
|
|
158
|
+
return props.theme.helperTextFontFamily;
|
|
159
|
+
}, function (props) {
|
|
160
|
+
return props.theme.helperTextFontSize;
|
|
161
|
+
}, function (props) {
|
|
162
|
+
return props.theme.helperTextFontStyle;
|
|
163
|
+
}, function (props) {
|
|
164
|
+
return props.theme.helperTextFontWeight;
|
|
165
|
+
}, function (props) {
|
|
166
|
+
return props.theme.helperTextLineHeight;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
var ToggleGroup = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
170
|
+
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
171
|
+
}, function (props) {
|
|
172
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
173
|
+
}, function (props) {
|
|
174
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
|
|
175
|
+
}, function (props) {
|
|
176
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
177
|
+
}, function (props) {
|
|
178
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n opacity: 1;\n height: calc(48px - 4px - 4px);\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n border-color: ", ";\n background-color: ", ";\n padding: 4px;\n margin-top: ", ";\n"])), function (props) {
|
|
182
|
+
return props.theme.containerBorderThickness;
|
|
183
|
+
}, function (props) {
|
|
184
|
+
return props.theme.containerBorderStyle;
|
|
185
|
+
}, function (props) {
|
|
186
|
+
return props.theme.containerBorderRadius;
|
|
187
|
+
}, function (props) {
|
|
188
|
+
return props.theme.containerBorderColor;
|
|
189
|
+
}, function (props) {
|
|
190
|
+
return props.theme.containerBackgroundColor;
|
|
191
|
+
}, function (props) {
|
|
192
|
+
return props.theme.containerMarginTop;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
var ToggleContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-right: ", ";\n\n ", "\n"])), function (props) {
|
|
196
|
+
return !props.isLast && "4px";
|
|
197
|
+
}, function (props) {
|
|
198
|
+
return "\n background-color: ".concat(props.selected ? props.disabled ? props.theme.selectedDisabledBackgroundColor : props.theme.selectedBackgroundColor : props.disabled ? props.theme.unselectedDisabledBackgroundColor : props.theme.unselectedBackgroundColor, ";\n border-width: ").concat(props.theme.optionBorderThickness, ";\n border-style: ").concat(props.theme.optionBorderStyle, ";\n border-radius: ").concat(props.theme.optionBorderRadius, ";\n padding-left: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingLeft : props.theme.iconPaddingLeft, ";\n padding-right: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingRight : props.theme.iconPaddingRight, ";\n ").concat(!props.disabled ? ":hover {\n background-color: ".concat(props.selected ? props.theme.selectedHoverBackgroundColor : props.theme.unselectedHoverBackgroundColor, ";\n }\n :active {\n background-color: ").concat(props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor, ";\n color: #ffffff;\n } \n :focus {\n border-color: transparent;\n box-shadow: 0 0 0 ").concat(props.theme.optionFocusBorderThickness, " ").concat(props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor, ";\n }\n &:focus-visible {\n outline: none;\n }\n cursor: pointer;\n color: ").concat(props.selected ? props.theme.selectedFontColor : props.theme.unselectedFontColor, ";\n") : "color: ".concat(props.selected ? props.theme.selectedDisabledFontColor : props.theme.unselectedDisabledFontColor, ";\n cursor: not-allowed;"), "\n ");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
202
|
+
return props.theme.optionLabelFontFamily;
|
|
203
|
+
}, function (props) {
|
|
204
|
+
return props.theme.optionLabelFontSize;
|
|
205
|
+
}, function (props) {
|
|
206
|
+
return props.theme.optionLabelFontStyle;
|
|
207
|
+
}, function (props) {
|
|
208
|
+
return props.theme.optionLabelFontWeight;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
var OptionContent = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n"])));
|
|
212
|
+
|
|
213
|
+
var Icon = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 24px;\n width: 24px;\n margin-right: ", ";\n"])), function (props) {
|
|
214
|
+
return props.optionLabel && props.theme.iconMarginRight;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
var IconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: ", ";\n height: 24px;\n width: 24px;\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
218
|
+
return props.optionLabel && props.theme.iconMarginRight;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
DxcToggleGroup.propTypes = {
|
|
222
|
+
label: _propTypes["default"].string,
|
|
223
|
+
helperText: _propTypes["default"].string,
|
|
224
|
+
value: _propTypes["default"].any,
|
|
225
|
+
onChange: _propTypes["default"].func,
|
|
226
|
+
disabled: _propTypes["default"].bool,
|
|
227
|
+
multiple: _propTypes["default"].bool,
|
|
228
|
+
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
229
|
+
value: _propTypes["default"].any.isRequired,
|
|
230
|
+
label: _propTypes["default"].string,
|
|
231
|
+
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
232
|
+
iconSrc: _propTypes["default"].string
|
|
233
|
+
})),
|
|
234
|
+
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
235
|
+
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
236
|
+
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
237
|
+
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
238
|
+
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
239
|
+
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
240
|
+
tabIndex: _propTypes["default"].number
|
|
241
|
+
};
|
|
242
|
+
var _default = DxcToggleGroup;
|
|
243
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
2
|
+
type Margin = {
|
|
3
|
+
top?: Space;
|
|
4
|
+
bottom?: Space;
|
|
5
|
+
left?: Space;
|
|
6
|
+
right?: Space;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
label?: string;
|
|
11
|
+
helperText?: string;
|
|
12
|
+
value?: any;
|
|
13
|
+
onChange?: void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
options?: any;
|
|
16
|
+
multiple?: boolean;
|
|
17
|
+
margin?: Space | Margin;
|
|
18
|
+
tabIndex?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default function DxcToggleGroup(props: Props): JSX.Element;
|