@oracle/oraclejet-preact 18.1.4 → 18.1.5
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/amd/InputDatePicker-ecd4a7ce.js +2 -0
- package/amd/{InputDatePicker-cf7e7ea3.js.map → InputDatePicker-ecd4a7ce.js.map} +1 -1
- package/amd/Legend-6fa54628.js +2 -0
- package/amd/Legend-6fa54628.js.map +1 -0
- package/amd/LegendRendered-d8626509.js.map +1 -1
- package/amd/MaxLengthCounter-9a95922c.js +2 -0
- package/amd/MaxLengthCounter-9a95922c.js.map +1 -0
- package/amd/TextArea-f6b13c73.js +2 -0
- package/amd/TextArea-f6b13c73.js.map +1 -0
- package/amd/TextAreaAutosize-af350c32.js +2 -0
- package/amd/{TextAreaAutosize-b7e56051.js.map → TextAreaAutosize-af350c32.js.map} +1 -1
- package/amd/Theme-redwood/theme.css +130 -130
- package/amd/Theme-stable/theme.css +254 -254
- package/amd/UNSAFE_InputDatePicker.js +1 -1
- package/amd/UNSAFE_Legend.js +1 -1
- package/amd/UNSAFE_TextArea.js +1 -1
- package/amd/UNSAFE_TextAreaAutosize.js +1 -1
- package/cjs/CheckboxSetContext-c62db26d.js +12 -0
- package/{es/CheckboxSetContext-1be56556.js.map → cjs/CheckboxSetContext-c62db26d.js.map} +1 -1
- package/cjs/{InputDatePicker-6c8cbbf7.js → InputDatePicker-3dace90c.js} +2 -2
- package/cjs/{InputDatePicker-6c8cbbf7.js.map → InputDatePicker-3dace90c.js.map} +1 -1
- package/cjs/{Legend-743ebb76.js → Legend-7e72e911.js} +4 -4
- package/cjs/Legend-7e72e911.js.map +1 -0
- package/cjs/LegendRendered-c12152bc.js.map +1 -1
- package/cjs/MaxLengthCounter-9ab3f74b.js +27 -0
- package/cjs/MaxLengthCounter-9ab3f74b.js.map +1 -0
- package/cjs/{TextArea-f4a84aab.js → TextArea-a11875f3.js} +4 -22
- package/cjs/TextArea-a11875f3.js.map +1 -0
- package/cjs/{TextAreaAutosize-08ca17cf.js → TextAreaAutosize-5a8e8335.js} +3 -3
- package/cjs/{TextAreaAutosize-08ca17cf.js.map → TextAreaAutosize-5a8e8335.js.map} +1 -1
- package/cjs/Theme-redwood/theme.css +182 -182
- package/cjs/Theme-stable/theme.css +205 -205
- package/cjs/UNSAFE_CheckboxItem.js +30 -82
- package/cjs/UNSAFE_CheckboxItem.js.map +1 -1
- package/cjs/UNSAFE_CheckboxSet.js +44 -15
- package/cjs/UNSAFE_CheckboxSet.js.map +1 -1
- package/cjs/UNSAFE_InputDatePicker.js +90 -90
- package/cjs/UNSAFE_Legend.js +1 -1
- package/cjs/UNSAFE_RichCheckboxSet.js +26 -29
- package/cjs/UNSAFE_RichCheckboxSet.js.map +1 -1
- package/cjs/UNSAFE_RichSelectionItem.js +46 -184
- package/cjs/UNSAFE_RichSelectionItem.js.map +1 -1
- package/cjs/UNSAFE_TextArea.js +4 -3
- package/cjs/UNSAFE_TextArea.js.map +1 -1
- package/cjs/UNSAFE_TextAreaAutosize.js +3 -3
- package/es/CheckboxSet-28953b25.js +49 -0
- package/{cjs/CheckboxSet-abbf7a03.js.map → es/CheckboxSet-28953b25.js.map} +1 -1
- package/es/InputPassword-fa63ac17.js +1 -1
- package/es/{Legend-a60126aa.js → Legend-0e274097.js} +4 -4
- package/es/Legend-0e274097.js.map +1 -0
- package/es/LegendRendered-65a3684e.js.map +1 -1
- package/es/MaxLengthCounter-181b4fc9.js +25 -0
- package/es/MaxLengthCounter-181b4fc9.js.map +1 -0
- package/es/{NavigationListItem-07f041e6.js → NavigationListItem-37edc23b.js} +1 -14
- package/es/{NavigationListItem-07f041e6.js.map → NavigationListItem-37edc23b.js.map} +1 -1
- package/es/{OverflowTabBar-c920e944.js → OverflowTabBar-87b36877.js} +2 -2
- package/es/{OverflowTabBar-c920e944.js.map → OverflowTabBar-87b36877.js.map} +1 -1
- package/es/{OverflowTabBarItem-ccfa49a3.js → OverflowTabBarItem-a2684d2b.js} +2 -2
- package/es/{OverflowTabBarItem-ccfa49a3.js.map → OverflowTabBarItem-a2684d2b.js.map} +1 -1
- package/es/PRIVATE_RevealToggleIcon.js +2 -2
- package/es/{RevealToggleIcon-2f49fd19.js → RevealToggleIcon-35baaadf.js} +2 -2
- package/es/{RevealToggleIcon-2f49fd19.js.map → RevealToggleIcon-35baaadf.js.map} +1 -1
- package/es/SplitMenuButtonTheme.styles.css +4 -4
- package/es/SplitMenuButtonTheme.styles2.css +4 -4
- package/es/{TextArea-d7eb6b00.js → TextArea-2eb362ec.js} +8 -25
- package/es/TextArea-2eb362ec.js.map +1 -0
- package/es/{TextAreaAutosize-301eb2b7.js → TextAreaAutosize-35a923c3.js} +2 -2
- package/es/{TextAreaAutosize-301eb2b7.js.map → TextAreaAutosize-35a923c3.js.map} +1 -1
- package/es/Theme-redwood/theme.css +545 -545
- package/es/Theme-stable/theme.css +483 -483
- package/es/UNSAFE_ButtonLayout/tests/ButtonLayout.spec.js +1 -1
- package/es/UNSAFE_CheckboxItem.js +82 -30
- package/es/UNSAFE_CheckboxItem.js.map +1 -1
- package/es/UNSAFE_CheckboxSet.js +10 -44
- package/es/UNSAFE_CheckboxSet.js.map +1 -1
- package/es/UNSAFE_InputPassword.js +1 -1
- package/es/UNSAFE_InputSensitiveText.js +1 -1
- package/es/UNSAFE_Legend.js +1 -1
- package/es/UNSAFE_NavigationList.js +4 -4
- package/es/UNSAFE_OverflowTabBar.js +3 -3
- package/es/UNSAFE_RichCheckboxSet.js +28 -25
- package/es/UNSAFE_RichCheckboxSet.js.map +1 -1
- package/es/UNSAFE_RichSelectionItem.js +182 -44
- package/es/UNSAFE_RichSelectionItem.js.map +1 -1
- package/es/UNSAFE_SplitMenuButton/themes/redwood/SplitMenuButtonTheme.css.js +1 -1
- package/es/UNSAFE_SplitMenuButton/themes/stable/SplitMenuButtonTheme.css.js +1 -1
- package/es/UNSAFE_SplitMenuButton.js +1 -1
- package/es/UNSAFE_TabBar.js +2 -2
- package/es/UNSAFE_TabBarCommon.js +2 -2
- package/es/UNSAFE_TabBarMixed.js +2 -2
- package/es/UNSAFE_TextArea.js +3 -2
- package/es/UNSAFE_TextArea.js.map +1 -1
- package/es/UNSAFE_TextAreaAutosize.js +3 -3
- package/es/UNSAFE_Toolbar/tests/Toolbar.spec.js +1 -1
- package/package.json +2 -2
- package/types/hooks/UNSAFE_useLegendPreferredSize/LegendRendered.d.ts +1 -1
- package/amd/InputDatePicker-cf7e7ea3.js +0 -2
- package/amd/Legend-76df298c.js +0 -2
- package/amd/Legend-76df298c.js.map +0 -1
- package/amd/TextArea-d69acd23.js +0 -2
- package/amd/TextArea-d69acd23.js.map +0 -1
- package/amd/TextAreaAutosize-b7e56051.js +0 -2
- package/cjs/CheckboxSet-abbf7a03.js +0 -53
- package/cjs/Legend-743ebb76.js.map +0 -1
- package/cjs/TextArea-f4a84aab.js.map +0 -1
- package/es/CheckboxSetContext-1be56556.js +0 -9
- package/es/Legend-a60126aa.js.map +0 -1
- package/es/TextArea-d7eb6b00.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
define(['exports', 'preact/jsx-runtime', 'preact/compat', 'preact/hooks', './Calendar-0e2eb66f', './HiddenAccessible-037ef42d', './IconButton-05c6b793', './clientHints-fff66be9', './FormFieldContext-3c44aaaa', './logger-0f873e29', './TabbableModeContext-a9c97640', './useTranslationBundle-7c40cb58', 'css!./UserAssistanceStyles.styles.css', 'module', './UNSAFE_UserAssistance/themes/redwood/UserAssistanceVariants.css', './InlineUserAssistance-3d3e72a9', './Flex-590160eb', 'css!./MessageBannerStyles.styles.css', 'module', './UNSAFE_MessageBanner/themes/redwood/MessageBannerVariants.css', 'preact', './LayerHost-733ade2f', 'css!./TooltipContentStyles.styles.css', 'module', './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css', './tooltipUtils-30886397', 'css!./IconStyle.styles.css', 'css!./MessageStyles.styles.css', './MessageFormattingUtils-2e19d8de', './TransitionGroup-3b9d81b6', './MessagesContext-602a69a2', 'css!./HiddenAccessibleStyles.styles.css', 'css!./ComponentMessageStyles.styles.css', 'module', './UNSAFE_ComponentMessage/themes/redwood/ComponentMessageVariants.css', './Popup-3e2566da', './UNSAFE_Separator/themes/SeparatorStyles.css', 'css!./LabelStyles.styles.css', 'module', './UNSAFE_Label/themes/redwood/LabelVariants.css', './InputGroupContext-372087af', 'module', './UNSAFE_Popup/themes/redwood/PopupVariants.css', './UNSAFE_InputDatePicker/themes/InputDatePickerDropdownStyles.css', './Sheet-404b38fa', './DatePicker-b907fb97', './SectionedContent-ef1f844c', './stringUtils-0ae982c2', './FormContext-5130e198', './useFormContext-30acdd33', './useId-c9578d26', './getFormatParse-3d7186b3', './maskUtils-9370948f', './calendarDateUtils-5e25297c', './InputDateMask-55fcbf50'], (function(e,s,t,a,n,o,r,i,l,d,c,u,m,p,h,y,f,b,C,D,S,k,x,A,v,g,F,T,V,I,w,P,U,M,R,j,_,B,H,E,N,L,O,Y,Z,W,z,G,q,J,K,Q,X,$,ee){"use strict";const se=({anchorRef:e,assistiveText:t,dayFormatter:n,daysOutsideMonth:o,helpSourceLink:r,helpSourceText:i,isDisabled:d,isOpen:c,isReadonly:m,label:p,onClose:h,onCommit:f,max:b,messages:C,min:D,monthAndYearPicker:S,testId:k,todayButton:x,todayTimeZone:A,userAssistanceDensity:v,value:g,weekDisplay:F})=>{const[T,V]=a.useState(!1),[I,w]=a.useState(c),P=a.useCallback((e=>{V(e.placement.startsWith("top"))}),[]);I!==c&&(w(c),c||V(!1));const U=te(),{datePicker_label:M}=u.useTranslationBundle("@oracle/oraclejet-preact"),R=M(),j=s.jsx(W.DatePicker,{dayFormatter:n,daysOutsideMonth:o,height:U?void 0:"auto",onCommit:f,max:b,min:D,maxWidth:U?"100%":void 0,width:"100%",monthAndYearPicker:S,testId:k,todayTimeZone:A,todayButton:x,value:g,weekDisplay:F}),_=!c||T&&!U||d||m||!(t||r||C&&C.length>0)||"efficient"!==v&&"reflow"!==v?void 0:s.jsx(l.FormFieldContext.Provider,{value:{isFocused:!0},children:s.jsx("div",{class:Y.userAssistanceStyles,children:s.jsx(y.InlineUserAssistance,{assistiveText:t,fieldLabel:p,helpSourceLink:r,helpSourceText:i,messages:C,userAssistanceDensity:v})})}),B=k?k+(U?"_sheet":"_dropdown"):void 0,H=s.jsx("div",{class:Y.dropdownStyles,children:s.jsx(z.SectionedContent,{"aria-label":R,footer:_,hasFocusTrap:!0,main:j,role:"dialog",testId:B})});return U?s.jsx(Z.Sheet,{initialFocus:"firstFocusable",isOpen:c,onClose:h,children:s.jsx(z.SectionedContent,{"aria-label":R,footer:_,hasFocusTrap:!0,main:j,role:"dialog",testId:B})}):s.jsx(z.StickyPositioningDropdown,{anchorRef:e,initialFocus:"firstFocusable",isOpen:c,onClose:h,onPosition:P,sizeOptions:{isMaxWidthAdjusted:!1,isMaxHeightAdjusted:!0},children:H})},te=()=>"phone"===i.getClientHints().deviceType,ae=e=>e&&$.isCompleteCalendarDate(e)?e:void 0,ne=(e,s)=>{switch(s.type){case"dateChanged":return{...e,dateValue:s.data,completeDateValue:ae(s.data)};case"dateSelected":return{...e,dateValue:s.data,completeDateValue:s.data};case"reset":return{completeDateValue:ae(s.data),dateValue:s.data};default:return e}},oe=({onCommit:e,onInput:s,value:t})=>{const[n,o]=a.useState(!1),r=a.useRef(null),i=a.useRef(null),l=a.useRef(!1),d=a.useRef(),c=a.useRef(t),u=a.useRef(t),m=a.useRef(t),p=a.useRef(!1),{state:h,dispatch:y}=(({value:e})=>{const[s,t]=a.useReducer(ne,{completeDateValue:ae(e),dateValue:e});return{state:s,dispatch:t}})({value:t});X.calendarDatesAreDifferent(m.current,t)&&(m.current=t,X.calendarDatesAreDifferent(t,h.dateValue)&&(y({type:"reset",data:t}),u.current=t,c.current=t)),a.useEffect((()=>{X.calendarDatesAreDifferent(h.dateValue,u.current)&&(s({previousValue:u.current,value:h.dateValue}),u.current=h.dateValue),p.current&&X.calendarDatesAreDifferent(h.dateValue,c.current)&&(e?.({previousValue:c.current,value:h.dateValue}),c.current=h.dateValue,p.current=!1)}),[e,s,h.dateValue]);const f=a.useCallback((e=>{y({type:"dateChanged",data:e.value})}),[y]),b=a.useCallback((()=>{X.calendarDatesAreDifferent(c.current,h.dateValue)&&(e?.({value:h.dateValue,previousValue:c.current}),c.current=h.dateValue)}),[e,h.dateValue]),C=a.useCallback((()=>{l.current||o((e=>!e)),l.current=!1}),[]),D=a.useCallback((e=>{"outsideMousedown"===e.reason?(l.current=!0,clearTimeout(d.current),d.current=setTimeout((()=>{l.current=!1}),200)):"dismissed"!==e.reason&&"keyboardDismissed"!==e.reason||r.current?.focus(),o(!1)}),[]);return{calendarIconActionHandler:C,datePickerCommitHandler:a.useCallback((e=>{r.current?.focus(),p.current=!0,y({type:"dateSelected",data:e.value}),o(!1)}),[y]),dropdownCloseHandler:D,completeDateValue:h.completeDateValue,dateValue:h.dateValue,iconRef:r,isOpen:n,maskCommitHandler:b,maskInputHandler:f,maskRef:i}},re=t.forwardRef((({"aria-describedby":e,assistiveText:t,dayFormatter:i,daysOutsideMonth:l,helpSourceLink:d,helpSourceText:c,isDisabled:m,isReadonly:p,label:h,max:y,messages:f,min:b,monthAndYearPicker:C,todayTimeZone:D,todayButton:S,value:k,onCommit:x,onInput:A,testId:v,userAssistanceDensity:g,weekDisplay:F,...T},V)=>{const{calendarIconActionHandler:I,datePickerCommitHandler:w,completeDateValue:P,dateValue:U,dropdownCloseHandler:M,iconRef:R,isOpen:j,maskCommitHandler:_,maskInputHandler:B,maskRef:H}=oe({onCommit:x,onInput:A,value:k}),E=a.useRef(null),{inputDatePicker_selectDate:N,inputDatePicker_instruction:L}=u.useTranslationBundle("@oracle/oraclejet-preact"),O=N(),{userAssistanceDensity:Y}=J.useFormContext(),Z=g??Y;a.useImperativeHandle(V,(()=>({focus:()=>{H.current?.focus()},blur:()=>{H.current?.blur()}})));const W=K.useId(),z=L(),q=m||p?void 0:s.jsx(o.HiddenAccessible,{id:W,isHidden:!0,children:z}),Q=m||p?e:G.merge([e,W]),X=s.jsx(r.IconButton,{"aria-haspopup":"dialog","aria-label":O,isDisabled:m,ref:R,size:"sm",testId:v?v+"_calendarIcon":void 0,variant:"ghost",onAction:I,children:s.jsx(n.SvgCalendar,{})}),$=j;return s.jsxs(s.Fragment,{children:[s.jsx(ee.InputDateMaskContext.Provider,{value:{isDropdownOpen:j,isInputDatePickerParent:!0},children:s.jsx(ee.InputDateMask,{"aria-describedby":Q,assistiveText:t,endContent:X,helpSourceLink:d,helpSourceText:c,isDisabled:m,isReadonly:p,label:h,onCommit:_,onInput:B,mainFieldRef:E,messages:f,testId:v,ref:H,userAssistanceDensity:g,value:U,...T})}),q,$&&s.jsx(se,{anchorRef:E,assistiveText:t,dayFormatter:i,daysOutsideMonth:l,helpSourceLink:d,helpSourceText:c,isDisabled:m,isReadonly:p,isOpen:j,label:h,onClose:M,onCommit:w,max:y,messages:f,min:b,monthAndYearPicker:C,testId:v?v+"_datePicker":void 0,todayTimeZone:D,todayButton:S,userAssistanceDensity:Z,value:P,weekDisplay:F})]})}));e.InputDatePicker=re}));
|
|
2
|
+
//# sourceMappingURL=InputDatePicker-ecd4a7ce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputDatePicker-cf7e7ea3.js","sources":["../../src/UNSAFE_InputDatePicker/InputDatePickerDropdown.tsx","../../src/UNSAFE_InputDatePicker/useInputDatePickerState.ts","../../src/UNSAFE_InputDatePicker/useInputDatePicker.ts","../../src/UNSAFE_InputDatePicker/InputDatePicker.tsx"],"sourcesContent":["/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { ComponentProps } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport { BundleType } from '../resources/nls/bundle';\nimport { DatePicker } from '#UNSAFE_DatePicker';\nimport { type CloseDetail as DropdownCloseDetail } from '#UNSAFE_Dropdown';\nimport { getClientHints } from '#utils/PRIVATE_clientHints';\nimport { FormFieldContext } from '../hooks/UNSAFE_useFormFieldContext';\nimport { InlineUserAssistance } from '../UNSAFE_UserAssistance';\nimport { InputDatePicker } from './InputDatePicker';\nimport { dropdownStyles, userAssistanceStyles } from './themes/InputDatePickerDropdownStyles.css';\nimport { PositionData } from '../UNSAFE_Floating';\nimport { StickyPositioningDropdown } from '#PRIVATE_FormControls';\nimport { SectionedContent } from '#PRIVATE_FormControls';\nimport { type CloseDetail as SheetCloseDetail, Sheet } from '#UNSAFE_Sheet';\nimport type { TestIdProps } from '#hooks/UNSAFE_useTestId';\nimport { useTranslationBundle } from '#hooks/UNSAFE_useTranslationBundle';\nimport { SizeOptions } from '#UNSAFE_Floating/Floating'; \n\ntype StickyPositioningDropdownProps = ComponentProps<typeof StickyPositioningDropdown>;\ntype InputDatePickerProps = ComponentProps<typeof InputDatePicker>;\ntype PickedPropsFromInputDatePicker = Pick<\n InputDatePickerProps,\n | 'assistiveText'\n | 'dayFormatter'\n | 'daysOutsideMonth'\n | 'helpSourceLink'\n | 'helpSourceText'\n | 'isDisabled'\n | 'isReadonly'\n | 'label'\n | 'messages'\n | 'min'\n | 'max'\n | 'monthAndYearPicker'\n | 'todayButton'\n | 'todayTimeZone'\n | 'userAssistanceDensity'\n | 'value'\n | 'weekDisplay'\n>;\ntype DatePickerProps = ComponentProps<typeof DatePicker>;\ntype PickedPropsFromDatePicker = Pick<DatePickerProps, 'value' | 'onCommit'>;\ntype PickedPropsFromDropdown = Omit<StickyPositioningDropdownProps, 'onClose'>;\ntype CloseDetail = SheetCloseDetail | DropdownCloseDetail;\n\ntype Props = PickedPropsFromDatePicker &\n PickedPropsFromInputDatePicker &\n PickedPropsFromDropdown &\n TestIdProps & {\n /**\n * Called when the dropdown or sheet is supposed to be closed.\n */\n onClose?: (detail: CloseDetail) => void;\n };\n\n/**\n * Component that renders DatePicker either inside a dropdown or sheet; at small screen\n * widths, it renders inside a sheet. Additionally, when a dropdown is being shown beneath\n * the component, we also show any user assistance text or messages below the picker\n * because otherwise that information would be obscured from view. When a sheet is being\n * shown, it will always display UA and messages at the bottom of the sheet.\n */\nconst InputDatePickerDropdown = ({\n anchorRef,\n assistiveText,\n dayFormatter,\n daysOutsideMonth,\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isOpen,\n isReadonly,\n label,\n onClose,\n onCommit,\n max,\n messages,\n min,\n monthAndYearPicker,\n testId,\n todayButton,\n todayTimeZone,\n userAssistanceDensity,\n value,\n weekDisplay\n}: Props) => {\n // If the dropdown opens above the component, we don't want to show UA or messages.\n const [isDropdownAbove, setDropdownAbove] = useState(false);\n const [prevIsOpen, setPrevIsOpen] = useState(isOpen);\n const handleDropdownPosition = useCallback<\n NonNullable<StickyPositioningDropdownProps['onPosition']>\n >((data: PositionData) => {\n setDropdownAbove(data.placement.startsWith('top'));\n }, []);\n // Reset the flag when the dropdown is closed.\n if (prevIsOpen !== isOpen) {\n setPrevIsOpen(isOpen);\n if (!isOpen) {\n setDropdownAbove(false);\n }\n }\n\n const sizeOptions: SizeOptions = {\n isMaxWidthAdjusted: false,\n isMaxHeightAdjusted: true\n };\n\n // On mobile phones, the dropdown becomes a sheet.\n const shouldShowSheet = isPhone();\n\n const { datePicker_label } = useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const datePickerAriaLabel = datePicker_label();\n\n const datePickerMainContent = (\n <DatePicker\n dayFormatter={dayFormatter}\n daysOutsideMonth={daysOutsideMonth}\n height={!shouldShowSheet ? 'auto' : undefined}\n onCommit={onCommit}\n max={max}\n min={min}\n // for sheet, we want the width to grow to the width of the sheet, otherwise it will use the theme default.\n maxWidth={shouldShowSheet ? '100%' : undefined}\n width=\"100%\"\n monthAndYearPicker={monthAndYearPicker}\n testId={testId}\n todayTimeZone={todayTimeZone}\n todayButton={todayButton}\n value={value}\n weekDisplay={weekDisplay}\n />\n );\n\n const inlineUserAssistanceFooter =\n isOpen &&\n (!isDropdownAbove || shouldShowSheet) &&\n !isDisabled &&\n !isReadonly &&\n (assistiveText || helpSourceLink || (messages && messages.length > 0)) &&\n (userAssistanceDensity === 'efficient' || userAssistanceDensity === 'reflow') ? (\n <FormFieldContext.Provider value={{ isFocused: true }}>\n <div class={userAssistanceStyles}>\n <InlineUserAssistance\n assistiveText={assistiveText}\n fieldLabel={label}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n messages={messages}\n userAssistanceDensity={userAssistanceDensity}\n />\n </div>\n </FormFieldContext.Provider>\n ) : undefined;\n\n const contentTestId = testId ? testId + (shouldShowSheet ? '_sheet' : '_dropdown') : undefined;\n\n // The same content is displayed either in a dropdown or sheet: date picker and inline UA.\n // Add styling to the dropdown to enforce a fixed width.\n const dropdownContent = (\n <div class={dropdownStyles}>\n <SectionedContent\n aria-label={datePickerAriaLabel}\n footer={inlineUserAssistanceFooter}\n hasFocusTrap={true}\n main={datePickerMainContent}\n role=\"dialog\"\n testId={contentTestId}\n />\n </div>\n );\n\n const dropdown = shouldShowSheet ? (\n <Sheet initialFocus=\"firstFocusable\" isOpen={isOpen} onClose={onClose}>\n <SectionedContent\n aria-label={datePickerAriaLabel}\n footer={inlineUserAssistanceFooter}\n hasFocusTrap={true}\n main={datePickerMainContent}\n role=\"dialog\"\n testId={contentTestId}\n />\n </Sheet>\n ) : (\n <StickyPositioningDropdown\n anchorRef={anchorRef}\n initialFocus=\"firstFocusable\"\n isOpen={isOpen}\n onClose={onClose}\n onPosition={handleDropdownPosition}\n sizeOptions={sizeOptions}>\n {dropdownContent}\n </StickyPositioningDropdown>\n );\n\n return dropdown;\n};\n\nconst isPhone = () => {\n return getClientHints().deviceType === 'phone';\n};\n\nexport { InputDatePickerDropdown, type CloseDetail };\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { useReducer } from 'preact/hooks';\nimport type { CalendarDate, CalendarDateRequired } from '#utils/UNSAFE_calendarDateUtils';\nimport { isCompleteCalendarDate } from '#utils/UNSAFE_calendarDateUtils';\n\ntype InputDatePickerState = {\n /**\n * If dateValue is a complete date, then completeDateValue is the same as dateValue\n * otherwise is is undefined. We need to maintain separate states because\n * InputDateMask uses CalendarDate, but DatePicker uses CalendarDateRequired.\n * If the user types a partial date then opens the picker, we treat that as\n * no selection. The picker opens to the current month showing today.\n */\n completeDateValue?: CalendarDateRequired;\n\n /**\n * Represents the current date value of the component. The user either selected\n * the date in the picker, or typed it into the date field.\n */\n dateValue?: CalendarDate;\n};\n\ntype DateChangedAction = { type: 'dateChanged'; data?: CalendarDate };\ntype DateResetAction = { type: 'reset'; data?: CalendarDate };\ntype DateSelectedAction = { type: 'dateSelected'; data?: CalendarDateRequired };\ntype InputDatePickerReducerAction = DateChangedAction | DateResetAction | DateSelectedAction;\n\n// If dateVal is a complete date, return it as a CalendarDateRequired\n// otherwise return undefined.\nconst convertToCalendarDateRequired = (dateVal?: CalendarDate) => {\n return !dateVal || !isCompleteCalendarDate(dateVal)\n ? undefined\n : (dateVal as CalendarDateRequired);\n};\n\n// Use a reducer function to manage InputDatePickerState.\nconst inputDatePickerReducer = (\n state: InputDatePickerState,\n action: InputDatePickerReducerAction\n): InputDatePickerState => {\n switch (action.type) {\n case 'dateChanged': {\n return {\n ...state,\n dateValue: action.data,\n completeDateValue: convertToCalendarDateRequired(action.data)\n };\n }\n case 'dateSelected': {\n return { ...state, dateValue: action.data, completeDateValue: action.data };\n }\n case 'reset': {\n return {\n completeDateValue: convertToCalendarDateRequired(action.data),\n dateValue: action.data\n };\n }\n default:\n return state;\n }\n};\n\ntype Props = {\n /**\n * The value of the InputDatePicker, or undefined.\n */\n value?: CalendarDate;\n};\n\n/**\n * useInputDatePickerState calls useReducer to determine the initial state. Any changes to that state\n * are managed by dispatching actions to the reducer function.\n */\nconst useInputDatePickerState = ({ value }: Props) => {\n const [state, dispatch] = useReducer(inputDatePickerReducer, {\n completeDateValue: convertToCalendarDateRequired(value),\n dateValue: value\n });\n\n return { state, dispatch };\n};\n\nexport { useInputDatePickerState };\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport type { ComponentProps, RefObject } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport type { CalendarDate, CalendarDateRequired } from '#utils/UNSAFE_calendarDateUtils';\nimport { calendarDatesAreDifferent } from '#utils/PRIVATE_dayUtils';\nimport { DatePicker } from '#UNSAFE_DatePicker';\nimport { CloseDetail, InputDatePickerDropdown } from './InputDatePickerDropdown';\nimport { IconButton } from '#UNSAFE_IconButton';\nimport { InputDateMask } from '#UNSAFE_InputDateMask';\nimport { InputDatePicker } from './InputDatePicker';\nimport { useInputDatePickerState } from './useInputDatePickerState';\nimport type { ValueUpdateDetail } from '#utils/UNSAFE_valueUpdateDetail';\n\ntype InputDatePickerProps = ComponentProps<typeof InputDatePicker>;\ntype InputDateMaskProps = ComponentProps<typeof InputDateMask>;\ntype DatePickerProps = ComponentProps<typeof DatePicker>;\ntype IconButtonProps = ComponentProps<typeof IconButton>;\ntype DropdownProps = ComponentProps<typeof InputDatePickerDropdown>;\n\ntype Props = {\n onCommit: InputDatePickerProps['onCommit'];\n onInput: InputDatePickerProps['onInput'];\n value: InputDatePickerProps['value'];\n};\n\n/**\n * Hook that provides handlers and other functionality for InputDatePicker.\n */\nconst useInputDatePicker = ({ onCommit, onInput, value: currentValue }: Props) => {\n // Whether the dropdown is open.\n const [isOpen, setIsOpen] = useState(false);\n\n // Ref to the calendar icon button.\n const iconRef: RefObject<HTMLButtonElement> = useRef<HTMLButtonElement>(null);\n\n // Ref to the InputDateMask component.\n const maskRef: RefObject<HTMLElement> = useRef<HTMLElement>(null);\n\n // Keep track of whether the dropdown was just dismissed from an outside mousedown event.\n const outsideMousedownRef = useRef<boolean>(false);\n const outsideMousedownTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>();\n\n // Keep track of the last date values passed to onInput and onCommit.\n const lastCommittedDateRef = useRef<CalendarDate | undefined>(currentValue);\n const lastDateRef = useRef<CalendarDate | undefined>(currentValue);\n\n // Keep track of the last controlled value passed from the parent, so we can detect a programmatic change.\n const lastValueFromParentRef = useRef<CalendarDate | undefined>(currentValue);\n\n // Keep track of whether a date was selected in the date picker.\n const dateSelectedRef = useRef<boolean>(false);\n\n const { state, dispatch } = useInputDatePickerState({ value: currentValue });\n\n // If a new value is being pushed from the parent, and that value differs from\n // the current value of the reducer, then this is a programmatic update\n // and we need to call 'reset' to update the reducer state. Otherwise, the only\n // time the reducer state is updated from the value is on mount.\n if (calendarDatesAreDifferent(lastValueFromParentRef.current, currentValue)) {\n lastValueFromParentRef.current = currentValue;\n if (calendarDatesAreDifferent(currentValue, state.dateValue)) {\n dispatch({ type: 'reset', data: currentValue });\n lastDateRef.current = currentValue;\n lastCommittedDateRef.current = currentValue;\n }\n }\n\n // Reducer updates are async, so wait until the state updates and then call our callbacks.\n useEffect(() => {\n if (calendarDatesAreDifferent(state.dateValue, lastDateRef.current)) {\n onInput({ previousValue: lastDateRef.current, value: state.dateValue });\n lastDateRef.current = state.dateValue;\n }\n if (\n dateSelectedRef.current &&\n calendarDatesAreDifferent(state.dateValue, lastCommittedDateRef.current)\n ) {\n onCommit?.({ previousValue: lastCommittedDateRef.current, value: state.dateValue });\n lastCommittedDateRef.current = state.dateValue;\n dateSelectedRef.current = false;\n }\n }, [onCommit, onInput, state.dateValue]);\n\n // Handle onInput from InputDateMask as segment values are being added or changed in the input field.\n // We wait for the state to update before calling onInput.\n const maskInputHandler = useCallback<InputDateMaskProps['onInput']>(\n (detail: ValueUpdateDetail<CalendarDate>) => {\n dispatch({ type: 'dateChanged', data: detail.value });\n },\n [dispatch]\n );\n\n // Handle onCommit from InputDateMask, which is called when the user presses Enter or the field is blurred.\n const maskCommitHandler = useCallback<NonNullable<InputDateMaskProps['onCommit']>>(() => {\n // If the current date value differs from the last committed value, then call onCommit.\n if (calendarDatesAreDifferent(lastCommittedDateRef.current, state.dateValue)) {\n onCommit?.({ value: state.dateValue, previousValue: lastCommittedDateRef.current });\n lastCommittedDateRef.current = state.dateValue;\n }\n }, [onCommit, state.dateValue]);\n\n // Respond to onAction event from the calendar icon button. Toggles the date picker dropdown.\n const calendarIconActionHandler = useCallback<NonNullable<IconButtonProps['onAction']>>(() => {\n // Only toggle the value of isOpen if we didn't just dismiss the dropdown.\n if (!outsideMousedownRef.current) {\n setIsOpen((prevIsOpen) => !prevIsOpen);\n }\n outsideMousedownRef.current = false;\n }, []);\n\n const dropdownCloseHandler = useCallback<NonNullable<DropdownProps['onClose']>>(\n (detail: CloseDetail) => {\n // Keep track of when the dropdown is closed via outside mousedown, including when the calendar icon\n // is clicked. We need this in order to toggle visibility of the picker and dropdown.\n if (detail.reason === 'outsideMousedown') {\n outsideMousedownRef.current = true;\n clearTimeout(outsideMousedownTimerRef.current);\n\n // Clear the flag after a short delay to ensure the dropdown can be opened again.\n outsideMousedownTimerRef.current = setTimeout(() => {\n outsideMousedownRef.current = false;\n }, 200);\n } else if (detail.reason === 'dismissed' || detail.reason === 'keyboardDismissed') {\n // Focus the calendar icon when the dropdown is closed.\n iconRef.current?.focus();\n }\n setIsOpen(false);\n },\n []\n );\n\n // Handle date selection in the picker.\n // - Updates the value in state.\n // - Closes the dropdown.\n // - Sets focus to the date field.\n const datePickerCommitHandler = useCallback<DatePickerProps['onCommit']>(\n (detail: ValueUpdateDetail<CalendarDateRequired>) => {\n // Set focus to the calendar icon when a date is selected.\n iconRef.current?.focus();\n\n // Set a ref indicating a date was selected.\n dateSelectedRef.current = true;\n dispatch({ type: 'dateSelected', data: detail.value });\n setIsOpen(false);\n },\n [dispatch]\n );\n\n return {\n calendarIconActionHandler,\n datePickerCommitHandler,\n dropdownCloseHandler,\n completeDateValue: state.completeDateValue,\n dateValue: state.dateValue,\n iconRef,\n isOpen,\n maskCommitHandler,\n maskInputHandler,\n maskRef\n };\n};\n\nexport { useInputDatePicker };\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\nimport { ComponentProps, Ref } from 'preact';\nimport { forwardRef } from 'preact/compat';\nimport { useImperativeHandle, useRef } from 'preact/hooks';\nimport { BundleType } from '../resources/nls/bundle';\nimport { CalendarIcon } from '#PRIVATE_ThemedIcons/CalendarIcon';\nimport {\n CalendarDate,\n CalendarDatePlaceholders,\n InputDateMask,\n InputDateMaskContext\n} from '#UNSAFE_InputDateMask';\nimport { DatePicker } from '#UNSAFE_DatePicker';\nimport { HiddenAccessible } from '#UNSAFE_HiddenAccessible';\nimport { IconButton } from '#UNSAFE_IconButton';\nimport { InputDatePickerDropdown } from './InputDatePickerDropdown';\nimport { FocusableHandle } from '#hooks/UNSAFE_useFocusableTextField';\nimport { merge } from '#utils/UNSAFE_stringUtils';\nimport { useFormContext } from '#hooks/UNSAFE_useFormContext';\nimport { useId } from '#hooks/UNSAFE_useId';\nimport { useInputDatePicker } from './useInputDatePicker';\nimport { useTranslationBundle } from '#hooks/UNSAFE_useTranslationBundle';\nimport { ValueUpdateDetail } from '#utils/UNSAFE_valueUpdateDetail';\n\ntype InputDateMaskProps = ComponentProps<typeof InputDateMask>;\ntype PickedPropsFromInputDateMask = Pick<\n InputDateMaskProps,\n | 'aria-describedby'\n | 'assistiveText'\n | 'columnSpan'\n | 'helpSourceLink'\n | 'helpSourceText'\n | 'isDisabled'\n | 'isReadonly'\n | 'isRequired'\n | 'isRequiredShown'\n | 'label'\n | 'labelEdge'\n | 'labelStartWidth'\n | 'messages'\n | 'textAlign'\n | 'testId'\n | 'userAssistanceDensity'\n | 'variant'\n>;\n\ntype DatePickerProps = ComponentProps<typeof DatePicker>;\ntype PickedPropsFromDatePicker = Pick<\n DatePickerProps,\n | 'dayFormatter'\n | 'daysOutsideMonth'\n | 'max'\n | 'min'\n | 'monthAndYearPicker'\n | 'todayTimeZone'\n | 'todayButton'\n | 'weekDisplay'\n>;\n\ntype Props = PickedPropsFromInputDateMask &\n PickedPropsFromDatePicker & {\n /**\n * If specified, overrides the locale specific order of the individual date segments\n * in the date field as well as the locale specific separator. The value of each placeholder\n * is only used when the type is 'literal', otherwise it is replaced with a translated\n * placeholder for month, day, or year. The placeholders must include month, day, and year.\n */\n masks?: CalendarDatePlaceholders;\n\n /**\n * The current display value of the component.\n * This is a CalendarDate, not CalendarDateRequired, because this is a controlled component and\n * the user may type the month, day, and year separately. If a selection is made in the date\n * picker, then the value is a complete date.\n */\n value?: CalendarDate;\n\n /**\n * Callback invoked when the user commits the entered value by blurring or hitting the enter key.\n * It is also called when a selection is made in the date picker.\n */\n onCommit?: (detail: ValueUpdateDetail<CalendarDate>) => void;\n\n /**\n * Callback invoked each time the user changes the value of a segment. For example, if the user\n * types '12' into the month segment, this callback will be called twice to change the month\n * first to '1' and then '12'.\n */\n onInput: (detail: ValueUpdateDetail<CalendarDate>) => void;\n };\n\n/**\n * InputDatePicker allows users to enter or select a single date using a calendar interface.\n */\nexport const InputDatePicker = forwardRef(\n (\n {\n 'aria-describedby': propDescribedBy,\n assistiveText,\n dayFormatter,\n daysOutsideMonth,\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isReadonly,\n label,\n max,\n messages,\n min,\n monthAndYearPicker,\n todayTimeZone,\n todayButton,\n value,\n onCommit,\n onInput,\n testId,\n userAssistanceDensity: propUserAssistanceDensity,\n weekDisplay,\n ...dateMaskProps\n }: Props,\n ref?: Ref<FocusableHandle>\n ) => {\n const {\n calendarIconActionHandler,\n datePickerCommitHandler,\n completeDateValue,\n dateValue,\n dropdownCloseHandler,\n iconRef,\n isOpen,\n maskCommitHandler,\n maskInputHandler,\n maskRef\n } = useInputDatePicker({\n onCommit,\n onInput,\n value\n });\n\n const mainFieldRef = useRef<HTMLDivElement>(null);\n const { inputDatePicker_selectDate, inputDatePicker_instruction } =\n useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const calendarIconAriaLabel = inputDatePicker_selectDate();\n\n // We need this to determine if UA/messaging should be shown in the dropdown.\n const { userAssistanceDensity: formUserAssistanceDensity } = useFormContext();\n const userAssistanceDensity = propUserAssistanceDensity ?? formUserAssistanceDensity;\n\n useImperativeHandle(ref!, () => ({\n focus: () => {\n maskRef.current?.focus();\n },\n blur: () => {\n maskRef.current?.blur();\n }\n }));\n\n const maskFieldInstructionId = useId();\n const maskFieldInstructionText = inputDatePicker_instruction();\n const maskFieldInstruction =\n !isDisabled && !isReadonly ? (\n <HiddenAccessible id={maskFieldInstructionId} isHidden={true}>\n {maskFieldInstructionText}\n </HiddenAccessible>\n ) : undefined;\n const ariaDescribedBy =\n !isDisabled && !isReadonly\n ? merge([propDescribedBy, maskFieldInstructionId])\n : propDescribedBy;\n\n const endContent = (\n <IconButton\n aria-haspopup=\"dialog\"\n aria-label={calendarIconAriaLabel}\n isDisabled={isDisabled}\n ref={iconRef}\n size=\"sm\"\n testId={testId ? testId + '_calendarIcon' : undefined}\n variant=\"ghost\"\n onAction={calendarIconActionHandler}>\n <CalendarIcon />\n </IconButton>\n );\n\n const shouldShowDropdown = isOpen as boolean;\n\n return (\n <>\n <InputDateMaskContext.Provider\n value={{ isDropdownOpen: isOpen, isInputDatePickerParent: true }}>\n <InputDateMask\n aria-describedby={ariaDescribedBy}\n assistiveText={assistiveText}\n endContent={endContent}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n isDisabled={isDisabled}\n isReadonly={isReadonly}\n label={label}\n onCommit={maskCommitHandler}\n onInput={maskInputHandler}\n mainFieldRef={mainFieldRef}\n messages={messages}\n testId={testId}\n ref={maskRef}\n userAssistanceDensity={propUserAssistanceDensity}\n value={dateValue}\n {...dateMaskProps}\n />\n </InputDateMaskContext.Provider>\n\n {maskFieldInstruction}\n\n {shouldShowDropdown && (\n <InputDatePickerDropdown\n anchorRef={mainFieldRef}\n assistiveText={assistiveText}\n dayFormatter={dayFormatter}\n daysOutsideMonth={daysOutsideMonth}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n isDisabled={isDisabled}\n isReadonly={isReadonly}\n isOpen={isOpen}\n label={label}\n onClose={dropdownCloseHandler}\n onCommit={datePickerCommitHandler}\n max={max}\n messages={messages}\n min={min}\n monthAndYearPicker={monthAndYearPicker}\n testId={testId ? testId + '_datePicker' : undefined}\n todayTimeZone={todayTimeZone}\n todayButton={todayButton}\n userAssistanceDensity={userAssistanceDensity}\n value={completeDateValue}\n weekDisplay={weekDisplay}\n />\n )}\n </>\n );\n }\n);\n"],"names":["InputDatePickerDropdown","anchorRef","assistiveText","dayFormatter","daysOutsideMonth","helpSourceLink","helpSourceText","isDisabled","isOpen","isReadonly","label","onClose","onCommit","max","messages","min","monthAndYearPicker","testId","todayButton","todayTimeZone","userAssistanceDensity","value","weekDisplay","isDropdownAbove","setDropdownAbove","useState","prevIsOpen","setPrevIsOpen","handleDropdownPosition","useCallback","data","placement","startsWith","shouldShowSheet","isPhone","datePicker_label","useTranslationBundle","datePickerAriaLabel","datePickerMainContent","_jsx","DatePicker","height","undefined","maxWidth","width","inlineUserAssistanceFooter","length","FormFieldContext","Provider","isFocused","children","jsx","class","userAssistanceStyles","InlineUserAssistance","fieldLabel","contentTestId","dropdownContent","dropdownStyles","SectionedContent","footer","hasFocusTrap","main","role","Sheet","initialFocus","StickyPositioningDropdown","onPosition","sizeOptions","isMaxWidthAdjusted","isMaxHeightAdjusted","getClientHints","deviceType","convertToCalendarDateRequired","dateVal","isCompleteCalendarDate","inputDatePickerReducer","state","action","type","dateValue","completeDateValue","useInputDatePicker","onInput","currentValue","setIsOpen","iconRef","useRef","maskRef","outsideMousedownRef","outsideMousedownTimerRef","lastCommittedDateRef","lastDateRef","lastValueFromParentRef","dateSelectedRef","dispatch","useReducer","useInputDatePickerState","calendarDatesAreDifferent","current","useEffect","previousValue","maskInputHandler","detail","maskCommitHandler","calendarIconActionHandler","dropdownCloseHandler","reason","clearTimeout","setTimeout","focus","datePickerCommitHandler","InputDatePicker","forwardRef","propDescribedBy","propUserAssistanceDensity","dateMaskProps","ref","mainFieldRef","inputDatePicker_selectDate","inputDatePicker_instruction","calendarIconAriaLabel","formUserAssistanceDensity","useFormContext","useImperativeHandle","blur","maskFieldInstructionId","useId","maskFieldInstructionText","maskFieldInstruction","HiddenAccessible","id","isHidden","ariaDescribedBy","merge","endContent","IconButton","size","variant","onAction","CalendarIcon","shouldShowDropdown","_jsxs","InputDateMaskContext","isDropdownOpen","isInputDatePickerParent","InputDateMask"],"mappings":"ylEAsEA,MAAMA,GAA0B,EAC9BC,YACAC,gBACAC,eACAC,mBACAC,iBACAC,iBACAC,aACAC,SACAC,aACAC,QACAC,UACAC,WACAC,MACAC,WACAC,MACAC,qBACAC,SACAC,cACAC,gBACAC,wBACAC,QACAC,kBAGA,MAAOC,EAAiBC,GAAoBC,EAAQA,UAAC,IAC9CC,EAAYC,GAAiBF,EAAQA,SAACjB,GACvCoB,EAAyBC,eAE5BC,IACDN,EAAiBM,EAAKC,UAAUC,WAAW,OAAO,GACjD,IAECN,IAAelB,IACjBmB,EAAcnB,GACTA,GACHgB,GAAiB,IAIrB,MAMMS,EAAkBC,MAElBC,iBAAEA,GAAqBC,EAAoBA,qBAAa,4BACxDC,EAAsBF,IAEtBG,EACJC,EAAAA,IAACC,EAAUA,YACTrC,aAAcA,EACdC,iBAAkBA,EAClBqC,OAASR,OAA2BS,EAAT,OAC3B9B,SAAUA,EACVC,IAAKA,EACLE,IAAKA,EAEL4B,SAAUV,EAAkB,YAASS,EACrCE,MAAM,OACN5B,mBAAoBA,EACpBC,OAAQA,EACRE,cAAeA,EACfD,YAAaA,EACbG,MAAOA,EACPC,YAAaA,IAIXuB,GACJrC,GACEe,IAAmBU,GACpB1B,GACAE,KACAP,GAAiBG,G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D,KACHoC,MAIPa,EAEAY,IACCtG,MAACvC,GAAuB,CACtBC,UAAWqH,EACXpH,cAAeA,EACfC,aAAcA,EACdC,iBAAkBA,EAClBC,eAAgBA,EAChBC,eAAgBA,EAChBC,WAAYA,EACZE,WAAYA,EACZD,OAAQA,EACRE,MAAOA,EACPC,QAAS+F,EACT9F,SAAUmG,EACVlG,IAAKA,EACLC,SAAUA,EACVC,IAAKA,EACLC,mBAAoBA,EACpBC,OAAQA,EAASA,EAAS,mBAAgByB,EAC1CvB,cAAeA,EACfD,YAAaA,EACbE,sBAAuBA,EACvBC,MAAO4D,EACP3D,YAAaA,MAInB"}
|
|
1
|
+
{"version":3,"file":"InputDatePicker-ecd4a7ce.js","sources":["../../src/UNSAFE_InputDatePicker/InputDatePickerDropdown.tsx","../../src/UNSAFE_InputDatePicker/useInputDatePickerState.ts","../../src/UNSAFE_InputDatePicker/useInputDatePicker.ts","../../src/UNSAFE_InputDatePicker/InputDatePicker.tsx"],"sourcesContent":["/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { ComponentProps } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport { BundleType } from '../resources/nls/bundle';\nimport { DatePicker } from '#UNSAFE_DatePicker';\nimport { type CloseDetail as DropdownCloseDetail } from '#UNSAFE_Dropdown';\nimport { getClientHints } from '#utils/PRIVATE_clientHints';\nimport { FormFieldContext } from '../hooks/UNSAFE_useFormFieldContext';\nimport { InlineUserAssistance } from '../UNSAFE_UserAssistance';\nimport { InputDatePicker } from './InputDatePicker';\nimport { dropdownStyles, userAssistanceStyles } from './themes/InputDatePickerDropdownStyles.css';\nimport { PositionData } from '../UNSAFE_Floating';\nimport { StickyPositioningDropdown } from '#PRIVATE_FormControls';\nimport { SectionedContent } from '#PRIVATE_FormControls';\nimport { type CloseDetail as SheetCloseDetail, Sheet } from '#UNSAFE_Sheet';\nimport type { TestIdProps } from '#hooks/UNSAFE_useTestId';\nimport { useTranslationBundle } from '#hooks/UNSAFE_useTranslationBundle';\nimport { SizeOptions } from '#UNSAFE_Floating/Floating'; \n\ntype StickyPositioningDropdownProps = ComponentProps<typeof StickyPositioningDropdown>;\ntype InputDatePickerProps = ComponentProps<typeof InputDatePicker>;\ntype PickedPropsFromInputDatePicker = Pick<\n InputDatePickerProps,\n | 'assistiveText'\n | 'dayFormatter'\n | 'daysOutsideMonth'\n | 'helpSourceLink'\n | 'helpSourceText'\n | 'isDisabled'\n | 'isReadonly'\n | 'label'\n | 'messages'\n | 'min'\n | 'max'\n | 'monthAndYearPicker'\n | 'todayButton'\n | 'todayTimeZone'\n | 'userAssistanceDensity'\n | 'value'\n | 'weekDisplay'\n>;\ntype DatePickerProps = ComponentProps<typeof DatePicker>;\ntype PickedPropsFromDatePicker = Pick<DatePickerProps, 'value' | 'onCommit'>;\ntype PickedPropsFromDropdown = Omit<StickyPositioningDropdownProps, 'onClose'>;\ntype CloseDetail = SheetCloseDetail | DropdownCloseDetail;\n\ntype Props = PickedPropsFromDatePicker &\n PickedPropsFromInputDatePicker &\n PickedPropsFromDropdown &\n TestIdProps & {\n /**\n * Called when the dropdown or sheet is supposed to be closed.\n */\n onClose?: (detail: CloseDetail) => void;\n };\n\n/**\n * Component that renders DatePicker either inside a dropdown or sheet; at small screen\n * widths, it renders inside a sheet. Additionally, when a dropdown is being shown beneath\n * the component, we also show any user assistance text or messages below the picker\n * because otherwise that information would be obscured from view. When a sheet is being\n * shown, it will always display UA and messages at the bottom of the sheet.\n */\nconst InputDatePickerDropdown = ({\n anchorRef,\n assistiveText,\n dayFormatter,\n daysOutsideMonth,\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isOpen,\n isReadonly,\n label,\n onClose,\n onCommit,\n max,\n messages,\n min,\n monthAndYearPicker,\n testId,\n todayButton,\n todayTimeZone,\n userAssistanceDensity,\n value,\n weekDisplay\n}: Props) => {\n // If the dropdown opens above the component, we don't want to show UA or messages.\n const [isDropdownAbove, setDropdownAbove] = useState(false);\n const [prevIsOpen, setPrevIsOpen] = useState(isOpen);\n const handleDropdownPosition = useCallback<\n NonNullable<StickyPositioningDropdownProps['onPosition']>\n >((data: PositionData) => {\n setDropdownAbove(data.placement.startsWith('top'));\n }, []);\n // Reset the flag when the dropdown is closed.\n if (prevIsOpen !== isOpen) {\n setPrevIsOpen(isOpen);\n if (!isOpen) {\n setDropdownAbove(false);\n }\n }\n\n const sizeOptions: SizeOptions = {\n isMaxWidthAdjusted: false,\n isMaxHeightAdjusted: true\n };\n\n // On mobile phones, the dropdown becomes a sheet.\n const shouldShowSheet = isPhone();\n\n const { datePicker_label } = useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const datePickerAriaLabel = datePicker_label();\n\n const datePickerMainContent = (\n <DatePicker\n dayFormatter={dayFormatter}\n daysOutsideMonth={daysOutsideMonth}\n height={!shouldShowSheet ? 'auto' : undefined}\n onCommit={onCommit}\n max={max}\n min={min}\n // for sheet, we want the width to grow to the width of the sheet, otherwise it will use the theme default.\n maxWidth={shouldShowSheet ? '100%' : undefined}\n width=\"100%\"\n monthAndYearPicker={monthAndYearPicker}\n testId={testId}\n todayTimeZone={todayTimeZone}\n todayButton={todayButton}\n value={value}\n weekDisplay={weekDisplay}\n />\n );\n\n const inlineUserAssistanceFooter =\n isOpen &&\n (!isDropdownAbove || shouldShowSheet) &&\n !isDisabled &&\n !isReadonly &&\n (assistiveText || helpSourceLink || (messages && messages.length > 0)) &&\n (userAssistanceDensity === 'efficient' || userAssistanceDensity === 'reflow') ? (\n <FormFieldContext.Provider value={{ isFocused: true }}>\n <div class={userAssistanceStyles}>\n <InlineUserAssistance\n assistiveText={assistiveText}\n fieldLabel={label}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n messages={messages}\n userAssistanceDensity={userAssistanceDensity}\n />\n </div>\n </FormFieldContext.Provider>\n ) : undefined;\n\n const contentTestId = testId ? testId + (shouldShowSheet ? '_sheet' : '_dropdown') : undefined;\n\n // The same content is displayed either in a dropdown or sheet: date picker and inline UA.\n // Add styling to the dropdown to enforce a fixed width.\n const dropdownContent = (\n <div class={dropdownStyles}>\n <SectionedContent\n aria-label={datePickerAriaLabel}\n footer={inlineUserAssistanceFooter}\n hasFocusTrap={true}\n main={datePickerMainContent}\n role=\"dialog\"\n testId={contentTestId}\n />\n </div>\n );\n\n const dropdown = shouldShowSheet ? (\n <Sheet initialFocus=\"firstFocusable\" isOpen={isOpen} onClose={onClose}>\n <SectionedContent\n aria-label={datePickerAriaLabel}\n footer={inlineUserAssistanceFooter}\n hasFocusTrap={true}\n main={datePickerMainContent}\n role=\"dialog\"\n testId={contentTestId}\n />\n </Sheet>\n ) : (\n <StickyPositioningDropdown\n anchorRef={anchorRef}\n initialFocus=\"firstFocusable\"\n isOpen={isOpen}\n onClose={onClose}\n onPosition={handleDropdownPosition}\n sizeOptions={sizeOptions}>\n {dropdownContent}\n </StickyPositioningDropdown>\n );\n\n return dropdown;\n};\n\nconst isPhone = () => {\n return getClientHints().deviceType === 'phone';\n};\n\nexport { InputDatePickerDropdown, type CloseDetail };\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { useReducer } from 'preact/hooks';\nimport type { CalendarDate, CalendarDateRequired } from '#utils/UNSAFE_calendarDateUtils';\nimport { isCompleteCalendarDate } from '#utils/UNSAFE_calendarDateUtils';\n\ntype InputDatePickerState = {\n /**\n * If dateValue is a complete date, then completeDateValue is the same as dateValue\n * otherwise is is undefined. We need to maintain separate states because\n * InputDateMask uses CalendarDate, but DatePicker uses CalendarDateRequired.\n * If the user types a partial date then opens the picker, we treat that as\n * no selection. The picker opens to the current month showing today.\n */\n completeDateValue?: CalendarDateRequired;\n\n /**\n * Represents the current date value of the component. The user either selected\n * the date in the picker, or typed it into the date field.\n */\n dateValue?: CalendarDate;\n};\n\ntype DateChangedAction = { type: 'dateChanged'; data?: CalendarDate };\ntype DateResetAction = { type: 'reset'; data?: CalendarDate };\ntype DateSelectedAction = { type: 'dateSelected'; data?: CalendarDateRequired };\ntype InputDatePickerReducerAction = DateChangedAction | DateResetAction | DateSelectedAction;\n\n// If dateVal is a complete date, return it as a CalendarDateRequired\n// otherwise return undefined.\nconst convertToCalendarDateRequired = (dateVal?: CalendarDate) => {\n return !dateVal || !isCompleteCalendarDate(dateVal)\n ? undefined\n : (dateVal as CalendarDateRequired);\n};\n\n// Use a reducer function to manage InputDatePickerState.\nconst inputDatePickerReducer = (\n state: InputDatePickerState,\n action: InputDatePickerReducerAction\n): InputDatePickerState => {\n switch (action.type) {\n case 'dateChanged': {\n return {\n ...state,\n dateValue: action.data,\n completeDateValue: convertToCalendarDateRequired(action.data)\n };\n }\n case 'dateSelected': {\n return { ...state, dateValue: action.data, completeDateValue: action.data };\n }\n case 'reset': {\n return {\n completeDateValue: convertToCalendarDateRequired(action.data),\n dateValue: action.data\n };\n }\n default:\n return state;\n }\n};\n\ntype Props = {\n /**\n * The value of the InputDatePicker, or undefined.\n */\n value?: CalendarDate;\n};\n\n/**\n * useInputDatePickerState calls useReducer to determine the initial state. Any changes to that state\n * are managed by dispatching actions to the reducer function.\n */\nconst useInputDatePickerState = ({ value }: Props) => {\n const [state, dispatch] = useReducer(inputDatePickerReducer, {\n completeDateValue: convertToCalendarDateRequired(value),\n dateValue: value\n });\n\n return { state, dispatch };\n};\n\nexport { useInputDatePickerState };\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport type { ComponentProps, RefObject } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport type { CalendarDate, CalendarDateRequired } from '#utils/UNSAFE_calendarDateUtils';\nimport { calendarDatesAreDifferent } from '#utils/PRIVATE_dayUtils';\nimport { DatePicker } from '#UNSAFE_DatePicker';\nimport { CloseDetail, InputDatePickerDropdown } from './InputDatePickerDropdown';\nimport { IconButton } from '#UNSAFE_IconButton';\nimport { InputDateMask } from '#UNSAFE_InputDateMask';\nimport { InputDatePicker } from './InputDatePicker';\nimport { useInputDatePickerState } from './useInputDatePickerState';\nimport type { ValueUpdateDetail } from '#utils/UNSAFE_valueUpdateDetail';\n\ntype InputDatePickerProps = ComponentProps<typeof InputDatePicker>;\ntype InputDateMaskProps = ComponentProps<typeof InputDateMask>;\ntype DatePickerProps = ComponentProps<typeof DatePicker>;\ntype IconButtonProps = ComponentProps<typeof IconButton>;\ntype DropdownProps = ComponentProps<typeof InputDatePickerDropdown>;\n\ntype Props = {\n onCommit: InputDatePickerProps['onCommit'];\n onInput: InputDatePickerProps['onInput'];\n value: InputDatePickerProps['value'];\n};\n\n/**\n * Hook that provides handlers and other functionality for InputDatePicker.\n */\nconst useInputDatePicker = ({ onCommit, onInput, value: currentValue }: Props) => {\n // Whether the dropdown is open.\n const [isOpen, setIsOpen] = useState(false);\n\n // Ref to the calendar icon button.\n const iconRef: RefObject<HTMLButtonElement> = useRef<HTMLButtonElement>(null);\n\n // Ref to the InputDateMask component.\n const maskRef: RefObject<HTMLElement> = useRef<HTMLElement>(null);\n\n // Keep track of whether the dropdown was just dismissed from an outside mousedown event.\n const outsideMousedownRef = useRef<boolean>(false);\n const outsideMousedownTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>();\n\n // Keep track of the last date values passed to onInput and onCommit.\n const lastCommittedDateRef = useRef<CalendarDate | undefined>(currentValue);\n const lastDateRef = useRef<CalendarDate | undefined>(currentValue);\n\n // Keep track of the last controlled value passed from the parent, so we can detect a programmatic change.\n const lastValueFromParentRef = useRef<CalendarDate | undefined>(currentValue);\n\n // Keep track of whether a date was selected in the date picker.\n const dateSelectedRef = useRef<boolean>(false);\n\n const { state, dispatch } = useInputDatePickerState({ value: currentValue });\n\n // If a new value is being pushed from the parent, and that value differs from\n // the current value of the reducer, then this is a programmatic update\n // and we need to call 'reset' to update the reducer state. Otherwise, the only\n // time the reducer state is updated from the value is on mount.\n if (calendarDatesAreDifferent(lastValueFromParentRef.current, currentValue)) {\n lastValueFromParentRef.current = currentValue;\n if (calendarDatesAreDifferent(currentValue, state.dateValue)) {\n dispatch({ type: 'reset', data: currentValue });\n lastDateRef.current = currentValue;\n lastCommittedDateRef.current = currentValue;\n }\n }\n\n // Reducer updates are async, so wait until the state updates and then call our callbacks.\n useEffect(() => {\n if (calendarDatesAreDifferent(state.dateValue, lastDateRef.current)) {\n onInput({ previousValue: lastDateRef.current, value: state.dateValue });\n lastDateRef.current = state.dateValue;\n }\n if (\n dateSelectedRef.current &&\n calendarDatesAreDifferent(state.dateValue, lastCommittedDateRef.current)\n ) {\n onCommit?.({ previousValue: lastCommittedDateRef.current, value: state.dateValue });\n lastCommittedDateRef.current = state.dateValue;\n dateSelectedRef.current = false;\n }\n }, [onCommit, onInput, state.dateValue]);\n\n // Handle onInput from InputDateMask as segment values are being added or changed in the input field.\n // We wait for the state to update before calling onInput.\n const maskInputHandler = useCallback<InputDateMaskProps['onInput']>(\n (detail: ValueUpdateDetail<CalendarDate>) => {\n dispatch({ type: 'dateChanged', data: detail.value });\n },\n [dispatch]\n );\n\n // Handle onCommit from InputDateMask, which is called when the user presses Enter or the field is blurred.\n const maskCommitHandler = useCallback<NonNullable<InputDateMaskProps['onCommit']>>(() => {\n // If the current date value differs from the last committed value, then call onCommit.\n if (calendarDatesAreDifferent(lastCommittedDateRef.current, state.dateValue)) {\n onCommit?.({ value: state.dateValue, previousValue: lastCommittedDateRef.current });\n lastCommittedDateRef.current = state.dateValue;\n }\n }, [onCommit, state.dateValue]);\n\n // Respond to onAction event from the calendar icon button. Toggles the date picker dropdown.\n const calendarIconActionHandler = useCallback<NonNullable<IconButtonProps['onAction']>>(() => {\n // Only toggle the value of isOpen if we didn't just dismiss the dropdown.\n if (!outsideMousedownRef.current) {\n setIsOpen((prevIsOpen) => !prevIsOpen);\n }\n outsideMousedownRef.current = false;\n }, []);\n\n const dropdownCloseHandler = useCallback<NonNullable<DropdownProps['onClose']>>(\n (detail: CloseDetail) => {\n // Keep track of when the dropdown is closed via outside mousedown, including when the calendar icon\n // is clicked. We need this in order to toggle visibility of the picker and dropdown.\n if (detail.reason === 'outsideMousedown') {\n outsideMousedownRef.current = true;\n clearTimeout(outsideMousedownTimerRef.current);\n\n // Clear the flag after a short delay to ensure the dropdown can be opened again.\n outsideMousedownTimerRef.current = setTimeout(() => {\n outsideMousedownRef.current = false;\n }, 200);\n } else if (detail.reason === 'dismissed' || detail.reason === 'keyboardDismissed') {\n // Focus the calendar icon when the dropdown is closed.\n iconRef.current?.focus();\n }\n setIsOpen(false);\n },\n []\n );\n\n // Handle date selection in the picker.\n // - Updates the value in state.\n // - Closes the dropdown.\n // - Sets focus to the date field.\n const datePickerCommitHandler = useCallback<DatePickerProps['onCommit']>(\n (detail: ValueUpdateDetail<CalendarDateRequired>) => {\n // Set focus to the calendar icon when a date is selected.\n iconRef.current?.focus();\n\n // Set a ref indicating a date was selected.\n dateSelectedRef.current = true;\n dispatch({ type: 'dateSelected', data: detail.value });\n setIsOpen(false);\n },\n [dispatch]\n );\n\n return {\n calendarIconActionHandler,\n datePickerCommitHandler,\n dropdownCloseHandler,\n completeDateValue: state.completeDateValue,\n dateValue: state.dateValue,\n iconRef,\n isOpen,\n maskCommitHandler,\n maskInputHandler,\n maskRef\n };\n};\n\nexport { useInputDatePicker };\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\nimport { ComponentProps, Ref } from 'preact';\nimport { forwardRef } from 'preact/compat';\nimport { useImperativeHandle, useRef } from 'preact/hooks';\nimport { BundleType } from '../resources/nls/bundle';\nimport { CalendarIcon } from '#PRIVATE_ThemedIcons/CalendarIcon';\nimport {\n CalendarDate,\n CalendarDatePlaceholders,\n InputDateMask,\n InputDateMaskContext\n} from '#UNSAFE_InputDateMask';\nimport { DatePicker } from '#UNSAFE_DatePicker';\nimport { HiddenAccessible } from '#UNSAFE_HiddenAccessible';\nimport { IconButton } from '#UNSAFE_IconButton';\nimport { InputDatePickerDropdown } from './InputDatePickerDropdown';\nimport { FocusableHandle } from '#hooks/UNSAFE_useFocusableTextField';\nimport { merge } from '#utils/UNSAFE_stringUtils';\nimport { useFormContext } from '#hooks/UNSAFE_useFormContext';\nimport { useId } from '#hooks/UNSAFE_useId';\nimport { useInputDatePicker } from './useInputDatePicker';\nimport { useTranslationBundle } from '#hooks/UNSAFE_useTranslationBundle';\nimport { ValueUpdateDetail } from '#utils/UNSAFE_valueUpdateDetail';\n\ntype InputDateMaskProps = ComponentProps<typeof InputDateMask>;\ntype PickedPropsFromInputDateMask = Pick<\n InputDateMaskProps,\n | 'aria-describedby'\n | 'assistiveText'\n | 'columnSpan'\n | 'helpSourceLink'\n | 'helpSourceText'\n | 'isDisabled'\n | 'isReadonly'\n | 'isRequired'\n | 'isRequiredShown'\n | 'label'\n | 'labelEdge'\n | 'labelStartWidth'\n | 'messages'\n | 'textAlign'\n | 'testId'\n | 'userAssistanceDensity'\n | 'variant'\n>;\n\ntype DatePickerProps = ComponentProps<typeof DatePicker>;\ntype PickedPropsFromDatePicker = Pick<\n DatePickerProps,\n | 'dayFormatter'\n | 'daysOutsideMonth'\n | 'max'\n | 'min'\n | 'monthAndYearPicker'\n | 'todayTimeZone'\n | 'todayButton'\n | 'weekDisplay'\n>;\n\ntype Props = PickedPropsFromInputDateMask &\n PickedPropsFromDatePicker & {\n /**\n * If specified, overrides the locale specific order of the individual date segments\n * in the date field as well as the locale specific separator. The value of each placeholder\n * is only used when the type is 'literal', otherwise it is replaced with a translated\n * placeholder for month, day, or year. The placeholders must include month, day, and year.\n */\n masks?: CalendarDatePlaceholders;\n\n /**\n * The current display value of the component.\n * This is a CalendarDate, not CalendarDateRequired, because this is a controlled component and\n * the user may type the month, day, and year separately. If a selection is made in the date\n * picker, then the value is a complete date.\n */\n value?: CalendarDate;\n\n /**\n * Callback invoked when the user commits the entered value by blurring or hitting the enter key.\n * It is also called when a selection is made in the date picker.\n */\n onCommit?: (detail: ValueUpdateDetail<CalendarDate>) => void;\n\n /**\n * Callback invoked each time the user changes the value of a segment. For example, if the user\n * types '12' into the month segment, this callback will be called twice to change the month\n * first to '1' and then '12'.\n */\n onInput: (detail: ValueUpdateDetail<CalendarDate>) => void;\n };\n\n/**\n * InputDatePicker allows users to enter or select a single date using a calendar interface.\n */\nexport const InputDatePicker = forwardRef(\n (\n {\n 'aria-describedby': propDescribedBy,\n assistiveText,\n dayFormatter,\n daysOutsideMonth,\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isReadonly,\n label,\n max,\n messages,\n min,\n monthAndYearPicker,\n todayTimeZone,\n todayButton,\n value,\n onCommit,\n onInput,\n testId,\n userAssistanceDensity: propUserAssistanceDensity,\n weekDisplay,\n ...dateMaskProps\n }: Props,\n ref?: Ref<FocusableHandle>\n ) => {\n const {\n calendarIconActionHandler,\n datePickerCommitHandler,\n completeDateValue,\n dateValue,\n dropdownCloseHandler,\n iconRef,\n isOpen,\n maskCommitHandler,\n maskInputHandler,\n maskRef\n } = useInputDatePicker({\n onCommit,\n onInput,\n value\n });\n\n const mainFieldRef = useRef<HTMLDivElement>(null);\n const { inputDatePicker_selectDate, inputDatePicker_instruction } =\n useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const calendarIconAriaLabel = inputDatePicker_selectDate();\n\n // We need this to determine if UA/messaging should be shown in the dropdown.\n const { userAssistanceDensity: formUserAssistanceDensity } = useFormContext();\n const userAssistanceDensity = propUserAssistanceDensity ?? formUserAssistanceDensity;\n\n useImperativeHandle(ref!, () => ({\n focus: () => {\n maskRef.current?.focus();\n },\n blur: () => {\n maskRef.current?.blur();\n }\n }));\n\n const maskFieldInstructionId = useId();\n const maskFieldInstructionText = inputDatePicker_instruction();\n const maskFieldInstruction =\n !isDisabled && !isReadonly ? (\n <HiddenAccessible id={maskFieldInstructionId} isHidden={true}>\n {maskFieldInstructionText}\n </HiddenAccessible>\n ) : undefined;\n const ariaDescribedBy =\n !isDisabled && !isReadonly\n ? merge([propDescribedBy, maskFieldInstructionId])\n : propDescribedBy;\n\n const endContent = (\n <IconButton\n aria-haspopup=\"dialog\"\n aria-label={calendarIconAriaLabel}\n isDisabled={isDisabled}\n ref={iconRef}\n size=\"sm\"\n testId={testId ? testId + '_calendarIcon' : undefined}\n variant=\"ghost\"\n onAction={calendarIconActionHandler}>\n <CalendarIcon />\n </IconButton>\n );\n\n const shouldShowDropdown = isOpen as boolean;\n\n return (\n <>\n <InputDateMaskContext.Provider\n value={{ isDropdownOpen: isOpen, isInputDatePickerParent: true }}>\n <InputDateMask\n aria-describedby={ariaDescribedBy}\n assistiveText={assistiveText}\n endContent={endContent}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n isDisabled={isDisabled}\n isReadonly={isReadonly}\n label={label}\n onCommit={maskCommitHandler}\n onInput={maskInputHandler}\n mainFieldRef={mainFieldRef}\n messages={messages}\n testId={testId}\n ref={maskRef}\n userAssistanceDensity={propUserAssistanceDensity}\n value={dateValue}\n {...dateMaskProps}\n />\n </InputDateMaskContext.Provider>\n\n {maskFieldInstruction}\n\n {shouldShowDropdown && (\n <InputDatePickerDropdown\n anchorRef={mainFieldRef}\n assistiveText={assistiveText}\n dayFormatter={dayFormatter}\n daysOutsideMonth={daysOutsideMonth}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n isDisabled={isDisabled}\n isReadonly={isReadonly}\n isOpen={isOpen}\n label={label}\n onClose={dropdownCloseHandler}\n onCommit={datePickerCommitHandler}\n max={max}\n messages={messages}\n min={min}\n monthAndYearPicker={monthAndYearPicker}\n testId={testId ? testId + '_datePicker' : undefined}\n todayTimeZone={todayTimeZone}\n todayButton={todayButton}\n userAssistanceDensity={userAssistanceDensity}\n value={completeDateValue}\n weekDisplay={weekDisplay}\n />\n )}\n </>\n );\n }\n);\n"],"names":["InputDatePickerDropdown","anchorRef","assistiveText","dayFormatter","daysOutsideMonth","helpSourceLink","helpSourceText","isDisabled","isOpen","isReadonly","label","onClose","onCommit","max","messages","min","monthAndYearPicker","testId","todayButton","todayTimeZone","userAssistanceDensity","value","weekDisplay","isDropdownAbove","setDropdownAbove","useState","prevIsOpen","setPrevIsOpen","handleDropdownPosition","useCallback","data","placement","startsWith","shouldShowSheet","isPhone","datePicker_label","useTranslationBundle","datePickerAriaLabel","datePickerMainContent","_jsx","DatePicker","height","undefined","maxWidth","width","inlineUserAssistanceFooter","length","FormFieldContext","Provider","isFocused","children","jsx","class","userAssistanceStyles","InlineUserAssistance","fieldLabel","contentTestId","dropdownContent","dropdownStyles","SectionedContent","footer","hasFocusTrap","main","role","Sheet","initialFocus","StickyPositioningDropdown","onPosition","sizeOptions","isMaxWidthAdjusted","isMaxHeightAdjusted","getClientHints","deviceType","convertToCalendarDateRequired","dateVal","isCompleteCalendarDate","inputDatePickerReducer","state","action","type","dateValue","completeDateValue","useInputDatePicker","onInput","currentValue","setIsOpen","iconRef","useRef","maskRef","outsideMousedownRef","outsideMousedownTimerRef","lastCommittedDateRef","lastDateRef","lastValueFromParentRef","dateSelectedRef","dispatch","useReducer","useInputDatePickerState","calendarDatesAreDifferent","current","useEffect","previousValue","maskInputHandler","detail","maskCommitHandler","calendarIconActionHandler","dropdownCloseHandler","reason","clearTimeout","setTimeout","focus","datePickerCommitHandler","InputDatePicker","forwardRef","propDescribedBy","propUserAssistanceDensity","dateMaskProps","ref","mainFieldRef","inputDatePicker_selectDate","inputDatePicker_instruction","calendarIconAriaLabel","formUserAssistanceDensity","useFormContext","useImperativeHandle","blur","maskFieldInstructionId","useId","maskFieldInstructionText","maskFieldInstruction","HiddenAccessible","id","isHidden","ariaDescribedBy","merge","endContent","IconButton","size","variant","onAction","CalendarIcon","shouldShowDropdown","_jsxs","InputDateMaskContext","isDropdownOpen","isInputDatePickerParent","InputDateMask"],"mappings":"ylEAsEA,MAAMA,GAA0B,EAC9BC,YACAC,gBACAC,eACAC,mBACAC,iBACAC,iBACAC,aACAC,SACAC,aACAC,QACAC,UACAC,WACAC,MACAC,WACAC,MACAC,qBACAC,SACAC,cACAC,gBACAC,wBACAC,QACAC,kBAGA,MAAOC,EAAiBC,GAAoBC,EAAQA,UAAC,IAC9CC,EAAYC,GAAiBF,EAAQA,SAACjB,GACvCoB,EAAyBC,eAE5BC,IACDN,EAAiBM,EAAKC,UAAUC,WAAW,OAAO,GACjD,IAECN,IAAelB,IACjBmB,EAAcnB,GACTA,GACHgB,GAAiB,IAIrB,MAMMS,EAAkBC,MAElBC,iBAAEA,GAAqBC,EAAoBA,qBAAa,4BACxDC,EAAsBF,IAEtBG,EACJC,EAAAA,IAACC,EAAUA,YACTrC,aAAcA,EACdC,iBAAkBA,EAClBqC,OAASR,OAA2BS,EAAT,OAC3B9B,SAAUA,EACVC,IAAKA,EACLE,IAAKA,EAEL4B,SAAUV,EAAkB,YAASS,EACrCE,MAAM,OACN5B,mBAAoBA,EACpBC,OAAQA,EACRE,cAAeA,EACfD,YAAaA,EACbG,MAAOA,EACPC,YAAaA,IAIXuB,GACJrC,GACEe,IAAmBU,GACpB1B,GACAE,KACAP,GAAiBG,GAAmBS,GAAYA,EAASgC,OAAS,IACxC,cAA1B1B,GAAmE,WAA1BA,OAatCsB,EAZFH,MAACQ,EAAAA,iBAAiBC,SAAQ,CAAC3B,MAAO,CAAE4B,WAAW,GAAMC,SACnDX,EAAKY,IAAA,MAAA,CAAAC,MAAOC,gCACVd,EAAAA,IAACe,EAAAA,qBACC,CAAApD,cAAeA,EACfqD,WAAY7C,EACZL,eAAgBA,EAChBC,eAAgBA,EAChBQ,SAAUA,EACVM,sBAAuBA,QAM3BoC,EAAgBvC,EAASA,GAAUg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aA,EACbE,sBAAuBA,EACvBC,MAAO4D,EACP3D,YAAaA,MAInB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
define(['exports', 'preact/jsx-runtime', 'preact/hooks', './useLegendContextMenu-c4a44c23', './useVisEvents-a8ea4ced', './useLegendDnd-126b0174', './mergeProps-bcfa6a92', './useItemFocus-75d6510d', './PRIVATE_BaseLegend/themes/LegendStyles.css', './useCssVars-cc825c54', './classNames-08d99695', './useTestId-c286f212', './useVisTouchResponse-88a7bb09', './stringUtils-0ae982c2', 'preact/compat', './TrackResizeContainer-c6b5de04', './useTextDimensions-030c6dbd', './hooks/PRIVATE_useVisDnd/themes/VisDndStyles.css', './LegendRendered-d8626509'], (function(e,t,n,s,i,o,a,d,r,l,m,g,h,c,u,I,x,f,y){"use strict";function v(e,t){const{itemIdx:n}=e;return-1==n?t[t.length-1]:t[n]}function b(e,t){let n=e.itemIdx;return-1==n&&(n=t.length-1),n=Math.min(t.length-1,n+1),"off"!==t[n].actionable?{sectionIdx:0,itemIdx:n}:n===t.length-1?(n-=1,{sectionIdx:0,itemIdx:n}):b({sectionIdx:0,itemIdx:n},t)}function p(e,t){let n=e.itemIdx;return-1==n&&(n=t.length-1),n=Math.max(0,n-1),"off"!==t[n].actionable?{sectionIdx:0,itemIdx:n}:p({sectionIdx:0,itemIdx:n},t)}function D(e){return{getItem:t=>v(t,e),getDetailFromInfo:t=>{if(!t||0===e.length)return{itemId:void 0,data:void 0};const n=v(t,e);return{itemId:n.id,data:n}},getPrevItemInfo:t=>p(t,e),getNextItemInfo:t=>b(t,e)}}const S=({width:e,getTextDimensions:t,resolvedVars:n,orientation:s,legendFontStylesObj:i={},symbolWidth:o,items:a})=>{let d=0,r=0,l=0,m=!1;const g=e;if(!Object.keys(n).length||!t)return;const h=parseFloat(n.unit),{maxItemWidth:c,maxItemHeight:u,horizontalSectionWidth:I}=R(a,h,t,i,o);l=I,d=c,r=u,m=I>g;return{totalWidth:l,maxItemWidth:Math.min(d,g),maxItemHeight:r,itemsPerRow:"vertical"===s?1:Math.max(1,Math.floor(g/d)),isWrapped:m}},R=(e,t,n,s,i,o)=>{let a=0,d=0,r=0,l=0,m=0;return l=i?1.5*t+i:4*t,m=o?o+1.7*t:2.5*t+1.7*t,e?.forEach((e=>{const i=e,{width:o,height:g}=n(i.text,s),h=2.5*t+o;r+=l+h,a=Math.max(a,l+h),d=Math.max(d,g,m)})),{maxItemWidth:a,maxItemHeight:d,horizontalSectionWidth:r}};const M=u.forwardRef((({orientation:e="horizontal",items:v,isReadOnly:b=!0,onItemAction:p,onItemHover:R,onItemFocus:M,testId:W,contextMenuConfig:C,hideAndShowBehavior:P="off",hoverBehavior:F="none",halign:T="start",valign:L="top",...V},H=null)=>{const{isGetPreferredSizeReady:w,width:j,height:E}=n.useContext(y.LegendRenderedContext),{textMeasureContent:O,getTextDimensions:z}=x.useTextDimensions(),{resolvedVars:A,cssContent:N}=l.useCssVars(o.legendVars),B=o.getLegendTextStyle({fontStyle:V.textFontStyle,fontSize:V.textFontSize?.toString(),fontWeight:V.textFontWeight?.toString(),fontFamily:V.textFontFamily},A),k=n.useRef(null);u.useImperativeHandle(H,(()=>({_getPreferredSize:(t,n)=>function(e,t,n,s,i,a,d,r,l){if(!l)return;const m=S({width:e,getTextDimensions:l,resolvedVars:s,orientation:i,legendFontStylesObj:a,symbolWidth:d,symbolHeight:r,items:n}),{itemsPerCol:g,itemsPerRow:h}=o.getGridNums(n.length,m,i),c=parseFloat(s.unit),u=Math.min(e,1===g?m.totalWidth:h?m.maxItemWidth*h:m.totalWidth),I=.8*c,x=1.5*c,f=g?m.maxItemHeight*g+(g-1)*I+x:m.maxItemHeight+x,y=Math.min(t,f);return{width:Math.ceil(u),height:Math.ceil(y)}}(t,n,v,A,e,B,V.symbolWidth,V.symbolHeight,z)})),[z,A,e,B,V.symbolWidth,V.symbolHeight,v]),z&&null!=A.unit&&null!=A.fontSize&&w?.(!0);const $=g.useTestId(W),G=void 0!==$["data-testid"],_=n.useRef(),{getItem:U,getDetailFromInfo:q,getPrevItemInfo:K,getNextItemInfo:J}=D(v),Q=o.getIsLegendItemActionable(v,b),X=v.length>0,{touchResponse:Y,touchResponseStyle:Z}=h.useVisTouchResponse({type:"touchStart"}),{focusedItemInfo:ee,hoveredItemInfo:te,onContextMenuDismissed:ne,activeId:se,eventsProps:ie}=i.useVisEvent(Y,!b,Q,((e,t,n)=>o.getKeyUpHandler(e,t,n,null!=V.hiddenIds)),q,K,J,p,R,M,o.isEqualItem,o.getItemInfo,{itemIdx:0,sectionIdx:0},null!=V.hiddenIds),{focusedItemRef:oe}=d.useItemFocus(ee),ae=o.getDatatipText(v,U,ee,te),[de,re]=n.useState(!1),{datatipContent:le,datatipProps:{"aria-describedby":me,...ge}}=s.useLegendDatatip({text:ae,rootDimsRef:_,focusedItemInfo:ee,focusedItemRef:oe,touchResponse:Y,isDisabled:de}),he=o.getAriaProps(b,V["aria-label"],V.hiddenIds,c.merge([V["aria-describedby"],me]),V["aria-labelledby"]),{contextMenuContent:ce,contextMenuProps:ue}=s.useLegendContextMenu({rootRef:k,contextMenuConfig:X?C:void 0,focusedItemInfo:ee,items:v,isReadOnly:b,onContextMenuDismissed:ne}),[Ie,xe]=n.useState(),{draggable:fe,dndProps:ye,dndContent:ve}=o.useLegendDnd({onDrag:V.onDrag,onDragStart:V.onDragStart,onDragEnd:V.onDragEnd,onDragEnter:V.onDragEnter,onDragLeave:V.onDragLeave,onDragOver:V.onDragOver,onDrop:V.onDrop,items:v,setDragOver:xe,setDatatipDisabled:re,itemDraggable:V.itemDraggable}),be=a.mergeProps(ie,ge,ue,ye),{legendStyle:pe,renderedLegendStyle:De}=r.styles;return t.jsxs(t.Fragment,{children:[!w&&t.jsx(I.TrackResizeContainer,{width:j?`${j}px`:"100%",height:E?`${E}px`:"100%",class:m.classNames([r.styles.flexStyle,r.styles[`${T}HAlign`],r.styles[`${L}VAlign`]]),children:function(i){const a=n.useMemo((()=>S({width:i,getTextDimensions:z,resolvedVars:A,orientation:e,legendFontStylesObj:B,symbolWidth:V.symbolWidth,symbolHeight:V.symbolHeight,items:v})),[i]),{itemsPerCol:d,itemsPerRow:r}=o.getGridNums(v.length,a);return t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:k,tabIndex:b?void 0:0,role:"application",draggable:fe,class:m.classNames([pe,De,Ie?f.styles.dndDragOverHTMLStyle:!1===Ie?f.styles.dndRejectedStyle:void 0]),style:Z,...$,...he,...be,"aria-activedescendant":se,children:t.jsx(s.BaseLegend,{...V,focusedItemRef:oe,items:v,isReadOnly:b,orientation:e,sectionIdx:0,itemsPerRow:r,itemsPerCol:d,itemWidth:a?.isWrapped?a?.maxItemWidth:void 0,focusedItemInfo:ee,hoveredItemInfo:te,activeId:se,hideAndShowBehavior:P,hoverBehavior:F,isTestEnv:G})}),le,ce,ve]})}}),O,N]})}));e.Legend=M}));
|
|
2
|
+
//# sourceMappingURL=Legend-6fa54628.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Legend-6fa54628.js","sources":["../../src/UNSAFE_Legend/legendNavUtils.ts","../../src/UNSAFE_Legend/getLegendLayout.ts","../../src/UNSAFE_Legend/Legend.tsx"],"sourcesContent":["/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport {\n ItemActionDetail,\n ItemFocusDetail,\n ItemHoverDetail,\n ItemInfo,\n LegendItemData\n} from '#utils/UNSAFE_visTypes/legend';\n\nfunction getItem<K, D extends LegendItemData<K>>(itemInfo: ItemInfo, items: D[]) {\n const { itemIdx } = itemInfo;\n\n if (itemIdx == -1) {\n return items[items.length - 1];\n }\n return items[itemIdx];\n}\n\nfunction getNextItemInfo<K>(itemInfo: ItemInfo, items: LegendItemData<K>[]) {\n let itemIdx = itemInfo.itemIdx;\n\n if (itemIdx == -1) {\n itemIdx = items.length - 1;\n }\n\n itemIdx = Math.min(items.length - 1, itemIdx + 1);\n if (items[itemIdx].actionable !== 'off') {\n return { sectionIdx: 0, itemIdx };\n } else if (itemIdx === items.length - 1) {\n itemIdx = itemIdx - 1;\n return { sectionIdx: 0, itemIdx };\n }\n\n return getNextItemInfo({ sectionIdx: 0, itemIdx }, items);\n}\n\nfunction getPrevItemInfo<K>(itemInfo: ItemInfo, items: LegendItemData<K>[]) {\n let itemIdx = itemInfo.itemIdx;\n\n if (itemIdx == -1) {\n itemIdx = items.length - 1;\n }\n\n itemIdx = Math.max(0, itemIdx - 1);\n if (items[itemIdx].actionable !== 'off') {\n return { sectionIdx: 0, itemIdx };\n }\n\n return getPrevItemInfo({ sectionIdx: 0, itemIdx }, items);\n}\n\n/**\n * Returns utils functions for navigation in simple legend.\n * @param items\n * @returns\n */\nexport function getLegendNavUtils<K extends string | number, D extends LegendItemData<K>>(\n items: D[]\n) {\n return {\n getItem: (itemInfo: ItemInfo) => {\n return getItem(itemInfo, items);\n },\n getDetailFromInfo: (\n itemInfo?: ItemInfo\n ): ItemFocusDetail<K, D> | ItemHoverDetail<K, D> | ItemActionDetail<K, D> => {\n if (!itemInfo || items.length === 0) {\n return { itemId: undefined, data: undefined };\n }\n const item = getItem(itemInfo, items);\n return { itemId: item.id, data: item };\n },\n getPrevItemInfo: (itemInfo: ItemInfo) => {\n return getPrevItemInfo(itemInfo, items);\n },\n getNextItemInfo: (itemInfo: ItemInfo) => {\n return getNextItemInfo(itemInfo, items);\n }\n };\n}\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { LegendItemData } from '#utils/UNSAFE_visTypes/legend';\nimport { Font, TextDimensions, useTextDimensions } from '#hooks/PRIVATE_useTextDimensions';\nimport { getGridNums } from '#utils/PRIVATE_legendUtils/legendUtils';\n\ntype Props<K> = {\n width: number;\n getTextDimensions?: ((textString: string, font?: Font | undefined) => TextDimensions) | undefined;\n resolvedVars: Record<string, any>;\n orientation?: 'vertical' | 'horizontal';\n legendFontStylesObj?: Font;\n symbolWidth?: number;\n symbolHeight?: number;\n items: LegendItemData<K>[];\n};\nexport type LayoutInfo = {\n totalWidth: number;\n maxItemWidth: number;\n maxItemHeight: number;\n itemsPerRow: number;\n isWrapped?: boolean;\n};\ntype getTextDimensionsType = NonNullable<\n NonNullable<ReturnType<typeof useTextDimensions>>['getTextDimensions']\n>;\n\nexport const getLinearLegendLayoutInfo = <K>({\n width,\n getTextDimensions,\n resolvedVars,\n orientation,\n legendFontStylesObj = {},\n symbolWidth,\n items\n}: Props<K>) => {\n let maxWidth = 0;\n let maxHeight = 0;\n let totalWidth = 0;\n let isWrapped = false;\n\n const containerWidth = width;\n\n if (!Object.keys(resolvedVars).length || !getTextDimensions) {\n return;\n }\n\n const unitLength = parseFloat(resolvedVars['unit']);\n\n const { maxItemWidth, maxItemHeight, horizontalSectionWidth } = getMaxWidth(\n items,\n unitLength,\n getTextDimensions,\n legendFontStylesObj,\n symbolWidth\n );\n totalWidth = horizontalSectionWidth;\n maxWidth = maxItemWidth;\n maxHeight = maxItemHeight;\n isWrapped = horizontalSectionWidth > containerWidth!;\n\n const legendLayoutInfo = {\n totalWidth,\n maxItemWidth: Math.min(maxWidth, containerWidth!),\n maxItemHeight: maxHeight,\n itemsPerRow:\n orientation === 'vertical' ? 1 : Math.max(1, Math.floor(containerWidth / maxWidth)),\n isWrapped\n };\n\n return legendLayoutInfo;\n};\n\n/**\n * Returns maximum of the width among the items in a section of legend also return the width of the entire section.\n * @param items Legend items array\n * @param unitLength Base element\n * @param getTextDimensions Text width measurement function\n * @param legendFontStylesObj Legend text font style properties object\n * @param symbolWidth Width of legend symbol\n *\n * @returns\n */\nconst getMaxWidth = <K>(\n items: LegendItemData<K>[],\n unitLength: number,\n getTextDimensions: getTextDimensionsType,\n legendFontStylesObj?: Font,\n symbolWidth?: number,\n symbolHeight?: number\n) => {\n let maxItemWidth = 0;\n let maxItemHeight = 0;\n let horizontalSectionWidth = 0;\n let itemSymbolWidth = 0;\n let itemSymbolHeight = 0;\n if (symbolWidth) {\n itemSymbolWidth = unitLength * 1.5 + symbolWidth;\n } else {\n //itemSymbolWidth = marginLeft + marginRight + width below expression is simplified\n itemSymbolWidth = 4 * unitLength;\n }\n\n if (symbolHeight) {\n // symbolHeight/defaultSymbolHeight + symbolPaddingTopBottom\n itemSymbolHeight = symbolHeight + unitLength * 1.7;\n } else {\n // symbolHeight/defaultSymbolHeight + symbolPaddingTopBottom\n itemSymbolHeight = 2.5 * unitLength + unitLength * 1.7;\n }\n\n items?.forEach((item) => {\n const legendItem = item as LegendItemData<K>;\n const { width, height } = getTextDimensions(legendItem.text, legendFontStylesObj);\n //itemTextWidth = paddingLeft + paddingRight + width\n const itemTextWidth = unitLength * 2.5 + width;\n //horizontalSectionWidth = total width of the section\n horizontalSectionWidth += itemSymbolWidth + itemTextWidth;\n maxItemWidth = Math.max(maxItemWidth, itemSymbolWidth + itemTextWidth);\n maxItemHeight = Math.max(maxItemHeight, height, itemSymbolHeight);\n });\n\n return { maxItemWidth, maxItemHeight, horizontalSectionWidth };\n};\n\nexport function _getPreferredSize<K>(\n _width: number,\n _height: number,\n items: LegendItemData<K>[],\n resolvedVars: Record<string, any>,\n orientation: 'vertical' | 'horizontal',\n legendFontStylesObj: Record<string, any>,\n symbolWidth?: number,\n symbolHeight?: number,\n getTextDimensions?: (textString: string, font?: Font | undefined) => TextDimensions\n) {\n if (!getTextDimensions) {\n return undefined;\n }\n const layoutInfo = getLinearLegendLayoutInfo({\n width: _width,\n getTextDimensions,\n resolvedVars,\n orientation,\n legendFontStylesObj,\n symbolWidth: symbolWidth,\n symbolHeight: symbolHeight,\n items\n });\n const { itemsPerCol, itemsPerRow } = getGridNums(items.length, layoutInfo, orientation);\n const unitLength = parseFloat(resolvedVars['unit']);\n const preferredWidth = Math.min(\n _width,\n itemsPerCol === 1\n ? layoutInfo!.totalWidth\n : itemsPerRow\n ? layoutInfo!.maxItemWidth * itemsPerRow!\n : layoutInfo!.totalWidth\n );\n const paddingLegendItems = 0.8 * unitLength;\n const paddingLegendTopBottom = 1.5 * unitLength;\n\n const legendHeight = itemsPerCol\n ? layoutInfo!.maxItemHeight * itemsPerCol! +\n (itemsPerCol! - 1) * paddingLegendItems +\n paddingLegendTopBottom\n : layoutInfo!.maxItemHeight + paddingLegendTopBottom;\n const preferredHeight = Math.min(_height, legendHeight);\n\n return { width: Math.ceil(preferredWidth), height: Math.ceil(preferredHeight) };\n}\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\nimport { Ref, VNode } from 'preact';\nimport { useContext, useMemo, useRef, useState } from 'preact/hooks';\nimport { BaseLegend } from '#PRIVATE_BaseLegend/BaseLegend';\nimport { useVisEvent } from '#hooks/PRIVATE_useVisEvents/useVisEvents';\nimport { LegendProps, LegendDragStartDetail } from './legend.type';\nimport { getLegendNavUtils } from './legendNavUtils';\nimport {\n getAriaProps,\n getDatatipText,\n getGridNums,\n getIsLegendItemActionable,\n getItemInfo,\n getLegendTextStyle,\n isEqualItem\n} from '#utils/PRIVATE_legendUtils/legendUtils';\nimport { mergeProps } from '#utils/UNSAFE_mergeProps';\nimport { useLegendDatatip } from './useLegendDatatip';\nimport { useItemFocus } from '#hooks/PRIVATE_useVisEvents';\nimport { styles } from '#PRIVATE_BaseLegend/themes/LegendStyles.css';\nimport { useCssVars } from '#hooks/PRIVATE_useCssVars';\nimport { legendVars, getKeyUpHandler } from '#utils/PRIVATE_legendUtils/legendUtils';\nimport { classNames } from '#utils/UNSAFE_classNames';\nimport { useTestId } from '#hooks/UNSAFE_useTestId';\nimport { useLegendContextMenu } from '#PRIVATE_BaseLegend/useLegendContextMenu';\nimport {\n ItemFocusDetail,\n ItemActionDetail,\n ItemInfo,\n LegendItemData\n} from '#utils/UNSAFE_visTypes/legend';\nimport { useVisTouchResponse } from '#hooks/PRIVATE_useVisTouchResponse';\nimport { merge } from '#utils/UNSAFE_stringUtils';\nimport { forwardRef, useImperativeHandle } from 'preact/compat';\nimport { TrackResizeContainer } from '#UNSAFE_TrackResizeContainer';\nimport { useTextDimensions } from '#hooks/PRIVATE_useTextDimensions';\nimport { _getPreferredSize, getLinearLegendLayoutInfo } from './getLegendLayout';\nimport { useLegendDnd } from '#hooks/PRIVATE_useLegendDnD/useLegendDnd';\nimport { styles as VisDndStyles } from '#hooks/PRIVATE_useVisDnd/themes/VisDndStyles.css';\nimport { LegendRenderedContext } from '#hooks/UNSAFE_useLegendPreferredSize';\n\nexport type SizeHandle = {\n _getPreferredSize: (\n _width: number,\n _height: number\n ) => { width: number; height: number } | undefined;\n};\n\ntype ForwardRefLegend = <K extends string | number, D extends LegendItemData<K>>(\n props: LegendProps<K, D> & { ref?: Ref<SizeHandle> }\n) => VNode | null;\n\n/**\n * A legend displays an interactive description of symbols, colors, etc., used in graphical information representations.\n */\nexport const Legend = forwardRef(\n <K extends string | number, D extends LegendItemData<K>>(\n {\n orientation = 'horizontal',\n items,\n isReadOnly = true,\n onItemAction,\n onItemHover,\n onItemFocus,\n testId,\n contextMenuConfig,\n hideAndShowBehavior = 'off',\n hoverBehavior = 'none',\n halign = 'start',\n valign = 'top',\n ...props\n }: LegendProps<K, D>,\n ref: Ref<SizeHandle> = null\n ) => {\n // Use the context\n const { isGetPreferredSizeReady, width, height } = useContext(LegendRenderedContext);\n const { textMeasureContent, getTextDimensions } = useTextDimensions();\n const { resolvedVars, cssContent } = useCssVars(legendVars);\n\n const legendFontStylesObj = getLegendTextStyle(\n {\n fontStyle: props.textFontStyle,\n fontSize: props.textFontSize?.toString(),\n fontWeight: props.textFontWeight?.toString(),\n fontFamily: props.textFontFamily\n },\n resolvedVars\n );\n const rootRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(\n ref!,\n () => ({\n _getPreferredSize: (_width: number, _height: number) => {\n return _getPreferredSize(\n _width,\n _height,\n items,\n resolvedVars,\n orientation,\n legendFontStylesObj,\n props.symbolWidth,\n props.symbolHeight,\n getTextDimensions\n );\n }\n }),\n [\n getTextDimensions,\n resolvedVars,\n orientation,\n legendFontStylesObj,\n props.symbolWidth,\n props.symbolHeight,\n items\n ]\n );\n\n if (\n getTextDimensions &&\n resolvedVars['unit'] != undefined &&\n resolvedVars['fontSize'] != undefined\n ) {\n isGetPreferredSizeReady?.(true);\n }\n\n const testIdProps = useTestId(testId);\n const isTestEnv = testIdProps['data-testid'] !== undefined;\n const rootDimsRef = useRef<DOMRect>();\n const { getItem, getDetailFromInfo, getPrevItemInfo, getNextItemInfo } = getLegendNavUtils<\n K,\n D\n >(items);\n\n const isLegendItemActionable = getIsLegendItemActionable(items, isReadOnly);\n const hasData = items.length > 0;\n\n const legendKeyUpHandler = (\n triggerOnAction: () => void,\n updatefocusedItemInfo: (itemInfo: ItemInfo) => void,\n focusedItemInfo: ItemInfo\n ) =>\n getKeyUpHandler(\n triggerOnAction,\n updatefocusedItemInfo,\n focusedItemInfo,\n props.hiddenIds != null\n );\n\n const { touchResponse, touchResponseStyle } = useVisTouchResponse({\n type: 'touchStart'\n });\n const { focusedItemInfo, hoveredItemInfo, onContextMenuDismissed, activeId, eventsProps } =\n useVisEvent<ItemInfo, ItemActionDetail<K, D>, ItemFocusDetail<K, D>, D>(\n touchResponse,\n !isReadOnly,\n isLegendItemActionable,\n legendKeyUpHandler,\n getDetailFromInfo,\n getPrevItemInfo,\n getNextItemInfo,\n onItemAction,\n onItemHover,\n onItemFocus,\n isEqualItem,\n getItemInfo,\n { itemIdx: 0, sectionIdx: 0 },\n props.hiddenIds != null\n );\n\n const { focusedItemRef } = useItemFocus(focusedItemInfo);\n const datatipText = getDatatipText(items, getItem, focusedItemInfo, hoveredItemInfo);\n const [datatipDisabled, setDatatipDisabled] = useState(false);\n const {\n datatipContent,\n datatipProps: { 'aria-describedby': datatipAriaDescribedby, ...datatipProps }\n } = useLegendDatatip({\n text: datatipText,\n rootDimsRef,\n focusedItemInfo,\n focusedItemRef,\n touchResponse,\n isDisabled: datatipDisabled\n });\n\n const ariaProps = getAriaProps<K>(\n isReadOnly,\n props['aria-label'],\n props.hiddenIds,\n merge([props['aria-describedby'], datatipAriaDescribedby]),\n props['aria-labelledby']\n );\n\n const { contextMenuContent, contextMenuProps } = useLegendContextMenu<D>({\n rootRef,\n contextMenuConfig: hasData ? contextMenuConfig : undefined,\n focusedItemInfo,\n items,\n isReadOnly,\n onContextMenuDismissed\n });\n\n const [dragOver, setDragOver] = useState<boolean>();\n\n const { draggable, dndProps, dndContent } = useLegendDnd<K, D, LegendDragStartDetail<D>>({\n onDrag: props.onDrag,\n onDragStart: props.onDragStart,\n onDragEnd: props.onDragEnd,\n onDragEnter: props.onDragEnter,\n onDragLeave: props.onDragLeave,\n onDragOver: props.onDragOver,\n onDrop: props.onDrop,\n items,\n setDragOver,\n setDatatipDisabled,\n itemDraggable: props.itemDraggable\n });\n\n const mergedProps = mergeProps(eventsProps, datatipProps, contextMenuProps, dndProps);\n const { legendStyle, renderedLegendStyle } = styles;\n\n return (\n <>\n {!isGetPreferredSizeReady && (\n <TrackResizeContainer\n width={width ? `${width}px` : '100%'}\n height={height ? `${height}px` : '100%'}\n class={classNames([\n styles.flexStyle,\n styles[`${halign}HAlign`],\n styles[`${valign}VAlign`]\n ])}>\n {function _(width) {\n const layoutInfo = useMemo(\n () =>\n getLinearLegendLayoutInfo<K>({\n width,\n getTextDimensions,\n resolvedVars,\n orientation,\n legendFontStylesObj,\n symbolWidth: props.symbolWidth,\n symbolHeight: props.symbolHeight,\n items\n }),\n [width]\n );\n const { itemsPerCol, itemsPerRow } = getGridNums(items.length, layoutInfo);\n return (\n <>\n <div\n ref={rootRef}\n tabIndex={isReadOnly ? undefined : 0}\n role=\"application\"\n draggable={draggable}\n class={classNames([\n legendStyle,\n renderedLegendStyle,\n dragOver\n ? VisDndStyles.dndDragOverHTMLStyle\n : dragOver === false\n ? VisDndStyles.dndRejectedStyle\n : undefined\n ])}\n style={touchResponseStyle}\n {...testIdProps}\n {...ariaProps}\n {...mergedProps}\n aria-activedescendant={activeId}>\n <BaseLegend\n {...props}\n focusedItemRef={focusedItemRef}\n items={items}\n isReadOnly={isReadOnly}\n orientation={orientation}\n sectionIdx={0}\n itemsPerRow={itemsPerRow}\n itemsPerCol={itemsPerCol}\n itemWidth={layoutInfo?.isWrapped ? layoutInfo?.maxItemWidth : undefined}\n focusedItemInfo={focusedItemInfo}\n hoveredItemInfo={hoveredItemInfo}\n activeId={activeId}\n hideAndShowBehavior={hideAndShowBehavior}\n hoverBehavior={hoverBehavior}\n isTestEnv={isTestEnv}\n />\n </div>\n {datatipContent}\n {contextMenuContent}\n {dndContent}\n </>\n );\n }}\n </TrackResizeContainer>\n )}\n {textMeasureContent}\n {cssContent}\n </>\n );\n }\n) as ForwardRefLegend;\n"],"names":["getItem","itemInfo","items","itemIdx","length","getNextItemInfo","Math","min","actionable","sectionIdx","getPrevItemInfo","max","getLegendNavUtils","getDetailFromInfo","itemId","undefined","data","item","id","getLinearLegendLayoutInfo","width","getTextDimensions","resolvedVars","orientation","legendFontStylesObj","symbolWidth","maxWidth","maxHeight","totalWidth","isWrapped","containerWidth","Object","keys","unitLength","parseFloat","maxItemWidth","maxItemHeight","horizontalSectionWidth","getMaxWidth","itemsPerRow","floor","symbolHeight","itemSymbolWidth","itemSymbolHeight","forEach","legendItem","height","text","itemTextWidth","Legend","forwardRef","isReadOnly","onItemAction","onItemHover","onItemFocus","testId","contextMenuConfig","hideAndShowBehavior","hoverBehavior","halign","valign","props","ref","isGetPreferredSizeReady","useContext","LegendRenderedContext","textMeasureContent","useTextDimensions","cssContent","useCssVars","legendVars","getLegendTextStyle","fontStyle","textFontStyle","fontSize","textFontSize","toString","fontWeight","textFontWeight","fontFamily","textFontFamily","rootRef","useRef","useImperativeHandle","_getPreferredSize","_width","_height","layoutInfo","itemsPerCol","getGridNums","preferredWidth","paddingLegendItems","paddingLegendTopBottom","legendHeight","preferredHeight","ceil","testIdProps","useTestId","isTestEnv","rootDimsRef","isLegendItemActionable","getIsLegendItemActionable","hasData","touchResponse","touchResponseStyle","useVisTouchResponse","type","focusedItemInfo","hoveredItemInfo","onContextMenuDismissed","activeId","eventsProps","useVisEvent","triggerOnAction","updatefocusedItemInfo","getKeyUpHandler","hiddenIds","isEqualItem","getItemInfo","focusedItemRef","useItemFocus","datatipText","getDatatipText","datatipDisabled","setDatatipDisabled","useState","datatipContent","datatipProps","datatipAriaDescribedby","useLegendDatatip","isDisabled","ariaProps","getAriaProps","merge","contextMenuContent","contextMenuProps","useLegendContextMenu","dragOver","setDragOver","draggable","dndProps","dndContent","useLegendDnd","onDrag","onDragStart","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop","itemDraggable","mergedProps","mergeProps","legendStyle","renderedLegendStyle","styles","_jsxs","_Fragment","children","_jsx","TrackResizeContainer","class","classNames","flexStyle","useMemo","jsxs","Fragment","tabIndex","role","VisDndStyles","dndDragOverHTMLStyle","dndRejectedStyle","style","BaseLegend","itemWidth"],"mappings":"8kBAgBA,SAASA,EAAwCC,EAAoBC,GACnE,MAAMC,QAAEA,GAAYF,EAEpB,OAAgB,GAAZE,EACKD,EAAMA,EAAME,OAAS,GAEvBF,EAAMC,EACf,CAEA,SAASE,EAAmBJ,EAAoBC,GAC9C,IAAIC,EAAUF,EAASE,QAOvB,OALgB,GAAZA,IACFA,EAAUD,EAAME,OAAS,GAG3BD,EAAUG,KAAKC,IAAIL,EAAME,OAAS,EAAGD,EAAU,GACb,QAA9BD,EAAMC,GAASK,WACV,CAAEC,WAAY,EAAGN,WACfA,IAAYD,EAAME,OAAS,GACpCD,GAAoB,EACb,CAAEM,WAAY,EAAGN,YAGnBE,EAAgB,CAAEI,WAAY,EAAGN,WAAWD,EACrD,CAEA,SAASQ,EAAmBT,EAAoBC,GAC9C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A,OAAOQ,UACPR,EAAAA,OAAO,GAAGhG,WACVgG,EAAAA,OAAO,GAAG/F,aAEXkG,SAAA,SAAW1I,GACV,MAAMmE,EAAa6E,WACjB,IACEjJ,EAA6B,CAC3BC,QACAC,oBACAC,eACAC,cACAC,sBACAC,YAAaoC,EAAMpC,YACnBgB,aAAcoB,EAAMpB,aACpBvC,WAEJ,CAACkB,KAEGoE,YAAEA,EAAWjD,YAAEA,GAAgBkD,EAAWA,YAACvF,EAAME,OAAQmF,GAC/D,OACEqE,EAAAS,KAAAR,EAAAS,SAAA,CAAAR,SAAA,CACEC,EAAAA,IACE,MAAA,CAAAjG,IAAKmB,EACLsF,SAAUpH,OAAapC,EAAY,EACnCyJ,KAAK,cACL7B,UAAWA,GACXsB,MAAOC,aAAW,CAChBT,GACAC,GACAjB,GACIgC,EAAAA,OAAaC,sBACA,IAAbjC,GACAgC,EAAAA,OAAaE,sBACb5J,IAEN6J,MAAOpE,KACHR,KACAmC,MACAoB,2BACmBzC,GAAQgD,SAC/BC,MAACc,EAAUA,WAAA,IACLhH,EACJ0D,eAAgBA,GAChBrH,MAAOA,EACPiD,WAAYA,EACZ5B,YAAaA,EACbd,WAAY,EACZ8B,YAAaA,EACbiD,YAAaA,EACbsF,UAAWvF,GAAY1D,UAAY0D,GAAYpD,kBAAepB,EAC9D4F,gBAAiBA,GACjBC,gBAAiBA,GACjBE,SAAUA,GACVrD,oBAAqBA,EACrBC,cAAeA,EACfwC,UAAWA,MAGd4B,GACAQ,GACAO,KAGN,IAGJ3E,EACAE,IAEH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendRendered-d8626509.js","sources":["../../src/hooks/UNSAFE_useLegendPreferredSize/LegendRendered.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { createContext } from 'preact/compat';\n\ntype LegendRenderedContextType = {\n
|
|
1
|
+
{"version":3,"file":"LegendRendered-d8626509.js","sources":["../../src/hooks/UNSAFE_useLegendPreferredSize/LegendRendered.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { createContext } from 'preact/compat';\n\ntype LegendRenderedContextType = {\n isGetPreferredSizeReady?: (isReady: boolean) => void;\n width?: number;\n height?: number;\n};\n\nexport const LegendRenderedContext = createContext<LegendRenderedContextType>({});\n"],"names":["LegendRenderedContext","createContext"],"mappings":"qEAgBaA,EAAwBC,EAAaA,cAA4B,CAAE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
define(['exports', 'preact/jsx-runtime', 'preact/hooks', './classNames-08d99695', './usePress-949a0d03', './FormFieldContext-3c44aaaa', './useFormFieldContext-8196183c', 'css!./MaxLengthCounterStyles.styles.css'], (function(s,e,n,t,a,r,l,c){"use strict";var o="MaxLengthCounterStyles_spanStyles__7dy9j72";const u=()=>{};s.MaxLengthCounter=function({maxLength:s,valueLength:r=0,onClick:c}){const{isFocused:d}=l.useFormFieldContext(),i=n.useCallback((s=>s.preventDefault()),[]),x=t.classNames([!d&&"MaxLengthCounterStyles_hide__7dy9j71"]),{pressProps:h}=a.usePress(c??u);return e.jsx("div",{class:"MaxLengthCounterStyles_maxLengthCounterBase__7dy9j70",onMouseDown:i,...h,children:e.jsxs("span",{class:x,children:[e.jsx("span",{class:o,children:r}),e.jsx("span",{class:o,children:"/"}),e.jsx("span",{class:o,children:s})]})})}}));
|
|
2
|
+
//# sourceMappingURL=MaxLengthCounter-9a95922c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxLengthCounter-9a95922c.js","sources":["../../src/UNSAFE_TextArea/MaxLengthCounter.tsx"],"sourcesContent":["import { useCallback } from 'preact/hooks';\n\nimport { classNames } from '../utils/UNSAFE_classNames';\nimport { usePress } from '../hooks/UNSAFE_usePress';\nimport { useFormFieldContext } from '../hooks/UNSAFE_useFormFieldContext';\nimport { hide, maxLengthCounterBase, spanStyles } from './MaxLengthCounterStyles.css';\n\ntype Props = {\n maxLength: number;\n valueLength?: number;\n onClick?: () => void; // the calling component should focus on the appropriate element when clicked.\n};\n\nconst noop = () => {};\n\nexport function MaxLengthCounter({ maxLength, valueLength = 0, onClick }: Props) {\n const { isFocused } = useFormFieldContext();\n // We don't want mousedown on this component to do anything, so prevent the default behavior.\n const killEvent = useCallback((event: Event) => event.preventDefault(), []);\n const textClasses = classNames([!isFocused && hide]);\n const { pressProps } = usePress(onClick ?? noop);\n return (\n <div class={maxLengthCounterBase} onMouseDown={killEvent} {...pressProps}>\n <span class={textClasses}>\n <span class={spanStyles}>{valueLength}</span>\n <span class={spanStyles}>/</span>\n <span class={spanStyles}>{maxLength}</span>\n </span>\n </div>\n );\n}\n"],"names":["noop","maxLength","valueLength","onClick","isFocused","useFormFieldContext","killEvent","useCallback","event","preventDefault","textClasses","classNames","pressProps","usePress","_jsx","jsx","class","onMouseDown","_jsxs","jsxs","children","spanStyles"],"mappings":"qSAaA,MAAMA,EAAO,0BAEP,UAA2BC,UAAEA,EAASC,YAAEA,EAAc,EAACC,QAAEA,IAC7D,MAAMC,UAAEA,GAAcC,EAAAA,sBAEhBC,EAAYC,EAAAA,aAAaC,GAAiBA,EAAMC,kBAAkB,IAClEC,EAAcC,EAAAA,WAAW,EAAEP,6CAC3BQ,WAAEA,GAAeC,EAAQA,SAACV,GAAWH,GAC3C,OACEc,EAAKC,IAAA,MAAA,CAAAC,6DAA6BC,YAAaX,KAAeM,WAC5DM,EAAMC,KAAA,OAAA,CAAAH,MAAON,EAAWU,SAAA,CACtBN,cAAME,MAAOK,EAAUD,SAAGlB,IAC1BY,EAAAA,YAAME,MAAOK,EAAoBD,SAAA,MACjCN,cAAME,MAAOK,EAAaD,SAAAnB,QAIlC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
define(['exports', 'preact/jsx-runtime', 'preact/compat', './FormContext-5130e198', './useFormContext-30acdd33', './FormFieldContext-3c44aaaa', 'preact/hooks', './useFocusableTextField-8b755b15', './Label-7cbbe3b7', './keyboardUtils-71bc5d84', './TextFieldInput-e86a1d08', 'css!./ObfuscatedTextFieldInputStyles.styles.css', './ReadonlyTextFieldInput-d6c6dbc4', './StyledTextField-5dcd2ff4', './TextField-c16917d8', './MaxLengthLiveRegion-46bb45da', './useTextField-e6877c79', './logger-0f873e29', './TabbableModeContext-a9c97640', './useId-c9578d26', './useTranslationBundle-7c40cb58', 'css!./UserAssistanceStyles.styles.css', 'module', './UNSAFE_UserAssistance/themes/redwood/UserAssistanceVariants.css', './InlineUserAssistance-3d3e72a9', './CompactUserAssistance-f962b357', './mergeProps-bcfa6a92', './LayerHost-733ade2f', 'css!./TooltipContentStyles.styles.css', 'module', './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css', './tooltipUtils-30886397', 'preact', 'css!./IconStyle.styles.css', './Popup-3e2566da', 'css!./LabelStyles.styles.css', 'module', './UNSAFE_Label/themes/redwood/LabelVariants.css', './InputGroupContext-372087af', './HiddenAccessible-037ef42d', 'module', './UNSAFE_Popup/themes/redwood/PopupVariants.css', './useLengthFilter-ed8959a4', './MaxLengthCounter-9a95922c', './useCurrentValueReducer-faded381', './useSelectableTextField-900d2860'], (function(e,s,t,a,n,i,o,l,r,d,c,u,m,p,x,b,h,F,y,g,f,A,L,v,C,T,R,S,I,U,E,j,w,P,_,k,D,V,N,B,M,H,q,z,W,$){"use strict";const G=t.forwardRef((({"aria-describedby":e,assistiveText:a,autoComplete:o="off",autoFocus:d=!1,columnSpan:u,helpSourceLink:F,helpSourceText:y,isDisabled:A,isReadonly:L,isRequired:v=!1,isRequiredShown:S,label:I,labelEdge:U,labelStartWidth:E,maxLength:j,maxLengthCounter:w="remaining",maxLengthUnit:P,messages:_,placeholder:k,resize:D,role:V,rows:N,textAlign:M,userAssistanceDensity:H,value:G,variant:O="default",onInput:X,onCommit:J,testId:K},Q)=>{const Y=f.useTranslationBundle("@oracle/oraclejet-preact"),Z=j?Y.formControl_limitReached({CHARACTER_LIMIT:j}):"",{currentCommitValue:ee,dispatch:se}=W.useCurrentValueReducer({value:G}),te=t.useCallback((e=>{se({type:"input",payload:e.value}),X?.(e)}),[X,se]),ae=t.useCallback((e=>{se({type:"commit",payload:e.value}),J?.(e)}),[J,se]),{isDisabled:ne,isReadonly:ie,labelEdge:oe,labelStartWidth:le,textAlign:re,userAssistanceDensity:de}=n.useFormContext(),ce=A??ne,ue=L??ie,me=U??oe,pe=E??le,xe=M??re,be=H??de,he=t.useRef(g.useId()),Fe=e?`${e} ${he.current}`:he.current,ye=t.useRef(null),ge=t.useRef(null),{focusProps:fe,isFocused:Ae,methods:Le}=l.useFocusableTextField({isDisabled:ce,isReadonly:ue,enabledElementRef:ye,readonlyElementRef:ge}),{methods:ve}=$.useSelectableTextField(ye);t.useImperativeHandle(Q,(()=>R.mergeProps(Le,ve)),[Le,ve]);const{isMaxLengthReached:Ce,valueLength:Te,onFilteredInput:Re}=q.useLengthFilter({maxLength:j,maxLengthUnit:P,value:G,onInput:te,onCommit:ae}),Se=[..._??[],...Ce?[{detail:Z,severity:"info"}]:[]],{formFieldContext:Ie,inputProps:Ue,labelProps:Ee,textFieldProps:je,userAssistanceProps:we}=h.useTextField({ariaDescribedBy:ue||ce?e:Fe,contentVariant:"textarea",helpSourceLink:F,helpSourceText:y,isDisabled:ce,isFocused:Ae,isReadonly:ue,isRequiredShown:S,labelEdge:me,messages:Se,styleVariant:O,userAssistanceDensity:be,value:G}),Pe=t.useCallback((()=>{const e=ye.current,s=e?e.value.length:null;ye.current?.setSelectionRange(s,s),ye.current?.focus()}),[ye]),_e="none"!==me?s.jsx(r.Label,{...Ee,children:I}):void 0,ke={label:"none"!==me?_e:void 0,labelEdge:"none"!==me?me:void 0,labelStartWidth:"none"!==me?pe:void 0},De="none"===me?I:void 0,Ve="efficient"===be||"reflow"===be?ce||ue?"efficient"!==be?void 0:s.jsx(C.InlineUserAssistance,{userAssistanceDensity:be,...we}):s.jsx(C.InlineUserAssistance,{assistiveText:a,fieldLabel:I,helpSourceLink:F,helpSourceText:y,messages:Se,isRequiredShown:S,userAssistanceDensity:be,...we}):void 0,Ne=t.useRef(null),Be="compact"===be?s.jsx(T.CompactUserAssistance,{anchorRef:Ne,messages:Se,assistiveText:a,...we}):void 0;if(ue){const e=s.jsx(m.ReadonlyTextFieldInput,{"aria-describedby":Ue["aria-describedby"],"aria-label":De,"aria-labelledby":Ee.id,as:"textarea",elementRef:ge,rows:N,autoFocus:d,textAlign:xe,value:G,variant:"textarea",hasEmptyLabel:""===I&&"none"===me,hasInsideLabel:void 0!==I&&"inside"===me});return s.jsx(i.FormFieldContext.Provider,{value:Ie,children:s.jsx(p.ReadonlyTextField,{role:"presentation",columnSpan:u,compactUserAssistance:Be,inlineUserAssistance:Ve,ref:Ne,testId:K,variant:"textarea",mainContent:e,resize:D,...ke})})}const Me=void 0!==j,He=s.jsxs(s.Fragment,{children:[s.jsx(c.TextFieldInput,{as:"textarea","aria-label":De,autoComplete:o,autoFocus:d,currentCommitValue:ee,hasEmptyLabel:""===I&&"none"===me,hasInsideLabel:void 0!==_e&&"inside"===me,isRequired:v,inputRef:ye,onCommit:ae,onInput:Re,placeholder:k,role:V,rows:N,textAlign:xe,value:G,...Ue}),"remaining"===w&&Me&&s.jsx(z.MaxLengthCounter,{maxLength:j,valueLength:Te,onClick:Pe}),Me&&s.jsx(B.HiddenAccessible,{id:he.current,isHidden:!0,children:Y.formControl_maxLength({MAX_LENGTH:`${j}`})}),Me&&Ae&&s.jsx(b.MaxLengthLiveRegion,{maxLength:j,valueLength:Te,testId:K+"_remainingChars"})]});return s.jsx(i.FormFieldContext.Provider,{value:Ie,children:s.jsx(x.TextField,{mainContent:He,columnSpan:u,compactUserAssistance:Be,inlineUserAssistance:Ve,onBlur:fe?.onFocusOut,onFocus:fe?.onFocusIn,mainFieldRef:Ne,resize:D,testId:K,...je,...ke})})}));e.TextArea=G}));
|
|
2
|
+
//# sourceMappingURL=TextArea-f6b13c73.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea-f6b13c73.js","sources":["../../src/UNSAFE_TextArea/TextArea.tsx"],"sourcesContent":["/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { ComponentProps, Ref } from 'preact';\nimport { forwardRef, useCallback, useImperativeHandle, useRef } from 'preact/compat';\nimport { useFormContext } from '../hooks/UNSAFE_useFormContext';\nimport { FormFieldContext } from '../hooks/UNSAFE_useFormFieldContext';\nimport { FocusableHandle, useFocusableTextField } from '../hooks/UNSAFE_useFocusableTextField';\nimport { Label } from '../UNSAFE_Label';\nimport {\n ReadonlyTextField,\n ReadonlyTextFieldInput,\n TextField,\n TextFieldInput\n} from '../UNSAFE_TextField';\nimport { useTextField } from '../hooks/UNSAFE_useTextField';\nimport {\n CompactUserAssistance,\n InlineUserAssistance,\n UserAssistanceDensityType\n} from '../UNSAFE_UserAssistance';\nimport { CountUnit, useLengthFilter } from '../hooks/UNSAFE_useLengthFilter';\nimport { MaxLengthLiveRegion } from '../UNSAFE_TextField';\nimport { MaxLengthCounter } from './MaxLengthCounter';\nimport { Size } from '../utils/UNSAFE_size';\nimport { useCurrentValueReducer } from '../hooks/UNSAFE_useCurrentValueReducer';\nimport { ValueUpdateDetail } from '../utils/UNSAFE_valueUpdateDetail';\nimport { ComponentMessageItem } from '../UNSAFE_ComponentMessage';\nimport { useTranslationBundle } from '../hooks/UNSAFE_useTranslationBundle';\nimport { BundleType } from '../resources/nls/bundle';\nimport { LayoutColumnSpan } from '../utils/UNSAFE_styles/Layout';\nimport type { TestIdProps } from '#hooks/UNSAFE_useTestId';\nimport { HiddenAccessible } from '../UNSAFE_HiddenAccessible';\nimport { useId } from '../hooks/UNSAFE_useId';\nimport { SelectableHandle, useSelectableTextField } from '#hooks/UNSAFE_useSelectableTextField';\nimport { mergeProps } from '#utils/UNSAFE_mergeProps';\n\ntype TextFieldProps = ComponentProps<typeof TextField>;\ntype TextFieldInputProps = ComponentProps<typeof TextFieldInput>;\ntype InlineUserAssistanceProps = ComponentProps<typeof InlineUserAssistance>;\n\ntype Props = TestIdProps & {\n /**\n * The ID of an element (or space separated IDs of multiple elements) that\n * describes the input.\n */\n 'aria-describedby'?: TextFieldInputProps['aria-describedby'];\n\n /**\n * Text to provide guidance to help the user understand what to enter.\n */\n assistiveText?: InlineUserAssistanceProps['assistiveText'];\n /**\n * Dictates component's autocomplete state.\n * This attribute indicates whether the value of the control can be automatically completed by the browser.\n * The common values are \"on\" and \"off\".\n */\n autoComplete?: TextFieldInputProps['autoComplete'];\n /**\n * Autofocus specifies whether the component will get focus when the page is loaded.\n * If it is set to true then the associated component will get input focus when the page is loaded.\n * Setting this property doesn't set the focus to the component; it tells the browser to focus\n * to it when the element is inserted in the document.\n */\n autoFocus?: TextFieldInputProps['autoFocus'];\n /**\n * Specifies how many columns to span in a FormLayout with direction === 'row'\n */\n columnSpan?: LayoutColumnSpan;\n /**\n * Help source URL associated with the component.\n */\n helpSourceLink?: InlineUserAssistanceProps['helpSourceLink'];\n /**\n * Custom text to be rendered for the <code>helpSourceLink</code>.\n */\n helpSourceText?: InlineUserAssistanceProps['helpSourceText'];\n /**\n * Specifies whether the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * Specifies whether the component is readonly.\n */\n isReadonly?: boolean;\n /**\n * Specifies for accessibility purposes whether a value is required.\n *\n * Setting this property to <code>false</code> means that a value is not required to be\n * committed by the user. Setting this property to <code>true</code> means that a value\n * is required to be committed by the user.\n */\n isRequired?: TextFieldInputProps['isRequired'];\n /**\n * Specifies whether to show an indicator on screen that a value is required, for example\n * before the user has committed a value.\n */\n isRequiredShown?: InlineUserAssistanceProps['isRequiredShown'];\n /**\n * Specifies the label associated with the field.\n */\n label: string;\n /**\n * Specifies where the label is positioned relative to the field.\n */\n labelEdge?: 'inside' | 'start' | 'top' | 'none';\n /**\n * Specifies the width of the label when <code>labelEdge</code> is <code>\"start\"</code>\n */\n labelStartWidth?: Size;\n /**\n * Specifies the maximum number of characters that can be entered in the input field.\n */\n maxLength?: number;\n /**\n * Determines whether the remaining number of characters that can be entered is shown or not.\n */\n maxLengthCounter?: 'none' | 'remaining';\n /**\n * Specifies how the input text characters are to be counted when maxLength is specified.\n */\n maxLengthUnit?: CountUnit;\n /**\n * Messages to show on screen that are associated with the component.\n */\n messages?: InlineUserAssistanceProps['messages'];\n /**\n * A short hint to display before the user enters a value.\n */\n placeholder?: TextFieldInputProps['placeholder'];\n /**\n * Specifies how the user is allowed to manually resize the TextArea component.\n */\n resize?: TextFieldProps['resize'];\n /**\n * Specifies the ARIA role type.\n */\n role?: TextFieldInputProps['role'];\n /**\n * Specifies the number of rows to display\n */\n rows?: TextFieldInputProps['rows'];\n /**\n * Specifies how to align text within the field.\n */\n textAlign?: TextFieldInputProps['textAlign'];\n /**\n * Specifies the density of the user assistance presentation. It can be set to:\n * <ul>\n * <li><code>'efficient'</code>: Show inline and reserve space to prevent layout reflow when user\n * assistance text is displayed.</li>\n * <li><code>'reflow'</code>: Show inline. Layout will reflow when text is displayed.</li>\n * <li><code>'compact'</code>: Messages, help, hints, and required will not be shown inline; they will show in a mode that keeps the screen more compact, like a popup for the messages, and a required icon to indicate Required. </li>\n * </ul>\n */\n userAssistanceDensity?: UserAssistanceDensityType;\n /**\n * The current display value of the component.\n */\n value?: TextFieldInputProps['value'];\n /**\n * The style variant of the component.\n */\n variant?: TextFieldInputProps['variant'];\n /**\n * Callback invoked when the user commits the entered value by blurring out of the field.\n */\n onCommit?: TextFieldInputProps['onCommit'];\n /**\n * Callback invoked each time the user changes the value of the field. For example, if the user\n * types 'abcd', this callback will be called four times with the value as 'a', 'ab', 'abc' and 'abcd'\n * respectively.\n */\n onInput: TextFieldInputProps['onInput'];\n};\n\ntype FocusSelectHandle = FocusableHandle & SelectableHandle;\n\n/**\n * A text area displays a field that allows a user to enter a multi-line text value.\n */\nexport const TextArea = forwardRef(\n (\n {\n 'aria-describedby': ariaDescribedBy,\n assistiveText,\n autoComplete = 'off',\n autoFocus = false,\n columnSpan,\n helpSourceLink,\n helpSourceText,\n isDisabled: propIsDisabled,\n isReadonly: propIsReadonly,\n isRequired = false,\n isRequiredShown,\n label,\n labelEdge: propLabelEdge,\n labelStartWidth: propLabelStartWidth,\n maxLength,\n maxLengthCounter = 'remaining',\n maxLengthUnit,\n messages,\n placeholder,\n resize,\n role,\n rows,\n textAlign: propTextAlign,\n userAssistanceDensity: propUserAssistanceDensity,\n value,\n variant = 'default',\n onInput,\n onCommit,\n testId\n }: Props,\n ref?: Ref<FocusSelectHandle>\n ) => {\n const translations = useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const formControl_limitReached = maxLength\n ? translations.formControl_limitReached({\n CHARACTER_LIMIT: maxLength\n })\n : '';\n\n const { currentCommitValue, dispatch } = useCurrentValueReducer({ value });\n const onInputAndDispatch = useCallback(\n (detail: ValueUpdateDetail<string>) => {\n // Should dispatch happen first? This will queue up a re-render, ordering should not cause issues (this is async)\n dispatch({ type: 'input', payload: detail.value });\n onInput?.(detail);\n },\n [onInput, dispatch]\n );\n const onCommitAndDispatch = useCallback(\n (detail: ValueUpdateDetail<string>) => {\n // Should dispatch happen first? This will queue up a re-render, ordering should not cause issues (this is async)\n dispatch({ type: 'commit', payload: detail.value });\n onCommit?.(detail);\n },\n [onCommit, dispatch]\n );\n const {\n isDisabled: isFormDisabled,\n isReadonly: isFormReadonly,\n labelEdge: formLabelEdge,\n labelStartWidth: formLabelStartWidth,\n textAlign: formTextAlign,\n userAssistanceDensity: formUserAssistanceDensity\n } = useFormContext();\n\n // default to FormContext values if component properties are not specified\n const isDisabled = propIsDisabled ?? isFormDisabled;\n const isReadonly = propIsReadonly ?? isFormReadonly;\n const labelEdge = propLabelEdge ?? formLabelEdge;\n const labelStartWidth = propLabelStartWidth ?? formLabelStartWidth;\n const textAlign = propTextAlign ?? formTextAlign;\n const userAssistanceDensity = propUserAssistanceDensity ?? formUserAssistanceDensity;\n const maxLengthDescribedByIdRef = useRef<string>(useId());\n // The enabledAriaDescribedBy includes the maxLengthDescribedById in addition to what was passed in to aria-describedby.\n // We don't need to announce the max length message for readonly, as it only applies when editing the value.\n const enabledAriaDescribedBy = ariaDescribedBy\n ? `${ariaDescribedBy} ${maxLengthDescribedByIdRef.current}`\n : maxLengthDescribedByIdRef.current;\n\n const enabledElementRef = useRef<HTMLTextAreaElement>(null);\n const readonlyElementRef = useRef<HTMLTextAreaElement>(null);\n\n const {\n focusProps,\n isFocused,\n methods: focusMethods\n } = useFocusableTextField<HTMLTextAreaElement, HTMLTextAreaElement>({\n isDisabled,\n isReadonly,\n enabledElementRef,\n readonlyElementRef\n });\n\n const { methods: selectMethods } =\n useSelectableTextField<HTMLTextAreaElement>(enabledElementRef);\n\n useImperativeHandle(ref!, () => mergeProps(focusMethods, selectMethods), [\n focusMethods,\n selectMethods\n ]);\n\n // Handle length filter for user-typed inputs and controlled inputs\n const { isMaxLengthReached, valueLength, onFilteredInput } = useLengthFilter({\n maxLength,\n maxLengthUnit,\n value,\n onInput: onInputAndDispatch,\n onCommit: onCommitAndDispatch\n });\n\n const limitMessage = [{ detail: formControl_limitReached, severity: 'info' }];\n const allMessages = [\n ...(messages ?? []),\n ...(isMaxLengthReached ? limitMessage : [])\n ] as ComponentMessageItem[];\n\n const { formFieldContext, inputProps, labelProps, textFieldProps, userAssistanceProps } =\n useTextField({\n ariaDescribedBy: isReadonly || isDisabled ? ariaDescribedBy : enabledAriaDescribedBy,\n contentVariant: 'textarea',\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isFocused,\n isReadonly,\n isRequiredShown,\n labelEdge,\n messages: allMessages,\n styleVariant: variant,\n userAssistanceDensity,\n value\n });\n\n const onClickCounter = useCallback(() => {\n const elm = enabledElementRef.current;\n // for setSelectionRange(), len needs to be a number or null.\n const len = elm ? elm.value.length : null;\n // Since the counter element is after the text, clicking in this\n // should put the selection at the end of the text\n enabledElementRef.current?.setSelectionRange(len, len);\n // Clicking the counter should put the focus on the input field\n enabledElementRef.current?.focus();\n }, [enabledElementRef]);\n\n const labelComp = labelEdge !== 'none' ? <Label {...labelProps}>{label}</Label> : undefined;\n\n const fieldLabelProps = {\n label: labelEdge !== 'none' ? labelComp : undefined,\n labelEdge: labelEdge !== 'none' ? labelEdge : undefined,\n labelStartWidth: labelEdge !== 'none' ? labelStartWidth : undefined\n };\n\n const ariaLabel = labelEdge === 'none' ? label : undefined;\n const isInlineDensity =\n userAssistanceDensity === 'efficient' || userAssistanceDensity === 'reflow';\n\n const inlineUserAssistance = isInlineDensity ? (\n isDisabled || isReadonly ? (\n // save space for user assistance if density is 'efficient', even though we don't\n // render user assistance for disabled or readonly fields\n userAssistanceDensity !== 'efficient' ? undefined : (\n <InlineUserAssistance\n userAssistanceDensity={userAssistanceDensity}\n {...userAssistanceProps}\n />\n )\n ) : (\n <InlineUserAssistance\n assistiveText={assistiveText}\n fieldLabel={label}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n messages={allMessages}\n isRequiredShown={isRequiredShown}\n userAssistanceDensity={userAssistanceDensity}\n {...userAssistanceProps}\n />\n )\n ) : undefined;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n\n const compactUserAssistance =\n userAssistanceDensity === 'compact' ? (\n <CompactUserAssistance\n anchorRef={anchorRef}\n messages={allMessages}\n assistiveText={assistiveText}\n {...userAssistanceProps}\n />\n ) : undefined;\n\n if (isReadonly) {\n const mainContent = (\n <ReadonlyTextFieldInput\n aria-describedby={inputProps['aria-describedby']}\n aria-label={ariaLabel}\n aria-labelledby={labelProps.id}\n as=\"textarea\"\n elementRef={readonlyElementRef}\n rows={rows}\n autoFocus={autoFocus}\n textAlign={textAlign}\n value={value}\n variant=\"textarea\"\n hasEmptyLabel={label === '' && labelEdge === 'none'}\n hasInsideLabel={label !== undefined && labelEdge === 'inside'}\n />\n );\n return (\n <FormFieldContext.Provider value={formFieldContext}>\n <ReadonlyTextField\n role=\"presentation\"\n columnSpan={columnSpan}\n compactUserAssistance={compactUserAssistance}\n inlineUserAssistance={inlineUserAssistance}\n ref={anchorRef}\n testId={testId}\n variant=\"textarea\"\n mainContent={mainContent}\n resize={resize}\n {...fieldLabelProps}\n />\n </FormFieldContext.Provider>\n );\n }\n const hasMaxLength = maxLength !== undefined;\n const mainContent = (\n <>\n <TextFieldInput\n as=\"textarea\"\n aria-label={ariaLabel}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n currentCommitValue={currentCommitValue}\n hasEmptyLabel={label === '' && labelEdge === 'none'}\n hasInsideLabel={labelComp !== undefined && labelEdge === 'inside'}\n isRequired={isRequired}\n inputRef={enabledElementRef}\n onCommit={onCommitAndDispatch}\n onInput={onFilteredInput}\n placeholder={placeholder}\n role={role}\n rows={rows}\n textAlign={textAlign}\n value={value}\n {...inputProps}\n />\n {maxLengthCounter === 'remaining' && hasMaxLength && (\n <MaxLengthCounter\n maxLength={maxLength}\n valueLength={valueLength}\n onClick={onClickCounter}\n />\n )}\n {hasMaxLength && (\n <HiddenAccessible id={maxLengthDescribedByIdRef.current} isHidden={true}>\n {translations.formControl_maxLength({\n MAX_LENGTH: `${maxLength}`\n })}\n </HiddenAccessible>\n )}\n {hasMaxLength && isFocused && (\n <MaxLengthLiveRegion\n maxLength={maxLength}\n valueLength={valueLength}\n testId={testId + '_remainingChars'}\n />\n )}\n </>\n );\n\n return (\n <FormFieldContext.Provider value={formFieldContext}>\n <TextField\n mainContent={mainContent}\n columnSpan={columnSpan}\n compactUserAssistance={compactUserAssistance}\n inlineUserAssistance={inlineUserAssistance}\n onBlur={focusProps?.onFocusOut}\n onFocus={focusProps?.onFocusIn}\n mainFieldRef={anchorRef}\n resize={resize}\n testId={testId}\n {...textFieldProps}\n {...fieldLabelProps}></TextField>\n </FormFieldContext.Provider>\n );\n }\n);\n"],"names":["TextArea","forwardRef","ariaDescribedBy","assistiveText","autoComplete","autoFocus","columnSpan","helpSourceLink","helpSourceText","isDisabled","propIsDisabled","isReadonly","propIsReadonly","isRequired","isRequiredShown","label","labelEdge","propLabelEdge","labelStartWidth","propLabelStartWidth","maxLength","maxLengthCounter","maxLengthUnit","messages","placeholder","resize","role","rows","textAlign","propTextAlign","userAssistanceDensity","propUserAssistanceDensity","value","variant","onInput","onCommit","testId","ref","translations","useTranslationBundle","formControl_limitReached","CHARACTER_LIMIT","currentCommitValue","dispatch","useCurrentValueReducer","onInputAndDispatch","useCallback","detail","type","payload","onCommitAndDispatch","isFormDisabled","isFormReadonly","formLabelEdge","formLabelStartWidth","formTextAlign","formUserAssistanceDensity","useFormContext","maxLengthDescribedByIdRef","useRef","useId","enabledAriaDescribedBy","current","enabledElementRef","readonlyElementRef","focusProps","isFocused","methods","focusMethods","useFocusableTextField","selectMethods","useSelectableTextField","useImperativeHandle","mergeProps","isMaxLengthReached","valueLength","onFilteredInput","useLengthFilter","allMessages","severity","formFieldContext","inputProps","labelProps","textFieldProps","userAssistanceProps","useTextField","contentVariant","styleVariant","onClickCounter","elm","len","length","setSelectionRange","focus","labelComp","_jsx","jsx","Label","undefined","fieldLabelProps","ariaLabel","inlineUserAssistance","InlineUserAssistance","fieldLabel","anchorRef","compactUserAssistance","CompactUserAssistance","mainContent","ReadonlyTextFieldInput","id","as","elementRef","hasEmptyLabel","hasInsideLabel","FormFieldContext","Provider","children","ReadonlyTextField","hasMaxLength","_jsxs","_Fragment","Fragment","TextFieldInput","inputRef","MaxLengthCounter","onClick","HiddenAccessible","isHidden","formControl_maxLength","MAX_LENGTH","MaxLengthLiveRegion","TextField","onBlur","onFocusOut","onFocus","onFocusIn","mainFieldRef"],"mappings":"8oDA0LaA,EAAWC,EAAAA,YACtB,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D,YAAaA,GACbkD,QAASrC,KAGZ8B,IACCvB,MAAC+B,EAAAA,iBAAgB,CAACjB,GAAInD,GAA0BI,QAASiE,UAAU,EAAIX,SACpE9E,EAAa0F,sBAAsB,CAClCC,WAAY,GAAG7G,QAIpBkG,IAAgBpD,IACf6B,MAACmC,EAAAA,oBACC,CAAA9G,UAAWA,EACXuD,YAAaA,GACbvC,OAAQA,EAAS,uBAMzB,OACE2D,EAAAA,IAACmB,EAAAA,iBAAiBC,SAAS,CAAAnF,MAAOgD,GAChCoC,SAAArB,EAAAC,IAACmC,EAASA,UAAA,CACRxB,YAAaA,GACbrG,WAAYA,EACZmG,sBAAuBA,GACvBJ,qBAAsBA,GACtB+B,OAAQnE,IAAYoE,WACpBC,QAASrE,IAAYsE,UACrBC,aAAchC,GACd/E,OAAQA,EACRW,OAAQA,KACJ+C,MACAgB,MAER"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
define(['exports', 'preact/jsx-runtime', 'preact/compat', './FormContext-5130e198', './useFormContext-30acdd33', './FormFieldContext-3c44aaaa', 'preact/hooks', './useFocusableTextField-8b755b15', './Label-7cbbe3b7', './keyboardUtils-71bc5d84', './TextFieldInput-e86a1d08', 'css!./ObfuscatedTextFieldInputStyles.styles.css', './ReadonlyTextFieldInput-d6c6dbc4', './StyledTextField-5dcd2ff4', './TextField-c16917d8', './MaxLengthLiveRegion-46bb45da', './useTextField-e6877c79', './logger-0f873e29', './TabbableModeContext-a9c97640', './useId-c9578d26', './useTranslationBundle-7c40cb58', 'css!./UserAssistanceStyles.styles.css', 'module', './UNSAFE_UserAssistance/themes/redwood/UserAssistanceVariants.css', './InlineUserAssistance-3d3e72a9', './CompactUserAssistance-f962b357', './mergeProps-bcfa6a92', './LayerHost-733ade2f', 'css!./TooltipContentStyles.styles.css', 'module', './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css', './tooltipUtils-30886397', 'preact', 'css!./IconStyle.styles.css', './Popup-3e2566da', 'css!./LabelStyles.styles.css', 'module', './UNSAFE_Label/themes/redwood/LabelVariants.css', './InputGroupContext-372087af', './HiddenAccessible-037ef42d', 'module', './UNSAFE_Popup/themes/redwood/PopupVariants.css', './useLengthFilter-ed8959a4', './useCurrentValueReducer-faded381', './useSelectableTextField-900d2860', './MaxLengthCounter-9a95922c'], (function(e,s,t,a,n,o,i,l,r,d,c,u,m,p,h,x,b,g,F,f,y,R,v,L,T,A,C,S,I,U,w,E,j,P,H,_,k,D,B,V,M,N,q,W,$,z){"use strict";const G=({isReadonly:e,enabledElementRef:s,readonlyElementRef:t,minRows:a=2,maxRows:n,value:o})=>{i.useLayoutEffect((()=>{const o=e?t:s;if(null===o.current)return;if(o.current instanceof HTMLDivElement)return;const i=o.current,l=(e=>{const s=window.getComputedStyle(e),t=s.lineHeight;if("normal"===t)return 1.2*parseFloat(s.fontSize);return parseFloat(t)})(i);i.style.height="0";const{paddingHeight:r,borderHeight:d}=(e=>{const s=window.getComputedStyle(e);return{paddingHeight:parseFloat(s.paddingTop)+parseFloat(s.paddingBottom),borderHeight:parseFloat(s.borderTop)+parseFloat(s.borderBottom)}})(i),c=l*a+r+d,u=i.scrollHeight+d;let m=0;if(void 0===n)m=u<c?c:u;else if(n>a){const e=l*n+r+d;m=u>e?e:u<c?c:u}else m=c;i.style.height=m+.5+"px"}),[o,a,n,e,s,t])},O=t.forwardRef((({"aria-describedby":e,assistiveText:a,autoComplete:i="off",autoFocus:d=!1,columnSpan:u,helpSourceLink:g,helpSourceText:F,isDisabled:R,isReadonly:v,isRequired:L=!1,isRequiredShown:S,label:I,labelEdge:U,labelStartWidth:w,maxLength:E,maxLengthCounter:j="remaining",maxLengthUnit:P,maxRows:H,messages:_,minRows:k=2,placeholder:D,role:B,textAlign:M,userAssistanceDensity:N,value:O,variant:X="default",onInput:J,onCommit:K,testId:Q},Y)=>{const Z=y.useTranslationBundle("@oracle/oraclejet-preact"),ee=E?Z.formControl_limitReached({CHARACTER_LIMIT:E}):"",{currentCommitValue:se,dispatch:te}=W.useCurrentValueReducer({value:O}),ae=t.useCallback((e=>{te({type:"input",payload:e.value}),J?.(e)}),[J,te]),ne=t.useCallback((e=>{te({type:"commit",payload:e.value}),K?.(e)}),[K,te]),{isDisabled:oe,isReadonly:ie,labelEdge:le,labelStartWidth:re,textAlign:de,userAssistanceDensity:ce}=n.useFormContext(),ue=R??oe,me=v??ie,pe=U??le,he=w??re,xe=M??de,be=N??ce,ge=t.useRef(f.useId()),Fe=e?`${e} ${ge.current}`:ge.current,fe=t.useRef(null),ye=t.useRef(null),{focusProps:Re,isFocused:ve,methods:Le}=l.useFocusableTextField({isDisabled:ue,isReadonly:me,enabledElementRef:fe,readonlyElementRef:ye}),{methods:Te}=$.useSelectableTextField(fe);t.useImperativeHandle(Y,(()=>C.mergeProps(Le,Te)),[Le,Te]);const{isMaxLengthReached:Ae,valueLength:Ce,onFilteredInput:Se}=q.useLengthFilter({maxLength:E,maxLengthUnit:P,value:O,onInput:ae,onCommit:ne}),Ie=[..._??[],...Ae?[{detail:ee,severity:"info"}]:[]],{formFieldContext:Ue,inputProps:we,labelProps:Ee,textFieldProps:je,userAssistanceProps:Pe}=b.useTextField({ariaDescribedBy:me||ue?e:Fe,contentVariant:"textarea",helpSourceLink:g,helpSourceText:F,isDisabled:ue,isFocused:ve,isReadonly:me,isRequiredShown:S,labelEdge:pe,messages:Ie,styleVariant:X,userAssistanceDensity:be,value:O}),He=t.useCallback((()=>{const e=fe.current,s=e?e.value.length:null;fe.current?.setSelectionRange(s,s),fe.current?.focus()}),[fe]),_e="none"!==pe?s.jsx(r.Label,{...Ee,children:I}):void 0,ke={label:"none"!==pe?_e:void 0,labelEdge:"none"!==pe?pe:void 0,labelStartWidth:"none"!==pe?he:void 0},De="none"===pe?I:void 0,Be="efficient"===be||"reflow"===be?ue||me?"efficient"!==be?void 0:s.jsx(T.InlineUserAssistance,{userAssistanceDensity:be,...Pe}):s.jsx(T.InlineUserAssistance,{assistiveText:a,fieldLabel:I,helpSourceLink:g,helpSourceText:F,messages:Ie,isRequiredShown:S,userAssistanceDensity:be,...Pe}):void 0,Ve=t.useRef(null),Me="compact"===be?s.jsx(A.CompactUserAssistance,{anchorRef:Ve,messages:Ie,assistiveText:a,...Pe}):void 0;if(G({isReadonly:me,enabledElementRef:fe,readonlyElementRef:ye,minRows:k,maxRows:H,value:O}),me){const e=s.jsx(m.ReadonlyTextFieldInput,{"aria-describedby":we["aria-describedby"],"aria-label":De,"aria-labelledby":Ee.id,elementRef:ye,...H?{as:"textarea",rows:k}:{as:"div"},autoFocus:d,textAlign:xe,value:O,variant:"textarea",hasEmptyLabel:""===I&&"none"===pe,hasInsideLabel:void 0!==I&&"inside"===pe});return s.jsx(o.FormFieldContext.Provider,{value:Ue,children:s.jsx(p.ReadonlyTextField,{role:"presentation",columnSpan:u,compactUserAssistance:Me,inlineUserAssistance:Be,variant:"textarea",mainContent:e,ref:Ve,testId:Q,...ke})})}const Ne=void 0!==E,qe=s.jsxs(s.Fragment,{children:[s.jsx(c.TextFieldInput,{as:"textarea","aria-label":De,autoComplete:i,autoFocus:d,currentCommitValue:se,hasEmptyLabel:""===I&&"none"===pe,hasInsideLabel:void 0!==_e&&"inside"===pe,isRequired:L,inputRef:fe,onCommit:ne,onInput:Se,placeholder:D,role:B,rows:k,textAlign:xe,value:O,...we}),"remaining"===j&&Ne&&s.jsx(z.MaxLengthCounter,{maxLength:E,valueLength:Ce,onClick:He}),Ne&&s.jsx(V.HiddenAccessible,{id:ge.current,children:Z.formControl_maxLength({MAX_LENGTH:`${E}`})}),Ne&&ve&&s.jsx(x.MaxLengthLiveRegion,{maxLength:E,valueLength:Ce,testId:Q+"_remainingChars"})]});return s.jsx(o.FormFieldContext.Provider,{value:Ue,children:s.jsx(h.TextField,{mainContent:qe,columnSpan:u,compactUserAssistance:Me,inlineUserAssistance:Be,onBlur:Re?.onFocusOut,onFocus:Re?.onFocusIn,mainFieldRef:Ve,testId:Q,...je,...ke})})}));e.TextAreaAutosize=O}));
|
|
2
|
+
//# sourceMappingURL=TextAreaAutosize-af350c32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaAutosize-b7e56051.js","sources":["../../src/UNSAFE_TextAreaAutosize/ScrollHeightUtils.tsx","../../src/UNSAFE_TextAreaAutosize/useTextAreaAutosizing.tsx","../../src/UNSAFE_TextAreaAutosize/TextAreaAutosize.tsx"],"sourcesContent":["// returns the lineHeight as a number of pixels.\nexport const calculateLineHeight = (textarea: HTMLTextAreaElement): number => {\n const computedStyle = window.getComputedStyle(textarea);\n const computedlineHeight = computedStyle.lineHeight;\n if (computedlineHeight === 'normal') {\n // We get 'normal' for values 'initial', 'inherit', 'unset' and 'normal'\n // TODO: Unclear if we need this.\n // getComputedStyle always return fontSize in pixels. Not likely a float, but since it's legal\n // we use parseFloat()\n const fontSize = parseFloat(computedStyle.fontSize);\n return 1.2 * fontSize;\n }\n return parseFloat(computedlineHeight);\n};\nexport const getStylingHeight = (textarea: HTMLTextAreaElement) => {\n const cssStyle = window.getComputedStyle(textarea);\n const paddingTop = parseFloat(cssStyle.paddingTop);\n const paddingBottom = parseFloat(cssStyle.paddingBottom);\n const borderTop = parseFloat(cssStyle.borderTop);\n const borderBottom = parseFloat(cssStyle.borderBottom);\n return { paddingHeight: paddingTop + paddingBottom, borderHeight: borderTop + borderBottom };\n};\n","import type { ComponentProps, RefObject } from 'preact';\nimport { useLayoutEffect } from 'preact/hooks';\nimport { calculateLineHeight, getStylingHeight } from './ScrollHeightUtils';\nimport { TextAreaAutosize } from './TextAreaAutosize';\n\ntype PickedPropsFromTextAreaAutosize = Pick<\n ComponentProps<typeof TextAreaAutosize>,\n 'minRows' | 'maxRows' | 'value'\n>;\ntype Props = PickedPropsFromTextAreaAutosize & {\n isReadonly?: boolean;\n enabledElementRef: RefObject<HTMLTextAreaElement>;\n readonlyElementRef: RefObject<HTMLTextAreaElement | HTMLDivElement>;\n};\n\n// TODO: Make this fire when the container resizes - JET-50840\nexport const useTextAreaAutosizing = ({\n isReadonly,\n enabledElementRef,\n readonlyElementRef,\n minRows = 2,\n maxRows,\n value\n}: Props) => {\n useLayoutEffect(() => {\n const textareaRef = isReadonly ? readonlyElementRef : enabledElementRef;\n if (textareaRef.current === null) return;\n if (textareaRef.current instanceof HTMLDivElement) return; // We don't need to do anything if the readonlyElement is a DIV.\n const textarea = textareaRef.current;\n const lineHeight = calculateLineHeight(textarea);\n textarea.style.height = '0';\n const { paddingHeight, borderHeight } = getStylingHeight(textarea);\n const heightForMinRows = lineHeight * minRows + paddingHeight + borderHeight;\n const scrollHeight = textarea.scrollHeight + borderHeight;\n let resizedHeight = 0;\n // if maxRows is -1 the textarea will grow or shrink to fit all the content.\n // it won't shrink any less than rows.\n if (maxRows === undefined) {\n // we want to fit the entire scrollHeight, but we don't want\n // to shrink smaller than the height for rows.\n if (scrollHeight < heightForMinRows) {\n resizedHeight = heightForMinRows;\n } else {\n resizedHeight = scrollHeight;\n }\n } else if (maxRows > minRows) {\n // if maxRows is positive and greater than rows, the textarea will grow to fit the content\n // up to maxrows, or shrink to fit the content and down to rows.\n const heightForMaxRows = lineHeight * maxRows + paddingHeight + borderHeight;\n if (scrollHeight > heightForMaxRows) {\n resizedHeight = heightForMaxRows;\n } else if (scrollHeight < heightForMinRows) {\n resizedHeight = heightForMinRows;\n } else {\n resizedHeight = scrollHeight;\n }\n } else {\n resizedHeight = heightForMinRows;\n }\n // The 0.5 gaurantees that the clientHeight will be bigger than the scrollHeight, so no scrollbar appears.\n textarea.style.height = resizedHeight + 0.5 + 'px';\n }, [value, minRows, maxRows, isReadonly, enabledElementRef, readonlyElementRef]);\n};\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { ComponentProps, Ref } from 'preact';\nimport { forwardRef, useCallback, useImperativeHandle, useRef } from 'preact/compat';\nimport { useFormContext } from '../hooks/UNSAFE_useFormContext';\nimport { FormFieldContext } from '../hooks/UNSAFE_useFormFieldContext';\nimport { FocusableHandle, useFocusableTextField } from '../hooks/UNSAFE_useFocusableTextField';\nimport { Label } from '../UNSAFE_Label';\nimport {\n ReadonlyTextField,\n ReadonlyTextFieldInput,\n TextField,\n TextFieldInput\n} from '../UNSAFE_TextField';\nimport { useTextField } from '../hooks/UNSAFE_useTextField';\nimport {\n CompactUserAssistance,\n InlineUserAssistance,\n UserAssistanceDensityType\n} from '../UNSAFE_UserAssistance';\nimport { CountUnit, useLengthFilter } from '../hooks/UNSAFE_useLengthFilter';\nimport { MaxLengthLiveRegion } from '../UNSAFE_TextField';\nimport { useTextAreaAutosizing } from './useTextAreaAutosizing';\nimport { Size } from '../utils/UNSAFE_size';\nimport { useCurrentValueReducer } from '../hooks/UNSAFE_useCurrentValueReducer';\nimport { ValueUpdateDetail } from '../utils/UNSAFE_valueUpdateDetail';\nimport { MaxLengthCounter } from '../UNSAFE_TextArea';\nimport { useTranslationBundle } from '../hooks/UNSAFE_useTranslationBundle';\nimport { BundleType } from '../resources/nls/bundle';\nimport { ComponentMessageItem } from '../UNSAFE_ComponentMessage';\nimport { LayoutColumnSpan } from '../utils/UNSAFE_styles/Layout';\nimport type { TestIdProps } from '#hooks/UNSAFE_useTestId';\nimport { HiddenAccessible } from '../UNSAFE_HiddenAccessible';\nimport { useId } from '../hooks/UNSAFE_useId';\nimport { SelectableHandle, useSelectableTextField } from '#hooks/UNSAFE_useSelectableTextField';\nimport { mergeProps } from '#utils/UNSAFE_mergeProps';\n\ntype TextFieldInputProps = ComponentProps<typeof TextFieldInput>;\ntype InlineUserAssistanceProps = ComponentProps<typeof InlineUserAssistance>;\n\ntype Props = TestIdProps & {\n /**\n * The ID of an element (or space separated IDs of multiple elements) that\n * describes the input.\n */\n 'aria-describedby'?: TextFieldInputProps['aria-describedby'];\n /**\n * Text to provide guidance to help the user understand what to enter.\n */\n assistiveText?: InlineUserAssistanceProps['assistiveText'];\n /**\n * Dictates component's autocomplete state.\n * This attribute indicates whether the value of the control can be automatically completed by the browser.\n * The common values are \"on\" and \"off\".\n */\n autoComplete?: TextFieldInputProps['autoComplete'];\n /**\n * Autofocus specifies whether the component will get focus when the page is loaded.\n * If it is set to true then the associated component will get input focus when the page is loaded.\n * Setting this property doesn't set the focus to the component; it tells the browser to focus\n * to it when the element is inserted in the document.\n */\n autoFocus?: TextFieldInputProps['autoFocus'];\n /**\n * Specifies how many columns to span in a FormLayout with direction === 'row'\n */\n columnSpan?: LayoutColumnSpan;\n /**\n * Help source URL associated with the component.\n */\n helpSourceLink?: InlineUserAssistanceProps['helpSourceLink'];\n /**\n * Custom text to be rendered for the <code>helpSourceLink</code>.\n */\n helpSourceText?: InlineUserAssistanceProps['helpSourceText'];\n /**\n * Specifies whether the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * Specifies whether the component is readonly.\n */\n isReadonly?: boolean;\n /**\n * Specifies for accessibility purposes whether a value is required.\n *\n * Setting this property to <code>false</code> means that a value is not required to be\n * committed by the user. Setting this property to <code>true</code> means that a value\n * is required to be committed by the user.\n */\n isRequired?: TextFieldInputProps['isRequired'];\n /**\n * Specifies whether to show an indicator on screen that a value is required, for example\n * before the user has committed a value.\n */\n isRequiredShown?: InlineUserAssistanceProps['isRequiredShown'];\n /**\n * Specifies the label associated with the field.\n */\n label: string;\n /**\n * Specifies where the label is positioned relative to the field.\n */\n labelEdge?: 'inside' | 'start' | 'top' | 'none';\n /**\n * Specifies the width of the label when <code>labelEdge</code> is <code>\"start\"</code>\n */\n labelStartWidth?: Size;\n /**\n * Specifies the maximum number of characters that can be entered in the input field.\n */\n maxLength?: number;\n /**\n * Determines whether the remaining number of characters that can be entered is shown or not.\n */\n maxLengthCounter?: 'none' | 'remaining';\n /**\n * Specifies how the input text characters are to be counted when maxLength is specified.\n */\n maxLengthUnit?: CountUnit;\n /**\n * Specifies the maximum number of rows that the TextAreaAutosize is allowed to grow to.\n * If maxRows is less than minRows, it is ignored.\n */\n maxRows?: number;\n /**\n * Messages to show on screen that are associated with the component.\n */\n messages?: InlineUserAssistanceProps['messages'];\n /**\n * Specifies the minimum number of rows that the TextAreaAutosize is allowed to shrink to.\n */\n minRows?: number;\n /**\n * A short hint to display before the user enters a value.\n */\n placeholder?: TextFieldInputProps['placeholder'];\n /**\n * Specifies how the user is allowed to manually resize the TextArea component.\n */\n role?: TextFieldInputProps['role'];\n /**\n * Specifies the number of rows to display\n */\n textAlign?: TextFieldInputProps['textAlign'];\n /**\n * Specifies the density of the user assistance presentation. It can be set to:\n * <ul>\n * <li><code>'efficient'</code>: Show inline and reserve space to prevent layout reflow when user\n * assistance text is displayed.</li>\n * <li><code>'reflow'</code>: Show inline. Layout will reflow when text is displayed.</li>\n * <li><code>'compact'</code>: Messages, help, hints, and required will not be shown inline; they will show in a mode that keeps the screen more compact, like a popup for the messages, and a required icon to indicate Required. </li>\n * </ul>\n */\n userAssistanceDensity?: UserAssistanceDensityType;\n /**\n * The current display value of the component.\n */\n value?: TextFieldInputProps['value'];\n /**\n * The style variant of the component.\n */\n variant?: TextFieldInputProps['variant'];\n /**\n * Callback invoked when the user commits the entered value by blurring out of the field.\n *\n */\n onCommit?: TextFieldInputProps['onCommit'];\n\n /**\n * Callback invoked when the user inputs a value.\n *\n */\n onInput: TextFieldInputProps['onInput'];\n};\ntype FocusSelectHandle = FocusableHandle & SelectableHandle;\n/**\n * A text area auto size displays a field that allows a user to enter a multi-line text value, and will adjust its height based on its content.\n */\nexport const TextAreaAutosize = forwardRef(\n (\n {\n 'aria-describedby': ariaDescribedBy,\n assistiveText,\n autoComplete = 'off',\n autoFocus = false,\n columnSpan,\n helpSourceLink,\n helpSourceText,\n isDisabled: propIsDisabled,\n isReadonly: propIsReadonly,\n isRequired = false,\n isRequiredShown,\n label,\n labelEdge: propLabelEdge,\n labelStartWidth: propLabelStartWidth,\n maxLength,\n maxLengthCounter = 'remaining',\n maxLengthUnit,\n maxRows,\n messages,\n minRows = 2,\n placeholder,\n role,\n //TODO: Add counter to show the length remaining - JET-50752\n textAlign: propTextAlign,\n userAssistanceDensity: propUserAssistanceDensity,\n value,\n variant = 'default',\n onInput,\n onCommit,\n testId\n }: Props,\n ref?: Ref<FocusSelectHandle>\n ) => {\n const translations = useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const formControl_limitReached = maxLength\n ? translations.formControl_limitReached({\n CHARACTER_LIMIT: maxLength\n })\n : '';\n\n const { currentCommitValue, dispatch } = useCurrentValueReducer({ value });\n const onInputAndDispatch = useCallback(\n (detail: ValueUpdateDetail<string>) => {\n // Should dispatch happen first? This will queue up a re-render, ordering should not cause issues (this is async)\n dispatch({ type: 'input', payload: detail.value });\n onInput?.(detail);\n },\n [onInput, dispatch]\n );\n const onCommitAndDispatch = useCallback(\n (detail: ValueUpdateDetail<string>) => {\n // Should dispatch happen first? This will queue up a re-render, ordering should not cause issues (this is async)\n dispatch({ type: 'commit', payload: detail.value });\n onCommit?.(detail);\n },\n [onCommit, dispatch]\n );\n const {\n isDisabled: isFormDisabled,\n isReadonly: isFormReadonly,\n labelEdge: formLabelEdge,\n labelStartWidth: formLabelStartWidth,\n textAlign: formTextAlign,\n userAssistanceDensity: formUserAssistanceDensity\n } = useFormContext();\n // default to FormContext values if component properties are not specified\n const isDisabled = propIsDisabled ?? isFormDisabled;\n const isReadonly = propIsReadonly ?? isFormReadonly;\n const labelEdge = propLabelEdge ?? formLabelEdge;\n const labelStartWidth = propLabelStartWidth ?? formLabelStartWidth;\n const textAlign = propTextAlign ?? formTextAlign;\n const userAssistanceDensity = propUserAssistanceDensity ?? formUserAssistanceDensity;\n const maxLengthDescribedByIdRef = useRef<string>(useId());\n // The enabledAriaDescribedBy includes the maxLengthDescribedById in addition to what was passed in to aria-describedby.\n // We don't need to announce the max length message for readonly, as it only applies when editing the value.\n const enabledAriaDescribedBy = ariaDescribedBy\n ? `${ariaDescribedBy} ${maxLengthDescribedByIdRef.current}`\n : maxLengthDescribedByIdRef.current;\n\n const enabledElementRef = useRef<HTMLTextAreaElement>(null);\n const readonlyElementRef = useRef<HTMLTextAreaElement | HTMLDivElement>(null);\n\n const {\n focusProps,\n isFocused,\n methods: focusMethods\n } = useFocusableTextField<HTMLTextAreaElement, HTMLTextAreaElement | HTMLDivElement>({\n isDisabled,\n isReadonly,\n enabledElementRef,\n readonlyElementRef\n });\n\n const { methods: selectMethods } =\n useSelectableTextField<HTMLTextAreaElement>(enabledElementRef);\n\n useImperativeHandle(ref!, () => mergeProps(focusMethods, selectMethods), [\n focusMethods,\n selectMethods\n ]);\n\n // Handle length filter for user-typed inputs and controlled inputs\n const { isMaxLengthReached, valueLength, onFilteredInput } = useLengthFilter({\n maxLength,\n maxLengthUnit,\n value,\n onInput: onInputAndDispatch,\n onCommit: onCommitAndDispatch\n });\n\n const limitMessage = [{ detail: formControl_limitReached, severity: 'info' }];\n const allMessages = [\n ...(messages ?? []),\n ...(isMaxLengthReached ? limitMessage : [])\n ] as ComponentMessageItem[];\n\n const { formFieldContext, inputProps, labelProps, textFieldProps, userAssistanceProps } =\n useTextField({\n ariaDescribedBy: isReadonly || isDisabled ? ariaDescribedBy : enabledAriaDescribedBy,\n contentVariant: 'textarea',\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isFocused,\n isReadonly,\n isRequiredShown,\n labelEdge,\n messages: allMessages,\n styleVariant: variant,\n userAssistanceDensity,\n value\n });\n\n const onClickCounter = useCallback(() => {\n const elm = enabledElementRef.current;\n // for setSelectionRange(), len needs to be a number or null.\n const len = elm ? elm.value.length : null;\n // Since the counter element is after the text, clicking in this\n // should put the selection at the end of the text\n enabledElementRef.current?.setSelectionRange(len, len);\n // Clicking the counter should put the focus on the input field\n enabledElementRef.current?.focus();\n }, [enabledElementRef]);\n\n const labelComp = labelEdge !== 'none' ? <Label {...labelProps}>{label}</Label> : undefined;\n\n const fieldLabelProps = {\n label: labelEdge !== 'none' ? labelComp : undefined,\n labelEdge: labelEdge !== 'none' ? labelEdge : undefined,\n labelStartWidth: labelEdge !== 'none' ? labelStartWidth : undefined\n };\n\n const ariaLabel = labelEdge === 'none' ? label : undefined;\n const isInlineDensity =\n userAssistanceDensity === 'efficient' || userAssistanceDensity === 'reflow';\n\n const inlineUserAssistance = isInlineDensity ? (\n isDisabled || isReadonly ? (\n // save space for user assistance if density is 'efficient', even though we don't\n // render user assistance for disabled or readonly fields\n userAssistanceDensity !== 'efficient' ? undefined : (\n <InlineUserAssistance\n userAssistanceDensity={userAssistanceDensity}\n {...userAssistanceProps}\n />\n )\n ) : (\n <InlineUserAssistance\n assistiveText={assistiveText}\n fieldLabel={label}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n messages={allMessages}\n isRequiredShown={isRequiredShown}\n userAssistanceDensity={userAssistanceDensity}\n {...userAssistanceProps}\n />\n )\n ) : undefined;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n\n const compactUserAssistance =\n userAssistanceDensity === 'compact' ? (\n <CompactUserAssistance\n anchorRef={anchorRef}\n messages={allMessages}\n assistiveText={assistiveText}\n {...userAssistanceProps}\n />\n ) : undefined;\n\n useTextAreaAutosizing({\n isReadonly,\n enabledElementRef,\n readonlyElementRef,\n minRows,\n maxRows,\n value\n });\n\n if (isReadonly) {\n // TODO: should be able to configure whether start/end content is shown when readonly\n // JET-49916 - Preact InputText: show start/end content when readonly\n const mainContent = (\n <ReadonlyTextFieldInput\n aria-describedby={inputProps['aria-describedby']}\n aria-label={ariaLabel}\n aria-labelledby={labelProps.id}\n elementRef={readonlyElementRef}\n {...(maxRows ? { as: 'textarea', rows: minRows } : { as: 'div' })}\n autoFocus={autoFocus}\n textAlign={textAlign}\n value={value}\n variant=\"textarea\"\n hasEmptyLabel={label === '' && labelEdge === 'none'}\n hasInsideLabel={label !== undefined && labelEdge === 'inside'}\n />\n );\n return (\n <FormFieldContext.Provider value={formFieldContext}>\n <ReadonlyTextField\n role=\"presentation\"\n columnSpan={columnSpan}\n compactUserAssistance={compactUserAssistance}\n inlineUserAssistance={inlineUserAssistance}\n variant=\"textarea\"\n mainContent={mainContent}\n ref={anchorRef}\n testId={testId}\n {...fieldLabelProps}\n />\n </FormFieldContext.Provider>\n );\n }\n const hasMaxLength = maxLength !== undefined;\n const mainContent = (\n <>\n <TextFieldInput\n as=\"textarea\"\n aria-label={ariaLabel}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n currentCommitValue={currentCommitValue}\n hasEmptyLabel={label === '' && labelEdge === 'none'}\n hasInsideLabel={labelComp !== undefined && labelEdge === 'inside'}\n isRequired={isRequired}\n inputRef={enabledElementRef}\n onCommit={onCommitAndDispatch}\n onInput={onFilteredInput}\n placeholder={placeholder}\n role={role}\n rows={minRows}\n textAlign={textAlign}\n value={value}\n {...inputProps}\n />\n {maxLengthCounter === 'remaining' && hasMaxLength && (\n <MaxLengthCounter\n maxLength={maxLength}\n valueLength={valueLength}\n onClick={onClickCounter}\n />\n )}\n {hasMaxLength && (\n <HiddenAccessible id={maxLengthDescribedByIdRef.current}>\n {translations.formControl_maxLength({\n MAX_LENGTH: `${maxLength}`\n })}\n </HiddenAccessible>\n )}\n {hasMaxLength && isFocused && (\n <MaxLengthLiveRegion\n maxLength={maxLength}\n valueLength={valueLength}\n testId={testId + '_remainingChars'}\n />\n )}\n </>\n );\n\n return (\n <FormFieldContext.Provider value={formFieldContext}>\n <TextField\n mainContent={mainContent}\n columnSpan={columnSpan}\n compactUserAssistance={compactUserAssistance}\n inlineUserAssistance={inlineUserAssistance}\n onBlur={focusProps?.onFocusOut}\n onFocus={focusProps?.onFocusIn}\n mainFieldRef={anchorRef}\n testId={testId}\n {...textFieldProps}\n {...fieldLabelProps}\n />\n </FormFieldContext.Provider>\n );\n }\n);\n"],"names":["useTextAreaAutosizing","isReadonly","enabledElementRef","readonlyElementRef","minRows","maxRows","value","useLayoutEffect","textareaRef","current","HTMLDivElement","textarea","lineHeight","computedStyle","window","getComputedStyle","computedlineHeight","parseFloat","fontSize","calculateLineHeight","style","height","paddingHeight","borderHeight","cssStyle","paddingTop","paddingBottom","borderTop","borderBottom","getStylingHeight","heightForMinRows","scrollHeight","resizedHeight","undefined","heightForMaxRows","TextAreaAutosize","forwardRef","ariaDescribedBy","assistiveText","autoComplete","autoFocus","columnSpan","helpSourceLink","helpSourceText","isDisabled","propIsDisabled","propIsReadonly","isRequired","isRequiredShown","label","labelEdge","propLabelEdge","labelStartWidth","propLabelStartWidth","maxLength","maxLengthCounter","maxLengthUnit","messages","placeholder","role","textAlign","propTextAlign","userAssistanceDensity","propUserAssistanceDensity","variant","onInput","onCommit","testId","ref","translations","useTranslationBundle","formControl_limitReached","CHARACTER_LIMIT","currentCommitValue","dispatch","useCurrentValueReducer","onInputAndDispatch","useCallback","detail","type","payload","onCommitAndDispatch","isFormDisabled","isFormReadonly","formLabelEdge","formLabelStartWidth","formTextAlign","formUserAssistanceDensity","useFormContext","maxLengthDescribedByIdRef","useRef","useId","enabledAriaDescribedBy","focusProps","isFocused","methods","focusMethods","useFocusableTextField","selectMethods","useSelectableTextField","useImperativeHandle","mergeProps","isMaxLengthReached","valueLength","onFilteredInput","useLengthFilter","allMessages","severity","formFieldContext","inputProps","labelProps","textFieldProps","userAssistanceProps","useTextField","contentVariant","styleVariant","onClickCounter","elm","len","length","setSelectionRange","focus","labelComp","_jsx","jsx","Label","fieldLabelProps","ariaLabel","inlineUserAssistance","InlineUserAssistance","fieldLabel","anchorRef","compactUserAssistance","CompactUserAssistance","mainContent","ReadonlyTextFieldInput","id","elementRef","as","rows","hasEmptyLabel","hasInsideLabel","FormFieldContext","Provider","children","ReadonlyTextField","hasMaxLength","_jsxs","_Fragment","Fragment","TextFieldInput","inputRef","MaxLengthCounter","onClick","HiddenAccessible","formControl_maxLength","MAX_LENGTH","MaxLengthLiveRegion","TextField","onBlur","onFocusOut","onFocus","onFocusIn","mainFieldRef"],"mappings":"goDACO,MCeMA,EAAwB,EACnCC,aACAC,oBACAC,qBACAC,UAAU,EACVC,UACAC,YAEAC,EAAAA,iBAAgB,KACd,MAA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EAAasF,sBAAsB,CAClCC,WAAY,GAAGtG,QAIpB4F,IAAgBpD,IACf6B,MAACkC,EAAAA,oBACC,CAAAvG,UAAWA,EACXiD,YAAaA,GACbpC,OAAQA,EAAS,uBAMzB,OACEwD,EAAAA,IAACmB,EAAAA,iBAAiBC,UAASzI,MAAOsG,GAAgBoC,SAChDrB,EAAAA,IAACmC,EAAAA,WACCxB,YAAaA,GACb7F,WAAYA,EACZ2F,sBAAuBA,GACvBJ,qBAAsBA,GACtB+B,OAAQlE,IAAYmE,WACpBC,QAASpE,IAAYqE,UACrBC,aAAchC,GACdhE,OAAQA,KACJ4C,MACAe,MAGR"}
|
|
1
|
+
{"version":3,"file":"TextAreaAutosize-af350c32.js","sources":["../../src/UNSAFE_TextAreaAutosize/ScrollHeightUtils.tsx","../../src/UNSAFE_TextAreaAutosize/useTextAreaAutosizing.tsx","../../src/UNSAFE_TextAreaAutosize/TextAreaAutosize.tsx"],"sourcesContent":["// returns the lineHeight as a number of pixels.\nexport const calculateLineHeight = (textarea: HTMLTextAreaElement): number => {\n const computedStyle = window.getComputedStyle(textarea);\n const computedlineHeight = computedStyle.lineHeight;\n if (computedlineHeight === 'normal') {\n // We get 'normal' for values 'initial', 'inherit', 'unset' and 'normal'\n // TODO: Unclear if we need this.\n // getComputedStyle always return fontSize in pixels. Not likely a float, but since it's legal\n // we use parseFloat()\n const fontSize = parseFloat(computedStyle.fontSize);\n return 1.2 * fontSize;\n }\n return parseFloat(computedlineHeight);\n};\nexport const getStylingHeight = (textarea: HTMLTextAreaElement) => {\n const cssStyle = window.getComputedStyle(textarea);\n const paddingTop = parseFloat(cssStyle.paddingTop);\n const paddingBottom = parseFloat(cssStyle.paddingBottom);\n const borderTop = parseFloat(cssStyle.borderTop);\n const borderBottom = parseFloat(cssStyle.borderBottom);\n return { paddingHeight: paddingTop + paddingBottom, borderHeight: borderTop + borderBottom };\n};\n","import type { ComponentProps, RefObject } from 'preact';\nimport { useLayoutEffect } from 'preact/hooks';\nimport { calculateLineHeight, getStylingHeight } from './ScrollHeightUtils';\nimport { TextAreaAutosize } from './TextAreaAutosize';\n\ntype PickedPropsFromTextAreaAutosize = Pick<\n ComponentProps<typeof TextAreaAutosize>,\n 'minRows' | 'maxRows' | 'value'\n>;\ntype Props = PickedPropsFromTextAreaAutosize & {\n isReadonly?: boolean;\n enabledElementRef: RefObject<HTMLTextAreaElement>;\n readonlyElementRef: RefObject<HTMLTextAreaElement | HTMLDivElement>;\n};\n\n// TODO: Make this fire when the container resizes - JET-50840\nexport const useTextAreaAutosizing = ({\n isReadonly,\n enabledElementRef,\n readonlyElementRef,\n minRows = 2,\n maxRows,\n value\n}: Props) => {\n useLayoutEffect(() => {\n const textareaRef = isReadonly ? readonlyElementRef : enabledElementRef;\n if (textareaRef.current === null) return;\n if (textareaRef.current instanceof HTMLDivElement) return; // We don't need to do anything if the readonlyElement is a DIV.\n const textarea = textareaRef.current;\n const lineHeight = calculateLineHeight(textarea);\n textarea.style.height = '0';\n const { paddingHeight, borderHeight } = getStylingHeight(textarea);\n const heightForMinRows = lineHeight * minRows + paddingHeight + borderHeight;\n const scrollHeight = textarea.scrollHeight + borderHeight;\n let resizedHeight = 0;\n // if maxRows is -1 the textarea will grow or shrink to fit all the content.\n // it won't shrink any less than rows.\n if (maxRows === undefined) {\n // we want to fit the entire scrollHeight, but we don't want\n // to shrink smaller than the height for rows.\n if (scrollHeight < heightForMinRows) {\n resizedHeight = heightForMinRows;\n } else {\n resizedHeight = scrollHeight;\n }\n } else if (maxRows > minRows) {\n // if maxRows is positive and greater than rows, the textarea will grow to fit the content\n // up to maxrows, or shrink to fit the content and down to rows.\n const heightForMaxRows = lineHeight * maxRows + paddingHeight + borderHeight;\n if (scrollHeight > heightForMaxRows) {\n resizedHeight = heightForMaxRows;\n } else if (scrollHeight < heightForMinRows) {\n resizedHeight = heightForMinRows;\n } else {\n resizedHeight = scrollHeight;\n }\n } else {\n resizedHeight = heightForMinRows;\n }\n // The 0.5 gaurantees that the clientHeight will be bigger than the scrollHeight, so no scrollbar appears.\n textarea.style.height = resizedHeight + 0.5 + 'px';\n }, [value, minRows, maxRows, isReadonly, enabledElementRef, readonlyElementRef]);\n};\n","/**\n * @license\n * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.\n * The Universal Permissive License (UPL), Version 1.0\n * as shown at https://oss.oracle.com/licenses/upl/\n * @ignore\n */\n\nimport { ComponentProps, Ref } from 'preact';\nimport { forwardRef, useCallback, useImperativeHandle, useRef } from 'preact/compat';\nimport { useFormContext } from '../hooks/UNSAFE_useFormContext';\nimport { FormFieldContext } from '../hooks/UNSAFE_useFormFieldContext';\nimport { FocusableHandle, useFocusableTextField } from '../hooks/UNSAFE_useFocusableTextField';\nimport { Label } from '../UNSAFE_Label';\nimport {\n ReadonlyTextField,\n ReadonlyTextFieldInput,\n TextField,\n TextFieldInput\n} from '../UNSAFE_TextField';\nimport { useTextField } from '../hooks/UNSAFE_useTextField';\nimport {\n CompactUserAssistance,\n InlineUserAssistance,\n UserAssistanceDensityType\n} from '../UNSAFE_UserAssistance';\nimport { CountUnit, useLengthFilter } from '../hooks/UNSAFE_useLengthFilter';\nimport { MaxLengthLiveRegion } from '../UNSAFE_TextField';\nimport { useTextAreaAutosizing } from './useTextAreaAutosizing';\nimport { Size } from '../utils/UNSAFE_size';\nimport { useCurrentValueReducer } from '../hooks/UNSAFE_useCurrentValueReducer';\nimport { ValueUpdateDetail } from '../utils/UNSAFE_valueUpdateDetail';\nimport { MaxLengthCounter } from '../UNSAFE_TextArea';\nimport { useTranslationBundle } from '../hooks/UNSAFE_useTranslationBundle';\nimport { BundleType } from '../resources/nls/bundle';\nimport { ComponentMessageItem } from '../UNSAFE_ComponentMessage';\nimport { LayoutColumnSpan } from '../utils/UNSAFE_styles/Layout';\nimport type { TestIdProps } from '#hooks/UNSAFE_useTestId';\nimport { HiddenAccessible } from '../UNSAFE_HiddenAccessible';\nimport { useId } from '../hooks/UNSAFE_useId';\nimport { SelectableHandle, useSelectableTextField } from '#hooks/UNSAFE_useSelectableTextField';\nimport { mergeProps } from '#utils/UNSAFE_mergeProps';\n\ntype TextFieldInputProps = ComponentProps<typeof TextFieldInput>;\ntype InlineUserAssistanceProps = ComponentProps<typeof InlineUserAssistance>;\n\ntype Props = TestIdProps & {\n /**\n * The ID of an element (or space separated IDs of multiple elements) that\n * describes the input.\n */\n 'aria-describedby'?: TextFieldInputProps['aria-describedby'];\n /**\n * Text to provide guidance to help the user understand what to enter.\n */\n assistiveText?: InlineUserAssistanceProps['assistiveText'];\n /**\n * Dictates component's autocomplete state.\n * This attribute indicates whether the value of the control can be automatically completed by the browser.\n * The common values are \"on\" and \"off\".\n */\n autoComplete?: TextFieldInputProps['autoComplete'];\n /**\n * Autofocus specifies whether the component will get focus when the page is loaded.\n * If it is set to true then the associated component will get input focus when the page is loaded.\n * Setting this property doesn't set the focus to the component; it tells the browser to focus\n * to it when the element is inserted in the document.\n */\n autoFocus?: TextFieldInputProps['autoFocus'];\n /**\n * Specifies how many columns to span in a FormLayout with direction === 'row'\n */\n columnSpan?: LayoutColumnSpan;\n /**\n * Help source URL associated with the component.\n */\n helpSourceLink?: InlineUserAssistanceProps['helpSourceLink'];\n /**\n * Custom text to be rendered for the <code>helpSourceLink</code>.\n */\n helpSourceText?: InlineUserAssistanceProps['helpSourceText'];\n /**\n * Specifies whether the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * Specifies whether the component is readonly.\n */\n isReadonly?: boolean;\n /**\n * Specifies for accessibility purposes whether a value is required.\n *\n * Setting this property to <code>false</code> means that a value is not required to be\n * committed by the user. Setting this property to <code>true</code> means that a value\n * is required to be committed by the user.\n */\n isRequired?: TextFieldInputProps['isRequired'];\n /**\n * Specifies whether to show an indicator on screen that a value is required, for example\n * before the user has committed a value.\n */\n isRequiredShown?: InlineUserAssistanceProps['isRequiredShown'];\n /**\n * Specifies the label associated with the field.\n */\n label: string;\n /**\n * Specifies where the label is positioned relative to the field.\n */\n labelEdge?: 'inside' | 'start' | 'top' | 'none';\n /**\n * Specifies the width of the label when <code>labelEdge</code> is <code>\"start\"</code>\n */\n labelStartWidth?: Size;\n /**\n * Specifies the maximum number of characters that can be entered in the input field.\n */\n maxLength?: number;\n /**\n * Determines whether the remaining number of characters that can be entered is shown or not.\n */\n maxLengthCounter?: 'none' | 'remaining';\n /**\n * Specifies how the input text characters are to be counted when maxLength is specified.\n */\n maxLengthUnit?: CountUnit;\n /**\n * Specifies the maximum number of rows that the TextAreaAutosize is allowed to grow to.\n * If maxRows is less than minRows, it is ignored.\n */\n maxRows?: number;\n /**\n * Messages to show on screen that are associated with the component.\n */\n messages?: InlineUserAssistanceProps['messages'];\n /**\n * Specifies the minimum number of rows that the TextAreaAutosize is allowed to shrink to.\n */\n minRows?: number;\n /**\n * A short hint to display before the user enters a value.\n */\n placeholder?: TextFieldInputProps['placeholder'];\n /**\n * Specifies how the user is allowed to manually resize the TextArea component.\n */\n role?: TextFieldInputProps['role'];\n /**\n * Specifies the number of rows to display\n */\n textAlign?: TextFieldInputProps['textAlign'];\n /**\n * Specifies the density of the user assistance presentation. It can be set to:\n * <ul>\n * <li><code>'efficient'</code>: Show inline and reserve space to prevent layout reflow when user\n * assistance text is displayed.</li>\n * <li><code>'reflow'</code>: Show inline. Layout will reflow when text is displayed.</li>\n * <li><code>'compact'</code>: Messages, help, hints, and required will not be shown inline; they will show in a mode that keeps the screen more compact, like a popup for the messages, and a required icon to indicate Required. </li>\n * </ul>\n */\n userAssistanceDensity?: UserAssistanceDensityType;\n /**\n * The current display value of the component.\n */\n value?: TextFieldInputProps['value'];\n /**\n * The style variant of the component.\n */\n variant?: TextFieldInputProps['variant'];\n /**\n * Callback invoked when the user commits the entered value by blurring out of the field.\n *\n */\n onCommit?: TextFieldInputProps['onCommit'];\n\n /**\n * Callback invoked when the user inputs a value.\n *\n */\n onInput: TextFieldInputProps['onInput'];\n};\ntype FocusSelectHandle = FocusableHandle & SelectableHandle;\n/**\n * A text area auto size displays a field that allows a user to enter a multi-line text value, and will adjust its height based on its content.\n */\nexport const TextAreaAutosize = forwardRef(\n (\n {\n 'aria-describedby': ariaDescribedBy,\n assistiveText,\n autoComplete = 'off',\n autoFocus = false,\n columnSpan,\n helpSourceLink,\n helpSourceText,\n isDisabled: propIsDisabled,\n isReadonly: propIsReadonly,\n isRequired = false,\n isRequiredShown,\n label,\n labelEdge: propLabelEdge,\n labelStartWidth: propLabelStartWidth,\n maxLength,\n maxLengthCounter = 'remaining',\n maxLengthUnit,\n maxRows,\n messages,\n minRows = 2,\n placeholder,\n role,\n //TODO: Add counter to show the length remaining - JET-50752\n textAlign: propTextAlign,\n userAssistanceDensity: propUserAssistanceDensity,\n value,\n variant = 'default',\n onInput,\n onCommit,\n testId\n }: Props,\n ref?: Ref<FocusSelectHandle>\n ) => {\n const translations = useTranslationBundle<BundleType>('@oracle/oraclejet-preact');\n const formControl_limitReached = maxLength\n ? translations.formControl_limitReached({\n CHARACTER_LIMIT: maxLength\n })\n : '';\n\n const { currentCommitValue, dispatch } = useCurrentValueReducer({ value });\n const onInputAndDispatch = useCallback(\n (detail: ValueUpdateDetail<string>) => {\n // Should dispatch happen first? This will queue up a re-render, ordering should not cause issues (this is async)\n dispatch({ type: 'input', payload: detail.value });\n onInput?.(detail);\n },\n [onInput, dispatch]\n );\n const onCommitAndDispatch = useCallback(\n (detail: ValueUpdateDetail<string>) => {\n // Should dispatch happen first? This will queue up a re-render, ordering should not cause issues (this is async)\n dispatch({ type: 'commit', payload: detail.value });\n onCommit?.(detail);\n },\n [onCommit, dispatch]\n );\n const {\n isDisabled: isFormDisabled,\n isReadonly: isFormReadonly,\n labelEdge: formLabelEdge,\n labelStartWidth: formLabelStartWidth,\n textAlign: formTextAlign,\n userAssistanceDensity: formUserAssistanceDensity\n } = useFormContext();\n // default to FormContext values if component properties are not specified\n const isDisabled = propIsDisabled ?? isFormDisabled;\n const isReadonly = propIsReadonly ?? isFormReadonly;\n const labelEdge = propLabelEdge ?? formLabelEdge;\n const labelStartWidth = propLabelStartWidth ?? formLabelStartWidth;\n const textAlign = propTextAlign ?? formTextAlign;\n const userAssistanceDensity = propUserAssistanceDensity ?? formUserAssistanceDensity;\n const maxLengthDescribedByIdRef = useRef<string>(useId());\n // The enabledAriaDescribedBy includes the maxLengthDescribedById in addition to what was passed in to aria-describedby.\n // We don't need to announce the max length message for readonly, as it only applies when editing the value.\n const enabledAriaDescribedBy = ariaDescribedBy\n ? `${ariaDescribedBy} ${maxLengthDescribedByIdRef.current}`\n : maxLengthDescribedByIdRef.current;\n\n const enabledElementRef = useRef<HTMLTextAreaElement>(null);\n const readonlyElementRef = useRef<HTMLTextAreaElement | HTMLDivElement>(null);\n\n const {\n focusProps,\n isFocused,\n methods: focusMethods\n } = useFocusableTextField<HTMLTextAreaElement, HTMLTextAreaElement | HTMLDivElement>({\n isDisabled,\n isReadonly,\n enabledElementRef,\n readonlyElementRef\n });\n\n const { methods: selectMethods } =\n useSelectableTextField<HTMLTextAreaElement>(enabledElementRef);\n\n useImperativeHandle(ref!, () => mergeProps(focusMethods, selectMethods), [\n focusMethods,\n selectMethods\n ]);\n\n // Handle length filter for user-typed inputs and controlled inputs\n const { isMaxLengthReached, valueLength, onFilteredInput } = useLengthFilter({\n maxLength,\n maxLengthUnit,\n value,\n onInput: onInputAndDispatch,\n onCommit: onCommitAndDispatch\n });\n\n const limitMessage = [{ detail: formControl_limitReached, severity: 'info' }];\n const allMessages = [\n ...(messages ?? []),\n ...(isMaxLengthReached ? limitMessage : [])\n ] as ComponentMessageItem[];\n\n const { formFieldContext, inputProps, labelProps, textFieldProps, userAssistanceProps } =\n useTextField({\n ariaDescribedBy: isReadonly || isDisabled ? ariaDescribedBy : enabledAriaDescribedBy,\n contentVariant: 'textarea',\n helpSourceLink,\n helpSourceText,\n isDisabled,\n isFocused,\n isReadonly,\n isRequiredShown,\n labelEdge,\n messages: allMessages,\n styleVariant: variant,\n userAssistanceDensity,\n value\n });\n\n const onClickCounter = useCallback(() => {\n const elm = enabledElementRef.current;\n // for setSelectionRange(), len needs to be a number or null.\n const len = elm ? elm.value.length : null;\n // Since the counter element is after the text, clicking in this\n // should put the selection at the end of the text\n enabledElementRef.current?.setSelectionRange(len, len);\n // Clicking the counter should put the focus on the input field\n enabledElementRef.current?.focus();\n }, [enabledElementRef]);\n\n const labelComp = labelEdge !== 'none' ? <Label {...labelProps}>{label}</Label> : undefined;\n\n const fieldLabelProps = {\n label: labelEdge !== 'none' ? labelComp : undefined,\n labelEdge: labelEdge !== 'none' ? labelEdge : undefined,\n labelStartWidth: labelEdge !== 'none' ? labelStartWidth : undefined\n };\n\n const ariaLabel = labelEdge === 'none' ? label : undefined;\n const isInlineDensity =\n userAssistanceDensity === 'efficient' || userAssistanceDensity === 'reflow';\n\n const inlineUserAssistance = isInlineDensity ? (\n isDisabled || isReadonly ? (\n // save space for user assistance if density is 'efficient', even though we don't\n // render user assistance for disabled or readonly fields\n userAssistanceDensity !== 'efficient' ? undefined : (\n <InlineUserAssistance\n userAssistanceDensity={userAssistanceDensity}\n {...userAssistanceProps}\n />\n )\n ) : (\n <InlineUserAssistance\n assistiveText={assistiveText}\n fieldLabel={label}\n helpSourceLink={helpSourceLink}\n helpSourceText={helpSourceText}\n messages={allMessages}\n isRequiredShown={isRequiredShown}\n userAssistanceDensity={userAssistanceDensity}\n {...userAssistanceProps}\n />\n )\n ) : undefined;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n\n const compactUserAssistance =\n userAssistanceDensity === 'compact' ? (\n <CompactUserAssistance\n anchorRef={anchorRef}\n messages={allMessages}\n assistiveText={assistiveText}\n {...userAssistanceProps}\n />\n ) : undefined;\n\n useTextAreaAutosizing({\n isReadonly,\n enabledElementRef,\n readonlyElementRef,\n minRows,\n maxRows,\n value\n });\n\n if (isReadonly) {\n // TODO: should be able to configure whether start/end content is shown when readonly\n // JET-49916 - Preact InputText: show start/end content when readonly\n const mainContent = (\n <ReadonlyTextFieldInput\n aria-describedby={inputProps['aria-describedby']}\n aria-label={ariaLabel}\n aria-labelledby={labelProps.id}\n elementRef={readonlyElementRef}\n {...(maxRows ? { as: 'textarea', rows: minRows } : { as: 'div' })}\n autoFocus={autoFocus}\n textAlign={textAlign}\n value={value}\n variant=\"textarea\"\n hasEmptyLabel={label === '' && labelEdge === 'none'}\n hasInsideLabel={label !== undefined && labelEdge === 'inside'}\n />\n );\n return (\n <FormFieldContext.Provider value={formFieldContext}>\n <ReadonlyTextField\n role=\"presentation\"\n columnSpan={columnSpan}\n compactUserAssistance={compactUserAssistance}\n inlineUserAssistance={inlineUserAssistance}\n variant=\"textarea\"\n mainContent={mainContent}\n ref={anchorRef}\n testId={testId}\n {...fieldLabelProps}\n />\n </FormFieldContext.Provider>\n );\n }\n const hasMaxLength = maxLength !== undefined;\n const mainContent = (\n <>\n <TextFieldInput\n as=\"textarea\"\n aria-label={ariaLabel}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n currentCommitValue={currentCommitValue}\n hasEmptyLabel={label === '' && labelEdge === 'none'}\n hasInsideLabel={labelComp !== undefined && labelEdge === 'inside'}\n isRequired={isRequired}\n inputRef={enabledElementRef}\n onCommit={onCommitAndDispatch}\n onInput={onFilteredInput}\n placeholder={placeholder}\n role={role}\n rows={minRows}\n textAlign={textAlign}\n value={value}\n {...inputProps}\n />\n {maxLengthCounter === 'remaining' && hasMaxLength && (\n <MaxLengthCounter\n maxLength={maxLength}\n valueLength={valueLength}\n onClick={onClickCounter}\n />\n )}\n {hasMaxLength && (\n <HiddenAccessible id={maxLengthDescribedByIdRef.current}>\n {translations.formControl_maxLength({\n MAX_LENGTH: `${maxLength}`\n })}\n </HiddenAccessible>\n )}\n {hasMaxLength && isFocused && (\n <MaxLengthLiveRegion\n maxLength={maxLength}\n valueLength={valueLength}\n testId={testId + '_remainingChars'}\n />\n )}\n </>\n );\n\n return (\n <FormFieldContext.Provider value={formFieldContext}>\n <TextField\n mainContent={mainContent}\n columnSpan={columnSpan}\n compactUserAssistance={compactUserAssistance}\n inlineUserAssistance={inlineUserAssistance}\n onBlur={focusProps?.onFocusOut}\n onFocus={focusProps?.onFocusIn}\n mainFieldRef={anchorRef}\n testId={testId}\n {...textFieldProps}\n {...fieldLabelProps}\n />\n </FormFieldContext.Provider>\n );\n }\n);\n"],"names":["useTextAreaAutosizing","isReadonly","enabledElementRef","readonlyElementRef","minRows","maxRows","value","useLayoutEffect","textareaRef","current","HTMLDivElement","textarea","lineHeight","computedStyle","window","getComputedStyle","computedlineHeight","parseFloat","fontSize","calculateLineHeight","style","height","paddingHeight","borderHeight","cssStyle","paddingTop","paddingBottom","borderTop","borderBottom","getStylingHeight","heightForMinRows","scrollHeight","resizedHeight","undefined","heightForMaxRows","TextAreaAutosize","forwardRef","ariaDescribedBy","assistiveText","autoComplete","autoFocus","columnSpan","helpSourceLink","helpSourceText","isDisabled","propIsDisabled","propIsReadonly","isRequired","isRequiredShown","label","labelEdge","propLabelEdge","labelStartWidth","propLabelStartWidth","maxLength","maxLengthCounter","maxLengthUnit","messages","placeholder","role","textAlign","propTextAlign","userAssistanceDensity","propUserAssistanceDensity","variant","onInput","onCommit","testId","ref","translations","useTranslationBundle","formControl_limitReached","CHARACTER_LIMIT","currentCommitValue","dispatch","useCurrentValueReducer","onInputAndDispatch","useCallback","detail","type","payload","onCommitAndDispatch","isFormDisabled","isFormReadonly","formLabelEdge","formLabelStartWidth","formTextAlign","formUserAssistanceDensity","useFormContext","maxLengthDescribedByIdRef","useRef","useId","enabledAriaDescribedBy","focusProps","isFocused","methods","focusMethods","useFocusableTextField","selectMethods","useSelectableTextField","useImperativeHandle","mergeProps","isMaxLengthReached","valueLength","onFilteredInput","useLengthFilter","allMessages","severity","formFieldContext","inputProps","labelProps","textFieldProps","userAssistanceProps","useTextField","contentVariant","styleVariant","onClickCounter","elm","len","length","setSelectionRange","focus","labelComp","_jsx","jsx","Label","fieldLabelProps","ariaLabel","inlineUserAssistance","InlineUserAssistance","fieldLabel","anchorRef","compactUserAssistance","CompactUserAssistance","mainContent","ReadonlyTextFieldInput","id","elementRef","as","rows","hasEmptyLabel","hasInsideLabel","FormFieldContext","Provider","children","ReadonlyTextField","hasMaxLength","_jsxs","_Fragment","Fragment","TextFieldInput","inputRef","MaxLengthCounter","onClick","HiddenAccessible","formControl_maxLength","MAX_LENGTH","MaxLengthLiveRegion","TextField","onBlur","onFocusOut","onFocus","onFocusIn","mainFieldRef"],"mappings":"woDACO,MCeMA,EAAwB,EACnCC,aACAC,oBACAC,qBACAC,UAAU,EACVC,UACAC,YAEAC,EAAAA,iBAAgB,KACd,MAAMC,EAAcP,EAAaE,EAAqBD,EACtD,GAA4B,OAAxBM,EAAYC,QAAkB,OAClC,GAAID,EAAYC,mBAAmBC,eAAgB,OACnD,MAAMC,EAAWH,EAAYC,QACvBG,ED5ByB,CAACD,IAClC,MAAME,EAAgBC,OAAOC,iBAAiBJ,GACxCK,EAAqBH,EAAcD,WACzC,GAA2B,WAAvBI,EAMF,OAAO,IADUC,WAAWJ,EAAcK,UAG5C,OAAOD,WAAWD,EAAmB,ECiBhBG,CAAoBR,GACvCA,EAASS,MAAMC,OAAS,IACxB,MAAMC,cAAEA,EAAaC,aAAEA,GDjBK,CAACZ,IAC/B,MAAMa,EAAWV,OAAOC,iBAAiBJ,GAKzC,MAAO,CAAEW,cAJUL,WAAWO,EAASC,YACjBR,WAAWO,EAASE,eAGUH,aAFlCN,WAAWO,EAASG,WACjBV,WAAWO,EAASI,cACmD,ECWlDC,CAAiBlB,GACnDmB,EAAmBlB,EAAaR,EAAUkB,EAAgBC,EAC1DQ,EAAepB,EAASoB,aAAeR,EAC7C,IAAIS,EAAgB,EAGpB,QAAgBC,IAAZ5B,EAIA2B,EADED,EAAeD,EACDA,EAEAC,OAEb,GAAI1B,EAAUD,EAAS,CAG5B,MAAM8B,EAAmBtB,EAAaP,EAAUiB,EAAgBC,EAE9DS,EADED,EAAeG,EACDA,EACPH,EAAeD,EACRA,EAEAC,CAEnB,MACCC,EAAgBF,EAGlBnB,EAASS,MAAMC,OAAS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