@via-profit/ui-kit 0.3.0 → 0.4.0
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/Accordion/AccordionContainer.js +11 -11
- package/Accordion/AccordionContent.js +16 -7
- package/Accordion/AccordionHeader.d.ts +22 -0
- package/Accordion/AccordionHeader.js +35 -18
- package/Accordion/Chevron.js +3 -3
- package/Accordion/index.d.ts +12 -8
- package/Accordion/index.js +21 -6
- package/Autocomplete/AutocompleteContainer.d.ts +5 -9
- package/Autocomplete/AutocompleteContainer.js +91 -35
- package/Autocomplete/AutocompleteTagsInput.d.ts +15 -0
- package/Autocomplete/AutocompleteTagsInput.js +65 -0
- package/Autocomplete/context.d.ts +1 -0
- package/Autocomplete/context.js +5 -5
- package/Autocomplete/index.js +1 -0
- package/Avatar/AvatarBase.js +1 -1
- package/Avatar/AvatarContainer.js +6 -11
- package/Avatar/AvatarPicture.d.ts +9 -1
- package/Avatar/AvatarPicture.js +4 -3
- package/Avatar/index.js +10 -10
- package/Badge/BadgeBase.d.ts +9 -0
- package/Badge/BadgeBase.js +21 -3
- package/Badge/BadgeContainer.js +2 -1
- package/Badge/BadgeDeleteButton.d.ts +1 -1
- package/Badge/BadgeOutlined.d.ts +1 -1
- package/Badge/BadgeOutlined.js +5 -80
- package/Badge/BadgeStandard.d.ts +1 -1
- package/Badge/BadgeStandard.js +5 -91
- package/Badge/BadgeStyled.d.ts +5 -0
- package/Badge/BadgeStyled.js +125 -0
- package/Badge/index.d.ts +2 -2
- package/Badge/index.js +3 -20
- package/Button/ButtonBase.js +8 -4
- package/Button/ButtonContainer.js +2 -0
- package/Button/ButtonIconWrapper.d.ts +1 -1
- package/Button/ButtonOutlined.d.ts +1 -1
- package/Button/ButtonOutlined.js +5 -80
- package/Button/ButtonPlain.d.ts +1 -1
- package/Button/ButtonPlain.js +5 -85
- package/Button/ButtonStandard.d.ts +1 -1
- package/Button/ButtonStandard.js +5 -97
- package/Button/ButtonStyled.d.ts +10 -0
- package/Button/ButtonStyled.js +205 -0
- package/Button/index.d.ts +5 -5
- package/Button/index.js +3 -24
- package/ButtonGroup/ButtonGroupContext.d.ts +21 -0
- package/ButtonGroup/ButtonGroupContext.js +11 -0
- package/ButtonGroup/index.d.ts +76 -0
- package/ButtonGroup/index.js +132 -0
- package/CHANGELOG.md +122 -0
- package/Calendar/CalendarCell.js +11 -4
- package/Calendar/CalendarComponent.d.ts +15 -4
- package/Calendar/CalendarComponent.js +150 -55
- package/Calendar/CalendarDayBadge.d.ts +1 -1
- package/Calendar/CalendarMonthCell.js +1 -11
- package/Calendar/CalendarWeekDayLabel.js +3 -1
- package/Calendar/CalendarWeekDaysBar.js +6 -1
- package/Calendar/CalendarYearCell.js +1 -16
- package/Calendar/CalendarYearsSelector.d.ts +0 -1
- package/Calendar/CalendarYearsSelector.js +33 -35
- package/Calendar/use-calendar.d.ts +1 -1
- package/Checkbox/CheckboxAsterisk.d.ts +13 -0
- package/{Autocomplete2/Autocomplete2TextField.js → Checkbox/CheckboxAsterisk.js} +24 -10
- package/Checkbox/CheckboxBox.d.ts +22 -0
- package/Checkbox/CheckboxBox.js +88 -0
- package/Checkbox/CheckboxContainer.d.ts +27 -0
- package/Checkbox/CheckboxContainer.js +38 -0
- package/Checkbox/CheckboxErrorText.d.ts +6 -0
- package/Checkbox/CheckboxErrorText.js +76 -0
- package/Checkbox/CheckboxIcon.d.ts +10 -0
- package/Checkbox/CheckboxIcon.js +57 -0
- package/Checkbox/CheckboxTextWrapper.d.ts +4 -0
- package/Checkbox/CheckboxTextWrapper.js +29 -0
- package/Checkbox/CheckboxWrapper.d.ts +4 -0
- package/Checkbox/CheckboxWrapper.js +29 -0
- package/Checkbox/index.d.ts +144 -0
- package/Checkbox/index.js +71 -0
- package/Checkbox/useCheckboxColor.d.ts +6 -0
- package/Checkbox/useCheckboxColor.js +33 -0
- package/ClickOutside/index.d.ts +6 -0
- package/ClickOutside/index.js +7 -2
- package/Color/Color.d.ts +4 -4
- package/Color/Color.js +9 -5
- package/Color/ColorGenerator.d.ts +5 -1
- package/CountryFlags/AC.js +5 -1
- package/CountryFlags/AD.js +5 -1
- package/CountryFlags/AE.js +5 -1
- package/CountryFlags/AF.js +5 -1
- package/CountryFlags/AG.js +5 -1
- package/CountryFlags/AI.js +5 -1
- package/CountryFlags/AL.js +5 -1
- package/CountryFlags/AM.js +5 -1
- package/CountryFlags/AO.js +5 -1
- package/CountryFlags/AQ.js +5 -1
- package/CountryFlags/AR.js +5 -1
- package/CountryFlags/AS.js +5 -1
- package/CountryFlags/AT.js +5 -1
- package/CountryFlags/AU.js +5 -1
- package/CountryFlags/AW.js +5 -1
- package/CountryFlags/AX.js +5 -1
- package/CountryFlags/AZ.js +5 -1
- package/CountryFlags/BA.js +5 -1
- package/CountryFlags/BB.js +5 -1
- package/CountryFlags/BD.js +5 -1
- package/CountryFlags/BE.js +5 -1
- package/CountryFlags/BF.js +5 -1
- package/CountryFlags/BG.js +5 -1
- package/CountryFlags/BH.js +5 -1
- package/CountryFlags/BI.js +5 -1
- package/CountryFlags/BJ.js +5 -1
- package/CountryFlags/BL.js +5 -1
- package/CountryFlags/BM.js +5 -1
- package/CountryFlags/BN.js +5 -1
- package/CountryFlags/BO.js +5 -1
- package/CountryFlags/BQ.js +5 -1
- package/CountryFlags/BR.js +5 -1
- package/CountryFlags/BS.js +5 -1
- package/CountryFlags/BT.js +5 -1
- package/CountryFlags/BV.js +5 -1
- package/CountryFlags/BW.js +5 -1
- package/CountryFlags/BY.js +5 -1
- package/CountryFlags/BZ.js +5 -1
- package/CountryFlags/CA.js +5 -1
- package/CountryFlags/CC.js +5 -1
- package/CountryFlags/CD.js +5 -1
- package/CountryFlags/CF.js +5 -1
- package/CountryFlags/CG.js +5 -1
- package/CountryFlags/CH.js +5 -1
- package/CountryFlags/CI.js +5 -1
- package/CountryFlags/CK.js +5 -1
- package/CountryFlags/CL.js +5 -1
- package/CountryFlags/CM.js +5 -1
- package/CountryFlags/CN.js +5 -1
- package/CountryFlags/CO.js +5 -1
- package/CountryFlags/CR.js +5 -1
- package/CountryFlags/CU.js +5 -1
- package/CountryFlags/CV.js +5 -1
- package/CountryFlags/CW.js +5 -1
- package/CountryFlags/CX.js +5 -1
- package/CountryFlags/CY.js +5 -1
- package/CountryFlags/CZ.js +5 -1
- package/CountryFlags/DE.js +5 -1
- package/CountryFlags/DJ.js +5 -1
- package/CountryFlags/DK.js +5 -1
- package/CountryFlags/DM.js +5 -1
- package/CountryFlags/DO.js +5 -1
- package/CountryFlags/DZ.js +5 -1
- package/CountryFlags/EC.js +5 -1
- package/CountryFlags/EE.js +5 -1
- package/CountryFlags/EG.js +5 -1
- package/CountryFlags/EH.js +5 -1
- package/CountryFlags/ER.js +5 -1
- package/CountryFlags/ES.js +5 -1
- package/CountryFlags/ET.js +5 -1
- package/CountryFlags/EU.js +5 -1
- package/CountryFlags/FI.js +5 -1
- package/CountryFlags/FJ.js +5 -1
- package/CountryFlags/FK.js +5 -1
- package/CountryFlags/FM.js +5 -1
- package/CountryFlags/FO.js +5 -1
- package/CountryFlags/FR.js +5 -1
- package/CountryFlags/GA.js +5 -1
- package/CountryFlags/GB.js +5 -1
- package/CountryFlags/GD.js +5 -1
- package/CountryFlags/GE.js +5 -1
- package/CountryFlags/GEAB.js +5 -1
- package/CountryFlags/GEOS.js +5 -1
- package/CountryFlags/GF.js +5 -1
- package/CountryFlags/GG.js +5 -1
- package/CountryFlags/GH.js +5 -1
- package/CountryFlags/GI.js +5 -1
- package/CountryFlags/GL.js +5 -1
- package/CountryFlags/GM.js +5 -1
- package/CountryFlags/GN.js +5 -1
- package/CountryFlags/GP.js +5 -1
- package/CountryFlags/GQ.js +5 -1
- package/CountryFlags/GR.js +5 -1
- package/CountryFlags/GS.js +5 -1
- package/CountryFlags/GT.js +5 -1
- package/CountryFlags/GU.js +5 -1
- package/CountryFlags/GW.js +5 -1
- package/CountryFlags/GY.js +5 -1
- package/CountryFlags/HK.js +5 -1
- package/CountryFlags/HM.js +5 -1
- package/CountryFlags/HN.js +5 -1
- package/CountryFlags/HR.js +5 -1
- package/CountryFlags/HT.js +5 -1
- package/CountryFlags/HU.js +5 -1
- package/CountryFlags/IC.js +5 -1
- package/CountryFlags/ID.js +5 -1
- package/CountryFlags/IE.js +5 -1
- package/CountryFlags/IL.js +5 -1
- package/CountryFlags/IM.js +5 -1
- package/CountryFlags/IN.js +5 -1
- package/CountryFlags/IO.js +5 -1
- package/CountryFlags/IQ.js +5 -1
- package/CountryFlags/IR.js +5 -1
- package/CountryFlags/IS.js +5 -1
- package/CountryFlags/IT.js +5 -1
- package/CountryFlags/JE.js +5 -1
- package/CountryFlags/JM.js +5 -1
- package/CountryFlags/JO.js +5 -1
- package/CountryFlags/JP.js +5 -1
- package/CountryFlags/KE.js +5 -1
- package/CountryFlags/KG.js +5 -1
- package/CountryFlags/KH.js +5 -1
- package/CountryFlags/KI.js +5 -1
- package/CountryFlags/KM.js +5 -1
- package/CountryFlags/KN.js +5 -1
- package/CountryFlags/KP.js +5 -1
- package/CountryFlags/KR.js +5 -1
- package/CountryFlags/KW.js +5 -1
- package/CountryFlags/KY.js +5 -1
- package/CountryFlags/KZ.js +5 -1
- package/CountryFlags/LA.js +5 -1
- package/CountryFlags/LB.js +5 -1
- package/CountryFlags/LC.js +5 -1
- package/CountryFlags/LI.js +5 -1
- package/CountryFlags/LK.js +5 -1
- package/CountryFlags/LR.js +5 -1
- package/CountryFlags/LS.js +5 -1
- package/CountryFlags/LT.js +5 -1
- package/CountryFlags/LU.js +5 -1
- package/CountryFlags/LV.js +5 -1
- package/CountryFlags/LY.js +5 -1
- package/CountryFlags/MA.js +5 -1
- package/CountryFlags/MC.js +5 -1
- package/CountryFlags/MD.js +5 -1
- package/CountryFlags/ME.js +5 -1
- package/CountryFlags/MF.js +5 -1
- package/CountryFlags/MG.js +5 -1
- package/CountryFlags/MH.js +5 -1
- package/CountryFlags/MK.js +5 -1
- package/CountryFlags/ML.js +5 -1
- package/CountryFlags/MM.js +5 -1
- package/CountryFlags/MN.js +5 -1
- package/CountryFlags/MO.js +5 -1
- package/CountryFlags/MP.js +5 -1
- package/CountryFlags/MQ.js +5 -1
- package/CountryFlags/MR.js +5 -1
- package/CountryFlags/MS.js +5 -1
- package/CountryFlags/MT.js +5 -1
- package/CountryFlags/MU.js +5 -1
- package/CountryFlags/MV.js +5 -1
- package/CountryFlags/MW.js +5 -1
- package/CountryFlags/MX.js +5 -1
- package/CountryFlags/MY.js +5 -1
- package/CountryFlags/MZ.js +5 -1
- package/CountryFlags/NA.js +5 -1
- package/CountryFlags/NC.js +5 -1
- package/CountryFlags/NE.js +5 -1
- package/CountryFlags/NF.js +5 -1
- package/CountryFlags/NG.js +5 -1
- package/CountryFlags/NI.js +5 -1
- package/CountryFlags/NL.js +5 -1
- package/CountryFlags/NO.js +5 -1
- package/CountryFlags/NP.js +5 -1
- package/CountryFlags/NR.js +5 -1
- package/CountryFlags/NU.js +5 -1
- package/CountryFlags/NZ.js +5 -1
- package/CountryFlags/OM.js +5 -1
- package/CountryFlags/PA.js +5 -1
- package/CountryFlags/PE.js +5 -1
- package/CountryFlags/PF.js +5 -1
- package/CountryFlags/PG.js +5 -1
- package/CountryFlags/PH.js +5 -1
- package/CountryFlags/PK.js +5 -1
- package/CountryFlags/PL.js +5 -1
- package/CountryFlags/PM.js +5 -1
- package/CountryFlags/PN.js +5 -1
- package/CountryFlags/PR.js +5 -1
- package/CountryFlags/PS.js +5 -1
- package/CountryFlags/PT.js +5 -1
- package/CountryFlags/PW.js +5 -1
- package/CountryFlags/PY.js +5 -1
- package/CountryFlags/QA.js +5 -1
- package/CountryFlags/RE.js +5 -1
- package/CountryFlags/RO.js +5 -1
- package/CountryFlags/RS.js +5 -1
- package/CountryFlags/RU.js +5 -1
- package/CountryFlags/RW.js +5 -1
- package/CountryFlags/SA.js +5 -1
- package/CountryFlags/SB.js +5 -1
- package/CountryFlags/SC.js +5 -1
- package/CountryFlags/SD.js +5 -1
- package/CountryFlags/SE.js +5 -1
- package/CountryFlags/SG.js +5 -1
- package/CountryFlags/SH.js +5 -1
- package/CountryFlags/SI.js +5 -1
- package/CountryFlags/SJ.js +5 -1
- package/CountryFlags/SK.js +5 -1
- package/CountryFlags/SL.js +5 -1
- package/CountryFlags/SM.js +5 -1
- package/CountryFlags/SN.js +5 -1
- package/CountryFlags/SO.js +5 -1
- package/CountryFlags/SR.js +5 -1
- package/CountryFlags/SS.js +5 -1
- package/CountryFlags/ST.js +5 -1
- package/CountryFlags/SV.js +5 -1
- package/CountryFlags/SX.js +5 -1
- package/CountryFlags/SY.js +5 -1
- package/CountryFlags/SZ.js +5 -1
- package/CountryFlags/TA.js +5 -1
- package/CountryFlags/TC.js +5 -1
- package/CountryFlags/TD.js +5 -1
- package/CountryFlags/TF.js +5 -1
- package/CountryFlags/TG.js +5 -1
- package/CountryFlags/TH.js +5 -1
- package/CountryFlags/TJ.js +5 -1
- package/CountryFlags/TK.js +5 -1
- package/CountryFlags/TL.js +5 -1
- package/CountryFlags/TM.js +5 -1
- package/CountryFlags/TN.js +5 -1
- package/CountryFlags/TO.js +5 -1
- package/CountryFlags/TR.js +5 -1
- package/CountryFlags/TT.js +5 -1
- package/CountryFlags/TV.js +5 -1
- package/CountryFlags/TW.js +5 -1
- package/CountryFlags/TZ.js +5 -1
- package/CountryFlags/UA.js +5 -1
- package/CountryFlags/UG.js +5 -1
- package/CountryFlags/UM.js +5 -1
- package/CountryFlags/US.js +5 -1
- package/CountryFlags/UY.js +5 -1
- package/CountryFlags/UZ.js +5 -1
- package/CountryFlags/Uknown.d.ts +7 -3
- package/CountryFlags/Uknown.js +9 -31
- package/CountryFlags/Unknown.d.ts +3 -0
- package/CountryFlags/Unknown.js +42 -0
- package/CountryFlags/VA.js +5 -1
- package/CountryFlags/VC.js +5 -1
- package/CountryFlags/VE.js +5 -1
- package/CountryFlags/VG.js +5 -1
- package/CountryFlags/VI.js +5 -1
- package/CountryFlags/VN.js +5 -1
- package/CountryFlags/VU.js +5 -1
- package/CountryFlags/WF.js +5 -1
- package/CountryFlags/WS.js +5 -1
- package/CountryFlags/XK.js +5 -1
- package/CountryFlags/YE.js +5 -1
- package/CountryFlags/YT.js +5 -1
- package/CountryFlags/ZA.js +5 -1
- package/CountryFlags/ZM.js +5 -1
- package/CountryFlags/ZW.js +5 -1
- package/CountryFlags/index.d.ts +2 -1
- package/CountryFlags/index.js +3 -1
- package/CountryFlags/isLabelled.d.ts +6 -0
- package/CountryFlags/isLabelled.js +7 -0
- package/DatePicker/index.d.ts +19 -6
- package/DatePicker/index.js +59 -12
- package/Grid/index.d.ts +60 -0
- package/Grid/index.js +43 -0
- package/Highlighted/index.d.ts +1 -1
- package/Highlighted/index.js +14 -10
- package/LoadingIndicator/LoadingOverlay.d.ts +11 -0
- package/LoadingIndicator/LoadingOverlay.js +63 -0
- package/LoadingIndicator/Spinner.d.ts +34 -5
- package/LoadingIndicator/Spinner.js +48 -37
- package/LoadingIndicator/SpinnerCircle.d.ts +14 -0
- package/LoadingIndicator/SpinnerCircle.js +34 -0
- package/LoadingIndicator/index.d.ts +8 -3
- package/LoadingIndicator/index.js +9 -15
- package/MaskedField/index.d.ts +3 -2
- package/MaskedField/index.js +7 -2
- package/MaskedField/templates.js +2 -0
- package/MaskedField/useMasked.js +9 -6
- package/Menu/MenuContainer.d.ts +8 -0
- package/Menu/MenuContainer.js +101 -30
- package/Menu/MenuItem.js +1 -1
- package/Menu/context.js +5 -0
- package/Modal/BaseModal/useDialogID.d.ts +6 -0
- package/Modal/BaseModal/useDialogID.js +12 -0
- package/Modal/ConfirmBox/ConfirmBoxContainer.js +5 -1
- package/Modal/ConfirmBox/index.js +2 -1
- package/Modal/Dialog/DialogInner.js +1 -1
- package/Modal/Dialog/index.js +12 -7
- package/Modal/Drawer/DrawerHeader.d.ts +20 -0
- package/Modal/Drawer/DrawerHeader.js +3 -3
- package/Modal/Drawer/DrawerInner.js +9 -1
- package/Modal/Drawer/index.d.ts +7 -0
- package/Modal/Drawer/index.js +12 -10
- package/Modal/MessageBox/MessageBoxContainer.js +1 -1
- package/Modal/MessageBox/index.js +2 -1
- package/PhoneField/CountryFlagComponent.js +2 -2
- package/PhoneField/UnknownFlag.d.ts +6 -3
- package/PhoneField/UnknownFlag.js +8 -31
- package/PhoneField/index.js +45 -55
- package/PhoneField/templates.js +13 -14
- package/PhoneField/usePhoneUtils.d.ts +15 -0
- package/PhoneField/usePhoneUtils.js +30 -37
- package/Popper/Popper.d.ts +28 -8
- package/Popper/usePopper.d.ts +21 -31
- package/README.md +27 -10
- package/Radio/RadioBox.d.ts +14 -0
- package/Radio/RadioBox.js +100 -0
- package/Radio/RadioContainer.d.ts +27 -0
- package/Radio/RadioContainer.js +38 -0
- package/Radio/RadioTextWrapper.d.ts +4 -0
- package/Radio/RadioTextWrapper.js +29 -0
- package/Radio/index.d.ts +64 -0
- package/Radio/index.js +49 -0
- package/Radio/useRadioColor.d.ts +6 -0
- package/Radio/useRadioColor.js +33 -0
- package/RadioGroup/RadioGroupAsterisk.d.ts +13 -0
- package/RadioGroup/RadioGroupAsterisk.js +53 -0
- package/RadioGroup/RadioGroupContainer.d.ts +4 -0
- package/RadioGroup/RadioGroupContainer.js +36 -0
- package/RadioGroup/RadioGroupContext.d.ts +20 -0
- package/RadioGroup/RadioGroupContext.js +11 -0
- package/RadioGroup/RadioGroupErrorText.d.ts +6 -0
- package/RadioGroup/RadioGroupErrorText.js +76 -0
- package/RadioGroup/RadioGroupItems.d.ts +9 -0
- package/RadioGroup/RadioGroupItems.js +30 -0
- package/RadioGroup/RadioGroupLegend.d.ts +4 -0
- package/RadioGroup/RadioGroupLegend.js +37 -0
- package/RadioGroup/index.d.ts +134 -0
- package/RadioGroup/index.js +62 -0
- package/Selectbox/index.d.ts +18 -2
- package/Selectbox/index.js +23 -7
- package/Stack/index.d.ts +62 -0
- package/Stack/index.js +38 -0
- package/Surface/SurfaceContainer.js +6 -0
- package/Surface/index.js +7 -3
- package/Swiper/Swiper.d.ts +28 -2
- package/Swiper/Swiper.js +233 -90
- package/Swiper/SwiperContainer.js +0 -2
- package/Swiper/SwiperSlidesRenderer.d.ts +8 -0
- package/Swiper/SwiperSlidesRenderer.js +17 -14
- package/Swiper/SwiperTrack.d.ts +8 -0
- package/Swiper/SwiperTrack.js +8 -3
- package/Swiper/SwiperWrapper.js +9 -1
- package/Switch/SwitchContainer.d.ts +1 -1
- package/Switch/SwitchContainer.js +5 -5
- package/Switch/SwitchDot.js +13 -53
- package/Switch/SwitchToggleWrapper.d.ts +1 -1
- package/Switch/SwitchToggleWrapper.js +5 -6
- package/Switch/SwitchTrack.js +5 -41
- package/Switch/index.d.ts +4 -4
- package/Switch/index.js +21 -11
- package/Switch/useSwitchColor.d.ts +7 -0
- package/Switch/useSwitchColor.js +33 -0
- package/Table/Table.d.ts +6 -0
- package/Table/Table.js +7 -62
- package/Table/TableBody.d.ts +1 -1
- package/Table/TableBody.js +4 -2
- package/Table/TableCaption.d.ts +2 -2
- package/Table/TableCaption.js +2 -3
- package/Table/TableCell.js +2 -5
- package/Table/TableFooter.js +8 -7
- package/Table/TableHeader.js +6 -2
- package/Table/TableHeaderCell.js +8 -9
- package/Table/TableRow.js +1 -5
- package/TextArea/TextAreaIconWrapper.d.ts +1 -1
- package/TextArea/TextAreaInput.js +2 -0
- package/TextArea/index.js +1 -1
- package/TextField/TextFieldInput.js +2 -0
- package/TextField/TextFieldInputWrapper.d.ts +2 -0
- package/TextField/TextFieldInputWrapper.js +12 -2
- package/TextField/index.js +1 -1
- package/ThemeProvider/createTheme.js +2 -3
- package/ThemeProvider/index.d.ts +19 -2
- package/Typography/Base.d.ts +1 -1
- package/Typography/Base.js +1 -1
- package/Typography/Blockquote.js +1 -1
- package/Typography/Del.js +2 -2
- package/Typography/H4.js +1 -1
- package/Typography/H5.js +2 -2
- package/Typography/H6.d.ts +4 -0
- package/Typography/H6.js +28 -0
- package/Typography/SectionDescription.js +0 -1
- package/Typography/SectionTitle.d.ts +4 -7
- package/Typography/SectionTitle.js +26 -8
- package/Typography/index.d.ts +27 -0
- package/Typography/index.js +35 -0
- package/package.json +2 -4
- package/utils/spacing.d.ts +11 -0
- package/utils/spacing.js +14 -0
- package/Autocomplete/OverrideMenuList.d.ts +0 -4
- package/Autocomplete/OverrideMenuList.js +0 -39
- package/Autocomplete2/Autocomplete2.d.ts +0 -12
- package/Autocomplete2/Autocomplete2.js +0 -83
- package/Autocomplete2/Autocomplete2TextField.d.ts +0 -7
- package/Autocomplete2/index.d.ts +0 -2
- package/Autocomplete2/index.js +0 -7
- package/CountryFlags/SwiperOverview.d.ts +0 -257
- package/CountryFlags/SwiperOverview.js +0 -524
|
@@ -39,23 +39,23 @@ const StyledAccordionContainer = styled_1.default.div `
|
|
|
39
39
|
? theme.color.backgroundSecondary.lighten(80).alpha(0.12).toString()
|
|
40
40
|
: theme.color.backgroundSecondary.lighten(50).alpha(0.12).toString()}
|
|
41
41
|
0px 1px 3px 0px;
|
|
42
|
-
margin-top: 1px;
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
/*
|
|
44
|
+
* Adjacent accordions form a group: the inner corners are square.
|
|
45
|
+
* Data attributes, not class names: emotion labels are absent in the published package
|
|
46
|
+
*/
|
|
47
|
+
&:has(+ [data-accordion]) {
|
|
48
|
+
border-bottom-left-radius: 0;
|
|
49
|
+
border-bottom-right-radius: 0;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
border-radius: 0
|
|
51
|
-
|
|
52
|
-
&:not(:has(+ div[class*='StyledAccordionContainer'])) {
|
|
53
|
-
border-radius: 0 0 ${({ theme }) => theme.shape.radiusFactor}em
|
|
54
|
-
${({ theme }) => theme.shape.radiusFactor}em;
|
|
52
|
+
[data-accordion] + & {
|
|
53
|
+
border-top-left-radius: 0;
|
|
54
|
+
border-top-right-radius: 0;
|
|
55
55
|
}
|
|
56
56
|
`;
|
|
57
57
|
const AccordionContainer = (props, ref) => {
|
|
58
58
|
const { inline, children } = props, nativeProps = __rest(props, ["inline", "children"]);
|
|
59
|
-
return (react_1.default.createElement(StyledAccordionContainer, Object.assign({ "$inline": inline }, nativeProps, { ref: ref }), children));
|
|
59
|
+
return (react_1.default.createElement(StyledAccordionContainer, Object.assign({ "data-accordion": "", "$inline": inline }, nativeProps, { ref: ref }), children));
|
|
60
60
|
};
|
|
61
61
|
exports.default = react_1.default.forwardRef(AccordionContainer);
|
|
@@ -16,12 +16,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
18
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
/**
|
|
20
|
+
* Animates the height with grid rows 0fr -> 1fr: no fixed max-height, so the tall content is not cut.
|
|
21
|
+
* `visibility: hidden` of the collapsed content removes it from the tab order and the accessibility tree
|
|
22
|
+
*/
|
|
19
23
|
const StyledAccordionContent = styled_1.default.div `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
display: grid;
|
|
25
|
+
grid-template-rows: ${({ $isOpen }) => ($isOpen ? '1fr' : '0fr')};
|
|
26
|
+
visibility: ${({ $isOpen }) => ($isOpen ? 'visible' : 'hidden')};
|
|
27
|
+
transition:
|
|
28
|
+
grid-template-rows 0.3s ease-out,
|
|
29
|
+
visibility 0s linear ${({ $isOpen }) => ($isOpen ? '0s' : '0.3s')};
|
|
30
|
+
`;
|
|
31
|
+
const Clip = styled_1.default.div `
|
|
32
|
+
min-height: 0;
|
|
25
33
|
overflow: hidden;
|
|
26
34
|
`;
|
|
27
35
|
const Wrapper = styled_1.default.div `
|
|
@@ -29,7 +37,8 @@ const Wrapper = styled_1.default.div `
|
|
|
29
37
|
`;
|
|
30
38
|
const AccordionContent = (props, ref) => {
|
|
31
39
|
const { children, noPadding, isOpen } = props, nativeProps = __rest(props, ["children", "noPadding", "isOpen"]);
|
|
32
|
-
return (react_1.default.createElement(StyledAccordionContent, Object.assign({ "
|
|
33
|
-
react_1.default.createElement(
|
|
40
|
+
return (react_1.default.createElement(StyledAccordionContent, Object.assign({ role: "region" }, nativeProps, { "$isOpen": isOpen, ref: ref }),
|
|
41
|
+
react_1.default.createElement(Clip, null,
|
|
42
|
+
react_1.default.createElement(Wrapper, { "$noPadding": Boolean(noPadding) }, children))));
|
|
34
43
|
};
|
|
35
44
|
exports.default = react_1.default.forwardRef(AccordionContent);
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type AccordionHeaderProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
readonly isOpen: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Toggles the accordion
|
|
6
|
+
*/
|
|
4
7
|
readonly onOpen: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* The id of the header button (the content is labelled by it)
|
|
10
|
+
*/
|
|
11
|
+
readonly headerID?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The id of the content (the header button controls it)
|
|
14
|
+
*/
|
|
15
|
+
readonly contentID?: string;
|
|
5
16
|
};
|
|
6
17
|
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
7
18
|
readonly isOpen: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Toggles the accordion
|
|
21
|
+
*/
|
|
8
22
|
readonly onOpen: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* The id of the header button (the content is labelled by it)
|
|
25
|
+
*/
|
|
26
|
+
readonly headerID?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The id of the content (the header button controls it)
|
|
29
|
+
*/
|
|
30
|
+
readonly contentID?: string | undefined;
|
|
9
31
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
10
32
|
export default _default;
|
|
@@ -16,38 +16,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
18
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
-
const Button_1 = __importDefault(require("../Button"));
|
|
20
19
|
const Chevron_1 = __importDefault(require("./Chevron"));
|
|
21
20
|
const StyledHeader = styled_1.default.div `
|
|
22
|
-
padding: 1rem 1rem 1rem 1rem;
|
|
23
21
|
font-size: 1.3rem;
|
|
24
22
|
font-weight: 600;
|
|
25
23
|
border-top-left-radius: inherit;
|
|
26
24
|
border-top-right-radius: inherit;
|
|
25
|
+
`;
|
|
26
|
+
/**
|
|
27
|
+
* The whole header is the button: it is clickable, focusable and announced as expanded/collapsed
|
|
28
|
+
*/
|
|
29
|
+
const HeaderButton = styled_1.default.button `
|
|
27
30
|
display: flex;
|
|
28
|
-
cursor: pointer;
|
|
29
31
|
flex-direction: row;
|
|
30
32
|
flex-wrap: nowrap;
|
|
31
33
|
align-items: center;
|
|
34
|
+
gap: 1rem;
|
|
35
|
+
width: 100%;
|
|
36
|
+
margin: 0;
|
|
37
|
+
padding: 1rem;
|
|
38
|
+
border: 0;
|
|
39
|
+
border-radius: inherit;
|
|
40
|
+
background: none;
|
|
41
|
+
color: inherit;
|
|
42
|
+
font: inherit;
|
|
43
|
+
text-align: start;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
|
|
46
|
+
&:focus-visible {
|
|
47
|
+
outline: 0.1em solid ${({ theme }) => theme.color.accentPrimary.toString()};
|
|
48
|
+
outline-offset: -0.1em;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
const HeaderCell = styled_1.default.span `
|
|
52
|
+
flex: 1;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
gap: 0.5em;
|
|
32
56
|
`;
|
|
33
57
|
const StyledChevron = (0, styled_1.default)(Chevron_1.default, { shouldForwardProp: p => p[0] !== '$' }) `
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
color: ${({ theme }) => theme.color.accentSecondary.toString()};
|
|
34
60
|
transform: ${({ $isOpen }) => (!$isOpen ? 'rotate(180deg)' : 'rotate(0)')};
|
|
35
|
-
transition:
|
|
36
|
-
`;
|
|
37
|
-
const StyledButton = (0, styled_1.default)(Button_1.default) `
|
|
38
|
-
width: 1rem;
|
|
39
|
-
height: 1rem;
|
|
40
|
-
`;
|
|
41
|
-
const HeaderCell = styled_1.default.div `
|
|
42
|
-
flex: 1;
|
|
61
|
+
transition: transform 0.3s ease-out;
|
|
43
62
|
`;
|
|
44
|
-
const Actions = styled_1.default.div ``;
|
|
45
63
|
const AccordionHeader = (props, ref) => {
|
|
46
|
-
const { children, isOpen, onOpen } = props, nativeProps = __rest(props, ["children", "isOpen", "onOpen"]);
|
|
47
|
-
return (react_1.default.createElement(StyledHeader, Object.assign({}, nativeProps, { ref: ref
|
|
48
|
-
react_1.default.createElement(
|
|
49
|
-
|
|
50
|
-
react_1.default.createElement(
|
|
51
|
-
react_1.default.createElement(StyledChevron, { "$isOpen": isOpen })))));
|
|
64
|
+
const { children, isOpen, onOpen, headerID, contentID } = props, nativeProps = __rest(props, ["children", "isOpen", "onOpen", "headerID", "contentID"]);
|
|
65
|
+
return (react_1.default.createElement(StyledHeader, Object.assign({}, nativeProps, { ref: ref }),
|
|
66
|
+
react_1.default.createElement(HeaderButton, { type: "button", id: headerID, "aria-expanded": isOpen, "aria-controls": contentID, onClick: () => onOpen() },
|
|
67
|
+
react_1.default.createElement(HeaderCell, null, children),
|
|
68
|
+
react_1.default.createElement(StyledChevron, { "$isOpen": isOpen }))));
|
|
52
69
|
};
|
|
53
70
|
exports.default = react_1.default.forwardRef(AccordionHeader);
|
package/Accordion/Chevron.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const Path = styled_1.default.path `
|
|
9
|
-
fill:
|
|
9
|
+
fill: currentColor;
|
|
10
10
|
`;
|
|
11
|
-
const
|
|
11
|
+
const Chevron = (props, ref) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", "aria-hidden": true }, props, { ref: ref }),
|
|
12
12
|
react_1.default.createElement(Path, { d: "M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z" })));
|
|
13
|
-
exports.default = react_1.default.forwardRef(
|
|
13
|
+
exports.default = react_1.default.forwardRef(Chevron);
|
package/Accordion/index.d.ts
CHANGED
|
@@ -18,17 +18,19 @@ export type AccordionProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
18
18
|
*/
|
|
19
19
|
readonly overrides?: AccordionOverrides;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* The state of the controlled accordion. Pass it together with `onOpen`
|
|
22
22
|
*/
|
|
23
23
|
readonly isOpen?: boolean;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* The initial state of the uncontrolled accordion
|
|
26
|
+
* Default: false
|
|
26
27
|
*/
|
|
27
28
|
readonly defaultOpened?: boolean;
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
+
* Called when the user clicks the header, both to open and to close the accordion.\
|
|
31
|
+
* Receives the next state: `true` - should be opened, `false` - should be closed
|
|
30
32
|
*/
|
|
31
|
-
readonly onOpen?: () => void;
|
|
33
|
+
readonly onOpen?: (isOpen: boolean) => void;
|
|
32
34
|
/**
|
|
33
35
|
* If `true` initial padding of accorion content would be disabled
|
|
34
36
|
*/
|
|
@@ -67,17 +69,19 @@ declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTM
|
|
|
67
69
|
*/
|
|
68
70
|
readonly overrides?: AccordionOverrides | undefined;
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* The state of the controlled accordion. Pass it together with `onOpen`
|
|
71
73
|
*/
|
|
72
74
|
readonly isOpen?: boolean | undefined;
|
|
73
75
|
/**
|
|
74
|
-
*
|
|
76
|
+
* The initial state of the uncontrolled accordion
|
|
77
|
+
* Default: false
|
|
75
78
|
*/
|
|
76
79
|
readonly defaultOpened?: boolean | undefined;
|
|
77
80
|
/**
|
|
78
|
-
*
|
|
81
|
+
* Called when the user clicks the header, both to open and to close the accordion.\
|
|
82
|
+
* Receives the next state: `true` - should be opened, `false` - should be closed
|
|
79
83
|
*/
|
|
80
|
-
readonly onOpen?: (() => void) | undefined;
|
|
84
|
+
readonly onOpen?: ((isOpen: boolean) => void) | undefined;
|
|
81
85
|
/**
|
|
82
86
|
* If `true` initial padding of accorion content would be disabled
|
|
83
87
|
*/
|
package/Accordion/index.js
CHANGED
|
@@ -46,19 +46,34 @@ const Accordion = (props, ref) => {
|
|
|
46
46
|
const { children, header, actions, isOpen, onOpen, overrides, noPadding, defaultOpened } = props, nativeProps = __rest(props, ["children", "header", "actions", "isOpen", "onOpen", "overrides", "noPadding", "defaultOpened"]);
|
|
47
47
|
const hasActions = typeof actions !== 'undefined' && actions !== null;
|
|
48
48
|
const hasHeader = typeof header !== 'undefined' && header !== null;
|
|
49
|
-
const [
|
|
49
|
+
const [internalOpened, setInternalOpened] = React.useState(Boolean(defaultOpened));
|
|
50
|
+
const isControlled = typeof isOpen !== 'undefined';
|
|
51
|
+
const opened = isControlled ? Boolean(isOpen) : internalOpened;
|
|
52
|
+
const id = React.useId().replace(/:/g, '');
|
|
53
|
+
const headerID = `accordion-${id}-header`;
|
|
54
|
+
const contentID = `accordion-${id}-content`;
|
|
50
55
|
const overridesMap = React.useMemo(() => ({
|
|
51
56
|
Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || AccordionContainer_1.default,
|
|
52
57
|
Header: (overrides === null || overrides === void 0 ? void 0 : overrides.Header) || AccordionHeader_1.default,
|
|
53
58
|
Content: (overrides === null || overrides === void 0 ? void 0 : overrides.Content) || AccordionContent_1.default,
|
|
54
59
|
Actions: (overrides === null || overrides === void 0 ? void 0 : overrides.Actions) || AccordionActions_1.default,
|
|
55
60
|
}), [overrides]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
// Warn once, not on every render
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (!hasHeader) {
|
|
64
|
+
console.warn('[@via-profit/ui-kit] Accordion component. The accordion without the «header» can not be opened by the user');
|
|
65
|
+
}
|
|
66
|
+
}, [hasHeader]);
|
|
67
|
+
// In the uncontrolled mode the own state is updated even when onOpen is passed
|
|
68
|
+
const handleToggle = () => {
|
|
69
|
+
if (!isControlled) {
|
|
70
|
+
setInternalOpened(!opened);
|
|
71
|
+
}
|
|
72
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen(!opened);
|
|
73
|
+
};
|
|
59
74
|
return (React.createElement(overridesMap.Container, Object.assign({}, nativeProps, { ref: ref }),
|
|
60
|
-
hasHeader && (React.createElement(overridesMap.Header, { isOpen:
|
|
61
|
-
React.createElement(overridesMap.Content, {
|
|
75
|
+
hasHeader && (React.createElement(overridesMap.Header, { isOpen: opened, onOpen: handleToggle, headerID: headerID, contentID: contentID }, header)),
|
|
76
|
+
React.createElement(overridesMap.Content, { id: contentID, "aria-labelledby": hasHeader ? headerID : undefined, noPadding: noPadding, isOpen: opened },
|
|
62
77
|
children,
|
|
63
78
|
hasActions && React.createElement(overridesMap.Actions, { noPadding: noPadding }, actions))));
|
|
64
79
|
};
|
|
@@ -15,14 +15,10 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
|
|
|
15
15
|
* If `true` then menu is open, otherwise - closed
|
|
16
16
|
*/
|
|
17
17
|
readonly isOpen?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Loading indicator visibility\
|
|
20
|
-
* If `true` then visible, otherwise - hidden
|
|
21
|
-
*/
|
|
22
18
|
/**
|
|
23
19
|
* Anchor position\
|
|
24
20
|
* \
|
|
25
|
-
* Default: `bottom`
|
|
21
|
+
* Default: `bottom-fill`
|
|
26
22
|
*/
|
|
27
23
|
readonly anchorPos?: AnchorPos;
|
|
28
24
|
/**
|
|
@@ -50,8 +46,7 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
|
|
|
50
46
|
* Used to prevent the popper from being positioned too close to the screen boundaries.
|
|
51
47
|
* The popper will try to flip to another placement if it cannot maintain this margin.
|
|
52
48
|
*
|
|
53
|
-
* **Default**: `
|
|
54
|
-
* ```
|
|
49
|
+
* **Default**: `30`
|
|
55
50
|
*/
|
|
56
51
|
readonly viewportMargin?: number;
|
|
57
52
|
/**
|
|
@@ -97,7 +92,8 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
|
|
|
97
92
|
*/
|
|
98
93
|
readonly onChange?: OnChange<T, Multiple>;
|
|
99
94
|
/**
|
|
100
|
-
* A function that transforms the selected item into a string
|
|
95
|
+
* A function that transforms the selected item into a string.\
|
|
96
|
+
* With `multiple` it is called for every selected item to get the label of its tag
|
|
101
97
|
* Example:
|
|
102
98
|
* ```tsx
|
|
103
99
|
* <Autocomplete
|
|
@@ -146,7 +142,7 @@ export type Children<T> = (data: {
|
|
|
146
142
|
index: number;
|
|
147
143
|
inputValue: string;
|
|
148
144
|
}, itemProps: MenuItemProps) => React.ReactNode;
|
|
149
|
-
export type ItemToString<T, Multiple extends boolean | undefined = undefined> = (item:
|
|
145
|
+
export type ItemToString<T, Multiple extends boolean | undefined = undefined> = (item: T) => string;
|
|
150
146
|
export type OnChange<T, Multiple extends boolean | undefined = undefined> = (item: Value<T, Multiple>) => void;
|
|
151
147
|
export type FilterItems<T> = (items: readonly T[], data: {
|
|
152
148
|
readonly query: string;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
26
|
var t = {};
|
|
4
27
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -17,11 +40,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
40
|
const react_1 = __importDefault(require("react"));
|
|
18
41
|
const TextField_1 = __importDefault(require("../TextField"));
|
|
19
42
|
const Button_1 = __importDefault(require("../Button"));
|
|
20
|
-
const
|
|
43
|
+
const Spinner_1 = __importDefault(require("../LoadingIndicator/Spinner"));
|
|
21
44
|
const context_1 = require("./context");
|
|
22
45
|
const IconClear_1 = __importDefault(require("./IconClear"));
|
|
46
|
+
const AutocompleteTagsInput_1 = __importStar(require("./AutocompleteTagsInput"));
|
|
23
47
|
const ClickOutside_1 = require("../ClickOutside");
|
|
24
|
-
const Menu_1 =
|
|
48
|
+
const Menu_1 = __importStar(require("../Menu"));
|
|
49
|
+
// Module level, so the input keeps its identity between renders and does not lose the focus
|
|
50
|
+
const MULTIPLE_TEXT_FIELD_OVERRIDES = { Input: AutocompleteTagsInput_1.default };
|
|
51
|
+
// The list must not take the focus on a click: the user keeps typing in the field
|
|
52
|
+
const AutocompleteMenuList = react_1.default.forwardRef((props, ref) => (react_1.default.createElement(Menu_1.MenuList, Object.assign({}, props, { onMouseDown: event => {
|
|
53
|
+
var _a;
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
(_a = props.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
56
|
+
}, ref: ref }))));
|
|
57
|
+
AutocompleteMenuList.displayName = 'AutocompleteMenuList';
|
|
58
|
+
const MENU_OVERRIDES = { List: AutocompleteMenuList };
|
|
25
59
|
const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
26
60
|
const { items, value, multiple, isOpen = false, isLoading = false, clearOnBlur = true, anchorPos = 'bottom-fill', alternativePlacements = ['bottom-fill', 'top-fill'], openOnFocus = true, autoFlip = true, viewportMargin, positionStrategy, requiredAsterisk, startIcon, fullWidth, placeholder, label, error, errorText, inputRef, filterItems, children, onChange, selectedItemToString, clearable = true, onInputChange, getOptionSelected, onRequestOpen = () => undefined, onRequestClose = () => undefined, overrides } = props, nativeInputProps = __rest(props, ["items", "value", "multiple", "isOpen", "isLoading", "clearOnBlur", "anchorPos", "alternativePlacements", "openOnFocus", "autoFlip", "viewportMargin", "positionStrategy", "requiredAsterisk", "startIcon", "fullWidth", "placeholder", "label", "error", "errorText", "inputRef", "filterItems", "children", "onChange", "selectedItemToString", "clearable", "onInputChange", "getOptionSelected", "onRequestOpen", "onRequestClose", "overrides"]);
|
|
27
61
|
const menuRef = react_1.default.useRef(null);
|
|
@@ -63,23 +97,14 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
63
97
|
* Restore the input text from the current value (used by clearOnBlur)
|
|
64
98
|
*/
|
|
65
99
|
const restoreInputValue = react_1.default.useCallback(() => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const newFilteredItems = multiple ? filteredItems : applyFilterForItems(newInputValue, items);
|
|
100
|
+
// With multiple the field holds only the search text, the selected items are tags
|
|
101
|
+
const newInputValue = multiple || currentValue === null ? '' : selectedItemToString(currentValue);
|
|
102
|
+
const newFilteredItems = applyFilterForItems(newInputValue, items);
|
|
70
103
|
dispatch((0, context_1.actionSetPartial)({
|
|
71
104
|
filteredItems: newFilteredItems,
|
|
72
105
|
inputValue: newInputValue,
|
|
73
106
|
}));
|
|
74
|
-
}, [
|
|
75
|
-
currentValue,
|
|
76
|
-
selectedItemToString,
|
|
77
|
-
multiple,
|
|
78
|
-
filteredItems,
|
|
79
|
-
applyFilterForItems,
|
|
80
|
-
items,
|
|
81
|
-
dispatch,
|
|
82
|
-
]);
|
|
107
|
+
}, [currentValue, selectedItemToString, multiple, applyFilterForItems, items, dispatch]);
|
|
83
108
|
const inputKeydownEvent = react_1.default.useCallback((event) => {
|
|
84
109
|
var _a, _b, _c, _d, _e;
|
|
85
110
|
if (!isFocusedRef.current) {
|
|
@@ -126,6 +151,15 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
126
151
|
// case 'PageDown':
|
|
127
152
|
// event.preventDefault();
|
|
128
153
|
// break;
|
|
154
|
+
case 'Backspace':
|
|
155
|
+
// An empty field with tags: Backspace removes the last tag
|
|
156
|
+
if (multiple && event.currentTarget.value === '' && Array.isArray(currentValue)) {
|
|
157
|
+
if (currentValue.length > 0 && typeof onChange === 'function') {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
onChange(currentValue.slice(0, -1));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
129
163
|
case 'Tab':
|
|
130
164
|
// Focus leaves the field, so clearOnBlur applies as for the outside click
|
|
131
165
|
if (clearOnBlur) {
|
|
@@ -151,6 +185,9 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
151
185
|
filteredItems.length,
|
|
152
186
|
clearOnBlur,
|
|
153
187
|
restoreInputValue,
|
|
188
|
+
multiple,
|
|
189
|
+
currentValue,
|
|
190
|
+
onChange,
|
|
154
191
|
]);
|
|
155
192
|
const renderChildren = react_1.default.useCallback(({ index, item }, itemProps) => children({ index, item: item, inputValue }, itemProps), [children, inputValue]);
|
|
156
193
|
/**
|
|
@@ -160,12 +197,13 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
160
197
|
if (value === currentValue) {
|
|
161
198
|
return;
|
|
162
199
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
:
|
|
168
|
-
|
|
200
|
+
// With multiple the selected items are shown as tags and the search text is kept
|
|
201
|
+
dispatch((0, context_1.actionSetPartial)(multiple
|
|
202
|
+
? { currentValue: value }
|
|
203
|
+
: {
|
|
204
|
+
currentValue: value,
|
|
205
|
+
inputValue: value === null ? '' : selectedItemToString(value),
|
|
206
|
+
}));
|
|
169
207
|
}, [value, multiple, currentValue, inputValue, dispatch, selectedItemToString]);
|
|
170
208
|
react_1.default.useEffect(() => {
|
|
171
209
|
if (currentOpen && menuRef.current) {
|
|
@@ -211,8 +249,9 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
211
249
|
}
|
|
212
250
|
parentElem = parentElem.parentNode;
|
|
213
251
|
}
|
|
214
|
-
// Click outside
|
|
215
|
-
|
|
252
|
+
// Click outside. The menu can be already closed (no matches, Escape),
|
|
253
|
+
// but the user still leaves the field with an unfinished text
|
|
254
|
+
if (needToClose && (currentOpen || isFocusedRef.current)) {
|
|
216
255
|
if (clearOnBlur) {
|
|
217
256
|
restoreInputValue();
|
|
218
257
|
}
|
|
@@ -227,14 +266,10 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
227
266
|
};
|
|
228
267
|
}, [onRequestClose, anchorElement, isOpen, clearOnBlur, currentOpen, restoreInputValue]);
|
|
229
268
|
const onSelectMenuItem = react_1.default.useCallback(item => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
filteredItems: applyFilterForItems(selectedItemToString(item), items),
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
}
|
|
269
|
+
dispatch((0, context_1.actionSetPartial)(multiple
|
|
270
|
+
? // The search text is done, the whole list is shown again for the next choice
|
|
271
|
+
{ inputValue: '', filteredItems: applyFilterForItems('', items) }
|
|
272
|
+
: { filteredItems: applyFilterForItems(selectedItemToString(item), items) }));
|
|
238
273
|
if (typeof onChange === 'function') {
|
|
239
274
|
onChange(item);
|
|
240
275
|
}
|
|
@@ -242,7 +277,7 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
242
277
|
const endIconMemo = react_1.default.useMemo(() => {
|
|
243
278
|
if (currentLoading) {
|
|
244
279
|
return (react_1.default.createElement(Button_1.default, { iconOnly: true, type: "button", variant: "plain", disabled: true },
|
|
245
|
-
react_1.default.createElement(
|
|
280
|
+
react_1.default.createElement(Spinner_1.default, { size: "1.2em" })));
|
|
246
281
|
}
|
|
247
282
|
if (!clearable) {
|
|
248
283
|
return undefined;
|
|
@@ -319,6 +354,24 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
319
354
|
dispatch((0, context_1.actionSetPartial)({ anchorElement: el }));
|
|
320
355
|
}
|
|
321
356
|
}, [anchorElement, dispatch]);
|
|
357
|
+
const tags = react_1.default.useMemo(() => {
|
|
358
|
+
if (!multiple || !Array.isArray(currentValue)) {
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
361
|
+
const selected = currentValue;
|
|
362
|
+
return selected.map((item, index) => {
|
|
363
|
+
const tagLabel = selectedItemToString(item);
|
|
364
|
+
return {
|
|
365
|
+
key: `${index}:${tagLabel}`,
|
|
366
|
+
label: tagLabel,
|
|
367
|
+
onDelete: () => {
|
|
368
|
+
if (typeof onChange === 'function') {
|
|
369
|
+
onChange(selected.filter((_, i) => i !== index));
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
}, [multiple, currentValue, selectedItemToString, onChange]);
|
|
322
375
|
const inputRefRef = react_1.default.useRef(inputRef);
|
|
323
376
|
react_1.default.useEffect(() => {
|
|
324
377
|
inputRefRef.current = inputRef;
|
|
@@ -333,11 +386,14 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
333
386
|
currentInputRef.current = el;
|
|
334
387
|
}
|
|
335
388
|
}, []);
|
|
336
|
-
return (react_1.default.createElement(
|
|
337
|
-
react_1.default.useMemo(() => (react_1.default.createElement(overridesMap.TextField, Object.assign({ placeholder: placeholder, label: label, error: error, requiredAsterisk: requiredAsterisk, errorText: errorText, fullWidth: fullWidth, startIcon: startIcon, endIcon: endIconMemo
|
|
389
|
+
return (react_1.default.createElement(AutocompleteTagsInput_1.AutocompleteTagsContext.Provider, { value: tags },
|
|
390
|
+
react_1.default.useMemo(() => (react_1.default.createElement(overridesMap.TextField, Object.assign({ overrides: multiple ? MULTIPLE_TEXT_FIELD_OVERRIDES : undefined, placeholder: placeholder, label: label, error: error, requiredAsterisk: requiredAsterisk, errorText: errorText, fullWidth: fullWidth, startIcon: startIcon, endIcon: endIconMemo,
|
|
391
|
+
// The browser suggestions would be shown over the menu; can be overridden by the props
|
|
392
|
+
autoComplete: "off" }, nativeInputProps, { onKeyDown: textFieldOnKeyDown, ref: setAnchorElementRef, inputRef: setInputElementRef, value: inputValue, onBlur: textFieldBlur, onFocus: textFieldFocus, onClick: textFieldClick, onChange: textFieldOnChange }))), [
|
|
338
393
|
setAnchorElementRef,
|
|
339
394
|
setInputElementRef,
|
|
340
395
|
overridesMap,
|
|
396
|
+
multiple,
|
|
341
397
|
placeholder,
|
|
342
398
|
label,
|
|
343
399
|
error,
|
|
@@ -354,7 +410,7 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
|
354
410
|
textFieldClick,
|
|
355
411
|
textFieldOnChange,
|
|
356
412
|
]),
|
|
357
|
-
react_1.default.useMemo(() => (react_1.default.createElement(Menu_1.default, { ref: menuRef, anchorPos: anchorPos, alternativePlacements: alternativePlacements, multiple: multiple, items: filteredItems, value: currentValue, isOpen: currentOpen, autofocus: false, autoFlip: autoFlip, viewportMargin: viewportMargin, offset: 0, positionStrategy: positionStrategy, anchorElement: anchorElement, closeOutsideClick: false, getOptionSelected: getOptionSelected, onRequestClose: onRequestClose, closeOnSelect: !multiple, onSelectItem: onSelectMenuItem }, renderChildren)), [
|
|
413
|
+
react_1.default.useMemo(() => (react_1.default.createElement(Menu_1.default, { ref: menuRef, overrides: MENU_OVERRIDES, anchorPos: anchorPos, alternativePlacements: alternativePlacements, multiple: multiple, items: filteredItems, value: currentValue, isOpen: currentOpen, autofocus: false, autoFlip: autoFlip, viewportMargin: viewportMargin, offset: 0, positionStrategy: positionStrategy, anchorElement: anchorElement, closeOutsideClick: false, getOptionSelected: getOptionSelected, onRequestClose: onRequestClose, closeOnSelect: !multiple, onSelectItem: onSelectMenuItem }, renderChildren)), [
|
|
358
414
|
anchorPos,
|
|
359
415
|
alternativePlacements,
|
|
360
416
|
multiple,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextFieldInputProps } from '../TextField/TextFieldInput';
|
|
3
|
+
export type AutocompleteTag = {
|
|
4
|
+
readonly key: React.Key;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly onDelete: () => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Selected items of the multiple <Autocomplete>.
|
|
10
|
+
* The input override must keep its identity between renders (otherwise the input is remounted
|
|
11
|
+
* and loses the focus), so the tags are passed through the context instead of the props
|
|
12
|
+
*/
|
|
13
|
+
export declare const AutocompleteTagsContext: React.Context<readonly AutocompleteTag[]>;
|
|
14
|
+
declare const AutocompleteTagsInput: React.ForwardRefExoticComponent<TextFieldInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
15
|
+
export default AutocompleteTagsInput;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AutocompleteTagsContext = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
9
|
+
const TextFieldInput_1 = __importDefault(require("../TextField/TextFieldInput"));
|
|
10
|
+
const Badge_1 = __importDefault(require("../Badge"));
|
|
11
|
+
/**
|
|
12
|
+
* Selected items of the multiple <Autocomplete>.
|
|
13
|
+
* The input override must keep its identity between renders (otherwise the input is remounted
|
|
14
|
+
* and loses the focus), so the tags are passed through the context instead of the props
|
|
15
|
+
*/
|
|
16
|
+
exports.AutocompleteTagsContext = react_1.default.createContext([]);
|
|
17
|
+
const Wrapper = styled_1.default.div `
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
align-items: center;
|
|
21
|
+
flex: 1;
|
|
22
|
+
min-width: 0;
|
|
23
|
+
cursor: text;
|
|
24
|
+
`;
|
|
25
|
+
const Tag = (0, styled_1.default)(Badge_1.default) `
|
|
26
|
+
margin: 0.4em 0 0.4em 0.6em;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
`;
|
|
29
|
+
const Input = (0, styled_1.default)(TextFieldInput_1.default) `
|
|
30
|
+
flex: 1 1 6em;
|
|
31
|
+
min-width: 6em;
|
|
32
|
+
width: auto;
|
|
33
|
+
`;
|
|
34
|
+
const AutocompleteTagsInput = react_1.default.forwardRef((props, ref) => {
|
|
35
|
+
const tags = react_1.default.useContext(exports.AutocompleteTagsContext);
|
|
36
|
+
const inputRef = react_1.default.useRef(null);
|
|
37
|
+
const setRefs = react_1.default.useCallback((el) => {
|
|
38
|
+
inputRef.current = el;
|
|
39
|
+
if (typeof ref === 'function') {
|
|
40
|
+
ref(el);
|
|
41
|
+
}
|
|
42
|
+
else if (ref) {
|
|
43
|
+
ref.current = el;
|
|
44
|
+
}
|
|
45
|
+
}, [ref]);
|
|
46
|
+
// A click on the tags area puts the caret into the input, as a click on a plain field does
|
|
47
|
+
const handleMouseDown = react_1.default.useCallback((event) => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (event.target === event.currentTarget) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
return (react_1.default.createElement(Wrapper, { onMouseDown: handleMouseDown },
|
|
55
|
+
tags.map(tag => (react_1.default.createElement(Tag, { key: tag.key, variant: "outlined", color: "primary", onDelete: event => {
|
|
56
|
+
var _a;
|
|
57
|
+
// The input keeps the focus, so the menu is not closed by the blur
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
tag.onDelete();
|
|
60
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
61
|
+
} }, tag.label))),
|
|
62
|
+
react_1.default.createElement(Input, Object.assign({}, props, { ref: setRefs }))));
|
|
63
|
+
});
|
|
64
|
+
AutocompleteTagsInput.displayName = 'AutocompleteTagsInput';
|
|
65
|
+
exports.default = AutocompleteTagsInput;
|
|
@@ -22,6 +22,7 @@ export declare const createInitialState: <T, Multiple extends boolean | undefine
|
|
|
22
22
|
readonly value: Value<T, Multiple> | null;
|
|
23
23
|
readonly selectedItemToString: ItemToString<T, Multiple>;
|
|
24
24
|
readonly isOpen?: boolean | undefined;
|
|
25
|
+
readonly multiple?: Multiple | undefined;
|
|
25
26
|
readonly filterItems: FilterItems<T> | undefined;
|
|
26
27
|
}) => State;
|
|
27
28
|
interface ContextProviderProps {
|