@alma-oss/spirit-web-react 4.7.0 → 4.8.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/CHANGELOG.md +10 -0
- package/dist/bundles/web-react.umd.js +18 -2
- package/dist/bundles/web-react.umd.js.map +1 -1
- package/dist/bundles/web-react.umd.min.js +1 -1
- package/dist/bundles/web-react.umd.min.js.map +1 -1
- package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.cjs +1 -1
- package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.cjs.map +1 -1
- package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.js +128 -115
- package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.js.map +1 -1
- package/dist/components/UNSTABLE_Picker/constants.cjs +1 -1
- package/dist/components/UNSTABLE_Picker/constants.cjs.map +1 -1
- package/dist/components/UNSTABLE_Picker/constants.d.ts +2 -1
- package/dist/components/UNSTABLE_Picker/constants.js +10 -7
- package/dist/components/UNSTABLE_Picker/constants.js.map +1 -1
- package/dist/components/UNSTABLE_Picker/types.d.ts +4 -1
- package/dist/types/dropdown.cjs.map +1 -1
- package/dist/types/dropdown.d.ts +10 -8
- package/dist/types/dropdown.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),w=require("classnames"),r=require("react"),xe=require("../../constants/selection.cjs"),fe=require("../../hooks/styleProps.cjs"),Te=require("../../hooks/useAriaIdRefs.cjs"),ye=require("../../hooks/useI18n.cjs"),B=require("../../hooks/useSelectionState.cjs"),O=require("../../translations/replaceTranslationParams.cjs"),ke=require("../Dropdown/Dropdown.cjs"),Se=require("../Dropdown/DropdownPopover.cjs"),qe=require("../Field/HelperText.cjs"),he=require("../Field/Label.cjs"),Ie=require("../Field/ValidationText.cjs"),Ae=require("../Field/useValidationTextRole.cjs"),Le=require("../Icon/Icon.cjs"),Ne=require("../VisuallyHidden/VisuallyHidden.cjs"),V=require("./constants.cjs"),Re=require("./PickerContext.cjs"),je=require("./PickerPopoverContext.cjs"),F=require("./UNSTABLE_PickerTag.cjs"),Ce=require("./usePickerId.cjs"),Ee=require("./usePickerPopoverTabOutToTrigger.cjs"),_e=require("./usePickerSelectionGridKeyboard.cjs"),De=require("./usePickerStyleProps.cjs"),p=require("./utils.cjs"),Ke=(G,H)=>{const{t:n}=ye.useI18n(),{"aria-describedby":$="",addButtonLabel:z=n("picker.add"),children:x,closeButtonLabel:Z=n("common.close"),emptySelectionLabel:q,helperText:J,id:Q,isAggregated:f=!1,isDisabled:o=!1,isFluid:W=!1,isLabelHidden:X=!1,isOpen:s,isRequired:Y=!1,dropdownProps:ee,label:i,labelProps:h,onSelectionChange:c,onToggle:P,popoverProps:re=V.DEFAULT_POPOVER_PROPS,removeAllLabel:se=n("picker.removeAll"),renderTags:I,selectedKeys:d,selectionAriaLabel:te=n("picker.selectionAriaLabel"),selectionMode:u=xe.MULTIPLE_SELECTION_MODE,size:A=V.DEFAULT_SIZE,tagDescriptionText:oe=n("picker.tagDescriptionText"),hasValidationIcon:ie,validationState:g,validationText:L,...ae}=G,[le,N]=Te.useAriaDescribedBy($),ne=Ae.useValidationTextRole({validationState:g,validationText:L}),{classProps:t}=De.usePickerStyleProps({isDisabled:o,isFluid:W,isLabelHidden:X,isRequired:Y,size:A,validationState:g}),{styleProps:R,props:ce}=fe.useStyleProps(ae),{labelId:j,pickerId:m,popoverId:C,selectionId:de,tagDescriptionId:E}=Ce.usePickerId(Q),_=r.useMemo(()=>p.collectPickerItems(x),[x]),D=r.useMemo(()=>p.getPickerItemLabelMap(_),[_]),b=r.useMemo(()=>B.getSelectedKeys(d,u),[d,u]),a=r.useMemo(()=>p.getSelectedItems(b,D),[b,D]),K=l=>B.isSingleSelectionMode(u)?c([]):c(d.filter(v=>v!==l)),ue=()=>c([]),M=r.useRef(null),U=r.useRef(null),T=r.useCallback(()=>{s&&(P(),Promise.resolve().then(()=>{U.current?.focus()}))},[s,P]),{onPopoverKeyDownCapture:pe}=Ee.usePickerPopoverTabOutToTrigger({isOpen:s,onClose:T}),Pe=p.getPickerSelectionGridKeyboardRowCount(a.length,{isAggregated:f}),{getKeyboardGridRowProps:y,removeTagAtIndex:k}=_e.usePickerSelectionGridKeyboard({isDisabled:o,isPopoverOpen:s,onRemoveAtIndex:l=>{f?ue():K(a[l].value)},selectionRef:M,tagCount:Pe}),ge=q?O.replaceTranslationParams(q,{label:i}):i,me=p.getAggregatedTagLabel(i,a),be=a.length?I?I({getKeyboardGridRowProps:y,onRemove:K,removeTagAtIndex:k}):f?e.jsx(F.default,{tagKeyboardProps:y(0),isDisabled:o,label:me,onRemove:()=>k(0),removeLabel:se}):a.map((l,v)=>e.jsx(F.default,{tagKeyboardProps:y(v),isDisabled:o,label:l.label,onRemove:()=>k(v)},l.value)):e.jsx("span",{"aria-hidden":"true",className:t.selectionEmpty,children:ge}),ve=r.useMemo(()=>({id:m,isDisabled:o,onSelectionChange:c,selectedKeys:b,selectionMode:u}),[b,o,c,m,u]);return r.useImperativeHandle(H,()=>({close:T,selectedKeys:d}),[T,d]),e.jsx(Re.PickerContextProvider,{value:{size:A,tagDescriptionId:E},children:e.jsxs("div",{...R,className:w(t.root,R.className),...ce,children:[e.jsx(he.default,{...h,id:j,elementType:"span",UNSAFE_className:w(t.label,h?.UNSAFE_className),children:i}),e.jsxs(ke.default,{...ee,id:C,isOpen:s,onToggle:P,children:[e.jsxs("div",{role:"group","aria-label":i,className:t.inputContainer,children:[e.jsx("div",{ref:M,...le,id:de,role:a.length?"grid":"group","aria-label":O.replaceTranslationParams(te,{label:i}),"aria-live":"off","aria-atomic":!1,"aria-relevant":"additions",className:t.selection,children:be}),e.jsxs("button",{ref:U,type:"button",className:t.trigger,"aria-haspopup":"dialog","aria-expanded":s,"aria-controls":C,onClick:P,disabled:o,children:[e.jsx(Ne.default,{children:s?Z:z}),e.jsx(Le.default,{name:`chevron-${s?"up":"down"}`,boxSize:20})]})]}),e.jsx(Se.default,{...re,"aria-labelledby":j,role:"dialog","aria-modal":"true",onKeyDownCapture:pe,children:e.jsx(je.PickerPopoverContextProvider,{value:ve,children:x})})]}),e.jsx(qe.default,{UNSAFE_className:t.helperText,id:`${m}-helper-text`,registerAria:N,helperText:J}),g&&e.jsx(Ie.default,{UNSAFE_className:t.validationText,id:`${m}-validation-text`,...ie&&{hasValidationStateIcon:g},validationText:L,registerAria:N,role:ne}),e.jsx("span",{id:E,hidden:!0,children:oe})]})})},S=r.forwardRef(Ke);S.spiritComponent="UNSTABLE_Picker";S.displayName="UNSTABLE_Picker";exports.default=S;
|
|
2
2
|
//# sourceMappingURL=UNSTABLE_Picker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UNSTABLE_Picker.cjs","sources":["../../../src/components/UNSTABLE_Picker/UNSTABLE_Picker.tsx"],"sourcesContent":["'use client';\n\nimport classNames from 'classnames';\nimport React, { type ForwardedRef, forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from 'react';\nimport { MULTIPLE_SELECTION_MODE } from '../../constants';\nimport { getSelectedKeys, isSingleSelectionMode, useAriaDescribedBy, useI18n, useStyleProps } from '../../hooks';\nimport { replaceTranslationParams } from '../../translations';\nimport { type ForwardRefComponent } from '../../types';\nimport { Dropdown, DropdownPopover } from '../Dropdown';\nimport { HelperText, Label, ValidationText } from '../Field';\nimport { useValidationTextRole } from '../Field/useValidationTextRole';\nimport { Icon } from '../Icon';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { DEFAULT_SIZE } from './constants';\nimport { PickerContextProvider } from './PickerContext';\nimport { PickerPopoverContextProvider } from './PickerPopoverContext';\nimport type { SpiritUnstablePickerProps, SpiritUnstablePickerRef } from './types';\nimport UNSTABLE_PickerTag from './UNSTABLE_PickerTag';\nimport { usePickerId } from './usePickerId';\nimport { usePickerPopoverTabOutToTrigger } from './usePickerPopoverTabOutToTrigger';\nimport { usePickerSelectionGridKeyboard } from './usePickerSelectionGridKeyboard';\nimport { usePickerStyleProps } from './usePickerStyleProps';\nimport {\n collectPickerItems,\n getAggregatedTagLabel,\n getPickerItemLabelMap,\n getPickerSelectionGridKeyboardRowCount,\n getSelectedItems,\n} from './utils';\n\n// eslint-disable-next-line camelcase\nconst _UNSTABLE_Picker = (props: SpiritUnstablePickerProps, ref: ForwardedRef<SpiritUnstablePickerRef>) => {\n const { t } = useI18n();\n\n const {\n 'aria-describedby': ariaDescribedBy = '',\n addButtonLabel = t('picker.add'),\n children,\n closeButtonLabel = t('common.close'),\n emptySelectionLabel,\n helperText,\n id,\n isAggregated = false,\n isDisabled = false,\n isFluid = false,\n isLabelHidden = false,\n isOpen,\n isRequired = false,\n label,\n onSelectionChange,\n onToggle,\n removeAllLabel = t('picker.removeAll'),\n renderTags,\n selectedKeys,\n selectionAriaLabel = t('picker.selectionAriaLabel'),\n selectionMode = MULTIPLE_SELECTION_MODE,\n size = DEFAULT_SIZE,\n tagDescriptionText = t('picker.tagDescriptionText'),\n hasValidationIcon,\n validationState,\n validationText,\n ...restProps\n } = props;\n\n const [ariaDescribedByProp, register] = useAriaDescribedBy(ariaDescribedBy);\n const validationTextRole = useValidationTextRole({\n validationState,\n validationText,\n });\n const { classProps } = usePickerStyleProps({\n isDisabled,\n isFluid,\n isLabelHidden,\n isRequired,\n size,\n validationState,\n });\n const { styleProps, props: transferProps } = useStyleProps(restProps);\n const { labelId, pickerId, popoverId, selectionId, tagDescriptionId } = usePickerId(id);\n\n const pickerItems = useMemo(() => collectPickerItems(children), [children]);\n\n const pickerItemLabels = useMemo(() => getPickerItemLabelMap(pickerItems), [pickerItems]);\n\n const selectedPickerKeys = useMemo(() => getSelectedKeys(selectedKeys, selectionMode), [selectedKeys, selectionMode]);\n\n const selectedPickerItems = useMemo(\n () => getSelectedItems(selectedPickerKeys, pickerItemLabels),\n [selectedPickerKeys, pickerItemLabels],\n );\n\n const removeItem = (key: string) =>\n isSingleSelectionMode(selectionMode)\n ? onSelectionChange([])\n : onSelectionChange(selectedKeys.filter((selectedKey) => selectedKey !== key));\n\n const removeAll = () => onSelectionChange([]);\n\n const selectionGridRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n\n const close = useCallback(() => {\n if (!isOpen) {\n return;\n }\n\n onToggle();\n\n Promise.resolve().then(() => {\n triggerRef.current?.focus();\n });\n }, [isOpen, onToggle]);\n\n const { onPopoverKeyDownCapture } = usePickerPopoverTabOutToTrigger({\n isOpen,\n onClose: close,\n });\n\n const selectionGridKeyboardRowCount = getPickerSelectionGridKeyboardRowCount(selectedPickerItems.length, {\n isAggregated,\n });\n\n const { getKeyboardGridRowProps, removeTagAtIndex } = usePickerSelectionGridKeyboard({\n isDisabled,\n isPopoverOpen: isOpen,\n onRemoveAtIndex: (index) => {\n if (isAggregated) {\n removeAll();\n } else {\n removeItem(selectedPickerItems[index]!.value);\n }\n },\n selectionRef: selectionGridRef,\n tagCount: selectionGridKeyboardRowCount,\n });\n\n const emptyLabel = emptySelectionLabel ? replaceTranslationParams(emptySelectionLabel, { label }) : label;\n const aggregatedTagLabel = getAggregatedTagLabel(label, selectedPickerItems);\n\n const selectionContent = (() => {\n if (!selectedPickerItems.length) {\n return (\n <span aria-hidden=\"true\" className={classProps.selectionEmpty}>\n {emptyLabel}\n </span>\n );\n }\n\n if (renderTags) {\n return renderTags({\n getKeyboardGridRowProps,\n onRemove: removeItem,\n removeTagAtIndex,\n });\n }\n\n if (isAggregated) {\n return (\n <UNSTABLE_PickerTag\n tagKeyboardProps={getKeyboardGridRowProps(0)}\n isDisabled={isDisabled}\n label={aggregatedTagLabel}\n onRemove={() => removeTagAtIndex(0)}\n removeLabel={removeAllLabel}\n />\n );\n }\n\n return selectedPickerItems.map((item, index) => (\n <UNSTABLE_PickerTag\n key={item.value}\n tagKeyboardProps={getKeyboardGridRowProps(index)}\n isDisabled={isDisabled}\n label={item.label}\n onRemove={() => removeTagAtIndex(index)}\n />\n ));\n })();\n\n const popoverContextValue = useMemo(\n () => ({\n id: pickerId,\n isDisabled,\n onSelectionChange,\n selectedKeys: selectedPickerKeys,\n selectionMode,\n }),\n [selectedPickerKeys, isDisabled, onSelectionChange, pickerId, selectionMode],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n close,\n selectedKeys,\n }),\n [close, selectedKeys],\n );\n\n return (\n <PickerContextProvider value={{ size, tagDescriptionId }}>\n <div {...styleProps} className={classNames(classProps.root, styleProps.className)} {...transferProps}>\n <Label id={labelId} UNSAFE_className={classProps.label} elementType=\"span\">\n {label}\n </Label>\n <Dropdown id={popoverId} isOpen={isOpen} onToggle={onToggle}>\n <div role=\"group\" aria-label={label} className={classProps.inputContainer}>\n <div\n ref={selectionGridRef}\n {...ariaDescribedByProp}\n id={selectionId}\n role={selectedPickerItems.length ? 'grid' : 'group'}\n aria-label={replaceTranslationParams(selectionAriaLabel, { label })}\n aria-live=\"off\"\n aria-atomic={false}\n aria-relevant=\"additions\"\n className={classProps.selection}\n >\n {selectionContent}\n </div>\n <button\n ref={triggerRef}\n type=\"button\"\n className={classProps.trigger}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={popoverId}\n onClick={onToggle}\n disabled={isDisabled}\n >\n <VisuallyHidden>{isOpen ? closeButtonLabel : addButtonLabel}</VisuallyHidden>\n <Icon name={`chevron-${isOpen ? 'up' : 'down'}`} boxSize={20} />\n </button>\n </div>\n <DropdownPopover\n aria-labelledby={labelId}\n role=\"dialog\"\n aria-modal=\"true\"\n onKeyDownCapture={onPopoverKeyDownCapture}\n >\n <PickerPopoverContextProvider value={popoverContextValue}>{children}</PickerPopoverContextProvider>\n </DropdownPopover>\n </Dropdown>\n <HelperText\n UNSAFE_className={classProps.helperText}\n id={`${pickerId}-helper-text`}\n registerAria={register}\n helperText={helperText}\n />\n {validationState && (\n <ValidationText\n UNSAFE_className={classProps.validationText}\n id={`${pickerId}-validation-text`}\n {...(hasValidationIcon && { hasValidationStateIcon: validationState })}\n validationText={validationText}\n registerAria={register}\n role={validationTextRole}\n />\n )}\n <span id={tagDescriptionId} hidden>\n {tagDescriptionText}\n </span>\n </div>\n </PickerContextProvider>\n );\n};\n\nconst UNSTABLE_Picker = forwardRef<SpiritUnstablePickerRef, SpiritUnstablePickerProps>(\n _UNSTABLE_Picker,\n) as ForwardRefComponent<SpiritUnstablePickerRef, SpiritUnstablePickerProps>;\n\nUNSTABLE_Picker.spiritComponent = 'UNSTABLE_Picker';\nUNSTABLE_Picker.displayName = 'UNSTABLE_Picker';\n\nexport default UNSTABLE_Picker;\n"],"names":["_UNSTABLE_Picker","props","ref","t","useI18n","ariaDescribedBy","addButtonLabel","children","closeButtonLabel","emptySelectionLabel","helperText","id","isAggregated","isDisabled","isFluid","isLabelHidden","isOpen","isRequired","label","onSelectionChange","onToggle","removeAllLabel","renderTags","selectedKeys","selectionAriaLabel","selectionMode","MULTIPLE_SELECTION_MODE","size","DEFAULT_SIZE","tagDescriptionText","hasValidationIcon","validationState","validationText","restProps","ariaDescribedByProp","register","useAriaDescribedBy","validationTextRole","useValidationTextRole","classProps","usePickerStyleProps","styleProps","transferProps","useStyleProps","labelId","pickerId","popoverId","selectionId","tagDescriptionId","usePickerId","pickerItems","useMemo","collectPickerItems","pickerItemLabels","getPickerItemLabelMap","selectedPickerKeys","getSelectedKeys","selectedPickerItems","getSelectedItems","removeItem","key","isSingleSelectionMode","selectedKey","removeAll","selectionGridRef","useRef","triggerRef","close","useCallback","onPopoverKeyDownCapture","usePickerPopoverTabOutToTrigger","selectionGridKeyboardRowCount","getPickerSelectionGridKeyboardRowCount","getKeyboardGridRowProps","removeTagAtIndex","usePickerSelectionGridKeyboard","index","emptyLabel","replaceTranslationParams","aggregatedTagLabel","getAggregatedTagLabel","selectionContent","jsx","UNSTABLE_PickerTag","item","popoverContextValue","useImperativeHandle","PickerContextProvider","jsxs","classNames","Label","Dropdown","VisuallyHidden","Icon","DropdownPopover","PickerPopoverContextProvider","HelperText","ValidationText","UNSTABLE_Picker","forwardRef"],"mappings":"6nCA+BMA,GAAmB,CAACC,EAAkCC,IAA+C,CACzG,KAAM,CAAE,EAAAC,CAAA,EAAMC,WAAA,EAER,CACJ,mBAAoBC,EAAkB,GACtC,eAAAC,EAAiBH,EAAE,YAAY,EAC/B,SAAAI,EACA,iBAAAC,EAAmBL,EAAE,cAAc,EACnC,oBAAAM,EACA,WAAAC,EACA,GAAAC,EACA,aAAAC,EAAe,GACf,WAAAC,EAAa,GACb,QAAAC,EAAU,GACV,cAAAC,EAAgB,GAChB,OAAAC,EACA,WAAAC,EAAa,GACb,MAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,eAAAC,EAAiBlB,EAAE,kBAAkB,EACrC,WAAAmB,EACA,aAAAC,EACA,mBAAAC,EAAqBrB,EAAE,2BAA2B,EAClD,cAAAsB,EAAgBC,GAAAA,wBAChB,KAAAC,EAAOC,GAAAA,aACP,mBAAAC,EAAqB1B,EAAE,2BAA2B,EAClD,kBAAA2B,GACA,gBAAAC,EACA,eAAAC,EACA,GAAGC,EAAA,EACDhC,EAEE,CAACiC,GAAqBC,CAAQ,EAAIC,GAAAA,mBAAmB/B,CAAe,EACpEgC,GAAqBC,GAAAA,sBAAsB,CAC/C,gBAAAP,EACA,eAAAC,CAAA,CACD,EACK,CAAE,WAAAO,CAAA,EAAeC,uBAAoB,CACzC,WAAA3B,EACA,QAAAC,EACA,cAAAC,EACA,WAAAE,EACA,KAAAU,EACA,gBAAAI,CAAA,CACD,EACK,CAAA,WAAEU,EAAY,MAAOC,EAAA,EAAkBC,GAAAA,cAAcV,EAAS,EAC9D,CAAE,QAAAW,EAAS,SAAAC,EAAU,UAAAC,EAAW,YAAAC,GAAa,iBAAAC,CAAA,EAAqBC,GAAAA,YAAYtC,CAAE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AAA,CAAA,CACF,CAAA,CACF,CAEJ,EAEMqE,EAAkBC,EAAAA,WACtBnG,EACF,EAEAkG,EAAgB,gBAAkB,kBAClCA,EAAgB,YAAc"}
|
|
1
|
+
{"version":3,"file":"UNSTABLE_Picker.cjs","sources":["../../../src/components/UNSTABLE_Picker/UNSTABLE_Picker.tsx"],"sourcesContent":["'use client';\n\nimport classNames from 'classnames';\nimport React, { type ForwardedRef, forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from 'react';\nimport { MULTIPLE_SELECTION_MODE } from '../../constants';\nimport { getSelectedKeys, isSingleSelectionMode, useAriaDescribedBy, useI18n, useStyleProps } from '../../hooks';\nimport { replaceTranslationParams } from '../../translations';\nimport { type ForwardRefComponent } from '../../types';\nimport { Dropdown, DropdownPopover } from '../Dropdown';\nimport { HelperText, Label, ValidationText } from '../Field';\nimport { useValidationTextRole } from '../Field/useValidationTextRole';\nimport { Icon } from '../Icon';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { DEFAULT_POPOVER_PROPS, DEFAULT_SIZE } from './constants';\nimport { PickerContextProvider } from './PickerContext';\nimport { PickerPopoverContextProvider } from './PickerPopoverContext';\nimport type { SpiritUnstablePickerProps, SpiritUnstablePickerRef } from './types';\nimport UNSTABLE_PickerTag from './UNSTABLE_PickerTag';\nimport { usePickerId } from './usePickerId';\nimport { usePickerPopoverTabOutToTrigger } from './usePickerPopoverTabOutToTrigger';\nimport { usePickerSelectionGridKeyboard } from './usePickerSelectionGridKeyboard';\nimport { usePickerStyleProps } from './usePickerStyleProps';\nimport {\n collectPickerItems,\n getAggregatedTagLabel,\n getPickerItemLabelMap,\n getPickerSelectionGridKeyboardRowCount,\n getSelectedItems,\n} from './utils';\n\n// eslint-disable-next-line camelcase\nconst _UNSTABLE_Picker = (props: SpiritUnstablePickerProps, ref: ForwardedRef<SpiritUnstablePickerRef>) => {\n const { t } = useI18n();\n\n const {\n 'aria-describedby': ariaDescribedBy = '',\n addButtonLabel = t('picker.add'),\n children,\n closeButtonLabel = t('common.close'),\n emptySelectionLabel,\n helperText,\n id,\n isAggregated = false,\n isDisabled = false,\n isFluid = false,\n isLabelHidden = false,\n isOpen,\n isRequired = false,\n dropdownProps,\n label,\n labelProps,\n onSelectionChange,\n onToggle,\n popoverProps = DEFAULT_POPOVER_PROPS,\n removeAllLabel = t('picker.removeAll'),\n renderTags,\n selectedKeys,\n selectionAriaLabel = t('picker.selectionAriaLabel'),\n selectionMode = MULTIPLE_SELECTION_MODE,\n size = DEFAULT_SIZE,\n tagDescriptionText = t('picker.tagDescriptionText'),\n hasValidationIcon,\n validationState,\n validationText,\n ...restProps\n } = props;\n\n const [ariaDescribedByProp, register] = useAriaDescribedBy(ariaDescribedBy);\n const validationTextRole = useValidationTextRole({\n validationState,\n validationText,\n });\n const { classProps } = usePickerStyleProps({\n isDisabled,\n isFluid,\n isLabelHidden,\n isRequired,\n size,\n validationState,\n });\n const { styleProps, props: transferProps } = useStyleProps(restProps);\n const { labelId, pickerId, popoverId, selectionId, tagDescriptionId } = usePickerId(id);\n\n const pickerItems = useMemo(() => collectPickerItems(children), [children]);\n\n const pickerItemLabels = useMemo(() => getPickerItemLabelMap(pickerItems), [pickerItems]);\n\n const selectedPickerKeys = useMemo(() => getSelectedKeys(selectedKeys, selectionMode), [selectedKeys, selectionMode]);\n\n const selectedPickerItems = useMemo(\n () => getSelectedItems(selectedPickerKeys, pickerItemLabels),\n [selectedPickerKeys, pickerItemLabels],\n );\n\n const removeItem = (key: string) =>\n isSingleSelectionMode(selectionMode)\n ? onSelectionChange([])\n : onSelectionChange(selectedKeys.filter((selectedKey) => selectedKey !== key));\n\n const removeAll = () => onSelectionChange([]);\n\n const selectionGridRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n\n const close = useCallback(() => {\n if (!isOpen) {\n return;\n }\n\n onToggle();\n\n Promise.resolve().then(() => {\n triggerRef.current?.focus();\n });\n }, [isOpen, onToggle]);\n\n const { onPopoverKeyDownCapture } = usePickerPopoverTabOutToTrigger({\n isOpen,\n onClose: close,\n });\n\n const selectionGridKeyboardRowCount = getPickerSelectionGridKeyboardRowCount(selectedPickerItems.length, {\n isAggregated,\n });\n\n const { getKeyboardGridRowProps, removeTagAtIndex } = usePickerSelectionGridKeyboard({\n isDisabled,\n isPopoverOpen: isOpen,\n onRemoveAtIndex: (index) => {\n if (isAggregated) {\n removeAll();\n } else {\n removeItem(selectedPickerItems[index]!.value);\n }\n },\n selectionRef: selectionGridRef,\n tagCount: selectionGridKeyboardRowCount,\n });\n\n const emptyLabel = emptySelectionLabel ? replaceTranslationParams(emptySelectionLabel, { label }) : label;\n const aggregatedTagLabel = getAggregatedTagLabel(label, selectedPickerItems);\n\n const selectionContent = (() => {\n if (!selectedPickerItems.length) {\n return (\n <span aria-hidden=\"true\" className={classProps.selectionEmpty}>\n {emptyLabel}\n </span>\n );\n }\n\n if (renderTags) {\n return renderTags({\n getKeyboardGridRowProps,\n onRemove: removeItem,\n removeTagAtIndex,\n });\n }\n\n if (isAggregated) {\n return (\n <UNSTABLE_PickerTag\n tagKeyboardProps={getKeyboardGridRowProps(0)}\n isDisabled={isDisabled}\n label={aggregatedTagLabel}\n onRemove={() => removeTagAtIndex(0)}\n removeLabel={removeAllLabel}\n />\n );\n }\n\n return selectedPickerItems.map((item, index) => (\n <UNSTABLE_PickerTag\n key={item.value}\n tagKeyboardProps={getKeyboardGridRowProps(index)}\n isDisabled={isDisabled}\n label={item.label}\n onRemove={() => removeTagAtIndex(index)}\n />\n ));\n })();\n\n const popoverContextValue = useMemo(\n () => ({\n id: pickerId,\n isDisabled,\n onSelectionChange,\n selectedKeys: selectedPickerKeys,\n selectionMode,\n }),\n [selectedPickerKeys, isDisabled, onSelectionChange, pickerId, selectionMode],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n close,\n selectedKeys,\n }),\n [close, selectedKeys],\n );\n\n return (\n <PickerContextProvider value={{ size, tagDescriptionId }}>\n <div {...styleProps} className={classNames(classProps.root, styleProps.className)} {...transferProps}>\n <Label\n {...labelProps}\n id={labelId}\n elementType=\"span\"\n UNSAFE_className={classNames(classProps.label, labelProps?.UNSAFE_className)}\n >\n {label}\n </Label>\n <Dropdown {...dropdownProps} id={popoverId} isOpen={isOpen} onToggle={onToggle}>\n <div role=\"group\" aria-label={label} className={classProps.inputContainer}>\n <div\n ref={selectionGridRef}\n {...ariaDescribedByProp}\n id={selectionId}\n role={selectedPickerItems.length ? 'grid' : 'group'}\n aria-label={replaceTranslationParams(selectionAriaLabel, { label })}\n aria-live=\"off\"\n aria-atomic={false}\n aria-relevant=\"additions\"\n className={classProps.selection}\n >\n {selectionContent}\n </div>\n <button\n ref={triggerRef}\n type=\"button\"\n className={classProps.trigger}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={popoverId}\n onClick={onToggle}\n disabled={isDisabled}\n >\n <VisuallyHidden>{isOpen ? closeButtonLabel : addButtonLabel}</VisuallyHidden>\n <Icon name={`chevron-${isOpen ? 'up' : 'down'}`} boxSize={20} />\n </button>\n </div>\n <DropdownPopover\n {...popoverProps}\n aria-labelledby={labelId}\n role=\"dialog\"\n aria-modal=\"true\"\n onKeyDownCapture={onPopoverKeyDownCapture}\n >\n <PickerPopoverContextProvider value={popoverContextValue}>{children}</PickerPopoverContextProvider>\n </DropdownPopover>\n </Dropdown>\n <HelperText\n UNSAFE_className={classProps.helperText}\n id={`${pickerId}-helper-text`}\n registerAria={register}\n helperText={helperText}\n />\n {validationState && (\n <ValidationText\n UNSAFE_className={classProps.validationText}\n id={`${pickerId}-validation-text`}\n {...(hasValidationIcon && { hasValidationStateIcon: validationState })}\n validationText={validationText}\n registerAria={register}\n role={validationTextRole}\n />\n )}\n <span id={tagDescriptionId} hidden>\n {tagDescriptionText}\n </span>\n </div>\n </PickerContextProvider>\n );\n};\n\nconst UNSTABLE_Picker = forwardRef<SpiritUnstablePickerRef, SpiritUnstablePickerProps>(\n _UNSTABLE_Picker,\n) as ForwardRefComponent<SpiritUnstablePickerRef, SpiritUnstablePickerProps>;\n\nUNSTABLE_Picker.spiritComponent = 'UNSTABLE_Picker';\nUNSTABLE_Picker.displayName = 'UNSTABLE_Picker';\n\nexport default UNSTABLE_Picker;\n"],"names":["_UNSTABLE_Picker","props","ref","t","useI18n","ariaDescribedBy","addButtonLabel","children","closeButtonLabel","emptySelectionLabel","helperText","id","isAggregated","isDisabled","isFluid","isLabelHidden","isOpen","isRequired","dropdownProps","label","labelProps","onSelectionChange","onToggle","popoverProps","DEFAULT_POPOVER_PROPS","removeAllLabel","renderTags","selectedKeys","selectionAriaLabel","selectionMode","MULTIPLE_SELECTION_MODE","size","DEFAULT_SIZE","tagDescriptionText","hasValidationIcon","validationState","validationText","restProps","ariaDescribedByProp","register","useAriaDescribedBy","validationTextRole","useValidationTextRole","classProps","usePickerStyleProps","styleProps","transferProps","useStyleProps","labelId","pickerId","popoverId","selectionId","tagDescriptionId","usePickerId","pickerItems","useMemo","collectPickerItems","pickerItemLabels","getPickerItemLabelMap","selectedPickerKeys","getSelectedKeys","selectedPickerItems","getSelectedItems","removeItem","key","isSingleSelectionMode","selectedKey","removeAll","selectionGridRef","useRef","triggerRef","close","useCallback","onPopoverKeyDownCapture","usePickerPopoverTabOutToTrigger","selectionGridKeyboardRowCount","getPickerSelectionGridKeyboardRowCount","getKeyboardGridRowProps","removeTagAtIndex","usePickerSelectionGridKeyboard","index","emptyLabel","replaceTranslationParams","aggregatedTagLabel","getAggregatedTagLabel","selectionContent","jsx","UNSTABLE_PickerTag","item","popoverContextValue","useImperativeHandle","PickerContextProvider","jsxs","classNames","Label","Dropdown","VisuallyHidden","Icon","DropdownPopover","PickerPopoverContextProvider","HelperText","ValidationText","UNSTABLE_Picker","forwardRef"],"mappings":"2nCA+BMA,GAAmB,CAACC,EAAkCC,IAA+C,CACzG,KAAM,CAAE,EAAAC,CAAA,EAAMC,WAAA,EAER,CACJ,mBAAoBC,EAAkB,GACtC,eAAAC,EAAiBH,EAAE,YAAY,E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
|
3
|
-
import
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
import { MULTIPLE_SELECTION_MODE as
|
|
6
|
-
import { useStyleProps as
|
|
7
|
-
import { useAriaDescribedBy as
|
|
8
|
-
import { useI18n as
|
|
9
|
-
import { getSelectedKeys as
|
|
10
|
-
import { replaceTranslationParams as
|
|
2
|
+
import { jsx as e, jsxs as P } from "react/jsx-runtime";
|
|
3
|
+
import O from "classnames";
|
|
4
|
+
import { forwardRef as Pe, useMemo as p, useRef as F, useCallback as ve, useImperativeHandle as Te } from "react";
|
|
5
|
+
import { MULTIPLE_SELECTION_MODE as ye } from "../../constants/selection.js";
|
|
6
|
+
import { useStyleProps as he } from "../../hooks/styleProps.js";
|
|
7
|
+
import { useAriaDescribedBy as ke } from "../../hooks/useAriaIdRefs.js";
|
|
8
|
+
import { useI18n as Se } from "../../hooks/useI18n.js";
|
|
9
|
+
import { getSelectedKeys as Le, isSingleSelectionMode as Ae } from "../../hooks/useSelectionState.js";
|
|
10
|
+
import { replaceTranslationParams as V } from "../../translations/replaceTranslationParams.js";
|
|
11
11
|
import Ie from "../Dropdown/Dropdown.js";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { useValidationTextRole as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { DEFAULT_SIZE as
|
|
20
|
-
import { PickerContextProvider as
|
|
21
|
-
import { PickerPopoverContextProvider as
|
|
22
|
-
import
|
|
23
|
-
import { usePickerId as
|
|
24
|
-
import { usePickerPopoverTabOutToTrigger as
|
|
25
|
-
import { usePickerSelectionGridKeyboard as
|
|
26
|
-
import { usePickerStyleProps as
|
|
27
|
-
import { collectPickerItems as
|
|
28
|
-
const
|
|
29
|
-
const { t: s } =
|
|
30
|
-
"aria-describedby":
|
|
31
|
-
addButtonLabel:
|
|
32
|
-
children:
|
|
33
|
-
closeButtonLabel:
|
|
34
|
-
emptySelectionLabel:
|
|
35
|
-
helperText:
|
|
36
|
-
id:
|
|
12
|
+
import Ne from "../Dropdown/DropdownPopover.js";
|
|
13
|
+
import xe from "../Field/HelperText.js";
|
|
14
|
+
import Ee from "../Field/Label.js";
|
|
15
|
+
import Re from "../Field/ValidationText.js";
|
|
16
|
+
import { useValidationTextRole as Ce } from "../Field/useValidationTextRole.js";
|
|
17
|
+
import _e from "../Icon/Icon.js";
|
|
18
|
+
import De from "../VisuallyHidden/VisuallyHidden.js";
|
|
19
|
+
import { DEFAULT_POPOVER_PROPS as Ke, DEFAULT_SIZE as Ue } from "./constants.js";
|
|
20
|
+
import { PickerContextProvider as we } from "./PickerContext.js";
|
|
21
|
+
import { PickerPopoverContextProvider as Be } from "./PickerPopoverContext.js";
|
|
22
|
+
import M from "./UNSTABLE_PickerTag.js";
|
|
23
|
+
import { usePickerId as Oe } from "./usePickerId.js";
|
|
24
|
+
import { usePickerPopoverTabOutToTrigger as Fe } from "./usePickerPopoverTabOutToTrigger.js";
|
|
25
|
+
import { usePickerSelectionGridKeyboard as Ve } from "./usePickerSelectionGridKeyboard.js";
|
|
26
|
+
import { usePickerStyleProps as Me } from "./usePickerStyleProps.js";
|
|
27
|
+
import { collectPickerItems as Ge, getPickerItemLabelMap as He, getSelectedItems as $e, getPickerSelectionGridKeyboardRowCount as je, getAggregatedTagLabel as ze } from "./utils.js";
|
|
28
|
+
const qe = (H, $) => {
|
|
29
|
+
const { t: s } = Se(), {
|
|
30
|
+
"aria-describedby": j = "",
|
|
31
|
+
addButtonLabel: z = s("picker.add"),
|
|
32
|
+
children: v,
|
|
33
|
+
closeButtonLabel: q = s("common.close"),
|
|
34
|
+
emptySelectionLabel: S,
|
|
35
|
+
helperText: Z,
|
|
36
|
+
id: J,
|
|
37
37
|
isAggregated: T = !1,
|
|
38
38
|
isDisabled: t = !1,
|
|
39
|
-
isFluid:
|
|
40
|
-
isLabelHidden:
|
|
41
|
-
isOpen:
|
|
42
|
-
isRequired:
|
|
39
|
+
isFluid: Q = !1,
|
|
40
|
+
isLabelHidden: W = !1,
|
|
41
|
+
isOpen: o,
|
|
42
|
+
isRequired: X = !1,
|
|
43
|
+
dropdownProps: Y,
|
|
43
44
|
label: i,
|
|
45
|
+
labelProps: L,
|
|
44
46
|
onSelectionChange: n,
|
|
45
|
-
onToggle:
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
onToggle: m,
|
|
48
|
+
popoverProps: ee = Ke,
|
|
49
|
+
removeAllLabel: oe = s("picker.removeAll"),
|
|
50
|
+
renderTags: A,
|
|
48
51
|
selectedKeys: c,
|
|
49
|
-
selectionAriaLabel:
|
|
50
|
-
selectionMode: d =
|
|
51
|
-
size:
|
|
52
|
-
tagDescriptionText:
|
|
53
|
-
hasValidationIcon:
|
|
52
|
+
selectionAriaLabel: re = s("picker.selectionAriaLabel"),
|
|
53
|
+
selectionMode: d = ye,
|
|
54
|
+
size: I = Ue,
|
|
55
|
+
tagDescriptionText: te = s("picker.tagDescriptionText"),
|
|
56
|
+
hasValidationIcon: ie,
|
|
54
57
|
validationState: f,
|
|
55
|
-
validationText:
|
|
56
|
-
...
|
|
57
|
-
} =
|
|
58
|
+
validationText: N,
|
|
59
|
+
...ae
|
|
60
|
+
} = H, [le, x] = ke(j), se = Ce({
|
|
58
61
|
validationState: f,
|
|
59
|
-
validationText:
|
|
60
|
-
}), { classProps:
|
|
62
|
+
validationText: N
|
|
63
|
+
}), { classProps: r } = Me({
|
|
61
64
|
isDisabled: t,
|
|
62
|
-
isFluid:
|
|
63
|
-
isLabelHidden:
|
|
64
|
-
isRequired:
|
|
65
|
-
size:
|
|
65
|
+
isFluid: Q,
|
|
66
|
+
isLabelHidden: W,
|
|
67
|
+
isRequired: X,
|
|
68
|
+
size: I,
|
|
66
69
|
validationState: f
|
|
67
|
-
}), { styleProps:
|
|
68
|
-
() =>
|
|
70
|
+
}), { styleProps: E, props: ne } = he(ae), { labelId: R, pickerId: u, popoverId: C, selectionId: ce, tagDescriptionId: _ } = Oe(J), D = p(() => Ge(v), [v]), K = p(() => He(D), [D]), g = p(() => Le(c, d), [c, d]), a = p(
|
|
71
|
+
() => $e(g, K),
|
|
69
72
|
[g, K]
|
|
70
|
-
),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
), U = (l) => Ae(d) ? n([]) : n(c.filter((b) => b !== l)), de = () => n([]), w = F(null), B = F(null), y = ve(() => {
|
|
74
|
+
o && (m(), Promise.resolve().then(() => {
|
|
75
|
+
B.current?.focus();
|
|
73
76
|
}));
|
|
74
|
-
}, [
|
|
75
|
-
isOpen:
|
|
77
|
+
}, [o, m]), { onPopoverKeyDownCapture: pe } = Fe({
|
|
78
|
+
isOpen: o,
|
|
76
79
|
onClose: y
|
|
77
|
-
}),
|
|
80
|
+
}), me = je(a.length, {
|
|
78
81
|
isAggregated: T
|
|
79
|
-
}), { getKeyboardGridRowProps: h, removeTagAtIndex: k } =
|
|
82
|
+
}), { getKeyboardGridRowProps: h, removeTagAtIndex: k } = Ve({
|
|
80
83
|
isDisabled: t,
|
|
81
|
-
isPopoverOpen:
|
|
84
|
+
isPopoverOpen: o,
|
|
82
85
|
onRemoveAtIndex: (l) => {
|
|
83
|
-
T ?
|
|
86
|
+
T ? de() : U(a[l].value);
|
|
84
87
|
},
|
|
85
|
-
selectionRef:
|
|
86
|
-
tagCount:
|
|
87
|
-
}),
|
|
88
|
+
selectionRef: w,
|
|
89
|
+
tagCount: me
|
|
90
|
+
}), fe = S ? V(S, { label: i }) : i, ue = ze(i, a), ge = a.length ? A ? A({
|
|
88
91
|
getKeyboardGridRowProps: h,
|
|
89
|
-
onRemove:
|
|
92
|
+
onRemove: U,
|
|
90
93
|
removeTagAtIndex: k
|
|
91
94
|
}) : T ? /* @__PURE__ */ e(
|
|
92
|
-
|
|
95
|
+
M,
|
|
93
96
|
{
|
|
94
97
|
tagKeyboardProps: h(0),
|
|
95
98
|
isDisabled: t,
|
|
96
|
-
label:
|
|
99
|
+
label: ue,
|
|
97
100
|
onRemove: () => k(0),
|
|
98
|
-
removeLabel:
|
|
101
|
+
removeLabel: oe
|
|
99
102
|
}
|
|
100
103
|
) : a.map((l, b) => /* @__PURE__ */ e(
|
|
101
|
-
|
|
104
|
+
M,
|
|
102
105
|
{
|
|
103
106
|
tagKeyboardProps: h(b),
|
|
104
107
|
isDisabled: t,
|
|
@@ -106,7 +109,7 @@ const He = (G, O) => {
|
|
|
106
109
|
onRemove: () => k(b)
|
|
107
110
|
},
|
|
108
111
|
l.value
|
|
109
|
-
)) : /* @__PURE__ */ e("span", { "aria-hidden": "true", className:
|
|
112
|
+
)) : /* @__PURE__ */ e("span", { "aria-hidden": "true", className: r.selectionEmpty, children: fe }), be = p(
|
|
110
113
|
() => ({
|
|
111
114
|
id: u,
|
|
112
115
|
isDisabled: t,
|
|
@@ -116,89 +119,99 @@ const He = (G, O) => {
|
|
|
116
119
|
}),
|
|
117
120
|
[g, t, n, u, d]
|
|
118
121
|
);
|
|
119
|
-
return
|
|
120
|
-
|
|
122
|
+
return Te(
|
|
123
|
+
$,
|
|
121
124
|
() => ({
|
|
122
125
|
close: y,
|
|
123
126
|
selectedKeys: c
|
|
124
127
|
}),
|
|
125
128
|
[y, c]
|
|
126
|
-
), /* @__PURE__ */ e(
|
|
127
|
-
/* @__PURE__ */ e(
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
), /* @__PURE__ */ e(we, { value: { size: I, tagDescriptionId: _ }, children: /* @__PURE__ */ P("div", { ...E, className: O(r.root, E.className), ...ne, children: [
|
|
130
|
+
/* @__PURE__ */ e(
|
|
131
|
+
Ee,
|
|
132
|
+
{
|
|
133
|
+
...L,
|
|
134
|
+
id: R,
|
|
135
|
+
elementType: "span",
|
|
136
|
+
UNSAFE_className: O(r.label, L?.UNSAFE_className),
|
|
137
|
+
children: i
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ P(Ie, { ...Y, id: C, isOpen: o, onToggle: m, children: [
|
|
141
|
+
/* @__PURE__ */ P("div", { role: "group", "aria-label": i, className: r.inputContainer, children: [
|
|
130
142
|
/* @__PURE__ */ e(
|
|
131
143
|
"div",
|
|
132
144
|
{
|
|
133
|
-
ref:
|
|
134
|
-
...
|
|
135
|
-
id:
|
|
145
|
+
ref: w,
|
|
146
|
+
...le,
|
|
147
|
+
id: ce,
|
|
136
148
|
role: a.length ? "grid" : "group",
|
|
137
|
-
"aria-label":
|
|
149
|
+
"aria-label": V(re, { label: i }),
|
|
138
150
|
"aria-live": "off",
|
|
139
151
|
"aria-atomic": !1,
|
|
140
152
|
"aria-relevant": "additions",
|
|
141
|
-
className:
|
|
142
|
-
children:
|
|
153
|
+
className: r.selection,
|
|
154
|
+
children: ge
|
|
143
155
|
}
|
|
144
156
|
),
|
|
145
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ P(
|
|
146
158
|
"button",
|
|
147
159
|
{
|
|
148
|
-
ref:
|
|
160
|
+
ref: B,
|
|
149
161
|
type: "button",
|
|
150
|
-
className:
|
|
162
|
+
className: r.trigger,
|
|
151
163
|
"aria-haspopup": "dialog",
|
|
152
|
-
"aria-expanded":
|
|
153
|
-
"aria-controls":
|
|
154
|
-
onClick:
|
|
164
|
+
"aria-expanded": o,
|
|
165
|
+
"aria-controls": C,
|
|
166
|
+
onClick: m,
|
|
155
167
|
disabled: t,
|
|
156
168
|
children: [
|
|
157
|
-
/* @__PURE__ */ e(
|
|
158
|
-
/* @__PURE__ */ e(
|
|
169
|
+
/* @__PURE__ */ e(De, { children: o ? q : z }),
|
|
170
|
+
/* @__PURE__ */ e(_e, { name: `chevron-${o ? "up" : "down"}`, boxSize: 20 })
|
|
159
171
|
]
|
|
160
172
|
}
|
|
161
173
|
)
|
|
162
174
|
] }),
|
|
163
175
|
/* @__PURE__ */ e(
|
|
164
|
-
|
|
176
|
+
Ne,
|
|
165
177
|
{
|
|
166
|
-
|
|
178
|
+
...ee,
|
|
179
|
+
"aria-labelledby": R,
|
|
167
180
|
role: "dialog",
|
|
168
181
|
"aria-modal": "true",
|
|
169
|
-
onKeyDownCapture:
|
|
170
|
-
children: /* @__PURE__ */ e(
|
|
182
|
+
onKeyDownCapture: pe,
|
|
183
|
+
children: /* @__PURE__ */ e(Be, { value: be, children: v })
|
|
171
184
|
}
|
|
172
185
|
)
|
|
173
186
|
] }),
|
|
174
187
|
/* @__PURE__ */ e(
|
|
175
|
-
|
|
188
|
+
xe,
|
|
176
189
|
{
|
|
177
|
-
UNSAFE_className:
|
|
190
|
+
UNSAFE_className: r.helperText,
|
|
178
191
|
id: `${u}-helper-text`,
|
|
179
|
-
registerAria:
|
|
180
|
-
helperText:
|
|
192
|
+
registerAria: x,
|
|
193
|
+
helperText: Z
|
|
181
194
|
}
|
|
182
195
|
),
|
|
183
196
|
f && /* @__PURE__ */ e(
|
|
184
|
-
|
|
197
|
+
Re,
|
|
185
198
|
{
|
|
186
|
-
UNSAFE_className:
|
|
199
|
+
UNSAFE_className: r.validationText,
|
|
187
200
|
id: `${u}-validation-text`,
|
|
188
|
-
...
|
|
189
|
-
validationText:
|
|
190
|
-
registerAria:
|
|
191
|
-
role:
|
|
201
|
+
...ie && { hasValidationStateIcon: f },
|
|
202
|
+
validationText: N,
|
|
203
|
+
registerAria: x,
|
|
204
|
+
role: se
|
|
192
205
|
}
|
|
193
206
|
),
|
|
194
|
-
/* @__PURE__ */ e("span", { id:
|
|
207
|
+
/* @__PURE__ */ e("span", { id: _, hidden: !0, children: te })
|
|
195
208
|
] }) });
|
|
196
|
-
},
|
|
197
|
-
|
|
209
|
+
}, G = Pe(
|
|
210
|
+
qe
|
|
198
211
|
);
|
|
199
|
-
|
|
200
|
-
|
|
212
|
+
G.spiritComponent = "UNSTABLE_Picker";
|
|
213
|
+
G.displayName = "UNSTABLE_Picker";
|
|
201
214
|
export {
|
|
202
|
-
|
|
215
|
+
G as default
|
|
203
216
|
};
|
|
204
217
|
//# sourceMappingURL=UNSTABLE_Picker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UNSTABLE_Picker.js","sources":["../../../src/components/UNSTABLE_Picker/UNSTABLE_Picker.tsx"],"sourcesContent":["'use client';\n\nimport classNames from 'classnames';\nimport React, { type ForwardedRef, forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from 'react';\nimport { MULTIPLE_SELECTION_MODE } from '../../constants';\nimport { getSelectedKeys, isSingleSelectionMode, useAriaDescribedBy, useI18n, useStyleProps } from '../../hooks';\nimport { replaceTranslationParams } from '../../translations';\nimport { type ForwardRefComponent } from '../../types';\nimport { Dropdown, DropdownPopover } from '../Dropdown';\nimport { HelperText, Label, ValidationText } from '../Field';\nimport { useValidationTextRole } from '../Field/useValidationTextRole';\nimport { Icon } from '../Icon';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { DEFAULT_SIZE } from './constants';\nimport { PickerContextProvider } from './PickerContext';\nimport { PickerPopoverContextProvider } from './PickerPopoverContext';\nimport type { SpiritUnstablePickerProps, SpiritUnstablePickerRef } from './types';\nimport UNSTABLE_PickerTag from './UNSTABLE_PickerTag';\nimport { usePickerId } from './usePickerId';\nimport { usePickerPopoverTabOutToTrigger } from './usePickerPopoverTabOutToTrigger';\nimport { usePickerSelectionGridKeyboard } from './usePickerSelectionGridKeyboard';\nimport { usePickerStyleProps } from './usePickerStyleProps';\nimport {\n collectPickerItems,\n getAggregatedTagLabel,\n getPickerItemLabelMap,\n getPickerSelectionGridKeyboardRowCount,\n getSelectedItems,\n} from './utils';\n\n// eslint-disable-next-line camelcase\nconst _UNSTABLE_Picker = (props: SpiritUnstablePickerProps, ref: ForwardedRef<SpiritUnstablePickerRef>) => {\n const { t } = useI18n();\n\n const {\n 'aria-describedby': ariaDescribedBy = '',\n addButtonLabel = t('picker.add'),\n children,\n closeButtonLabel = t('common.close'),\n emptySelectionLabel,\n helperText,\n id,\n isAggregated = false,\n isDisabled = false,\n isFluid = false,\n isLabelHidden = false,\n isOpen,\n isRequired = false,\n label,\n onSelectionChange,\n onToggle,\n removeAllLabel = t('picker.removeAll'),\n renderTags,\n selectedKeys,\n selectionAriaLabel = t('picker.selectionAriaLabel'),\n selectionMode = MULTIPLE_SELECTION_MODE,\n size = DEFAULT_SIZE,\n tagDescriptionText = t('picker.tagDescriptionText'),\n hasValidationIcon,\n validationState,\n validationText,\n ...restProps\n } = props;\n\n const [ariaDescribedByProp, register] = useAriaDescribedBy(ariaDescribedBy);\n const validationTextRole = useValidationTextRole({\n validationState,\n validationText,\n });\n const { classProps } = usePickerStyleProps({\n isDisabled,\n isFluid,\n isLabelHidden,\n isRequired,\n size,\n validationState,\n });\n const { styleProps, props: transferProps } = useStyleProps(restProps);\n const { labelId, pickerId, popoverId, selectionId, tagDescriptionId } = usePickerId(id);\n\n const pickerItems = useMemo(() => collectPickerItems(children), [children]);\n\n const pickerItemLabels = useMemo(() => getPickerItemLabelMap(pickerItems), [pickerItems]);\n\n const selectedPickerKeys = useMemo(() => getSelectedKeys(selectedKeys, selectionMode), [selectedKeys, selectionMode]);\n\n const selectedPickerItems = useMemo(\n () => getSelectedItems(selectedPickerKeys, pickerItemLabels),\n [selectedPickerKeys, pickerItemLabels],\n );\n\n const removeItem = (key: string) =>\n isSingleSelectionMode(selectionMode)\n ? onSelectionChange([])\n : onSelectionChange(selectedKeys.filter((selectedKey) => selectedKey !== key));\n\n const removeAll = () => onSelectionChange([]);\n\n const selectionGridRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n\n const close = useCallback(() => {\n if (!isOpen) {\n return;\n }\n\n onToggle();\n\n Promise.resolve().then(() => {\n triggerRef.current?.focus();\n });\n }, [isOpen, onToggle]);\n\n const { onPopoverKeyDownCapture } = usePickerPopoverTabOutToTrigger({\n isOpen,\n onClose: close,\n });\n\n const selectionGridKeyboardRowCount = getPickerSelectionGridKeyboardRowCount(selectedPickerItems.length, {\n isAggregated,\n });\n\n const { getKeyboardGridRowProps, removeTagAtIndex } = usePickerSelectionGridKeyboard({\n isDisabled,\n isPopoverOpen: isOpen,\n onRemoveAtIndex: (index) => {\n if (isAggregated) {\n removeAll();\n } else {\n removeItem(selectedPickerItems[index]!.value);\n }\n },\n selectionRef: selectionGridRef,\n tagCount: selectionGridKeyboardRowCount,\n });\n\n const emptyLabel = emptySelectionLabel ? replaceTranslationParams(emptySelectionLabel, { label }) : label;\n const aggregatedTagLabel = getAggregatedTagLabel(label, selectedPickerItems);\n\n const selectionContent = (() => {\n if (!selectedPickerItems.length) {\n return (\n <span aria-hidden=\"true\" className={classProps.selectionEmpty}>\n {emptyLabel}\n </span>\n );\n }\n\n if (renderTags) {\n return renderTags({\n getKeyboardGridRowProps,\n onRemove: removeItem,\n removeTagAtIndex,\n });\n }\n\n if (isAggregated) {\n return (\n <UNSTABLE_PickerTag\n tagKeyboardProps={getKeyboardGridRowProps(0)}\n isDisabled={isDisabled}\n label={aggregatedTagLabel}\n onRemove={() => removeTagAtIndex(0)}\n removeLabel={removeAllLabel}\n />\n );\n }\n\n return selectedPickerItems.map((item, index) => (\n <UNSTABLE_PickerTag\n key={item.value}\n tagKeyboardProps={getKeyboardGridRowProps(index)}\n isDisabled={isDisabled}\n label={item.label}\n onRemove={() => removeTagAtIndex(index)}\n />\n ));\n })();\n\n const popoverContextValue = useMemo(\n () => ({\n id: pickerId,\n isDisabled,\n onSelectionChange,\n selectedKeys: selectedPickerKeys,\n selectionMode,\n }),\n [selectedPickerKeys, isDisabled, onSelectionChange, pickerId, selectionMode],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n close,\n selectedKeys,\n }),\n [close, selectedKeys],\n );\n\n return (\n <PickerContextProvider value={{ size, tagDescriptionId }}>\n <div {...styleProps} className={classNames(classProps.root, styleProps.className)} {...transferProps}>\n <Label id={labelId} UNSAFE_className={classProps.label} elementType=\"span\">\n {label}\n </Label>\n <Dropdown id={popoverId} isOpen={isOpen} onToggle={onToggle}>\n <div role=\"group\" aria-label={label} className={classProps.inputContainer}>\n <div\n ref={selectionGridRef}\n {...ariaDescribedByProp}\n id={selectionId}\n role={selectedPickerItems.length ? 'grid' : 'group'}\n aria-label={replaceTranslationParams(selectionAriaLabel, { label })}\n aria-live=\"off\"\n aria-atomic={false}\n aria-relevant=\"additions\"\n className={classProps.selection}\n >\n {selectionContent}\n </div>\n <button\n ref={triggerRef}\n type=\"button\"\n className={classProps.trigger}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={popoverId}\n onClick={onToggle}\n disabled={isDisabled}\n >\n <VisuallyHidden>{isOpen ? closeButtonLabel : addButtonLabel}</VisuallyHidden>\n <Icon name={`chevron-${isOpen ? 'up' : 'down'}`} boxSize={20} />\n </button>\n </div>\n <DropdownPopover\n aria-labelledby={labelId}\n role=\"dialog\"\n aria-modal=\"true\"\n onKeyDownCapture={onPopoverKeyDownCapture}\n >\n <PickerPopoverContextProvider value={popoverContextValue}>{children}</PickerPopoverContextProvider>\n </DropdownPopover>\n </Dropdown>\n <HelperText\n UNSAFE_className={classProps.helperText}\n id={`${pickerId}-helper-text`}\n registerAria={register}\n helperText={helperText}\n />\n {validationState && (\n <ValidationText\n UNSAFE_className={classProps.validationText}\n id={`${pickerId}-validation-text`}\n {...(hasValidationIcon && { hasValidationStateIcon: validationState })}\n validationText={validationText}\n registerAria={register}\n role={validationTextRole}\n />\n )}\n <span id={tagDescriptionId} hidden>\n {tagDescriptionText}\n </span>\n </div>\n </PickerContextProvider>\n );\n};\n\nconst UNSTABLE_Picker = forwardRef<SpiritUnstablePickerRef, SpiritUnstablePickerProps>(\n _UNSTABLE_Picker,\n) as ForwardRefComponent<SpiritUnstablePickerRef, SpiritUnstablePickerProps>;\n\nUNSTABLE_Picker.spiritComponent = 'UNSTABLE_Picker';\nUNSTABLE_Picker.displayName = 'UNSTABLE_Picker';\n\nexport default UNSTABLE_Picker;\n"],"names":["_UNSTABLE_Picker","props","ref","t","useI18n","ariaDescribedBy","addButtonLabel","children","closeButtonLabel","emptySelectionLabel","helperText","id","isAggregated","isDisabled","isFluid","isLabelHidden","isOpen","isRequired","label","onSelectionChange","onToggle","removeAllLabel","renderTags","selectedKeys","selectionAriaLabel","selectionMode","MULTIPLE_SELECTION_MODE","size","DEFAULT_SIZE","tagDescriptionText","hasValidationIcon","validationState","validationText","restProps","ariaDescribedByProp","register","useAriaDescribedBy","validationTextRole","useValidationTextRole","classProps","usePickerStyleProps","styleProps","transferProps","useStyleProps","labelId","pickerId","popoverId","selectionId","tagDescriptionId","usePickerId","pickerItems","useMemo","collectPickerItems","pickerItemLabels","getPickerItemLabelMap","selectedPickerKeys","getSelectedKeys","selectedPickerItems","getSelectedItems","removeItem","key","isSingleSelectionMode","selectedKey","removeAll","selectionGridRef","useRef","triggerRef","close","useCallback","onPopoverKeyDownCapture","usePickerPopoverTabOutToTrigger","selectionGridKeyboardRowCount","getPickerSelectionGridKeyboardRowCount","getKeyboardGridRowProps","removeTagAtIndex","usePickerSelectionGridKeyboard","index","emptyLabel","replaceTranslationParams","aggregatedTagLabel","getAggregatedTagLabel","selectionContent","jsx","UNSTABLE_PickerTag","item","popoverContextValue","useImperativeHandle","PickerContextProvider","jsxs","classNames","Label","Dropdown","VisuallyHidden","Icon","DropdownPopover","PickerPopoverContextProvider","HelperText","ValidationText","UNSTABLE_Picker","forwardRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,KAAmB,CAACC,GAAkCC,MAA+C;AACzG,QAAM,EAAE,GAAAC,EAAA,IAAMC,GAAA,GAER;AAAA,IACJ,oBAAoBC,IAAkB;AAAA,IACtC,gBAAAC,IAAiBH,EAAE,YAAY;AAAA,IAC/B,UAAAI;AAAA,IACA,kBAAAC,IAAmBL,EAAE,cAAc;AAAA,IACnC,qBAAAM;AAAA,IACA,YAAAC;AAAA,IACA,IAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,YAAAC,IAAa;AAAA,IACb,SAAAC,IAAU;AAAA,IACV,eAAAC,IAAgB;AAAA,IAChB,QAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,OAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,U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;AAAA,QACA,cAAcG;AAAA,QACd,MAAME;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGT,QAAA,EAAK,IAAIW,GAAkB,QAAM,IAC/B,UAAAnB,EAAA,CACH;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ,GAEMqE,IAAkBC;AAAA,EACtBnG;AACF;AAEAkG,EAAgB,kBAAkB;AAClCA,EAAgB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"UNSTABLE_Picker.js","sources":["../../../src/components/UNSTABLE_Picker/UNSTABLE_Picker.tsx"],"sourcesContent":["'use client';\n\nimport classNames from 'classnames';\nimport React, { type ForwardedRef, forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from 'react';\nimport { MULTIPLE_SELECTION_MODE } from '../../constants';\nimport { getSelectedKeys, isSingleSelectionMode, useAriaDescribedBy, useI18n, useStyleProps } from '../../hooks';\nimport { replaceTranslationParams } from '../../translations';\nimport { type ForwardRefComponent } from '../../types';\nimport { Dropdown, DropdownPopover } from '../Dropdown';\nimport { HelperText, Label, ValidationText } from '../Field';\nimport { useValidationTextRole } from '../Field/useValidationTextRole';\nimport { Icon } from '../Icon';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { DEFAULT_POPOVER_PROPS, DEFAULT_SIZE } from './constants';\nimport { PickerContextProvider } from './PickerContext';\nimport { PickerPopoverContextProvider } from './PickerPopoverContext';\nimport type { SpiritUnstablePickerProps, SpiritUnstablePickerRef } from './types';\nimport UNSTABLE_PickerTag from './UNSTABLE_PickerTag';\nimport { usePickerId } from './usePickerId';\nimport { usePickerPopoverTabOutToTrigger } from './usePickerPopoverTabOutToTrigger';\nimport { usePickerSelectionGridKeyboard } from './usePickerSelectionGridKeyboard';\nimport { usePickerStyleProps } from './usePickerStyleProps';\nimport {\n collectPickerItems,\n getAggregatedTagLabel,\n getPickerItemLabelMap,\n getPickerSelectionGridKeyboardRowCount,\n getSelectedItems,\n} from './utils';\n\n// eslint-disable-next-line camelcase\nconst _UNSTABLE_Picker = (props: SpiritUnstablePickerProps, ref: ForwardedRef<SpiritUnstablePickerRef>) => {\n const { t } = useI18n();\n\n const {\n 'aria-describedby': ariaDescribedBy = '',\n addButtonLabel = t('picker.add'),\n children,\n closeButtonLabel = t('common.close'),\n emptySelectionLabel,\n helperText,\n id,\n isAggregated = false,\n isDisabled = false,\n isFluid = false,\n isLabelHidden = false,\n isOpen,\n isRequired = false,\n dropdownProps,\n label,\n labelProps,\n onSelectionChange,\n onToggle,\n popoverProps = DEFAULT_POPOVER_PROPS,\n removeAllLabel = t('picker.removeAll'),\n renderTags,\n selectedKeys,\n selectionAriaLabel = t('picker.selectionAriaLabel'),\n selectionMode = MULTIPLE_SELECTION_MODE,\n size = DEFAULT_SIZE,\n tagDescriptionText = t('picker.tagDescriptionText'),\n hasValidationIcon,\n validationState,\n validationText,\n ...restProps\n } = props;\n\n const [ariaDescribedByProp, register] = useAriaDescribedBy(ariaDescribedBy);\n const validationTextRole = useValidationTextRole({\n validationState,\n validationText,\n });\n const { classProps } = usePickerStyleProps({\n isDisabled,\n isFluid,\n isLabelHidden,\n isRequired,\n size,\n validationState,\n });\n const { styleProps, props: transferProps } = useStyleProps(restProps);\n const { labelId, pickerId, popoverId, selectionId, tagDescriptionId } = usePickerId(id);\n\n const pickerItems = useMemo(() => collectPickerItems(children), [children]);\n\n const pickerItemLabels = useMemo(() => getPickerItemLabelMap(pickerItems), [pickerItems]);\n\n const selectedPickerKeys = useMemo(() => getSelectedKeys(selectedKeys, selectionMode), [selectedKeys, selectionMode]);\n\n const selectedPickerItems = useMemo(\n () => getSelectedItems(selectedPickerKeys, pickerItemLabels),\n [selectedPickerKeys, pickerItemLabels],\n );\n\n const removeItem = (key: string) =>\n isSingleSelectionMode(selectionMode)\n ? onSelectionChange([])\n : onSelectionChange(selectedKeys.filter((selectedKey) => selectedKey !== key));\n\n const removeAll = () => onSelectionChange([]);\n\n const selectionGridRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n\n const close = useCallback(() => {\n if (!isOpen) {\n return;\n }\n\n onToggle();\n\n Promise.resolve().then(() => {\n triggerRef.current?.focus();\n });\n }, [isOpen, onToggle]);\n\n const { onPopoverKeyDownCapture } = usePickerPopoverTabOutToTrigger({\n isOpen,\n onClose: close,\n });\n\n const selectionGridKeyboardRowCount = getPickerSelectionGridKeyboardRowCount(selectedPickerItems.length, {\n isAggregated,\n });\n\n const { getKeyboardGridRowProps, removeTagAtIndex } = usePickerSelectionGridKeyboard({\n isDisabled,\n isPopoverOpen: isOpen,\n onRemoveAtIndex: (index) => {\n if (isAggregated) {\n removeAll();\n } else {\n removeItem(selectedPickerItems[index]!.value);\n }\n },\n selectionRef: selectionGridRef,\n tagCount: selectionGridKeyboardRowCount,\n });\n\n const emptyLabel = emptySelectionLabel ? replaceTranslationParams(emptySelectionLabel, { label }) : label;\n const aggregatedTagLabel = getAggregatedTagLabel(label, selectedPickerItems);\n\n const selectionContent = (() => {\n if (!selectedPickerItems.length) {\n return (\n <span aria-hidden=\"true\" className={classProps.selectionEmpty}>\n {emptyLabel}\n </span>\n );\n }\n\n if (renderTags) {\n return renderTags({\n getKeyboardGridRowProps,\n onRemove: removeItem,\n removeTagAtIndex,\n });\n }\n\n if (isAggregated) {\n return (\n <UNSTABLE_PickerTag\n tagKeyboardProps={getKeyboardGridRowProps(0)}\n isDisabled={isDisabled}\n label={aggregatedTagLabel}\n onRemove={() => removeTagAtIndex(0)}\n removeLabel={removeAllLabel}\n />\n );\n }\n\n return selectedPickerItems.map((item, index) => (\n <UNSTABLE_PickerTag\n key={item.value}\n tagKeyboardProps={getKeyboardGridRowProps(index)}\n isDisabled={isDisabled}\n label={item.label}\n onRemove={() => removeTagAtIndex(index)}\n />\n ));\n })();\n\n const popoverContextValue = useMemo(\n () => ({\n id: pickerId,\n isDisabled,\n onSelectionChange,\n selectedKeys: selectedPickerKeys,\n selectionMode,\n }),\n [selectedPickerKeys, isDisabled, onSelectionChange, pickerId, selectionMode],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n close,\n selectedKeys,\n }),\n [close, selectedKeys],\n );\n\n return (\n <PickerContextProvider value={{ size, tagDescriptionId }}>\n <div {...styleProps} className={classNames(classProps.root, styleProps.className)} {...transferProps}>\n <Label\n {...labelProps}\n id={labelId}\n elementType=\"span\"\n UNSAFE_className={classNames(classProps.label, labelProps?.UNSAFE_className)}\n >\n {label}\n </Label>\n <Dropdown {...dropdownProps} id={popoverId} isOpen={isOpen} onToggle={onToggle}>\n <div role=\"group\" aria-label={label} className={classProps.inputContainer}>\n <div\n ref={selectionGridRef}\n {...ariaDescribedByProp}\n id={selectionId}\n role={selectedPickerItems.length ? 'grid' : 'group'}\n aria-label={replaceTranslationParams(selectionAriaLabel, { label })}\n aria-live=\"off\"\n aria-atomic={false}\n aria-relevant=\"additions\"\n className={classProps.selection}\n >\n {selectionContent}\n </div>\n <button\n ref={triggerRef}\n type=\"button\"\n className={classProps.trigger}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={popoverId}\n onClick={onToggle}\n disabled={isDisabled}\n >\n <VisuallyHidden>{isOpen ? closeButtonLabel : addButtonLabel}</VisuallyHidden>\n <Icon name={`chevron-${isOpen ? 'up' : 'down'}`} boxSize={20} />\n </button>\n </div>\n <DropdownPopover\n {...popoverProps}\n aria-labelledby={labelId}\n role=\"dialog\"\n aria-modal=\"true\"\n onKeyDownCapture={onPopoverKeyDownCapture}\n >\n <PickerPopoverContextProvider value={popoverContextValue}>{children}</PickerPopoverContextProvider>\n </DropdownPopover>\n </Dropdown>\n <HelperText\n UNSAFE_className={classProps.helperText}\n id={`${pickerId}-helper-text`}\n registerAria={register}\n helperText={helperText}\n />\n {validationState && (\n <ValidationText\n UNSAFE_className={classProps.validationText}\n id={`${pickerId}-validation-text`}\n {...(hasValidationIcon && { hasValidationStateIcon: validationState })}\n validationText={validationText}\n registerAria={register}\n role={validationTextRole}\n />\n )}\n <span id={tagDescriptionId} hidden>\n {tagDescriptionText}\n </span>\n </div>\n </PickerContextProvider>\n );\n};\n\nconst UNSTABLE_Picker = forwardRef<SpiritUnstablePickerRef, SpiritUnstablePickerProps>(\n _UNSTABLE_Picker,\n) as ForwardRefComponent<SpiritUnstablePickerRef, SpiritUnstablePickerProps>;\n\nUNSTABLE_Picker.spiritComponent = 'UNSTABLE_Picker';\nUNSTABLE_Picker.displayName = 'UNSTABLE_Picker';\n\nexport default UNSTABLE_Picker;\n"],"names":["_UNSTABLE_Picker","props","ref","t","useI18n","ariaDescribedBy","addButtonLabel","children","closeButtonLabel","emptySelectionLabel","helperText","id","isAggregated","isDisabled","isFluid","isLabelHidden","isOpen","isRequired","dropdownProps","label","labelProps","onSelectionChange","onToggle","popoverProps","DEFAULT_POPOVER_PROPS","removeAllLabel","renderTags","selectedKeys","selectionAriaLabel","selectionMode","MULTIPLE_SELECTION_MODE","size","DEFAULT_SIZE","tagDescriptionText","hasValidationIcon","validationState","validationText","restProps","ariaDescribedByProp","register","useAriaDescribedBy","validationTextRole","useValidationTextRole","classProps","usePickerStyleProps","styleProps","transferProps","useStyleProps","labelId","pickerId","popoverId","selectionId","tagDescriptionId","usePickerId","pickerItems","useMemo","collectPickerItems","pickerItemLabels","getPickerItemLabelMap","selectedPickerKeys","getSelectedKeys","selectedPickerItems","getSelectedItems","removeItem","key","isSingleSelectionMode","selectedKey","removeAll","selectionGridRef","useRef","triggerRef","close","useCallback","onPopoverKeyDownCapture","usePickerPopoverTabOutToTrigger","selectionGridKeyboardRowCount","getPickerSelectionGridKeyboardRowCount","getKeyboardGridRowProps","removeTagAtIndex","usePickerSelectionGridKeyboard","index","emptyLabel","replaceTranslationParams","aggregatedTagLabel","getAggregatedTagLabel","selectionContent","jsx","UNSTABLE_PickerTag","item","popoverContextValue","useImperativeHandle","PickerContextProvider","jsxs","classNames","Label","Dropdown","VisuallyHidden","Icon","DropdownPopover","PickerPopoverContextProvider","HelperText","ValidationText","UNSTABLE_Picker","forwardRef"],"mappings":";;;;;;;;;;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GAAA,CAAI;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAChE,GACF;AAAA,MACA,gBAAAsE;AAAA,QAACY;AAAA,QAAA;AAAA,UACE,GAAG3E;AAAA,UACJ,mBAAiByB;AAAA,UACjB,MAAK;AAAA,UACL,cAAW;AAAA,UACX,kBAAkByB;AAAA,UAElB,UAAA,gBAAAa,EAACa,IAAA,EAA6B,OAAOV,IAAsB,UAAAlF,EAAA,CAAS;AAAA,QAAA;AAAA,MAAA;AAAA,IACtE,GACF;AAAA,IACA,gBAAA+E;AAAA,MAACc;AAAA,MAAA;AAAA,QACC,kBAAkBzD,EAAW;AAAA,QAC7B,IAAI,GAAGM,CAAQ;AAAA,QACf,cAAcV;AAAA,QACd,YAAA7B;AAAA,MAAA;AAAA,IAAA;AAAA,IAEDyB,KACC,gBAAAmD;AAAA,MAACe;AAAA,MAAA;AAAA,QACC,kBAAkB1D,EAAW;AAAA,QAC7B,IAAI,GAAGM,CAAQ;AAAA,QACd,GAAIf,MAAqB,EAAE,wBAAwBC,EAAA;AAAA,QACpD,gBAAAC;AAAA,QACA,cAAcG;AAAA,QACd,MAAME;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGT,QAAA,EAAK,IAAIW,GAAkB,QAAM,IAC/B,UAAAnB,GAAA,CACH;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ,GAEMqE,IAAkBC;AAAA,EACtBvG;AACF;AAEAsG,EAAgB,kBAAkB;AAClCA,EAAgB,cAAc;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/dictionaries.cjs"),E=e.Sizes.MEDIUM,S={[e.Sizes.SMALL]:e.SizesExtended.XSMALL,[e.Sizes.MEDIUM]:e.SizesExtended.SMALL,[e.Sizes.LARGE]:e.SizesExtended.MEDIUM};exports.DEFAULT_SIZE=E;exports.PICKER_NESTED_SIZE_MAP=S;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/dictionaries.cjs"),E=e.Sizes.MEDIUM,t={theme:"theme-light-default"},S={[e.Sizes.SMALL]:e.SizesExtended.XSMALL,[e.Sizes.MEDIUM]:e.SizesExtended.SMALL,[e.Sizes.LARGE]:e.SizesExtended.MEDIUM};exports.DEFAULT_POPOVER_PROPS=t;exports.DEFAULT_SIZE=E;exports.PICKER_NESTED_SIZE_MAP=S;
|
|
2
2
|
//# sourceMappingURL=constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sources":["../../../src/components/UNSTABLE_Picker/constants.ts"],"sourcesContent":["import { Sizes, SizesExtended } from '../../constants';\nimport type { SizeExtendedDictionaryType } from '../../types';\n\ntype PickerShellSize = (typeof Sizes)[keyof typeof Sizes];\n\nexport const DEFAULT_SIZE = Sizes.MEDIUM;\n\n/** Maps picker shell size to extended sizes for nested Tag and ControlButton. */\nexport const PICKER_NESTED_SIZE_MAP: Record<PickerShellSize, SizeExtendedDictionaryType> = {\n [Sizes.SMALL]: SizesExtended.XSMALL,\n [Sizes.MEDIUM]: SizesExtended.SMALL,\n [Sizes.LARGE]: SizesExtended.MEDIUM,\n};\n"],"names":["DEFAULT_SIZE","Sizes","PICKER_NESTED_SIZE_MAP","SizesExtended"],"mappings":"oIAKaA,EAAeC,EAAAA,MAAM,OAGrBC,EAA8E,CACzF,
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../../src/components/UNSTABLE_Picker/constants.ts"],"sourcesContent":["import { Sizes, SizesExtended } from '../../constants';\nimport type { SizeExtendedDictionaryType, StyleProps } from '../../types';\n\ntype PickerShellSize = (typeof Sizes)[keyof typeof Sizes];\n\nexport const DEFAULT_SIZE = Sizes.MEDIUM;\n\n/** Default props for the inner `DropdownPopover` (overridable via `popoverProps`). */\nexport const DEFAULT_POPOVER_PROPS: StyleProps = {\n theme: 'theme-light-default',\n};\n\n/** Maps picker shell size to extended sizes for nested Tag and ControlButton. */\nexport const PICKER_NESTED_SIZE_MAP: Record<PickerShellSize, SizeExtendedDictionaryType> = {\n [Sizes.SMALL]: SizesExtended.XSMALL,\n [Sizes.MEDIUM]: SizesExtended.SMALL,\n [Sizes.LARGE]: SizesExtended.MEDIUM,\n};\n"],"names":["DEFAULT_SIZE","Sizes","DEFAULT_POPOVER_PROPS","PICKER_NESTED_SIZE_MAP","SizesExtended"],"mappings":"oIAKaA,EAAeC,EAAAA,MAAM,OAGrBC,EAAoC,CAC/C,MAAO,qBACT,EAGaC,EAA8E,CACzF,CAACF,EAAAA,MAAM,KAAK,EAAGG,EAAAA,cAAc,OAC7B,CAACH,EAAAA,MAAM,MAAM,EAAGG,EAAAA,cAAc,MAC9B,CAACH,EAAAA,MAAM,KAAK,EAAGG,gBAAc,MAC/B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Sizes } from '../../constants';
|
|
2
|
-
import { SizeExtendedDictionaryType } from '../../types';
|
|
2
|
+
import { SizeExtendedDictionaryType, StyleProps } from '../../types';
|
|
3
3
|
type PickerShellSize = (typeof Sizes)[keyof typeof Sizes];
|
|
4
4
|
export declare const DEFAULT_SIZE: "medium";
|
|
5
|
+
export declare const DEFAULT_POPOVER_PROPS: StyleProps;
|
|
5
6
|
export declare const PICKER_NESTED_SIZE_MAP: Record<PickerShellSize, SizeExtendedDictionaryType>;
|
|
6
7
|
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { SizesExtended as
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[E.
|
|
1
|
+
import { SizesExtended as t, Sizes as E } from "../../constants/dictionaries.js";
|
|
2
|
+
const M = E.MEDIUM, L = {
|
|
3
|
+
theme: "theme-light-default"
|
|
4
|
+
}, S = {
|
|
5
|
+
[E.SMALL]: t.XSMALL,
|
|
6
|
+
[E.MEDIUM]: t.SMALL,
|
|
7
|
+
[E.LARGE]: t.MEDIUM
|
|
6
8
|
};
|
|
7
9
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
L as DEFAULT_POPOVER_PROPS,
|
|
11
|
+
M as DEFAULT_SIZE,
|
|
12
|
+
S as PICKER_NESTED_SIZE_MAP
|
|
10
13
|
};
|
|
11
14
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../src/components/UNSTABLE_Picker/constants.ts"],"sourcesContent":["import { Sizes, SizesExtended } from '../../constants';\nimport type { SizeExtendedDictionaryType } from '../../types';\n\ntype PickerShellSize = (typeof Sizes)[keyof typeof Sizes];\n\nexport const DEFAULT_SIZE = Sizes.MEDIUM;\n\n/** Maps picker shell size to extended sizes for nested Tag and ControlButton. */\nexport const PICKER_NESTED_SIZE_MAP: Record<PickerShellSize, SizeExtendedDictionaryType> = {\n [Sizes.SMALL]: SizesExtended.XSMALL,\n [Sizes.MEDIUM]: SizesExtended.SMALL,\n [Sizes.LARGE]: SizesExtended.MEDIUM,\n};\n"],"names":["DEFAULT_SIZE","Sizes","PICKER_NESTED_SIZE_MAP","SizesExtended"],"mappings":";AAKO,MAAMA,IAAeC,EAAM,QAGrBC,IAA8E;AAAA,EACzF,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/components/UNSTABLE_Picker/constants.ts"],"sourcesContent":["import { Sizes, SizesExtended } from '../../constants';\nimport type { SizeExtendedDictionaryType, StyleProps } from '../../types';\n\ntype PickerShellSize = (typeof Sizes)[keyof typeof Sizes];\n\nexport const DEFAULT_SIZE = Sizes.MEDIUM;\n\n/** Default props for the inner `DropdownPopover` (overridable via `popoverProps`). */\nexport const DEFAULT_POPOVER_PROPS: StyleProps = {\n theme: 'theme-light-default',\n};\n\n/** Maps picker shell size to extended sizes for nested Tag and ControlButton. */\nexport const PICKER_NESTED_SIZE_MAP: Record<PickerShellSize, SizeExtendedDictionaryType> = {\n [Sizes.SMALL]: SizesExtended.XSMALL,\n [Sizes.MEDIUM]: SizesExtended.SMALL,\n [Sizes.LARGE]: SizesExtended.MEDIUM,\n};\n"],"names":["DEFAULT_SIZE","Sizes","DEFAULT_POPOVER_PROPS","PICKER_NESTED_SIZE_MAP","SizesExtended"],"mappings":";AAKO,MAAMA,IAAeC,EAAM,QAGrBC,IAAoC;AAAA,EAC/C,OAAO;AACT,GAGaC,IAA8E;AAAA,EACzF,CAACF,EAAM,KAAK,GAAGG,EAAc;AAAA,EAC7B,CAACH,EAAM,MAAM,GAAGG,EAAc;AAAA,EAC9B,CAACH,EAAM,KAAK,GAAGG,EAAc;AAC/B;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FocusEvent, KeyboardEvent, ReactNode } from 'react';
|
|
2
2
|
import { SelectionMode } from '../../hooks';
|
|
3
|
-
import { HelperTextProps, SizesDictionaryType, SpiritCheckboxProps, SpiritDivElementProps, SpiritFieldGroupProps, SpiritTagProps, Validation, ValidationTextProp } from '../../types';
|
|
3
|
+
import { DropdownBaseProps, HelperTextProps, SizesDictionaryType, SpiritCheckboxProps, SpiritDivElementProps, SpiritFieldGroupProps, SpiritTagProps, StyleProps, Validation, ValidationTextProp } from '../../types';
|
|
4
4
|
export type UnstablePickerSelectionMode = SelectionMode;
|
|
5
5
|
export interface UnstablePickerSelectionGridRowProps {
|
|
6
6
|
tabIndex: 0 | -1;
|
|
@@ -32,6 +32,9 @@ export interface UnstablePickerBaseProps<S = void> extends Omit<SpiritDivElement
|
|
|
32
32
|
isLabelHidden?: boolean;
|
|
33
33
|
isRequired?: boolean;
|
|
34
34
|
label: string;
|
|
35
|
+
dropdownProps?: DropdownBaseProps;
|
|
36
|
+
labelProps?: StyleProps;
|
|
37
|
+
popoverProps?: StyleProps;
|
|
35
38
|
renderTags?: (options: UnstablePickerRenderTagsOptions) => ReactNode;
|
|
36
39
|
selectionMode?: UnstablePickerSelectionMode;
|
|
37
40
|
size?: SizesDictionaryType<S>;
|