@okta/odyssey-react-mui 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/Autocomplete.js +2 -0
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Field.js +2 -0
- package/dist/Field.js.map +1 -1
- package/dist/FieldComponentProps.js.map +1 -1
- package/dist/NativeSelect.js +2 -0
- package/dist/NativeSelect.js.map +1 -1
- package/dist/PasswordField.js +2 -0
- package/dist/PasswordField.js.map +1 -1
- package/dist/SearchField.js +2 -0
- package/dist/SearchField.js.map +1 -1
- package/dist/Select.js +2 -0
- package/dist/Select.js.map +1 -1
- package/dist/TextField.js +2 -0
- package/dist/TextField.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +2 -2
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Field.d.ts +5 -1
- package/dist/src/Field.d.ts.map +1 -1
- package/dist/src/FieldComponentProps.d.ts +4 -0
- package/dist/src/FieldComponentProps.d.ts.map +1 -1
- package/dist/src/NativeSelect.d.ts +1 -1
- package/dist/src/NativeSelect.d.ts.map +1 -1
- package/dist/src/PasswordField.d.ts.map +1 -1
- package/dist/src/SearchField.d.ts +2 -2
- package/dist/src/SearchField.d.ts.map +1 -1
- package/dist/src/Select.d.ts +2 -2
- package/dist/src/Select.d.ts.map +1 -1
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Autocomplete.tsx +3 -1
- package/src/Field.tsx +6 -0
- package/src/FieldComponentProps.ts +4 -0
- package/src/NativeSelect.tsx +3 -1
- package/src/PasswordField.tsx +2 -0
- package/src/SearchField.tsx +3 -1
- package/src/Select.tsx +9 -1
- package/src/TextField.tsx +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.8.2](https://github.com/okta/odyssey/compare/v1.8.1...v1.8.2) (2023-12-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @okta/odyssey-react-mui
|
|
9
|
+
|
|
6
10
|
## [1.8.1](https://github.com/okta/odyssey/compare/v1.8.0...v1.8.1) (2023-12-01)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/dist/Autocomplete.js
CHANGED
|
@@ -24,6 +24,7 @@ const Autocomplete = _ref => {
|
|
|
24
24
|
inputValue,
|
|
25
25
|
isCustomValueAllowed,
|
|
26
26
|
isDisabled,
|
|
27
|
+
isFullWidth = false,
|
|
27
28
|
isLoading,
|
|
28
29
|
isOptional = false,
|
|
29
30
|
isReadOnly,
|
|
@@ -118,6 +119,7 @@ const Autocomplete = _ref => {
|
|
|
118
119
|
freeSolo: isCustomValueAllowed,
|
|
119
120
|
filterSelectedOptions: true,
|
|
120
121
|
id: idOverride,
|
|
122
|
+
fullWidth: isFullWidth,
|
|
121
123
|
loading: isLoading,
|
|
122
124
|
multiple: hasMultipleChoices,
|
|
123
125
|
onBlur: onBlur,
|
package/dist/Autocomplete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.js","names":["memo","useCallback","useMemo","useRef","Field","ComponentControlledState","useInputValues","getControlState","jsx","_jsx","Autocomplete","_ref","defaultValue","errorMessage","hasMultipleChoices","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isLoading","isOptional","isReadOnly","hint","label","name","nameOverride","onBlur","onChange","onChangeProp","onInputChange","onInputChangeProp","onFocus","options","value","getIsOptionEqualToValue","testId","controlledStateRef","controlledValue","uncontrolledValue","defaultValueProp","undefined","valueProps","controlState","current","inputValueProp","CONTROLLED","renderInput","_ref2","InputLabelProps","InputProps","params","fieldType","hasVisibleLabel","htmlFor","renderFieldComponent","_ref3","ariaDescribedBy","errorMessageElementId","labelElementId","_InputBase","inputProps","required","event","reason","details","_Autocomplete","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","loading","multiple","readOnly","isOptionEqualToValue","MemoizedAutocomplete","displayName"],"sources":["../src/Autocomplete.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n Autocomplete as MuiAutocomplete,\n AutocompleteProps as MuiAutocompleteProps,\n InputBase,\n UseAutocompleteProps,\n AutocompleteValue,\n} from \"@mui/material\";\nimport { memo, useCallback, useMemo, useRef } from \"react\";\n\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils\";\n\nexport type AutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"defaultValue\"];\n /**\n * Enables multiple choice selection\n */\n hasMultipleChoices?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"multiple\"];\n /**\n * The value for the input\n */\n inputValue?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"inputValue\"];\n /**\n * Allows the input of custom values\n */\n isCustomValueAllowed?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"freeSolo\"];\n /**\n * Disables the Autocomplete input\n */\n isDisabled?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"disabled\"];\n /**\n * Displays a loading indicator\n */\n isLoading?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"loading\"];\n /**\n * Makes the Autocomplete input read-only\n */\n isReadOnly?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"readOnly\"];\n /**\n * The label text for the autocomplete input\n */\n label: string;\n /**\n * Callback fired when the autocomplete loses focus.\n */\n onBlur?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onBlur\"];\n /**\n * Callback fired when a selection is made.\n */\n onChange?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"];\n /**\n * Callback fired when the textbox receives typed characters.\n */\n onInputChange?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"];\n /**\n * Callback fired when the autocomplete gains focus.\n */\n onFocus?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onFocus\"];\n /**\n * The options for the Autocomplete input\n */\n options: ReadonlyArray<OptionType>;\n /**\n * The value of the Autocomplete input\n */\n value?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n\n /**\n * Used to determine if the option represents the given value. Uses strict equality by default if none provided.\n * Both arguments need to be handled, an option can only match with one value.\n * option: the option to test\n * value: the value to test against\n *\n * You will need to implement this function if your `option` items are objects.\n */\n getIsOptionEqualToValue?: (option: OptionType, value: OptionType) => boolean;\n} & Pick<\n FieldComponentProps,\n \"errorMessage\" | \"hint\" | \"id\" | \"isOptional\" | \"name\"\n> &\n SeleniumProps;\n\nconst Autocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined\n>({\n defaultValue,\n errorMessage,\n hasMultipleChoices,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isLoading,\n isOptional = false,\n isReadOnly,\n hint,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n onFocus,\n options,\n value,\n getIsOptionEqualToValue,\n testId,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const controlledStateRef = useRef(\n getControlState({ controlledValue: value, uncontrolledValue: defaultValue })\n );\n const defaultValueProp = useMemo<\n | AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >\n | undefined\n >(() => {\n if (hasMultipleChoices) {\n if (value === undefined) {\n return defaultValue;\n }\n return [] as AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >;\n }\n return value === undefined ? defaultValue : undefined;\n }, [defaultValue, hasMultipleChoices, value]);\n\n const valueProps = useInputValues({\n defaultValue: defaultValueProp,\n value: value,\n controlState: controlledStateRef.current,\n });\n\n const inputValueProp = useMemo(() => {\n if (controlledStateRef.current === ComponentControlledState.CONTROLLED) {\n return { inputValue };\n }\n return undefined;\n }, [inputValue]);\n\n const renderInput = useCallback(\n ({ InputLabelProps, InputProps, ...params }) => (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n id={InputLabelProps.htmlFor}\n hint={hint}\n label={label}\n isOptional={isOptional}\n renderFieldComponent={({\n ariaDescribedBy,\n id,\n errorMessageElementId,\n labelElementId,\n }) => (\n <InputBase\n {...params}\n {...InputProps}\n inputProps={{\n ...params.inputProps,\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n }}\n aria-describedby={ariaDescribedBy}\n id={id}\n name={nameOverride ?? id}\n required={!isOptional}\n />\n )}\n />\n ),\n [errorMessage, hint, isOptional, label, nameOverride]\n );\n const onChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"]\n >\n >(\n (event, value, reason, details) => {\n onChangeProp?.(event, value, reason, details);\n },\n [onChangeProp]\n );\n\n const onInputChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"]\n >\n >(\n (event, value, reason) => {\n onInputChangeProp?.(event, value, reason);\n },\n [onInputChangeProp]\n );\n\n return (\n <MuiAutocomplete\n {...valueProps}\n {...inputValueProp}\n // AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div\n aria-disabled={isDisabled}\n data-se={testId}\n disableCloseOnSelect={hasMultipleChoices}\n disabled={isDisabled}\n freeSolo={isCustomValueAllowed}\n filterSelectedOptions={true}\n id={idOverride}\n loading={isLoading}\n multiple={hasMultipleChoices}\n onBlur={onBlur}\n onChange={onChange}\n onInputChange={onInputChange}\n onFocus={onFocus}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n isOptionEqualToValue={getIsOptionEqualToValue}\n />\n );\n};\n\n// Need the `typeof Autocomplete` because generics don't get passed through\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n// @ts-expect-error displayName is expected to not be on `typeof Autocomplete`\nMemoizedAutocomplete.displayName = \"Autocomplete\";\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA,SAASA,IAAI,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAAC,SAElDC,KAAK;AAAA,SAIZC,wBAAwB,EACxBC,cAAc,EACdC,eAAe;AAAA,SA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B,GAAGgC,KAAK,EAAE7B,KAAK,EAAE8B,MAAM,CAAC;EAC3C,CAAC,EACD,CAACjC,iBAAiB,CACpB,CAAC;EAED,OACEtB,IAAA,CAAAyD,aAAA;IAAA,GACMxB,UAAU;IAAA,GACVG,cAAc;IAElB,iBAAe1B,UAAW;IAC1B,WAASiB,MAAO;IAChB+B,oBAAoB,EAAErD,kBAAmB;IACzCsD,QAAQ,EAAEjD,UAAW;IACrBkD,QAAQ,EAAEnD,oBAAqB;IAC/BoD,qBAAqB,EAAE,IAAK;IAC5BvD,EAAE,EAAEC,UAAW;IACfuD,OAAO,EAAEnD,SAAU;IACnBoD,QAAQ,EAAE1D,kBAAmB;IAC7Ba,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBE,aAAa,EAAEA,aAAc;IAC7BE,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBwC,QAAQ,EAAEnD,UAAW;IACrByB,WAAW,EAAEA,WAAY;IACzB2B,oBAAoB,EAAEvC;EAAwB,CAC/C,CAAC;AAEN,CAAC;AAGD,MAAMwC,oBAAoB,GAAG3E,IAAI,CAACU,YAAY,CAAwB;AAEtEiE,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIjE,YAAY"}
|
|
1
|
+
{"version":3,"file":"Autocomplete.js","names":["memo","useCallback","useMemo","useRef","Field","ComponentControlledState","useInputValues","getControlState","jsx","_jsx","Autocomplete","_ref","defaultValue","errorMessage","hasMultipleChoices","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isFullWidth","isLoading","isOptional","isReadOnly","hint","label","name","nameOverride","onBlur","onChange","onChangeProp","onInputChange","onInputChangeProp","onFocus","options","value","getIsOptionEqualToValue","testId","controlledStateRef","controlledValue","uncontrolledValue","defaultValueProp","undefined","valueProps","controlState","current","inputValueProp","CONTROLLED","renderInput","_ref2","InputLabelProps","InputProps","params","fieldType","hasVisibleLabel","htmlFor","renderFieldComponent","_ref3","ariaDescribedBy","errorMessageElementId","labelElementId","_InputBase","inputProps","required","event","reason","details","_Autocomplete","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","fullWidth","loading","multiple","readOnly","isOptionEqualToValue","MemoizedAutocomplete","displayName"],"sources":["../src/Autocomplete.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n Autocomplete as MuiAutocomplete,\n AutocompleteProps as MuiAutocompleteProps,\n InputBase,\n UseAutocompleteProps,\n AutocompleteValue,\n} from \"@mui/material\";\nimport { memo, useCallback, useMemo, useRef } from \"react\";\n\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils\";\n\nexport type AutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"defaultValue\"];\n /**\n * Enables multiple choice selection\n */\n hasMultipleChoices?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"multiple\"];\n /**\n * The value for the input\n */\n inputValue?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"inputValue\"];\n /**\n * Allows the input of custom values\n */\n isCustomValueAllowed?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"freeSolo\"];\n /**\n * Disables the Autocomplete input\n */\n isDisabled?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"disabled\"];\n /**\n * Displays a loading indicator\n */\n isLoading?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"loading\"];\n /**\n * Makes the Autocomplete input read-only\n */\n isReadOnly?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"readOnly\"];\n /**\n * The label text for the autocomplete input\n */\n label: string;\n /**\n * Callback fired when the autocomplete loses focus.\n */\n onBlur?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onBlur\"];\n /**\n * Callback fired when a selection is made.\n */\n onChange?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"];\n /**\n * Callback fired when the textbox receives typed characters.\n */\n onInputChange?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"];\n /**\n * Callback fired when the autocomplete gains focus.\n */\n onFocus?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onFocus\"];\n /**\n * The options for the Autocomplete input\n */\n options: ReadonlyArray<OptionType>;\n /**\n * The value of the Autocomplete input\n */\n value?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n\n /**\n * Used to determine if the option represents the given value. Uses strict equality by default if none provided.\n * Both arguments need to be handled, an option can only match with one value.\n * option: the option to test\n * value: the value to test against\n *\n * You will need to implement this function if your `option` items are objects.\n */\n getIsOptionEqualToValue?: (option: OptionType, value: OptionType) => boolean;\n} & Pick<\n FieldComponentProps,\n \"errorMessage\" | \"hint\" | \"id\" | \"isOptional\" | \"name\" | \"isFullWidth\"\n> &\n SeleniumProps;\n\nconst Autocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined\n>({\n defaultValue,\n errorMessage,\n hasMultipleChoices,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isFullWidth = false,\n isLoading,\n isOptional = false,\n isReadOnly,\n hint,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n onFocus,\n options,\n value,\n getIsOptionEqualToValue,\n testId,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const controlledStateRef = useRef(\n getControlState({ controlledValue: value, uncontrolledValue: defaultValue })\n );\n const defaultValueProp = useMemo<\n | AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >\n | undefined\n >(() => {\n if (hasMultipleChoices) {\n if (value === undefined) {\n return defaultValue;\n }\n return [] as AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >;\n }\n return value === undefined ? defaultValue : undefined;\n }, [defaultValue, hasMultipleChoices, value]);\n\n const valueProps = useInputValues({\n defaultValue: defaultValueProp,\n value: value,\n controlState: controlledStateRef.current,\n });\n\n const inputValueProp = useMemo(() => {\n if (controlledStateRef.current === ComponentControlledState.CONTROLLED) {\n return { inputValue };\n }\n return undefined;\n }, [inputValue]);\n\n const renderInput = useCallback(\n ({ InputLabelProps, InputProps, ...params }) => (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n id={InputLabelProps.htmlFor}\n hint={hint}\n label={label}\n isOptional={isOptional}\n renderFieldComponent={({\n ariaDescribedBy,\n id,\n errorMessageElementId,\n labelElementId,\n }) => (\n <InputBase\n {...params}\n {...InputProps}\n inputProps={{\n ...params.inputProps,\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n }}\n aria-describedby={ariaDescribedBy}\n id={id}\n name={nameOverride ?? id}\n required={!isOptional}\n />\n )}\n />\n ),\n [errorMessage, hint, isOptional, label, nameOverride]\n );\n const onChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"]\n >\n >(\n (event, value, reason, details) => {\n onChangeProp?.(event, value, reason, details);\n },\n [onChangeProp]\n );\n\n const onInputChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"]\n >\n >(\n (event, value, reason) => {\n onInputChangeProp?.(event, value, reason);\n },\n [onInputChangeProp]\n );\n\n return (\n <MuiAutocomplete\n {...valueProps}\n {...inputValueProp}\n // AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div\n aria-disabled={isDisabled}\n data-se={testId}\n disableCloseOnSelect={hasMultipleChoices}\n disabled={isDisabled}\n freeSolo={isCustomValueAllowed}\n filterSelectedOptions={true}\n id={idOverride}\n fullWidth={isFullWidth}\n loading={isLoading}\n multiple={hasMultipleChoices}\n onBlur={onBlur}\n onChange={onChange}\n onInputChange={onInputChange}\n onFocus={onFocus}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n isOptionEqualToValue={getIsOptionEqualToValue}\n />\n );\n};\n\n// Need the `typeof Autocomplete` because generics don't get passed through\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n// @ts-expect-error displayName is expected to not be on `typeof Autocomplete`\nMemoizedAutocomplete.displayName = \"Autocomplete\";\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA,SAASA,IAAI,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAA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ACf,CAAC;EAED,MAAMC,aAAa,GAAG9B,WAAW,CAU/B,CAAC+D,KAAK,EAAE7B,KAAK,EAAE8B,MAAM,KAAK;IACxBjC,iBAAiB,GAAGgC,KAAK,EAAE7B,KAAK,EAAE8B,MAAM,CAAC;EAC3C,CAAC,EACD,CAACjC,iBAAiB,CACpB,CAAC;EAED,OACEvB,IAAA,CAAA0D,aAAA;IAAA,GACMxB,UAAU;IAAA,GACVG,cAAc;IAElB,iBAAe3B,UAAW;IAC1B,WAASkB,MAAO;IAChB+B,oBAAoB,EAAEtD,kBAAmB;IACzCuD,QAAQ,EAAElD,UAAW;IACrBmD,QAAQ,EAAEpD,oBAAqB;IAC/BqD,qBAAqB,EAAE,IAAK;IAC5BxD,EAAE,EAAEC,UAAW;IACfwD,SAAS,EAAEpD,WAAY;IACvBqD,OAAO,EAAEpD,SAAU;IACnBqD,QAAQ,EAAE5D,kBAAmB;IAC7Bc,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBE,aAAa,EAAEA,aAAc;IAC7BE,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjByC,QAAQ,EAAEpD,UAAW;IACrByB,WAAW,EAAEA,WAAY;IACzB4B,oBAAoB,EAAExC;EAAwB,CAC/C,CAAC;AAEN,CAAC;AAGD,MAAMyC,oBAAoB,GAAG7E,IAAI,CAACU,YAAY,CAAwB;AAEtEmE,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAInE,YAAY"}
|
package/dist/Field.js
CHANGED
|
@@ -31,6 +31,7 @@ const Field = _ref => {
|
|
|
31
31
|
hint,
|
|
32
32
|
id: idOverride,
|
|
33
33
|
isDisabled: isDisabledProp = false,
|
|
34
|
+
isFullWidth = false,
|
|
34
35
|
isRadioGroup = false,
|
|
35
36
|
isOptional = false,
|
|
36
37
|
label,
|
|
@@ -53,6 +54,7 @@ const Field = _ref => {
|
|
|
53
54
|
disabled: isDisabled,
|
|
54
55
|
error: Boolean(errorMessage),
|
|
55
56
|
role: isRadioGroup ? "radiogroup" : undefined,
|
|
57
|
+
fullWidth: isFullWidth,
|
|
56
58
|
children: [fieldType === "group" ? _jsxs(_FormLabel, {
|
|
57
59
|
component: "legend",
|
|
58
60
|
children: [label, " ", isOptional && label && _jsxs(Typography, {
|
package/dist/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","names":["memo","useMemo","FieldError","FieldHint","FieldLabel","Typography","useFieldset","useTranslation","useUniqueId","jsxs","_jsxs","jsx","_jsx","fieldTypeValues","Field","_ref","errorMessage","fieldType","hasVisibleLabel","hint","id","idOverride","isDisabled","isDisabledProp","isRadioGroup","isOptional","label","renderFieldComponent","t","hintId","undefined","errorMessageElementId","labelElementId","ariaDescribedBy","join","trim","isFieldsetDisabled","_FormControl","component","disabled","error","Boolean","role","children","_FormLabel","color","inputId","text","MemoizedField","displayName"],"sources":["../src/Field.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, ReactElement, useMemo } from \"react\";\n\nimport {\n FormControl as MuiFormControl,\n FormLabel as MuiFormLabel,\n} from \"@mui/material\";\nimport { FieldError } from \"./FieldError\";\nimport { FieldHint } from \"./FieldHint\";\nimport { FieldLabel } from \"./FieldLabel\";\nimport { Typography } from \"./Typography\";\nimport { useFieldset } from \"./FieldsetContext\";\nimport { useTranslation } from \"react-i18next\";\nimport { useUniqueId } from \"./useUniqueId\";\n\nexport const fieldTypeValues = [\"single\", \"group\"] as const;\n\nexport type FieldProps = {\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessage?: string;\n /**\n * The field type determines how ARIA components are setup. It's important to use this to denote if you expect only one component (like a text field) or multiple (like a radio group).\n */\n fieldType: (typeof fieldTypeValues)[number];\n /**\n * If `true`, the Field label will be shown\n */\n hasVisibleLabel: boolean;\n /**\n * The helper text content.\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * Important for narrowing down the `fieldset` role to \"radiogroup\".\n */\n isRadioGroup?: boolean;\n /**\n * Important for determining if children inherit error state\n */\n isCheckboxGroup?: boolean;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * Render-props function that sends back ARIA props to your field component.\n */\n renderFieldComponent: ({\n ariaDescribedBy,\n dataSe,\n errorMessageElementId,\n id,\n labelElementId,\n }: {\n ariaDescribedBy?: string;\n dataSe?: string;\n errorMessageElementId?: string;\n id: string;\n labelElementId: string;\n }) => ReactElement;\n};\n\nconst Field = ({\n errorMessage,\n fieldType,\n hasVisibleLabel,\n hint,\n id: idOverride,\n isDisabled: isDisabledProp = false,\n isRadioGroup = false,\n isOptional = false,\n label,\n renderFieldComponent,\n}: FieldProps) => {\n const { t } = useTranslation();\n\n const id = useUniqueId(idOverride);\n const hintId = hint ? `${id}-hint` : undefined;\n const errorMessageElementId = errorMessage ? `${id}-error` : undefined;\n const labelElementId = `${id}-label`;\n\n const ariaDescribedBy = useMemo(\n () => [hintId, errorMessageElementId].join(\" \").trim() || undefined,\n [errorMessageElementId, hintId]\n );\n\n const { isDisabled: isFieldsetDisabled } = useFieldset();\n\n const isDisabled = useMemo(\n () => isDisabledProp || isFieldsetDisabled,\n [isDisabledProp, isFieldsetDisabled]\n );\n\n return (\n <MuiFormControl\n component={fieldType === \"group\" ? \"fieldset\" : \"div\"}\n disabled={isDisabled}\n error={Boolean(errorMessage)}\n role={isRadioGroup ? \"radiogroup\" : undefined}\n >\n {fieldType === \"group\" ? (\n <MuiFormLabel component=\"legend\">\n {label}{\" \"}\n {isOptional && label && (\n <Typography component=\"span\" color=\"textSecondary\">\n ({t(\"fieldlabel.optional.text\")})\n </Typography>\n )}\n </MuiFormLabel>\n ) : (\n <FieldLabel\n hasVisibleLabel={hasVisibleLabel}\n id={labelElementId}\n inputId={id}\n isOptional={isOptional}\n text={label}\n />\n )}\n\n {hint && <FieldHint id={hintId} text={hint} />}\n\n {renderFieldComponent({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n })}\n\n {errorMessage && (\n <FieldError id={errorMessageElementId} text={errorMessage} />\n )}\n </MuiFormControl>\n );\n};\n\nconst MemoizedField = memo(Field);\nMemoizedField.displayName = \"Field\";\n\nexport { MemoizedField as Field };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAgBC,OAAO,QAAQ,OAAO;AAAC,SAM3CC,UAAU;AAAA,SACVC,SAAS;AAAA,SACTC,UAAU;AAAA,SACVC,UAAU;AAAA,SACVC,WAAW;AACpB,SAASC,cAAc,QAAQ,eAAe;AAAC,SACtCC,WAAW;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpB,OAAO,MAAMC,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"Field.js","names":["memo","useMemo","FieldError","FieldHint","FieldLabel","Typography","useFieldset","useTranslation","useUniqueId","jsxs","_jsxs","jsx","_jsx","fieldTypeValues","Field","_ref","errorMessage","fieldType","hasVisibleLabel","hint","id","idOverride","isDisabled","isDisabledProp","isFullWidth","isRadioGroup","isOptional","label","renderFieldComponent","t","hintId","undefined","errorMessageElementId","labelElementId","ariaDescribedBy","join","trim","isFieldsetDisabled","_FormControl","component","disabled","error","Boolean","role","fullWidth","children","_FormLabel","color","inputId","text","MemoizedField","displayName"],"sources":["../src/Field.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, ReactElement, useMemo } from \"react\";\n\nimport {\n FormControl as MuiFormControl,\n FormLabel as MuiFormLabel,\n} from \"@mui/material\";\nimport { FieldError } from \"./FieldError\";\nimport { FieldHint } from \"./FieldHint\";\nimport { FieldLabel } from \"./FieldLabel\";\nimport { Typography } from \"./Typography\";\nimport { useFieldset } from \"./FieldsetContext\";\nimport { useTranslation } from \"react-i18next\";\nimport { useUniqueId } from \"./useUniqueId\";\n\nexport const fieldTypeValues = [\"single\", \"group\"] as const;\n\nexport type FieldProps = {\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessage?: string;\n /**\n * The field type determines how ARIA components are setup. It's important to use this to denote if you expect only one component (like a text field) or multiple (like a radio group).\n */\n fieldType: (typeof fieldTypeValues)[number];\n /**\n * If `true`, the Field label will be shown\n */\n hasVisibleLabel: boolean;\n /**\n * The helper text content.\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * Important for narrowing down the `fieldset` role to \"radiogroup\".\n */\n isRadioGroup?: boolean;\n /**\n * Important for determining if children inherit error state\n */\n isCheckboxGroup?: boolean;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * If `true`, the component can stretch to fill the width of the container.\n */\n isFullWidth?: boolean;\n /**\n * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * Render-props function that sends back ARIA props to your field component.\n */\n renderFieldComponent: ({\n ariaDescribedBy,\n dataSe,\n errorMessageElementId,\n id,\n labelElementId,\n }: {\n ariaDescribedBy?: string;\n dataSe?: string;\n errorMessageElementId?: string;\n id: string;\n labelElementId: string;\n }) => ReactElement;\n};\n\nconst Field = ({\n errorMessage,\n fieldType,\n hasVisibleLabel,\n hint,\n id: idOverride,\n isDisabled: isDisabledProp = false,\n isFullWidth = false,\n isRadioGroup = false,\n isOptional = false,\n label,\n renderFieldComponent,\n}: FieldProps) => {\n const { t } = useTranslation();\n\n const id = useUniqueId(idOverride);\n const hintId = hint ? `${id}-hint` : undefined;\n const errorMessageElementId = errorMessage ? `${id}-error` : undefined;\n const labelElementId = `${id}-label`;\n\n const ariaDescribedBy = useMemo(\n () => [hintId, errorMessageElementId].join(\" \").trim() || undefined,\n [errorMessageElementId, hintId]\n );\n\n const { isDisabled: isFieldsetDisabled } = useFieldset();\n\n const isDisabled = useMemo(\n () => isDisabledProp || isFieldsetDisabled,\n [isDisabledProp, isFieldsetDisabled]\n );\n\n return (\n <MuiFormControl\n component={fieldType === \"group\" ? \"fieldset\" : \"div\"}\n disabled={isDisabled}\n error={Boolean(errorMessage)}\n role={isRadioGroup ? \"radiogroup\" : undefined}\n fullWidth={isFullWidth}\n >\n {fieldType === \"group\" ? (\n <MuiFormLabel component=\"legend\">\n {label}{\" \"}\n {isOptional && label && (\n <Typography component=\"span\" color=\"textSecondary\">\n ({t(\"fieldlabel.optional.text\")})\n </Typography>\n )}\n </MuiFormLabel>\n ) : (\n <FieldLabel\n hasVisibleLabel={hasVisibleLabel}\n id={labelElementId}\n inputId={id}\n isOptional={isOptional}\n text={label}\n />\n )}\n\n {hint && <FieldHint id={hintId} text={hint} />}\n\n {renderFieldComponent({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n })}\n\n {errorMessage && (\n <FieldError id={errorMessageElementId} text={errorMessage} />\n )}\n </MuiFormControl>\n );\n};\n\nconst MemoizedField = memo(Field);\nMemoizedField.displayName = \"Field\";\n\nexport { MemoizedField as Field };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAgBC,OAAO,QAAQ,OAAO;AAAC,SAM3CC,UAAU;AAAA,SACVC,SAAS;AAAA,SACTC,UAAU;AAAA,SACVC,UAAU;AAAA,SACVC,WAAW;AACpB,SAASC,cAAc,QAAQ,eAAe;AAAC,SACtCC,WAAW;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpB,OAAO,MAAMC,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU;AAqE3D,MAAMC,KAAK,GAAGC,IAAA,IAYI;EAAA,IAZH;IACbC,YAAY;IACZC,SAAS;IACTC,eAAe;IACfC,IAAI;IACJC,EAAE,EAAEC,UAAU;IACdC,UAAU,EAAEC,cAAc,GAAG,KAAK;IAClCC,WAAW,GAAG,KAAK;IACnBC,YAAY,GAAG,KAAK;IACpBC,UAAU,GAAG,KAAK;IAClBC,KAAK;IACLC;EACU,CAAC,GAAAb,IAAA;EACX,MAAM;IAAEc;EAAE,CAAC,GAAGtB,cAAc,CAAC,CAAC;EAE9B,MAAMa,EAAE,GAAGZ,WAAW,CAACa,UAAU,CAAC;EAClC,MAAMS,MAAM,GAAGX,IAAI,GAAI,GAAEC,EAAG,OAAM,GAAGW,SAAS;EAC9C,MAAMC,qBAAqB,GAAGhB,YAAY,GAAI,GAAEI,EAAG,QAAO,GAAGW,SAAS;EACtE,MAAME,cAAc,GAAI,GAAEb,EAAG,QAAO;EAEpC,MAAMc,eAAe,GAAGjC,OAAO,CAC7B,MAAM,CAAC6B,MAAM,EAAEE,qBAAqB,CAAC,CAACG,IAAI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ACFa;IACF,CAAC,CAAC,EAEDjB,YAAY,IACXJ,IAAA,CAACV,UAAU;MAACkB,EAAE,EAAEY,qBAAsB;MAACiB,IAAI,EAAEjC;IAAa,CAAE,CAC7D;EAAA,CACa,CAAC;AAErB,CAAC;AAED,MAAMkC,aAAa,GAAGlD,IAAI,CAACc,KAAK,CAAC;AACjCoC,aAAa,CAACC,WAAW,GAAG,OAAO;AAEnC,SAASD,aAAa,IAAIpC,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldComponentProps.js","names":[],"sources":["../src/FieldComponentProps.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport type FieldComponentProps = {\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessage?: string;\n /**\n * The helper text content.\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\n /**\n * It prevents the user from changing the value of the field\n */\n isReadOnly?: boolean;\n /**\n * The name of the `input` element. Defaults to the `id` if not set.\n */\n name?: string;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"FieldComponentProps.js","names":[],"sources":["../src/FieldComponentProps.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport type FieldComponentProps = {\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessage?: string;\n /**\n * The helper text content.\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * If `true`, the component can stretch to fill the width of the container.\n */\n isFullWidth?: boolean;\n /**\n * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\n /**\n * It prevents the user from changing the value of the field\n */\n isReadOnly?: boolean;\n /**\n * The name of the `input` element. Defaults to the `id` if not set.\n */\n name?: string;\n};\n"],"mappings":""}
|
package/dist/NativeSelect.js
CHANGED
|
@@ -23,6 +23,7 @@ const NativeSelect = forwardRef((_ref, ref) => {
|
|
|
23
23
|
hint,
|
|
24
24
|
id: idOverride,
|
|
25
25
|
isDisabled = false,
|
|
26
|
+
isFullWidth = false,
|
|
26
27
|
isMultiSelect,
|
|
27
28
|
isOptional = false,
|
|
28
29
|
label,
|
|
@@ -78,6 +79,7 @@ const NativeSelect = forwardRef((_ref, ref) => {
|
|
|
78
79
|
hint: hint,
|
|
79
80
|
id: idOverride,
|
|
80
81
|
isDisabled: isDisabled,
|
|
82
|
+
isFullWidth: isFullWidth,
|
|
81
83
|
isOptional: isOptional,
|
|
82
84
|
label: label,
|
|
83
85
|
renderFieldComponent: renderFieldComponent
|
package/dist/NativeSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeSelect.js","names":["React","forwardRef","memo","useCallback","useMemo","useRef","Field","getControlState","useInputValues","jsx","_jsx","NativeSelect","_ref","ref","defaultValue","errorMessage","hasMultipleChoices","hasMultipleChoicesProp","hint","id","idOverride","isDisabled","isMultiSelect","isOptional","label","onBlur","onChange","onChangeProp","onFocus","testId","value","children","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","event","child","undefined","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_Select","inputProps","name","multiple","native","fieldType","hasVisibleLabel","MemoizedNativeSelect","displayName"],"sources":["../src/NativeSelect.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, {\n ReactElement,\n forwardRef,\n memo,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n Select as MuiSelect,\n SelectProps as MuiSelectProps,\n} from \"@mui/material\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { getControlState, useInputValues } from \"./inputUtils\";\nimport { ForwardRefWithType } from \"./@types/react-augment\";\n\nexport type NativeSelectOption = {\n text: string;\n value?: string;\n type?: \"heading\" | \"option\";\n};\n\nexport type NativeSelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type NativeSelectProps<\n Value extends NativeSelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n> = {\n /**\n * The options or optgroup elements within the NativeSelect\n */\n children?: ReactElement<\"option\"> | ReactElement<\"optgroup\">;\n /**\n * The default value of the NativeSelect. Use when component is uncontrolled\n */\n defaultValue?: Value;\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * @deprecated Use `hasMultipleChoices` instead\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the NativeSelect\n */\n label: string;\n /**\n * Callback fired when the NativeSelect loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the NativeSelect changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the NativeSelect gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n options: Value;\n /**\n * The value or values selected in the NativeSelect. Use when component is controlled\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n \"errorMessage\" | \"hint\" | \"id\" | \"isDisabled\" | \"isOptional\"\n> &\n SeleniumProps;\n\nconst NativeSelect: ForwardRefWithType = forwardRef(\n <\n Value extends NativeSelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n >(\n {\n defaultValue,\n errorMessage,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n id: idOverride,\n isDisabled = false,\n isMultiSelect,\n isOptional = false,\n label,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n testId,\n value,\n children,\n }: NativeSelectProps<Value, HasMultipleChoices>,\n ref?: React.Ref<ReactElement>\n ) => {\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<\n NonNullable<MuiSelectProps<Value>[\"onChange\"]>\n >(\n (event, child) => {\n onChangeProp?.(event, child);\n },\n [onChangeProp]\n );\n\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect]\n );\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, labelElementId }) => (\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n children={children}\n data-se={testId}\n id={idOverride}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n }}\n name={idOverride}\n multiple={hasMultipleChoices}\n native={true}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n ref={ref}\n />\n ),\n [\n children,\n idOverride,\n inputValues,\n hasMultipleChoices,\n onBlur,\n onChange,\n onFocus,\n ref,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedNativeSelect = memo(NativeSelect);\nMemoizedNativeSelect.displayName = \"NativeSelect\";\n\nexport { MemoizedNativeSelect as NativeSelect };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAEVC,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,OAAO,EACPC,MAAM,QACD,OAAO;AAAC,SAKNC,KAAK;AAAA,SAGLC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA4DxC,MAAMC,YAAgC,GAAGV,UAAU,CACjD,CAAAW,IAAA,
|
|
1
|
+
{"version":3,"file":"NativeSelect.js","names":["React","forwardRef","memo","useCallback","useMemo","useRef","Field","getControlState","useInputValues","jsx","_jsx","NativeSelect","_ref","ref","defaultValue","errorMessage","hasMultipleChoices","hasMultipleChoicesProp","hint","id","idOverride","isDisabled","isFullWidth","isMultiSelect","isOptional","label","onBlur","onChange","onChangeProp","onFocus","testId","value","children","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","event","child","undefined","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_Select","inputProps","name","multiple","native","fieldType","hasVisibleLabel","MemoizedNativeSelect","displayName"],"sources":["../src/NativeSelect.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, {\n ReactElement,\n forwardRef,\n memo,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n Select as MuiSelect,\n SelectProps as MuiSelectProps,\n} from \"@mui/material\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { getControlState, useInputValues } from \"./inputUtils\";\nimport { ForwardRefWithType } from \"./@types/react-augment\";\n\nexport type NativeSelectOption = {\n text: string;\n value?: string;\n type?: \"heading\" | \"option\";\n};\n\nexport type NativeSelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type NativeSelectProps<\n Value extends NativeSelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n> = {\n /**\n * The options or optgroup elements within the NativeSelect\n */\n children?: ReactElement<\"option\"> | ReactElement<\"optgroup\">;\n /**\n * The default value of the NativeSelect. Use when component is uncontrolled\n */\n defaultValue?: Value;\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * @deprecated Use `hasMultipleChoices` instead\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the NativeSelect\n */\n label: string;\n /**\n * Callback fired when the NativeSelect loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the NativeSelect changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the NativeSelect gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n options: Value;\n /**\n * The value or values selected in the NativeSelect. Use when component is controlled\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n \"errorMessage\" | \"hint\" | \"id\" | \"isDisabled\" | \"isOptional\" | \"isFullWidth\"\n> &\n SeleniumProps;\n\nconst NativeSelect: ForwardRefWithType = forwardRef(\n <\n Value extends NativeSelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n >(\n {\n defaultValue,\n errorMessage,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n id: idOverride,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n label,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n testId,\n value,\n children,\n }: NativeSelectProps<Value, HasMultipleChoices>,\n ref?: React.Ref<ReactElement>\n ) => {\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<\n NonNullable<MuiSelectProps<Value>[\"onChange\"]>\n >(\n (event, child) => {\n onChangeProp?.(event, child);\n },\n [onChangeProp]\n );\n\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect]\n );\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, labelElementId }) => (\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n children={children}\n data-se={testId}\n id={idOverride}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n }}\n name={idOverride}\n multiple={hasMultipleChoices}\n native={true}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n ref={ref}\n />\n ),\n [\n children,\n idOverride,\n inputValues,\n hasMultipleChoices,\n onBlur,\n onChange,\n onFocus,\n ref,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedNativeSelect = memo(NativeSelect);\nMemoizedNativeSelect.displayName = \"NativeSelect\";\n\nexport { MemoizedNativeSelect as NativeSelect };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAEVC,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,OAAO,EACPC,MAAM,QACD,OAAO;AAAC,SAKNC,KAAK;AAAA,SAGLC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA4DxC,MAAMC,YAAgC,GAAGV,UAAU,CACjD,CAAAW,IAAA,EAsBEC,GAA6B,KAC1B;EAAA,IAnBH;IACEC,YAAY;IACZC,YAAY;IACZC,kBAAkB,EAAEC,sBAAsB;IAC1CC,IAAI;IACJC,EAAE,EAAEC,UAAU;IACdC,UAAU,GAAG,KAAK;IAClBC,WAAW,GAAG,KAAK;IACnBC,aAAa;IACbC,UAAU,GAAG,KAAK;IAClBC,KAAK;IACLC,MAAM;IACNC,QAAQ,EAAEC,YAAY;IACtBC,OAAO;IACPC,MAAM;IACNC,KAAK;IACLC;EAC4C,CAAC,GAAApB,IAAA;EAG/C,MAAMqB,kBAAkB,GAAG5B,MAAM,CAC/BE,eAAe,CAAC;IACd2B,eAAe,EAAEH,KAAK;IACtBI,iBAAiB,EAAErB;EACrB,CAAC,CACH,CAAC;EACD,MAAMsB,WAAW,GAAG5B,cAAc,CAAC;IACjCM,YAAY;IACZiB,KAAK;IACLM,YAAY,EAAEJ,kBAAkB,CAACK;EACnC,CAAC,CAAC;EAEF,MAAMX,QAAQ,GAAGxB,WAAW,CAG1B,CAACoC,KA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AAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMY,oBAAoB,GAAGpD,IAAI,CAACS,YAAY,CAAC;AAC/C2C,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAI3C,YAAY"}
|
package/dist/PasswordField.js
CHANGED
|
@@ -27,6 +27,7 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
27
27
|
hint,
|
|
28
28
|
id: idOverride,
|
|
29
29
|
isDisabled = false,
|
|
30
|
+
isFullWidth = false,
|
|
30
31
|
isOptional = false,
|
|
31
32
|
hasShowPassword = true,
|
|
32
33
|
isReadOnly,
|
|
@@ -103,6 +104,7 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
103
104
|
hint: hint,
|
|
104
105
|
id: idOverride,
|
|
105
106
|
isDisabled: isDisabled,
|
|
107
|
+
isFullWidth: isFullWidth,
|
|
106
108
|
isOptional: isOptional,
|
|
107
109
|
label: label,
|
|
108
110
|
renderFieldComponent: renderFieldComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useRef","useState","ShowIcon","HideIcon","Field","useTranslation","getControlState","useInputValues","jsx","_jsx","PasswordField","_ref","ref","autoCompleteType","defaultValue","errorMessage","hasInitialFocus","hint","id","idOverride","isDisabled","isOptional","hasShowPassword","isReadOnly","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","placeholder","testId","value","t","inputType","setInputType","togglePasswordVisibility","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","event","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","onClick","inputProps","role","readOnly","required","type","fieldType","hasVisibleLabel","MemoizedPasswordField","displayName"],"sources":["../src/PasswordField.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n memo,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { ShowIcon, HideIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { useTranslation } from \"react-i18next\";\nimport { getControlState, useInputValues } from \"./inputUtils\";\n\nexport type PasswordFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: \"current-password\" | \"new-password\";\n /**\n * initial value for input. Use when component in uncontrolled.\n */\n defaultValue?: string;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * If `true`, the show/hide icon is not shown to the user\n */\n hasShowPassword?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * The value of the `input` element. Use when component is controlled.\n */\n value?: string;\n} & FieldComponentProps &\n SeleniumProps;\n\nconst PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(\n (\n {\n autoCompleteType,\n defaultValue,\n errorMessage,\n hasInitialFocus,\n hint,\n id: idOverride,\n isDisabled = false,\n isOptional = false,\n hasShowPassword = true,\n isReadOnly,\n label,\n name: nameOverride,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n placeholder,\n testId,\n value,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [inputType, setInputType] = useState(\"password\");\n\n const togglePasswordVisibility = useCallback(() => {\n setInputType((inputType) =>\n inputType === \"password\" ? \"text\" : \"password\"\n );\n }, []);\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<\n ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>\n >(\n (event) => {\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (\n <InputBase\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n autoComplete={inputType === \"password\" ? autoCompleteType : \"off\"}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n hasShowPassword && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label={\n inputType === \"password\"\n ? t(\"passwordfield.icon.label.show\")\n : t(\"passwordfield.icon.label.hide\")\n }\n onClick={togglePasswordVisibility}\n >\n {inputType === \"password\" ? <ShowIcon /> : <HideIcon />}\n </IconButton>\n </InputAdornment>\n )\n }\n id={id}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n // role: \"textbox\" Added because password inputs don't have an implicit role assigned. This causes problems with element selection.\n role: \"textbox\",\n }}\n name={nameOverride ?? id}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n placeholder={placeholder}\n readOnly={isReadOnly}\n ref={ref}\n required={!isOptional}\n type={inputType}\n />\n ),\n [\n autoCompleteType,\n hasInitialFocus,\n inputValues,\n t,\n togglePasswordVisibility,\n inputType,\n nameOverride,\n onChange,\n onFocus,\n onBlur,\n placeholder,\n isOptional,\n isReadOnly,\n hasShowPassword,\n ref,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedPasswordField = memo(PasswordField);\nMemoizedPasswordField.displayName = \"PasswordField\";\n\nexport { MemoizedPasswordField as PasswordField };\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAGEA,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH,OAAO;AAAC,SAENC,QAAQ,EAAEC,QAAQ;AAAA,SAClBC,KAAK;AAGd,SAASC,cAAc,QAAQ,eAAe;AAAC,SACtCC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAgDxC,MAAMC,aAAa,GAAGb,UAAU,CAC9B,CAAAc,IAAA,EAqBEC,GAAG,KACA;EAAA,IArBH;IACEC,gBAAgB;IAChBC,YAAY;IACZC,YAAY;IACZC,eAAe;IACfC,IAAI;IACJC,EAAE,EAAEC,UAAU;IACdC,UAAU,GAAG,KAAK;IAClBC,UAAU,GAAG,KAAK;IAClBC,eAAe,GAAG,IAAI;IACtBC,UAAU;IACVC,KAAK;IACLC,IAAI,EAAEC,YAAY;IAClBC,QAAQ,EAAEC,YAAY;IACtBC,OAAO;IACPC,MAAM;IACNC,WAAW;IACXC,MAAM;IACNC;EACF,CAAC,GAAAtB,IAAA;EAGD,MAAM;IAAEuB;EAAE,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"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useRef","useState","ShowIcon","HideIcon","Field","useTranslation","getControlState","useInputValues","jsx","_jsx","PasswordField","_ref","ref","autoCompleteType","defaultValue","errorMessage","hasInitialFocus","hint","id","idOverride","isDisabled","isFullWidth","isOptional","hasShowPassword","isReadOnly","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","placeholder","testId","value","t","inputType","setInputType","togglePasswordVisibility","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","event","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","onClick","inputProps","role","readOnly","required","type","fieldType","hasVisibleLabel","MemoizedPasswordField","displayName"],"sources":["../src/PasswordField.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n memo,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { ShowIcon, HideIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { useTranslation } from \"react-i18next\";\nimport { getControlState, useInputValues } from \"./inputUtils\";\n\nexport type PasswordFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: \"current-password\" | \"new-password\";\n /**\n * initial value for input. Use when component in uncontrolled.\n */\n defaultValue?: string;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * If `true`, the show/hide icon is not shown to the user\n */\n hasShowPassword?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * The value of the `input` element. Use when component is controlled.\n */\n value?: string;\n} & FieldComponentProps &\n SeleniumProps;\n\nconst PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(\n (\n {\n autoCompleteType,\n defaultValue,\n errorMessage,\n hasInitialFocus,\n hint,\n id: idOverride,\n isDisabled = false,\n isFullWidth = false,\n isOptional = false,\n hasShowPassword = true,\n isReadOnly,\n label,\n name: nameOverride,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n placeholder,\n testId,\n value,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [inputType, setInputType] = useState(\"password\");\n\n const togglePasswordVisibility = useCallback(() => {\n setInputType((inputType) =>\n inputType === \"password\" ? \"text\" : \"password\"\n );\n }, []);\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<\n ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>\n >(\n (event) => {\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (\n <InputBase\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n autoComplete={inputType === \"password\" ? autoCompleteType : \"off\"}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n hasShowPassword && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label={\n inputType === \"password\"\n ? t(\"passwordfield.icon.label.show\")\n : t(\"passwordfield.icon.label.hide\")\n }\n onClick={togglePasswordVisibility}\n >\n {inputType === \"password\" ? <ShowIcon /> : <HideIcon />}\n </IconButton>\n </InputAdornment>\n )\n }\n id={id}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n // role: \"textbox\" Added because password inputs don't have an implicit role assigned. This causes problems with element selection.\n role: \"textbox\",\n }}\n name={nameOverride ?? id}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n placeholder={placeholder}\n readOnly={isReadOnly}\n ref={ref}\n required={!isOptional}\n type={inputType}\n />\n ),\n [\n autoCompleteType,\n hasInitialFocus,\n inputValues,\n t,\n togglePasswordVisibility,\n inputType,\n nameOverride,\n onChange,\n onFocus,\n onBlur,\n placeholder,\n isOptional,\n isReadOnly,\n hasShowPassword,\n ref,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedPasswordField = memo(PasswordField);\nMemoizedPasswordField.displayName = \"PasswordField\";\n\nexport { MemoizedPasswordField as PasswordField };\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAGEA,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH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0B,WAAW,EACXP,CAAC,EACDG,wBAAwB,EACxBF,SAAS,EACTT,YAAY,EACZC,QAAQ,EACRE,OAAO,EACPC,MAAM,EACNC,WAAW,EACXV,UAAU,EACVE,UAAU,EACVD,eAAe,EACfX,GAAG,EACHqB,MAAM,CAEV,CAAC;EAED,OACExB,IAAA,CAACL,KAAK;IACJW,YAAY,EAAEA,YAAa;IAC3BkD,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACfjD,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBC,UAAU,EAAEA,UAAW;IACvBG,KAAK,EAAEA,KAAM;IACbqB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMqB,qBAAqB,GAAGrE,IAAI,CAACY,aAAa,CAAC;AACjDyD,qBAAqB,CAACC,WAAW,GAAG,eAAe;AAEnD,SAASD,qBAAqB,IAAIzD,aAAa"}
|
package/dist/SearchField.js
CHANGED
|
@@ -24,6 +24,7 @@ const SearchField = forwardRef((_ref, ref) => {
|
|
|
24
24
|
hasInitialFocus,
|
|
25
25
|
id: idOverride,
|
|
26
26
|
isDisabled = false,
|
|
27
|
+
isFullWidth = false,
|
|
27
28
|
label,
|
|
28
29
|
name: nameOverride,
|
|
29
30
|
onChange: onChangeProp,
|
|
@@ -89,6 +90,7 @@ const SearchField = forwardRef((_ref, ref) => {
|
|
|
89
90
|
hasVisibleLabel: false,
|
|
90
91
|
id: idOverride,
|
|
91
92
|
isDisabled: isDisabled,
|
|
93
|
+
isFullWidth: isFullWidth,
|
|
92
94
|
isOptional: true,
|
|
93
95
|
label: label,
|
|
94
96
|
renderFieldComponent: renderFieldComponent
|
package/dist/SearchField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.js","names":["forwardRef","memo","useCallback","useRef","CloseCircleFilledIcon","SearchIcon","Field","getControlState","useInputValues","jsx","_jsx","SearchField","_ref","ref","autoCompleteType","defaultValue","hasInitialFocus","id","idOverride","isDisabled","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","onClear","onClearProp","placeholder","testId","value","event","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","renderFieldComponent","_ref2","ariaDescribedBy","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","disabled","onClick","size","startAdornment","type","fieldType","hasVisibleLabel","isOptional","MemoizedSearchField","displayName"],"sources":["../src/SearchField.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n InputHTMLAttributes,\n memo,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { CloseCircleFilledIcon, SearchIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { getControlState, useInputValues } from \"./inputUtils\";\n\nexport type SearchFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n /**\n * The value of the `input` element to use when uncontrolled.\n */\n defaultValue?: string;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * This label won't show up visually, but it's required for accessibility.\n */\n label: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the clear button is pressed.\n */\n onClear?: () => void;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * The value of the `input` element, to use when controlled.\n */\n value?: string;\n} & Pick<FieldComponentProps, \"id\" | \"isDisabled\" | \"name\"> &\n SeleniumProps;\n\nconst SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(\n (\n {\n autoCompleteType,\n defaultValue,\n hasInitialFocus,\n id: idOverride,\n isDisabled = false,\n label,\n name: nameOverride,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n onClear: onClearProp,\n placeholder,\n testId,\n value,\n },\n ref\n ) => {\n const onChange: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement> =\n useCallback(\n (event) => {\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const onClear = useCallback(() => {\n onClearProp?.();\n }, [onClearProp]);\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, id }) => (\n <InputBase\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n autoComplete={autoCompleteType}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n defaultValue && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label=\"Clear\"\n disabled={isDisabled}\n onClick={onClear}\n size=\"small\"\n >\n <CloseCircleFilledIcon />\n </IconButton>\n </InputAdornment>\n )\n }\n id={id}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n ref={ref}\n startAdornment={\n <InputAdornment position=\"start\">\n <SearchIcon />\n </InputAdornment>\n }\n type=\"search\"\n />\n ),\n [\n autoCompleteType,\n defaultValue,\n hasInitialFocus,\n inputValues,\n isDisabled,\n nameOverride,\n onBlur,\n onChange,\n onClear,\n onFocus,\n placeholder,\n ref,\n testId,\n ]\n );\n\n return (\n <Field\n fieldType=\"single\"\n hasVisibleLabel={false}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={true}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedSearchField = memo(SearchField);\nMemoizedSearchField.displayName = \"SearchField\";\n\nexport { MemoizedSearchField as SearchField };\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAGEA,UAAU,EAEVC,IAAI,EACJC,WAAW,EACXC,MAAM,QACD,OAAO;AAAC,SAENC,qBAAqB,EAAEC,UAAU;AAAA,SACjCC,KAAK;AAAA,SAGLC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAwDxC,MAAMC,WAAW,GAAGX,UAAU,CAC5B,CAAAY,IAAA,
|
|
1
|
+
{"version":3,"file":"SearchField.js","names":["forwardRef","memo","useCallback","useRef","CloseCircleFilledIcon","SearchIcon","Field","getControlState","useInputValues","jsx","_jsx","SearchField","_ref","ref","autoCompleteType","defaultValue","hasInitialFocus","id","idOverride","isDisabled","isFullWidth","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","onClear","onClearProp","placeholder","testId","value","event","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","renderFieldComponent","_ref2","ariaDescribedBy","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","disabled","onClick","size","startAdornment","type","fieldType","hasVisibleLabel","isOptional","MemoizedSearchField","displayName"],"sources":["../src/SearchField.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n InputHTMLAttributes,\n memo,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { CloseCircleFilledIcon, SearchIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { getControlState, useInputValues } from \"./inputUtils\";\n\nexport type SearchFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n /**\n * The value of the `input` element to use when uncontrolled.\n */\n defaultValue?: string;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * This label won't show up visually, but it's required for accessibility.\n */\n label: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the clear button is pressed.\n */\n onClear?: () => void;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * The value of the `input` element, to use when controlled.\n */\n value?: string;\n} & Pick<FieldComponentProps, \"id\" | \"isDisabled\" | \"name\" | \"isFullWidth\"> &\n SeleniumProps;\n\nconst SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(\n (\n {\n autoCompleteType,\n defaultValue,\n hasInitialFocus,\n id: idOverride,\n isDisabled = false,\n isFullWidth = false,\n label,\n name: nameOverride,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n onClear: onClearProp,\n placeholder,\n testId,\n value,\n },\n ref\n ) => {\n const onChange: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement> =\n useCallback(\n (event) => {\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const onClear = useCallback(() => {\n onClearProp?.();\n }, [onClearProp]);\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, id }) => (\n <InputBase\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n autoComplete={autoCompleteType}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n defaultValue && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label=\"Clear\"\n disabled={isDisabled}\n onClick={onClear}\n size=\"small\"\n >\n <CloseCircleFilledIcon />\n </IconButton>\n </InputAdornment>\n )\n }\n id={id}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n ref={ref}\n startAdornment={\n <InputAdornment position=\"start\">\n <SearchIcon />\n </InputAdornment>\n }\n type=\"search\"\n />\n ),\n [\n autoCompleteType,\n defaultValue,\n hasInitialFocus,\n inputValues,\n isDisabled,\n nameOverride,\n onBlur,\n onChange,\n onClear,\n onFocus,\n placeholder,\n ref,\n testId,\n ]\n );\n\n return (\n <Field\n fieldType=\"single\"\n hasVisibleLabel={false}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={true}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedSearchField = memo(SearchField);\nMemoizedSearchField.displayName = \"SearchField\";\n\nexport { MemoizedSearchField as SearchField };\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAGEA,UAAU,EAEVC,IAAI,EACJC,WAAW,EACXC,MAAM,QACD,OAAO;AAAC,SAENC,qBAAqB,EAAEC,UAAU;AAAA,SACjCC,KAAK;AAAA,SAGLC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAwDxC,MAAMC,WAAW,GAAGX,UAAU,CAC5B,CAAAY,IAAA,EAkBEC,GAAG,KACA;EAAA,IAlBH;IACEC,gBAAgB;IAChBC,YAAY;IACZC,eAAe;IACfC,EAAE,EAAEC,UAAU;IACdC,UAAU,GAAG,KAAK;IAClBC,WAAW,GAAG,KAAK;IACnBC,KAAK;IACLC,IAAI,EAAEC,YAAY;IAClBC,QAAQ,EAAEC,YAAY;IACtBC,OAAO;IACPC,MAAM;IACNC,OAAO,EAAEC,WAAW;IACpBC,WAAW;IACXC,MAAM;IACNC;EACF,CAAC,GAAApB,IAAA;EAGD,MAAMY,QAAoE,GACxEtB,WAAW,CACR+B,KAAK,IAAK;IACTR,YAAY,GAAGQ,KAAK,CAAC;EACvB,CAAC,EACD,CAACR,YAAY,CACf,CAAC;EAE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AAU,IAAE;MAAC,CACA,CACjB;MACDkD,IAAI,EAAC;IAAQ,CACd,CAAC;EAAA,CACH,EACD,CACEzC,gBAAgB,EAChBC,YAAY,EACZC,eAAe,EACfqB,WAAW,EACXlB,UAAU,EACVI,YAAY,EACZI,MAAM,EACNH,QAAQ,EACRI,OAAO,EACPF,OAAO,EACPI,WAAW,EACXjB,GAAG,EACHkB,MAAM,CAEV,CAAC;EAED,OACErB,IAAA,CAACJ,KAAK;IACJkD,SAAS,EAAC,QAAQ;IAClBC,eAAe,EAAE,KAAM;IACvBxC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBsC,UAAU,EAAE,IAAK;IACjBrC,KAAK,EAAEA,KAAM;IACbmB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMmB,mBAAmB,GAAG1D,IAAI,CAACU,WAAW,CAAC;AAC7CgD,mBAAmB,CAACC,WAAW,GAAG,aAAa;AAE/C,SAASD,mBAAmB,IAAIhD,WAAW"}
|
package/dist/Select.js
CHANGED
|
@@ -34,6 +34,7 @@ const Select = _ref => {
|
|
|
34
34
|
hint,
|
|
35
35
|
id: idOverride,
|
|
36
36
|
isDisabled = false,
|
|
37
|
+
isFullWidth = false,
|
|
37
38
|
isMultiSelect,
|
|
38
39
|
isOptional = false,
|
|
39
40
|
label,
|
|
@@ -146,6 +147,7 @@ const Select = _ref => {
|
|
|
146
147
|
hint: hint,
|
|
147
148
|
id: idOverride,
|
|
148
149
|
isDisabled: isDisabled,
|
|
150
|
+
isFullWidth: isFullWidth,
|
|
149
151
|
isOptional: isOptional,
|
|
150
152
|
label: label,
|
|
151
153
|
renderFieldComponent: renderFieldComponent
|
package/dist/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","Field","CheckIcon","ComponentControlledState","useInputValues","getControlState","jsx","_jsx","jsxs","_jsxs","CONTROLLED","Select","_ref","defaultValue","errorMessage","hasMultipleChoices","hasMultipleChoicesProp","hint","id","idOverride","isDisabled","isMultiSelect","isOptional","label","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","options","testId","value","undefined","controlledStateRef","controlledValue","uncontrolledValue","internalSelectedValues","setInternalSelectedValues","current","inputValues","controlState","event","child","target","split","normalizedOptions","map","option","text","type","renderValue","selected","renderedChips","item","selectedOption","find","_Chip","filter","Boolean","length","_Box","children","_ListSubheader","_MenuItem","_Checkbox","checked","includes","_ListItemSecondaryAction","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_Select","labelId","multiple","fieldType","hasVisibleLabel","MemoizedSelect","displayName"],"sources":["../src/Select.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Box,\n Checkbox as MuiCheckbox,\n Chip,\n ListItemSecondaryAction,\n ListSubheader,\n MenuItem,\n Select as MuiSelect,\n} from \"@mui/material\";\nimport { SelectProps as MuiSelectProps } from \"@mui/material\";\n\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport { CheckIcon } from \"./icons.generated\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils\";\n\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n};\n\nexport type SelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type SelectProps<\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiSelectProps<Value>[\"defaultValue\"];\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * @deprecated Use `hasMultipleChoices` instead.\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n \"errorMessage\" | \"hint\" | \"id\" | \"isDisabled\" | \"isOptional\" | \"name\"\n> &\n SeleniumProps;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst { CONTROLLED } = ComponentControlledState;\nconst Select = <\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n>({\n defaultValue,\n errorMessage,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n id: idOverride,\n isDisabled = false,\n isMultiSelect,\n isOptional = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n options,\n testId,\n value,\n}: SelectProps<Value, HasMultipleChoices>) => {\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect]\n );\n const controlledStateRef = useRef(\n getControlState({ controlledValue: value, uncontrolledValue: defaultValue })\n );\n const [internalSelectedValues, setInternalSelectedValues] = useState(\n controlledStateRef.current === CONTROLLED ? value : defaultValue\n );\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSelectedValues(value);\n }\n }, [value]);\n\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<NonNullable<MuiSelectProps<Value>[\"onChange\"]>>(\n (event, child) => {\n const {\n target: { value },\n } = event;\n if (controlledStateRef.current !== CONTROLLED) {\n setInternalSelectedValues(\n (typeof value === \"string\" ? value.split(\",\") : value) as Value\n );\n }\n onChangeProp?.(event, child);\n },\n [onChangeProp]\n );\n\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const normalizedOptions = useMemo(\n () =>\n options.map((option) =>\n typeof option === \"object\"\n ? {\n text: option.text,\n value: option.value || option.text,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n }\n : { text: option, value: option, type: \"option\" }\n ),\n [options]\n );\n\n const renderValue = useCallback(\n (selected: Value) => {\n // If the selected value isn't an array, then we don't need to display\n // chips and should fall back to the default render behavior\n if (typeof selected === \"string\") {\n return undefined;\n }\n\n // Convert the selected options array into <Chip>s\n const renderedChips = selected\n .map((item: string) => {\n const selectedOption = normalizedOptions.find(\n (option) => option.value === item\n );\n\n if (!selectedOption) {\n return null;\n }\n\n return <Chip key={item} label={selectedOption.text} />;\n })\n .filter(Boolean);\n\n if (renderedChips.length === 0) {\n return null;\n }\n\n // We need the <Box> to surround the <Chip>s for\n // proper styling\n return <Box>{renderedChips}</Box>;\n },\n [normalizedOptions]\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const children = useMemo(\n () =>\n normalizedOptions.map((option) => {\n if (option.type === \"heading\") {\n return <ListSubheader key={option.text}>{option.text}</ListSubheader>;\n }\n return (\n <MenuItem key={option.value} value={option.value}>\n {hasMultipleChoices && (\n <MuiCheckbox\n checked={internalSelectedValues?.includes(option.value)}\n />\n )}\n {option.text}\n {internalSelectedValues === option.value && (\n <ListItemSecondaryAction>\n <CheckIcon />\n </ListItemSecondaryAction>\n )}\n </MenuItem>\n );\n }),\n [hasMultipleChoices, normalizedOptions, internalSelectedValues]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n children={children}\n data-se={testId}\n id={id}\n labelId={labelElementId}\n multiple={hasMultipleChoices}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={hasMultipleChoices ? renderValue : undefined}\n />\n ),\n [\n children,\n inputValues,\n hasMultipleChoices,\n nameOverride,\n onBlur,\n onChange,\n onFocus,\n renderValue,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAYvEC,KAAK;AAAA,SAELC,SAAS;AAAA,SAGhBC,wBAAwB,EACxBC,cAAc,EACdC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA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S/B,MAAO;MAChBb,EAAE,EAAEA,EAAG;MACPyD,OAAO,EAAEF,cAAe;MACxBG,QAAQ,EAAE7D,kBAAmB;MAC7BS,IAAI,EAAEC,YAAY,IAAIP,EAAG;MACzBQ,MAAM,EAAEA,MAAO;MACfC,QAAQ,EAAEA,QAAS;MACnBE,OAAO,EAAEA,OAAQ;MACjBsB,WAAW,EAAEpC,kBAAkB,GAAGoC,WAAW,GAAGlB;IAAU,CAC3D,CAAC;EAAA,CACH,EACD,CACE6B,QAAQ,EACRtB,WAAW,EACXzB,kBAAkB,EAClBU,YAAY,EACZC,MAAM,EACNC,QAAQ,EACRE,OAAO,EACPsB,WAAW,EACXpB,MAAM,CAEV,CAAC;EAED,OACExB,IAAA,CAACN,KAAK;IACJa,YAAY,EAAEA,YAAa;IAC3B+D,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACf7D,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBE,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACb8C,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMU,cAAc,GAAGpF,IAAI,CAACgB,MAAM,CAAC;AACnCoE,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIpE,MAAM"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","Field","CheckIcon","ComponentControlledState","useInputValues","getControlState","jsx","_jsx","jsxs","_jsxs","CONTROLLED","Select","_ref","defaultValue","errorMessage","hasMultipleChoices","hasMultipleChoicesProp","hint","id","idOverride","isDisabled","isFullWidth","isMultiSelect","isOptional","label","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","options","testId","value","undefined","controlledStateRef","controlledValue","uncontrolledValue","internalSelectedValues","setInternalSelectedValues","current","inputValues","controlState","event","child","target","split","normalizedOptions","map","option","text","type","renderValue","selected","renderedChips","item","selectedOption","find","_Chip","filter","Boolean","length","_Box","children","_ListSubheader","_MenuItem","_Checkbox","checked","includes","_ListItemSecondaryAction","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_Select","labelId","multiple","fieldType","hasVisibleLabel","MemoizedSelect","displayName"],"sources":["../src/Select.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Box,\n Checkbox as MuiCheckbox,\n Chip,\n ListItemSecondaryAction,\n ListSubheader,\n MenuItem,\n Select as MuiSelect,\n} from \"@mui/material\";\nimport { SelectProps as MuiSelectProps } from \"@mui/material\";\n\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport { CheckIcon } from \"./icons.generated\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils\";\n\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n};\n\nexport type SelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type SelectProps<\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiSelectProps<Value>[\"defaultValue\"];\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * @deprecated Use `hasMultipleChoices` instead.\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"hint\"\n | \"id\"\n | \"isDisabled\"\n | \"isOptional\"\n | \"name\"\n | \"isFullWidth\"\n> &\n SeleniumProps;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst { CONTROLLED } = ComponentControlledState;\nconst Select = <\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n>({\n defaultValue,\n errorMessage,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n id: idOverride,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n options,\n testId,\n value,\n}: SelectProps<Value, HasMultipleChoices>) => {\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect]\n );\n const controlledStateRef = useRef(\n getControlState({ controlledValue: value, uncontrolledValue: defaultValue })\n );\n const [internalSelectedValues, setInternalSelectedValues] = useState(\n controlledStateRef.current === CONTROLLED ? value : defaultValue\n );\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSelectedValues(value);\n }\n }, [value]);\n\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<NonNullable<MuiSelectProps<Value>[\"onChange\"]>>(\n (event, child) => {\n const {\n target: { value },\n } = event;\n if (controlledStateRef.current !== CONTROLLED) {\n setInternalSelectedValues(\n (typeof value === \"string\" ? value.split(\",\") : value) as Value\n );\n }\n onChangeProp?.(event, child);\n },\n [onChangeProp]\n );\n\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const normalizedOptions = useMemo(\n () =>\n options.map((option) =>\n typeof option === \"object\"\n ? {\n text: option.text,\n value: option.value || option.text,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n }\n : { text: option, value: option, type: \"option\" }\n ),\n [options]\n );\n\n const renderValue = useCallback(\n (selected: Value) => {\n // If the selected value isn't an array, then we don't need to display\n // chips and should fall back to the default render behavior\n if (typeof selected === \"string\") {\n return undefined;\n }\n\n // Convert the selected options array into <Chip>s\n const renderedChips = selected\n .map((item: string) => {\n const selectedOption = normalizedOptions.find(\n (option) => option.value === item\n );\n\n if (!selectedOption) {\n return null;\n }\n\n return <Chip key={item} label={selectedOption.text} />;\n })\n .filter(Boolean);\n\n if (renderedChips.length === 0) {\n return null;\n }\n\n // We need the <Box> to surround the <Chip>s for\n // proper styling\n return <Box>{renderedChips}</Box>;\n },\n [normalizedOptions]\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const children = useMemo(\n () =>\n normalizedOptions.map((option) => {\n if (option.type === \"heading\") {\n return <ListSubheader key={option.text}>{option.text}</ListSubheader>;\n }\n return (\n <MenuItem key={option.value} value={option.value}>\n {hasMultipleChoices && (\n <MuiCheckbox\n checked={internalSelectedValues?.includes(option.value)}\n />\n )}\n {option.text}\n {internalSelectedValues === option.value && (\n <ListItemSecondaryAction>\n <CheckIcon />\n </ListItemSecondaryAction>\n )}\n </MenuItem>\n );\n }),\n [hasMultipleChoices, normalizedOptions, internalSelectedValues]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n children={children}\n data-se={testId}\n id={id}\n labelId={labelElementId}\n multiple={hasMultipleChoices}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={hasMultipleChoices ? renderValue : undefined}\n />\n ),\n [\n children,\n inputValues,\n hasMultipleChoices,\n nameOverride,\n onBlur,\n onChange,\n onFocus,\n renderValue,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAYvEC,KAAK;AAAA,SAELC,SAAS;AAAA,SAGhBC,wBAAwB,EACxBC,cAAc,EACdC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAgFjB,MAAM;EAAEC;AAAW,CAAC,GAAGP,wBAAwB;AAC/C,MAAMQ,MAAM,GAAGC,IAAA,IAqB+B;EAAA,IAlB5C;IACAC,YAAY;IACZC,YAAY;IACZC,kBAAkB,EAAEC,sBAAsB;IAC1CC,IAAI;IACJC,EAAE,EAAEC,UAAU;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nBE,OAAO,EAAEA,OAAQ;MACjBsB,WAAW,EAAErC,kBAAkB,GAAGqC,WAAW,GAAGlB;IAAU,CAC3D,CAAC;EAAA,CACH,EACD,CACE6B,QAAQ,EACRtB,WAAW,EACX1B,kBAAkB,EAClBW,YAAY,EACZC,MAAM,EACNC,QAAQ,EACRE,OAAO,EACPsB,WAAW,EACXpB,MAAM,CAEV,CAAC;EAED,OACEzB,IAAA,CAACN,KAAK;IACJa,YAAY,EAAEA,YAAa;IAC3BgE,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACf9D,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACb8C,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMU,cAAc,GAAGrF,IAAI,CAACgB,MAAM,CAAC;AACnCqE,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIrE,MAAM"}
|
package/dist/TextField.js
CHANGED
|
@@ -27,6 +27,7 @@ const TextField = forwardRef((_ref, ref) => {
|
|
|
27
27
|
hint,
|
|
28
28
|
id: idOverride,
|
|
29
29
|
isDisabled = false,
|
|
30
|
+
isFullWidth = false,
|
|
30
31
|
isMultiline = false,
|
|
31
32
|
isOptional = false,
|
|
32
33
|
isReadOnly,
|
|
@@ -98,6 +99,7 @@ const TextField = forwardRef((_ref, ref) => {
|
|
|
98
99
|
hint: hint,
|
|
99
100
|
id: idOverride,
|
|
100
101
|
isDisabled: isDisabled,
|
|
102
|
+
isFullWidth: isFullWidth,
|
|
101
103
|
isOptional: isOptional,
|
|
102
104
|
label: label,
|
|
103
105
|
renderFieldComponent: renderFieldComponent
|
package/dist/TextField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":["forwardRef","memo","useCallback","useRef","Field","useInputValues","getControlState","jsx","_jsx","textFieldTypeValues","TextField","_ref","ref","autoCompleteType","defaultValue","hasInitialFocus","endAdornment","errorMessage","hint","id","idOverride","isDisabled","isMultiline","isOptional","isReadOnly","label","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","placeholder","startAdornment","testId","type","value","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","event","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_InputBase","inputProps","autoComplete","autoFocus","_InputAdornment","position","children","multiline","readOnly","required","fieldType","hasVisibleLabel","MemoizedTextField","displayName"],"sources":["../src/TextField.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n InputHTMLAttributes,\n memo,\n ReactElement,\n useCallback,\n useRef,\n} from \"react\";\nimport { InputAdornment, InputBase } from \"@mui/material\";\n\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport { Field } from \"./Field\";\nimport { SeleniumProps } from \"./SeleniumProps\";\nimport { useInputValues, getControlState } from \"./inputUtils\";\n\nexport const textFieldTypeValues = [\n \"email\",\n \"number\",\n \"tel\",\n \"text\",\n \"url\",\n] as const;\n\nexport type TextFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: string;\n /**\n * End `InputAdornment` for this component.\n */\n endAdornment?: string | ReactElement;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.\n */\n isMultiline?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * Start `InputAdornment` for this component.\n */\n startAdornment?: string | ReactElement;\n /**\n * Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).\n */\n type?: (typeof textFieldTypeValues)[number];\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: string;\n} & FieldComponentProps &\n SeleniumProps;\n\nconst TextField = forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n autoCompleteType,\n defaultValue,\n hasInitialFocus,\n endAdornment,\n errorMessage,\n hint,\n id: idOverride,\n isDisabled = false,\n isMultiline = false,\n isOptional = false,\n isReadOnly,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n placeholder,\n startAdornment,\n testId,\n type = \"text\",\n value: value,\n },\n ref\n ) => {\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<\n NonNullable<ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>>\n >(\n (event) => {\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (\n <InputBase\n {...inputValues}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n }}\n aria-describedby={ariaDescribedBy}\n autoComplete={autoCompleteType}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n endAdornment && (\n <InputAdornment position=\"end\">{endAdornment}</InputAdornment>\n )\n }\n id={id}\n multiline={isMultiline}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n readOnly={isReadOnly}\n ref={ref}\n required={!isOptional}\n startAdornment={\n startAdornment && (\n <InputAdornment position=\"start\">{startAdornment}</InputAdornment>\n )\n }\n type={type}\n />\n ),\n [\n autoCompleteType,\n inputValues,\n hasInitialFocus,\n endAdornment,\n isMultiline,\n nameOverride,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n isOptional,\n isReadOnly,\n ref,\n startAdornment,\n testId,\n type,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedTextField = memo(TextField);\nMemoizedTextField.displayName = \"TextField\";\n\nexport { MemoizedTextField as TextField };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAGEA,UAAU,EAEVC,IAAI,EAEJC,WAAW,EACXC,MAAM,QACD,OAAO;AAAC,SAINC,KAAK;AAAA,SAELC,cAAc,EAAEC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExC,OAAO,MAAMC,mBAAmB,GAAG,CACjC,OAAO,EACP,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,CACG;AA4DV,MAAMC,SAAS,GAAGV,UAAU,CAC1B,CAAAW,IAAA,
|
|
1
|
+
{"version":3,"file":"TextField.js","names":["forwardRef","memo","useCallback","useRef","Field","useInputValues","getControlState","jsx","_jsx","textFieldTypeValues","TextField","_ref","ref","autoCompleteType","defaultValue","hasInitialFocus","endAdornment","errorMessage","hint","id","idOverride","isDisabled","isFullWidth","isMultiline","isOptional","isReadOnly","label","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","placeholder","startAdornment","testId","type","value","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","event","renderFieldComponent","_ref2","ariaDescribedBy","errorMessageElementId","labelElementId","_InputBase","inputProps","autoComplete","autoFocus","_InputAdornment","position","children","multiline","readOnly","required","fieldType","hasVisibleLabel","MemoizedTextField","displayName"],"sources":["../src/TextField.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n InputHTMLAttributes,\n memo,\n ReactElement,\n useCallback,\n useRef,\n} from \"react\";\nimport { InputAdornment, InputBase } from \"@mui/material\";\n\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport { Field } from \"./Field\";\nimport { SeleniumProps } from \"./SeleniumProps\";\nimport { useInputValues, getControlState } from \"./inputUtils\";\n\nexport const textFieldTypeValues = [\n \"email\",\n \"number\",\n \"tel\",\n \"text\",\n \"url\",\n] as const;\n\nexport type TextFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: string;\n /**\n * End `InputAdornment` for this component.\n */\n endAdornment?: string | ReactElement;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.\n */\n isMultiline?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * Start `InputAdornment` for this component.\n */\n startAdornment?: string | ReactElement;\n /**\n * Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).\n */\n type?: (typeof textFieldTypeValues)[number];\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: string;\n} & FieldComponentProps &\n SeleniumProps;\n\nconst TextField = forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n autoCompleteType,\n defaultValue,\n hasInitialFocus,\n endAdornment,\n errorMessage,\n hint,\n id: idOverride,\n isDisabled = false,\n isFullWidth = false,\n isMultiline = false,\n isOptional = false,\n isReadOnly,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n placeholder,\n startAdornment,\n testId,\n type = \"text\",\n value: value,\n },\n ref\n ) => {\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n })\n );\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<\n NonNullable<ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>>\n >(\n (event) => {\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, errorMessageElementId, id, labelElementId }) => (\n <InputBase\n {...inputValues}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n }}\n aria-describedby={ariaDescribedBy}\n autoComplete={autoCompleteType}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n endAdornment && (\n <InputAdornment position=\"end\">{endAdornment}</InputAdornment>\n )\n }\n id={id}\n multiline={isMultiline}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n readOnly={isReadOnly}\n ref={ref}\n required={!isOptional}\n startAdornment={\n startAdornment && (\n <InputAdornment position=\"start\">{startAdornment}</InputAdornment>\n )\n }\n type={type}\n />\n ),\n [\n autoCompleteType,\n inputValues,\n hasInitialFocus,\n endAdornment,\n isMultiline,\n nameOverride,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n isOptional,\n isReadOnly,\n ref,\n startAdornment,\n testId,\n type,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedTextField = memo(TextField);\nMemoizedTextField.displayName = \"TextField\";\n\nexport { MemoizedTextField as TextField };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAGEA,UAAU,E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EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvBE,KAAK,EAAEA,KAAM;IACbmB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMiB,iBAAiB,GAAG7D,IAAI,CAACS,SAAS,CAAC;AACzCoD,iBAAiB,CAACC,WAAW,GAAG,WAAW;AAE3C,SAASD,iBAAiB,IAAIpD,SAAS"}
|
|
@@ -78,7 +78,7 @@ export type AutocompleteProps<OptionType, HasMultipleChoices extends boolean | u
|
|
|
78
78
|
* You will need to implement this function if your `option` items are objects.
|
|
79
79
|
*/
|
|
80
80
|
getIsOptionEqualToValue?: (option: OptionType, value: OptionType) => boolean;
|
|
81
|
-
} & Pick<FieldComponentProps, "errorMessage" | "hint" | "id" | "isOptional" | "name"> & SeleniumProps;
|
|
82
|
-
declare const MemoizedAutocomplete: <OptionType, HasMultipleChoices extends boolean | undefined, IsCustomValueAllowed extends boolean | undefined>({ defaultValue, errorMessage, hasMultipleChoices, id: idOverride, inputValue, isCustomValueAllowed, isDisabled, isLoading, isOptional, isReadOnly, hint, label, name: nameOverride, onBlur, onChange: onChangeProp, onInputChange: onInputChangeProp, onFocus, options, value, getIsOptionEqualToValue, testId, }: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => JSX.Element;
|
|
81
|
+
} & Pick<FieldComponentProps, "errorMessage" | "hint" | "id" | "isOptional" | "name" | "isFullWidth"> & SeleniumProps;
|
|
82
|
+
declare const MemoizedAutocomplete: <OptionType, HasMultipleChoices extends boolean | undefined, IsCustomValueAllowed extends boolean | undefined>({ defaultValue, errorMessage, hasMultipleChoices, id: idOverride, inputValue, isCustomValueAllowed, isDisabled, isFullWidth, isLoading, isOptional, isReadOnly, hint, label, name: nameOverride, onBlur, onChange: onChangeProp, onInputChange: onInputChangeProp, onFocus, options, value, getIsOptionEqualToValue, testId, }: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => JSX.Element;
|
|
83
83
|
export { MemoizedAutocomplete as Autocomplete };
|
|
84
84
|
//# sourceMappingURL=Autocomplete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../src/Autocomplete.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAEL,iBAAiB,IAAI,oBAAoB,EAEzC,oBAAoB,EAErB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOrD,MAAM,MAAM,iBAAiB,CAC3B,UAAU,EACV,kBAAkB,SAAS,OAAO,GAAG,SAAS,EAC9C,oBAAoB,SAAS,OAAO,GAAG,SAAS,IAC9C;IACF;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,CACjC,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,cAAc,CAAC,CAAC;IAClB;;OAEG;IACH,kBAAkB,CAAC,EAAE,oBAAoB,CACvC,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,UAAU,CAAC,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAC/B,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,YAAY,CAAC,CAAC;IAChB;;OAEG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CACzC,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,UAAU,CAAC,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAC/B,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,UAAU,CAAC,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,oBAAoB,CAC9B,UAAU,EACV,kBAAkB,EAClB,SAAS,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ACH,MAAM,CAAC,EAAE,oBAAoB,CAC3B,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,QAAQ,CAAC,CAAC;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAC7B,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,UAAU,CAAC,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAClC,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,eAAe,CAAC,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,oBAAoB,CAC5B,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,SAAS,CAAC,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAC1B,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,oBAAoB,CACrB,CAAC,OAAO,CAAC,CAAC;IAEX;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC;CAC9E,GAAG,IAAI,CACN,mBAAmB,EACnB,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,GAAG,MAAM,GAAG,aAAa,CACvE,GACC,aAAa,CAAC;AAmKhB,QAAA,MAAM,oBAAoB,wgBAA4C,CAAC;AAIvE,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC"}
|
package/dist/src/Field.d.ts
CHANGED
|
@@ -44,6 +44,10 @@ export type FieldProps = {
|
|
|
44
44
|
* If `true`, the component is disabled.
|
|
45
45
|
*/
|
|
46
46
|
isDisabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* If `true`, the component can stretch to fill the width of the container.
|
|
49
|
+
*/
|
|
50
|
+
isFullWidth?: boolean;
|
|
47
51
|
/**
|
|
48
52
|
* If `true`, the `input` element is not required.
|
|
49
53
|
*/
|
|
@@ -67,6 +71,6 @@ export type FieldProps = {
|
|
|
67
71
|
labelElementId: string;
|
|
68
72
|
}) => ReactElement;
|
|
69
73
|
};
|
|
70
|
-
declare const MemoizedField: import("react").MemoExoticComponent<({ errorMessage, fieldType, hasVisibleLabel, hint, id: idOverride, isDisabled: isDisabledProp, isRadioGroup, isOptional, label, renderFieldComponent, }: FieldProps) => JSX.Element>;
|
|
74
|
+
declare const MemoizedField: import("react").MemoExoticComponent<({ errorMessage, fieldType, hasVisibleLabel, hint, id: idOverride, isDisabled: isDisabledProp, isFullWidth, isRadioGroup, isOptional, label, renderFieldComponent, }: FieldProps) => JSX.Element>;
|
|
71
75
|
export { MemoizedField as Field };
|
|
72
76
|
//# sourceMappingURL=Field.d.ts.map
|