@okta/odyssey-react-mui 1.13.4 → 1.13.6
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 +8 -0
- package/dist/Accordion.js +11 -12
- package/dist/Accordion.js.map +1 -1
- package/dist/Autocomplete.js +63 -70
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Badge.js +7 -8
- package/dist/Badge.js.map +1 -1
- package/dist/Banner.js +10 -11
- package/dist/Banner.js.map +1 -1
- package/dist/Box.js +16 -19
- package/dist/Box.js.map +1 -1
- package/dist/Breadcrumbs.js +12 -14
- package/dist/Breadcrumbs.js.map +1 -1
- package/dist/Button.js +20 -21
- package/dist/Button.js.map +1 -1
- package/dist/Callout.js +11 -12
- package/dist/Callout.js.map +1 -1
- package/dist/Checkbox.js +20 -21
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxGroup.js +27 -31
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CircularProgress.js +10 -13
- package/dist/CircularProgress.js.map +1 -1
- package/dist/Dialog.js +11 -12
- package/dist/Dialog.js.map +1 -1
- package/dist/ErrorMessageList.js +3 -4
- package/dist/ErrorMessageList.js.map +1 -1
- package/dist/Field.js +16 -17
- package/dist/Field.js.map +1 -1
- package/dist/FieldError.js +7 -8
- package/dist/FieldError.js.map +1 -1
- package/dist/FieldHint.js +7 -8
- package/dist/FieldHint.js.map +1 -1
- package/dist/FieldLabel.js +9 -10
- package/dist/FieldLabel.js.map +1 -1
- package/dist/Fieldset.js +11 -12
- package/dist/Fieldset.js.map +1 -1
- package/dist/Form.js +16 -17
- package/dist/Form.js.map +1 -1
- package/dist/Link.js +13 -14
- package/dist/Link.js.map +1 -1
- package/dist/MenuButton.js +21 -22
- package/dist/MenuButton.js.map +1 -1
- package/dist/MenuItem.js +10 -11
- package/dist/MenuItem.js.map +1 -1
- package/dist/MuiPropsChild.js +4 -5
- package/dist/MuiPropsChild.js.map +1 -1
- package/dist/NativeSelect.js +49 -53
- package/dist/NativeSelect.js.map +1 -1
- package/dist/OdysseyCacheProvider.js +6 -7
- package/dist/OdysseyCacheProvider.js.map +1 -1
- package/dist/OdysseyProvider.js +26 -29
- package/dist/OdysseyProvider.js.map +1 -1
- package/dist/OdysseyThemeProvider.js +8 -9
- package/dist/OdysseyThemeProvider.js.map +1 -1
- package/dist/OdysseyTranslationProvider.js +5 -6
- package/dist/OdysseyTranslationProvider.js.map +1 -1
- package/dist/PasswordField.js +64 -68
- package/dist/PasswordField.js.map +1 -1
- package/dist/Radio.js +13 -14
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +34 -38
- package/dist/RadioGroup.js.map +1 -1
- package/dist/ScreenReaderText.js +9 -12
- package/dist/ScreenReaderText.js.map +1 -1
- package/dist/SearchField.js +56 -60
- package/dist/SearchField.js.map +1 -1
- package/dist/Select.js +50 -54
- package/dist/Select.js.map +1 -1
- package/dist/Status.js +6 -7
- package/dist/Status.js.map +1 -1
- package/dist/Tabs.js +14 -16
- package/dist/Tabs.js.map +1 -1
- package/dist/Tag.js +9 -10
- package/dist/Tag.js.map +1 -1
- package/dist/TagList.js +4 -5
- package/dist/TagList.js.map +1 -1
- package/dist/TextField.js +70 -74
- package/dist/TextField.js.map +1 -1
- package/dist/Toast.js +13 -14
- package/dist/Toast.js.map +1 -1
- package/dist/ToastStack.js +3 -4
- package/dist/ToastStack.js.map +1 -1
- package/dist/Tooltip.js +17 -20
- package/dist/Tooltip.js.map +1 -1
- package/dist/Typography.js +212 -243
- package/dist/Typography.js.map +1 -1
- package/dist/i18n.js +1 -2
- package/dist/i18n.js.map +1 -1
- package/dist/inputUtils.js +9 -11
- package/dist/inputUtils.js.map +1 -1
- package/dist/labs/DataFilters.js +18 -22
- package/dist/labs/DataFilters.js.map +1 -1
- package/dist/labs/DataTable.js +78 -92
- package/dist/labs/DataTable.js.map +1 -1
- package/dist/labs/DataTablePagination.js +9 -10
- package/dist/labs/DataTablePagination.js.map +1 -1
- package/dist/labs/DatePicker.js +10 -12
- package/dist/labs/DatePicker.js.map +1 -1
- package/dist/labs/GroupPicker.js +37 -44
- package/dist/labs/GroupPicker.js.map +1 -1
- package/dist/labs/PaginatedTable.js +23 -27
- package/dist/labs/PaginatedTable.js.map +1 -1
- package/dist/labs/StaticTable.js +17 -21
- package/dist/labs/StaticTable.js.map +1 -1
- package/dist/labs/Switch.js +20 -22
- package/dist/labs/Switch.js.map +1 -1
- package/dist/labs/VirtualizedAutocomplete.js +61 -68
- package/dist/labs/VirtualizedAutocomplete.js.map +1 -1
- package/dist/labs/datePickerTheme.js +266 -350
- package/dist/labs/datePickerTheme.js.map +1 -1
- package/dist/src/Button.d.ts +15 -1
- package/dist/src/Button.d.ts.map +1 -1
- package/dist/theme/components.js +1104 -1198
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/createOdysseyMuiTheme.js +22 -25
- package/dist/theme/createOdysseyMuiTheme.js.map +1 -1
- package/dist/theme/mixins.js +3 -4
- package/dist/theme/mixins.js.map +1 -1
- package/dist/theme/palette.js +3 -4
- package/dist/theme/palette.js.map +1 -1
- package/dist/theme/shape.js +3 -4
- package/dist/theme/shape.js.map +1 -1
- package/dist/theme/spacing.js +3 -4
- package/dist/theme/spacing.js.map +1 -1
- package/dist/theme/typography.js +3 -4
- package/dist/theme/typography.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/useNormalizedKey.js +1 -4
- package/dist/useNormalizedKey.js.map +1 -1
- package/package.json +3 -3
- package/src/Button.tsx +15 -0
- package/src/MenuButton.tsx +3 -3
package/dist/NativeSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeSelect.js","names":["React","forwardRef","memo","useCallback","useImperativeHandle","useMemo","useRef","Field","getControlState","useInputValues","jsx","_jsx","NativeSelect","_ref","ref","ariaDescribedBy","autoCompleteType","defaultValue","errorMessage","errorMessageList","hasMultipleChoices","hasMultipleChoicesProp","hint","HintLinkComponent","id","idOverride","inputRef","isDisabled","isFullWidth","isMultiSelect","isOptional","label","onBlur","onChange","onChangeProp","onFocus","testId","translate","value","children","controlledStateRef","controlledValue","uncontrolledValue","localInputRef","focus","current","inputValues","controlState","event","child","undefined","renderFieldComponent","_ref2","errorMessageElementId","labelElementId","_Select","autoComplete","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 InputHTMLAttributes,\n ReactElement,\n forwardRef,\n memo,\n useCallback,\n useImperativeHandle,\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 { HtmlProps } from \"./HtmlProps\";\nimport { FocusHandle, getControlState, useInputValues } from \"./inputUtils\";\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 * 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 * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill\n */\n autoCompleteType?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\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 * The ref forwarded to the NativeSelect\n */\n inputRef?: React.RefObject<FocusHandle>;\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 | \"ariaDescribedBy\"\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n> &\n HtmlProps;\n\nconst NativeSelect = forwardRef(\n <\n Value extends NativeSelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n >(\n {\n ariaDescribedBy,\n autoCompleteType,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputRef,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n label,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n testId,\n translate,\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 localInputRef = useRef<HTMLSelectElement>(null);\n\n useImperativeHandle(\n inputRef,\n () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n },\n []\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 autoComplete={autoCompleteType}\n children={children}\n id={idOverride}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n \"data-se\": testId,\n }}\n inputRef={localInputRef}\n name={idOverride}\n multiple={hasMultipleChoices}\n native={true}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n ref={ref}\n translate={translate}\n />\n ),\n [\n autoCompleteType,\n children,\n idOverride,\n inputValues,\n hasMultipleChoices,\n onBlur,\n onChange,\n onFocus,\n ref,\n testId,\n translate,\n ]\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\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;A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Ae;IACfxC,IAAI,EAAEA,IAAK;IACXC,iBAAiB,EAAEA,iBAAkB;IACrCC,EAAE,EAAEC,UAAW;IACfE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACboB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMY,oBAAoB,GAAG7D,IAAI,CAACU,YAAY,CAAC;AAC/CmD,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAInD,YAAY"}
|
|
1
|
+
{"version":3,"file":"NativeSelect.js","names":["React","forwardRef","memo","useCallback","useImperativeHandle","useMemo","useRef","Field","getControlState","useInputValues","jsx","_jsx","NativeSelect","ariaDescribedBy","autoCompleteType","defaultValue","errorMessage","errorMessageList","hasMultipleChoices","hasMultipleChoicesProp","hint","HintLinkComponent","id","idOverride","inputRef","isDisabled","isFullWidth","isMultiSelect","isOptional","label","onBlur","onChange","onChangeProp","onFocus","testId","translate","value","children","ref","controlledStateRef","controlledValue","uncontrolledValue","localInputRef","focus","current","inputValues","controlState","event","child","undefined","renderFieldComponent","errorMessageElementId","labelElementId","_Select","autoComplete","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 InputHTMLAttributes,\n ReactElement,\n forwardRef,\n memo,\n useCallback,\n useImperativeHandle,\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 { HtmlProps } from \"./HtmlProps\";\nimport { FocusHandle, getControlState, useInputValues } from \"./inputUtils\";\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 * 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 * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill\n */\n autoCompleteType?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\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 * The ref forwarded to the NativeSelect\n */\n inputRef?: React.RefObject<FocusHandle>;\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 | \"ariaDescribedBy\"\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n> &\n HtmlProps;\n\nconst NativeSelect = forwardRef(\n <\n Value extends NativeSelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean\n >(\n {\n ariaDescribedBy,\n autoCompleteType,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputRef,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n label,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n testId,\n translate,\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 localInputRef = useRef<HTMLSelectElement>(null);\n\n useImperativeHandle(\n inputRef,\n () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n },\n []\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 autoComplete={autoCompleteType}\n children={children}\n id={idOverride}\n inputProps={{\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n \"data-se\": testId,\n }}\n inputRef={localInputRef}\n name={idOverride}\n multiple={hasMultipleChoices}\n native={true}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n ref={ref}\n translate={translate}\n />\n ),\n [\n autoCompleteType,\n children,\n idOverride,\n inputValues,\n hasMultipleChoices,\n onBlur,\n onChange,\n onFocus,\n ref,\n testId,\n translate,\n ]\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\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,IAGVC,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AAAC,SAKNC,KAAK;AAAA,SAGQC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA6ErD,MAAMC,YAAY,GAAGX,UAAU,CAC7B,CAIE;EACEY,eAAe;EACfC,gBAAgB;EAChBC,YAAY;EACZC,YAAY;EACZC,gBAAgB;EAChBC,kBAAkB,EAAEC,sBAAsB;EAC1CC,IAAI;EACJC,iBAAiB;EACjBC,EAAE,EAAEC,UAAU;EACdC,QAAQ;EACRC,UAAU,GAAG,KAAK;EAClBC,WAAW,GAAG,KAAK;EACnBC,aAAa;EACbC,UAAU,GAAG,KAAK;EAClBC,KAAK;EACLC,MAAM;EACNC,QAAQ,EAAEC,YAAY;EACtBC,OAAO;EACPC,MAAM;EACNC,SAAS;EACTC,KAAK;EACLC;AAC4C,CAAC,EAC/CC,GAA6B,KAC1B;E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mB;IAC7BwC,MAAM,EAAE,IAAK;IACb5B,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBE,OAAO,EAAEA,OAAQ;IACjBK,GAAG,EAAEA,GAAI;IACTH,SAAS,EAAEA;EAAU,CACtB,CACF,EACD,CACErB,gBAAgB,EAChBuB,QAAQ,EACRd,UAAU,EACVsB,WAAW,EACX3B,kBAAkB,EAClBY,MAAM,EACNC,QAAQ,EACRE,OAAO,EACPK,GAAG,EACHJ,MAAM,EACNC,SAAS,CAEb,CAAC;EAED,OACExB,IAAA,CAACJ,KAAK;IACJM,eAAe,EAAEA,eAAgB;IACjCG,YAAY,EAAEA,YAAa;IAC3BC,gBAAgB,EAAEA,gBAAiB;IACnC0C,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACfxC,IAAI,EAAEA,IAAK;IACXC,iBAAiB,EAAEA,iBAAkB;IACrCC,EAAE,EAAEC,UAAW;IACfE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbqB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMW,oBAAoB,GAAG3D,IAAI,CAACU,YAAY,CAAC;AAC/CiD,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIjD,YAAY"}
|
|
@@ -15,13 +15,12 @@ import { memo, useMemo } from "react";
|
|
|
15
15
|
import { useUniqueAlphabeticalId } from "./useUniqueAlphabeticalId.js";
|
|
16
16
|
import { CacheProvider } from "@emotion/react";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
const OdysseyCacheProvider =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _ref;
|
|
18
|
+
const OdysseyCacheProvider = ({
|
|
19
|
+
children,
|
|
20
|
+
emotionRoot,
|
|
21
|
+
nonce,
|
|
22
|
+
stylisPlugins
|
|
23
|
+
}) => {
|
|
25
24
|
const uniqueAlphabeticalId = useUniqueAlphabeticalId();
|
|
26
25
|
const emotionCache = useMemo(() => {
|
|
27
26
|
return createCache({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyCacheProvider.js","names":["createCache","memo","useMemo","useUniqueAlphabeticalId","CacheProvider","jsx","_jsx","OdysseyCacheProvider","
|
|
1
|
+
{"version":3,"file":"OdysseyCacheProvider.js","names":["createCache","memo","useMemo","useUniqueAlphabeticalId","CacheProvider","jsx","_jsx","OdysseyCacheProvider","children","emotionRoot","nonce","stylisPlugins","uniqueAlphabeticalId","emotionCache","container","key","window","cspNonce","prepend","speedy","value","MemoizedOdysseyCacheProvider","displayName"],"sources":["../src/OdysseyCacheProvider.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\ndeclare global {\n interface Window {\n cspNonce: string;\n }\n}\n\nimport createCache, { StylisPlugin } from \"@emotion/cache\";\nimport { memo, useMemo, ReactNode } from \"react\";\nimport { useUniqueAlphabeticalId } from \"./useUniqueAlphabeticalId\";\nimport { CacheProvider } from \"@emotion/react\";\n\nexport type OdysseyCacheProviderProps = {\n children: ReactNode;\n nonce?: string;\n /**\n * Emotion caches styles into the style element.\n * When enabling this prop, Emotion caches the styles at this element, rather than in <head>.\n */\n emotionRoot?: HTMLStyleElement;\n /**\n * Emotion renders into this HTML element.\n * When enabling this prop, Emotion renders at the top of this component rather than the bottom like it does in the HTML `<head>`.\n */\n shadowDomElement?: HTMLDivElement | HTMLElement;\n stylisPlugins?: StylisPlugin[];\n};\n\nconst OdysseyCacheProvider = ({\n children,\n emotionRoot,\n nonce,\n stylisPlugins,\n}: OdysseyCacheProviderProps) => {\n const uniqueAlphabeticalId = useUniqueAlphabeticalId();\n\n const emotionCache = useMemo(() => {\n return createCache({\n ...(emotionRoot && { container: emotionRoot }),\n key: uniqueAlphabeticalId,\n nonce: nonce ?? window.cspNonce,\n prepend: true,\n speedy: false, // <-- Needs to be set to false when shadow-dom is used!! https://github.com/emotion-js/emotion/issues/2053#issuecomment-713429122\n ...(stylisPlugins && { stylisPlugins }),\n });\n }, [emotionRoot, nonce, stylisPlugins, uniqueAlphabeticalId]);\n\n return <CacheProvider value={emotionCache}>{children}</CacheProvider>;\n};\n\nconst MemoizedOdysseyCacheProvider = memo(OdysseyCacheProvider);\nMemoizedOdysseyCacheProvider.displayName = \"OdysseyCacheProvider\";\n\nexport { MemoizedOdysseyCacheProvider as OdysseyCacheProvider };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,WAAW,MAAwB,gBAAgB;AAC1D,SAASC,IAAI,EAAEC,OAAO,QAAmB,OAAO;AAAC,SACxCC,uBAAuB;AAChC,SAASC,aAAa,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAkB/C,MAAMC,oBAAoB,GAAGA,CAAC;EAC5BC,QAAQ;EACRC,WAAW;EACXC,KAAK;EACLC;AACyB,CAAC,KAAK;EAC/B,MAAMC,oBAAoB,GAAGT,uBAAuB,CAAC,CAAC;EAEtD,MAAMU,YAAY,GAAGX,OAAO,CAAC,MAAM;IACjC,OAAOF,WAAW,CAAC;MACjB,IAAIS,WAAW,IAAI;QAAEK,SAAS,EAAEL;MAAY,CAAC,CAAC;MAC9CM,GAAG,EAAEH,oBAAoB;MACzBF,KAAK,EAAEA,KAAK,IAAIM,MAAM,CAACC,QAAQ;MAC/BC,OAAO,EAAE,IAAI;MACbC,MAAM,EAAE,KAAK;MACb,IAAIR,aAAa,IAAI;QAAEA;MAAc,CAAC;IACxC,CAAC,CAAC;EACJ,CAAC,EAAE,CAACF,WAAW,EAAEC,KAAK,EAAEC,aAAa,EAAEC,oBAAoB,CAAC,CAAC;EAE7D,OAAON,IAAA,CAACF,aAAa;IAACgB,KAAK,EAAEP,YAAa;IAAAL,QAAA,EAAEA;EAAQ,CAAgB,CAAC;AACvE,CAAC;AAED,MAAMa,4BAA4B,GAAGpB,IAAI,CAACM,oBAAoB,CAAC;AAC/Dc,4BAA4B,CAACC,WAAW,GAAG,sBAAsB;AAEjE,SAASD,4BAA4B,IAAId,oBAAoB"}
|
package/dist/OdysseyProvider.js
CHANGED
|
@@ -16,39 +16,36 @@ import { OdysseyCacheProvider } from "./OdysseyCacheProvider.js";
|
|
|
16
16
|
import { OdysseyThemeProvider } from "./OdysseyThemeProvider.js";
|
|
17
17
|
import { OdysseyTranslationProvider } from "./OdysseyTranslationProvider.js";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
const OdysseyProvider =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
const OdysseyProvider = ({
|
|
20
|
+
children,
|
|
21
|
+
designTokensOverride,
|
|
22
|
+
emotionRoot,
|
|
23
|
+
shadowDomElement,
|
|
24
|
+
languageCode,
|
|
25
|
+
nonce,
|
|
26
|
+
stylisPlugins,
|
|
27
|
+
themeOverride,
|
|
28
|
+
translationOverrides
|
|
29
|
+
}) => _jsx(OdysseyCacheProvider, {
|
|
30
|
+
nonce: nonce,
|
|
31
|
+
emotionRoot: emotionRoot,
|
|
32
|
+
shadowDomElement: shadowDomElement,
|
|
33
|
+
stylisPlugins: stylisPlugins,
|
|
34
|
+
children: _jsx(OdysseyThemeProvider, {
|
|
35
|
+
designTokensOverride: designTokensOverride,
|
|
33
36
|
emotionRoot: emotionRoot,
|
|
34
37
|
shadowDomElement: shadowDomElement,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
children: _jsx(_ScopedCssBaseline, {
|
|
43
|
-
children: _jsx(OdysseyTranslationProvider, {
|
|
44
|
-
languageCode: languageCode,
|
|
45
|
-
translationOverrides: translationOverrides,
|
|
46
|
-
children: children
|
|
47
|
-
})
|
|
38
|
+
themeOverride: themeOverride,
|
|
39
|
+
withCache: false,
|
|
40
|
+
children: _jsx(_ScopedCssBaseline, {
|
|
41
|
+
children: _jsx(OdysseyTranslationProvider, {
|
|
42
|
+
languageCode: languageCode,
|
|
43
|
+
translationOverrides: translationOverrides,
|
|
44
|
+
children: children
|
|
48
45
|
})
|
|
49
46
|
})
|
|
50
|
-
})
|
|
51
|
-
};
|
|
47
|
+
})
|
|
48
|
+
});
|
|
52
49
|
const MemoizedThemeProvider = memo(OdysseyProvider);
|
|
53
50
|
export { MemoizedThemeProvider as OdysseyProvider };
|
|
54
51
|
//# sourceMappingURL=OdysseyProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyProvider.js","names":["memo","OdysseyCacheProvider","OdysseyThemeProvider","OdysseyTranslationProvider","jsx","_jsx","OdysseyProvider","
|
|
1
|
+
{"version":3,"file":"OdysseyProvider.js","names":["memo","OdysseyCacheProvider","OdysseyThemeProvider","OdysseyTranslationProvider","jsx","_jsx","OdysseyProvider","children","designTokensOverride","emotionRoot","shadowDomElement","languageCode","nonce","stylisPlugins","themeOverride","translationOverrides","withCache","_ScopedCssBaseline","MemoizedThemeProvider"],"sources":["../src/OdysseyProvider.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, ReactNode } from \"react\";\nimport { ScopedCssBaseline } from \"@mui/material\";\n\nimport {\n OdysseyCacheProvider,\n OdysseyCacheProviderProps,\n} from \"./OdysseyCacheProvider\";\nimport {\n OdysseyThemeProvider,\n OdysseyThemeProviderProps,\n} from \"./OdysseyThemeProvider\";\nimport {\n OdysseyTranslationProvider,\n OdysseyTranslationProviderProps,\n} from \"./OdysseyTranslationProvider\";\nimport { DefaultSupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nexport type OdysseyProviderProps<\n SupportedLanguages extends string = DefaultSupportedLanguages\n> = OdysseyCacheProviderProps &\n OdysseyThemeProviderProps &\n OdysseyTranslationProviderProps<SupportedLanguages> & {\n children: ReactNode;\n };\n\nconst OdysseyProvider = <SupportedLanguages extends string>({\n children,\n designTokensOverride,\n emotionRoot,\n shadowDomElement,\n languageCode,\n nonce,\n stylisPlugins,\n themeOverride,\n translationOverrides,\n}: OdysseyProviderProps<SupportedLanguages>) => (\n <OdysseyCacheProvider\n nonce={nonce}\n emotionRoot={emotionRoot}\n shadowDomElement={shadowDomElement}\n stylisPlugins={stylisPlugins}\n >\n <OdysseyThemeProvider\n designTokensOverride={designTokensOverride}\n emotionRoot={emotionRoot}\n shadowDomElement={shadowDomElement}\n themeOverride={themeOverride}\n withCache={false}\n >\n <ScopedCssBaseline>\n <OdysseyTranslationProvider<SupportedLanguages>\n languageCode={languageCode}\n translationOverrides={translationOverrides}\n >\n {children}\n </OdysseyTranslationProvider>\n </ScopedCssBaseline>\n </OdysseyThemeProvider>\n </OdysseyCacheProvider>\n);\n\nconst MemoizedThemeProvider = memo(OdysseyProvider) as typeof OdysseyProvider;\n\nexport { MemoizedThemeProvider as OdysseyProvider };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAmB,OAAO;AAAC,SAItCC,oBAAoB;AAAA,SAIpBC,oBAAoB;AAAA,SAIpBC,0BAA0B;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAa5B,MAAMC,eAAe,GAAGA,CAAoC;EAC1DC,QAAQ;EACRC,oBAAoB;EACpBC,WAAW;EACXC,gBAAgB;EAChBC,YAAY;EACZC,KAAK;EACLC,aAAa;EACbC,aAAa;EACbC;AACwC,CAAC,KACzCV,IAAA,CAACJ,oBAAoB;EACnBW,KAAK,EAAEA,KAAM;EACbH,WAAW,EAAEA,WAAY;EACzBC,gBAAgB,EAAEA,gBAAiB;EACnCG,aAAa,EAAEA,aAAc;EAAAN,QAAA,EAE7BF,IAAA,CAACH,oBAAoB;IACnBM,oBAAoB,EAAEA,oBAAqB;IAC3CC,WAAW,EAAEA,WAAY;IACzBC,gBAAgB,EAAEA,gBAAiB;IACnCI,aAAa,EAAEA,aAAc;IAC7BE,SAAS,EAAE,KAAM;IAAAT,QAAA,EAEjBF,IAAA,CAAAY,kBAAA;MAAAV,QAAA,EACEF,IAAA,CAACF,0BAA0B;QACzBQ,YAAY,EAAEA,YAAa;QAC3BI,oBAAoB,EAAEA,oBAAqB;QAAAR,QAAA,EAE1CA;MAAQ,CACiB;IAAC,CACZ;EAAC,CACA;AAAC,CACH,CACvB;AAED,MAAMW,qBAAqB,GAAGlB,IAAI,CAACM,eAAe,CAA2B;AAE7E,SAASY,qBAAqB,IAAIZ,eAAe"}
|
|
@@ -20,15 +20,14 @@ import { CacheProvider } from "@emotion/react";
|
|
|
20
20
|
import createCache from "@emotion/cache";
|
|
21
21
|
import { useUniqueAlphabeticalId } from "./useUniqueAlphabeticalId.js";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
const OdysseyThemeProvider =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} = _ref;
|
|
23
|
+
const OdysseyThemeProvider = ({
|
|
24
|
+
children,
|
|
25
|
+
designTokensOverride,
|
|
26
|
+
emotionRoot,
|
|
27
|
+
shadowDomElement,
|
|
28
|
+
themeOverride,
|
|
29
|
+
withCache = true
|
|
30
|
+
}) => {
|
|
32
31
|
const odysseyTokens = useMemo(() => ({
|
|
33
32
|
...Tokens,
|
|
34
33
|
...designTokensOverride
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyThemeProvider.js","names":["createTheme","ThemeProvider","MuiThemeProvider","memo","useMemo","deepmerge","createOdysseyMuiTheme","Tokens","OdysseyDesignTokensContext","CacheProvider","createCache","useUniqueAlphabeticalId","jsx","_jsx","OdysseyThemeProvider","
|
|
1
|
+
{"version":3,"file":"OdysseyThemeProvider.js","names":["createTheme","ThemeProvider","MuiThemeProvider","memo","useMemo","deepmerge","createOdysseyMuiTheme","Tokens","OdysseyDesignTokensContext","CacheProvider","createCache","useUniqueAlphabeticalId","jsx","_jsx","OdysseyThemeProvider","children","designTokensOverride","emotionRoot","shadowDomElement","themeOverride","withCache","odysseyTokens","odysseyTheme","customOdysseyTheme","uniqueAlphabeticalId","cache","container","key","prepend","nonce","window","cspNonce","speedy","value","theme","Provider","MemoizedOdysseyThemeProvider"],"sources":["../src/OdysseyThemeProvider.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 createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport { memo, ReactNode, useMemo } from \"react\";\n\nimport { ThemeOptions } from \"@mui/material\";\nimport { deepmerge } from \"@mui/utils\";\nimport { createOdysseyMuiTheme, DesignTokensOverride } from \"./theme\";\nimport * as Tokens from \"@okta/odyssey-design-tokens\";\nimport { OdysseyDesignTokensContext } from \"./OdysseyDesignTokensContext\";\nimport { CacheProvider } from \"@emotion/react\";\nimport createCache from \"@emotion/cache\";\nimport { useUniqueAlphabeticalId } from \"./useUniqueAlphabeticalId\";\n\nexport type OdysseyThemeProviderProps = {\n children: ReactNode;\n designTokensOverride?: DesignTokensOverride;\n emotionRoot?: HTMLStyleElement;\n shadowDomElement?: HTMLDivElement | HTMLElement | undefined;\n themeOverride?: ThemeOptions;\n withCache?: boolean;\n};\n\nconst OdysseyThemeProvider = ({\n children,\n designTokensOverride,\n emotionRoot,\n shadowDomElement,\n themeOverride,\n withCache = true,\n}: OdysseyThemeProviderProps) => {\n const odysseyTokens = useMemo(\n () => ({ ...Tokens, ...designTokensOverride }),\n [designTokensOverride]\n );\n const odysseyTheme = useMemo(\n () =>\n createOdysseyMuiTheme({\n odysseyTokens,\n shadowDomElement,\n }),\n [odysseyTokens, shadowDomElement]\n );\n\n const customOdysseyTheme = useMemo(\n () => themeOverride && createTheme(deepmerge(odysseyTheme, themeOverride)),\n [odysseyTheme, themeOverride]\n );\n\n const uniqueAlphabeticalId = useUniqueAlphabeticalId();\n\n const cache = useMemo(\n () =>\n createCache({\n ...(emotionRoot && { container: emotionRoot }),\n key: uniqueAlphabeticalId,\n prepend: true,\n nonce: window.cspNonce,\n speedy: false, // <-- Needs to be set to false when shadow-dom is used!! https://github.com/emotion-js/emotion/issues/2053#issuecomment-713429122\n }),\n [emotionRoot, uniqueAlphabeticalId]\n );\n\n if (withCache) {\n return (\n <CacheProvider value={cache}>\n <MuiThemeProvider theme={customOdysseyTheme ?? odysseyTheme}>\n <OdysseyDesignTokensContext.Provider value={odysseyTokens}>\n {children}\n </OdysseyDesignTokensContext.Provider>\n </MuiThemeProvider>\n </CacheProvider>\n );\n }\n return (\n <MuiThemeProvider theme={customOdysseyTheme ?? odysseyTheme}>\n <OdysseyDesignTokensContext.Provider value={odysseyTokens}>\n {children}\n </OdysseyDesignTokensContext.Provider>\n </MuiThemeProvider>\n );\n};\n\nconst MemoizedOdysseyThemeProvider = memo(OdysseyThemeProvider);\n\nexport { MemoizedOdysseyThemeProvider as OdysseyThemeProvider };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,WAAW,EACXC,aAAa,IAAIC,gBAAgB,QAC5B,sBAAsB;AAC7B,SAASC,IAAI,EAAaC,OAAO,QAAQ,OAAO;AAGhD,SAASC,SAAS,QAAQ,YAAY;AAAC,SAC9BC,qBAAqB;AAC9B,OAAO,KAAKC,MAAM,MAAM,6BAA6B;AAAC,SAC7CC,0BAA0B;AACnC,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,OAAOC,WAAW,MAAM,gBAAgB;AAAC,SAChCC,uBAAuB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAWhC,MAAMC,oBAAoB,GAAGA,CAAC;EAC5BC,QAAQ;EACRC,oBAAoB;EACpBC,WAAW;EACXC,gBAAgB;EAChBC,aAAa;EACbC,SAAS,GAAG;AACa,CAAC,KAAK;EAC/B,MAAMC,aAAa,GAAGjB,OAAO,CAC3B,OAAO;IAAE,GAAGG,MAAM;IAAE,GAAGS;EAAqB,CAAC,CAAC,EAC9C,CAACA,oBAAoB,CACvB,CAAC;EACD,MAAMM,YAAY,GAAGlB,OAAO,CAC1B,MACEE,qBAAqB,CAAC;IACpBe,aAAa;IACbH;EACF,CAAC,CAAC,EACJ,CAACG,aAAa,EAAEH,gBAAgB,CAClC,CAAC;EAED,MAAMK,kBAAkB,GAAGnB,OAAO,CAChC,MAAMe,aAAa,IAAInB,WAAW,CAACK,SAAS,CAACiB,YAAY,EAAEH,aAAa,CAAC,CAAC,EAC1E,CAACG,YAAY,EAAEH,aAAa,CAC9B,CAAC;EAED,MAAMK,oBAAoB,GAAGb,uBAAuB,CAAC,CAAC;EAEtD,MAAMc,KAAK,GAAGrB,OAAO,CACnB,MACEM,WAAW,CAAC;IACV,IAAIO,WAAW,IAAI;MAAES,SAAS,EAAET;IAAY,CAAC,CAAC;IAC9CU,GAAG,EAAEH,oBAAoB;IACzBI,OAAO,EAAE,IAAI;IACbC,KAAK,EAAEC,MAAM,CAACC,QAAQ;IACtBC,MAAM,EAAE;EACV,CAAC,CAAC,EACJ,CAACf,WAAW,EAAEO,oBAAoB,CACpC,CAAC;EAED,IAAIJ,SAAS,EAAE;IACb,OACEP,IAAA,CAACJ,aAAa;MAACwB,KAAK,EAAER,KAAM;MAAAV,QAAA,EAC1BF,IAAA,CAACX,gBAAgB;QAACgC,KAAK,EAAEX,kBAAkB,IAAID,YAAa;QAAAP,QAAA,EAC1DF,IAAA,CAACL,0BAA0B,CAAC2B,QAAQ;UAACF,KAAK,EAAEZ,aAAc;UAAAN,QAAA,EACvDA;QAAQ,CAC0B;MAAC,CACtB;IAAC,CACN,CAAC;EAEpB;EACA,OACEF,IAAA,CAACX,gBAAgB;IAACgC,KAAK,EAAEX,kBAAkB,IAAID,YAAa;IAAAP,QAAA,EAC1DF,IAAA,CAACL,0BAA0B,CAAC2B,QAAQ;MAACF,KAAK,EAAEZ,aAAc;MAAAN,QAAA,EACvDA;IAAQ,CAC0B;EAAC,CACtB,CAAC;AAEvB,CAAC;AAED,MAAMqB,4BAA4B,GAAGjC,IAAI,CAACW,oBAAoB,CAAC;AAE/D,SAASsB,4BAA4B,IAAItB,oBAAoB"}
|
|
@@ -25,12 +25,11 @@ const mergeBundleOverrides = (languageCode, translationOverrides) => {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
const formatLanguageCodeToHyphenated = languageCode => languageCode?.replaceAll("_", "-");
|
|
28
|
-
export const OdysseyTranslationProvider =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} = _ref;
|
|
28
|
+
export const OdysseyTranslationProvider = ({
|
|
29
|
+
children,
|
|
30
|
+
languageCode,
|
|
31
|
+
translationOverrides
|
|
32
|
+
}) => {
|
|
34
33
|
useEffect(() => {
|
|
35
34
|
const normalizedLanguageCode = formatLanguageCodeToHyphenated(languageCode);
|
|
36
35
|
const changeHtmlElementLanguageAttribute = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","getTypedObjectKeys","jsx","_jsx","odysseyI18nResourceKeysList","mergeBundleOverrides","languageCode","translationOverrides","translationStrings","translationStringOverrides","formatLanguageCodeToHyphenated","replaceAll","OdysseyTranslationProvider","
|
|
1
|
+
{"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","getTypedObjectKeys","jsx","_jsx","odysseyI18nResourceKeysList","mergeBundleOverrides","languageCode","translationOverrides","translationStrings","translationStringOverrides","formatLanguageCodeToHyphenated","replaceAll","OdysseyTranslationProvider","children","normalizedLanguageCode","changeHtmlElementLanguageAttribute","window","document","documentElement","setAttribute","changeLanguage","navigator","language","forEach","bundle","addResourceBundle"],"sources":["../src/OdysseyTranslationProvider.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 { ReactNode, useEffect } from \"react\";\n\nimport { DefaultSupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nimport { i18n, defaultNS, resources } from \"./i18n\";\nimport { I18nextProvider } from \"react-i18next\";\nimport { getTypedObjectKeys } from \"./getTypedObjectKeys\";\n\nexport type OdysseyI18nResourceKeys = (typeof resources)[\"en\"];\nexport const odysseyI18nResourceKeysList = getTypedObjectKeys(resources[\"en\"]);\n\nexport type TranslationOverrides<\n SupportedLanguages extends string = DefaultSupportedLanguages\n> = Record<SupportedLanguages, Partial<OdysseyI18nResourceKeys>>;\n\nconst mergeBundleOverrides = <SupportedLanguages extends string>(\n languageCode: SupportedLanguages,\n translationOverrides: TranslationOverrides<SupportedLanguages>\n) => {\n const translationStrings = resources[languageCode] || {};\n const translationStringOverrides = translationOverrides[languageCode];\n return {\n ...translationStrings,\n ...translationStringOverrides,\n };\n};\n\nexport type OdysseyTranslationProviderProps<\n SupportedLanguages extends string = DefaultSupportedLanguages\n> = {\n children: ReactNode;\n languageCode?: SupportedLanguages | DefaultSupportedLanguages;\n translationOverrides?: TranslationOverrides<SupportedLanguages>;\n};\n\nconst formatLanguageCodeToHyphenated = <SupportedLanguages extends string>(\n languageCode: OdysseyTranslationProviderProps<SupportedLanguages>[\"languageCode\"]\n) => languageCode?.replaceAll(\"_\", \"-\");\n\nexport const OdysseyTranslationProvider = <SupportedLanguages extends string>({\n children,\n languageCode,\n translationOverrides,\n}: OdysseyTranslationProviderProps<SupportedLanguages>) => {\n useEffect(() => {\n const normalizedLanguageCode =\n formatLanguageCodeToHyphenated<SupportedLanguages>(languageCode);\n\n const changeHtmlElementLanguageAttribute = () => {\n window.document.documentElement.setAttribute(\n \"lang\",\n normalizedLanguageCode || \"en\"\n );\n };\n // Defaults to the browser's language if available otherwise `en` will be used\n i18n.changeLanguage(\n languageCode || window.navigator.language,\n changeHtmlElementLanguageAttribute\n );\n }, [languageCode]);\n\n useEffect(() => {\n if (translationOverrides) {\n getTypedObjectKeys(translationOverrides).forEach((language) => {\n const bundle = mergeBundleOverrides<SupportedLanguages>(\n language,\n translationOverrides\n );\n i18n.addResourceBundle(language, defaultNS, bundle);\n });\n }\n }, [translationOverrides]);\n\n return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAoBA,SAAS,QAAQ,OAAO;AAAC,SAIpCC,IAAI,EAAEC,SAAS,EAAEC,SAAS;AACnC,SAASC,eAAe,QAAQ,eAAe;AAAC,SACvCC,kBAAkB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG3B,OAAO,MAAMC,2BAA2B,GAAGH,kBAAkB,CAACF,SAAS,CAAC,IAAI,CAAC,CAAC;AAM9E,MAAMM,oBAAoB,GAAGA,CAC3BC,YAAgC,EAChCC,oBAA8D,KAC3D;EACH,MAAMC,kBAAkB,GAAGT,SAAS,CAACO,YAAY,CAAC,IAAI,CAAC,CAAC;EACxD,MAAMG,0BAA0B,GAAGF,oBAAoB,CAACD,YAAY,CAAC;EACrE,OAAO;IACL,GAAGE,kBAAkB;IACrB,GAAGC;EACL,CAAC;AACH,CAAC;AAUD,MAAMC,8BAA8B,GAClCJ,YAAiF,IAC9EA,YAAY,EAAEK,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;AAEvC,OAAO,MAAMC,0BAA0B,GAAGA,CAAoC;EAC5EC,QAAQ;EACRP,YAAY;EACZC;AACmD,CAAC,KAAK;EACzDX,SAAS,CAAC,MAAM;IACd,MAAMkB,sBAAsB,GAC1BJ,8BAA8B,CAAqBJ,YAAY,CAAC;IAElE,MAAMS,kCAAkC,GAAGA,CAAA,KAAM;MAC/CC,MAAM,CAACC,QAAQ,CAACC,eAAe,CAACC,YAAY,CAC1C,MAAM,EACNL,sBAAsB,IAAI,IAC5B,CAAC;IACH,CAAC;IAEDjB,IAAI,CAACuB,cAAc,CACjBd,YAAY,IAAIU,MAAM,CAACK,SAAS,CAACC,QAAQ,EACzCP,kCACF,CAAC;EACH,CAAC,EAAE,CAACT,YAAY,CAAC,CAAC;EAElBV,SAAS,CAAC,MAAM;IACd,IAAIW,oBAAoB,EAAE;MACxBN,kBAAkB,CAACM,oBAAoB,CAAC,CAACgB,OAAO,CAAED,QAAQ,IAAK;QAC7D,MAAME,MAAM,GAAGnB,oBAAoB,CACjCiB,QAAQ,EACRf,oBACF,CAAC;QACDV,IAAI,CAAC4B,iBAAiB,CAACH,QAAQ,EAAExB,SAAS,EAAE0B,MAAM,CAAC;MACrD,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAACjB,oBAAoB,CAAC,CAAC;EAE1B,OAAOJ,IAAA,CAACH,eAAe;IAACH,IAAI,EAAEA,IAAK;IAAAgB,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAClE,CAAC"}
|
package/dist/PasswordField.js
CHANGED
|
@@ -18,32 +18,31 @@ import { Field } from "./Field.js";
|
|
|
18
18
|
import { useTranslation } from "react-i18next";
|
|
19
19
|
import { getControlState, useInputValues } from "./inputUtils.js";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
-
const PasswordField = forwardRef((
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} = _ref;
|
|
21
|
+
const PasswordField = forwardRef(({
|
|
22
|
+
ariaDescribedBy,
|
|
23
|
+
autoCompleteType,
|
|
24
|
+
defaultValue,
|
|
25
|
+
errorMessage,
|
|
26
|
+
errorMessageList,
|
|
27
|
+
hasInitialFocus,
|
|
28
|
+
hint,
|
|
29
|
+
id: idOverride,
|
|
30
|
+
inputRef,
|
|
31
|
+
isDisabled = false,
|
|
32
|
+
isFullWidth = false,
|
|
33
|
+
isOptional = false,
|
|
34
|
+
hasShowPassword = true,
|
|
35
|
+
isReadOnly,
|
|
36
|
+
label,
|
|
37
|
+
name: nameOverride,
|
|
38
|
+
onChange: onChangeProp,
|
|
39
|
+
onFocus,
|
|
40
|
+
onBlur,
|
|
41
|
+
placeholder,
|
|
42
|
+
testId,
|
|
43
|
+
translate,
|
|
44
|
+
value
|
|
45
|
+
}, ref) => {
|
|
47
46
|
const {
|
|
48
47
|
t
|
|
49
48
|
} = useTranslation();
|
|
@@ -71,48 +70,45 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
71
70
|
const onChange = useCallback(event => {
|
|
72
71
|
onChangeProp?.(event);
|
|
73
72
|
}, [onChangeProp]);
|
|
74
|
-
const renderFieldComponent = useCallback(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
type: inputType
|
|
114
|
-
});
|
|
115
|
-
}, [autoCompleteType, hasInitialFocus, inputValues, t, togglePasswordVisibility, inputType, nameOverride, onChange, onFocus, onBlur, placeholder, isOptional, isReadOnly, hasShowPassword, ref, testId, translate]);
|
|
73
|
+
const renderFieldComponent = useCallback(({
|
|
74
|
+
ariaDescribedBy,
|
|
75
|
+
errorMessageElementId,
|
|
76
|
+
id,
|
|
77
|
+
labelElementId
|
|
78
|
+
}) => _jsx(_InputBase, {
|
|
79
|
+
...inputValues,
|
|
80
|
+
"aria-describedby": ariaDescribedBy,
|
|
81
|
+
autoComplete: inputType === "password" ? autoCompleteType : "off",
|
|
82
|
+
autoFocus: hasInitialFocus,
|
|
83
|
+
endAdornment: hasShowPassword && _jsx(_InputAdornment, {
|
|
84
|
+
position: "end",
|
|
85
|
+
children: _jsx(_IconButton, {
|
|
86
|
+
"aria-controls": id,
|
|
87
|
+
"aria-label": inputType === "password" ? t("passwordfield.icon.label.show") : t("passwordfield.icon.label.hide"),
|
|
88
|
+
"aria-pressed": inputType === "text",
|
|
89
|
+
onClick: togglePasswordVisibility,
|
|
90
|
+
children: inputType === "password" ? _jsx(ShowIcon, {}) : _jsx(HideIcon, {})
|
|
91
|
+
})
|
|
92
|
+
}),
|
|
93
|
+
id: id,
|
|
94
|
+
inputProps: {
|
|
95
|
+
"aria-errormessage": errorMessageElementId,
|
|
96
|
+
"aria-labelledby": labelElementId,
|
|
97
|
+
"data-se": testId,
|
|
98
|
+
role: "textbox"
|
|
99
|
+
},
|
|
100
|
+
inputRef: localInputRef,
|
|
101
|
+
name: nameOverride ?? id,
|
|
102
|
+
onChange: onChange,
|
|
103
|
+
onFocus: onFocus,
|
|
104
|
+
onBlur: onBlur,
|
|
105
|
+
placeholder: placeholder,
|
|
106
|
+
readOnly: isReadOnly,
|
|
107
|
+
ref: ref,
|
|
108
|
+
required: !isOptional,
|
|
109
|
+
translate: translate,
|
|
110
|
+
type: inputType
|
|
111
|
+
}), [autoCompleteType, hasInitialFocus, inputValues, t, togglePasswordVisibility, inputType, nameOverride, onChange, onFocus, onBlur, placeholder, isOptional, isReadOnly, hasShowPassword, ref, testId, translate]);
|
|
116
112
|
return _jsx(Field, {
|
|
117
113
|
ariaDescribedBy: ariaDescribedBy,
|
|
118
114
|
errorMessage: errorMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useImperativeHandle","useRef","useState","ShowIcon","HideIcon","Field","useTranslation","getControlState","useInputValues","jsx","_jsx","PasswordField","_ref","ref","ariaDescribedBy","autoCompleteType","defaultValue","errorMessage","errorMessageList","hasInitialFocus","hint","id","idOverride","inputRef","isDisabled","isFullWidth","isOptional","hasShowPassword","isReadOnly","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","placeholder","testId","translate","value","t","inputType","setInputType","togglePasswordVisibility","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","localInputRef","focus","event","renderFieldComponent","_ref2","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 useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { ShowIcon, HideIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { HtmlProps } from \"./HtmlProps\";\nimport { useTranslation } from \"react-i18next\";\nimport { FocusHandle, 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 ref forwarded to the TextField\n */\n inputRef?: React.RefObject<FocusHandle>;\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 HtmlProps;\n\nconst PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(\n (\n {\n ariaDescribedBy,\n autoCompleteType,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasInitialFocus,\n hint,\n id: idOverride,\n inputRef,\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 translate,\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 localInputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(\n inputRef,\n () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n },\n []\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 endAdornment={\n hasShowPassword && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-controls={id}\n aria-label={\n inputType === \"password\"\n ? t(\"passwordfield.icon.label.show\")\n : t(\"passwordfield.icon.label.hide\")\n }\n aria-pressed={inputType === \"text\"}\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 \"data-se\": testId,\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 inputRef={localInputRef}\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 translate={translate}\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 translate,\n ]\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\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,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,OAAO;AAAC,SAENC,QAAQ,EAAEC,QAAQ;AAAA,SAClBC,KAAK;AAGd,SAASC,cAAc,QAAQ,eAAe;AAAC,SACzBC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAoDrD,MAAMC,aAAa,GAAGd,UAAU,CAC9B,CAAAe,IAAA,EA0BEC,GAAG,KACA;EAAA,IA1BH;IACEC,eAAe;IACfC,gBAAgB;IAChBC,YAAY;IACZC,YAAY;IACZC,gBAAgB;IAChBC,eAAe;IACfC,IAAI;IACJC,EAAE,EAAEC,UAAU;IACdC,QAAQ;IACRC,UAAU,GAAG,KAAK;IAClBC,WAAW,GAAG,KAAK;IACnBC,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,SAAS;IACTC;EACF,CAAC,GAAA3B,IAAA;EAGD,MAAM;IAAE4B;EAAE,CAAC,GAAGlC,cAAc,CAAC,CAAC;EAC9B,MAAM,CAACmC,SAAS,EAAEC,YAAY,CAAC,GAAGxC,QAAQ,CAAC,UAAU,CAAC;EAEtD,MAAMyC,wBAAwB,GAAG5C,WAAW,C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U,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBC,UAAU,EAAEA,UAAW;IACvBG,KAAK,EAAEA,KAAM;IACbwB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMoB,qBAAqB,GAAG3E,IAAI,CAACa,aAAa,CAAC;AACjD8D,qBAAqB,CAACC,WAAW,GAAG,eAAe;AAEnD,SAASD,qBAAqB,IAAI9D,aAAa"}
|
|
1
|
+
{"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useImperativeHandle","useRef","useState","ShowIcon","HideIcon","Field","useTranslation","getControlState","useInputValues","jsx","_jsx","PasswordField","ariaDescribedBy","autoCompleteType","defaultValue","errorMessage","errorMessageList","hasInitialFocus","hint","id","idOverride","inputRef","isDisabled","isFullWidth","isOptional","hasShowPassword","isReadOnly","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","placeholder","testId","translate","value","ref","t","inputType","setInputType","togglePasswordVisibility","controlledStateRef","controlledValue","uncontrolledValue","inputValues","controlState","current","localInputRef","focus","event","renderFieldComponent","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 useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { ShowIcon, HideIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { HtmlProps } from \"./HtmlProps\";\nimport { useTranslation } from \"react-i18next\";\nimport { FocusHandle, 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 ref forwarded to the TextField\n */\n inputRef?: React.RefObject<FocusHandle>;\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 HtmlProps;\n\nconst PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(\n (\n {\n ariaDescribedBy,\n autoCompleteType,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasInitialFocus,\n hint,\n id: idOverride,\n inputRef,\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 translate,\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 localInputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(\n inputRef,\n () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n },\n []\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 endAdornment={\n hasShowPassword && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-controls={id}\n aria-label={\n inputType === \"password\"\n ? t(\"passwordfield.icon.label.show\")\n : t(\"passwordfield.icon.label.hide\")\n }\n aria-pressed={inputType === \"text\"}\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 \"data-se\": testId,\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 inputRef={localInputRef}\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 translate={translate}\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 translate,\n ]\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\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,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,OAAO;AAAC,SAENC,QAAQ,EAAEC,QAAQ;AAAA,SAClBC,KAAK;AAGd,SAASC,cAAc,QAAQ,eAAe;AAAC,SACzBC,eAAe,EAAEC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAoDrD,MAAMC,aAAa,GAAGd,UAAU,CAC9B,CACE;EACEe,eAAe;EACfC,gBAAgB;EAChBC,YAAY;EACZC,YAAY;EACZC,gBAAgB;EAChBC,eAAe;EACfC,IAAI;EACJC,EAAE,EAAEC,UAAU;EACdC,QAAQ;EACRC,UAAU,GAAG,KAAK;EAClBC,WAAW,GAAG,KAAK;EACnBC,UAAU,GAAG,KAAK;EAClBC,eAAe,GAAG,IAAI;EACtBC,UAAU;EACVC,KAAK;EACLC,IAAI,EAAEC,YAAY;EAClBC,QAAQ,EAAEC,YAAY;EACtBC,OAAO;EACPC,MAAM;EACNC,WAAW;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,eAAe,EAAEA,eAAgB;IACjCG,YAAY,EAAEA,YAAa;IAC3BC,gBAAgB,EAAEA,gBAAiB;IACnCqD,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACfpD,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBC,UAAU,EAAEA,UAAW;IACvBG,KAAK,EAAEA,KAAM;IACbyB,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMmB,qBAAqB,GAAGzE,IAAI,CAACa,aAAa,CAAC;AACjD4D,qBAAqB,CAACC,WAAW,GAAG,eAAe;AAEnD,SAASD,qBAAqB,IAAI5D,aAAa"}
|
package/dist/Radio.js
CHANGED
|
@@ -13,20 +13,19 @@ import _Radio from "@mui/material/Radio";
|
|
|
13
13
|
*/
|
|
14
14
|
import { memo, useCallback, useRef, useImperativeHandle } from "react";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
const Radio =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} = _ref;
|
|
16
|
+
const Radio = ({
|
|
17
|
+
inputRef,
|
|
18
|
+
isChecked,
|
|
19
|
+
isDisabled,
|
|
20
|
+
isInvalid,
|
|
21
|
+
label,
|
|
22
|
+
name,
|
|
23
|
+
testId,
|
|
24
|
+
translate,
|
|
25
|
+
value,
|
|
26
|
+
onChange: onChangeProp,
|
|
27
|
+
onBlur: onBlurProp
|
|
28
|
+
}) => {
|
|
30
29
|
const localInputRef = useRef(null);
|
|
31
30
|
useImperativeHandle(inputRef, () => {
|
|
32
31
|
return {
|
package/dist/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","names":["memo","useCallback","useRef","useImperativeHandle","jsx","_jsx","Radio","
|
|
1
|
+
{"version":3,"file":"Radio.js","names":["memo","useCallback","useRef","useImperativeHandle","jsx","_jsx","Radio","inputRef","isChecked","isDisabled","isInvalid","label","name","testId","translate","value","onChange","onChangeProp","onBlur","onBlurProp","localInputRef","focus","current","event","checked","_FormControlLabel","className","control","_Radio","inputProps","disabled","MemoizedRadio","displayName"],"sources":["../src/Radio.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 FormControlLabel,\n FormControlLabelProps as MuiFormControlLabelProps,\n Radio as MuiRadio,\n RadioProps as MuiRadioProps,\n} from \"@mui/material\";\nimport { memo, useCallback, useRef, useImperativeHandle } from \"react\";\n\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { HtmlProps } from \"./HtmlProps\";\nimport { FocusHandle } from \"./inputUtils\";\n\nexport type RadioProps = {\n /**\n * The ref forwarded to the Radio\n */\n inputRef?: React.RefObject<FocusHandle>;\n /**\n * If `true`, the Radio is selected\n */\n isChecked?: boolean;\n /**\n * If `true`, the Radio has an invalid value\n */\n isInvalid?: boolean;\n /**\n * The label text for the Radio\n */\n label: string;\n /**\n * The value attribute of the Radio\n */\n value: string;\n /**\n * Callback fired when the state is changed. Provides event and checked value.\n */\n onChange?: MuiRadioProps[\"onChange\"];\n /**\n * Callback fired when the blur event happens. Provides event value.\n */\n onBlur?: MuiFormControlLabelProps[\"onBlur\"];\n} & Pick<FieldComponentProps, \"isDisabled\" | \"name\"> &\n HtmlProps;\n\nconst Radio = ({\n inputRef,\n isChecked,\n isDisabled,\n isInvalid,\n label,\n name,\n testId,\n translate,\n value,\n onChange: onChangeProp,\n onBlur: onBlurProp,\n}: RadioProps) => {\n const localInputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(\n inputRef,\n () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n },\n []\n );\n\n const onChange = useCallback<NonNullable<MuiRadioProps[\"onChange\"]>>(\n (event, checked) => {\n onChangeProp?.(event, checked);\n },\n [onChangeProp]\n );\n\n const onBlur = useCallback<NonNullable<MuiFormControlLabelProps[\"onBlur\"]>>(\n (event) => {\n onBlurProp?.(event);\n },\n [onBlurProp]\n );\n\n return (\n <FormControlLabel\n checked={isChecked}\n className={isInvalid ? \"Mui-error\" : \"\"}\n control={\n <MuiRadio\n inputProps={{\n \"data-se\": testId,\n }}\n inputRef={localInputRef}\n onChange={onChange}\n />\n }\n disabled={isDisabled}\n label={label}\n name={name}\n translate={translate}\n value={value}\n onBlur={onBlur}\n />\n );\n};\n\nconst MemoizedRadio = memo(Radio);\nMemoizedRadio.displayName = \"Radio\";\n\nexport { MemoizedRadio as Radio };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA,SAASA,IAAI,EAAEC,WAAW,EAAEC,MAAM,EAAEC,mBAAmB,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAsCvE,MAAMC,KAAK,GAAGA,CAAC;EACbC,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVC,SAAS;EACTC,KAAK;EACLC,IAAI;EACJC,MAAM;EACNC,SAAS;EACTC,KAAK;EACLC,QAAQ,EAAEC,YAAY;EACtBC,MAAM,EAAEC;AACE,CAAC,KAAK;EAChB,MAAMC,aAAa,GAAGlB,MAAM,CAAmB,IAAI,CAAC;EACpDC,mBAAmB,CACjBI,QAAQ,EACR,MAAM;IACJ,OAAO;MACLc,KAAK,EAAEA,CAAA,K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