carbon-react 156.4.0 → 157.0.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BorderRadiusType } from "../../components/box/box.component";
|
|
3
3
|
export type EnterKeyHintTypes = "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
|
|
4
|
-
export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
|
4
|
+
export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "value"> {
|
|
5
5
|
align?: "right" | "left";
|
|
6
6
|
/** The ID of the input's description, is set along with hint text and error message. */
|
|
7
7
|
"aria-describedby"?: string;
|
|
@@ -35,6 +35,8 @@ export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
35
35
|
required?: boolean;
|
|
36
36
|
/** Id of the validation icon */
|
|
37
37
|
validationIconId?: string;
|
|
38
|
+
/** The value of the input */
|
|
39
|
+
value: string | readonly string[] | number | undefined;
|
|
38
40
|
}
|
|
39
41
|
export interface InputProps extends CommonInputProps {
|
|
40
42
|
/** The visible width of the text control, in average character widths */
|
|
@@ -22,14 +22,12 @@ export interface AdvancedColorPickerProps extends MarginProps, Pick<ModalProps,
|
|
|
22
22
|
"aria-labelledby"?: string;
|
|
23
23
|
/** Prop for `availableColors` containing array of objects of colors */
|
|
24
24
|
availableColors: AdvancedColor[];
|
|
25
|
-
/** Prop for `defaultColor` containing the default color for `uncontrolled` use */
|
|
26
|
-
defaultColor: string;
|
|
27
25
|
/** Specifies the name prop to be applied to each color in the group */
|
|
28
26
|
name: string;
|
|
29
27
|
/** Prop for `onBlur` event */
|
|
30
28
|
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
31
29
|
/** Prop for `onChange` event */
|
|
32
|
-
onChange
|
|
30
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
33
31
|
/** Prop for `onClose` event */
|
|
34
32
|
onClose?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement> | KeyboardEvent) => void;
|
|
35
33
|
/** Prop for `onOpen` event */
|
|
@@ -39,7 +37,7 @@ export interface AdvancedColorPickerProps extends MarginProps, Pick<ModalProps,
|
|
|
39
37
|
/** The ARIA role to be applied to the component container */
|
|
40
38
|
role?: string;
|
|
41
39
|
/** Prop for `selectedColor` containing pre-selected color for `controlled` use */
|
|
42
|
-
selectedColor
|
|
40
|
+
selectedColor: string;
|
|
43
41
|
}
|
|
44
|
-
export declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors,
|
|
42
|
+
export declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors, name, onOpen, onClose, onChange, onBlur, open, role, selectedColor, restoreFocusOnClose, ...props }: AdvancedColorPickerProps) => React.JSX.Element;
|
|
45
43
|
export default AdvancedColorPicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as o,useRef as t,useEffect as l,useCallback as n}from"react";import{StyledAdvancedColorPickerWrapper as i,HiddenCurrentColorList as a,DialogStyle as c,StyledAdvancedColorPickerPreview as s}from"./advanced-color-picker.style.js";import{SimpleColorPicker as p}from"../simple-color-picker/simple-color-picker.component.js";import{SimpleColor as u}from"../simple-color-picker/simple-color/simple-color.component.js";import d from"../../__internal__/utils/helpers/events/events.js";import"../../style/utils/filter-styled-system-padding-props.js";import m from"../../style/utils/filter-styled-system-margin-props.js";import f from"../../__internal__/utils/helpers/guid/index.js";import b from"../../hooks/__internal__/useLocale/useLocale.js";import"../definition-list/dl.component.js";import y from"../definition-list/dt/dt.component.js";import v from"../definition-list/dd/dd.component.js";import O from"../../__internal__/utils/
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as o,useRef as t,useEffect as l,useCallback as n}from"react";import{StyledAdvancedColorPickerWrapper as i,HiddenCurrentColorList as a,DialogStyle as c,StyledAdvancedColorPickerPreview as s}from"./advanced-color-picker.style.js";import{SimpleColorPicker as p}from"../simple-color-picker/simple-color-picker.component.js";import{SimpleColor as u}from"../simple-color-picker/simple-color/simple-color.component.js";import d from"../../__internal__/utils/helpers/events/events.js";import"../../style/utils/filter-styled-system-padding-props.js";import m from"../../style/utils/filter-styled-system-margin-props.js";import f from"../../__internal__/utils/helpers/guid/index.js";import b from"../../hooks/__internal__/useLocale/useLocale.js";import"../definition-list/dl.component.js";import y from"../definition-list/dt/dt.component.js";import v from"../definition-list/dd/dd.component.js";import O from"../../__internal__/utils/helpers/tags/tags.js";import j from"./advanced-color-picker-cell.style.js";function g(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}const h=h=>{var{"aria-describedby":k,"aria-label":C,"aria-labelledby":P,availableColors:_,name:w,onOpen:D,onClose:x,onChange:E,onBlur:S,open:K=!1,role:F,selectedColor:R,restoreFocusOnClose:B=!0}=h,I=function(e,r){if(null==e)return{};var o,t,l=function(e,r){if(null==e)return{};var o,t,l={},n=Object.keys(e);for(t=0;t<n.length;t++)o=n[t],r.indexOf(o)>=0||(l[o]=e[o]);return l}(e,r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(t=0;t<n.length;t++)o=n[t],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(l[o]=e[o])}return l}(h,["aria-describedby","aria-label","aria-labelledby","availableColors","name","onOpen","onClose","onChange","onBlur","open","role","selectedColor","restoreFocusOnClose"]);const[L,T]=o(),[z,A]=o(null),q=t(f()),G=b(),H=t(null),J=_.map((({value:e,label:r},o)=>({value:e,label:r,getRef:()=>H.current?H.current.gridItemRefs[o]:null}))),M=()=>{var e;return(null===(e=_.find((e=>e.value===R)))||void 0===e?void 0:e.label)||R};l((()=>{if(L||K){const e=null==J?void 0:J.find((e=>R===e.value));e&&A(e.getRef())}}),[J,R,L,K]);const N=n(((e,r)=>{"Tab"===e.key&&(e.shiftKey?document.activeElement===r&&z&&(z.focus(),e.preventDefault()):document.activeElement===z&&(null==r||r.focus(),e.preventDefault()))}),[z]),Q=n((e=>{T(!0),D&&D(e)}),[D]),U=n((e=>{T(!1),x&&x(e)}),[x]),V=n((e=>{const r=null==J?void 0:J.find((r=>e.target.value===r.value));r&&A(r.getRef()),E&&E(e)}),[E,J]),W=n((e=>{(d.isEnterKey(e)||d.isSpaceKey(e))&&(e.preventDefault(),Q(e))}),[Q]),X=n((e=>{(d.isEnterKey(e)||d.isSpaceKey(e))&&(e.preventDefault(),U(e))}),[U]),Y=n((e=>{S&&S(e)}),[S]);return e(i,(Z=function(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),t.forEach((function(r){g(e,r,o[r])}))}return e}({m:"15px auto auto 15px"},m(I),O("advanced-color-picker",I)),$=null!=($={children:[r(j,{"data-element":"color-picker-cell","aria-label":G.advancedColorPicker.ariaLabel(),"aria-describedby":q.current,onClick:Q,onKeyDown:W,color:R,tabIndex:0}),e(a,{id:q.current,"data-element":"current-color-description",children:[r(y,{children:G.advancedColorPicker.currentColorDescriptionTerm(M())}),r(v,{children:G.advancedColorPicker.currentColorAssigned(M())})]}),e(c,{"aria-describedby":k,"aria-label":C,"aria-labelledby":P,open:L||K,size:"auto",onCancel:U,bespokeFocusTrap:N,focusFirstElement:z,role:F,restoreFocusOnClose:B,children:[r(s,{"data-element":"color-picker-preview",color:R}),r(p,{name:w,legend:"",onChange:V,onBlur:Y,onKeyDown:X,ref:H,value:R,children:null==J?void 0:J.map((({value:e,label:o})=>r(u,{value:e,"aria-label":o,id:e,checked:e===R},e)))})]})]})?$:{},Object.getOwnPropertyDescriptors?Object.defineProperties(Z,Object.getOwnPropertyDescriptors($)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object($)).forEach((function(e){Object.defineProperty(Z,e,Object.getOwnPropertyDescriptor($,e))})),Z));var Z,$};export{h as AdvancedColorPicker,h as default};
|
|
@@ -28,10 +28,10 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
|
|
|
28
28
|
labelWidth?: number;
|
|
29
29
|
/** If true all ButtonToggle children will flex to the full width of the ButtonToggleGroup parent */
|
|
30
30
|
fullWidth?: boolean;
|
|
31
|
-
/** Callback triggered by pressing one of the child buttons.
|
|
32
|
-
onChange
|
|
33
|
-
/** Determines which child button is selected
|
|
34
|
-
value
|
|
31
|
+
/** Callback triggered by pressing one of the child buttons. */
|
|
32
|
+
onChange: (ev: React.MouseEvent<HTMLButtonElement>, value?: string) => void;
|
|
33
|
+
/** Determines which child button is selected */
|
|
34
|
+
value: string;
|
|
35
35
|
/** [Legacy] Aria label for rendered help component */
|
|
36
36
|
helpAriaLabel?: string;
|
|
37
37
|
/** Allow buttons within the group to be deselected when already selected, leaving no selected button */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import l,{useMemo as n,useRef as r,
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import l,{useMemo as n,useRef as r,useContext as i,useState as o}from"react";import a from"invariant";import p from"../../../__internal__/form-field/form-field.component.js";import s from"../../../__internal__/utils/helpers/tags/tags.js";import u from"../../../__internal__/utils/helpers/guid/index.js";import c from"./button-toggle-group.style.js";import{ButtonToggle as d}from"../button-toggle.component.js";import"../../../style/utils/filter-styled-system-padding-props.js";import b from"../../../style/utils/filter-styled-system-margin-props.js";import{TooltipProvider as f}from"../../../__internal__/tooltip-provider/index.js";import{InputGroupBehaviour as m}from"../../../__internal__/input-behaviour/input-group-behaviour.component.js";import g from"../../../__internal__/utils/helpers/events/events.js";import y from"../../carbon-provider/__internal__/new-validation.context.js";import{ButtonToggleGroupProvider as h}from"./__internal__/button-toggle-group.context.js";import{HintText as _}from"../../../__internal__/hint-text/hint-text.component.js";function j(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function v(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{},n=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(l).filter((function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable})))),n.forEach((function(t){j(e,t,l[t])}))}return e}function O(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 l=Object.getOwnPropertySymbols(e);t.push.apply(t,l)}return t}(Object(t)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(t,l))})),e}const w=j=>{var{children:w,fieldHelp:P,fieldHelpInline:x,"aria-label":H,label:I,labelHelp:D,labelSpacing:S,inputHint:B,inputWidth:W,fullWidth:A,labelInline:E,labelWidth:C,onChange:T,value:k,helpAriaLabel:L,id:G,allowDeselect:K=!1,disabled:N=!1}=j,R=function(e,t){if(null==e)return{};var l,n,r=function(e,t){if(null==e)return{};var l,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)l=i[n],t.indexOf(l)>=0||(r[l]=e[l]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)l=i[n],t.indexOf(l)>=0||Object.prototype.propertyIsEnumerable.call(e,l)&&(r[l]=e[l])}return r}(j,["children","fieldHelp","fieldHelpInline","aria-label","label","labelHelp","labelSpacing","inputHint","inputWidth","fullWidth","labelInline","labelWidth","onChange","value","helpAriaLabel","id","allowDeselect","disabled"]);const V=n((()=>!l.Children.toArray(w).find((e=>!l.isValidElement(e)||"ButtonToggle"!==e.type.displayName))),[w]);a(V,`\`ButtonToggleGroup\` only accepts children of type \`${d.displayName}\``);const q=r(u()),M=r(u()),$=r(null),{validationRedesignOptIn:z}=i(y),F=e=>z?void 0:e,J=()=>{var e;return null===(e=$.current)||void 0===e?void 0:e.querySelectorAll('[data-element="button-toggle-button"]')},[Q,U]=o();var X;return e(f,{helpAriaLabel:L,children:e(m,{children:e(p,O(v({label:I,labelHelp:F(D),labelSpacing:F(S),fieldHelp:F(P),fieldHelpInline:F(x),labelInline:F(E),labelWidth:F(C),labelId:q.current,id:G,labelAs:"span",disabled:N},b(R),s(null!==(X=R["data-component"])&&void 0!==X?X:"button-toggle-group",R)),{children:t(h,{value:{onButtonClick:()=>{},handleKeyDown:e=>{const t=J();if(!t||!document.activeElement)return;const l=Array.from(t).indexOf(document.activeElement);let n;g.isLeftKey(e)?n=t[0===l?t.length-1:l-1]:g.isRightKey(e)&&(n=t[(l+1)%t.length]),n instanceof HTMLButtonElement&&n.focus()},pressedButtonValue:k,onChange:T,allowDeselect:K,isInGroup:!0,isDisabled:N,firstButton:Q,childButtonCallbackRef:e=>{setTimeout((()=>{if(e){const t=J();t?e===t[0]&&U(e):U(void 0)}}),0)},hintTextId:B?M.current:void 0},children:[B&&e(_,{id:M.current,isDisabled:N,marginBottom:"var(--spacing150)",children:B}),e(c,O(v({ref:$},I?{"aria-labelledby":q.current}:{"aria-label":H}),{labelInline:E,inputWidth:W,fullWidth:A,role:"group",id:G,disabled:N,children:w}))]})}))})})};w.displayName="ButtonToggleGroup";export{w as default};
|
|
@@ -17,6 +17,10 @@ export interface CheckboxProps extends CommonCheckableInputProps, MarginProps, T
|
|
|
17
17
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
18
18
|
/** The value of the checkbox, passed on form submit */
|
|
19
19
|
value?: string;
|
|
20
|
+
/** Handler for change events */
|
|
21
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
22
|
+
/** Checked state of the input */
|
|
23
|
+
checked: boolean;
|
|
20
24
|
}
|
|
21
25
|
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
22
26
|
export default Checkbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as r}from"react/jsx-runtime";import t,{useContext as n}from"react";import o from"../../__internal__/utils/helpers/tags/tags.js";import i from"./checkbox.style.js";import l from"../../__internal__/checkable-input/checkable-input.component.js";import a from"./checkbox-svg.component.js";import p from"../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import{TooltipProvider as c}from"../../__internal__/tooltip-provider/index.js";import s from"./checkbox-group/__internal__/checkbox-group.context.js";import d from"
|
|
1
|
+
import{jsx as e,Fragment as r}from"react/jsx-runtime";import t,{useContext as n}from"react";import o from"../../__internal__/utils/helpers/tags/tags.js";import i from"./checkbox.style.js";import l from"../../__internal__/checkable-input/checkable-input.component.js";import a from"./checkbox-svg.component.js";import p from"../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import{TooltipProvider as c}from"../../__internal__/tooltip-provider/index.js";import s from"./checkbox-group/__internal__/checkbox-group.context.js";import d from"../carbon-provider/__internal__/new-validation.context.js";import"../../style/utils/filter-styled-system-padding-props.js";import b from"../../style/utils/filter-styled-system-margin-props.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 f(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),n.forEach((function(r){u(e,r,t[r])}))}return e}function m(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 t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const y=t.forwardRef(((t,u)=>{var{"aria-labelledby":y,id:h,label:g,onChange:O,name:j,onClick:v,onBlur:_,onFocus:k,value:w,fieldHelp:P,autoFocus:S,labelHelp:x,labelSpacing:H=1,labelWidth:I,adaptiveSpacingBreakpoint:B,required:C,error:W,warning:F,info:A,fieldHelpInline:L,reverse:D=!1,checked:q,disabled:z,inputWidth:E,size:N,tooltipPosition:R,"data-element":V,"data-role":G,helpAriaLabel:J}=t,K=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(t,["aria-labelledby","id","label","onChange","name","onClick","onBlur","onFocus","value","fieldHelp","autoFocus","labelHelp","labelSpacing","labelWidth","adaptiveSpacingBreakpoint","required","error","warning","info","fieldHelpInline","reverse","checked","disabled","inputWidth","size","tooltipPosition","data-element","data-role","helpAriaLabel"]);const{validationRedesignOptIn:M}=n(d),Q=p(B),T=!(!B||Q),U=n(s),{error:X,warning:Y,info:Z}=U,$=m(f({ariaLabelledBy:y,onClick:v,onChange:O,onBlur:_,onFocus:k,labelInline:!0,id:h,label:g,value:w,type:"checkbox",name:j,reverse:!D,fieldHelp:P,autoFocus:S,labelHelp:x,labelSpacing:H,required:C,fieldHelpInline:L,checked:q,disabled:z,inputWidth:E,labelWidth:I,ref:u},K),{"data-component":void 0}),ee=f({error:X||W,warning:Y||F},M?{validationOnLabel:!1}:{info:Z||A}),re=b(K),te=e(i,m(f(m(f({disabled:z,labelSpacing:H,inputWidth:E,adaptiveSpacingSmallScreen:T},ee),{fieldHelpInline:L,reverse:D,size:N,applyNewValidation:M}),re,o("checkbox",{"data-element":V,"data-role":G})),{children:e(l,m(f({},$,ee),{children:e(a,{})}))}));return e(r,{children:M?te:e(c,{helpAriaLabel:J,tooltipPosition:R,children:te})})}));y.displayName="Checkbox";export{y as Checkbox,y as default};
|
|
@@ -15,14 +15,12 @@ export interface DecimalProps extends Omit<CommonTextboxProps, "onChange" | "onB
|
|
|
15
15
|
align?: "left" | "right";
|
|
16
16
|
/** Allow an empty value instead of defaulting to 0.00 */
|
|
17
17
|
allowEmptyValue?: boolean;
|
|
18
|
-
/** The default value of the input if it's meant to be used as an uncontrolled component */
|
|
19
|
-
defaultValue?: string;
|
|
20
18
|
/** The input id */
|
|
21
19
|
id?: string;
|
|
22
20
|
/** The width of the input as a percentage */
|
|
23
21
|
inputWidth?: number;
|
|
24
|
-
/** Handler for change event
|
|
25
|
-
onChange
|
|
22
|
+
/** Handler for change event */
|
|
23
|
+
onChange: (ev: CustomEvent) => void;
|
|
26
24
|
/** Handler for blur event */
|
|
27
25
|
onBlur?: (ev: CustomEvent) => void;
|
|
28
26
|
/** The input name */
|
|
@@ -31,8 +29,8 @@ export interface DecimalProps extends Omit<CommonTextboxProps, "onChange" | "onB
|
|
|
31
29
|
precision?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
|
|
32
30
|
/** If true, the component will be read-only */
|
|
33
31
|
readOnly?: boolean;
|
|
34
|
-
/** The value of the input
|
|
35
|
-
value
|
|
32
|
+
/** The value of the input */
|
|
33
|
+
value: string;
|
|
36
34
|
/** The locale string - default en */
|
|
37
35
|
locale?: string;
|
|
38
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import r,{useContext as
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import r,{useContext as a,useCallback as o,useEffect as l,useState as i}from"react";import u from"invariant";import{Textbox as c}from"../textbox/textbox.component.js";import m from"../../__internal__/i18n-context/index.js";import p from"../../hooks/__internal__/usePrevious/index.js";import s from"../../__internal__/utils/logger/index.js";import g from"../../__internal__/utils/helpers/tags/tags.js";function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(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){d(e,t,n[t])}))}return e}const h=r.forwardRef(((r,d)=>{var{align:h="right",precision:v=2,inputWidth:y,readOnly:b,onChange:O,onBlur:x,id:_,name:j,allowEmptyValue:w=!1,locale:E,value:P}=r,D=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(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)&&(a[n]=e[n])}return a}(r,["align","precision","inputWidth","readOnly","onChange","onBlur","id","name","allowEmptyValue","locale","value"]);const N=a(m),$=o((e=>{var t;return null===(t=Intl.NumberFormat(E||N.locale()).formatToParts(10000.1).find((t=>t.type===e)))||void 0===t?void 0:t.value}),[N,E]),V=o((e=>Number.isNaN(Number(e))),[]),R=o((e=>{if(V(e))return e;if(""===e||e.match(/\s+/g))return e;const t=$("decimal"),[n,r]=e.split(".");let a=Intl.NumberFormat(E||N.locale(),{maximumFractionDigits:0}).format(+n);return(null==r?void 0:r.length)>v?a+=`${t+r}`:(null==r?void 0:r.length)<=v?a+=`${t+r+"0".repeat(v-r.length)}`:a+=`${v?t+"0".repeat(v):""}`,a}),[$,V,N,E,v]),C=w?"":R((0).toFixed(v)),F=o((e=>(u("string"==typeof e,"Decimal `value` prop must be a string"),e&&!w&&u(""!==e,"Decimal `value` must not be an empty string. Please use `allowEmptyValue` or specify a non-empty initialValue"),e)),[w]),S=p(v);l((()=>{S&&S!==v&&s.error("Decimal `precision` prop has changed value. Changing the Decimal `precision` prop has no effect.")}),[v,S]);const W=o((e=>{const t=new RegExp(`[\\${$("group")} ]*`,"g");return e.replace(t,"")}),[$]),k=o((e=>{var t;const n=(null===(t=$("group"))||void 0===t?void 0:t.match(/\s+/))&&!e.match(/\s{2,}/)?e.replace(/\s+/g,""):e,r=new RegExp("([^A-Za-z0-9]{2,})|(^[^A-Za-z0-9-]+)|([^0-9a-z-,.])|([^0-9-,.]+)|([W,.])$","g"),a=$("decimal"),o=new RegExp("."===a?`\\${a}`:a,"g");return n.match(r)||(n.match(o)||[]).length>1?n:W(n).replace(new RegExp(`\\${a}`,"g"),".")}),[$,W]),z=F(P||C),[B,I]=i(V(k(z))?z:R(z)),A=(e,t)=>({target:{name:j,id:_,value:{formattedValue:R(k(e)),rawValue:t||k(e)}}}),Z=p(P);return l((()=>{const e=k(B),t=F(P);e!==t&&I(R(""===t&&""===Z?C:t))}),[C,R,F,Z,B,k,P]),e(t,{children:[n(c,f({align:h,readOnly:b,inputWidth:y,onChange:e=>{const{value:t}=e.target;I(t),O(A(t))},onBlur:e=>{const{value:t}=e.target;let n;if(t){const e=k(t),r=V(e)?t:R(e);n=A(r,e),I(r)}else n=A(C),I(C);x&&x(n)},value:B,"data-component":"decimal",id:_,ref:d},D,g("decimal",D))),n("input",{name:j,value:k(B),type:"hidden","data-component":"hidden-input","data-role":"hidden-input"})]})}));h.displayName="Decimal";export{h as Decimal,h as default};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { InputProps } from "../../__internal__/input";
|
|
2
2
|
import type { ValidationProps } from "../../__internal__/validations";
|
|
3
|
-
|
|
3
|
+
type CustomFileInputProps = Omit<InputProps, "value"> & {
|
|
4
|
+
value?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const StyledHiddenFileInput: import("styled-components").StyledComponent<"input", any, CustomFileInputProps, never>;
|
|
4
7
|
interface StyledFileInputPresentationProps extends Pick<ValidationProps, "error"> {
|
|
5
8
|
isDraggedOver?: boolean;
|
|
6
9
|
isDraggingFile?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import i,{css as t}from"styled-components";import e from"../typography/typography.style.js";const r=i.input.withConfig({displayName:"file-input.style__StyledHiddenFileInput",componentId:"sc-
|
|
1
|
+
import i,{css as t}from"styled-components";import e from"../typography/typography.style.js";const r=i.input.withConfig({displayName:"file-input.style__StyledHiddenFileInput",componentId:"sc-6e60ad6-0"})(["display:none;"]),o=i.div.withConfig({displayName:"file-input.style__StyledFileInputPresentation",componentId:"sc-6e60ad6-1"})([""," ",""],(({hasUploadStatus:i,minWidth:e,minHeight:r,maxWidth:o,maxHeight:a})=>t(["min-width:",";min-height:",";max-width:",";",""],e,r,o,!i&&t(["padding:11px;max-height:",";box-sizing:border-box;"],a))),(({hasUploadStatus:i,isDraggedOver:r,isDraggingFile:o,error:a,isVertical:n})=>{let l="colorsUtilityMajor300",d="colorsUtilityYang100";return r?(l="colorsUtilityMajor400",d="colorsUtilityMajor100"):o&&(l="colorsUtilityMajor400"),a&&(l="colorsSemanticNegative"+(o?600:500)),!i&&t(["display:flex;"," flex-wrap:wrap;justify-content:center;align-content:center;align-items:center;text-align:center;gap:var(--spacing100);border-radius:var(--borderRadius050);border:var(--",") dashed var(--",");background:var(--",");","{color:var(--colorsUtilityYin055);}"],n&&"flex-direction: column;",a||o?"borderWidth200":"borderWidth100",l,d,e)}));export{o as StyledFileInputPresentation,r as StyledHiddenFileInput};
|
|
@@ -4,9 +4,9 @@ export interface FlatTableCheckboxProps extends TagProps {
|
|
|
4
4
|
/** Prop to polymorphically render either a 'th' or 'td' element */
|
|
5
5
|
as?: "td" | "th";
|
|
6
6
|
/** Prop to set checked prop on Checkbox */
|
|
7
|
-
checked
|
|
7
|
+
checked: boolean;
|
|
8
8
|
/** Callback to be called onChange in Checkbox */
|
|
9
|
-
onChange
|
|
9
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
10
|
/** Whether to render the checkbox or not, defaults to true */
|
|
11
11
|
selectable?: boolean;
|
|
12
12
|
/** Callback function to be called when click event received */
|
|
@@ -13,18 +13,16 @@ export interface CustomEvent extends Omit<React.ChangeEvent<HTMLInputElement>, "
|
|
|
13
13
|
target: CustomTarget;
|
|
14
14
|
}
|
|
15
15
|
export interface GroupedCharacterProps extends Omit<TextboxProps, "onChange" | "onBlur" | "data-component"> {
|
|
16
|
-
/** Default input value if component is meant to be used as an uncontrolled component */
|
|
17
|
-
defaultValue?: string;
|
|
18
16
|
/** pattern by which input value should be grouped */
|
|
19
17
|
groups: number[];
|
|
20
18
|
/** Handler for blur event */
|
|
21
19
|
onBlur?: (ev: CustomEvent) => void;
|
|
22
|
-
/** Handler for change event
|
|
23
|
-
onChange
|
|
20
|
+
/** Handler for change event */
|
|
21
|
+
onChange: (ev: CustomEvent) => void;
|
|
24
22
|
/** character to be used as separator - has to be a 1 character string */
|
|
25
23
|
separator: string;
|
|
26
|
-
/** Input value
|
|
27
|
-
value
|
|
24
|
+
/** Input value */
|
|
25
|
+
value: string;
|
|
28
26
|
}
|
|
29
27
|
export declare const GroupedCharacter: React.ForwardRefExoticComponent<GroupedCharacterProps & React.RefAttributes<HTMLInputElement>>;
|
|
30
28
|
export default GroupedCharacter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import t
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"react";import{Textbox as r}from"../textbox/textbox.component.js";import{toSum as n,generateGroups as o}from"./grouped-character.utils.js";import l from"../../__internal__/utils/helpers/tags/tags.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(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){a(e,t,r[t])}))}return e}function c(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 s=({target:e},t)=>{const{name:r,id:n}=e;return c(u({},r&&{name:r},n&&{id:n}),{value:t})},i=t.forwardRef(((t,a)=>{var{groups:i,onBlur:p,onChange:f,onKeyDown:g,separator:b,value:y}=t,O=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,["groups","onBlur","onChange","onKeyDown","separator","value"]);const m=b.substring(0,1),j=i.reduce(n),h=e=>o(i,e).join(m),d=e=>e.split(m).join("").substring(0,j);return e(r,u(c(u({},O),{value:y,formattedValue:h(y),onChange:e=>{const{target:t}=e,{selectionEnd:r}=t;let n=null!=r?r:0;const o=d(t.value),l=h(o),a=t.value.length===n,u=l[n-1]===m;if(a){const e=t.value.split(m).length-1,r=l.split(m).length-1;n+=r-e}else u&&(y.length>o.length||(n+=1));const c=e;c.target=s(e,{rawValue:o,formattedValue:l}),null==f||f(c),setTimeout((()=>t.setSelectionRange(n,n)))},onBlur:e=>{if(p){const{target:t}=e,r=d(t.value),n=h(r),o=e;o.target=s(e,{rawValue:r,formattedValue:n}),p(o)}},onKeyDown:e=>{const{selectionStart:t,selectionEnd:r}=e.target,n=(null!=r?r:0)-(null!=t?t:0)>0;if(1===e.key.length&&j===y.length&&!n&&e.preventDefault(),"Delete"===e.key){const r=null!=t?t:0,n=d(y);if(h(n)[r]===m){e.preventDefault();const t=e.target;setTimeout((()=>t.setSelectionRange(r+1,r+1)))}}g&&g(e)},ref:a}),l("grouped-character",O)))}));i.displayName="GroupedCharacter";export{i as GroupedCharacter,i as default};
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { TextboxProps } from "../textbox";
|
|
3
3
|
export interface NumberProps extends Omit<TextboxProps, "value"> {
|
|
4
4
|
/** Value passed to the input */
|
|
5
|
-
value
|
|
5
|
+
value: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const Number: React.ForwardRefExoticComponent<NumberProps & React.RefAttributes<HTMLInputElement>>;
|
|
8
8
|
export default Number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import t,{useRef as r}from"react";import{LABEL_VALIDATION_DEFAULT as n,ALIGN_DEFAULT as o,LABEL_WIDTH_DEFAULT as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t,{useRef as r}from"react";import{LABEL_VALIDATION_DEFAULT as n,ALIGN_DEFAULT as o,LABEL_WIDTH_DEFAULT as a,SIZE_DEFAULT as l,Textbox as i}from"../textbox/textbox.component.js";import c from"../../__internal__/utils/helpers/tags/tags.js";function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(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){u(e,t,r[t])}))}return e}const s=t.forwardRef(((t,u)=>{var{onChange:s,onKeyDown:f,value:p,align:O=o,labelWidth:g=a,size:y=l,validationOnLabel:m=n}=t,j=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,["onChange","onKeyDown","value","align","labelWidth","size","validationOnLabel"]);const v=r(null),d=r(null);var w,h,P;return e(i,b((h=b({},j),P=null!=(P={value:p,onChange:e=>{!function(e){return new RegExp("^[-]?[0-9]*$").test(e)}(e.target.value)?(e.target.value=p||"",e.target.setSelectionRange(v.current,d.current)):s(e)},onKeyDown:e=>{v.current=e.target.selectionStart,d.current=e.target.selectionEnd,f&&f(e)},ref:u,align:O,labelWidth:g,size:y,validationOnLabel:m})?P:{},Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(P)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(P)).forEach((function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(P,e))})),h),c(null!==(w=j["data-component"])&&void 0!==w?w:"number",j)))}));s.displayName="Number";export{s as Number,s as default};
|
|
@@ -23,10 +23,8 @@ export interface NumeralDateProps extends ValidationProps, MarginProps, TagProps
|
|
|
23
23
|
/** If true, the component will be read-only */
|
|
24
24
|
readOnly?: boolean;
|
|
25
25
|
dateFormat?: ValidDateFormat;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/** Value for use in controlled mode */
|
|
29
|
-
value?: NumeralDateValue;
|
|
26
|
+
/** Value */
|
|
27
|
+
value: NumeralDateValue;
|
|
30
28
|
/** When true, enables the internal errors to be displayed */
|
|
31
29
|
enableInternalError?: boolean;
|
|
32
30
|
/** When true, enables the internal warnings to be displayed */
|
|
@@ -57,7 +55,7 @@ export interface NumeralDateProps extends ValidationProps, MarginProps, TagProps
|
|
|
57
55
|
/** Blur event handler */
|
|
58
56
|
onBlur?: (ev: NumeralDateEvent) => void;
|
|
59
57
|
/** Change event handler */
|
|
60
|
-
onChange
|
|
58
|
+
onChange: (ev: NumeralDateEvent) => void;
|
|
61
59
|
/** Flag to configure component as mandatory */
|
|
62
60
|
required?: boolean;
|
|
63
61
|
/** Size of an input */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n,Fragment as
|
|
1
|
+
import{jsx as e,jsxs as n,Fragment as r}from"react/jsx-runtime";import{forwardRef as t,useContext as i,useRef as a,useImperativeHandle as l,useState as o,useMemo as d}from"react";import s from"invariant";import m from"../../__internal__/utils/helpers/tags/tags.js";import"../../style/utils/filter-styled-system-padding-props.js";import y from"../../style/utils/filter-styled-system-margin-props.js";import c from"../../__internal__/utils/helpers/events/events.js";import{StyledFieldset as p,StyledNumeralDate as u,StyledDateField as b}from"./numeral-date.style.js";import{Textbox as f}from"../textbox/textbox.component.js";import{Box as g}from"../box/box.component.js";import h from"../textbox/textbox.style.js";import v from"../../__internal__/validation-message/validation-message.component.js";import _ from"../../__internal__/utils/helpers/guid/index.js";import O from"../../hooks/__internal__/useLocale/useLocale.js";import{TooltipProvider as j}from"../../__internal__/tooltip-provider/index.js";import w from"../carbon-provider/__internal__/new-validation.context.js";import D from"./__internal__/numeral-date.context.js";import{FieldHelp as I}from"../../__internal__/field-help/field-help.component.js";import x from"../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import P from"../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import{HintText as k}from"../../__internal__/hint-text/hint-text.component.js";function A(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function S(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),t.forEach((function(n){A(e,n,r[n])}))}return e}function B(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})),e}const L=[["dd","mm","yyyy"],["mm","dd","yyyy"],["yyyy","mm","dd"],["dd","mm"],["mm","dd"],["mm","yyyy"]],R=e=>{const n=(new Date).getFullYear(),{format:r}=new Intl.DateTimeFormat(e,{month:"long"});return[...Array(12).keys()].map((e=>r(new Date(Date.UTC(n,e)))))},E=(e,n,r)=>({dd:e.numeralDate.validation.day(n?R(e.locale())[+n-1]:void 0,r),mm:e.numeralDate.validation.month(),yyyy:e.numeralDate.validation.year()}),F=(e,n)=>{switch(e){case"mm":return n.numeralDate.labels.month();case"yyyy":return n.numeralDate.labels.year();default:return n.numeralDate.labels.day()}},T=t(((t,A)=>{var{dateFormat:R=["dd","mm","yyyy"],disabled:T,error:H="",warning:M="",info:z,id:W,name:q,onBlur:C,onChange:K,value:N,validationOnLabel:Y=!1,label:J,labelInline:U,labelWidth:V,labelAlign:$,fieldLabelsAlign:G,labelHelp:Q,labelSpacing:X,fieldHelp:Z,adaptiveLabelBreakpoint:ee,required:ne,readOnly:re,size:te="medium",enableInternalError:ie,enableInternalWarning:ae,tooltipPosition:le,helpAriaLabel:oe,dayRef:de,monthRef:se,yearRef:me,validationMessagePositionTop:ye=!0}=t,ce=function(e,n){if(null==e)return{};var r,t,i=function(e,n){if(null==e)return{};var r,t,i={},a=Object.keys(e);for(t=0;t<a.length;t++)r=a[t],n.indexOf(r)>=0||(i[r]=e[r]);return i}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t<a.length;t++)r=a[t],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(t,["dateFormat","disabled","error","warning","info","id","name","onBlur","onChange","value","validationOnLabel","label","labelInline","labelWidth","labelAlign","fieldLabelsAlign","labelHelp","labelSpacing","fieldHelp","adaptiveLabelBreakpoint","required","readOnly","size","enableInternalError","enableInternalWarning","tooltipPosition","helpAriaLabel","dayRef","monthRef","yearRef","validationMessagePositionTop"]);const pe=O(),{validationRedesignOptIn:ue}=i(w),{current:be}=a(W||_()),fe=a({dd:_(),mm:_(),yyyy:_()}),ge=a(_()),he=a(R.map((()=>null)));l(A,(()=>({focus:()=>{var e;null===(e=he.current[0])||void 0===e||e.focus()}})));const[ve,_e]=o(S({},Object.fromEntries(R.map((e=>[e,""]))))),Oe=d((()=>!R||L.find((e=>JSON.stringify(e)===JSON.stringify(R)))),[R]);s(Oe,"Forbidden prop dateFormat supplied to NumeralDate. Only one of these date formats is allowed: ['dd', 'mm', 'yyyy'], ['mm', 'dd', 'yyyy'], ['yyyy', 'mm', 'dd'], ['dd', 'mm'], ['mm', 'dd'], ['mm', 'yyyy']");const je=e=>({target:{name:q,id:be,value:e}}),we=e=>{c.isNumberKey(e)||c.isTabKey(e)||c.isEnterKey(e)||"Delete"===e.key||"Backspace"===e.key||e.preventDefault()},De=()=>{(ie||ae)&&_e((e=>S({},e,((e,{dd:n,mm:r,yyyy:t})=>{const i={dd:"",mm:"",yyyy:""},a=((e,n)=>{if(!e||+e>12||+e<1)return 31;const r=new Date,t=+(n||r.getFullYear());return new Date(t,+e,0).getDate()})(r,t);return n&&(+n>a||+n<1)&&(i.dd=E(e,r,String(a)).dd),r&&(+r>12||+r<1)&&(i.mm=E(e).mm),t&&(+t<1800||+t>2200)&&(i.yyyy=E(e).yyyy),i})(pe,N)))),setTimeout((()=>{const e=!he.current.find((e=>e===document.activeElement));C&&e&&C(je(N))}),5)},Ie=Object.keys(ve).reduce(((e,n)=>ve[n]?`${e+ve[n]}\n`:e),""),xe=ie?Ie+H:H,Pe=ae?Ie+M:M,ke=x(ee);let Ae=U;ee&&(Ae=ke);const{validationId:Se,fieldHelpId:Be,ariaDescribedBy:Le}=P({id:be,validationRedesignOptIn:!0,error:xe,warning:Pe,info:z,fieldHelp:Z}),Re=(ue&&ye?[Le,ge.current]:[ge.current,Le]).filter(Boolean).join(" "),Ee=()=>e(u,{onKeyDown:we,children:R.map(((n,r)=>{const t=r===R.length-1;let i;const a=xe||Pe||z,l=!ue&&"string"==typeof a&&""!==a;switch(n.slice(0,2)){case"dd":i=de;break;case"mm":i=se;break;case"yy":i=me}return e(D.Provider,{value:{disableErrorBorder:!0},children:e(b,{size:te,isYearInput:4===n.length,hasValidationIconInField:!Y&&t&&l,children:e(f,B(S({id:fe.current[n],label:F(n,pe),labelAlign:G,disabled:T,readOnly:re,error:!!xe,warning:!!Pe,info:!!z,size:te,value:N[n],onChange:e=>((e,n)=>{const{value:r}=e.target;if(r.length<=n.length){const e=B(S({},N),{[n]:r});K(je(e))}})(e,n),onBlur:De,ref:e=>((e,n,r)=>{he.current[n]=e,r&&("function"==typeof r?r(e):r.current=e)})(e,r,i)},t&&!Y&&!ue&&{error:xe,warning:Pe,info:z}),{tooltipPosition:le,tooltipId:Se,my:0}))},n)},n)}))});return ue?n(p,B(S({id:be,legend:J,legendMargin:{mb:0},legendAlign:$,isRequired:ne,isDisabled:T,name:q,"aria-describedby":Re},y(ce),m("numeral-date",ce)),{children:[Q&&e(k,{align:$,id:ge.current,children:Q}),n(g,{position:"relative",mt:Q?0:1,children:[ye&&(xe||Pe)&&n(r,{children:[e(v,{error:xe,warning:Pe,validationId:Se,validationMessagePositionTop:ye}),e(h,{warning:!(xe||!Pe)})]}),Ee(),!ye&&(xe||Pe)&&n(r,{children:[e(v,{error:xe,warning:Pe,validationId:Se,validationMessagePositionTop:ye}),e(h,{warning:!(xe||!Pe)})]})]})]})):e(j,{helpAriaLabel:oe,children:e(p,B(S({id:be,legend:J,legendMargin:{mb:0},isRequired:ne,isDisabled:T,name:q,error:Y&&xe,warning:Y&&Pe,info:Y&&z,inline:Ae,size:te,labelHelp:Q,legendAlign:$,legendWidth:V,legendSpacing:X,validationId:Se,"aria-describedby":Y?Le:Be},y(ce),m("numeral-date",ce)),{children:n(g,{display:"flex",flexDirection:"column",mt:Ae?0:1,children:[Ee(),Z&&e(I,{id:Be,children:Z})]})}))})}));export{L as ALLOWED_DATE_FORMATS,T as NumeralDate,T as default};
|
|
@@ -38,11 +38,11 @@ export interface RadioButtonGroupProps extends ValidationProps, MarginProps, Tag
|
|
|
38
38
|
/** Callback fired when each RadioButton is blurred */
|
|
39
39
|
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
40
40
|
/** Callback fired when the user selects a RadioButton */
|
|
41
|
-
onChange
|
|
41
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
42
42
|
/** Flag to configure component as mandatory */
|
|
43
43
|
required?: boolean;
|
|
44
44
|
/** value of the selected RadioButton */
|
|
45
|
-
value
|
|
45
|
+
value: string;
|
|
46
46
|
/** [Legacy] Overrides the default tooltip position */
|
|
47
47
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
48
48
|
/** Render the ValidationMessage above the RadioButton inputs when validationRedesignOptIn flag is set */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import i,{useContext as o,useRef as t}from"react";import l from"../../../__internal__/utils/helpers/tags/tags.js";import a from"../../../__internal__/fieldset/fieldset.component.js";import d from"./radio-button-group.style.js";import p from"../../../__internal__/radio-button-mapper/radio-button-mapper.component.js";import s from"../../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import"../../../style/utils/filter-styled-system-padding-props.js";import c from"../../../style/utils/filter-styled-system-margin-props.js";import{TooltipProvider as g}from"../../../__internal__/tooltip-provider/index.js";import u from"
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import i,{useContext as o,useRef as t}from"react";import l from"../../../__internal__/utils/helpers/tags/tags.js";import a from"../../../__internal__/fieldset/fieldset.component.js";import d from"./radio-button-group.style.js";import p from"../../../__internal__/radio-button-mapper/radio-button-mapper.component.js";import s from"../../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import"../../../style/utils/filter-styled-system-padding-props.js";import c from"../../../style/utils/filter-styled-system-margin-props.js";import{TooltipProvider as g}from"../../../__internal__/tooltip-provider/index.js";import u from"../../carbon-provider/__internal__/new-validation.context.js";import m from"../../../__internal__/validation-message/validation-message.component.js";import{Box as b}from"../../box/box.component.js";import f from"../../../__internal__/utils/helpers/guid/index.js";import _ from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import h from"../../textbox/textbox.style.js";import{HintText as v}from"../../../__internal__/hint-text/hint-text.component.js";function y(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function j(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},i=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),i.forEach((function(n){y(e,n,r[n])}))}return e}function O(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})),e}const w=y=>{var{children:w,id:P,name:x,legend:B,legendHelp:I,error:S,warning:k,info:A,onBlur:E,onChange:C,value:D,inline:R=!1,legendInline:T=!1,legendWidth:q,legendAlign:M="left",legendSpacing:G,labelSpacing:W=1,adaptiveLegendBreakpoint:H,adaptiveSpacingBreakpoint:L,required:V,tooltipPosition:N,validationMessagePositionTop:$=!0}=y,z=function(e,n){if(null==e)return{};var r,i,o=function(e,n){if(null==e)return{};var r,i,o={},t=Object.keys(e);for(i=0;i<t.length;i++)r=t[i],n.indexOf(r)>=0||(o[r]=e[r]);return o}(e,n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(i=0;i<t.length;i++)r=t[i],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(y,["children","id","name","legend","legendHelp","error","warning","info","onBlur","onChange","value","inline","legendInline","legendWidth","legendAlign","legendSpacing","labelSpacing","adaptiveLegendBreakpoint","adaptiveSpacingBreakpoint","required","tooltipPosition","validationMessagePositionTop"]);const{validationRedesignOptIn:F}=o(u),J=t(f()),K=P||J.current,Q=I?`${K}-hint`:void 0,U=c(z),X=s(H),Y=s(L);let Z=T;H&&(Z=!!X);let ee=U.ml;L&&!Y&&(ee=void 0);const{validationId:ne,ariaDescribedBy:re}=_({id:K,validationRedesignOptIn:!0,error:S,warning:k,info:A}),ie=(F&&$?[re,Q]:[Q,re]).filter(Boolean).join(" ");return e(n,{children:F?r(a,O(j(O(j({legend:B,error:S,warning:k,legendAlign:M,isRequired:V,width:"fit-content"},l("radiogroup",z),U),{ml:ee,blockGroupBehaviour:!(S||k)}),ie&&{"aria-describedby":ie}),{children:[I&&e(v,{align:M,id:Q,marginTop:"-4px",children:I}),r(b,{position:"relative",children:[$&&r(n,{children:[e(m,{error:S,warning:k,validationId:ne,validationMessagePositionTop:$}),(S||k)&&e(h,{"data-role":"radio-error-border",warning:!(S||!k)})]}),e(d,{"data-component":"radio-button-group",role:"radiogroup",inline:R,legendInline:Z,children:e(p,{name:x,onBlur:E,onChange:C,value:D,children:i.Children.map(w,(e=>i.isValidElement(e)?i.cloneElement(e,j({inline:R,labelSpacing:W,error:!!S,warning:!!k},e.props)):e))})}),!$&&r(n,{children:[e(m,{error:S,warning:k,validationId:ne,validationMessagePositionTop:$}),(S||k)&&e(h,{"data-role":"radio-error-border",warning:!(S||!k)})]})]})]})):e(g,{tooltipPosition:N,children:e(a,O(j({legend:B,error:S,warning:k,info:A,inline:Z,legendWidth:q,legendAlign:M,legendSpacing:G,isRequired:V},l("radiogroup",z),U),{ml:ee,blockGroupBehaviour:!(S||k||A),"aria-describedby":re,validationId:ne,children:e(d,{"data-component":"radio-button-group",role:"radiogroup",inline:R,legendInline:Z,children:e(p,{name:x,onBlur:E,onChange:C,value:D,children:i.Children.map(w,(e=>i.isValidElement(e)?i.cloneElement(e,j({inline:R,labelSpacing:W,error:!!S,warning:!!k,info:!!A},e.props)):e))})})}))})})};w.displayName="RadioButtonGroup";export{w as RadioButtonGroup,w as default};
|
|
@@ -14,8 +14,6 @@ export interface SearchProps extends ValidationProps, MarginProps, TagProps {
|
|
|
14
14
|
"aria-label"?: string;
|
|
15
15
|
/** Prop to specify the aria-label of the search button */
|
|
16
16
|
searchButtonAriaLabel?: string;
|
|
17
|
-
/** Prop for `uncontrolled` use */
|
|
18
|
-
defaultValue?: string;
|
|
19
17
|
/** Prop for `id` */
|
|
20
18
|
id?: string;
|
|
21
19
|
/** Prop for `name` */
|
|
@@ -23,7 +21,7 @@ export interface SearchProps extends ValidationProps, MarginProps, TagProps {
|
|
|
23
21
|
/** Prop for `onBlur` events */
|
|
24
22
|
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
25
23
|
/** Prop for `onChange` events */
|
|
26
|
-
onChange
|
|
24
|
+
onChange: (ev: SearchEvent) => void;
|
|
27
25
|
/** Prop for `onClick` events.
|
|
28
26
|
* `onClick` events are triggered when the `searchButton` is clicked
|
|
29
27
|
*/
|
|
@@ -53,8 +51,8 @@ export interface SearchProps extends ValidationProps, MarginProps, TagProps {
|
|
|
53
51
|
* Leaving the `maxWidth` prop with no value will default the width to '100%'
|
|
54
52
|
*/
|
|
55
53
|
maxWidth?: string;
|
|
56
|
-
/**
|
|
57
|
-
value
|
|
54
|
+
/** Current value */
|
|
55
|
+
value: string;
|
|
58
56
|
/** Prop to specify the styling of the search component */
|
|
59
57
|
variant?: "default" | "dark";
|
|
60
58
|
/** Input tabindex */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import r,{useRef as n,useImperativeHandle as o,useState as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import r,{useRef as n,useImperativeHandle as o,useState as i}from"react";import a from"invariant";import l from"../../__internal__/utils/helpers/tags/tags.js";import"../../style/utils/filter-styled-system-padding-props.js";import s from"../../style/utils/filter-styled-system-margin-props.js";import c from"./search.style.js";import u from"./search-button.style.js";import p from"../icon/icon.component.js";import{Textbox as f}from"../textbox/textbox.component.js";import m from"../button/button.component.js";import h from"../../hooks/__internal__/useLocale/useLocale.js";import b from"../../__internal__/utils/helpers/events/events.js";function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(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){y(e,t,r[t])}))}return e}function g(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 O=r.forwardRef(((r,y)=>{var{onChange:O,onClick:v,onFocus:j,onBlur:w,onKeyDown:P,value:x,id:_,name:C,searchWidth:k,maxWidth:B,searchButton:D,searchButtonAriaLabel:S,placeholder:I,variant:W="default","aria-label":T="search",tabIndex:E,error:F,warning:K,info:L,tooltipPosition:A,triggerOnClear:z}=r,H=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}(r,["onChange","onClick","onFocus","onBlur","onKeyDown","value","id","name","searchWidth","maxWidth","searchButton","searchButtonAriaLabel","placeholder","variant","aria-label","tabIndex","error","warning","info","tooltipPosition","triggerOnClear"]);const M=h(),N=n(null),R=n(null);o(y,(()=>({focus(){var e;null===(e=R.current)||void 0===e||e.focus()}})),[]),a("string"==typeof x,"This component has no initial value");const[V,q]=i(!1),G=0===x.length;let J={};D&&v&&(J={onClick:()=>{v({target:{name:C,id:_,value:x}})}});const Q="string"==typeof D?D:M.search.searchButtonText(),U=!!(null==x?void 0:x.length);return e(c,g(d(g(d({ref:N,isFocused:V,searchWidth:k,maxWidth:B,searchHasValue:U,showSearchButton:!!D,variant:W},s(H)),{id:_,name:C}),H,l("search",H)),{children:[t(f,{placeholder:I,value:x,inputIcon:G?void 0:"cross",iconTabIndex:G?-1:0,iconOnClick:()=>{var e;null==O||O({target:g(d({},C&&{name:C},_&&{id:_}),{value:""})}),z&&(null==v||v({target:g(d({},C&&{name:C},_&&{id:_}),{value:""})})),null===(e=R.current)||void 0===e||e.focus()},iconOnMouseDown:e=>{e.preventDefault()},"aria-label":T,onFocus:e=>{q(!0),j&&j(e)},onBlur:e=>{q(!1),w&&w(e)},onChange:e=>{O(e)},onKeyDown:e=>{1===e.key.length&&e.stopPropagation(),b.isEscKey(e)&&!G&&(e.stopPropagation(),null==O||O({target:g(d({},C&&{name:C},_&&{id:_}),{value:""})})),P&&P(e)},ref:R,tabIndex:E,error:F,warning:K,info:L,leftChildren:D?void 0:t(p,{type:"search",ml:1}),tooltipPosition:A,my:0}),D&&t(u,{children:t(m,g(d({"aria-label":S||Q,size:"medium",px:2,buttonType:"primary",iconPosition:"before",iconType:"search",className:"search-button"},J),{children:Q}))})]}))}));export{O as Search,O as default};
|
|
@@ -72,6 +72,8 @@ export interface SelectTextboxProps extends FormInputPropTypes {
|
|
|
72
72
|
transparent?: boolean;
|
|
73
73
|
/** @private @ignore */
|
|
74
74
|
activeDescendantId?: string;
|
|
75
|
+
/** Specify a callback triggered on change */
|
|
76
|
+
onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
75
77
|
}
|
|
76
78
|
declare const SelectTextbox: React.ForwardRefExoticComponent<SelectTextboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
77
79
|
export default SelectTextbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import t from"react";import{SelectTextboxContext as r}from"./select-textbox.context.js";import{StyledSelectText as o,StyledSelectTextChildrenWrapper as n}from"./select-textbox.style.js";import{Textbox as a}from"../../../textbox/textbox.component.js";import l from"../../../../hooks/__internal__/useLocale/useLocale.js";function i(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]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){i(e,t,r[t])}))}return e}function s(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}function d(e,t){if(null==e)return{};var r,o,n=function(e,t){if(null==e)return{};var r,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const b=t.forwardRef(((t,i)=>{var{ariaLabel:b,ariaLabelledby:u,accessibilityLabelId:p,labelId:y,"aria-controls":f,disabled:O=!1,isOpen:m,id:
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"react";import{SelectTextboxContext as r}from"./select-textbox.context.js";import{StyledSelectText as o,StyledSelectTextChildrenWrapper as n}from"./select-textbox.style.js";import{Textbox as a}from"../../../textbox/textbox.component.js";import l from"../../../../hooks/__internal__/useLocale/useLocale.js";function i(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]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){i(e,t,r[t])}))}return e}function s(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}function d(e,t){if(null==e)return{};var r,o,n=function(e,t){if(null==e)return{};var r,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const b=t.forwardRef(((t,i)=>{var{ariaLabel:b,ariaLabelledby:u,accessibilityLabelId:p,labelId:y,"aria-controls":f,disabled:O=!1,isOpen:m,id:h,readOnly:x=!1,placeholder:j,size:v="medium",onClick:g,onFocus:w,onBlur:P,formattedValue:I="",selectedValue:C,required:D,hasTextCursor:k,transparent:L=!1,activeDescendantId:S,onKeyDown:V,onChange:z}=t,_=d(t,["ariaLabel","ariaLabelledby","accessibilityLabelId","labelId","aria-controls","disabled","isOpen","id","readOnly","placeholder","size","onClick","onFocus","onBlur","formattedValue","selectedValue","required","hasTextCursor","transparent","activeDescendantId","onKeyDown","onChange"]);const q=l(),B=j||q.select.placeholder(),E=!O&&!x&&!I;function F(e){null==g||g(e)}const K=c({disabled:O,id:h,readOnly:x,required:D,onClick:F,onFocus:function(e){O||x||null==w||w(e)},onBlur:P,labelId:y,type:"text",ref:i,onKeyDown:V},_),{"aria-describedby":T}=_,A=d(_,["aria-describedby"]),$={"aria-expanded":x?void 0:m,"aria-labelledby":p?`${u||y} ${p}`:u,"aria-activedescendant":S,"aria-controls":f,"aria-autocomplete":k?"both":void 0,role:x?void 0:"combobox"},N="string"==typeof C||Array.isArray(C)&&"string"==typeof C[0];return e(r.Provider,{value:{isInputInSelect:!0},children:e(a,s(c({"aria-describedby":T,"aria-label":b,"data-element":"select-input","data-role":"select-textbox",inputIcon:"dropdown",autoComplete:"off",size:v,formattedValue:I,placeholder:k?B:void 0},$,K),{onChange:z,value:N?C:void 0,my:0,children:!k&&e(o,s(c({"aria-hidden":!0,"data-element":"select-text","data-role":"select-text",disabled:O,hasPlaceholder:E,onClick:O||x?void 0:F,readOnly:x,transparent:L,size:v},A),{children:e(n,{children:E?B:I})}))}))})}));b.displayName="SelectTextbox";export{b as default};
|