@strapi/design-system 1.6.3 → 1.6.4
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/dist/Accordion/Accordion.cjs +5 -5
- package/dist/Accordion/Accordion.js +45 -44
- package/dist/Accordion/AccordionContent.cjs +1 -1
- package/dist/Accordion/AccordionContent.js +4 -4
- package/dist/Accordion/AccordionGroup.cjs +4 -4
- package/dist/Accordion/AccordionGroup.js +18 -18
- package/dist/Accordion/AccordionToggle.cjs +2 -2
- package/dist/Accordion/AccordionToggle.js +11 -11
- package/dist/Alert/Alert.cjs +1 -1
- package/dist/Alert/Alert.js +8 -8
- package/dist/Avatar/Avatar.cjs +5 -5
- package/dist/Avatar/Avatar.js +11 -11
- package/dist/Avatar/AvatarGroup.cjs +2 -2
- package/dist/Avatar/AvatarGroup.js +4 -4
- package/dist/BaseButton/BaseButton.cjs +5 -11
- package/dist/BaseButton/BaseButton.js +31 -38
- package/dist/BaseCheckbox/BaseCheckbox.cjs +3 -3
- package/dist/BaseCheckbox/BaseCheckbox.js +22 -22
- package/dist/BaseRadio/BaseRadio.cjs +2 -2
- package/dist/BaseRadio/BaseRadio.js +4 -4
- package/dist/BaseRadio/RadioGroup.cjs +1 -1
- package/dist/BaseRadio/RadioGroup.js +28 -26
- package/dist/Box/Box.cjs +1 -1
- package/dist/Box/Box.js +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.cjs +4 -4
- package/dist/Breadcrumbs/Breadcrumbs.js +12 -12
- package/dist/Button/Button.cjs +10 -27
- package/dist/Button/Button.js +65 -85
- package/dist/Button/utils.cjs +22 -22
- package/dist/Button/utils.js +2 -2
- package/dist/Card/Card.cjs +1 -1
- package/dist/Card/Card.js +15 -14
- package/dist/Card/CardAsset.js +4 -4
- package/dist/Card/CardBody.cjs +1 -1
- package/dist/Card/CardBody.js +4 -4
- package/dist/Card/CardCheckbox.cjs +1 -1
- package/dist/Card/CardCheckbox.js +6 -6
- package/dist/Card/CardTitle.cjs +1 -1
- package/dist/Card/CardTitle.js +1 -1
- package/dist/CarouselInput/Carousel.cjs +2 -2
- package/dist/CarouselInput/Carousel.js +19 -64
- package/dist/CarouselInput/CarouselActions.js +1 -9
- package/dist/CarouselInput/CarouselImage.js +1 -10
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +19 -24
- package/dist/CarouselInput/CarouselSlide.js +13 -9
- package/dist/Checkbox/Checkbox.cjs +2 -2
- package/dist/Checkbox/Checkbox.js +7 -26
- package/dist/Combobox/Combobox.cjs +1 -1
- package/dist/Combobox/Combobox.js +106 -120
- package/dist/Combobox/ComboboxOption.cjs +1 -1
- package/dist/Combobox/ComboboxOption.js +18 -17
- package/dist/DatePicker/DatePicker.cjs +1 -1
- package/dist/DatePicker/DatePicker.js +47 -46
- package/dist/DatePicker/DatePickerCalendar.cjs +1 -1
- package/dist/DatePicker/DatePickerCalendar.js +28 -61
- package/dist/DatePicker/DatePickerTd.js +1 -12
- package/dist/DatePicker/DatePickerTh.cjs +3 -3
- package/dist/DatePicker/DatePickerTh.js +7 -16
- package/dist/DatePicker/components.cjs +3 -3
- package/dist/DatePicker/components.js +6 -6
- package/dist/DateTimePicker/DateTimePicker.cjs +1 -1
- package/dist/DateTimePicker/DateTimePicker.js +64 -61
- package/dist/DateTimePicker/DateTimePickerProps.js +1 -3
- package/dist/Dialog/Dialog.cjs +4 -4
- package/dist/Dialog/Dialog.js +26 -37
- package/dist/Dialog/DialogBody.cjs +1 -1
- package/dist/Dialog/DialogBody.js +2 -11
- package/dist/Dialog/DialogFooter.cjs +1 -1
- package/dist/Dialog/DialogFooter.js +2 -7
- package/dist/DismissibleLayer/DismissibleLayer.js +1 -4
- package/dist/Divider/Divider.js +1 -5
- package/dist/EmptyStateLayout/EmptyStateLayout.cjs +1 -1
- package/dist/EmptyStateLayout/EmptyStateLayout.js +2 -16
- package/dist/EmptyStateLayout/story-assets/Illo.js +60 -45
- package/dist/Field/Field.cjs +1 -1
- package/dist/Field/Field.js +12 -13
- package/dist/Field/FieldAction.cjs +1 -1
- package/dist/Field/FieldAction.js +2 -6
- package/dist/Field/FieldError.js +1 -7
- package/dist/Field/FieldHint.js +1 -6
- package/dist/Field/FieldInput.cjs +4 -4
- package/dist/Field/FieldInput.js +26 -34
- package/dist/Field/FieldLabel.cjs +1 -1
- package/dist/Field/FieldLabel.js +3 -16
- package/dist/FocusTrap/FocusTrap.js +1 -5
- package/dist/Grid/Grid.cjs +3 -3
- package/dist/Grid/Grid.js +12 -15
- package/dist/Grid/GridItem.cjs +2 -2
- package/dist/Grid/GridItem.js +5 -13
- package/dist/IconButton/IconButton.cjs +7 -12
- package/dist/IconButton/IconButton.js +88 -84
- package/dist/JSONInput/JSONInput.cjs +1 -1
- package/dist/JSONInput/JSONInput.js +85 -78
- package/dist/JSONInput/JSONInputContainer.cjs +10 -10
- package/dist/JSONInput/JSONInputContainer.js +22 -15
- package/dist/Layout/ActionLayout.js +1 -13
- package/dist/Layout/ContentLayout.js +1 -4
- package/dist/Layout/HeaderLayout.cjs +1 -1
- package/dist/Layout/HeaderLayout.js +35 -64
- package/dist/Layout/Layout.js +1 -5
- package/dist/Layout/TwoColsLayout.js +1 -17
- package/dist/Link/Link.cjs +5 -5
- package/dist/Link/Link.js +55 -57
- package/dist/LinkButton/LinkButton.cjs +7 -24
- package/dist/LinkButton/LinkButton.js +60 -87
- package/dist/LiveRegions/LiveRegions.cjs +1 -1
- package/dist/LiveRegions/LiveRegions.js +1 -1
- package/dist/Loader/Loader.cjs +4 -4
- package/dist/Loader/Loader.js +26 -24
- package/dist/Main/Main.js +1 -6
- package/dist/Main/SkipToContent.cjs +2 -2
- package/dist/Main/SkipToContent.js +17 -13
- package/dist/MainNav/MainNav.cjs +2 -2
- package/dist/MainNav/MainNav.js +21 -20
- package/dist/MainNav/NavBrand.cjs +2 -2
- package/dist/MainNav/NavBrand.js +4 -38
- package/dist/MainNav/NavCondense.cjs +2 -2
- package/dist/MainNav/NavCondense.js +10 -18
- package/dist/MainNav/NavFooter.js +1 -3
- package/dist/MainNav/NavLink.cjs +4 -4
- package/dist/MainNav/NavLink.js +8 -34
- package/dist/MainNav/NavSection.cjs +1 -1
- package/dist/MainNav/NavSection.js +5 -38
- package/dist/MainNav/NavSections.cjs +2 -2
- package/dist/MainNav/NavSections.js +4 -15
- package/dist/MainNav/NavUser.cjs +2 -2
- package/dist/MainNav/NavUser.js +6 -27
- package/dist/ModalLayout/ModalBody.js +1 -4
- package/dist/ModalLayout/ModalFooter.cjs +1 -1
- package/dist/ModalLayout/ModalFooter.js +2 -10
- package/dist/ModalLayout/ModalHeader.cjs +2 -2
- package/dist/ModalLayout/ModalHeader.js +8 -20
- package/dist/ModalLayout/ModalLayout.cjs +3 -3
- package/dist/ModalLayout/ModalLayout.js +23 -31
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +54 -59
- package/dist/Pagination/Pagination.cjs +2 -2
- package/dist/Pagination/Pagination.js +11 -16
- package/dist/Pagination/components.cjs +3 -3
- package/dist/Pagination/components.js +31 -38
- package/dist/Popover/Popover.cjs +3 -3
- package/dist/Popover/Popover.js +5 -5
- package/dist/Portal/Portal.cjs +1 -1
- package/dist/Portal/Portal.js +10 -12
- package/dist/ProgressBar/ProgressBar.js +17 -14
- package/dist/Radio/Radio.cjs +2 -2
- package/dist/Radio/Radio.js +4 -11
- package/dist/RawTable/RawCell.cjs +1 -1
- package/dist/RawTable/RawCell.js +5 -14
- package/dist/RawTable/RawTable.cjs +1 -1
- package/dist/RawTable/RawTable.js +36 -35
- package/dist/RawTable/RawTbody.js +1 -3
- package/dist/RawTable/RawThead.js +1 -3
- package/dist/RawTable/RawTr.js +1 -4
- package/dist/Searchbar/SearchForm.js +1 -4
- package/dist/Searchbar/Searchbar.cjs +3 -3
- package/dist/Searchbar/Searchbar.js +21 -25
- package/dist/Select/MultiSelectNested.js +2 -14
- package/dist/Select/OptGroup.cjs +1 -1
- package/dist/Select/OptGroup.js +14 -10
- package/dist/Select/Option.cjs +3 -3
- package/dist/Select/Option.js +31 -33
- package/dist/Select/Select.cjs +2 -2
- package/dist/Select/Select.js +86 -106
- package/dist/Select/SelectButton.cjs +1 -1
- package/dist/Select/SelectButton.js +14 -11
- package/dist/Select/SelectList.cjs +1 -1
- package/dist/Select/SelectList.js +20 -16
- package/dist/Select/SelectTags.cjs +3 -3
- package/dist/Select/SelectTags.js +17 -15
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +1 -1
- package/dist/SimpleMenu/SimpleMenu.cjs +3 -3
- package/dist/SimpleMenu/SimpleMenu.js +43 -67
- package/dist/Status/Status.js +15 -13
- package/dist/SubNav/SubNav.cjs +2 -2
- package/dist/SubNav/SubNav.js +5 -9
- package/dist/SubNav/SubNavHeader.cjs +2 -2
- package/dist/SubNav/SubNavHeader.js +31 -53
- package/dist/SubNav/SubNavLink.cjs +3 -3
- package/dist/SubNav/SubNavLink.js +18 -22
- package/dist/SubNav/SubNavLinkSection.cjs +2 -2
- package/dist/SubNav/SubNavLinkSection.js +5 -30
- package/dist/SubNav/SubNavSection.cjs +2 -2
- package/dist/SubNav/SubNavSection.js +23 -30
- package/dist/SubNav/SubNavSectionLabel.cjs +2 -2
- package/dist/SubNav/SubNavSectionLabel.js +15 -24
- package/dist/SubNav/SubNavSections.cjs +1 -1
- package/dist/SubNav/SubNavSections.js +3 -12
- package/dist/Switch/Switch.cjs +2 -2
- package/dist/Switch/Switch.js +16 -17
- package/dist/Table/Cell.cjs +1 -1
- package/dist/Table/Cell.js +3 -8
- package/dist/Table/TFooter.cjs +2 -2
- package/dist/Table/TFooter.js +3 -17
- package/dist/Table/Table.cjs +1 -1
- package/dist/Table/Table.js +2 -18
- package/dist/Table/Tbody.js +1 -3
- package/dist/Table/Thead.js +1 -3
- package/dist/Table/Tr.js +1 -3
- package/dist/Tabs/TabGroup.cjs +1 -1
- package/dist/Tabs/TabGroup.js +30 -27
- package/dist/Tabs/TabPanels.js +2 -10
- package/dist/Tabs/Tabs.cjs +1 -1
- package/dist/Tabs/Tabs.js +43 -51
- package/dist/Tag/Tag.cjs +1 -1
- package/dist/Tag/Tag.js +20 -23
- package/dist/TextButton/TextButton.cjs +6 -6
- package/dist/TextButton/TextButton.js +15 -15
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +6 -24
- package/dist/Textarea/Textarea.cjs +2 -2
- package/dist/Textarea/Textarea.js +10 -25
- package/dist/Textarea/TextareaInput.cjs +1 -1
- package/dist/Textarea/TextareaInput.js +15 -15
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +26 -25
- package/dist/ToggleCheckbox/ToggleCheckbox.cjs +5 -5
- package/dist/ToggleCheckbox/ToggleCheckbox.js +85 -60
- package/dist/ToggleInput/ToggleInput.cjs +3 -3
- package/dist/ToggleInput/ToggleInput.js +14 -32
- package/dist/Tooltip/Tooltip.cjs +2 -2
- package/dist/Tooltip/Tooltip.js +62 -53
- package/dist/Tooltip/hooks/useTooltipHandlers.cjs +1 -1
- package/dist/Tooltip/hooks/useTooltipHandlers.js +7 -7
- package/dist/Tooltip/hooks/useTooltipLayout.cjs +1 -1
- package/dist/Tooltip/hooks/useTooltipLayout.js +8 -5
- package/dist/Typography/Typography.cjs +3 -2
- package/dist/Typography/Typography.js +17 -14
- package/dist/helpers/objects.cjs +1 -1
- package/dist/helpers/objects.js +1 -1
- package/dist/hooks/useId.cjs +1 -0
- package/dist/hooks/useId.js +13 -0
- package/dist/themes/extendTheme.cjs +1 -1
- package/dist/themes/extendTheme.js +4 -4
- package/dist/v2/Breadcrumbs/Breadcrumbs.cjs +2 -2
- package/dist/v2/Breadcrumbs/Breadcrumbs.js +4 -13
- package/dist/v2/Breadcrumbs/Crumb.js +11 -12
- package/dist/v2/Breadcrumbs/CrumbLink.js +1 -3
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.cjs +2 -2
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.js +5 -11
- package/dist/v2/Breadcrumbs/Divider.js +1 -8
- package/dist/v2/Link/Link.cjs +2 -2
- package/dist/v2/Link/Link.js +5 -24
- package/dist/v2/LinkButton/LinkButton.cjs +11 -24
- package/dist/v2/LinkButton/LinkButton.js +62 -84
- package/dist/v2/MainNav/MainNav.cjs +2 -2
- package/dist/v2/MainNav/MainNav.js +21 -20
- package/dist/v2/MainNav/NavBrand.cjs +2 -2
- package/dist/v2/MainNav/NavBrand.js +4 -38
- package/dist/v2/MainNav/NavCondense.cjs +2 -2
- package/dist/v2/MainNav/NavCondense.js +10 -18
- package/dist/v2/MainNav/NavFooter.js +1 -3
- package/dist/v2/MainNav/NavLink.cjs +4 -4
- package/dist/v2/MainNav/NavLink.js +10 -39
- package/dist/v2/MainNav/NavSection.cjs +1 -1
- package/dist/v2/MainNav/NavSection.js +5 -38
- package/dist/v2/MainNav/NavSections.cjs +2 -2
- package/dist/v2/MainNav/NavSections.js +4 -15
- package/dist/v2/MainNav/NavUser.cjs +2 -2
- package/dist/v2/MainNav/NavUser.js +6 -27
- package/dist/v2/Pagination/Pagination.cjs +2 -2
- package/dist/v2/Pagination/Pagination.js +11 -16
- package/dist/v2/Pagination/components.cjs +2 -2
- package/dist/v2/Pagination/components.js +11 -39
- package/dist/v2/SimpleMenu/SimpleMenu.cjs +4 -4
- package/dist/v2/SimpleMenu/SimpleMenu.js +42 -65
- package/dist/v2/SubNav/SubNav.cjs +2 -2
- package/dist/v2/SubNav/SubNav.js +5 -9
- package/dist/v2/SubNav/SubNavHeader.cjs +2 -2
- package/dist/v2/SubNav/SubNavHeader.js +31 -53
- package/dist/v2/SubNav/SubNavLink.cjs +2 -2
- package/dist/v2/SubNav/SubNavLink.js +18 -22
- package/dist/v2/SubNav/SubNavLinkSection.cjs +2 -2
- package/dist/v2/SubNav/SubNavLinkSection.js +5 -30
- package/dist/v2/SubNav/SubNavSection.cjs +2 -2
- package/dist/v2/SubNav/SubNavSection.js +26 -33
- package/dist/v2/SubNav/SubNavSectionLabel.cjs +2 -2
- package/dist/v2/SubNav/SubNavSectionLabel.js +15 -24
- package/dist/v2/SubNav/SubNavSections.cjs +1 -1
- package/dist/v2/SubNav/SubNavSections.js +3 -12
- package/package.json +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react"),H=require("@strapi/icons"),he=require("prop-types"),ve=require("./ComboboxOption.cjs"),q=require("./components.cjs"),l=require("./utils.cjs"),Ee=require("../Box/Box.cjs"),Fe=require("../Field/Field.cjs"),Ie=require("../Field/FieldLabel.cjs");require("../Field/FieldInput.cjs");const ke=require("../Field/FieldHint.cjs"),qe=require("../Field/FieldError.cjs");require("../Field/FieldContext.cjs");require("../Field/FieldAction.cjs");const _=require("../Flex/Flex.cjs"),Me=require("../helpers/keyboardKeys.cjs"),Oe=require("../helpers/useId.cjs"),je=require("../Loader/Loader.cjs"),Se=require("../Popover/Popover.cjs"),N=require("../Select/components.cjs"),Le=require("../Stack/Stack.cjs"),U=require("../Typography/Typography.cjs"),Re=require("../VisuallyHidden/VisuallyHidden.cjs"),z=r=>r&&typeof r=="object"&&"default"in r?r:{default:r},o=z(a),e=z(he),C=({children:r,clearLabel:W,creatable:x,createMessage:G,disabled:d,error:F,hasMoreItems:J,hint:M,id:Q,label:h,labelAction:X,loading:O,loadingMessage:Y,noOptionsMessage:Z,onChange:R,onClear:A,onCreateOption:ee,onInputChange:T,onLoadMore:te,placeholder:oe,required:$,value:p,...ne})=>{const ae=()=>r.find(t=>t.props?.value.toLowerCase()===p.toLowerCase()).props?.children,[c,w]=a.useState(0),[re,le]=a.useState(null),[u,B]=a.useState(r),[m,se]=a.useState(!1),[s,I]=a.useState(""),v=a.useRef(),k=a.useRef(!1),E=a.useRef(),D=a.useRef(),ie=a.useRef(),P=a.useRef(!0),i=Oe.useId(Q),ce=`${i}-label`;if(!h&&!ne["aria-label"])throw new Error('The Combobox component needs a "label" or an "aria-label" props');a.useEffect(()=>{B(l.filterOptions(r,s))},[s,r]),a.useEffect(()=>{m&&v.current&&l.maintainScrollVisibility(v.current)},[c,m]),a.useLayoutEffect(()=>{P.current&&(P.current=!1)},[p]);const ue=m?`${i}-${c}`:"",V=()=>{R(null),I("")},de=t=>{T&&T(t);const n=E.current.value;B(l.filterOptions(r,n)),w(0),le(null),s!==n&&I(n),m||b(!0,!1)},fe=t=>{const{key:n}=t,f=x&&s?u.length:u.length-1,y=l.getActionFromKey(n,m);switch(p&&!s&&n===Me.KeyboardKeys.BACKSPACE&&V(),y){case l.MenuActions.Next:{if(c===f){g(0);break}g(l.getUpdatedIndex(c,f,y));break}case l.MenuActions.Previous:{if(c===0){g(f);break}g(l.getUpdatedIndex(c,f,y));break}case l.MenuActions.Last:case l.MenuActions.First:{if(c===f){g(0);break}g(l.getUpdatedIndex(c,f,y));break}case l.MenuActions.CloseSelect:t.preventDefault(),j(c);break;case l.MenuActions.Close:t.preventDefault(),b(!1);break;case l.MenuActions.Open:b(!0);break}},pe=t=>{if(t.preventDefault(),p&&!k.current&&I(""),k.current){k.current=!1;return}b(!1,!1)},g=t=>{w(t)},be=t=>{g(t),j(t)},K=()=>{k.current=!0},j=t=>{const n=u[t];if(I(""),n){R(n.props.value),b(!1);return}x&&(ee(s),b(!1))},b=(t,n=!0)=>{se(t),n&&E.current.focus()},me=a.Children.toArray(u).map((t,n)=>{const f=c===n;return a.cloneElement(t,{id:`${i}-${n}`,"aria-selected":re===n,"aria-posinset":n+1,"aria-setsize":a.Children.toArray(u).length,ref(y){f&&(v.current=y)},onClick:()=>be(n),onMouseDown:K,isSelected:f})}),ge=()=>{E.current.focus(),A&&A(),V()},ye=()=>{E.current.focus(),b(!0)},Ce=()=>{const t=u.findIndex(n=>n.props?.children===s);return s&&t===-1},xe=t=>{t.preventDefault(),b(t,!0)};let S;return F?S=`${i}-error`:M&&(S=`${i}-hint`),o.default.createElement(Fe.Field,{hint:M,error:F,id:i,required:$},o.default.createElement(Re.VisuallyHidden,{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text"},p),o.default.createElement(Le.Stack,{spacing:h||M||F?1:0},h&&o.default.createElement(Ie.FieldLabel,{action:X},h),o.default.createElement(q.MainRow,{ref:D,$disabled:d,hasError:F},o.default.createElement(q.InputContainer,{wrap:"wrap"},!s&&p&&o.default.createElement(q.ValueContainer,{id:`${i}-selected-value`},o.default.createElement(U.Typography,null,ae())),o.default.createElement(q.Input,{"aria-activedescendant":ue,"aria-autocomplete":"list","aria-controls":`${i}-listbox`,"aria-disabled":d,"aria-expanded":m,"aria-haspopup":"listbox","aria-describedby":S,autoComplete:"off",autoCorrect:"off",id:i,onBlur:d?void 0:pe,onClick:d?void 0:xe,onInput:d?void 0:de,onKeyDown:d?void 0:fe,placeholder:p?"":oe,readOnly:d,ref:E,required:$,role:"combobox",spellCheck:"off",type:"text",value:s})),o.default.createElement(_.Flex,null,(p||s)&&o.default.createElement(N.IconBox,{id:`${i}-clear`,"aria-label":W,disabled:d,paddingLeft:3,as:"button",onClick:ge,type:"button"},o.default.createElement(H.Cross,null)),o.default.createElement(N.CaretBox,{disabled:d,paddingLeft:3,"aria-hidden":!0,as:"button",onClick:ye,tabIndex:-1,type:"button"},o.default.createElement(H.CarretDown,null)))),o.default.createElement(ke.FieldHint,null),o.default.createElement(qe.FieldError,null)),m&&o.default.createElement(Se.Popover,{id:`${i}-popover`,source:D,spacing:4,fullWidth:!0,intersectionId:`${i}-listbox-popover-intersection`,onReachEnd:J&&!O?te:void 0},o.default.createElement("div",{role:"listbox",ref:ie,id:`${i}-listbox`,"aria-labelledby":h?ce:void 0},(Boolean(u.length)||x)&&o.default.createElement(o.default.Fragment,null,me,Ce()&&x&&o.default.createElement(ve.ComboboxOption,{isSelected:c===u.length,ref:t=>{c===u.length&&(v.current=t)},onMouseDown:K,onClick:()=>j(),taindex:0},G(s))),!u.length&&!x&&!O&&o.default.createElement(Ee.Box,{paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2,ref:v},o.default.createElement(U.Typography,{textColor:"neutral800"},Z(s))),O&&o.default.createElement(_.Flex,{justifyContent:"center",alignItems:"center",paddingTop:2,paddingBottom:2},o.default.createElement(je.Loader,{small:!0},Y)))))},L=r=>o.default.createElement(C,{...r,creatable:!0});C.defaultProps={"aria-label":void 0,clearLabel:"clear",creatable:!1,createMessage:r=>`Create "${r}"`,disabled:!1,error:void 0,hasMoreItems:!1,hint:void 0,id:void 0,label:void 0,loading:!1,loadingMessage:"Loading content...",noOptionsMessage:()=>"No results found",onClear:void 0,onCreateOption:void 0,onInputChange:void 0,onLoadMore:void 0,placeholder:"Select or enter a value",value:void 0};L.defaultProps=C.defaultProps;C.propTypes={"aria-label":e.default.string,children:e.default.oneOfType([e.default.arrayOf(e.default.node),e.default.node]),clearLabel:e.default.string,creatable:e.default.bool,createMessage:e.default.func,disabled:e.default.bool,error:e.default.string,hasMoreItems:e.default.bool,id:e.default.string,hint:e.default.oneOfType([e.default.string,e.default.node,e.default.arrayOf(e.default.node)]),label:e.default.string,labelAction:e.default.element,loading:e.default.bool,loadingMessage:e.default.string,noOptionsMessage:e.default.func,onChange:e.default.func.isRequired,onClear:e.default.func,onCreateOption:e.default.func,onInputChange:e.default.func,onLoadMore:e.default.func,placeholder:e.default.string,value:e.default.string};L.propTypes={...C.propTypes,onCreateOption:e.default.func.isRequired};exports.Combobox=C;exports.CreatableCombobox=L;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import o, { useState as y, useRef as C, useEffect as U, useLayoutEffect as xe, Children as _, cloneElement as ye } from "react";
|
|
2
|
-
import e from "prop-types";
|
|
3
2
|
import { Cross as Ie, CarretDown as ke } from "@strapi/icons";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { Loader as Se } from "../Loader/Loader.js";
|
|
12
|
-
import { MainRow as Be, InputContainer as Fe, ValueContainer as Te, Input as Ae } from "./components.js";
|
|
13
|
-
import { ComboboxOption as Pe } from "./ComboboxOption.js";
|
|
14
|
-
import { Field as Ve } from "../Field/Field.js";
|
|
15
|
-
import { FieldLabel as Ke } from "../Field/FieldLabel.js";
|
|
3
|
+
import e from "prop-types";
|
|
4
|
+
import { ComboboxOption as Oe } from "./ComboboxOption.js";
|
|
5
|
+
import { MainRow as Me, InputContainer as $e, ValueContainer as we, Input as Le } from "./components.js";
|
|
6
|
+
import { filterOptions as j, maintainScrollVisibility as De, getActionFromKey as Re, MenuActions as b, getUpdatedIndex as R } from "./utils.js";
|
|
7
|
+
import { Box as Se } from "../Box/Box.js";
|
|
8
|
+
import { Field as Be } from "../Field/Field.js";
|
|
9
|
+
import { FieldLabel as Fe } from "../Field/FieldLabel.js";
|
|
16
10
|
import "../Field/FieldInput.js";
|
|
17
|
-
import { FieldHint as
|
|
18
|
-
import { FieldError as
|
|
11
|
+
import { FieldHint as Te } from "../Field/FieldHint.js";
|
|
12
|
+
import { FieldError as Ae } from "../Field/FieldError.js";
|
|
19
13
|
import "../Field/FieldContext.js";
|
|
20
14
|
import "../Field/FieldAction.js";
|
|
21
|
-
import {
|
|
22
|
-
import { KeyboardKeys as
|
|
15
|
+
import { Flex as q } from "../Flex/Flex.js";
|
|
16
|
+
import { KeyboardKeys as Pe } from "../helpers/keyboardKeys.js";
|
|
17
|
+
import { useId as Ve } from "../helpers/useId.js";
|
|
18
|
+
import { Loader as Ke } from "../Loader/Loader.js";
|
|
19
|
+
import { Popover as Ne } from "../Popover/Popover.js";
|
|
20
|
+
import { IconBox as He, CaretBox as Ue } from "../Select/components.js";
|
|
21
|
+
import { Stack as _e } from "../Stack/Stack.js";
|
|
22
|
+
import { Typography as z } from "../Typography/Typography.js";
|
|
23
23
|
import { VisuallyHidden as je } from "../VisuallyHidden/VisuallyHidden.js";
|
|
24
24
|
const I = ({
|
|
25
25
|
children: s,
|
|
@@ -46,13 +46,13 @@ const I = ({
|
|
|
46
46
|
value: d,
|
|
47
47
|
...ne
|
|
48
48
|
}) => {
|
|
49
|
-
const ae = () => s.find((t) => t.props?.value.toLowerCase() === d.toLowerCase()).props?.children, [i, A] = y(0), [ie, le] = y(null), [l, P] = y(s), [u, se] = y(!1), [n, O] = y(""), v = C(), M = C(!1), x = C(), V = C(), ce = C(), K = C(!0), a =
|
|
49
|
+
const ae = () => s.find((t) => t.props?.value.toLowerCase() === d.toLowerCase()).props?.children, [i, A] = y(0), [ie, le] = y(null), [l, P] = y(s), [u, se] = y(!1), [n, O] = y(""), v = C(), M = C(!1), x = C(), V = C(), ce = C(), K = C(!0), a = Ve(X), pe = `${a}-label`;
|
|
50
50
|
if (!E && !ne["aria-label"])
|
|
51
51
|
throw new Error('The Combobox component needs a "label" or an "aria-label" props');
|
|
52
52
|
U(() => {
|
|
53
53
|
P(j(s, n));
|
|
54
54
|
}, [n, s]), U(() => {
|
|
55
|
-
u && v.current &&
|
|
55
|
+
u && v.current && De(v.current);
|
|
56
56
|
}, [i, u]), xe(() => {
|
|
57
57
|
K.current && (K.current = !1);
|
|
58
58
|
}, [d]);
|
|
@@ -63,8 +63,8 @@ const I = ({
|
|
|
63
63
|
const r = x.current.value;
|
|
64
64
|
P(j(s, r)), A(0), le(null), n !== r && O(r), u || f(!0, !1);
|
|
65
65
|
}, ue = (t) => {
|
|
66
|
-
const { key: r } = t, p = h && n ? l.length : l.length - 1, g =
|
|
67
|
-
switch (d && !n && r ===
|
|
66
|
+
const { key: r } = t, p = h && n ? l.length : l.length - 1, g = Re(r, u);
|
|
67
|
+
switch (d && !n && r === Pe.BACKSPACE && N(), g) {
|
|
68
68
|
case b.Next: {
|
|
69
69
|
if (i === p) {
|
|
70
70
|
m(0);
|
|
@@ -146,106 +146,92 @@ const I = ({
|
|
|
146
146
|
t.preventDefault(), f(t, !0);
|
|
147
147
|
};
|
|
148
148
|
let D;
|
|
149
|
-
return k ? D = `${a}-error` : $ && (D = `${a}-hint`), /* @__PURE__ */ o.createElement(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
paddingLeft: 3,
|
|
198
|
-
as: "button",
|
|
199
|
-
onClick: Ce,
|
|
200
|
-
type: "button"
|
|
201
|
-
}, /* @__PURE__ */ o.createElement(Ie, null)), /* @__PURE__ */ o.createElement(Le, {
|
|
202
|
-
disabled: c,
|
|
203
|
-
paddingLeft: 3,
|
|
204
|
-
"aria-hidden": !0,
|
|
205
|
-
as: "button",
|
|
206
|
-
onClick: he,
|
|
207
|
-
tabIndex: -1,
|
|
208
|
-
type: "button"
|
|
209
|
-
}, /* @__PURE__ */ o.createElement(ke, null)))), /* @__PURE__ */ o.createElement(Ne, null), /* @__PURE__ */ o.createElement(He, null)), u && /* @__PURE__ */ o.createElement(De, {
|
|
210
|
-
id: `${a}-popover`,
|
|
211
|
-
source: V,
|
|
212
|
-
spacing: 4,
|
|
213
|
-
fullWidth: !0,
|
|
214
|
-
intersectionId: `${a}-listbox-popover-intersection`,
|
|
215
|
-
onReachEnd: Q && !w ? oe : void 0
|
|
216
|
-
}, /* @__PURE__ */ o.createElement("div", {
|
|
217
|
-
role: "listbox",
|
|
218
|
-
ref: ce,
|
|
219
|
-
id: `${a}-listbox`,
|
|
220
|
-
"aria-labelledby": E ? pe : void 0
|
|
221
|
-
}, (Boolean(l.length) || h) && /* @__PURE__ */ o.createElement(o.Fragment, null, ge, Ee() && h && /* @__PURE__ */ o.createElement(Pe, {
|
|
222
|
-
isSelected: i === l.length,
|
|
223
|
-
ref: (t) => {
|
|
224
|
-
i === l.length && (v.current = t);
|
|
149
|
+
return k ? D = `${a}-error` : $ && (D = `${a}-hint`), /* @__PURE__ */ o.createElement(Be, { hint: $, error: k, id: a, required: T }, /* @__PURE__ */ o.createElement(je, { "aria-live": "polite", "aria-atomic": "false", "aria-relevant": "additions text" }, d), /* @__PURE__ */ o.createElement(_e, { spacing: E || $ || k ? 1 : 0 }, E && /* @__PURE__ */ o.createElement(Fe, { action: Y }, E), /* @__PURE__ */ o.createElement(Me, { ref: V, $disabled: c, hasError: k }, /* @__PURE__ */ o.createElement($e, { wrap: "wrap" }, !n && d && /* @__PURE__ */ o.createElement(we, { id: `${a}-selected-value` }, /* @__PURE__ */ o.createElement(z, null, ae())), /* @__PURE__ */ o.createElement(
|
|
150
|
+
Le,
|
|
151
|
+
{
|
|
152
|
+
"aria-activedescendant": de,
|
|
153
|
+
"aria-autocomplete": "list",
|
|
154
|
+
"aria-controls": `${a}-listbox`,
|
|
155
|
+
"aria-disabled": c,
|
|
156
|
+
"aria-expanded": u,
|
|
157
|
+
"aria-haspopup": "listbox",
|
|
158
|
+
"aria-describedby": D,
|
|
159
|
+
autoComplete: "off",
|
|
160
|
+
autoCorrect: "off",
|
|
161
|
+
id: a,
|
|
162
|
+
onBlur: c ? void 0 : me,
|
|
163
|
+
onClick: c ? void 0 : ve,
|
|
164
|
+
onInput: c ? void 0 : fe,
|
|
165
|
+
onKeyDown: c ? void 0 : ue,
|
|
166
|
+
placeholder: d ? "" : re,
|
|
167
|
+
readOnly: c,
|
|
168
|
+
ref: x,
|
|
169
|
+
required: T,
|
|
170
|
+
role: "combobox",
|
|
171
|
+
spellCheck: "off",
|
|
172
|
+
type: "text",
|
|
173
|
+
value: n
|
|
174
|
+
}
|
|
175
|
+
)), /* @__PURE__ */ o.createElement(q, null, (d || n) && /* @__PURE__ */ o.createElement(
|
|
176
|
+
He,
|
|
177
|
+
{
|
|
178
|
+
id: `${a}-clear`,
|
|
179
|
+
"aria-label": G,
|
|
180
|
+
disabled: c,
|
|
181
|
+
paddingLeft: 3,
|
|
182
|
+
as: "button",
|
|
183
|
+
onClick: Ce,
|
|
184
|
+
type: "button"
|
|
185
|
+
},
|
|
186
|
+
/* @__PURE__ */ o.createElement(Ie, null)
|
|
187
|
+
), /* @__PURE__ */ o.createElement(
|
|
188
|
+
Ue,
|
|
189
|
+
{
|
|
190
|
+
disabled: c,
|
|
191
|
+
paddingLeft: 3,
|
|
192
|
+
"aria-hidden": !0,
|
|
193
|
+
as: "button",
|
|
194
|
+
onClick: he,
|
|
195
|
+
tabIndex: -1,
|
|
196
|
+
type: "button"
|
|
225
197
|
},
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
198
|
+
/* @__PURE__ */ o.createElement(ke, null)
|
|
199
|
+
))), /* @__PURE__ */ o.createElement(Te, null), /* @__PURE__ */ o.createElement(Ae, null)), u && /* @__PURE__ */ o.createElement(
|
|
200
|
+
Ne,
|
|
201
|
+
{
|
|
202
|
+
id: `${a}-popover`,
|
|
203
|
+
source: V,
|
|
204
|
+
spacing: 4,
|
|
205
|
+
fullWidth: !0,
|
|
206
|
+
intersectionId: `${a}-listbox-popover-intersection`,
|
|
207
|
+
onReachEnd: Q && !w ? oe : void 0
|
|
208
|
+
},
|
|
209
|
+
/* @__PURE__ */ o.createElement(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
role: "listbox",
|
|
213
|
+
ref: ce,
|
|
214
|
+
id: `${a}-listbox`,
|
|
215
|
+
"aria-labelledby": E ? pe : void 0
|
|
216
|
+
},
|
|
217
|
+
(Boolean(l.length) || h) && /* @__PURE__ */ o.createElement(o.Fragment, null, ge, Ee() && h && /* @__PURE__ */ o.createElement(
|
|
218
|
+
Oe,
|
|
219
|
+
{
|
|
220
|
+
isSelected: i === l.length,
|
|
221
|
+
ref: (t) => {
|
|
222
|
+
i === l.length && (v.current = t);
|
|
223
|
+
},
|
|
224
|
+
onMouseDown: H,
|
|
225
|
+
onClick: () => L(),
|
|
226
|
+
taindex: 0
|
|
227
|
+
},
|
|
228
|
+
J(n)
|
|
229
|
+
)),
|
|
230
|
+
!l.length && !h && !w && /* @__PURE__ */ o.createElement(Se, { paddingLeft: 4, paddingRight: 4, paddingTop: 2, paddingBottom: 2, ref: v }, /* @__PURE__ */ o.createElement(z, { textColor: "neutral800" }, ee(n))),
|
|
231
|
+
w && /* @__PURE__ */ o.createElement(q, { justifyContent: "center", alignItems: "center", paddingTop: 2, paddingBottom: 2 }, /* @__PURE__ */ o.createElement(Ke, { small: !0 }, Z))
|
|
232
|
+
)
|
|
233
|
+
));
|
|
234
|
+
}, W = (s) => /* @__PURE__ */ o.createElement(I, { ...s, creatable: !0 });
|
|
249
235
|
I.defaultProps = {
|
|
250
236
|
"aria-label": void 0,
|
|
251
237
|
clearLabel: "clear",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react"),d=require("prop-types"),i=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react"),d=require("prop-types"),i=require("./components.cjs"),s=require("../Typography/Typography.cjs"),n=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},r=n(a),o=n(d),t=a.forwardRef(({isSelected:e,children:p,...u},l)=>r.default.createElement(i.OptionBox,{hasRadius:!0,paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2,role:"option",background:"neutral0",isSelected:e,ref:l,...u},r.default.createElement(s.Typography,{textColor:e?"primary600":"neutral800",fontWeight:e?"bold":null},p)));t.defaultProps={isSelected:!1};t.propTypes={children:o.default.oneOfType([o.default.string,o.default.number]).isRequired,isSelected:o.default.bool};t.displayName="ComboboxOption";exports.ComboboxOption=t;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import t, { forwardRef as a } from "react";
|
|
2
2
|
import o from "prop-types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
const r = a(({ isSelected: e, children: p, ...i }, n) => /* @__PURE__ */ t.createElement(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, p)
|
|
3
|
+
import { OptionBox as d } from "./components.js";
|
|
4
|
+
import { Typography as m } from "../Typography/Typography.js";
|
|
5
|
+
const r = a(({ isSelected: e, children: p, ...i }, n) => /* @__PURE__ */ t.createElement(
|
|
6
|
+
d,
|
|
7
|
+
{
|
|
8
|
+
hasRadius: !0,
|
|
9
|
+
paddingLeft: 4,
|
|
10
|
+
paddingRight: 4,
|
|
11
|
+
paddingTop: 2,
|
|
12
|
+
paddingBottom: 2,
|
|
13
|
+
role: "option",
|
|
14
|
+
background: "neutral0",
|
|
15
|
+
isSelected: e,
|
|
16
|
+
ref: n,
|
|
17
|
+
...i
|
|
18
|
+
},
|
|
19
|
+
/* @__PURE__ */ t.createElement(m, { textColor: e ? "primary600" : "neutral800", fontWeight: e ? "bold" : null }, p)
|
|
20
|
+
));
|
|
20
21
|
r.defaultProps = {
|
|
21
22
|
isSelected: !1
|
|
22
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),v=require("@strapi/icons"),z=require("prop-types"),u=require("./components.cjs"),I=require("./DatePickerCalendar.cjs"),C=require("./utils/formatDate.cjs"),S=require("../helpers/getDefaultLocale.cjs"),B=require("../TextInput/TextInput.cjs"),M=require("../themes/sizes.cjs"),h=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},a=h(o),e=h(z),f=({ariaLabel:t,initialDate:k,selectedDate:n,onChange:P,label:i,locale:q,selectedDateLabel:y,onClear:d,clearLabel:R,disabled:l,id:j,minDate:E,maxDate:T,...x})=>{const[p,c]=o.useState(!1),r=o.useRef(null),D=o.useRef(null),m=q||S.getDefaultLocale(),b=n?C.formatDate(n,m):"",g=()=>{l||c(s=>!s)},L=()=>{l||(d(),D.current.focus())},O=s=>{P(s),c(!1)},_=()=>{c(!1)};return a.default.createElement(u.DatePickerWrapper,{bold:p},a.default.createElement(B.TextInput,{ref:r,onClick:g,onChange:()=>{},value:b,startAction:a.default.createElement(u.DatePickerButton,{ref:D,onClick:g,"aria-label":n?y(C.formatDate(n,m)):i||t,type:"button","aria-disabled":l},a.default.createElement(v.Calendar,{"aria-hidden":!0})),endAction:d&&b?a.default.createElement(u.IconBox,{as:"button",onClick:L,"aria-label":R,"aria-disabled":l},a.default.createElement(v.Cross,null)):void 0,"aria-autocomplete":"none",label:i,"aria-label":t,disabled:l,id:j,...x}),r.current&&r.current.inputWrapperRef&&p&&a.default.createElement(I.DatePickerCalendar,{selectedDate:n,initialDate:k,onChange:O,onEscape:_,popoverSource:r.current.inputWrapperRef,label:i||t,minDate:E,maxDate:T}))};f.defaultProps={ariaLabel:void 0,clearLabel:void 0,disabled:!1,id:void 0,label:void 0,locale:void 0,initialDate:new Date,minDate:void 0,maxDate:void 0,onClear:void 0,placeholder:void 0,selectedDate:void 0,size:"M"};f.propTypes={ariaLabel:e.default.string,clearLabel:e.default.string,disabled:e.default.bool,id:e.default.string,initialDate:e.default.instanceOf(Date),label:e.default.string,locale:e.default.string,maxDate:e.default.instanceOf(Date),minDate:e.default.instanceOf(Date),onChange:e.default.func.isRequired,onClear:e.default.func,placeholder:e.default.string,selectedDate:e.default.instanceOf(Date),selectedDateLabel:e.default.func.isRequired,size:e.default.oneOf(Object.keys(M.sizes.input))};exports.DatePicker=f;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import t, { useState as B, useRef as D } from "react";
|
|
2
|
-
import e from "prop-types";
|
|
3
2
|
import { Calendar as T, Cross as W } from "@strapi/icons";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { DatePickerCalendar as _ } from "./DatePickerCalendar.js";
|
|
3
|
+
import e from "prop-types";
|
|
4
|
+
import { DatePickerWrapper as q, DatePickerButton as A, IconBox as I } from "./components.js";
|
|
5
|
+
import { DatePickerCalendar as S } from "./DatePickerCalendar.js";
|
|
8
6
|
import { formatDate as b } from "./utils/formatDate.js";
|
|
9
|
-
import { getDefaultLocale as
|
|
7
|
+
import { getDefaultLocale as V } from "../helpers/getDefaultLocale.js";
|
|
8
|
+
import { TextInput as _ } from "../TextInput/TextInput.js";
|
|
9
|
+
import { sizes as j } from "../themes/sizes.js";
|
|
10
10
|
const v = ({
|
|
11
11
|
ariaLabel: o,
|
|
12
12
|
initialDate: g,
|
|
@@ -23,7 +23,7 @@ const v = ({
|
|
|
23
23
|
maxDate: O,
|
|
24
24
|
...x
|
|
25
25
|
}) => {
|
|
26
|
-
const [f, l] = B(!1), n = D(null), p = D(null), u = h ||
|
|
26
|
+
const [f, l] = B(!1), n = D(null), p = D(null), u = h || V(), m = a ? b(a, u) : "", d = () => {
|
|
27
27
|
r || l((c) => !c);
|
|
28
28
|
}, y = () => {
|
|
29
29
|
r || (s(), p.current.focus());
|
|
@@ -32,45 +32,46 @@ const v = ({
|
|
|
32
32
|
}, z = () => {
|
|
33
33
|
l(!1);
|
|
34
34
|
};
|
|
35
|
-
return /* @__PURE__ */ t.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
onClick: d,
|
|
40
|
-
onChange: () => {
|
|
41
|
-
},
|
|
42
|
-
value: m,
|
|
43
|
-
startAction: /* @__PURE__ */ t.createElement(S, {
|
|
44
|
-
ref: p,
|
|
35
|
+
return /* @__PURE__ */ t.createElement(q, { bold: f }, /* @__PURE__ */ t.createElement(
|
|
36
|
+
_,
|
|
37
|
+
{
|
|
38
|
+
ref: n,
|
|
45
39
|
onClick: d,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
onChange: () => {
|
|
41
|
+
},
|
|
42
|
+
value: m,
|
|
43
|
+
startAction: /* @__PURE__ */ t.createElement(
|
|
44
|
+
A,
|
|
45
|
+
{
|
|
46
|
+
ref: p,
|
|
47
|
+
onClick: d,
|
|
48
|
+
"aria-label": a ? k(b(a, u)) : i || o,
|
|
49
|
+
type: "button",
|
|
50
|
+
"aria-disabled": r
|
|
51
|
+
},
|
|
52
|
+
/* @__PURE__ */ t.createElement(T, { "aria-hidden": !0 })
|
|
53
|
+
),
|
|
54
|
+
endAction: s && m ? /* @__PURE__ */ t.createElement(I, { as: "button", onClick: y, "aria-label": E, "aria-disabled": r }, /* @__PURE__ */ t.createElement(W, null)) : void 0,
|
|
55
|
+
"aria-autocomplete": "none",
|
|
56
|
+
label: i,
|
|
57
|
+
"aria-label": o,
|
|
58
|
+
disabled: r,
|
|
59
|
+
id: R,
|
|
60
|
+
...x
|
|
61
|
+
}
|
|
62
|
+
), n.current && n.current.inputWrapperRef && f && /* @__PURE__ */ t.createElement(
|
|
63
|
+
S,
|
|
64
|
+
{
|
|
65
|
+
selectedDate: a,
|
|
66
|
+
initialDate: g,
|
|
67
|
+
onChange: L,
|
|
68
|
+
onEscape: z,
|
|
69
|
+
popoverSource: n.current.inputWrapperRef,
|
|
70
|
+
label: i || o,
|
|
71
|
+
minDate: P,
|
|
72
|
+
maxDate: O
|
|
73
|
+
}
|
|
74
|
+
));
|
|
74
75
|
};
|
|
75
76
|
v.defaultProps = {
|
|
76
77
|
ariaLabel: void 0,
|
|
@@ -102,7 +103,7 @@ v.propTypes = {
|
|
|
102
103
|
placeholder: e.string,
|
|
103
104
|
selectedDate: e.instanceOf(Date),
|
|
104
105
|
selectedDateLabel: e.func.isRequired,
|
|
105
|
-
size: e.oneOf(Object.keys(
|
|
106
|
+
size: e.oneOf(Object.keys(j.input))
|
|
106
107
|
};
|
|
107
108
|
export {
|
|
108
109
|
v as DatePicker
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("react"),W=require("prop-types"),H=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("react"),W=require("prop-types"),H=require("./components.cjs"),V=require("./DatePickerTd.cjs"),r=require("./DatePickerTh.cjs"),L=require("./utils/getDayOfWeek.cjs"),$=require("./utils/getMonths.cjs"),I=require("./utils/generateWeeks.cjs"),z=require("./utils/getYears.cjs"),A=require("./utils/formatDate.cjs"),d=require("../Box/Box.cjs"),G=require("../Flex/Flex.cjs"),J=require("../FocusTrap/FocusTrap.cjs"),K=require("../RawTable/RawTable.cjs");require("../RawTable/RawCell.cjs");const N=require("../RawTable/RawThead.cjs"),Q=require("../RawTable/RawTbody.cjs"),D=require("../RawTable/RawTr.cjs"),i=require("../SimpleMenu/SimpleMenu.cjs"),U=require("../VisuallyHidden/VisuallyHidden.cjs"),T=a=>a&&typeof a=="object"&&"default"in a?a:{default:a},e=T(f),l=T(W),m=({selectedDate:a,initialDate:g,popoverSource:E,onChange:R,label:h,minDate:k,maxDate:w,onEscape:q})=>{const[c,s]=f.useState(g),[p,y,j]=I.generateWeeks(c,a),{sun:P,mon:b,tue:M,wed:x,thu:C,fri:F,sat:O}=L.getDayOfWeek(),o=$.getMonths(),S=z.getYears(k,w);f.useEffect(()=>{a&&s(a)},[a]);const v=t=>{const n=new Date(c);n.setMonth(o.indexOf(t)),s(n)},B=t=>{const n=new Date(c);n.setFullYear(t),s(n)};return e.default.createElement(H.DatePickerPopover,{source:E,role:"dialog","aria-modal":"true","aria-label":h,spacing:4},e.default.createElement(J.FocusTrap,{onEscape:q},e.default.createElement(d.Box,{padding:4},e.default.createElement(d.Box,{paddingBottom:4,paddingLeft:2,paddingRight:2},e.default.createElement(G.Flex,null,e.default.createElement(i.SimpleMenu,{label:o[c.getMonth()]},o.map(t=>e.default.createElement(i.MenuItem,{key:t,onClick:()=>v(t)},t))),e.default.createElement(d.Box,{paddingLeft:2},e.default.createElement(i.SimpleMenu,{label:c.getFullYear()},S.map(t=>e.default.createElement(i.MenuItem,{key:t,onClick:()=>B(t)},t)))))),e.default.createElement(K.RawTable,{colCount:7,rowCount:p.length+1,initialCol:j,initialRow:y,role:"grid"},e.default.createElement(N.RawThead,null,e.default.createElement(D.RawTr,{"aria-rowindex":1},e.default.createElement(r.DatePickerTh,null,P),e.default.createElement(r.DatePickerTh,null,b),e.default.createElement(r.DatePickerTh,null,M),e.default.createElement(r.DatePickerTh,null,x),e.default.createElement(r.DatePickerTh,null,C),e.default.createElement(r.DatePickerTh,null,F),e.default.createElement(r.DatePickerTh,null,O))),e.default.createElement(Q.RawTbody,null,p.map((t,n)=>e.default.createElement(D.RawTr,{key:n},t.map(({date:u,outsideMonth:Y,isSelected:_})=>e.default.createElement(V.DatePickerTd,{key:`${u.getFullYear()}-${u.getMonth()+1}-${u.getDate()}`,outsideMonth:Y,onSelectDay:()=>R(u),isSelected:_},e.default.createElement("span",{"aria-hidden":!0},u.getDate()),e.default.createElement(U.VisuallyHidden,null,e.default.createElement("span",null,A.formatDate(u))))))))))))};m.defaultProps={selectedDate:void 0,initialDate:new Date,minDate:void 0,maxDate:void 0};m.propTypes={initialDate:l.default.instanceOf(Date),label:l.default.string.isRequired,maxDate:l.default.instanceOf(Date),minDate:l.default.instanceOf(Date),onChange:l.default.func.isRequired,onEscape:l.default.func.isRequired,popoverSource:l.default.shape({current:(typeof Element>"u"?l.default.any:l.default.instanceOf(Element)).isRequired}).isRequired,selectedDate:l.default.instanceOf(Date)};exports.DatePickerCalendar=m;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import e, { useState as L, useEffect as W } from "react";
|
|
2
2
|
import a from "prop-types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { DatePickerPopover as _ } from "./components.js";
|
|
4
|
+
import { DatePickerTd as H } from "./DatePickerTd.js";
|
|
5
|
+
import { DatePickerTh as r } from "./DatePickerTh.js";
|
|
6
|
+
import { getDayOfWeek as I } from "./utils/getDayOfWeek.js";
|
|
7
|
+
import { getMonths as V } from "./utils/getMonths.js";
|
|
8
|
+
import { generateWeeks as j } from "./utils/generateWeeks.js";
|
|
9
|
+
import { getYears as z } from "./utils/getYears.js";
|
|
10
|
+
import { formatDate as A } from "./utils/formatDate.js";
|
|
7
11
|
import { Box as p } from "../Box/Box.js";
|
|
8
|
-
import {
|
|
12
|
+
import { Flex as G } from "../Flex/Flex.js";
|
|
13
|
+
import { FocusTrap as J } from "../FocusTrap/FocusTrap.js";
|
|
14
|
+
import { RawTable as K } from "../RawTable/RawTable.js";
|
|
9
15
|
import "../RawTable/RawCell.js";
|
|
10
|
-
import { RawThead as
|
|
11
|
-
import { RawTbody as
|
|
12
|
-
import { RawTr as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { FocusTrap as G } from "../FocusTrap/FocusTrap.js";
|
|
16
|
-
import { getDayOfWeek as J } from "./utils/getDayOfWeek.js";
|
|
17
|
-
import { getMonths as K } from "./utils/getMonths.js";
|
|
18
|
-
import { generateWeeks as N } from "./utils/generateWeeks.js";
|
|
19
|
-
import { getYears as Q } from "./utils/getYears.js";
|
|
20
|
-
import { formatDate as U } from "./utils/formatDate.js";
|
|
16
|
+
import { RawThead as N } from "../RawTable/RawThead.js";
|
|
17
|
+
import { RawTbody as Q } from "../RawTable/RawTbody.js";
|
|
18
|
+
import { RawTr as s } from "../RawTable/RawTr.js";
|
|
19
|
+
import { SimpleMenu as f, MenuItem as d } from "../SimpleMenu/SimpleMenu.js";
|
|
20
|
+
import { VisuallyHidden as U } from "../VisuallyHidden/VisuallyHidden.js";
|
|
21
21
|
const E = ({
|
|
22
22
|
selectedDate: i,
|
|
23
23
|
initialDate: g,
|
|
@@ -28,7 +28,7 @@ const E = ({
|
|
|
28
28
|
maxDate: R,
|
|
29
29
|
onEscape: y
|
|
30
30
|
}) => {
|
|
31
|
-
const [l, m] = L(g), [u, C, T] =
|
|
31
|
+
const [l, m] = L(g), [u, C, T] = j(l, i), { sun: v, mon: x, tue: M, wed: O, thu: P, fri: b, sat: q } = I(), c = V(), F = z(w, R);
|
|
32
32
|
W(() => {
|
|
33
33
|
i && m(i);
|
|
34
34
|
}, [i]);
|
|
@@ -39,50 +39,17 @@ const E = ({
|
|
|
39
39
|
const n = new Date(l);
|
|
40
40
|
n.setFullYear(t), m(n);
|
|
41
41
|
};
|
|
42
|
-
return /* @__PURE__ */ e.createElement(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
paddingBottom: 4,
|
|
54
|
-
paddingLeft: 2,
|
|
55
|
-
paddingRight: 2
|
|
56
|
-
}, /* @__PURE__ */ e.createElement(I, null, /* @__PURE__ */ e.createElement(s, {
|
|
57
|
-
label: c[l.getMonth()]
|
|
58
|
-
}, c.map((t) => /* @__PURE__ */ e.createElement(f, {
|
|
59
|
-
key: t,
|
|
60
|
-
onClick: () => Y(t)
|
|
61
|
-
}, t))), /* @__PURE__ */ e.createElement(p, {
|
|
62
|
-
paddingLeft: 2
|
|
63
|
-
}, /* @__PURE__ */ e.createElement(s, {
|
|
64
|
-
label: l.getFullYear()
|
|
65
|
-
}, F.map((t) => /* @__PURE__ */ e.createElement(f, {
|
|
66
|
-
key: t,
|
|
67
|
-
onClick: () => S(t)
|
|
68
|
-
}, t)))))), /* @__PURE__ */ e.createElement(V, {
|
|
69
|
-
colCount: 7,
|
|
70
|
-
rowCount: u.length + 1,
|
|
71
|
-
initialCol: T,
|
|
72
|
-
initialRow: C,
|
|
73
|
-
role: "grid"
|
|
74
|
-
}, /* @__PURE__ */ e.createElement(j, null, /* @__PURE__ */ e.createElement(d, {
|
|
75
|
-
"aria-rowindex": 1
|
|
76
|
-
}, /* @__PURE__ */ e.createElement(r, null, v), /* @__PURE__ */ e.createElement(r, null, x), /* @__PURE__ */ e.createElement(r, null, M), /* @__PURE__ */ e.createElement(r, null, O), /* @__PURE__ */ e.createElement(r, null, P), /* @__PURE__ */ e.createElement(r, null, b), /* @__PURE__ */ e.createElement(r, null, q))), /* @__PURE__ */ e.createElement(z, null, u.map((t, n) => /* @__PURE__ */ e.createElement(d, {
|
|
77
|
-
key: n
|
|
78
|
-
}, t.map(({ date: o, outsideMonth: $, isSelected: B }) => /* @__PURE__ */ e.createElement(A, {
|
|
79
|
-
key: `${o.getFullYear()}-${o.getMonth() + 1}-${o.getDate()}`,
|
|
80
|
-
outsideMonth: $,
|
|
81
|
-
onSelectDay: () => h(o),
|
|
82
|
-
isSelected: B
|
|
83
|
-
}, /* @__PURE__ */ e.createElement("span", {
|
|
84
|
-
"aria-hidden": !0
|
|
85
|
-
}, o.getDate()), /* @__PURE__ */ e.createElement(_, null, /* @__PURE__ */ e.createElement("span", null, U(o))))))))))));
|
|
42
|
+
return /* @__PURE__ */ e.createElement(_, { source: D, role: "dialog", "aria-modal": "true", "aria-label": k, spacing: 4 }, /* @__PURE__ */ e.createElement(J, { onEscape: y }, /* @__PURE__ */ e.createElement(p, { padding: 4 }, /* @__PURE__ */ e.createElement(p, { paddingBottom: 4, paddingLeft: 2, paddingRight: 2 }, /* @__PURE__ */ e.createElement(G, null, /* @__PURE__ */ e.createElement(f, { label: c[l.getMonth()] }, c.map((t) => /* @__PURE__ */ e.createElement(d, { key: t, onClick: () => Y(t) }, t))), /* @__PURE__ */ e.createElement(p, { paddingLeft: 2 }, /* @__PURE__ */ e.createElement(f, { label: l.getFullYear() }, F.map((t) => /* @__PURE__ */ e.createElement(d, { key: t, onClick: () => S(t) }, t)))))), /* @__PURE__ */ e.createElement(K, { colCount: 7, rowCount: u.length + 1, initialCol: T, initialRow: C, role: "grid" }, /* @__PURE__ */ e.createElement(N, null, /* @__PURE__ */ e.createElement(s, { "aria-rowindex": 1 }, /* @__PURE__ */ e.createElement(r, null, v), /* @__PURE__ */ e.createElement(r, null, x), /* @__PURE__ */ e.createElement(r, null, M), /* @__PURE__ */ e.createElement(r, null, O), /* @__PURE__ */ e.createElement(r, null, P), /* @__PURE__ */ e.createElement(r, null, b), /* @__PURE__ */ e.createElement(r, null, q))), /* @__PURE__ */ e.createElement(Q, null, u.map((t, n) => /* @__PURE__ */ e.createElement(s, { key: n }, t.map(({ date: o, outsideMonth: $, isSelected: B }) => /* @__PURE__ */ e.createElement(
|
|
43
|
+
H,
|
|
44
|
+
{
|
|
45
|
+
key: `${o.getFullYear()}-${o.getMonth() + 1}-${o.getDate()}`,
|
|
46
|
+
outsideMonth: $,
|
|
47
|
+
onSelectDay: () => h(o),
|
|
48
|
+
isSelected: B
|
|
49
|
+
},
|
|
50
|
+
/* @__PURE__ */ e.createElement("span", { "aria-hidden": !0 }, o.getDate()),
|
|
51
|
+
/* @__PURE__ */ e.createElement(U, null, /* @__PURE__ */ e.createElement("span", null, A(o)))
|
|
52
|
+
)))))))));
|
|
86
53
|
};
|
|
87
54
|
E.defaultProps = {
|
|
88
55
|
selectedDate: void 0,
|