carbon-react 156.4.0 → 156.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/__internal__/input/input.component.d.ts +3 -1
- package/esm/components/advanced-color-picker/advanced-color-picker.component.d.ts +3 -5
- package/esm/components/advanced-color-picker/advanced-color-picker.component.js +1 -1
- package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.d.ts +4 -4
- package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.js +1 -1
- package/esm/components/checkbox/checkbox.component.d.ts +4 -0
- package/esm/components/checkbox/checkbox.component.js +1 -1
- package/esm/components/decimal/decimal.component.d.ts +4 -6
- package/esm/components/decimal/decimal.component.js +1 -1
- package/esm/components/file-input/file-input.style.d.ts +4 -1
- package/esm/components/file-input/file-input.style.js +1 -1
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +2 -2
- package/esm/components/grouped-character/grouped-character.component.d.ts +4 -6
- package/esm/components/grouped-character/grouped-character.component.js +1 -1
- package/esm/components/number/number.component.d.ts +1 -1
- package/esm/components/number/number.component.js +1 -1
- package/esm/components/numeral-date/numeral-date.component.d.ts +3 -5
- package/esm/components/numeral-date/numeral-date.component.js +1 -1
- package/esm/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -2
- package/esm/components/radio-button/radio-button-group/radio-button-group.component.js +1 -1
- package/esm/components/search/search.component.d.ts +3 -5
- package/esm/components/search/search.component.js +1 -1
- package/esm/components/select/__internal__/select-textbox/select-textbox.component.d.ts +2 -0
- package/esm/components/select/__internal__/select-textbox/select-textbox.component.js +1 -1
- package/esm/components/select/filterable-select/filterable-select.component.d.ts +3 -5
- package/esm/components/select/filterable-select/filterable-select.component.js +1 -1
- package/esm/components/select/multi-select/multi-select.component.d.ts +3 -5
- package/esm/components/select/multi-select/multi-select.component.js +1 -1
- package/esm/components/select/simple-select/simple-select.component.d.ts +3 -5
- package/esm/components/select/simple-select/simple-select.component.js +1 -1
- package/esm/components/simple-color-picker/simple-color/simple-color.component.d.ts +2 -0
- package/esm/components/simple-color-picker/simple-color/simple-color.component.js +1 -1
- package/esm/components/simple-color-picker/simple-color-picker.component.d.ts +2 -2
- package/esm/components/simple-color-picker/simple-color-picker.component.js +1 -1
- package/esm/components/switch/switch.component.d.ts +5 -3
- package/esm/components/switch/switch.component.js +1 -1
- package/esm/components/textarea/textarea.component.d.ts +7 -2
- package/esm/components/textarea/textarea.component.js +1 -1
- package/esm/components/textbox/textbox.component.d.ts +2 -2
- package/esm/components/textbox/textbox.component.js +1 -1
- package/esm/hooks/use-multi-input/index.d.ts +1 -0
- package/esm/hooks/use-multi-input/index.js +1 -0
- package/esm/hooks/use-multi-input/use-multi-input.d.ts +19 -0
- package/esm/hooks/use-multi-input/use-multi-input.js +1 -0
- package/esm/hooks/useCharacterCount/useCharacterCount.d.ts +1 -1
- package/esm/hooks/useCharacterCount/useCharacterCount.js +1 -1
- package/lib/__internal__/input/input.component.d.ts +3 -1
- package/lib/components/advanced-color-picker/advanced-color-picker.component.d.ts +3 -5
- package/lib/components/advanced-color-picker/advanced-color-picker.component.js +1 -1
- package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.d.ts +4 -4
- package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.js +1 -1
- package/lib/components/checkbox/checkbox.component.d.ts +4 -0
- package/lib/components/checkbox/checkbox.component.js +1 -1
- package/lib/components/decimal/decimal.component.d.ts +4 -6
- package/lib/components/decimal/decimal.component.js +1 -1
- package/lib/components/file-input/file-input.style.d.ts +4 -1
- package/lib/components/file-input/file-input.style.js +1 -1
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +2 -2
- package/lib/components/grouped-character/grouped-character.component.d.ts +4 -6
- package/lib/components/grouped-character/grouped-character.component.js +1 -1
- package/lib/components/number/number.component.d.ts +1 -1
- package/lib/components/number/number.component.js +1 -1
- package/lib/components/numeral-date/numeral-date.component.d.ts +3 -5
- package/lib/components/numeral-date/numeral-date.component.js +1 -1
- package/lib/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -2
- package/lib/components/radio-button/radio-button-group/radio-button-group.component.js +1 -1
- package/lib/components/search/search.component.d.ts +3 -5
- package/lib/components/search/search.component.js +1 -1
- package/lib/components/select/__internal__/select-textbox/select-textbox.component.d.ts +2 -0
- package/lib/components/select/__internal__/select-textbox/select-textbox.component.js +1 -1
- package/lib/components/select/filterable-select/filterable-select.component.d.ts +3 -5
- package/lib/components/select/filterable-select/filterable-select.component.js +1 -1
- package/lib/components/select/multi-select/multi-select.component.d.ts +3 -5
- package/lib/components/select/multi-select/multi-select.component.js +1 -1
- package/lib/components/select/simple-select/simple-select.component.d.ts +3 -5
- package/lib/components/select/simple-select/simple-select.component.js +1 -1
- package/lib/components/simple-color-picker/simple-color/simple-color.component.d.ts +2 -0
- package/lib/components/simple-color-picker/simple-color/simple-color.component.js +1 -1
- package/lib/components/simple-color-picker/simple-color-picker.component.d.ts +2 -2
- package/lib/components/simple-color-picker/simple-color-picker.component.js +1 -1
- package/lib/components/switch/switch.component.d.ts +5 -3
- package/lib/components/switch/switch.component.js +1 -1
- package/lib/components/textarea/textarea.component.d.ts +7 -2
- package/lib/components/textarea/textarea.component.js +1 -1
- package/lib/components/textbox/textbox.component.d.ts +2 -2
- package/lib/components/textbox/textbox.component.js +1 -1
- package/lib/hooks/use-multi-input/index.d.ts +1 -0
- package/lib/hooks/use-multi-input/index.js +1 -0
- package/lib/hooks/use-multi-input/package.json +6 -0
- package/lib/hooks/use-multi-input/use-multi-input.d.ts +19 -0
- package/lib/hooks/use-multi-input/use-multi-input.js +1 -0
- package/lib/hooks/useCharacterCount/useCharacterCount.d.ts +1 -1
- package/lib/hooks/useCharacterCount/useCharacterCount.js +1 -1
- package/package.json +1 -1
|
@@ -10,8 +10,6 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
|
|
|
10
10
|
"aria-labelledby"?: string;
|
|
11
11
|
/** Child components (such as Option or OptionRow) for the SelectList */
|
|
12
12
|
children: React.ReactNode;
|
|
13
|
-
/** The default selected value(s), when the component is operating in uncontrolled mode */
|
|
14
|
-
defaultValue?: string | Record<string, unknown>;
|
|
15
13
|
/** If true the loader animation is displayed in the option list */
|
|
16
14
|
isLoading?: boolean;
|
|
17
15
|
/** True for default text button or a Button Component to be rendered */
|
|
@@ -36,8 +34,8 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
|
|
|
36
34
|
* Works only in multiColumn mode
|
|
37
35
|
*/
|
|
38
36
|
tableHeader?: React.ReactNode;
|
|
39
|
-
/** The selected value(s)
|
|
40
|
-
value
|
|
37
|
+
/** The selected value(s) */
|
|
38
|
+
value: string | Record<string, unknown>;
|
|
41
39
|
/** [Legacy] Overrides the default tooltip position */
|
|
42
40
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
43
41
|
/** Maximum list height - defaults to 180 */
|
|
@@ -59,7 +57,7 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
|
|
|
59
57
|
/** Flag to configure component as mandatory */
|
|
60
58
|
required?: boolean;
|
|
61
59
|
/** Specify a callback triggered on change */
|
|
62
|
-
onChange
|
|
60
|
+
onChange: (ev: CustomSelectChangeEvent | React.ChangeEvent<HTMLInputElement>) => void;
|
|
63
61
|
/** Override the default width of the list element. Number passed is converted into pixel value */
|
|
64
62
|
listWidth?: number;
|
|
65
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useState as r,useRef as o,useCallback as l,useEffect as i}from"react";import a from"invariant";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../select.style.js";import f from"../__internal__/select-list/select-list.component.js";import b from"../__internal__/utils/is-expected-option.js";import v from"../__internal__/utils/are-objects-equal.js";import
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useState as r,useRef as o,useCallback as l,useEffect as i}from"react";import a from"invariant";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../select.style.js";import f from"../__internal__/select-list/select-list.component.js";import b from"../__internal__/utils/is-expected-option.js";import v from"../__internal__/utils/are-objects-equal.js";import y from"../__internal__/utils/is-navigation-key.js";import{useStableCallback as g}from"../../../hooks/__internal__/useStableCallback/useStableCallback.js";import h from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){O(e,t,n[t])}))}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const w=p(f),C=n.forwardRef(((p,O)=>{var{"aria-label":C,"aria-labelledby":x,value:L,id:S,name:P,label:k,children:D,onOpen:A,onChange:E,onFilterChange:B,onClick:F,onKeyDown:M,onFocus:T,onBlur:I,openOnFocus:V,noResultsMessage:H,listActionButton:W,listMaxHeight:q,onListAction:K,isLoading:R,disabled:z,readOnly:G,onListScrollBottom:J,tableHeader:N,multiColumn:Q,"data-element":U,"data-role":X,tooltipPosition:Y,listPlacement:Z="bottom",flipEnabled:$=!0,enableVirtualScroll:ee,virtualScrollOverscan:te,disableDefaultFiltering:ne=!1,required:re,listWidth:oe}=p,le=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(p,["aria-label","aria-labelledby","value","id","name","label","children","onOpen","onChange","onFilterChange","onClick","onKeyDown","onFocus","onBlur","openOnFocus","noResultsMessage","listActionButton","listMaxHeight","onListAction","isLoading","disabled","readOnly","onListScrollBottom","tableHeader","multiColumn","data-element","data-role","tooltipPosition","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","disableDefaultFiltering","required","listWidth"]);const[ie,ae]=r(""),se=o(d()),ce=o(null),ue=o(null),de=o(!1),pe=o(!1),me=o(!1),[fe,be]=r(),[ve,ye]=r(!1),[ge,he]=r(""),[Oe,_e]=r(L||""),je=o(L),[we,Ce]=r(""),[xe,Le]=r(""),Se=o(S||d()),{labelId:Pe}=h({id:Se.current,label:k}),ke=o(null),De=o(!1),Ae=l(((e,t)=>({target:j(_({},P&&{name:P},S&&{id:S}),{value:e}),selectionConfirmed:t})),[P,S]),Ee=l(((e,t)=>{E&&E(Ae(e,t))}),[E,Ae]),Be=l(((e,t)=>{_e((()=>{var r;const o=e.trimStart(),l=(i=o,a=D,n.Children.toArray(a).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==i?void 0:i.toLowerCase()))})));var i,a;const s=t&&!e.length;return!l||s||l.props.disabled?(he(e),Ee("",!1),""):(o.length&&Ee(l.props.value,!1),t?(he(e),l.props.value):(o.length&&(null===(r=l.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(o.toLowerCase()))?he(l.props.text):he(e),Ce(l.props.value),l.props.value))}))}),[D,Ee]),Fe=l(((e,t=!1)=>{var r;const o=n.Children.toArray(D).find((t=>n.isValidElement(t)&&b(t,e)));o&&void 0!==o.props.text?(t||(null===(r=o.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(null==xe?void 0:xe.toLowerCase().trim())))&&he(o.props.text):he(xe||"")}),[D,xe]),Me=l((e=>{const t=e.target.value,{inputType:n}=e.nativeEvent;Be(t,"deleteContentBackward"===n||"deleteContentForward"===n||"delete"===n),Le(t),ye(!0)}),[Be]),Te=l((e=>{Le((t=>(null==t?void 0:t.length)===(null==ge?void 0:ge.length)-1&&e===ge.slice(-1)?ge:t))}),[ge]),Ie=l((e=>{const{key:t}=e;M&&M(e),G||(!e.defaultPrevented&&y(t)&&(e.preventDefault(),ye(!0)),Te(t))}),[Te,M,G]),Ve=l((e=>{const t=ce.current&&!ce.current.contains(e.target),n=ue.current&&!ue.current.contains(e.target);de.current=!1,t&&n&&(Fe(L,!0),ye(!1))}),[Fe,L]);i((()=>{_e((e=>(L&&e!==L&&Fe(L),L))),Ce(L)}),[L,E,D]);const He=g(A);i((()=>{ve?He&&He():Le("")}),[He,ve]),i((()=>{const e=void 0!==W;a(!e||e&&K,"onListAction prop required when using listActionButton prop")}),[W,K]);const We=o(!0);i((()=>{We.current&&Fe(Oe),"object"==typeof L&&"object"==typeof je.current?v(L,je.current)||(Fe(L),je.current=L):Fe(L)}),[L,D]);const qe=g(B);i((()=>{qe&&!We.current&&qe(xe)}),[qe,xe]),i((()=>{We.current=!1}),[]),i((()=>{const e="click";return window.addEventListener(e,Ve),function(){window.removeEventListener(e,Ve)}}),[Ve]),i((()=>{const e=null==xe?void 0:xe.trimStart(),t=null==ge?void 0:ge.toLowerCase().startsWith(e.toLowerCase());!z&&!G&&fe&&e.length&&(null==ge?void 0:ge.length)>e.length&&t&&(fe.selectionStart=e.length)}),[ge,xe,fe,z,G]);const Ke=l((e=>{const{id:t,text:n,value:r,selectionType:o,selectionConfirmed:l}=e;he(n),Ee(r,!!l),ae(t),"navigationKey"!==o&&(De.current=!!V,ye(!1),null==fe||fe.focus(),null==fe||fe.select(),De.current=!1)}),[fe,Ee,V]),Re=l((()=>{ye(!1),Fe(Oe,!0)}),[Oe,Fe]);function ze(e){de.current=!0,"input"===e.target.dataset.element&&(me.current=!0)}i((()=>()=>{ke.current&&clearTimeout(ke.current)}),[]);const Ge=l((e=>{e&&(be(e),O&&("function"==typeof O?O(e):O.current=e))}),[O]);let Je;switch(Z){case"top":Je="top-end";break;case"bottom":Je="bottom-end";break;default:Je=Z}const Ne={ref:ue,id:se.current,labelId:Pe,anchorElement:(null==fe?void 0:fe.parentElement)||void 0,onSelect:Ke,onSelectListClose:Re,onMouseDown:function(){de.current=!0},filterText:xe.trim(),highlightedValue:we,noResultsMessage:H,listActionButton:W,listMaxHeight:q,onListAction:function(){ye(!1),null==K||K()},isLoading:R,onListScrollBottom:J,tableHeader:N,multiColumn:Q,listPlacement:void 0!==oe?Je:Z,flipEnabled:$,isOpen:ve,enableVirtualScroll:ee,virtualScrollOverscan:te,listWidth:oe},Qe=e(ne?f:w,j(_({},Ne),{children:D})),Ue=s(le);return t(m,j(_({hasTextCursor:!0,readOnly:G,disabled:z,"data-component":"filterable-select","data-role":X,"data-element":U,isOpen:ve},Ue),{children:[e("div",{ref:ce,children:e(u,j(_({ref:Ge,activeDescendantId:ie,ariaLabel:C,ariaLabelledby:x,labelId:k?Pe:void 0,"aria-controls":se.current,isOpen:ve,hasTextCursor:!0},j(_({id:Se.current,name:P,label:k,disabled:z,readOnly:G,selectedValue:Oe,formattedValue:ge,onClick:function(e){de.current=!1,F&&F(e),ye(!0)},iconOnClick:function(e){de.current=!1,F&&F(e),ye((e=>!e))},iconOnMouseDown:ze,onFocus:function(e){const t=()=>null==T?void 0:T(e);if(V){if(ke.current&&clearTimeout(ke.current),De.current)return;ke.current=setTimeout((()=>{ye((e=>!(!e&&(T&&!pe.current&&(t(),pe.current=!0),de.current&&!me.current))))}))}else T&&!pe.current&&(t(),pe.current=!0)},onBlur:function(e){me.current=!1,de.current||(pe.current=!1,I&&I(e))},onKeyDown:Ie,onChange:Me,onMouseDown:ze,tooltipPosition:Y,required:re},c(le)),{"data-component":void 0})),{onChange:Me,value:ge}))}),Qe]}))}));export{C as FilterableSelect,C as default};
|
|
@@ -11,8 +11,6 @@ export interface MultiSelectProps extends Omit<FormInputPropTypes, "defaultValue
|
|
|
11
11
|
size?: "small" | "medium" | "large";
|
|
12
12
|
/** Child components (such as Option or OptionRow) for the SelectList */
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
-
/** The default selected value(s), when the component is operating in uncontrolled mode */
|
|
15
|
-
defaultValue?: string[] | Record<string, unknown>[];
|
|
16
14
|
/** If true the loader animation is displayed in the option list */
|
|
17
15
|
isLoading?: boolean;
|
|
18
16
|
/** When true component will work in multi column mode.
|
|
@@ -33,8 +31,8 @@ export interface MultiSelectProps extends Omit<FormInputPropTypes, "defaultValue
|
|
|
33
31
|
* Works only in multiColumn mode
|
|
34
32
|
*/
|
|
35
33
|
tableHeader?: React.ReactNode;
|
|
36
|
-
/** The selected value(s)
|
|
37
|
-
value
|
|
34
|
+
/** The selected value(s) */
|
|
35
|
+
value: string[] | Record<string, unknown>[];
|
|
38
36
|
/** [Legacy] Overrides the default tooltip position */
|
|
39
37
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
40
38
|
/** Maximum list height - defaults to 180 */
|
|
@@ -53,7 +51,7 @@ export interface MultiSelectProps extends Omit<FormInputPropTypes, "defaultValue
|
|
|
53
51
|
* Only used if the `enableVirtualScroll` prop is set. */
|
|
54
52
|
virtualScrollOverscan?: number;
|
|
55
53
|
/** Specify a callback triggered on change */
|
|
56
|
-
onChange
|
|
54
|
+
onChange: (ev: CustomSelectChangeEvent | React.ChangeEvent<HTMLInputElement>) => void;
|
|
57
55
|
/** Override the default width of the list element. Number passed is converted into pixel value */
|
|
58
56
|
listWidth?: number;
|
|
59
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r,{useState as n,useRef as l,useCallback as o,useMemo as i,useEffect as a}from"react";import
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r,{useState as n,useRef as l,useCallback as o,useMemo as i,useEffect as a}from"react";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../__internal__/select-list/select-list.component.js";import{StyledSelectPillContainer as f,StyledSelectMultiSelect as b,StyledAccessibilityLabelContainer as v}from"./multi-select.style.js";import{Pill as y}from"../../pill/pill.component.js";import h from"../__internal__/utils/is-expected-option.js";import g from"../__internal__/utils/is-expected-value.js";import O from"../__internal__/utils/is-navigation-key.js";import{useStableCallback as _}from"../../../hooks/__internal__/useStableCallback/useStableCallback.js";import j from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){w(e,t,r[t])}))}return e}function x(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const P=p(m),S=r.forwardRef(((p,m)=>{var{"aria-label":w,"aria-labelledby":S,value:k,id:D,label:L,name:E,disabled:V,readOnly:I,children:M,onOpen:T,onFilterChange:B,onChange:F,onClick:H,onFocus:z,onBlur:A,onKeyDown:K,openOnFocus:R=!1,noResultsMessage:q,placeholder:W,isLoading:$,onListScrollBottom:G,tableHeader:J,multiColumn:N,tooltipPosition:Q,size:U="medium","data-element":X,"data-role":Y,listPlacement:Z="bottom",listMaxHeight:ee,flipEnabled:te=!0,wrapPillText:re=!0,enableVirtualScroll:ne,virtualScrollOverscan:le,required:oe,listWidth:ie}=p,ae=function(e,t){if(null==e)return{};var r,n,l=function(e,t){if(null==e)return{};var r,n,l={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(l[r]=e[r]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r])}return l}(p,["aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","onOpen","onFilterChange","onChange","onClick","onFocus","onBlur","onKeyDown","openOnFocus","noResultsMessage","placeholder","isLoading","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","size","data-element","data-role","listPlacement","listMaxHeight","flipEnabled","wrapPillText","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const[se,ce]=n(""),ue=l(d()),de=l(d()),pe=l(null),me=l(null),fe=l(!1),be=l(!1),ve=l(!1),ye=l(!1),he=l(!1),[ge,Oe]=n(),[_e,je]=n(!1),[we,Ce]=n(""),[xe,Pe]=n(""),[Se,ke]=n(""),[De,Le]=n(),Ee=l(D||d()),{labelId:Ve}=j({id:Ee.current,label:L}),Ie=l(null),Me=o((()=>{je((e=>(!e&&T&&T(),!0)))}),[T]),Te=o(((e,t)=>({target:x(C({},E&&{name:E},D&&{id:D}),{value:e}),selectionConfirmed:t})),[E,D]),Be=o(((e,t)=>{const r=e(k);r.length!==(null==k?void 0:k.length)&&F(Te(r,t))}),[Te,F,k]),Fe=o((e=>{const t=e.target.value,n=(l=t,o=M,r.Children.toArray(o).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==l?void 0:l.toLowerCase()))})));var l,o;n&&Pe(n.props.value),ke(t),Ce(t),Me()}),[M,Me]),He=o((e=>{be.current=!0,Be((t=>{if(!t.length)return t;const r=t.slice();return r.splice(e,1),r}),!0)}),[Be]),ze=o((e=>{const{key:t}=e,r="Backspace"===t||"Delete"===t;K&&K(e),I||(!e.defaultPrevented&&O(t)&&(e.preventDefault(),Me()),!r||""!==Se&&""!==we||He(-1))}),[K,I,Se,we,Me,He]),Ae=i((()=>{var e;return k&&k.length?null===(e=r.Children.map(M,(e=>!(!r.isValidElement(e)||!k.includes(e.props.value))&&e.props.text)))||void 0===e?void 0:e.filter((e=>e)).reduce(((e,t)=>e?`${e}, ${t}`:t),""):null}),[M,k]),Ke=o((e=>{if(ve.current=!1,!_e)return;const t=pe.current&&!pe.current.contains(e.target),r=me.current&&!me.current.contains(e.target);t&&r&&!be.current&&(Ce(""),ke(""),Pe(""),je(!1)),be.current=!1}),[_e]),Re=i((()=>{const t=!V&&!I;let n;return(null==k?void 0:k.length)?k.map(((l,o)=>{const i=r.Children.toArray(M).find((e=>r.isValidElement(e)&&h(e,l)));let a={};if(!i)return null;var s,c;r.isValidElement(i)&&(n=void 0!==(null==i||null===(s=i.props.value)||void 0===s?void 0:s.value)?null==i||null===(c=i.props.value)||void 0===c?void 0:c.value:null==i?void 0:i.props.value,a={title:i.props.text,fill:i.props.fill,borderColor:i.props.borderColor});const u=a.title||"",d=u+n||o;return e(f,{children:e(y,x(C({onDelete:t?()=>He(o):void 0,wrapText:re},a),{children:u}))},d)})):""}),[M,V,I,k]);a((()=>{const e=null==k?void 0:k.length;Le(e?" ":W)}),[k,W]),a((()=>{const e="click";return window.addEventListener(e,Ke),function(){window.removeEventListener(e,Ke)}}),[Ke]);const qe=_(B),We=l(!0);function $e(e){if(ve.current=!1,H&&H(e),!R||R&&!he.current){if(_e)return ke(""),void je(!1);null==T||T(),je(!0)}else he.current=!1}function Ge(e){ve.current=!1,H&&H(e),je((e=>e?(ke(""),!1):(T&&T(),!0)))}function Je(e){ye.current=!1,ve.current||(fe.current=!1,A&&A(e))}function Ne(e){ve.current=!0,"input"===e.target.dataset.element&&(ye.current=!0)}function Qe(e){const t=()=>null==z?void 0:z(e);R?(Ie.current&&clearTimeout(Ie.current),Ie.current=setTimeout((()=>{je((e=>!!e||(T&&T(),z&&!fe.current&&(t(),fe.current=!0),ve.current&&!ye.current?(he.current=!1,!1):(ye.current&&(he.current=!0),!0))))}))):z&&!fe.current&&(t(),fe.current=!0)}a((()=>{qe&&!We.current&&qe(Se)}),[qe,Se]),a((()=>{We.current=!1}),[]);const Ue=o((e=>{const{value:t,selectionType:r,id:n,selectionConfirmed:l}=e;if("navigationKey"===r)return Pe(t),void ce(n);"click"===r&&(be.current=!0),Ce("");const o=-1!==(null==k?void 0:k.findIndex((e=>g(e,t))));null==ge||ge.focus(),ve.current=!1,Be((e=>o?e:[...e,t]),l)}),[ge,k,Be]),Xe=o((()=>{je(!1),ke("")}),[]),Ye=o((e=>{e&&(Oe(e),m&&("function"==typeof m?m(e):m.current=e))}),[m]);function Ze(){return x(C({id:Ee.current,name:E,disabled:V,label:L,readOnly:I,placeholder:De,leftChildren:Re,formattedValue:we,selectedValue:k,onClick:$e,onMouseDown:Ne,onFocus:Qe,onBlur:Je,iconOnClick:Ge,iconOnMouseDown:Ne,onKeyDown:ze,onChange:Fe,tooltipPosition:Q,size:U,required:oe},c(ae)),{"data-component":void 0})}let et;switch(Z){case"top":et="top-end";break;case"bottom":et="bottom-end";break;default:et=Z}const tt=e(P,{ref:me,id:ue.current,labelId:Ve,anchorElement:(null==ge?void 0:ge.parentElement)||void 0,onSelect:Ue,onSelectListClose:Xe,onMouseDown:function(){ve.current=!0},filterText:Se.trim(),highlightedValue:xe,noResultsMessage:q,isLoading:$,onListScrollBottom:G,tableHeader:J,multiColumn:N,listPlacement:void 0!==ie?et:Z,listMaxHeight:ee,flipEnabled:te,multiselectValues:k,isOpen:_e,enableVirtualScroll:ne,virtualScrollOverscan:le,listWidth:ie,children:M}),rt=s(ae);return t(b,x(C({disabled:V,readOnly:I,hasTextCursor:!0,size:U,"data-component":"multiselect","data-role":Y,"data-element":X,isOpen:_e},rt),{children:[t("div",{ref:pe,children:[e(v,{"data-element":"accessibility-label",id:de.current,children:Ae}),e(u,C({ref:Ye,accessibilityLabelId:de.current,activeDescendantId:se,"aria-controls":ue.current,ariaLabel:w,ariaLabelledby:S,hasTextCursor:!0,isOpen:_e,labelId:Ve,value:Ze().formattedValue},Ze()))]}),tt]}))}));export{S as MultiSelect,S as default};
|
|
@@ -13,8 +13,6 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
|
|
|
13
13
|
"aria-labelledby"?: string;
|
|
14
14
|
/** Child components (such as Option or OptionRow) for the SelectList */
|
|
15
15
|
children: React.ReactNode;
|
|
16
|
-
/** The default selected value(s), when the component is operating in uncontrolled mode */
|
|
17
|
-
defaultValue?: string | Record<string, unknown>;
|
|
18
16
|
/** If true the loader animation is displayed in the option list */
|
|
19
17
|
isLoading?: boolean;
|
|
20
18
|
/** When true component will work in multi column mode.
|
|
@@ -33,8 +31,8 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
|
|
|
33
31
|
tableHeader?: React.ReactNode;
|
|
34
32
|
/** If true the component input has no border and is transparent */
|
|
35
33
|
transparent?: boolean;
|
|
36
|
-
/** The selected value(s)
|
|
37
|
-
value
|
|
34
|
+
/** The selected value(s) */
|
|
35
|
+
value: string | Record<string, unknown>;
|
|
38
36
|
/** [Legacy] Overrides the default tooltip position */
|
|
39
37
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
40
38
|
/** Maximum list height - defaults to 180 */
|
|
@@ -53,7 +51,7 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
|
|
|
53
51
|
/** Flag to configure component as mandatory */
|
|
54
52
|
isRequired?: boolean;
|
|
55
53
|
/** Specify a callback triggered on change */
|
|
56
|
-
onChange
|
|
54
|
+
onChange: (ev: CustomSelectChangeEvent | React.ChangeEvent<HTMLInputElement>) => void;
|
|
57
55
|
/** Override the default width of the list element. Number passed is converted into pixel value */
|
|
58
56
|
listWidth?: number;
|
|
59
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useRef as r,useState as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useRef as r,useState as l,useMemo as o,useCallback as i,useEffect as a}from"react";import"../../../style/utils/filter-styled-system-padding-props.js";import c from"../../../style/utils/filter-styled-system-margin-props.js";import s from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../select.style.js";import d from"../__internal__/select-textbox/select-textbox.component.js";import p from"../__internal__/select-list/select-list.component.js";import m from"../../../__internal__/utils/helpers/guid/index.js";import b from"../__internal__/utils/get-next-child-by-text.js";import f from"../__internal__/utils/is-expected-option.js";import y from"../__internal__/utils/is-navigation-key.js";import O from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){g(e,t,n[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const h=n.forwardRef(((g,h)=>{var{"aria-describedby":j,"aria-label":_,"aria-labelledby":P,value:x,id:S,label:k,name:C,disabled:D,readOnly:E,children:L,transparent:I,openOnFocus:T=!1,onOpen:V,onChange:B,onClick:H,onFocus:K,onKeyDown:F,onBlur:M,isLoading:q,listMaxHeight:A,onListScrollBottom:W,tableHeader:R,multiColumn:z,tooltipPosition:G,"data-element":J,"data-role":N,listPlacement:Q="bottom",flipEnabled:U=!0,enableVirtualScroll:X,virtualScrollOverscan:Y,required:Z,listWidth:$}=g,ee=function(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}(g,["aria-describedby","aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","transparent","openOnFocus","onOpen","onChange","onClick","onFocus","onKeyDown","onBlur","isLoading","listMaxHeight","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","data-element","data-role","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const te=r(m()),ne=r(null),re=r(null),le=r(void 0),oe=r(),ie=r(),ae=r(),ce=r(),[se,ue]=l(),[de,pe]=l(!1),[me,be]=l(""),[fe,ye]=l(""),[Oe,ge]=l(x),we=r(S||m()),{labelId:ve}=O({id:we.current,label:k}),he=r(void 0),je=o((()=>n.Children.toArray(L)),[L]),_e=i(((e,t=!1)=>({target:v(w({},C&&{name:C},S&&{id:S}),{value:e}),selectionConfirmed:t})),[C,S]),Pe=i((e=>{const t=je.findIndex((e=>n.isValidElement(e)&&f(e,Oe))),r=b(e,je,t);r&&B(_e(r.props.value))}),[je,_e,B,Oe]),xe=i((e=>{if(ie.current){const t=ce.current+e;ce.current=t,Pe(t),window.clearTimeout(le.current)}else ce.current=e,Pe(e);ie.current=!0,window.clearTimeout(le.current),le.current=window.setTimeout((()=>{ie.current=!1,ce.current=""}),500)}),[Pe]),Se=i((e=>{const{key:t}=e;null==F||F(e),E||(" "===t||y(t)?(e.preventDefault(),pe((e=>(e||null==V||V(),!0)))):1!==t.length||e.metaKey||e.ctrlKey||xe(t))}),[xe,F,V,E]),ke=i((e=>{const t=ne.current&&!ne.current.contains(e.target),n=re.current&&!re.current.contains(e.target);oe.current=!1,t&&n&&!ae.current&&pe(!1),ae.current=!1}),[]);function Ce(e){oe.current=!1,null==H||H(e),pe((e=>!e&&(null==V||V(),!0)))}a((()=>{ge(x)}),[x]),a((()=>{const e=je.find((e=>f(e,Oe)));let t="";e&&(t=e.props.text),ye(t)}),[Oe,je]),a((()=>{const e="click";return window.addEventListener(e,ke),function(){window.removeEventListener(e,ke)}}),[ke]),a((()=>function(){window.clearTimeout(le.current),window.clearTimeout(he.current)}),[]);const De=i((()=>{pe(!1)}),[]),Ee=i((e=>{e&&(ue(e),h&&("function"==typeof h?h(e):h.current=e))}),[h]);let Le;switch(Q){case"top":Le="top-end";break;case"bottom":Le="bottom-end";break;default:Le=Q}const Ie=e(p,{ref:re,id:te.current,labelId:ve,anchorElement:(null==se?void 0:se.parentElement)||void 0,onSelect:e=>{const{text:t,value:n,selectionType:r,id:l,selectionConfirmed:o}=e,i="click"===r;!function(e,t,n){null==B||B(_e(e,n))}(n,0,o),be(l),"navigationKey"!==r&&pe(!1),i&&(ae.current=!0,null==se||se.focus())},onMouseDown:function(){oe.current=!0},onSelectListClose:De,highlightedValue:Oe,listMaxHeight:A,isLoading:q,onListScrollBottom:W,tableHeader:R,multiColumn:z,listPlacement:void 0!==$?Le:Q,flipEnabled:U,isOpen:de,enableVirtualScroll:X,virtualScrollOverscan:Y,listWidth:$,children:L}),Te=c(ee);return t(u,v(w({transparent:I,disabled:D,readOnly:E,"data-component":"simple-select","data-role":N,"data-element":J,isOpen:de},Te),{children:[e("div",{ref:ne,children:e(d,v(w({ref:Ee,ariaLabel:_,"aria-controls":te.current,activeDescendantId:me,ariaLabelledby:P,"aria-describedby":j,isOpen:de,value:fe},v(w({id:we.current,name:C,disabled:D,readOnly:E,selectedValue:Oe,formattedValue:fe,onClick:Ce,iconOnClick:function(e){Ce(e)},label:k,labelId:ve,onMouseDown:function(){oe.current=!0},onFocus:function(e){ae.current||(null==K||K(e),oe.current?oe.current=!1:T&&(window.clearTimeout(he.current),he.current=window.setTimeout((()=>{pe((e=>(e||null==V||V(),!0)))}))))},onKeyDown:Se,onBlur:function(e){oe.current||null==M||M(e)},tooltipPosition:G,required:Z,transparent:I},s(ee)),{"data-component":void 0})),{onChange:()=>{}}))}),Ie]}))}));export{h as SimpleSelect,h as default};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface SimpleColorProps {
|
|
3
|
+
/** the value of the label to pass to screen reader software */
|
|
4
|
+
"aria-label"?: string;
|
|
3
5
|
/** the value of the color that is represented by this SimpleColor */
|
|
4
6
|
value: string;
|
|
5
7
|
/** the input name */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import t,{useRef as o}from"react";import n from"../../../__internal__/utils/helpers/guid/index.js";import
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import t,{useRef as o}from"react";import n from"../../../__internal__/utils/helpers/guid/index.js";import l from"../../../__internal__/utils/helpers/tags/tags.js";import{StyledSimpleColor as c,StyledSimpleColorInput as a,StyledColorSampleBox as i,StyledTickIcon as s}from"./simple-color.style.js";function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){u(e,r,t[r])}))}return e}const f=t.forwardRef(((t,u)=>{const{onChange:f,onBlur:b,onMouseDown:m,value:O,name:y,checked:j=!1,id:d,className:g,"aria-label":h}=t,w=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},l=Object.keys(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(t,["onChange","onBlur","onMouseDown","value","name","checked","id","className","aria-label"]),{current:P}=o(d||n());return e(c,(v=p({className:g},l("simple-color",t)),_=null!=(_={children:[r(a,p({onChange:f,onBlur:b,onMouseDown:m,checked:j,name:y,"aria-label":h,type:"radio",role:"radio",value:O,ref:u,id:P},w)),r(i,{color:O,children:j&&r(s,{color:O,type:"tick"})})]})?_:{},Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(_)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(_)).forEach((function(e){Object.defineProperty(v,e,Object.getOwnPropertyDescriptor(_,e))})),v));var v,_}));f.displayName="SimpleColor";export{f as SimpleColor,f as default};
|
|
@@ -14,7 +14,7 @@ export interface SimpleColorPickerProps extends ValidationProps, MarginProps, Ta
|
|
|
14
14
|
/** The name to apply to the input. */
|
|
15
15
|
name: string;
|
|
16
16
|
/** Prop for `onChange` events */
|
|
17
|
-
onChange
|
|
17
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
18
|
/** Prop for `onKeyDown` events */
|
|
19
19
|
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
20
|
/** Prop for `onBlur` events */
|
|
@@ -24,7 +24,7 @@ export interface SimpleColorPickerProps extends ValidationProps, MarginProps, Ta
|
|
|
24
24
|
/** When true, validation icon will be placed on legend instead of being placed by the input */
|
|
25
25
|
validationOnLegend?: boolean;
|
|
26
26
|
/** The currently selected color. */
|
|
27
|
-
value
|
|
27
|
+
value: string;
|
|
28
28
|
}
|
|
29
29
|
export interface SimpleColorPickerRef {
|
|
30
30
|
/** List of color input HTML refs */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r,{useMemo as n,useRef as o,useState as i,useImperativeHandle as l,useCallback as a}from"react";import u from"invariant";import s from"../../__internal__/utils/helpers/events/events.js";import p from"../../__internal__/utils/helpers/tags/tags.js";import c from"../../__internal__/fieldset/fieldset.component.js";import{SimpleColor as d}from"./simple-color/simple-color.component.js";import m from"../../__internal__/radio-button-mapper/radio-button-mapper.component.js";import{StyledContent as f,StyledColorOptions as y}from"./simple-color-picker.style.js";import{ValidationIcon as g}from"../../__internal__/validations/validation-icon.component.js";import{InputGroupContext as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r,{useMemo as n,useRef as o,useState as i,useImperativeHandle as l,useCallback as a}from"react";import u from"invariant";import s from"../../__internal__/utils/helpers/events/events.js";import p from"../../__internal__/utils/helpers/tags/tags.js";import c from"../../__internal__/fieldset/fieldset.component.js";import{SimpleColor as d}from"./simple-color/simple-color.component.js";import m from"../../__internal__/radio-button-mapper/radio-button-mapper.component.js";import{StyledContent as f,StyledColorOptions as y}from"./simple-color-picker.style.js";import{ValidationIcon as g}from"../../__internal__/validations/validation-icon.component.js";import{InputGroupContext as h}from"../../__internal__/input-behaviour/input-group-behaviour.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import b from"../../style/utils/filter-styled-system-margin-props.js";function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){v(e,t,r[t])}))}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const w=r.forwardRef(((v,w)=>{const{children:_,error:P,warning:D,info:K,name:C,legend:E,onChange:S,onBlur:k,onKeyDown:x,value:A,maxWidth:L=300,childWidth:M=58,validationOnLegend:W,required:R}=v,q=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(v,["children","error","warning","info","name","legend","onChange","onBlur","onKeyDown","value","maxWidth","childWidth","validationOnLegend","required"]),B=n((()=>!r.Children.toArray(_).find((e=>"string"==typeof e||r.isValidElement(e)&&"SimpleColor"!==e.type.displayName))),[_]);u(B,`SimpleColorPicker accepts only children of type \`${d.displayName}\`.`);const I=n((()=>r.Children.toArray(_).filter((e=>r.isValidElement(e)))),[_]),N=o(null),[U,V]=i(null),F=Math.floor(+L/+M),T=Math.ceil((null==I?void 0:I.length)/F);let $=F*T-(null==I?void 0:I.length),z=1,G=1;const H=o([]),J=I.map(((e,t)=>{const n=1!==z;let o,i,l=!1;z+1===T&&$-F<0?(l=!0,$+=1):z+1!==T&&z!==T&&T>1&&(l=!0),G===F&&(G=0,z+=1),n&&(o=t-F),l&&(i=F+t);const a={ref:e=>{H.current[t]=e},"data-up":n,"data-down":l,"data-item-up":o,"data-item-down":i,required:R};return G+=1,r.cloneElement(e,a)}));l(w,(()=>({gridItemRefs:H.current})),[H]);const Q=a((e=>J.findIndex((t=>e.getAttribute("value")===t.props.value))),[J]),X=a((e=>{if(x&&x(e),![s.isLeftKey(e),s.isUpKey(e),s.isRightKey(e),s.isDownKey(e)].includes(!0))return;e.preventDefault();let t=null;const r=e.target;if(s.isUpKey(e)){if("true"!==r.getAttribute("data-up"))return;t=+r.getAttribute("data-item-up")}else if(s.isDownKey(e)){if("true"!==r.getAttribute("data-down"))return;t=+r.getAttribute("data-item-down")}if((s.isLeftKey(e)||s.isRightKey(e))&&(t=s.isLeftKey(e)?Q(r)-1:Q(r)+1,t<0?t=J.length-1:t>J.length-1&&(t=0)),null!==t){const e=H.current[t];null==e||e.focus(),null==e||e.click()}}),[x,J,Q]),Y=e=>{e.preventDefault(),setTimeout((()=>{var t;const r=!(null==H||null===(t=H.current)||void 0===t?void 0:t.find((e=>e===document.activeElement)));k&&r&&k(e)}),5)},Z=e=>{null!==U&&U===e.target?e.preventDefault():null!==U?(e.preventDefault(),V(e.target)):V(e.target)},ee={error:P,warning:D,info:K};return e(c,j(O({role:"radiogroup",legend:E,isRequired:R},W&&ee,p("simple-color-picker",v),b(q)),{children:t(f,{children:[e(h.Consumer,{children:({onMouseEnter:t,onMouseLeave:r})=>e(y,j(O({maxWidth:L,childWidth:M,ref:N,onMouseEnter:t,onMouseLeave:r},ee),{children:e(m,{name:C,value:A,onChange:S,onMouseDown:Z,onKeyDown:X,onBlur:Y,children:J})}))}),!W&&e(g,j(O({},ee),{tooltipFlipOverrides:["top","bottom"]}))]})}))}));w.displayName="SimpleColorPicker";export{w as SimpleColorPicker,w as default};
|
|
@@ -2,11 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
import { CommonCheckableInputProps } from "../../__internal__/checkable-input";
|
|
4
4
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
-
export interface SwitchProps extends CommonCheckableInputProps, MarginProps, TagProps {
|
|
5
|
+
export interface SwitchProps extends Omit<CommonCheckableInputProps, "defaultChecked">, MarginProps, TagProps {
|
|
6
6
|
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
7
7
|
adaptiveLabelBreakpoint?: number;
|
|
8
|
-
/** Set the default value of the Switch if component is meant to be used as uncontrolled */
|
|
9
|
-
defaultChecked?: boolean;
|
|
10
8
|
/** When true label is inline */
|
|
11
9
|
labelInline?: boolean;
|
|
12
10
|
/** Triggers loading animation */
|
|
@@ -25,6 +23,10 @@ export interface SwitchProps extends CommonCheckableInputProps, MarginProps, Tag
|
|
|
25
23
|
validationMessagePositionTop?: boolean;
|
|
26
24
|
/** Label width, as a percentage, when labelInline is true */
|
|
27
25
|
labelWidth?: number;
|
|
26
|
+
/** OnChange event handler */
|
|
27
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
+
/** Checked state of the input */
|
|
29
|
+
checked: boolean;
|
|
28
30
|
}
|
|
29
31
|
export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
|
|
30
32
|
export default Switch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import i,{useContext as
|
|
1
|
+
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import i,{useContext as o,useRef as a}from"react";import{Box as t}from"../box/box.component.js";import l from"../../__internal__/checkable-input/checkable-input.component.js";import d from"../../__internal__/label/label.component.js";import{TooltipProvider as s}from"../../__internal__/tooltip-provider/index.js";import c from"../carbon-provider/__internal__/new-validation.context.js";import p from"../../__internal__/validation-message/validation-message.component.js";import u from"../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import b,{ErrorBorder as m}from"./switch.style.js";import g from"./__internal__/switch-slider.component.js";import f from"../../__internal__/utils/helpers/guid/index.js";import{HintText as h}from"../../__internal__/hint-text/hint-text.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import v from"../../style/utils/filter-styled-system-margin-props.js";function k(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function y(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),i.forEach((function(r){k(e,r,n[r])}))}return e}function w(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})),e}const _=i.forwardRef(((i,k)=>{var{autoFocus:_,id:O,label:j,onChange:B,onBlur:D,onFocus:P,value:x,checked:I,disabled:S,loading:H,reverse:L=!0,required:F,validationOnLabel:z=!1,labelInline:q=!1,labelSpacing:A,labelHelp:T,labelWidth:$,fieldHelpInline:C,size:M="small",name:R,adaptiveLabelBreakpoint:W,tooltipPosition:E,error:U,warning:Y,info:N,"data-element":V,"data-role":G,helpAriaLabel:J,isDarkBackground:K=!1,validationMessagePositionTop:Q=!0}=i,X=function(e,r){if(null==e)return{};var n,i,o=function(e,r){if(null==e)return{};var n,i,o={},a=Object.keys(e);for(i=0;i<a.length;i++)n=a[i],r.indexOf(n)>=0||(o[n]=e[n]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],r.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(i,["autoFocus","id","label","onChange","onBlur","onFocus","value","checked","disabled","loading","reverse","required","validationOnLabel","labelInline","labelSpacing","labelHelp","labelWidth","fieldHelpInline","size","name","adaptiveLabelBreakpoint","tooltipPosition","error","warning","info","data-element","data-role","helpAriaLabel","isDarkBackground","validationMessagePositionTop"]);const{validationRedesignOptIn:Z}=o(c),ee=a(`${f()}-label`),re=a(`${f()}-hint`),ne=a(`${f()}-message`),ie=u(W);let oe=q;W&&(oe=ie);const ae=!(!q||L)||z,te=v(X),le=y({"data-component":"switch","data-role":G,"data-element":V,checked:I,isDarkBackground:K,fieldHelpInline:C,labelInline:oe,labelSpacing:A,reverse:!L,size:M},te),de={checked:I,disabled:S,loading:H,isDarkBackground:K,size:M,error:U,warning:Y,info:N,useValidationIcon:!Z&&!ae&&!S},se=w(y({autoFocus:_,error:U,warning:Y,info:N,disabled:S,loading:H,checked:I,label:j,labelHelp:T,labelWidth:$,fieldHelpInline:C,labelInline:oe,labelSpacing:A,onBlur:D,isDarkBackground:K,onFocus:P,onChange:B,id:O,name:R,value:x,type:"checkbox",role:"switch",reverse:!L,validationOnLabel:ae&&!S,ref:k,required:F},X),{"data-component":void 0}),ce=y({"data-component":"switch","data-role":G,"data-element":V,checked:I,labelInline:oe,isDarkBackground:K,size:M,reverse:!L,validationRedesignOptIn:Z},te),pe={checked:I,disabled:S,loading:H,isDarkBackground:K,size:M,error:U,warning:Y},ue=y({autoFocus:_,error:!!U,warning:Y,disabled:S,loading:H,checked:I,onBlur:D,isDarkBackground:K,onFocus:P,onChange:B,id:O,name:R,value:x,type:"checkbox",role:"switch",ref:k,required:F},X),be=U||Y,me=[T&&re.current,be&&ne.current].filter(Boolean).join(" ");if(!Z)return e(r,{children:e(s,{helpAriaLabel:J,tooltipPosition:E,children:e(b,w(y({},le),{children:e(l,w(y({},se),{children:e(g,y({},de))}))}))})});const ge=U||Y?q?3:0:q?1:0,fe=q?"row":"column",he=q?"row-reverse":"column",ve=!q||U||Y||N?"":"center";return n(r,{children:[e(b,w(y({},ce),{children:n(t,{"data-role":"field-reverse-wrapper",display:"flex",alignItems:U||Y?"flex-start":void 0,flexDirection:L?fe:he,width:q?"100%":"auto",children:[n(t,w(y({"data-role":"label-wrapper",alignSelf:ve},$&&{width:`${$}%`}),{children:[e(d,{isDarkBackground:K,labelId:ee.current,disabled:S,isRequired:F,children:j}),T&&e(t,{"data-role":"hint-text-wrapper",mb:q?0:1,children:e(h,{"data-role":"hint-text",fontWeight:"400",id:re.current,isDarkBackground:K,marginTop:"8px",children:T})})]})),n(t,{ml:L?ge:0,mr:L?0:ge,position:"relative",id:"input-wrapper","data-role":"input-wrapper",children:[Q&&n(r,{children:[e(p,{error:U,warning:Y,validationId:ne.current,isDarkBackground:K,validationMessagePositionTop:Q,"data-role":"validation-message-top"}),be&&e(m,{"data-role":"error-border",warning:!(U||!Y),reverse:!L,isDarkBackground:K})]}),e(l,w(y({ariaLabelledBy:`${j&&ee.current}`,ariaDescribedBy:me},ue),{fieldHelp:q?void 0:X.fieldHelp,children:e(g,y({},pe))})),!Q&&n(r,{children:[e(p,{error:U,warning:Y,validationId:ne.current,isDarkBackground:K,validationMessagePositionTop:Q,"data-role":"validation-message-bottom"}),be&&e(m,{"data-role":"error-border",warning:!(U||!Y),reverse:!L,isDarkBackground:K})]})]})]})})),q&&X.fieldHelp&&e(t,{color:K?"var(--colorsUtilityYang100)":"var(--colorsUtilityYin090)",children:X.fieldHelp})]})}));_.displayName="Switch";export{_ as Switch,_ as default};
|
|
@@ -72,11 +72,16 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
|
|
|
72
72
|
/** Name of the input */
|
|
73
73
|
name?: string;
|
|
74
74
|
/** Callback fired when the user types in the Textarea */
|
|
75
|
-
onChange
|
|
75
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
76
76
|
/** Placeholder text for the component */
|
|
77
77
|
placeholder?: string;
|
|
78
78
|
/** Adds readOnly property */
|
|
79
79
|
readOnly?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* [Legacy] Flag to configure component as optional.
|
|
82
|
+
* @deprecated If the value of this component is not required, use the `required` prop and set it to false instead.
|
|
83
|
+
*/
|
|
84
|
+
isOptional?: boolean;
|
|
80
85
|
/** The number of visible text lines for the control. When set, this determines the height of the textarea, and the minHeight property is ignored. */
|
|
81
86
|
rows?: number;
|
|
82
87
|
/** [Legacy] Overrides the default tooltip position */
|
|
@@ -84,7 +89,7 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
|
|
|
84
89
|
/** [Legacy] When true, validation icon will be placed on label instead of being placed on the input */
|
|
85
90
|
validationOnLabel?: boolean;
|
|
86
91
|
/** The value of the Textbox */
|
|
87
|
-
value
|
|
92
|
+
value: string;
|
|
88
93
|
/**
|
|
89
94
|
* Indicate that warning has occurred.
|
|
90
95
|
* Pass string to display icon, tooltip and orange border.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as i,Fragment as n}from"react/jsx-runtime";import
|
|
1
|
+
import{jsxs as e,jsx as i,Fragment as n}from"react/jsx-runtime";import t,{useContext as r,useState as o,useRef as l,useCallback as a,useEffect as d}from"react";import s from"../../__internal__/utils/helpers/tags/tags.js";import p from"../../__internal__/input/input.component.js";import u from"../../__internal__/input/input-presentation.component.js";import c from"../../__internal__/form-field/form-field.component.js";import b from"../../hooks/useCharacterCount/useCharacterCount.js";import{InputBehaviour as m}from"../../__internal__/input-behaviour/input-behaviour.component.js";import f from"../../__internal__/input-icon-toggle/input-icon-toggle.component.js";import h from"../../__internal__/utils/helpers/guid/index.js";import g,{DEFAULT_MIN_HEIGHT as v}from"./textarea.style.js";import{TooltipProvider as y}from"../../__internal__/tooltip-provider/index.js";import _ from"../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import O from"../carbon-provider/__internal__/new-validation.context.js";import j from"../textbox/textbox.style.js";import w from"../../__internal__/validation-message/validation-message.component.js";import{Box as x}from"../box/box.component.js";import I from"../../__internal__/utils/logger/index.js";import{HintText as P}from"../../__internal__/hint-text/hint-text.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import H from"../../style/utils/filter-styled-system-margin-props.js";function L(e,i,n){return i in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}function B(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{},t=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),t.forEach((function(i){L(e,i,n[i])}))}return e}let T=!1,A=!1;const R=t.forwardRef(((t,L)=>{var{"aria-labelledby":R,"aria-describedby":S,autoFocus:W,inputHint:k,fieldHelp:E,label:C,children:q,characterLimit:F,onChange:D,onFocus:M,onBlur:z,disabled:V=!1,labelInline:N,labelAlign:$,labelHelp:G,labelSpacing:J,inputIcon:K,id:Q,error:U,warning:X,info:Y,name:Z,readOnly:ee=!1,placeholder:ie,expandable:ne=!1,rows:te,validationOnLabel:re=!1,adaptiveLabelBreakpoint:oe,inputWidth:le,maxWidth:ae,labelWidth:de=30,tooltipPosition:se,value:pe,"data-element":ue,"data-role":ce,helpAriaLabel:be,borderRadius:me,hideBorders:fe=!1,required:he,isOptional:ge,minHeight:ve=v,validationMessagePositionTop:ye=!0}=t,_e=function(e,i){if(null==e)return{};var n,t,r=function(e,i){if(null==e)return{};var n,t,r={},o=Object.keys(e);for(t=0;t<o.length;t++)n=o[t],i.indexOf(n)>=0||(r[n]=e[n]);return r}(e,i);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(t=0;t<o.length;t++)n=o[t],i.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(t,["aria-labelledby","aria-describedby","autoFocus","inputHint","fieldHelp","label","children","characterLimit","onChange","onFocus","onBlur","disabled","labelInline","labelAlign","labelHelp","labelSpacing","inputIcon","id","error","warning","info","name","readOnly","placeholder","expandable","rows","validationOnLabel","adaptiveLabelBreakpoint","inputWidth","maxWidth","labelWidth","tooltipPosition","value","data-element","data-role","helpAriaLabel","borderRadius","hideBorders","required","isOptional","minHeight","validationMessagePositionTop"]);!T&&ge&&(T=!0,I.deprecate("`isOptional` is deprecated in TextArea and support will soon be removed. If the value of this component is not required, use the `required` prop and set it to false instead."));const{validationRedesignOptIn:Oe}=r(O),je=!Oe&&N,[we,xe]=o(v),Ie=e=>Oe?void 0:e,{current:Pe}=l(Q||h()),He=l(null),Le=a((e=>{He.current=e,L&&("current"in L?L.current=e:L(e))}),[L]),[Be,Te]=o("off");Array.isArray(me)&&me.length>4&&!A&&(I.warn("The `borderRadius` prop in `Textarea` component only supports up to 4 values."),A=!0);const Ae=a((()=>{const e=He.current;if((null==e?void 0:e.scrollHeight)&&(null==e?void 0:e.scrollHeight)>we){let i=e;for(;i&&!(null==i?void 0:i.scrollTop);)i=(null==i?void 0:i.parentElement)||null;const n=null==i?void 0:i.scrollTop;e.style.height="auto",e.style.height=`${Math.max(e.scrollHeight,we)}px`,i&&n&&(i.scrollTop=n)}}),[we]),{labelId:Re,validationId:Se,fieldHelpId:We,ariaDescribedBy:ke}=_({id:Pe,validationRedesignOptIn:Oe,error:U,warning:X,info:Y,label:C,fieldHelp:E}),[Ee,Ce]=b(pe,F,Be);d((()=>{var e;xe(te?(null==He||null===(e=He.current)||void 0===e?void 0:e.scrollHeight)||0:ve>v?ve:v)}),[ve,te]),d((()=>{ne&&Ae()})),d((()=>{var e,i;return ne&&(window.addEventListener("resize",Ae),xe((null==He||null===(e=He.current)||void 0===e?void 0:e.clientHeight)||0),null===(i=document.fonts)||void 0===i||i.addEventListener("loadingdone",Ae)),()=>{var e;ne&&(window.removeEventListener("resize",Ae),null===(e=document.fonts)||void 0===e||e.removeEventListener("loadingdone",Ae))}}),[Ae,ne]);const qe=!!(K||Se&&!re),Fe=l(h()),De=k?Fe.current:void 0,Me=[...Oe&&ye?[ke,De]:[De,ke],Ce,S].filter(Boolean).join(" "),ze=e(u,{disabled:V,readOnly:ee,inputWidth:"number"==typeof le?le:100-de,maxWidth:ae,error:U,warning:X,info:Y,borderRadius:me,hideBorders:fe,children:[i(p,B({"aria-invalid":!!U,"aria-labelledby":R,"aria-describedby":Me,autoFocus:W,name:Z,value:pe,ref:Le,onChange:D,onFocus:e=>{F&&Te("polite"),null==M||M(e)},onBlur:e=>{F&&Te("off"),null==z||z(e)},disabled:V,readOnly:ee,placeholder:V?"":ie,rows:te,id:Pe,as:"textarea",validationIconId:Oe?void 0:Se,inputBorderRadius:me,required:he},_e)),q,i(f,{disabled:V,readOnly:ee,inputIcon:K,error:U,warning:X,info:Y,validationIconId:Oe?void 0:Se,useValidationIcon:!(Oe||re)})]}),Ve=H(_e);return i(y,{tooltipPosition:se,helpAriaLabel:be,children:i(m,{children:e(g,(Ne=B({labelInline:je,hasIcon:qe,minHeight:we},Ve,s("textarea",{"data-element":ue,"data-role":ce})),$e={children:[e(c,{fieldHelp:Ie(E),fieldHelpId:We,error:U,warning:X,info:Y,label:C,labelId:Re,disabled:V,id:Pe,labelInline:Ie(je),labelAlign:$,labelWidth:Ie(de),labelHelp:Ie(G),labelSpacing:J,isRequired:he,useValidationIcon:Ie(re),adaptiveLabelBreakpoint:oe,validationRedesignOptIn:Oe,my:0,children:[(k||G&&Oe)&&i(P,{align:$,id:De,"data-element":"input-hint",children:k||G}),Oe?e(x,{position:"relative",children:[ye&&e(n,{children:[i(w,{error:U,validationId:Se,warning:X,validationMessagePositionTop:ye}),(U||X)&&i(j,{warning:!(U||!X)})]}),ze,!ye&&e(n,{children:[i(w,{error:U,validationId:Se,warning:X,validationMessagePositionTop:ye}),(U||X)&&i(j,{warning:!(U||!X)})]})]}):ze]}),Ee]},$e=null!=$e?$e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(Ne,Object.getOwnPropertyDescriptors($e)):function(e){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);i.push.apply(i,n)}return i}(Object($e)).forEach((function(e){Object.defineProperty(Ne,e,Object.getOwnPropertyDescriptor($e,e))})),Ne))})});var Ne,$e}));R.displayName="Textarea";export{R as OriginalTextarea,R as Textarea,R as default};
|
|
@@ -64,7 +64,7 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
|
|
|
64
64
|
/** [Legacy] Label width as a percentage when label is inline. */
|
|
65
65
|
labelWidth?: number;
|
|
66
66
|
/** Specify a callback triggered on change */
|
|
67
|
-
onChange
|
|
67
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
68
68
|
/** Deferred callback to be called after the onChange event */
|
|
69
69
|
onChangeDeferred?: () => void;
|
|
70
70
|
/** Specify a callback triggered on click */
|
|
@@ -94,7 +94,7 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
|
|
|
94
94
|
/** Render the ValidationMessage above the Textbox input when validationRedesignOptIn flag is set */
|
|
95
95
|
validationMessagePositionTop?: boolean;
|
|
96
96
|
}
|
|
97
|
-
export interface TextboxProps extends CommonTextboxProps {
|
|
97
|
+
export interface TextboxProps extends Omit<CommonTextboxProps, "defaultValue"> {
|
|
98
98
|
/** Content to be rendered next to the input */
|
|
99
99
|
children?: React.ReactNode;
|
|
100
100
|
/** Container for DatePicker or SelectList components */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as i,Fragment as n}from"react/jsx-runtime";import o,{useState as t,useContext as r,useRef as
|
|
1
|
+
import{jsxs as e,jsx as i,Fragment as n}from"react/jsx-runtime";import o,{useState as t,useContext as r,useRef as a}from"react";import{Box as l}from"../box/box.component.js";import d from"../../__internal__/form-field/form-field.component.js";import{HintText as p}from"../../__internal__/hint-text/hint-text.component.js";import s from"../../__internal__/input/input.component.js";import c from"../../__internal__/input/input-presentation.component.js";import{InputBehaviour as u}from"../../__internal__/input-behaviour/input-behaviour.component.js";import m from"../../__internal__/input-icon-toggle/input-icon-toggle.component.js";import{TooltipProvider as f}from"../../__internal__/tooltip-provider/index.js";import b from"../../__internal__/validation-message/validation-message.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import g from"../../style/utils/filter-styled-system-margin-props.js";import h from"../carbon-provider/__internal__/new-validation.context.js";import _ from"../numeral-date/__internal__/numeral-date.context.js";import v from"../../hooks/useCharacterCount/useCharacterCount.js";import y from"../../hooks/__internal__/useUniqueId/index.js";import O from"../../__internal__/utils/helpers/guid/index.js";import j from"../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import I from"./textbox.style.js";import w from"./__internal__/prefix.style.js";function x(e,i,n){return i in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}function C(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),o.forEach((function(i){x(e,i,n[i])}))}return e}function P(e,i){return i=null!=i?i:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):function(e){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);i.push.apply(i,n)}return i}(Object(i)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))})),e}const k="left",D="medium",H=30,L=!1,M=o.forwardRef(((o,x)=>{var{"aria-labelledby":M,"aria-describedby":T,align:W=k,autoFocus:B,children:S,disabled:A,inputIcon:F,leftChildren:q,label:z,labelAlign:R,labelHelp:E,labelInline:V,labelSpacing:U,id:G,formattedValue:J,inputHint:K,fieldHelp:N,error:Q,warning:X,info:Y,name:Z,reverse:$,size:ee=D,value:ie,readOnly:ne,placeholder:oe,onBlur:te,onClick:re,onFocus:ae,onChange:le,onMouseDown:de,onChangeDeferred:pe,deferTimeout:se,iconOnClick:ce,iconOnMouseDown:ue,iconTabIndex:me,validationOnLabel:fe=L,labelWidth:be=H,inputWidth:ge,maxWidth:he,prefix:_e,adaptiveLabelBreakpoint:ve,required:ye,positionedChildren:Oe,tooltipPosition:je,"data-component":Ie,"data-element":we,"data-role":xe,characterLimit:Ce,helpAriaLabel:Pe,tooltipId:ke,validationMessagePositionTop:De=!0}=o,He=function(e,i){if(null==e)return{};var n,o,t=function(e,i){if(null==e)return{};var n,o,t={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],i.indexOf(n)>=0||(t[n]=e[n]);return t}(e,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],i.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}(o,["aria-labelledby","aria-describedby","align","autoFocus","children","disabled","inputIcon","leftChildren","label","labelAlign","labelHelp","labelInline","labelSpacing","id","formattedValue","inputHint","fieldHelp","error","warning","info","name","reverse","size","value","readOnly","placeholder","onBlur","onClick","onFocus","onChange","onMouseDown","onChangeDeferred","deferTimeout","iconOnClick","iconOnMouseDown","iconTabIndex","validationOnLabel","labelWidth","inputWidth","maxWidth","prefix","adaptiveLabelBreakpoint","required","positionedChildren","tooltipPosition","data-component","data-element","data-role","characterLimit","helpAriaLabel","tooltipId","validationMessagePositionTop"]);const Le="string"==typeof ie?ie:"",[Me,Te]=y(G,Z),[We,Be]=t("off"),[Se,Ae]=v(Le,Ce,We),{validationRedesignOptIn:Fe}=r(h),{disableErrorBorder:qe}=r(_),ze=e=>Fe?void 0:e,{labelId:Re,validationId:Ee,fieldHelpId:Ve,ariaDescribedBy:Ue}=j({id:Me,validationRedesignOptIn:Fe,error:Q,warning:X,info:Y,label:z,fieldHelp:N}),Ge=a(O()),Je=K?Ge.current:void 0,Ke=[...Fe&&De?[Ue,Je]:[Je,Ue],Ae,T].filter(Boolean).join(" "),Ne=e(c,{align:W,disabled:A,readOnly:ne,size:ee,error:Q,warning:X,info:Y,prefix:_e,inputWidth:ge||100-be,maxWidth:V||"right"!==R?he:void 0,positionedChildren:Oe,hasIcon:!!(F||Ee&&!fe),children:[q,_e&&i(w,{"data-element":"textbox-prefix",size:ee,children:_e}),i(s,C(P(C({},ye&&{required:ye}),{align:W,"aria-invalid":!!Q,"aria-labelledby":M,"aria-describedby":Ke,autoFocus:B,deferTimeout:se,disabled:A,id:Me,ref:x,name:Te,onBlur:e=>{Ce&&Be("off"),null==te||te(e)},onChange:le,onChangeDeferred:pe,onClick:A||ne?void 0:re,onFocus:e=>{Ce&&Be("polite"),null==ae||ae(e)},onMouseDown:A||ne?void 0:de,placeholder:A||ne?"":oe,readOnly:ne,value:"string"==typeof J?J:ie,validationIconId:Fe?void 0:ke||Ee}),He)),S,i(m,{align:W,disabled:A,error:Q,iconTabIndex:me,info:Y,inputIcon:F,onClick:A||ne?void 0:ce||re,onMouseDown:A||ne?void 0:ue||de,readOnly:ne,size:ee,useValidationIcon:!(Fe||fe),warning:X,validationIconId:Fe?void 0:ke||Ee})]});return i(f,{helpAriaLabel:Pe,tooltipPosition:je,children:i(u,{children:e(d,P(C({maxWidth:V||"right"!==R?void 0:he,disabled:A,fieldHelpId:Ve,fieldHelp:ze(N),error:Q,warning:X,info:Y,label:z,labelId:Re,labelAlign:R,labelHelp:ze(E),labelInline:ze(V),labelSpacing:U,labelWidth:ze(be),id:Me,reverse:ze($),useValidationIcon:ze(fe),adaptiveLabelBreakpoint:ve,isRequired:ye,"data-component":Ie,"data-role":xe,"data-element":we,validationIconId:Fe?void 0:Ee,validationRedesignOptIn:Fe},g(He)),{children:[(K||E&&Fe)&&i(p,{align:R,"data-element":"input-hint",id:Je,isComponentInline:V,children:K||E}),Fe?e(l,{position:"relative",children:[De&&e(n,{children:[i(b,{error:Q,validationId:Ee,warning:X,validationMessagePositionTop:De}),!qe&&(Q||X)&&i(I,{warning:!(Q||!X)})]}),Ne,!De&&e(n,{children:[i(b,{error:Q,validationId:Ee,warning:X,validationMessagePositionTop:De}),!qe&&(Q||X)&&i(I,{warning:!(Q||!X)})]})]}):Ne,Se]}))})})}));export{k as ALIGN_DEFAULT,L as LABEL_VALIDATION_DEFAULT,H as LABEL_WIDTH_DEFAULT,D as SIZE_DEFAULT,M as Textbox,M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./use-multi-input";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{useMultiInput as default}from"./use-multi-input.js";
|